public function detailAction($id)
 {
     $id = $this->filter->sanitize($id, array("int"));
     if ($id) {
         $searchParams = array("id = '" . $id . "'");
         $debts = Debts::findFirst($searchParams);
         $this->view->setVar("debts", $debts);
         $debt = Debt::find("fid = " . $id);
         $this->view->debt = $debt;
         $this->view->website = FILEWEBNAME;
         $match = Match::find("debt_number  = '" . $debts->number . "'");
         $this->view->match = $match;
         foreach ($match as $key => $val) {
         }
         fb($match->toArray());
     } else {
         $this->flash->error("没有找到对应的债权");
         return $this->forward("debt/index");
     }
 }
 private function doClaim($is_duplicate)
 {
     $claim_match_id = Input::get('match-id');
     Log::info("======[claim_match_id]======");
     Log::info($claim_match_id);
     Log::info(Input::all());
     $match = Match::find($claim_match_id);
     $fip = FindPeople::find($match->fip_id);
     // MARK match as claimed and FIP as found
     $match->claimed = true;
     $match->save();
     $fip->found = true;
     $fip->duplicate = $is_duplicate;
     if ($match->match_army_update) {
         $fip->found_in_army_updates = true;
         $au = ArmyUpdates::find($match->match_table_id);
         $au->claimed = true;
         $au->save();
         // not deleting. allowing duplicate claims instead
         //Match::where('match_table_id', '=', $au->id)->delete();
     }
     if ($match->match_found_person) {
         $fip->found_in_found_people = true;
         $fop = FoundPeople::find($match->match_table_id);
         $fop->claimed = true;
         $fop->save();
         //Match::where('match_table_id', '=', $fop->id)->delete();
     }
     $fip->found_table_id = $match->match_table_id;
     $fip->save();
     Match::deleteMatchesForFip($fip->id);
     // TODO : also send back the id in the table it was matched to
     // Turn into Found
     $response = array('status' => 'success', 'fip-id' => $fip->id);
     return Response::json($response);
 }
Esempio n. 3
0
    private function showTeamSeasons()
    {
        $teamSeasonIds = Model::pluck(SeasonTeam::find('teamid = ?', [$this->team->teamid]), 'seasonid');
        $teamSeasons = Season::getMultiple($teamSeasonIds);
        Model::orderBy($teamSeasons, 'seasonid');

        $teamMatches = Match::find('team1id = ? or team2id = ?', [$this->team->teamid, $this->team->teamid]);
        // $games = [];
        $playedGames = [];
        $wins = [];
        $losses = [];

        foreach($teamMatches as $match) {
            if (!$match->isPublished()) continue;
            // $games[$match->seasonid]++;
            if ($match->getWinner() == $this->team->teamid) {
                $playedGames[$match->seasonid]++;
                $wins[$match->seasonid]++;
            }
            if ($match->getLooser() == $this->team->teamid) {
                $playedGames[$match->seasonid]++;
                $losses[$match->seasonid]++;
            }
        }

        ?>
        <h2>Actividad por temporadas</h2>

        <table style="width: 400px">
        <thead><tr>
            <td>Nombre</td>
            <td>Combates</td>
            <td>Victorias</td>
            <td>Derrotas</td>
        </tr></thead>
        <?
        foreach($teamSeasons as $season) {
            if (!$season->ispublic && !Team::isSuperAdmin()) continue;
            ?>
            <tr>
                <td>
                    <a href="/<?=$season->getLink()?>/equipos/<?=$this->team->getLink()?>/">
                        <?= htmlentities($season->name) ?>
                    </a>
                </td>
                <td><?= $playedGames[$season->seasonid] * 1 ?></td>
                <td><?= $wins[$season->seasonid] * 1 ?></td>
                <td><?= $losses[$season->seasonid] * 1 ?></td>
            </tr>
            <?
        }
        ?></table><br><?

    }
