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; } }
//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); }
private void RoundPoint(IPlayerSetScore roundWinner, IPlayerSetScore roundLoser) { if (tieBreakActivated) { TieBreakRoundFinished(roundWinner, roundLoser); return; } currentGame.PlayerWinPoint(roundWinner.Player); if (currentGame.GameEnd) { CurrentGameFinished(roundWinner, roundLoser); } }
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(); }
public string ScoreDisplay(IPlayerSetScore setScore1, IPlayerSetScore setScore2) { return(string.Format("{0}-{1}", setScore1.GamesAsString(), setScore2.GamesAsString())); }
private bool IsFirstSlotWinner(IPlayerSetScore scoreSlot1, IPlayerSetScore scoreSlot2) { return((scoreSlot1.Games >= 6 && (Math.Abs(scoreSlot1.Games - scoreSlot2.Games) >= 2)) ? true : false); }
public Player(string name) { _name = name; _gameScore = new PlayerGameScore(this); _setScore = new PlayerSetScore(this); }
public TennisSET(IPlayer player1, IPlayer player2) { player1SetScore = new PlayerSetScore(player1); player2SetScore = new PlayerSetScore(player2); StartNewGame(); }