Exemplo n.º 1
0
    void IsCheckOrEndGame(Chessman referencedChessman)
    {
        bool friendsHaveValidMoves = referencedChessman.EnemyKing.FriendsHaveValidMoves();

        if (referencedChessman.ThreatForEnemyKing(board.GetCells()))
        {
            if (!friendsHaveValidMoves)
            {
                board.EndGame(referencedChessman.isWhite);
            }
            // TODO: Visuals.
            else
            {
                Debug.Log("Check.");
            }
        }
        // Draw: No valid moves and no Check.
        else if (!friendsHaveValidMoves)
        {
            Debug.Log("Draw");
            board.EndGame(null);
        }
    }