diff --git a/src/main/java/Game/Chess.java b/src/main/java/Game/Chess.java index 91fdf86..52c88cb 100644 --- a/src/main/java/Game/Chess.java +++ b/src/main/java/Game/Chess.java @@ -12,6 +12,8 @@ public class Chess extends Game { private ArrayList destroyedWhiteFigures; private ArrayList destroyedBlackFigures; + private ChessBoard.MoveFeedback lastFeedback; + private ChessBoard chessBoard; public Chess() { @@ -72,6 +74,7 @@ public class Chess extends Game { String targetCoords = (char) (target[0] + 97) + "" + (target[1] + 1); ChessBoard.MoveFeedback moveFeedback = chessBoard.moveFigure(source[0], source[1], target[0], target[1]); + lastFeedback = moveFeedback; if (sourceFigure != null) sourceFigureName = sourceFigure.getTeam().name().toCharArray()[0] + sourceFigure.getTeam().name().substring(1).toLowerCase() + " " + sourceFigure.getType().name().toLowerCase(); @@ -90,8 +93,9 @@ public class Chess extends Game { result.add("Invalid input!"); switch (moveFeedback) { case INVALID: - if (chessBoard.getBoard()[target[0]][target[1]].getTeam() == getCurrentTeam()) - result.add("You are on the same Team! [" + getCurrentTeam().name() + "]"); + if (targetFigure != null) + if (targetFigure.getTeam() == sourceFigure.getTeam()) + result.add("You are on the same Team! [" + getCurrentTeam().name() + "]"); break; case OUTSIDEOFBOARD: result.add("Input is not inside the board!");