Archived
0

set blocked state on expansion

This commit is contained in:
Mo
2016-12-22 16:35:36 +03:00
parent 2c92a6fedf
commit 960c82a5e4

View File

@@ -171,9 +171,9 @@ public abstract class AbstractPlace implements Place {
if (market == null) return; if (market == null) return;
if (oldState == null) oldState = POWER_STATE.NONE; if (oldState == null) oldState = POWER_STATE.NONE;
if (newState == null) newState = POWER_STATE.NONE; if (newState == null) newState = POWER_STATE.NONE;
if (oldState.isControl() && !newState.isControl()){ if (oldState.isExpansion() && !newState.isExpansion()){
market.getInControllingRadius(this).forEach(p -> { market.getInControllingRadius(this).forEach(p -> {
if (p instanceof AbstractPlace) ((AbstractPlace)p).removeControlling(this); if (p.getPowerState() == POWER_STATE.BLOCKED) p.setPower(getPower(), POWER_STATE.NONE);
}); });
} }
if (!oldState.isControl() && newState.isControl()){ if (!oldState.isControl() && newState.isControl()){
@@ -181,6 +181,16 @@ public abstract class AbstractPlace implements Place {
if (p instanceof AbstractPlace) ((AbstractPlace)p).addControlling(this); if (p instanceof AbstractPlace) ((AbstractPlace)p).addControlling(this);
}); });
} }
if (oldState.isControl() && !newState.isControl()){
market.getInControllingRadius(this).forEach(p -> {
if (p instanceof AbstractPlace) ((AbstractPlace)p).removeControlling(this);
});
}
if (!oldState.isExpansion() && newState.isExpansion()){
market.getInControllingRadius(this).forEach(p -> {
if (p.getPowerState() == POWER_STATE.NONE) p.setPower(getPower(), POWER_STATE.BLOCKED);
});
}
} }
protected void addControlling(Place controllingSystem){ protected void addControlling(Place controllingSystem){