function resolveRound($subevent, $current_round) { if ($this->current_round <= $this->mainrounds) { $round = $this->current_round; } else { $round = $this->current_round - $this->mainrounds; } $matches_remaining = Match::unresolvedMatchesCheck($subevent, $round); if ($matches_remaining > 0) { // Nothing to do yet //echo "There are still {$matches_remaining} unresolved matches"; return 0; } else { if ($this->current_round > $this->mainrounds) { $structure = $this->finalstruct; } else { $structure = $this->mainstruct; } if ($this->current_round == $current_round) { //echo "No matches left, inside round resolver, round: " . $this->current_round; $matches2 = $this->getRoundMatches($this->current_round); foreach ($matches2 as $match) { //echo "about to update scores"; $match->updateScores($structure); } if ($structure == "Swiss") { $this->recalculateScores($structure); Standings::updateStandings($this->name, $this->mainid, 1); } $this->pairCurrentRound(); } } }
function content() { $event = NULL; // Prevent surplufous warnings. TODO: fix the code so we don't try to access these if unset. if (!isset($_GET['action'])) { $_GET['action'] = ''; } if (!isset($_POST['mode'])) { $_POST['mode'] = ''; } if (!isset($_GET['mode'])) { $_GET['mode'] = ''; } if (!isset($_GET['series'])) { $_GET['series'] = ''; } if (!isset($_GET['season'])) { $_GET['season'] = ''; } $player = Player::getSessionPlayer(); if ((isset($_GET['name']) || isset($_POST['name'])) && !mode_is("Create New Event")) { if (isset($_POST['name'])) { $eventname = $_POST['name']; } else { $eventname = $_GET['name']; } $event = new Event($eventname); } // if -- can create new events if (Player::getSessionPlayer()->isSteward()) { if (mode_is("Create New Event")) { if (isset($_POST['insert'])) { $event = insertEvent(); eventForm($event); } else { eventForm(); } return; } elseif (mode_is("Create Next Event")) { $oldevent = new Event($_POST['name']); $newevent = new Event(""); $newevent->season = $oldevent->season; $newevent->number = $oldevent->number + 1; $newevent->format = $oldevent->format; $newevent->start = strftime("%Y-%m-%d %H:00:00", strtotime($oldevent->start) + 86400 * 7); $newevent->kvalue = $oldevent->kvalue; $newevent->finalized = 0; $newevent->player_editdecks = 1; $newevent->player_reportable = $oldevent->player_reportable; $newevent->prereg_allowed = $oldevent->prereg_allowed; $newevent->series = $oldevent->series; $newevent->host = $oldevent->host; $newevent->cohost = $oldevent->cohost; $newevent->mainrounds = $oldevent->mainrounds; $newevent->mainstruct = $oldevent->mainstruct; $newevent->finalrounds = $oldevent->finalrounds; $newevent->finalstruct = $oldevent->finalstruct; $newevent->name = sprintf("%s %d.%02d", $newevent->series, $newevent->season, $newevent->number); eventForm($newevent, true); return; } else { if (!isset($event)) { if (!isset($_POST['series'])) { $_POST['series'] = ''; } if (!isset($_POST['season'])) { $_POST['season'] = ''; } eventList($_POST['series'], $_POST['season']); } } } if ($event && $event->authCheck($player)) { if (strcmp($_GET['action'], "undrop") == 0) { $event->undropPlayer($_GET['player']); } if (mode_is("Start Event")) { $event->active = 1; $event->save(); $entries = $event->getEntries(); Standings::startEvent($entries, $event->name); $event->pairCurrentRound(); } if (mode_is("Recalculate Standings")) { $structure = $event->mainstruct; $event->recalculateScores($structure); Standings::updateStandings($event->name, $event->mainid, 1); } if (mode_is("Reset Event")) { $event->resetEvent(); } if (mode_is("Delete Matches and Re-Pair Round")) { $event->repairRound(); } if (mode_is("Reactivate Event")) { $event->active = 1; $event->player_editdecks = 1; $event->finalized = 0; $event->save(); } if (mode_is("Assign Medals")) { $event->assignMedals(); } if (mode_is("Parse DCI Files")) { dciInput(); } elseif (mode_is("Parse DCIv3 Files")) { dci3Input(); } elseif (mode_is("Auto-Input Event Data")) { autoInput(); } elseif (mode_is("Update Registration")) { updateReg(); } elseif (mode_is("Update Match Listing")) { updateMatches(); } elseif (mode_is("Update Medals")) { updateMedals(); } elseif (mode_is("Update Adjustments")) { updateAdjustments(); } elseif (mode_is("Upload Trophy")) { if (insertTrophy()) { $event->hastrophy = 1; } } elseif (mode_is("Update Event Info")) { $event = updateEvent(); } eventForm($event); } else { authFailed(); } }