Esempio n. 4
0
    /**
     * @return void
     */
    public function show()
    {
        $week = $this->week;
        $canVote = $this->canVote;

        $publishTime = $this->season->getPublishTimeForWeek($week);

        if ($publishTime >= 1000) {

            $days = explode(',', 'Domingo,Lunes,Martes,Miércoles,Jueves,Viernes,Sábado');
            $months = explode(',', 'enero,febrero,marzo,abril,mayo,junio,julio,agosto,septiembre,octubre,noviembre,diciembre')

            ?>
            <div>
                <?= $days[date('w', $publishTime)] ?>
                <?= date('j', $publishTime)?> de <?= $months[date('m', $publishTime)-1] ?> de <?= date('Y', $publishTime) ?>,
                <?= date('H:i', $publishTime) ?> (hora española)
            </div>
        <? } ?>
        <div style="height: 6px"></div>
        <table style="border: 0; padding: 0; margin: 0; width: 100%">
            <tr>
                <td style="width: 150px; border: 0; padding: 0; margin: 0; text-align: left">
                    <?
                    if ($this->week > 1) {
                        ?>
                        <a style="float:left; margin-left: 24px" href="/<?=$this->season->getLink()?>/jornadas/<?=$this->week-1?>/">
                            &lt;&lt;
                            Ver <?= strtolower($this->season->getWeekName($this->week-1)) ?>
                        </a>
                        <?
                    }
                    ?>
                </td>
                <td style="border: 0; padding: 0; margin: 0; text-align: center">
                    <?
                    if (time() >= $publishTime) {
                        ?>
                        <a href="javascript:void(0)" onclick="$('._grayscale').toggleClass('grayscale'); $('.result').toggle(); $(this).find('span').toggle()">
                            <span>Mostrar resultados</span>
                            <span style="display: none">Ocultar resultados</span>
                        </a>
                        <?
                    }
                    ?>
                </td>
                <td style="width: 150px; border: 0; padding: 0; margin: 0; text-align: right"><?
                    if ($this->week < $this->maxWeek) {
                        ?>
                        <a style="float:right; margin-right: 24px" href="/<?=$this->season->getLink()?>/jornadas/<?=$this->week+1?>/">
                            Ver <?= strtolower($this->season->getWeekName($this->week+1)) ?>
                            &gt;&gt;
                        </a>
                        <?
                    }
                    ?>
                </td>
            </tr>
        </table>
        <?

        $matches = Match::find('seasonid = ? and week = ? order by matchid asc', [$this->season->seasonid, $week]);
        #shuffle($matches);

        if (!$matches) {
            ?>
            No hay enfrentamientos disponibles en estos momentos.<br><br>
            <?
            return;
        }

        foreach($matches as $match) {
            $team1 = $match->getTeam1();
            $team2 = $match->getTeam2();

            if (false && rand(0,1) == 1) {
                $tmp = $team2;
                $team2 = $team1;
                $team1 = $tmp;
            }


            $voteTeamid = HTMLResponse::fromPOST('teamid','') * 1;
            $voteMatchid = HTMLResponse::fromPOST('matchid','') * 1;
            $voteUnteamid = HTMLResponse::fromPOST('unteamid','') * 1;
            $voteUnmatchid = HTMLResponse::fromPOST('unmatchid','') * 1;

            if ($canVote && TwitterAuth::isLogged() && !$match->hasVoted() && $match->matchid &&
                $voteMatchid == $match->matchid && ($voteTeamid == $team1->teamid || $voteTeamid == $team2->teamid)) {
                $bet = Bet::create();
                $bet->matchid = $match->matchid;
                $bet->dateline = time();
                $bet->userid = TwitterAuth::getUserId();
                $bet->teamid = $voteTeamid;
                $bet->username = TwitterAuth::getUserName();
                $bet->avatar = $_SESSION['twitter-avatar'];
                $bet->save();
            }

            if ($canVote && TwitterAuth::isLogged() && $match->hasVoted() &&
                $voteUnmatchid == $match->matchid && ($voteUnteamid == $team1->teamid || $voteUnteamid == $team2->teamid)) {
                $bet = Bet::findOne('matchid = ? and teamid = ? and userid = ?', array($voteUnmatchid, $voteUnteamid, TwitterAuth::getUserId()));
                $bet->delete();
            }

            $votes = $match->getVotes();
            $votesCount = array_sum($votes);

            $team1votes = 0;
            $team2votes = 0;
            if ($votesCount != 0) {
                $team1votes = $votes[$team1->teamid]*1;
                $team2votes = $votes[$team2->teamid]*1;
            }

            ?>

            <div class="matchbox">
                <? $this->showTeamBox($match, $team1, $team1votes, $votesCount) ?>
                <div class="vsbox">
                    <? if ($match->isPublished() && $match->getWinner()) {
                        $score1 = $team1->teamid==$match->getWinner() ? 6-$match->getLooserKills() : 0;
                        $score2 = $team2->teamid==$match->getWinner() ? 6-$match->getLooserKills() : 0;
                        ?>
                        <div style="font-size:90%; display: none" class="result">
                            <?=$score1?>-<?=$score2?>
                        </div>
                        <?
                    } else if ($match->isPublished() && $match->isDelayed()) { ?>
                        <div style="font-size:90%; display: none" class="result">
                            Apl.
                        </div>
                    <? } ?>
                    VS
                </div>
                <? $this->showTeamBox($match, $team2, $team2votes, $votesCount) ?>
            </div>
            <?
        }
    }
