コード例 #1
0
 /// <summary> Sub function to choose which array to start
 /// updating depending on starting bracket
 /// </summary>
 public void updateWinners(TourneyMatchUp updated)
 {
     if (Finals.State == MatchState.VictorFound)
     {
         //update finals and winner
         TourneyWinner.Team = Finals.Winner;
         TourneyWinner.Update();
         //////
         ///TODO FINISH GAME
         //////
     }
     else
     {
         if (Semis.Contains <TourneyMatchUp>(updated))
         {
             // update semis and finals
             Team team1 = null, team2 = null;
             if (Semis[0].State == MatchState.VictorFound || Semis[0].State == MatchState.ByeRound)
             {
                 team1 = Semis[0].Winner;
             }
             if (Semis[1].State == MatchState.VictorFound || Semis[1].State == MatchState.ByeRound)
             {
                 team2 = Semis[1].Winner;
             }
             Finals.reset(team1, team2);
         }
         else if (Quarters.Contains <TourneyMatchUp>(updated))
         {
             int curRowCounter = 0, nextRowCounter = 0;
             for (int i = 0; i < Quarters.Length; i++)
             {
                 Team first  = (Quarters[curRowCounter].State == MatchState.VictorFound) ? Quarters[curRowCounter].Winner : null;
                 Team second = (Quarters[curRowCounter + 1].State == MatchState.VictorFound) ? Quarters[curRowCounter + 1].Winner : null;
                 Semis[nextRowCounter].reset(first, second);
                 curRowCounter += 2;
                 nextRowCounter++;
             }
             // update quarters and semis
         }
         else
         {
             int curRowCounter = 0, nextRowCounter = 0;
             for (int i = 0; i < Starters.Length; i++)
             {
                 Team first  = (Starters[curRowCounter].State == MatchState.VictorFound) ? Starters[curRowCounter].Winner : null;
                 Team second = (Starters[curRowCounter + 1].State == MatchState.VictorFound) ? Starters[curRowCounter + 1].Winner : null;
                 Quarters[nextRowCounter].reset(first, second);
                 curRowCounter += 2;
                 nextRowCounter++;
             }
             //update starters and quarters
         }
     }
 }