Esempio n. 1
0
function getAllNextEncounters()
{
    global $db;
    global $lang;
    $tournaments = $db->selectList("tournamentlist", "*", "`state`=2");
    $allNextEncs = array();
    foreach ($tournaments as $tourney) {
        switch ($tourney['mode']) {
            // Single Elimination
            case 1:
                // Double Elimination
            // Double Elimination
            case 2:
                // KotH
            // KotH
            case 6:
                $allEnc = $db->selectList("tournamentencounters", "*", "`tournamentid`=" . $tourney['tournamentid'] . " AND `state`=0 AND (`player1id`>0 OR `player2id`>0)");
                require_once "mod/default/tournament/tournament.eliminationencounter.class.php";
                foreach ($allEnc as $enc) {
                    $curEnc = new EliminationEncounter($enc['tournamentid'], $enc['roundid'], $enc['encounterid']);
                    $allNextEncs[] = array('time' => $curEnc->getEncTimeState(), 'round' => makeRoundNr($curEnc->getRoundId(), $tourney['mode']), 'encounterid' => $curEnc->getId(), 'player1id' => makePlayerUrl($curEnc->getPlayer1Id(), $tourney['playerperteam'] == 1), 'player2id' => makePlayerUrl($curEnc->getPlayer2Id(), $tourney['playerperteam'] == 1), 'title' => $tourney['title']);
                }
                break;
                // Groups
            // Groups
            case 3:
                $allEnc = $db->selectList("tournamentgroupenc", "*", "`tournamentid`=" . $tourney['tournamentid'] . " GROUP BY `round`, `group` HAVING MIN(rank)=0");
                foreach ($allEnc as $enc) {
                    $participants = $db->selectList("tournamentgroupenc", "*", "`tournamentid`=" . $enc['tournamentid'] . " AND `round`=" . $enc['round'] . " AND `group`=" . $enc['group']);
                    $allParticipants = array();
                    foreach ($participants as $participant) {
                        $allParticipants[] = makePlayerUrl($participant['participantid']);
                    }
                    $encounterUrl = makeHTMLUrl($lang->get('group') . " " . chr(65 + $enc['group']), makeURL('tournament', array('mode' => 'table', 'tournamentid' => $enc['tournamentid'], 'action' => 'submit', 'group' => $enc['group'], 'round' => $enc['round'])));
                    $allNextEncs[] = array('time' => '', 'round' => makeRoundNr($enc['round'] - 1, $tourney['mode']), 'encounterid' => $enc['group'], 'player1id' => $encounterUrl, 'player2id' => '', 'title' => $tourney['title'], 'participants' => $allParticipants);
                }
                break;
                // Points
            // Points
            case 4:
                break;
                // Randomize
            // Randomize
            case 5:
                break;
        }
    }
    usort($allNextEncs, "sortNextEncounters");
    return $allNextEncs;
}