Skip to content

Move validation not working #2

@LovinLifee

Description

@LovinLifee

I tried to simulate a game, 1. E4, 2. E5, but then it allows me to capture the E5 pawn with the E4 pawn even though I'm validating the moves.

public void attemptMove(IChessPlayer player, Move move) {
		Side toMove = board.getSideToMove();
		if((toMove.equals(Side.WHITE) && player.equals(playerBlack)) ||
				(toMove.equals(Side.BLACK) && player.equals(playerWhite))) {
			player.sendMessage("It's not your turn to move.");
			return;
		}
		if(!board.isMoveLegal(move, true)) {
			player.sendMessage("That's an illeagal move.");
			return;
		}
		
		if(move.equals(new Move(Square.NONE, Square.NONE))) {
			return;
		}

		boolean moved = board.doMove(move, true);

		if(!moved) {
			player.sendMessage("Something went wrong!");
			return;
		}

		if(board.isDraw()) {
			player.sendMessage("Draw!");
			return;
		}

		if(board.isMated()) {
			player.sendMessage("Checkmate!");
		}
	}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions