From 1ad2f6d3f390a09f30e47a033956f702473b79b0 Mon Sep 17 00:00:00 2001 From: Nathan Woodburn Date: Wed, 26 Apr 2023 18:06:37 +1000 Subject: [PATCH] state: Cleaned up isPhaseOver --- src/comp1110/ass2/State.java | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/src/comp1110/ass2/State.java b/src/comp1110/ass2/State.java index 778d1ff..5f27df6 100644 --- a/src/comp1110/ass2/State.java +++ b/src/comp1110/ass2/State.java @@ -396,20 +396,10 @@ public class State { /** * is the phase over? + * Defaults to simple mode */ public boolean isPhaseOver() { - - boolean resourcesLeft = false; - for (Resource r : resources) { - if (!r.isClaimed() && r.getType() != 'S') resourcesLeft = true; - } - - boolean moveLeft = false; - for (Player player : players) { - if (player.canPlay(this)) moveLeft = true; - } - - return !resourcesLeft || !moveLeft; + return isPhaseOver(true); } /** @@ -423,7 +413,15 @@ public class State { } boolean moveLeft = false; - if (getCurrentPlayer().canPlay(this)) moveLeft = true; + if (simple) { + if (getCurrentPlayer().canPlay(this)) moveLeft = true; + } + else + { + for (Player player : players) { + if (player.canPlay(this)) moveLeft = true; + } + } return !resourcesLeft || !moveLeft;