public function executeExportEstats(sfWebRequest $request) { $mO = $this->getRoute()->getObject(); $stats = array(); $match = $mO->toArray(); unset($match['id'], $match['config_password'], $match['season_id'], $match['server_id'], $match['rules'], $match['team_a'], $match['team_b'], $match['config_authkey'], $match['current_map']); $stats['match'] = $match; foreach ($mO->getMaps() as $mapO) { $map = $mapO->toArray(); unset($map['match_id'], $map['id']); $stats['map'] = $map; foreach ($mapO->getMapsScore() as $sO) { $score = $sO->toArray(); unset($score['id'], $score['map_id']); $stats['scores'][] = $score; } } foreach ($mO->getPlayers() as $pO) { $player = $pO->toArray(); unset($player['map_id'], $player['match_id'], $player['ip']); $stats['players'][] = $player; } $heatmap = PlayersHeatmapTable::getInstance()->createQuery()->where("match_id = ?", $mO->getId())->orderBy("created_at ASC")->execute(); foreach ($heatmap as $hO) { $data = $hO->toArray(); unset($data['id'], $data['match_id'], $data['map_id']); $stats['heatmap'][] = $data; } $kills = PlayerKillTable::getInstance()->createQuery()->where("match_id = ?", $mO->getId())->orderBy("created_at ASC")->execute(); foreach ($kills as $hO) { $data = $hO->toArray(); unset($data['match_id'], $data['map_id']); $stats['kills'][] = $data; } $kills = RoundTable::getInstance()->createQuery()->where("match_id = ?", $mO->getId())->orderBy("created_at ASC")->execute(); foreach ($kills as $hO) { $data = $hO->toArray(); unset($data['id'], $data['match_id'], $data['map_id']); $stats['rounds'][] = $data; } $kills = RoundSummaryTable::getInstance()->createQuery()->where("match_id = ?", $mO->getId())->orderBy("created_at ASC")->execute(); foreach ($kills as $hO) { $data = $hO->toArray(); unset($data['id'], $data['match_id'], $data['map_id']); $stats['summary'][] = $data; } return $this->renderText(json_encode($stats)); }
} ?> </tbody> </table> <?php $actions = array("1v1", "1v2", "1v3", "1v4", "1v5"); foreach ($actions as $action) { ?> <h3>Actions <?php echo $action; ?> </h3> <?php $rounds = RoundSummaryTable::getInstance()->createQuery("r")->where("best_action_type = ?", $action)->leftJoin("r.Match")->leftJoin("r.Map")->orderBy("match_id, round_id ASC")->execute(); ?> <table class="table table-stripped"> <thead> <tr> <th>Match</th> <th>Round</th> <th></th> </tr> </thead> <tbody> <?php foreach ($rounds as $round) { ?> <tr>
public function executeEntryKills(sfWebRequest $request) { $matchs = MatchsTable::getInstance()->findAll(); $players = array(); $players2 = array(); $weapons = array(); foreach ($matchs as $match) { $rounds = RoundSummaryTable::getInstance()->createQuery()->where("match_id = ?", $match->getId())->orderBy("round_id ASC")->execute(); foreach ($rounds as $round) { $kill = PlayerKillTable::getInstance()->createQuery()->where("match_id = ?", $match->getId())->andWhere("round_id = ?", $round->getRoundId())->orderBy("created_at ASC")->limit(1)->fetchOne(); if ($kill) { $team = $kill->getKillerTeam() == "CT" ? "ct" : "t"; $team_killed = $kill->getKilledTeam() == "CT" ? "ct" : "t"; $weapons[$kill->getWeapon()]++; if ($team == "ct" && $round->ct_win || $team == "t" && $round->t_win) { @($players[$kill->getKiller()->getSteamId()]['name'] = $kill->getKillerName()); @$players[$kill->getKiller()->getSteamId()]['count']++; @$players[$kill->getKiller()->getSteamId()]['weapons'][$kill->getWeapon()]++; } else { @($players[$kill->getKiller()->getSteamId()]['name'] = $kill->getKillerName()); @$players[$kill->getKiller()->getSteamId()]['loose']++; } @($players[$kill->getKiller()->getSteamId()]['matchs'][$match->getId()] = $match->getScoreA() + $match->getScoreB()); @($players2[$kill->getKilled()->getSteamId()]['matchs'][$match->getId()] = $match->getScoreA() + $match->getScoreB()); if ($team_killed == "ct" && $round->t_win || $team_killed == "t" && $round->ct_win) { @($players2[$kill->getKilled()->getSteamId()]['name'] = $kill->getKilledName()); @$players2[$kill->getKilled()->getSteamId()]['count']++; } else { @($players2[$kill->getKilled()->getSteamId()]['name'] = $kill->getKilledName()); @$players2[$kill->getKilled()->getSteamId()]['loose']++; } $s = $kill->getKiller()->getTeam(); $name = ""; if ($s == "a") { $name = $match->getTeamAName(); } elseif ($s == "b") { $name = $match->getTeamBName(); } if ($team == "ct" && $round->ct_win || $team == "t" && $round->t_win) { @($teams[$name]['name'] = $name); @$teams[$name]['count']++; } else { @($teams[$name]['name'] = $name); @$teams[$name]['loose']++; } $name = ""; $s = $kill->getKilled()->getTeam(); if ($s == "a") { $name = $match->getTeamAName(); } elseif ($s == "b") { $name = $match->getTeamBName(); } if ($team_killed == "ct" && $round->t_win || $team_killed == "t" && $round->ct_win) { @($teams2[$name]['name'] = $name); @$teams2[$name]['count']++; } else { @($teams2[$name]['name'] = $name); @$teams2[$name]['loose']++; } @($teams[$name]['matchs'][$match->getId()] = $match->getScoreA() + $match->getScoreB()); @($teams2[$name]['matchs'][$match->getId()] = $match->getScoreA() + $match->getScoreB()); } } } function cmp($a, $b) { if ($a['count'] == $b['count']) { return 0; } return $a['count'] > $b['count'] ? -1 : 1; } uasort($players, "cmp"); uasort($players2, "cmp"); uasort($teams, "cmp"); uasort($teams2, "cmp"); arsort($weapons); $this->playersWin = $players; $this->playersLoose = $players2; $this->teamsWin = $teams; $this->teamsLoose = $teams2; $this->weapons = $weapons; }
public function getLastRound() { return RoundSummaryTable::getInstance()->createQuery()->where("match_id = ?", $this->getId())->andWhere("map_id = ?", $this->getMap()->getId())->orderBy("round_id DESC")->limit(3)->execute(); }
<?php $players = array(); $statsRounds = array(); $rounds = RoundSummaryTable::getInstance()->createQuery()->where("match_id = ?", $match->getId())->orderBy("round_id ASC")->execute(); foreach ($rounds as $round) { $kill = PlayerKillTable::getInstance()->createQuery()->where("match_id = ?", $match->getId())->andWhere("round_id = ?", $round->getRoundId())->orderBy("created_at ASC")->limit(1)->fetchOne(); if ($kill) { $team = $kill->getKillerTeam() == "CT" ? "ct" : "t"; $team_killed = $kill->getKilledTeam() == "CT" ? "ct" : "t"; $weapons[$kill->getWeapon()]++; if ($team == "ct" && $round->ct_win || $team == "t" && $round->t_win) { @($players[$kill->getKiller()->getSteamId()]['name'] = $kill->getKillerName()); @$players[$kill->getKiller()->getSteamId()]['count']++; @$players[$kill->getKiller()->getSteamId()]['weapons'][$kill->getWeapon()]++; $statsRounds[$round->getRoundId()] = array("round" => $round, "kill" => $kill, "type" => "win"); } else { @($players[$kill->getKiller()->getSteamId()]['name'] = $kill->getKillerName()); @$players[$kill->getKiller()->getSteamId()]['loose']++; $statsRounds[$round->getRoundId()] = array("round" => $round, "kill" => $kill, "type" => "loose"); } @($players[$kill->getKiller()->getSteamId()]['matchs'][$match->getId()] = $match->getScoreA() + $match->getScoreB()); @($players2[$kill->getKilled()->getSteamId()]['matchs'][$match->getId()] = $match->getScoreA() + $match->getScoreB()); if ($team_killed == "ct" && $round->t_win || $team_killed == "t" && $round->ct_win) { @($players2[$kill->getKilled()->getSteamId()]['name'] = $kill->getKilledName()); @$players2[$kill->getKilled()->getSteamId()]['count']++; } else { @($players2[$kill->getKilled()->getSteamId()]['name'] = $kill->getKilledName()); @$players2[$kill->getKilled()->getSteamId()]['loose']++; } $s = $kill->getKiller()->getTeam();