Browse Source

Added lastFeedback functionality for later use

Nick Stolbov 3 years ago
parent
commit
0a2664e4a5
  1. 6
      src/main/java/Game/Chess.java

6
src/main/java/Game/Chess.java

@ -12,6 +12,8 @@ public class Chess extends Game {
private ArrayList<ChessFigure> destroyedWhiteFigures;
private ArrayList<ChessFigure> 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,7 +93,8 @@ public class Chess extends Game {
result.add("Invalid input!");
switch (moveFeedback) {
case INVALID:
if (chessBoard.getBoard()[target[0]][target[1]].getTeam() == getCurrentTeam())
if (targetFigure != null)
if (targetFigure.getTeam() == sourceFigure.getTeam())
result.add("You are on the same Team! [" + getCurrentTeam().name() + "]");
break;
case OUTSIDEOFBOARD:

Loading…
Cancel
Save