Search in sources :

Example 1 with MachineShop

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

the class ChooseCharonBoosters method execute.

@Override
public State execute() {
    try {
        if (gameState.UBs.isEmpty() || !gameState.getStrat().trainUnits.contains(UnitType.Terran_Goliath) || gameState.maxGoliaths == 0) {
            return State.FAILURE;
        }
        for (ResearchingFacility u : gameState.UBs) {
            if (!(u instanceof MachineShop))
                continue;
            if (gameState.getPlayer().getUpgradeLevel(UpgradeType.Charon_Boosters) < 1 && u.canUpgrade(UpgradeType.Charon_Boosters) && !u.isResearching() && !u.isUpgrading()) {
                gameState.chosenUnitUpgrader = u;
                gameState.chosenUpgrade = UpgradeType.Charon_Boosters;
                return State.SUCCESS;
            }
        }
        return State.FAILURE;
    } catch (Exception e) {
        System.err.println(this.getClass().getSimpleName());
        e.printStackTrace();
        return State.ERROR;
    }
}
Also used : MachineShop(org.openbw.bwapi4j.unit.MachineShop) ResearchingFacility(org.openbw.bwapi4j.unit.ResearchingFacility)

Example 2 with MachineShop

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

the class ChooseMachineShop method execute.

@Override
public State execute() {
    try {
        if (gameState.getStrat().name.equals("VultureRush") && (gameState.Fs.size() < 2 || gameState.UBs.stream().anyMatch(u -> u instanceof MachineShop)))
            return State.FAILURE;
        if (gameState.getStrat().name.equals("TheNitekat") && (gameState.Fs.size() > 1 || gameState.UBs.stream().anyMatch(u -> u instanceof MachineShop)))
            return State.FAILURE;
        if (!gameState.Fs.isEmpty()) {
            for (Factory c : gameState.Fs) {
                if (!c.isTraining() && c.getAddon() == null) {
                    gameState.chosenBuildingAddon = c;
                    gameState.chosenAddon = UnitType.Terran_Machine_Shop;
                    return State.SUCCESS;
                }
            }
        }
        gameState.chosenBuildingAddon = null;
        gameState.chosenAddon = null;
        return State.FAILURE;
    } catch (Exception e) {
        System.err.println(this.getClass().getSimpleName());
        e.printStackTrace();
        return State.ERROR;
    }
}
Also used : MachineShop(org.openbw.bwapi4j.unit.MachineShop) UnitType(org.openbw.bwapi4j.type.UnitType) GameState(ecgberht.GameState) State(org.iaie.btree.BehavioralTree.State) Action(org.iaie.btree.task.leaf.Action) Factory(org.openbw.bwapi4j.unit.Factory) MachineShop(org.openbw.bwapi4j.unit.MachineShop) Factory(org.openbw.bwapi4j.unit.Factory)

Example 3 with MachineShop

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

the class ChooseSiegeMode method execute.

@Override
public State execute() {
    try {
        if (gameState.UBs.isEmpty())
            return State.FAILURE;
        for (ResearchingFacility u : gameState.UBs) {
            if (!(u instanceof MachineShop))
                continue;
            if (!gameState.getPlayer().hasResearched(TechType.Tank_Siege_Mode) && u.canResearch(TechType.Tank_Siege_Mode) && !u.isResearching() && !u.isUpgrading()) {
                gameState.chosenUnitUpgrader = u;
                gameState.chosenResearch = TechType.Tank_Siege_Mode;
                return State.SUCCESS;
            }
        }
        return State.FAILURE;
    } catch (Exception e) {
        System.err.println(this.getClass().getSimpleName());
        e.printStackTrace();
        return State.ERROR;
    }
}
Also used : MachineShop(org.openbw.bwapi4j.unit.MachineShop) ResearchingFacility(org.openbw.bwapi4j.unit.ResearchingFacility)

Example 4 with MachineShop

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

the class ChooseVultureMines method execute.

@Override
public State execute() {
    try {
        if (gameState.UBs.isEmpty())
            return State.FAILURE;
        for (ResearchingFacility u : gameState.UBs) {
            if (!(u instanceof MachineShop))
                continue;
            if (!gameState.getPlayer().hasResearched(TechType.Spider_Mines) && u.canResearch(TechType.Spider_Mines) && !u.isResearching() && !u.isUpgrading()) {
                gameState.chosenUnitUpgrader = u;
                gameState.chosenResearch = TechType.Spider_Mines;
                return State.SUCCESS;
            }
        }
        return State.FAILURE;
    } catch (Exception e) {
        System.err.println(this.getClass().getSimpleName());
        e.printStackTrace();
        return State.ERROR;
    }
}
Also used : MachineShop(org.openbw.bwapi4j.unit.MachineShop) ResearchingFacility(org.openbw.bwapi4j.unit.ResearchingFacility)

Example 5 with MachineShop

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

the class ChooseVultureSpeed method execute.

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

Aggregations

MachineShop (org.openbw.bwapi4j.unit.MachineShop)5 ResearchingFacility (org.openbw.bwapi4j.unit.ResearchingFacility)4 GameState (ecgberht.GameState)1 State (org.iaie.btree.BehavioralTree.State)1 Action (org.iaie.btree.task.leaf.Action)1 UnitType (org.openbw.bwapi4j.type.UnitType)1 Factory (org.openbw.bwapi4j.unit.Factory)1