state: isPhaseOver sped up code
This commit is contained in:
parent
73293edb43
commit
f6f3f4a6a1
@ -409,28 +409,20 @@ public class State {
|
|||||||
* Defaults to simple mode
|
* Defaults to simple mode
|
||||||
*/
|
*/
|
||||||
public boolean isPhaseOver() {
|
public boolean isPhaseOver() {
|
||||||
return isPhaseOver(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* is the phase over?
|
|
||||||
* @param simple boolean don't check all player moves
|
|
||||||
*/
|
|
||||||
public boolean isPhaseOver(boolean simple){
|
|
||||||
boolean resourcesLeft = false;
|
boolean resourcesLeft = false;
|
||||||
for (Resource r : resources) {
|
for (Resource r : resources) {
|
||||||
if (r.isAvailable() && r.getType() != 'S') resourcesLeft = true;
|
if (r.isAvailable() && r.getType() != 'S') resourcesLeft = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean moveLeft = false;
|
boolean moveLeft = false;
|
||||||
if (simple) {
|
int numSettlers = 30 - ((numPlayers - 2) * 5);
|
||||||
if (getCurrentPlayer().canPlay(this)) moveLeft = true;
|
for (Player p: players) {
|
||||||
}
|
boolean canPlay = false;
|
||||||
else
|
if (p.getVillages().length < 5) canPlay = true;
|
||||||
{
|
if (p.getSettlers().length < numSettlers) canPlay = true;
|
||||||
for (Player player : players) {
|
if (canPlay) {
|
||||||
if (player.canPlay(this)) moveLeft = true;
|
if (p.canPlay(this)) moveLeft = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return !resourcesLeft || !moveLeft;
|
return !resourcesLeft || !moveLeft;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user