Example #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();
 }