Task 13 done with the help of Nathan

Signed-off-by: Immanuel Alvaro Bhirawa <u7280427@anu.edu.au>
This commit is contained in:
Immanuel Alvaro Bhirawa 2023-05-09 10:25:20 +10:00
parent bd2b3477b6
commit c4db86793c

View File

@ -660,9 +660,9 @@ public class BlueLagoon {
State state = new State(stateString);
char pieceType = moveString.charAt(0);
String coordStr = moveString.substring(2);
int x = Integer.parseInt(coordStr.split(",")[0]);
int y = Integer.parseInt(coordStr.split(",")[1]);
Coord coord = new Coord(x, y);
int y = Integer.parseInt(coordStr.split(",")[0]);
int x = Integer.parseInt(coordStr.split(",")[1]);
Coord coord = new Coord(y, x);
// if the move is valid, place it
if ( isMoveValid(stateString, moveString)) state.placePiece(coord, pieceType);
@ -677,7 +677,6 @@ public class BlueLagoon {
state.scorePhase();
state.cleanBoard();
state.distributeResources();
// if(!state.getCurrentPlayer().canPlay(state)) state.nextPlayer();
state.nextPhase();
}
@ -685,11 +684,13 @@ public class BlueLagoon {
// Tally up the score, if the current Player does not have any more move, go to next player
else if (state.getCurrentPhase() == 'S') {
state.scorePhase();
state.nextPlayer();
}
}
state.nextPlayer();
if (!state.getCurrentPlayer().canPlay(state)) state.nextPlayer();
return state.toString();
}