Esempio n. 1
0
 private TourneyMatchUp destroy(TourneyMatchUp finalists)
 {
     finalists.Dispose();
     finalists.Visible = false;
     finalists         = null;
     return(null);
 }
Esempio n. 2
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
         }
     }
 }
Esempio n. 3
0
 /// <summary>
 /// Sets the tournematchups to the manager
 /// </summary>
 /// <param name="b"></param>
 private void setBrackets(TourneyMatchUp[] b)
 {
     Starters = new TourneyMatchUp[] { b[0], b[1], b[2], b[3], b[4], b[5], b[6], b[7] };
     orderAndSet(Starters, 4);
     Quarters = new TourneyMatchUp[] { b[8], b[9], b[10], b[11] };
     orderAndSet(Starters, 3);
     Semis = new TourneyMatchUp[]    { b[12], b[13] };
     orderAndSet(Starters, 2);
     Finals = b[14];
     orderAndSet(Starters, 1);
 }
Esempio n. 4
0
        private void updateArray(TourneyMatchUp[] matchups, TourneyMatchUp[] nextRow, int t)
        {
            int pos = 0;

            for (int i = 0; i < matchups.Length; i += 2)
            {
                if (matchups[i].InCompletedState() && matchups[i + 1].InCompletedState())
                {
                    nextRow[pos]          = new TourneyMatchUp(matchups[i].Winner, matchups[i + 1].Winner);
                    nextRow[pos].Parent   = Parent;
                    nextRow[pos].Location = getLocationInfoForControl(t - 1, pos);
                    nextRow[pos].Visible  = true;
                }
                else
                {
                    Parent.Invalidate();
                    if (nextRow[pos].InCompletedState())
                    {
                        nextRow[pos].button_click(nextRow[pos].back, EventArgs.Empty);
                    }
                    if (nextRow[pos] != null)
                    {
                        Parent.Parent.Controls.Remove(nextRow[pos]);
                        //nextRow[pos].Dispose();
                    }
                    nextRow[pos] = new TourneyMatchUp(null, null);
                }
                pos++;
                //        //nextRow[pos].RedTeam = matchups[i].Winner;
                //        //nextRow[pos].BlueTeam = matchups[i + 1].Winner;
                //        nextRow[pos].Visible = true;
                //    } else {
                //        //First check to see if we have to revert the previus
                //        TourneyMatchUp tmu  =nextRow[pos];
                //        if (tmu.Winner != null) {
                //            tmu.Winner.undoWin();
                //            if (tmu.Winner == tmu.RedTeam) {
                //                tmu.BlueTeam.undoLoss();
                //            } else {
                //                tmu.RedTeam.undoLoss();
                //            }
                //        }
                //        //after its reverted invisitble
                //        tmu.Parent = null;
                //        tmu.Visible = false;
                //    }
                //    pos++;
            }

            //for (int i = 0; i < matchups.Length; i += 2) {
            //    if (matchups[i] == null || matchups[i + 1] == null) {
            //        if (nextRow[pos] != null) {
            //            nextRow[pos].Visible = false;
            //            //nextRow[pos].Dispose();
            //            //nextRow[pos].removeMe();
            //        }
            //        nextRow[pos] = null;
            //        pos++;
            //        continue;
            //    }
            //    if (matchups[i].Winner == null || matchups[i + 1].Winner == null) {
            //        if (nextRow[pos] != null) {
            //            nextRow[pos].Visible = false;
            //            //nextRow[pos].Dispose();
            //            //nextRow[pos].removeMe();
            //            nextRow[pos].Visible = false;
            //        }

            //        //nextRow[pos] = null;
            //    } else {
            //        nextRow[pos] = new TourneyMatchUp( matchups[i].Winner, matchups[i + 1].Winner );
            //        nextRow[pos].Visible = true;
            //    }
            //    pos++;
            //}
        }