public override void Suwit(Suwit s) { if (_gameEndend) { throw new Exception("Game already ended"); } RockPaperScissorSuwit swit = s as RockPaperScissorSuwit; if (swit == null) { throw new Exception("Invalid Rock-Paper-Scissor suwit!"); } if (swit.Player1Suwit == swit.Player2Suwit) { Console.WriteLine("Draw"); } else if (swit.Player1Suwit.Equals("rock") && swit.Player2Suwit.Equals("paper")) { Console.WriteLine("Player 2 wins"); player2Win++; } else if (swit.Player1Suwit.Equals("rock") && swit.Player2Suwit.Equals("scissor")) { Console.WriteLine("Player 1 Wins"); player1Win++; } else if (swit.Player1Suwit.Equals("paper") && swit.Player2Suwit.Equals("rock")) { Console.WriteLine("Player 1 wins"); player1Win++; } else if (swit.Player1Suwit.Equals("paper") && swit.Player2Suwit.Equals("scissor")) { Console.WriteLine("Player 2 wins"); player2Win++; } else if (swit.Player1Suwit.Equals("scissor") && swit.Player2Suwit.Equals("rock")) { Console.WriteLine("Player 2 wins"); player2Win++; } else if (swit.Player1Suwit.Equals("scissor") && swit.Player2Suwit.Equals("paper")) { Console.WriteLine("Player 1 Wins"); player1Win++; } if (IsEnd()) { _gameEndend = true; Guid winner = (player1Win == 3) ? _player1 : _player2; Guid loser = (winner.Equals(_player1)) ? _player2 : _player1; Broadcast(new Win(winner)); Broadcast(new Lose(loser)); } }
public void Suwit(Suwit s) { if (_game == null) { throw new Exception("Game hasn't been started!"); } _game.Suwit(s); }
public abstract void Suwit(Suwit s);