Exemplo n.º 1
0
        /// <summary>
        /// Switch the server to start serving the match. Default is Contestant 1
        /// </summary>
        public void SwitchServer()
        {
            if (Points.Count > 0)
            {
                throw new Exception("Can't switch server when the match has started.");
            }

            TennisContestant newServer = GetNextServer();

            currentSet().StartServer = newServer.ContestantNr;
            currentGame().Server     = newServer.ContestantNr;
            currentGame().Receiver   = 3 - currentGame().Server;
            if (currentGame().GetType() == typeof(TennisTiebreak))
            {
                TennisTiebreak _tiebreak = (TennisTiebreak)currentGame();
                _tiebreak.SetStartServer(newServer.ContestantNr);
            }
        }
Exemplo n.º 2
0
 public TennisMatch()
 {
     LogLevel               = LogLevelEnum.Shots;
     Points                 = new List <TennisPoint>();
     Sets                   = new List <TennisSet>();
     Statistics             = new TennisStatistics(this);
     Duration               = new TennisDuration();
     BestOutOf              = 1;
     NumberGamesPerSet      = 6;
     DeuceSuddenDeath       = false;
     TieBreakAtSameScoreOf  = 3;
     TieBreakFinalSet       = true;
     TieBreakLength         = 7;
     FinalSetIsTiebreak     = false;
     FinalSetTieBreakLength = 10;
     Winner                 = 0;
     Status                 = MatchStatus.Created;
     ID          = Guid.NewGuid();
     Contestant1 = new TennisContestant();
     Contestant1.ContestantNr = 1;
     Contestant2 = new TennisContestant();
     Contestant2.ContestantNr = 2;
     NextContestantToServe    = Contestant2;
 }