Esempio n. 5
0
File: Batch.php Progetto: xJakub/LCE
 public function restoreResults() {
     $matches = Match::find('1=1');
     foreach($matches as $match) {
         if (isset($this->results[$match->matchid])) {
             $match->result = $this->results[$match->matchid];
         }
     }
     Match::saveAll($matches);
 }
Esempio n. 6
0
    /**
     * @return void
     */
    public function show()
    {
        if (!Team::isSuperAdmin()) {
            HTMLResponse::exitWithRoute('/');
        }

        if (!($csrf = $_SESSION['csrf'])) {
            $_SESSION['csrf'] = $csrf = rand(1, 1000000);
        }
        $postCsrf = HTMLResponse::fromPOST('csrf', '');

        $totalWeeks = $this->season->getWeeksCount();
        if ($csrf == $postCsrf) {
            $this->season->mainweeks = HTMLResponse::fromPOST('mainweeks', $this->season->mainweeks);
            $this->season->playoffsweeks = HTMLResponse::fromPOST('playoffsweeks', $this->season->playoffsweeks);
            $this->season->save();
        }

        ?>
        <div class="inblock middle">
        <form action="<?=HTMLResponse::getRoute()?>" method="post">
            <table style="width:640px; margin: 0 auto; text-align: left">
                <thead>
                <tr style="text-align: center">
                    <td>
                        Propiedad
                    </td>
                    <td>
                        Valor
                    </td>
                </tr>
                </thead>
                <tr>
                    <td>
                        <b>Número de jornadas (principales)</b>
                    </td><td>
                        <input name="mainweeks" type="number" value="<?=htmlentities($this->season->mainweeks)?>">
                    </td>
                </tr>
                <tr>
                    <td>
                        <b>Número de jornadas (playoffs)</b>
                    </td><td>
                        <input name="playoffsweeks" type="number" value="<?=htmlentities($this->season->playoffsweeks)?>">
                    </td>
                </tr>
            </table>

            <?
            $teams = $this->season->getTeams(false);
            $maxMatches = ceil(count($teams)/2);

            $matches =
                Model::groupBy(
                    Match::find('seasonid = ? order by week asc, matchid asc', [$this->season->seasonid]),
                    'week'
                );

            if ($csrf == $postCsrf) {
                for ($week=1; $week<=$totalWeeks; $week++) {
                    $name = HTMLResponse::fromPOST("week{$week}name");
                    $date = HTMLResponse::fromPOST("week{$week}date");
                    $this->season->setWeekName($week, $name);
                    $this->season->setWeekDate($week, $date);
                }
                $this->season->save();

                $newMatches = [];
                $oldMatches = [];
                for ($week=1; $week<=$this->season->getWeeksCount(); $week++) {
                    for ($i=0; $i<$maxMatches; $i++) {
                        $team1id = HTMLResponse::fromPOST("week{$week}match{$i}team1id");
                        $team2id = HTMLResponse::fromPOST("week{$week}match{$i}team2id");
                        if ($team1id === null || $team2id === null) continue;

                        $team1id *= 1;
                        $team2id *= 1;

                        if ($team1id && $team2id) {
                            if (isset($matches[$week][$i])) {
                                $match = $matches[$week][$i];
                                $match->team1id = "$team1id";
                                $match->team2id = "$team2id";
                                $oldMatches[] = $match;
                            }
                            else {
                                $match = Match::create();
                                $match->result = 0;
                                $match->week = $week;
                                $match->seasonid = $this->season->seasonid;
                                $match->team1id = $team1id;
                                $match->team2id = $team2id;
                                $newMatches[] = $match;
                            }
                        }
                        else {
                            if (isset($matches[$week][$i])) {
                                $matches[$week][$i]->delete();
                            }
                        }
                    }
                }
                Model::saveAll($newMatches);
                Model::saveAll($oldMatches);

                $matches =
                    Model::groupBy(
                        Match::find('seasonid = ? order by week asc, matchid asc', [$this->season->seasonid]),
                        'week'
                    );
            }


            for ($week=1; $week<=$totalWeeks; $week++) {
                ?>
                <br>
                <table style="width:640px; margin: 0 auto; text-align: left">
                    <thead>
                    <tr>
                        <td colspan="2" style="text-align: center">Jornada Nº<?=$week?></td>
                    </tr>
                    </thead>
                    <tr>
                        <td>
                            <b>Nombre de la jornada</b>
                        </td><td>
                            <input name="week<?=$week?>name" value="<?=htmlentities($this->season->getWeekName($week))?>">
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <b>Fecha de publicación</b>
                        </td><td>
                            <input name="week<?=$week?>date" type="date" value="<?=htmlentities($this->season->getWeekDate($week))?>">
                        </td>
                    </tr>
                    <?
                    for ($i=0; $i<$maxMatches; $i++) {
                        ?>
                        <tr>
                            <td>
                                <b>- Enfrentamiento #<?=$i+1?></b>
                            </td>
                            <td>
                                <select name="week<?=$week?>match<?=$i?>team1id">
                                    <option value="0">-- Elige equipo --</option>
                                    <?
                                    foreach($teams as $team) {
                                        $selected = isset($matches[$week][$i])
                                            ? (
                                            $matches[$week][$i]->team1id == $team->teamid
                                                ? 'selected'
                                                : ''
                                            )
                                            : '';
                                        ?>
                                        <option value="<?=$team->teamid?>" <?=$selected?>>
                                            <?=htmlentities($team->name)?>
                                        </option>
                                        <?
                                    }
                                    ?>
                                </select>
                                VS
                                <select name="week<?=$week?>match<?=$i?>team2id">
                                    <option value="0">-- Elige equipo --</option>
                                    <?
                                    foreach($teams as $team) {
                                        $selected = isset($matches[$week][$i])
                                            ? (
                                            $matches[$week][$i]->team2id == $team->teamid
                                                ? 'selected'
                                                : ''
                                            )
                                            : '';
                                        ?>
                                        <option value="<?=$team->teamid?>" <?=$selected?>>
                                            <?=htmlentities($team->name)?>
                                        </option>
                                        <?
                                    }
                                    ?>
                                </select>
                            </td>
                        </tr>
                        <?
                    }
                    ?>
                </table>
                <?
            }
            ?>

            <input type="hidden" name="csrf" value="<?= $csrf ?>"><br>
            <button type="submit">Guardar cambios</button><br><br>

        </form>
        </div><?
    }
