Ejemplo n.º 1
0
    private void SetGameState()
    {
        State = GameState.Normal;
        bool kingInCheck = ActivePlayer.IsKingInCheck(GetOppositeToActivePlayer());

        if (kingInCheck)
        {
            State = GameState.Check;
        }

        if (kingInCheck && !ActivePlayer.HasAnyMoves())
        {
            State = GameState.Mate;
        }

        if (!kingInCheck && !ActivePlayer.HasAnyMoves())
        {
            State = GameState.Stalemate;
        }

        if (State == GameState.Check || State == GameState.Mate)
        {
            Board.SquareSelector.ActivateCheckMateSelector(ActivePlayer.FindFirstPieceOfType(PieceType.King));
        }

        if (State == GameState.Stalemate || State == GameState.Mate)
        {
            EnterEndGame();
        }
    }