Пример #1
0
 /// <summary>
 /// Returns true and notifies playGameState if an enemy army enters the castle and false otherwise.
 /// </summary>
 public bool PerformAction(Army enteredArmy)
 {
     if (enteredArmy.PlayerType != ownerType)
     {
         if (enteredArmy.PlayerType == PlayerType.FIRST)
         {
             playGameState.OnFinishGame(ResultType.FIRST_WIN);
         }
         else if (enteredArmy.PlayerType == PlayerType.SECOND)
         {
             playGameState.OnFinishGame(ResultType.SECOND_WIN);
         }
         return(true);
     }
     return(false);
 }
        /// <summary>
        /// Checks that no armies of one of the players exist on the board.
        /// If so, notifies play game state with the corresponding result type
        /// and returns true.
        /// Otherwise, returns false.
        /// </summary>
        private bool CheckAliveArmies()
        {
            if (!boardStorage.ContainsPlayerArmies(PlayerType.FIRST))
            {
                playGameState.OnFinishGame(ResultType.SECOND_WIN);
                return(true);
            }

            if (!boardStorage.ContainsPlayerArmies(PlayerType.SECOND))
            {
                playGameState.OnFinishGame(ResultType.FIRST_WIN);
                return(true);
            }

            return(false);
        }