Esempio n. 7
0
 public function post_set_match_winner($matchId)
 {
     $bracket = Bracket::find(Session::get('bracketId'));
     $match = Match::find($matchId);
     // If the bracket doesn't exist
     // redirect back on home
     if (!$bracket) {
         return Redirect::home();
     }
     if (!$match) {
         return Redirect::to('bracket/tournament');
     }
     $homeScore = Input::get('teamScoreHome');
     $awayScore = Input::get('teamScoreAway');
     if ($homeScore < 5 && $awayScore < 5) {
         return Redirect::to('bracket/tournament')->with('error', 'Neither team has a high enough score to conclude the match.');
     }
     // Create the tournament object
     $tournament = new Tournament($bracket);
     $team = $homeScore > $awayScore ? $match->teams[0] : $match->teams[1];
     // advance this team to the next round or declare them the champ.
     $tournament->advanceTeam($match, $team);
     return Redirect::to('bracket/tournament');
 }
Esempio n. 8
0
    /**
     * @return void
     */
    public function show()
    {
        $matches = Match::find('seasonid = ? and result != 0', [$this->season->seasonid]);
        $matches = Model::indexBy($matches, 'matchid');

        $teams = Model::indexBy(Team::find('1=1'), 'teamid');

        $matchWinner = [];

        foreach($matches as $match) {
            if ($this->season->weekIsPublished($match->week) && !$match->isDelayed()) {
                $matchWinner[$match->matchid] = $match->getWinner();
            }
        }

        $totalBets = [];
        $correctBets = [];

        $usernames = [];
        $avatars = Model::pluck(Avatar::find('1=1'), 'url', 'userid');

        foreach(Bet::find('1=1') as $bet) {
            if (isset($matchWinner[$bet->matchid])) {
                if ($bet->teamid && $matchWinner[$bet->matchid] == $bet->teamid) {
                    $correctBets[$bet->userid]++;
                }
                $totalBets[$bet->userid]++;
            }
            if ($bet->username) {
                $usernames[$bet->userid] = $bet->username;
            }
        }

        $tiebreakers = [];
        foreach(array_keys($correctBets) as $userid) {
            $tiebreakers[$userid] = [-$correctBets[$userid], $totalBets[$userid], strtolower($usernames[$userid])];
        }
        asort($tiebreakers);


        if (TwitterAuth::isLogged()) {
            $userid = TwitterAuth::getUserId();
            $userBets = Bet::find('userid = ? order by matchid desc', [$userid]);

            $userpos = array_search($userid, array_keys($tiebreakers));
            $userpos = ($userpos === FALSE) ? 0 : $userpos+1;

            ?>
            <div class="inblock" style="text-align: left; margin-right: 20px">
                <h2>Tus estadísticas</h2>
                <table>
                    <thead>
                    <tr>
                        <td>Puesto</td>
                        <td>Nombre</td>
                        <td>Aciertos</td>
                        <td>Fallos</td>
                    </tr>
                    </thead>
                    <tr>
                        <td><?= $userpos ?>º</td>
                        <td style="text-align: left">
                            <div class="inblock" style="vertical-align: middle">
                                <a href="http://twitter.com/<?=htmlentities($usernames[$userid])?>" target="_blank">
                                    <img src="<?= htmlentities($avatars[$userid]) ?>" style="width:40px; height:40px; border-radius: 20px">
                                </a>
                            </div>
                            <div class="inblock" style="vertical-align: middle">
                                <a href="http://twitter.com/<?=htmlentities($usernames[$userid])?>" target="_blank">
                                    <?= htmlentities($usernames[$userid]) ?>
                                    <? if (!isset($usernames[$userid])) echo "<i>$userid</i>"; ?>
                                </a>
                            </div>
                        </td>
                        <td><?= $correctBets[$userid] ?></td>
                        <td><?= $totalBets[$userid]-$correctBets[$userid] ?></td>
                    </tr>
                </table>

                <h2>Tus apuestas</h2>
                <table>
                    <thead>
                    <tr>
                        <td>Jornada</td>
                        <td>Enfrentamiento</td>
                        <td>Acierto</td>
                    </tr>
                    </thead>
                    <? foreach($userBets as $bet) {
                        if (!isset($matches[$bet->matchid])) continue;
                        /**
                         * @var $match Match
                         */
                        $match = $matches[$bet->matchid];
                        if (!$match->isPublished() || $match->isDelayed()) continue;

                        $team1 = $teams[$match->team1id];
                        $team2 = $teams[$match->team2id];

                        $success = $match->getWinner() == $bet->teamid;
                        ?>
                        <tr>
                            <td><?= $match->week ?></td>
                            <td>
                                <div class="inblock">
                                    <div class="teamimg64">
                                        <img src="/<?= $team1->getImageLink(64, 64) ?>" class="<?= $match->getWinner() == $team1->teamid ? '' : 'grayscale' ?>">
                                    </div>
                                    <? if ($bet->teamid == $team1->teamid) { ?>
                                        <br><i style="font-size:11px">Votado</i>
                                    <? } ?>
                                </div>

                                <div class="inblock" style="line-height: 64px; margin: 0px 4px">
                                    VS
                                </div>

                                <div class="inblock">
                                    <div class="teamimg64">
                                        <img src="/<?= $team2->getImageLink(64, 64) ?>" class="<?= $match->getWinner() == $team2->teamid ? '' : 'grayscale' ?>">
                                    </div>
                                    <? if ($bet->teamid == $team2->teamid) { ?>
                                        <br><i style="font-size:11px">Votado</i>
                                    <? } ?>
                                </div>
                            </td>
                            <td>
                                <?= $success
                                    ? '<div class="success-icon">&#x2714;</div>'
                                    : '<div class="fail-icon">&#x2718</div>' ?>
                            </td>

                        </tr>
                        <?
                    } ?>
                </table>
            </div>
            <?
        }


        ?>
        <div class="inblock">
            <h2>Clasificación</h2>
            <table>
                <thead>
                <tr>
                    <td>Puesto</td>
                    <td>Nombre</td>
                    <td>Aciertos</td>
                    <td>Fallos</td>
                </tr>
                </thead>

                <?
                $lastTiebreakers = null;
                $lastPos = 0;
                foreach(array_keys($tiebreakers) as $pos => $userid) {
                    unset($tiebreakers[$userid][2]);

                    if ($lastTiebreakers != $tiebreakers[$userid]) {
                        $lastPos = $pos;
                    }

                    if (!isset($avatars[$userid])) {
                        Avatar::setUsersAvatar($userid, $usernames[$userid]);
                    }
                    ?>
                    <tr>
                        <td><?= $lastPos+1 ?>º</td>
                        <td style="text-align: left">
                            <div class="inblock" style="vertical-align: middle">
                                <a href="http://twitter.com/<?=htmlentities($usernames[$userid])?>" target="_blank">
                                    <img src="<?= htmlentities($avatars[$userid]) ?>" style="width:40px; height:40px; border-radius: 20px">
                                </a>
                            </div>
                            <div class="inblock" style="vertical-align: middle">
                                <a href="http://twitter.com/<?=htmlentities($usernames[$userid])?>" target="_blank">
                                    <?= htmlentities($usernames[$userid]) ?>
                                    <? if (!isset($usernames[$userid])) echo "<i>$userid</i>"; ?>
                                </a>
                            </div>
                        </td>
                        <td><?= $correctBets[$userid] ?></td>
                        <td><?= $totalBets[$userid]-$correctBets[$userid] ?></td>
                    </tr>
                    <?
                    $lastTiebreakers = $tiebreakers[$userid];
                }
                ?>
            </table>
        </div>
        <?
    }
