Search in sources :

Example 1 with Academy

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

the class ChooseMarineRange method execute.

@Override
public State execute() {
    try {
        if (gameState.UBs.isEmpty())
            return State.FAILURE;
        String strat = gameState.getStrat().name;
        if (strat.equals("BioMech") || strat.equals("BioMechGreedyFE") || strat.equals("BioMechFE")) {
            Player self = gameState.getPlayer();
            if (!self.isResearching(TechType.Tank_Siege_Mode) && !self.hasResearched(TechType.Tank_Siege_Mode)) {
                return State.FAILURE;
            }
        }
        for (ResearchingFacility u : gameState.UBs) {
            if (!(u instanceof Academy))
                continue;
            if (gameState.getPlayer().hasResearched(TechType.Stim_Packs) && gameState.getPlayer().getUpgradeLevel(UpgradeType.U_238_Shells) < 1 && u.canUpgrade(UpgradeType.U_238_Shells) && !u.isResearching() && !u.isUpgrading()) {
                gameState.chosenUnitUpgrader = u;
                gameState.chosenUpgrade = UpgradeType.U_238_Shells;
                return State.SUCCESS;
            }
        }
        return State.FAILURE;
    } catch (Exception e) {
        System.err.println(this.getClass().getSimpleName());
        e.printStackTrace();
        return State.ERROR;
    }
}
Also used : Player(org.openbw.bwapi4j.Player) Academy(org.openbw.bwapi4j.unit.Academy) ResearchingFacility(org.openbw.bwapi4j.unit.ResearchingFacility)

Example 2 with Academy

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

the class ChooseComsatStation method execute.

@Override
public State execute() {
    try {
        if (!gameState.CCs.isEmpty()) {
            for (CommandCenter c : gameState.CCs.values()) {
                if (!c.isTraining() && c.getAddon() == null) {
                    for (ResearchingFacility u : gameState.UBs) {
                        if (u instanceof Academy) {
                            gameState.chosenBuildingAddon = c;
                            gameState.chosenAddon = UnitType.Terran_Comsat_Station;
                            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 : Academy(org.openbw.bwapi4j.unit.Academy) CommandCenter(org.openbw.bwapi4j.unit.CommandCenter) ResearchingFacility(org.openbw.bwapi4j.unit.ResearchingFacility)

Example 3 with Academy

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

the class ChooseMedic method execute.

@Override
public State execute() {
    try {
        if (gameState.UBs.isEmpty())
            return State.FAILURE;
        else {
            for (ResearchingFacility u : gameState.UBs) {
                if (u instanceof Academy) {
                    int marine_count = 0;
                    if (!gameState.DBs.isEmpty()) {
                        marine_count = gameState.DBs.values().stream().mapToInt(Set::size).sum();
                    }
                    if (!gameState.MBs.isEmpty() && Util.countUnitTypeSelf(UnitType.Terran_Medic) * 4 < Util.countUnitTypeSelf(UnitType.Terran_Marine) - marine_count) {
                        for (Barracks b : gameState.MBs) {
                            if (!b.isTraining()) {
                                gameState.chosenUnit = UnitType.Terran_Medic;
                                gameState.chosenTrainingFacility = b;
                                return State.SUCCESS;
                            }
                        }
                    }
                    break;
                }
            }
        }
        return State.FAILURE;
    } catch (Exception e) {
        System.err.println(this.getClass().getSimpleName());
        e.printStackTrace();
        return State.ERROR;
    }
}
Also used : Set(java.util.Set) Academy(org.openbw.bwapi4j.unit.Academy) ResearchingFacility(org.openbw.bwapi4j.unit.ResearchingFacility) Barracks(org.openbw.bwapi4j.unit.Barracks)

Example 4 with Academy

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

the class ChooseStimUpgrade method execute.

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

Aggregations

Academy (org.openbw.bwapi4j.unit.Academy)4 ResearchingFacility (org.openbw.bwapi4j.unit.ResearchingFacility)4 Set (java.util.Set)1 Player (org.openbw.bwapi4j.Player)1 Barracks (org.openbw.bwapi4j.unit.Barracks)1 CommandCenter (org.openbw.bwapi4j.unit.CommandCenter)1