Ejemplo n.º 1
0
    public void Move(int turn, String move)
    {
        move = Normalize(move);
        char f = move[0];

        if (move == "O-O")
        {
            gameManager.KingSideCastling(turn);
        }
        else if (move == "O-O-O")
        {
            gameManager.QueenSideCastling(turn);
        }
        else
        {
            int      n    = move.Length;
            int      rank = move[n - 1] - '1'; //hang
            int      file = move[n - 2] - 'a'; //cot
            Location dest = new Location(file, rank);
            Location src;

            if ("KQBNR".Contains(f.ToString()))
            {
                String disam = "";
                if (n == 4)
                {
                    disam += move[1];
                }
                src = gameManager.Find(turn, f, dest, disam);
            }
            else         //Pawn
            {
                String disam = "";
                if (n == 3)
                {
                    disam += move[0];
                }
                src = gameManager.Find(turn, 'P', dest, disam);         //Find Pawn
            }
            gameManager.Move(src, dest);
        }
    }