Esempio n. 9
0
    /**
     * @return void
     */
    public function show()
    {
        $matches = Match::find('seasonid = ?', [$this->season->seasonid]);
        $wins = [];
        $games = [];
        $kills = [];
        $deaths = [];
        $mainPositions = [];
        $playoffsDefeat = [];
        $playoffsLast = [];

        foreach($this->season->getTeams() as $team) {
            $wins[$team->teamid] = 0;
            $kills[$team->teamid] = 0;
            $games[$team->teamid] = 0;
            $deaths[$team->teamid] = 0;
        }

        foreach($matches as $match) {
            if ($match->week > $this->season->mainweeks) continue;
            if (!$this->season->weekIsPublished($match->week)) continue;
            if ($match->isDelayed()) continue;

            $winner = $match->getWinner();
            if (!$winner) continue;
            $looser = $match->getLooser();

            $games[$winner]++;
            $games[$looser]++;

            $wins[$winner]++;

            $kills[$winner] += 6;
            $deaths[$looser] += 6;

            $looserKills = $match->getLooserKills();
            $kills[$looser] += $looserKills;
            $deaths[$winner] += $looserKills;
        }

        foreach(array_keys($kills) as $teamid) {
            $tiebreakers[$teamid] = array($wins[$teamid], $kills[$teamid]-$deaths[$teamid], $kills[$teamid], -$deaths[$teamid]);
        }
        arsort($tiebreakers);

        $lastPos = 0;
        $lastTiebreakers = null;
        foreach(array_keys($tiebreakers) as $pos => $teamid) {
            if ($lastTiebreakers != $tiebreakers[$teamid]) {
                $lastPos = $pos;
            }
            $mainPositions[$teamid] = $lastPos;
            $lastTiebreakers = $tiebreakers[$teamid];
        }

        foreach($matches as $match) {
            if ($match->week <= $this->season->mainweeks) continue;
            if (!$this->season->weekIsPublished($match->week)) continue;
            if ($match->isDelayed()) continue;

            $winner = $match->getWinner();
            if (!$winner) continue;
            $looser = $match->getLooser();

            $playoffsDefeat[$looser] = -$match->week;
            $playoffsLast[$winner] = $match->week;
            $playoffsLast[$looser] = $match->week;

            $playoffsPlayed[$winner] = 1;
            $playoffsPlayed[$looser] = 1;

            $games[$winner]++;
            $games[$looser]++;

            $wins[$winner]++;

            $kills[$winner] += 6;
            $deaths[$looser] += 6;

            $looserKills = $match->getLooserKills();
            $kills[$looser] += $looserKills;
            $deaths[$winner] += $looserKills;
        }

        foreach(array_keys($kills) as $teamid) {
            $tiebreakers[$teamid] = array($playoffsLast[$teamid]*1, $playoffsDefeat[$teamid]*1, -$mainPositions[$teamid]);
        }
        arsort($tiebreakers);


        ?>
        <table>
            <thead><tr>
                <td>Puesto</td>
                <td>Equipo</td>
                <td>Combates</td>
                <td>Victorias</td>
                <td>Derrotas</td>
                <td>Debilitados</td>
                <td>Perdidos</td>
            </tr></thead>

            <?
            /**
             * @var $teams Team[]
             */
            $teams = Model::indexBy(Team::find('1=1'), 'teamid');

            $lastTiebreakers = null;
            $lastPos = 0;
            foreach(array_keys($tiebreakers) as $pos => $teamid) {
                $team = $teams[$teamid];
                if ($lastTiebreakers != $tiebreakers[$teamid]) {
                    $lastPos = $pos;
                }

                ?>
                <tr>
                    <td><?= $lastPos+1 ?>º
                        <? if (isset($mainPositions[$teamid]) && $lastPos != $mainPositions[$teamid]) { ?>
                            <div style="height: 4px"></div>
                            <i title="<?= $mainPositions[$teamid]+1 ?>º en las jornadas" style="cursor: pointer; color: #666">
                                <?= $mainPositions[$teamid]+1 ?>º
                            </i>
                        <? } ?>
                    </td>
                    <td style="text-align: left">
                        <div class="teamimg64">
                            <img src="/<?=$team->getImageLink(64, 64)?>">
                        </div>
                        <a href="/<?=$this->season->getLink()?>/equipos/<?=$team->getLink()?>/" class="inblock" style="vertical-align:middle">
                            <?= $team->name ?>
                        </a></td>
                    <td><?= $games[$teamid] ?></td>
                    <td><b><?= $wins[$teamid]*1 ?></b></td>
                    <td><?= $games[$teamid]-$wins[$teamid] ?></td>
                    <td><?= $kills[$teamid] ?></td>
                    <td><?= $deaths[$teamid] ?></td>
                </tr>
                <?
                $lastTiebreakers = $tiebreakers[$teamid];
            }
            ?>
        </table>
        <?
    }
