Search in sources :

Example 1 with Wraith

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;
    }
}
Also used : UnitInfo(ecgberht.UnitInfo) MineralPatch(org.openbw.bwapi4j.unit.MineralPatch) Worker(org.openbw.bwapi4j.unit.Worker) Squad(ecgberht.Squad) Wraith(org.openbw.bwapi4j.unit.Wraith)

Aggregations

Squad (ecgberht.Squad)1 UnitInfo (ecgberht.UnitInfo)1 MineralPatch (org.openbw.bwapi4j.unit.MineralPatch)1 Worker (org.openbw.bwapi4j.unit.Worker)1 Wraith (org.openbw.bwapi4j.unit.Wraith)1