From 77aaa079846380488f7809751f43894acde7039a Mon Sep 17 00:00:00 2001 From: Nathan Woodburn Date: Tue, 9 May 2023 10:46:38 +1000 Subject: [PATCH 1/2] state: Remove old comment --- src/comp1110/ass2/State.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/comp1110/ass2/State.java b/src/comp1110/ass2/State.java index 2fdb5af..33dff0f 100644 --- a/src/comp1110/ass2/State.java +++ b/src/comp1110/ass2/State.java @@ -406,7 +406,6 @@ public class State { /** * is the phase over? - * Defaults to simple mode */ public boolean isPhaseOver() { boolean resourcesLeft = false; From 519e9e840e9038407aaabd087ebf92dec70d198d Mon Sep 17 00:00:00 2001 From: Nathan Woodburn Date: Tue, 9 May 2023 10:46:51 +1000 Subject: [PATCH 2/2] player: Fixed canPlay bug --- src/comp1110/ass2/Player.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/comp1110/ass2/Player.java b/src/comp1110/ass2/Player.java index 1a6cd06..d759dcb 100644 --- a/src/comp1110/ass2/Player.java +++ b/src/comp1110/ass2/Player.java @@ -243,10 +243,11 @@ public class Player { // Check if the player has placed all their settlers or villages int numSettlers = 30 - ((state.getNumPlayers() - 2) * 5); boolean hasSettler = (settlers.length < numSettlers); - boolean hasVillage = (settlers.length < 5); - if (state.getCurrentPhase() != 'E'){ - if (!hasSettler && !hasVillage) return false; - } + boolean hasVillage = (villages.length < 5); + if (!hasSettler && !hasVillage) return false; +// if (state.getCurrentPhase() != 'E'){ +// if (!hasSettler && !hasVillage) return false; +// } // Add used coords @@ -302,13 +303,13 @@ public class Player { else if(y > state.boardHeight - 1) continue; switch (state.getCurrentPhase()) { case 'E' -> { - if (!islandCoords.contains(cord)) return true; + if (!islandCoords.contains(cord) && hasSettler) return true; if ((isAdjacent(cord, playerVillageCoords) || isAdjacent(cord, playerSettlerCoords))) return true; } // Settlement Phase case 'S' -> { // if the settler is adjacent with any of the pieces return true - if ((isAdjacent(cord, playerVillageCoords) || isAdjacent(cord, playerSettlerCoords))) return true; + if ((isAdjacent(cord, playerVillageCoords) || isAdjacent(cord, playerSettlerCoords)) && hasSettler) return true; } } }