Esempio n. 10
0
 public function postView()
 {
     $rules = array('id' => 'required|exists:matches,id', 'teamA_id' => 'required|integer|exists:teams,id', 'teamB_id' => 'required|integer|exists:teams,id', 'start_time' => 'required', 'rounds' => 'required|integer|min:1');
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->fails()) {
         return Redirect::action('Admin_MatchesController@getView', array(Input::get('id')))->withInput()->withErrors($validator);
     } else {
         $match = Match::find(Input::get('id'));
         $match->league_id = Input::get('league_id');
         $match->teamA_id = Input::get('teamA_id');
         $match->teamB_id = Input::get('teamB_id');
         $match->start_time = date("Y-m-d H:i:s", strtotime(Input::get('start_time')));
         $match->stream_url = Input::get('stream_url');
         $match->chat_url = Input::get('chat_url');
         $match->rounds = Input::get('rounds');
         $match->message = Input::get('message');
         $match->save();
         return Redirect::action('Admin_MatchesController@getIndex');
     }
 }
Esempio n. 11
0
File: bot.php Progetto: xJakub/LCE
                        }
                    }
                }
            }
        }
    }
}
if (date('H') * 1 == 17 && date('i') * 1 < 15) {
    // 17:00 - 17:15
    // Videos
    foreach (Season::find('1=1') as $season) {
        $weeksCount = $season->getWeeksCount();
        for ($week = 1; $week <= $weeksCount; $week++) {
            if ($season->getWeekDate($week) == $date) {
                $weekName = $season->getWeekName($week);
                $matches = Match::find('seasonid = ? and week = ?', [$season->seasonid, $week]);
                foreach ($matches as $match) {
                    /** @var Team $team1 */
                    $team1 = $match->getTeam1();
                    /** @var Team $team2 */
                    $team2 = $match->getTeam2();
                    $video1 = Video::findOne('matchid = ? and teamid = ? and type = ?', [$match->matchid, $team1->teamid, 1]);
                    $video2 = Video::findOne('matchid = ? and teamid = ? and type = ?', [$match->matchid, $team2->teamid, 1]);
                    if ($video1 || $video2) {
                        $msg = "{$weekName} {$season->name}: #" . $team1->getHashtag() . " VS #" . $team2->getHashtag();
                        $msg .= " @{$team1->username} VS @{$team2->username}";
                        if ($video1) {
                            $msg .= " {$video1->link}";
                        }
                        if ($video2) {
                            $msg .= " {$video2->link}";