Exemplo n.º 1
0
        private void TieBreakRoundFinished(IPlayerSetScore roundWinner, IPlayerSetScore roundLoser)
        {
            roundWinner.TiedBreakScore++;

            if (roundWinner.TiedBreakScore >= 7 && roundWinner.TiedBreakScore - roundLoser.TiedBreakScore >= 2)
            {
                roundWinner.TiedBreakScore = 0;
                roundWinner.Score++;
                roundLoser.TiedBreakScore = 0;
                SETWinner = roundWinner.Player;
            }
        }
Exemplo n.º 2
0
        //Work out if someone one the game. If someone did. Return that winner. If no one won, return null
        public IPlayerSetScore ChooseWinner(IPlayerSetScore setScore1, IPlayerSetScore setScore2)
        {
            // Check if the first player won
            if (IsFirstSlotWinner(setScore1, setScore2))
            {
                return(setScore1);
            }
            // if the first player didn't win. check if the second player won
            if (IsFirstSlotWinner(setScore2, setScore1))
            {
                return(setScore2);
            }

            return(null);
        }
Exemplo n.º 3
0
        private void RoundPoint(IPlayerSetScore roundWinner, IPlayerSetScore roundLoser)
        {
            if (tieBreakActivated)
            {
                TieBreakRoundFinished(roundWinner, roundLoser);
                return;
            }

            currentGame.PlayerWinPoint(roundWinner.Player);

            if (currentGame.GameEnd)
            {
                CurrentGameFinished(roundWinner, roundLoser);
            }
        }
Exemplo n.º 4
0
        private void CurrentGameFinished(IPlayerSetScore gameWinner, IPlayerSetScore gameLoser)
        {
            gameWinner.Score++;

            if ((gameWinner.Score == 6 && gameLoser.Score <= 4) || gameWinner.Score == 7)
            {
                SETWinner = gameWinner.Player;
            }

            if (gameWinner.Score == 6 && gameLoser.Score == 6)
            {
                tieBreakActivated = true;
            }

            StartNewGame();
        }
Exemplo n.º 5
0
 public string ScoreDisplay(IPlayerSetScore setScore1, IPlayerSetScore setScore2)
 {
     return(string.Format("{0}-{1}", setScore1.GamesAsString(), setScore2.GamesAsString()));
 }
Exemplo n.º 6
0
 private bool IsFirstSlotWinner(IPlayerSetScore scoreSlot1, IPlayerSetScore scoreSlot2)
 {
     return((scoreSlot1.Games >= 6 && (Math.Abs(scoreSlot1.Games - scoreSlot2.Games) >= 2)) ? true : false);
 }
Exemplo n.º 7
0
 public Player(string name)
 {
     _name      = name;
     _gameScore = new PlayerGameScore(this);
     _setScore  = new PlayerSetScore(this);
 }
Exemplo n.º 8
0
 public TennisSET(IPlayer player1, IPlayer player2)
 {
     player1SetScore = new PlayerSetScore(player1);
     player2SetScore = new PlayerSetScore(player2);
     StartNewGame();
 }