3 files modified
9 files added
1 files deleted
| | |
| | | const ROLE_ATTACK = 'att'; |
| | | const ROLE_DEFEND = 'def'; |
| | | |
| | | protected $sites = [ |
| | | protected $maps = [ |
| | | 'Bank' => [ |
| | | 'CEO Office / Executive Lounge', |
| | | 'Open Area / Staff Room', |
| | |
| | | /** |
| | | * @return array |
| | | */ |
| | | public function getSites(): array |
| | | public function getMaps(): array |
| | | { |
| | | return $this->sites; |
| | | return $this->maps; |
| | | } |
| | | |
| | | public function getMapNames() |
| | | { |
| | | return array_keys($this->maps); |
| | | } |
| | | |
| | | /** |
| | |
| | | public function getCurrentMap(): string |
| | | { |
| | | return $this->currentMap; |
| | | } |
| | | |
| | | public function getCurrentSites(): array |
| | | { |
| | | return $this->maps[$this->currentMap]; |
| | | } |
| | | |
| | | /** |
| | |
| | | |
| | | private function validMap($mapName) |
| | | { |
| | | $mapList = array_keys($this->sites); |
| | | $mapList = array_keys($this->maps); |
| | | return in_array($mapName, $mapList); |
| | | } |
| | | |
| | | private function validSite($siteName) |
| | | { |
| | | return in_array($siteName, $this->sites[$this->currentMap]); |
| | | return in_array($siteName, $this->maps[$this->currentMap]); |
| | | } |
| | | |
| | | public function setCurrentMap(string $mapName) |
New file |
| | |
| | | <?php |
| | | |
| | | |
| | | namespace EOG\Models; |
| | | |
| | | |
| | | class TeamList |
| | | { |
| | | /** |
| | | * @var string[] Csapatok listája (előtöltve) |
| | | */ |
| | | protected $teams = []; |
| | | |
| | | private $requiredRawFields = ['name', 'seed', 'status']; |
| | | |
| | | public function fromJson(string $jsonString) |
| | | { |
| | | $rawData = json_decode($jsonString, true); |
| | | |
| | | if ($rawData === null) return false; |
| | | |
| | | if (!is_array($rawData)) { |
| | | return false; |
| | | } |
| | | |
| | | $this->teams = []; |
| | | |
| | | foreach ($rawData as $key => $team) { |
| | | $rawKeys = array_keys($team); |
| | | if (count(array_intersect($rawKeys, $this->requiredRawFields)) != 3) { |
| | | continue; |
| | | } |
| | | |
| | | if ($team['status'] == 'checkedIn') { |
| | | $this->teams[] = $team; |
| | | } |
| | | } |
| | | |
| | | return (bool)count($this->teams); |
| | | } |
| | | |
| | | public function getTeamNames() |
| | | { |
| | | return array_column($this->teams, 'name'); |
| | | } |
| | | |
| | | /** |
| | | * @return string[] |
| | | */ |
| | | public function getTeams(): array |
| | | { |
| | | return $this->teams; |
| | | } |
| | | |
| | | /** |
| | | * @param string[] $teams |
| | | * @return TeamList |
| | | */ |
| | | public function setTeams(array $teams): TeamList |
| | | { |
| | | $this->teams = $teams; |
| | | |
| | | return $this; |
| | | } |
| | | |
| | | public function getJson() |
| | | { |
| | | return json_encode($this->teams); |
| | | } |
| | | } |
| | |
| | | $loader = new FilesystemLoader($fileSystemPaths); |
| | | } |
| | | |
| | | $twigEnvironmentOptions['cache'] = static::CACHE_DIR; |
| | | //$twigEnvironmentOptions['cache'] = static::CACHE_DIR; |
| | | $twigEnvironmentOptions['auto_reload'] = true; |
| | | |
| | | if (IS_DEV) |
New file |
| | |
| | | <?php |
| | | |
| | | ini_set('display_errors', E_ALL); |
| | | |
| | | include "vendor/autoload.php"; |
| | | |
| | | define('IS_DEV', true); |
| | | |
| | | define('SITE_ROOT', dirname(__DIR__)); |
| | | define('OVERLAY_DIR', dirname(SITE_ROOT) . '/overlays/'); |
| | | |
| | | define('STRIPE_JSON', OVERLAY_DIR . 'last.json'); |
| | | define('TEAMS_JSON', OVERLAY_DIR . 'teams.json'); |
| | | define('HISTORY_JSON', OVERLAY_DIR . 'history.json'); |
| | | |
| | | $twig = \EOG\Utils\TwigFactory::getEnvironment(SITE_ROOT . '/templates/'); |
New file |
| | |
| | | <?php |
| | | include_once "common/base.php"; |
| | | |
| | | $s = new \EOG\Models\Stripe(); |
| | | |
| | | if (file_exists(STRIPE_JSON)) { |
| | | $raw_json = file_get_contents(STRIPE_JSON); |
| | | $stateArray = json_decode($raw_json, true); |
| | | if (is_array($stateArray)) { |
| | | $s->loadFromArray($stateArray); |
| | | } |
| | | } |
| | | |
| | | $history = new \EOG\Models\MatchHistory(); |
| | | |
| | | if (file_exists(HISTORY_JSON)) { |
| | | $raw_json = file_get_contents(HISTORY_JSON); |
| | | $stateArray = json_decode($raw_json, true); |
| | | if (is_array($stateArray)) { |
| | | $history->loadState($stateArray); |
| | | } |
| | | } |
| | |
| | | <?php |
| | | ini_set('display_errors', E_ALL); |
| | | |
| | | include "vendor/autoload.php"; |
| | | |
| | | define('IS_DEV', (!isset($_SERVER['HTTP_HOST']))); |
| | | define('SITE_ROOT', __DIR__); |
| | | |
| | | if (IS_DEV) |
| | | { |
| | | define('OVERLAY_DIR', dirname(__DIR__) . '/esl-overlay/'); |
| | | } |
| | | else |
| | | { |
| | | define('OVERLAY_DIR', dirname(__DIR__) . '/overlays/'); |
| | | } |
| | | |
| | | $last_json = OVERLAY_DIR . 'last.json'; |
| | | |
| | | $twig = \EOG\Utils\TwigFactory::getEnvironment(SITE_ROOT); |
| | | include_once "common/base.php"; |
| | | |
| | | $s = new \EOG\Models\Stripe(); |
| | | |
| | | if (!empty($_POST['stripe'])) |
| | | { |
| | | $s->loadFromArray($_POST['stripe']); |
| | | if (!empty($_POST['stripe'])) { |
| | | $s->loadFromArray($_POST['stripe']); |
| | | |
| | | if (!empty($s->getState())) |
| | | { |
| | | file_put_contents($last_json, $s->getJson()); |
| | | } |
| | | if (!empty($s->getState())) { |
| | | file_put_contents(STRIPE_JSON, $s->getJson()); |
| | | } |
| | | |
| | | $s->setClass('simple'); |
| | | $html_content = $twig->render('templates/overlay-base.twig', ['stripe' => $s]); |
| | | file_put_contents(OVERLAY_DIR . 'simple.html', $html_content); |
| | | $s->setClass('simple'); |
| | | $html_content = $twig->render('overlay-base.twig', ['stripe' => $s]); |
| | | file_put_contents(OVERLAY_DIR . 'simple.html', $html_content); |
| | | |
| | | $s->setClass('team'); |
| | | $html_content = $twig->render('templates/overlay-base.twig', ['stripe' => $s]); |
| | | file_put_contents(OVERLAY_DIR . 'team.html', $html_content); |
| | | $s->setClass('team'); |
| | | $html_content = $twig->render('overlay-base.twig', ['stripe' => $s]); |
| | | file_put_contents(OVERLAY_DIR . 'team.html', $html_content); |
| | | |
| | | $s->setClass('team-ban'); |
| | | $html_content = $twig->render('templates/overlay-base.twig', ['stripe' => $s]); |
| | | file_put_contents(OVERLAY_DIR . 'team-ban.html', $html_content); |
| | | $s->setClass('team-ban'); |
| | | $html_content = $twig->render('overlay-base.twig', ['stripe' => $s]); |
| | | file_put_contents(OVERLAY_DIR . 'team-ban.html', $html_content); |
| | | |
| | | } else { |
| | | if (file_exists(STRIPE_JSON)) { |
| | | $raw_json = file_get_contents(STRIPE_JSON); |
| | | $stateArray = json_decode($raw_json, true); |
| | | if (is_array($stateArray)) { |
| | | $s->loadFromArray($stateArray); |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | if (file_exists($last_json)) |
| | | { |
| | | $raw_json = file_get_contents($last_json); |
| | | $stateArray = json_decode($raw_json, true); |
| | | if (is_array($stateArray)) |
| | | { |
| | | $s->loadFromArray($stateArray); |
| | | } |
| | | } |
| | | |
| | | $teams = new \EOG\Models\TeamList(); |
| | | |
| | | if (file_exists(TEAMS_JSON)) { |
| | | $teams->fromJson(file_get_contents(TEAMS_JSON)); |
| | | } |
| | | |
| | | $var = [ |
| | | 'stripe' => $s, |
| | | 'operators' => $s->getOperators(), |
| | | 'post' => !empty($_POST['stripe']) |
| | | 'stripe' => $s, |
| | | 'teamNames' => $teams->getTeamNames(), |
| | | 'operators' => $s->getOperators(), |
| | | 'post' => !empty($_POST['stripe']) |
| | | ]; |
| | | echo $twig->render('templates/admin/form.twig', $var); |
| | | |
| | | echo $twig->render('admin/stripe-form.twig', $var); |
| | | |
New file |
| | |
| | | <?php |
| | | include_once "common/history-base.php"; |
| | | |
| | | $var = [ |
| | | 'stripe' => $s, |
| | | 'post' => !empty($_POST['stripe']), |
| | | 'history' => $history, |
| | | ]; |
| | | |
| | | echo $twig->render('admin/history.twig', $var); |
New file |
| | |
| | | <?php |
| | | include_once "common/history-base.php"; |
| | | |
| | | |
| | | //validate & store as JSON |
New file |
| | |
| | | <?php |
| | | |
| | | include_once "common/base.php"; |
| | | |
| | | if (empty($_POST['json'])) { |
| | | header('Location: /generator/form.php', true, 302); |
| | | } |
| | | $teams = new \EOG\Models\TeamList(); |
| | | |
| | | $success = false; |
| | | |
| | | if ($teams->fromJson($_POST['json'])) { |
| | | $success = file_put_contents(OVERLAY_DIR . 'teams.json', $teams->getJson()); |
| | | } |
| | | |
| | | if ($success) { |
| | | header('Location: /generator/form.php', true, 302); |
| | | } else { |
| | | echo "Szar van a palacsintában"; |
| | | } |
New file |
| | |
| | | {% set classes = [ 'btn btn-outline-secondary', 'btn btn-outline-success', 'btn btn-outline-danger', 'btn btn-outline-warning', 'btn btn-outline-info', 'btn btn-outline-light', 'btn btn-outline-dark', 'btn btn-outline-link', 'btn btn-outline-primary'] %} |
| | | {% set activeClasses = [ 'btn btn-secondary', 'btn btn-success', 'btn btn-danger', 'btn btn-warning', 'btn btn-info', 'btn btn-light', 'btn btn-dark', 'btn btn-link', 'btn btn-primary'] %} |
| | | |
| | | <div class="form-row"> |
| | | {% for site in history.getCurrentSites %} |
| | | <button class="{{ cycle(classes, loop.index0)}}" id="r_{{ loop.parent.loop.index0 }}_b_{{ loop.index0 }}" |
| | | data-outline="{{ cycle(classes, loop.index0)}}" data-selected="{{ cycle(activeClasses, loop.index0)}}" onclick="return false;">{{ site }}</button> |
| | | {% endfor %} |
| | | </div> |
| | | {{ dump(round) }} |
New file |
| | |
| | | {% extends "admin/html-skeleton.twig" %} |
| | | {% block body %} |
| | | <form action="/generator/match-history.php" method="post"> |
| | | <select name="currentMap" id="currentMap" onchange="updateSites()"> |
| | | {% for map in history.getMapNames %} |
| | | <option value="{{ map }}" {{ history.getCurrentMap == map ? "selected" }}>{{ map }}</option> |
| | | {% endfor %} |
| | | </select> |
| | | <div class="form-group"> |
| | | <pre> |
| | | {% for round in history %} |
| | | {% include "admin/history-round.twig" %} |
| | | {% endfor %} |
| | | </pre> |
| | | </div> |
| | | </form> |
| | | {% endblock %} |
| | | |
| | | {% block lazyload %} |
| | | {{ parent() }} |
| | | <script type="text/javascript"> |
| | | var maps = {{ history.getMaps|json_encode|raw }} |
| | | function updateSites() { |
| | | var currentMap = document.getElementById('currentMap').value; |
| | | console.log(maps[currentMap]); |
| | | } |
| | | </script> |
| | | {% endblock %} |
New file |
| | |
| | | {% extends "admin/html-skeleton.twig" %} |
| | | {% block body %} |
| | | <form action="/generator/form.php" method="post"> |
| | | <input type="hidden" name="stripe[class]" value="team-ban"/> |
| | | |
| | | <div class="form-group"> |
| | | <div class="form-row"> |
| | | <div class="col-md-8 mb-3"> |
| | | <label for="validationServer01">Kupa neve</label> |
| | | <input type="text" name="stripe[cup][name]" class="form-control" id="validationServer01" |
| | | placeholder="Pld.: 5on5 Bomb Cup" value="{{ stripe.cup.name }}" required> |
| | | </div> |
| | | <div class="col-md-2 mb-3"> |
| | | <label for="validationServer02">Kupa sorszám</label> |
| | | <input type="text" name="stripe[cup][number]" class="form-control" id="validationServer02" |
| | | placeholder="Pld.: #654" |
| | | value="{{ stripe.cup.number }}" required> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | <div class="form-group"> |
| | | <div class="form-row"> |
| | | <label for="teamname">Csapat gyorsfeltöltés:</label> |
| | | <select id="teamname"> |
| | | {% for teamName in teamNames %} |
| | | <option value="{{ teamName }}">{{ teamName }}</option> |
| | | {% endfor %} |
| | | </select> |
| | | <button class="btn btn-primary" |
| | | title="Legyen az itt kiválasztott a kék csapat" |
| | | onclick="$('#team_blue_name').val($('#teamname').val()); return false;">Legyen kék</button> |
| | | |
| | | <button class="btn btn-warning" |
| | | title="Csapat színcsere" |
| | | onclick="$('#team_orange_name').val($('#teamname').val()); return false;">Legyen narancs</button> |
| | | </div> |
| | | </div> |
| | | <div class="form-group"> |
| | | <div class="form-row"> |
| | | <div class="form-group bg-primary"> |
| | | <div class="col-md-12 mb-4"> |
| | | <label for="team_blue_name" class="bg-primary">Kék csapat neve</label> |
| | | <input type="text" name="stripe[team][blue][name]" class="form-control" id="team_blue_name" |
| | | placeholder="Pld.: Impress!ve" value="{{ stripe.team.blue.name }}" required> |
| | | </div> |
| | | <div class="col-md-12 mb-4"> |
| | | <label for="op-blue" class="bg-primary">Banolt operátorok</label> |
| | | <select name="stripe[team][blue][ban][]" class="operators" id="op-blue" style="width: 100%" |
| | | multiple> |
| | | {% for operator in operators %} |
| | | <option value="{{ operator }}" {{ operator in stripe.team.blue.ban ? "selected" }}>{{ operator|capitalize }}</option> |
| | | {% endfor %} |
| | | </select> |
| | | </div> |
| | | </div> |
| | | <div class="form-group"> |
| | | <button class="btn btn-info" title="Csapat színcsere" onclick="swapTeams(); return false;"><=> |
| | | </button> |
| | | </div> |
| | | <div class="form-group bg-warning"> |
| | | <div class="col-md-12 mb-4"> |
| | | <label for="team_orange_name">Narancs csapat neve</label> |
| | | <input type="text" name="stripe[team][orange][name]" class="form-control" id="team_orange_name" |
| | | placeholder="Pld.: Opress!ve" value="{{ stripe.team.orange.name }}" required> |
| | | </div> |
| | | <div class="col-md-12 mb-4"> |
| | | <label for="op-orange" class="bg-warning">Banolt operátorok</label> |
| | | <select name="stripe[team][orange][ban][]" class="operators" id="op-orange" style="width: 100%" |
| | | multiple> |
| | | {% for operator in operators %} |
| | | <option value="{{ operator }}" {{ operator in stripe.team.orange.ban ? "selected" }}>{{ operator|capitalize }}</option> |
| | | {% endfor %} |
| | | </select> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | <div class="form-group"> |
| | | <button class="btn btn-primary mx-auto" type="submit">Overlay felülírása</button> |
| | | </div> |
| | | </form> |
| | | |
| | | <form action="/generator/save-teams.php" method="post"> |
| | | <div class="form-group"> |
| | | <div class="col-md-4 mb-4"> |
| | | <label for="json">Csapatok API Input adatai:</label> |
| | | Pld: https://api.eslgaming.com/play/v1/leagues/198846/contestants válasz eredménye |
| | | <textarea class="form-control" name="json" id="json"></textarea> |
| | | <button class="btn btn-secondary" type="submit">Csapatok frissítése</button> |
| | | </div> |
| | | </div> |
| | | </form> |
| | | |
| | | <a href="/generator/match-history.php" class="btn btn-secondary">Meccstörténet</a> |
| | | {% endblock %} |
| | | {% block lazyload %} |
| | | {{ parent() }} |
| | | <script type="text/javascript"> |
| | | $('.operators').chosen( |
| | | { |
| | | 'placeholder_text_multiple': 'Banolt operátorok', |
| | | 'max_selected_options': 2 |
| | | } |
| | | ); |
| | | |
| | | $('#teamname').chosen(); |
| | | |
| | | function swapTeams() { |
| | | var blue = document.getElementById('team_blue_name'); |
| | | var orange = document.getElementById('team_orange_name'); |
| | | |
| | | var blue_name = blue.value; |
| | | blue.value = orange.value; |
| | | orange.value = blue_name; |
| | | |
| | | return false; |
| | | } |
| | | |
| | | </script> |
| | | {% endblock %} |