From 0a2664e4a57727d550db5e43fe8a1dde752f293b Mon Sep 17 00:00:00 2001 From: Nick Stolbov Date: Mon, 31 Jan 2022 23:33:54 +0100 Subject: [PATCH] Added lastFeedback functionality for later use --- src/main/java/Game/Chess.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) 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!");