state: Added simple mode for isPhaseOver()

This commit is contained in:
Nathan Woodburn 2023-04-26 11:49:06 +10:00
parent 10b23e8a8c
commit e228e9551a
Signed by: nathanwoodburn
GPG Key ID: 203B000478AD0EF1
2 changed files with 18 additions and 1 deletions

View File

@ -538,7 +538,7 @@ public class BlueLagoon {
*/ */
public static boolean isPhaseOver(String stateString){ public static boolean isPhaseOver(String stateString){
State state = new State(stateString); State state = new State(stateString);
return state.isPhaseOver(); return state.isPhaseOver(true);
} }
/** /**

View File

@ -412,6 +412,23 @@ public class State {
return !resourcesLeft || !moveLeft; return !resourcesLeft || !moveLeft;
} }
/**
* is the phase over?
* @param simple boolean don't check all player moves
*/
public boolean isPhaseOver(boolean simple){
boolean resourcesLeft = false;
for (Resource r : resources) {
if (!r.isClaimed() && r.getType() != 'S') resourcesLeft = true;
}
boolean moveLeft = false;
if (getCurrentPlayer().canPlay(this)) moveLeft = true;
return !resourcesLeft || !moveLeft;
}
/** /**
* Clean board for next phase * Clean board for next phase
*/ */