Browse Source

Added lastFeedback functionality for later use

feature-chess
Dion Aliu 3 years ago
parent
commit
48e989cbc2
  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> destroyedWhiteFigures;
private ArrayList<ChessFigure> destroyedBlackFigures; private ArrayList<ChessFigure> destroyedBlackFigures;
private ChessBoard.MoveFeedback lastFeedback;
private ChessBoard chessBoard; private ChessBoard chessBoard;
public Chess() { public Chess() {
@ -72,6 +74,7 @@ public class Chess extends Game {
String targetCoords = (char) (target[0] + 97) + "" + (target[1] + 1); String targetCoords = (char) (target[0] + 97) + "" + (target[1] + 1);
ChessBoard.MoveFeedback moveFeedback = chessBoard.moveFigure(source[0], source[1], target[0], target[1]); ChessBoard.MoveFeedback moveFeedback = chessBoard.moveFigure(source[0], source[1], target[0], target[1]);
lastFeedback = moveFeedback;
if (sourceFigure != null) if (sourceFigure != null)
sourceFigureName = sourceFigure.getTeam().name().toCharArray()[0] + sourceFigure.getTeam().name().substring(1).toLowerCase() + " " + sourceFigure.getType().name().toLowerCase(); 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!"); result.add("Invalid input!");
switch (moveFeedback) { switch (moveFeedback) {
case INVALID: 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() + "]"); result.add("You are on the same Team! [" + getCurrentTeam().name() + "]");
break; break;
case OUTSIDEOFBOARD: case OUTSIDEOFBOARD:

Loading…
Cancel
Save