use of org.openbw.bwapi4j.unit.Wraith in project Ecgberht by Jabbo16.
the class ChooseScout method execute.
@Override
public State execute() {
try {
if (gameState.getStrat().name.equals("PlasmaWraithHell")) {
for (Squad s : gameState.sqManager.squads.values()) {
for (UnitInfo u : s.members) {
if (u.unit instanceof Wraith) {
gameState.chosenScout = (MobileUnit) u.unit;
s.members.remove(u);
return State.SUCCESS;
}
}
}
}
if (!gameState.workerIdle.isEmpty()) {
Worker chosen = gameState.workerIdle.iterator().next();
gameState.chosenScout = chosen;
gameState.workerIdle.remove(chosen);
}
if (gameState.chosenScout == null) {
for (Worker u : gameState.workerMining.keySet()) {
if (!u.isCarryingMinerals()) {
gameState.chosenScout = u;
MineralPatch mineral = gameState.workerMining.get(u);
if (gameState.mineralsAssigned.containsKey(mineral)) {
gameState.mining--;
gameState.mineralsAssigned.put(mineral, gameState.mineralsAssigned.get(mineral) - 1);
}
gameState.workerMining.remove(u);
break;
}
}
}
if (gameState.chosenScout != null)
return State.SUCCESS;
return State.FAILURE;
} catch (Exception e) {
System.err.println(this.getClass().getSimpleName());
e.printStackTrace();
return State.ERROR;
}
}
Aggregations