Beispiel #1
0
 public function fixScores($structure)
 {
     // Goes through all matches in this round and updates scores
     //echo $this->playera_wins . $this->playera_losses;
     $thisevent = Event::findBySubevent($this->subevent);
     $playera_standing = new Standings($thisevent->name, $this->playera);
     $playerb_standing = new Standings($thisevent->name, $this->playerb);
     if ($this->playera_wins > $this->playerb_wins) {
         $playera_standing->score += 3;
         $playera_standing->matches_won += 1;
         if ($structure == "Single Elimination") {
             $playerb_standing->active = 0;
         }
         $this->result = 'A';
     } else {
         $playerb_standing->score += 3;
         $playerb_standing->matches_won += 1;
         if ($structure == "Single Elimination") {
             $playera_standing->active = 0;
         }
         $this->result = 'B';
     }
     if (strcmp($playera_standing->player, $playerb_standing->player) == 0) {
         //Might need this later if I want to rebuild bye score with standings $playera_standing->byes++;
         $playerb_standing->byes++;
         $playerb_standing->save();
     } else {
         $playera_standing->matches_played++;
         $playera_standing->games_played += $this->playera_wins + $this->playera_losses;
         $playera_standing->games_won += $this->playera_wins;
         //echo "****playeragameswon".$playera_standing->games_won;
         $playerb_standing->matches_played++;
         $playerb_standing->games_played += $this->playera_wins + $this->playera_losses;
         $playerb_standing->games_won += $this->playerb_wins;
     }
     $playera_standing->save();
     $playerb_standing->save();
 }
Beispiel #2
0
 function swissFindMatch($player, $subevent)
 {
     $standing = new Standings($this->name, $player[0]->player);
     $opponents = $standing->getOpponents($this->name, $subevent, 1);
     $SQL_statement = "SELECT player FROM standings WHERE event = '" . $this->name . "' AND active = 1 AND matched = 0 AND player <> '" . $player[0]->player . "'";
     if ($opponents != NULL) {
         foreach ($opponents as $opponent) {
             $SQL_statement .= " AND player <> '" . $opponent->player . "'";
         }
     }
     // Updated to sort by standings to ensure matching of highest rated players.
     // TODO: this is only the pairing that should occur in the LAST round of swiss.
     //       it is referred to as "classic swiss method" by the DCI-R, and is highly predictable.
     //       Normally you would only randomly pair by SCORE, then lesser scores if there are no scores
     //       left that you can play against.
     $SQL_statement .= " ORDER BY score desc, byes desc, OP_Match desc, PL_Game desc, OP_Game desc LIMIT 1";
     $db = Database::getConnection();
     $stmt = $db->prepare($SQL_statement);
     $stmt or die($db->error);
     $stmt->execute() or die($stmt->error);
     $stmt->bind_result($playerb);
     if ($stmt->fetch() == NULL) {
         // No players left to match against, award bye
         $stmt->close();
         $this->awardBye($player[0]->player);
         $player[0]->matched = 1;
         $player[0]->save();
     } else {
         $stmt->close();
         $playerbStandings = new Standings($this->name, $playerb);
         $this->addPairing($player[0]->player, $playerb, $this->current_round + 1, "P");
         $player[0]->matched = 1;
         $player[0]->save();
         $playerbStandings->matched = 1;
         $playerbStandings->save();
     }
 }
Beispiel #3
0
 public static function writeSeed($eventname, $playername, $seed)
 {
     $standing = new Standings($eventname, $playername);
     $standing->seed = $seed;
     $standing->save();
 }