Search in sources :

Example 1 with Armory

use of org.openbw.bwapi4j.unit.Armory in project Ecgberht by Jabbo16.

the class ChooseGoliath method execute.

@Override
public State execute() {
    try {
        if (gameState.UBs.stream().filter(unit -> unit instanceof Armory).count() < 1)
            return State.FAILURE;
        int count = 0;
        for (Unit u : gameState.getGame().getUnits(gameState.getPlayer())) {
            if (!u.exists())
                continue;
            if (u.getType() == UnitType.Terran_Goliath)
                count++;
            if (count >= gameState.maxGoliaths)
                return State.FAILURE;
        }
        if (!gameState.Fs.isEmpty()) {
            for (Factory b : gameState.Fs) {
                if (!b.isTraining() && b.canTrain(UnitType.Terran_Goliath)) {
                    gameState.chosenUnit = UnitType.Terran_Goliath;
                    gameState.chosenTrainingFacility = b;
                    return State.SUCCESS;
                }
            }
        }
        return State.FAILURE;
    } catch (Exception e) {
        System.err.println(this.getClass().getSimpleName());
        e.printStackTrace();
        return State.ERROR;
    }
}
Also used : Factory(org.openbw.bwapi4j.unit.Factory) Unit(org.openbw.bwapi4j.unit.Unit) Armory(org.openbw.bwapi4j.unit.Armory)

Example 2 with Armory

use of org.openbw.bwapi4j.unit.Armory in project Ecgberht by Jabbo16.

the class ChooseArmorMechUp method execute.

@Override
public State execute() {
    try {
        if (gameState.UBs.isEmpty())
            return State.FAILURE;
        for (ResearchingFacility u : gameState.UBs) {
            if (!(u instanceof Armory))
                continue;
            if (u.canUpgrade(UpgradeType.Terran_Vehicle_Plating) && !u.isResearching() && !u.isUpgrading() && gameState.getPlayer().getUpgradeLevel(UpgradeType.Terran_Vehicle_Plating) < 3) {
                gameState.chosenUnitUpgrader = u;
                gameState.chosenUpgrade = UpgradeType.Terran_Vehicle_Plating;
                return State.SUCCESS;
            }
        }
        return State.FAILURE;
    } catch (Exception e) {
        System.err.println(this.getClass().getSimpleName());
        e.printStackTrace();
        return State.ERROR;
    }
}
Also used : ResearchingFacility(org.openbw.bwapi4j.unit.ResearchingFacility) Armory(org.openbw.bwapi4j.unit.Armory)

Example 3 with Armory

use of org.openbw.bwapi4j.unit.Armory in project Ecgberht by Jabbo16.

the class ChooseWeaponMechUp method execute.

@Override
public State execute() {
    try {
        if (gameState.UBs.isEmpty())
            return State.FAILURE;
        for (ResearchingFacility u : gameState.UBs) {
            if (!(u instanceof Armory))
                continue;
            if (u.canUpgrade(UpgradeType.Terran_Vehicle_Weapons) && !u.isResearching() && !u.isUpgrading() && gameState.getPlayer().getUpgradeLevel(UpgradeType.Terran_Vehicle_Weapons) < 3) {
                gameState.chosenUnitUpgrader = u;
                gameState.chosenUpgrade = UpgradeType.Terran_Vehicle_Weapons;
                return State.SUCCESS;
            }
        }
        return State.FAILURE;
    } catch (Exception e) {
        System.err.println(this.getClass().getSimpleName());
        e.printStackTrace();
        return State.ERROR;
    }
}
Also used : ResearchingFacility(org.openbw.bwapi4j.unit.ResearchingFacility) Armory(org.openbw.bwapi4j.unit.Armory)

Aggregations

Armory (org.openbw.bwapi4j.unit.Armory)3 ResearchingFacility (org.openbw.bwapi4j.unit.ResearchingFacility)2 Factory (org.openbw.bwapi4j.unit.Factory)1 Unit (org.openbw.bwapi4j.unit.Unit)1