Пример #1
0
        public string EndTurn()
        {
            ChangeActivePlayer();
            bool IsCheck     = Rules.IsCheck(GameBoard, ActivePlayer);
            bool IsStalemate = Rules.IsStalemate(GameBoard, ActivePlayer);

            if (IsCheck && IsStalemate)
            {
                GameStateMessage = ActivePlayer.GetOpposingColor().ToString() + " player won the game!";
            }
            else if (IsCheck)
            {
                GameStateMessage = ActivePlayer.Color.ToString() + " is in check!";
            }
            else if (IsStalemate)
            {
                GameStateMessage = "It's a draw...";
            }
            else
            {
                GameStateMessage = ActivePlayer.Color.ToString() + " player's turn";
            }

            storageHandler.UpdateGameState(ActivePlayer, GameStateMessage);

            return(GameStateMessage);
        }