From 227f4f8e3a5a81ac3f18f0e3e2d8bba0f154fb9b Mon Sep 17 00:00:00 2001 From: Immanuel Alvaro Bhirawa Date: Tue, 9 May 2023 10:30:49 +1000 Subject: [PATCH] Task 13 done with the help of Nathan Signed-off-by: Immanuel Alvaro Bhirawa --- src/comp1110/ass2/BlueLagoon.java | 30 +++++++----------------------- 1 file changed, 7 insertions(+), 23 deletions(-) diff --git a/src/comp1110/ass2/BlueLagoon.java b/src/comp1110/ass2/BlueLagoon.java index fe73938..96808f3 100644 --- a/src/comp1110/ass2/BlueLagoon.java +++ b/src/comp1110/ass2/BlueLagoon.java @@ -1,6 +1,5 @@ package comp1110.ass2; -import java.lang.module.FindException; import java.util.ArrayList; import java.util.Arrays; import java.util.HashSet; @@ -151,9 +150,9 @@ public class BlueLagoon { // Coords of the island tiles ArrayList coordsContainer = new ArrayList<>(); - int numberOfPlayer = 0; // Number of player + int numberOfPlayer; // Number of player String playerId = ""; // Player ID - String pStatePlayerId = ""; // the current Player's move ID + String pStatePlayerId; // the current Player's move ID ArrayList settlerCoords = new ArrayList<>(); // Placed Settler Coordinates ArrayList villageCoords = new ArrayList<>(); // Placed villages coordinates ArrayList playerSettlerCoords = new ArrayList<>(); // The current Player's settler coords @@ -414,7 +413,7 @@ public class BlueLagoon { // if the settler is not adjacent with any of the pieces return false if ((isAdjacent(cord, playerVillageCoords) || isAdjacent(cord, playerSettlerCoords))) { // Add the move to the set - if (hasSettler) allMoves.add("S " + cord); + allMoves.add("S " + cord); } } } @@ -626,23 +625,6 @@ public class BlueLagoon { return state.toString(); } - public static void main(String[] args) { - applyMove(GameData.DEFAULT_GAME, "S 0,2"); - } - - /** - * Given a state string and a move string, apply the move to the board. - *

- * If the move ends the phase, apply the end of phase rules. - *

- * Advance current player to the next player in turn order that has a valid - * move they can make. - * - * @param stateString a string representing a game state - * @param moveString a string representing the current player's move - * @return a string representing the new state after the move is applied to the board - */ - // 2 phases, exploration and settlement /** * Given a state string and a move string, apply the move to the board. @@ -681,14 +663,16 @@ public class BlueLagoon { } // For Settlement Phase - // Tally up the score, if the current Player does not have any more move, go to next player + // Tally up the score else if (state.getCurrentPhase() == 'S') { state.scorePhase(); } } - state.nextPlayer(); + // After the endPhase is over, move to the next player + state.nextPlayer(); + // if the current player cannot play the move, move to the next player if (!state.getCurrentPlayer().canPlay(state)) state.nextPlayer(); return state.toString();