Search in sources :

Example 6 with ResearchingFacility

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

the class ChooseIrradiate method execute.

@Override
public State execute() {
    try {
        if (gameState.enemyRace != Race.Zerg)
            return State.FAILURE;
        boolean found = false;
        ScienceFacility chosen = null;
        for (ResearchingFacility r : gameState.UBs) {
            if (r instanceof ScienceFacility && !r.isResearching()) {
                found = true;
                chosen = (ScienceFacility) r;
                break;
            }
        }
        if (!found)
            return State.FAILURE;
        if (!gameState.getPlayer().isResearching(TechType.Irradiate) && !gameState.getPlayer().hasResearched(TechType.Irradiate)) {
            gameState.chosenUnitUpgrader = chosen;
            gameState.chosenResearch = TechType.Irradiate;
            return State.SUCCESS;
        }
        return State.FAILURE;
    } catch (Exception e) {
        System.err.println(this.getClass().getSimpleName());
        e.printStackTrace();
        return State.ERROR;
    }
}
Also used : ScienceFacility(org.openbw.bwapi4j.unit.ScienceFacility) ResearchingFacility(org.openbw.bwapi4j.unit.ResearchingFacility)

Example 7 with ResearchingFacility

use of org.openbw.bwapi4j.unit.ResearchingFacility 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 8 with ResearchingFacility

use of org.openbw.bwapi4j.unit.ResearchingFacility 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 9 with ResearchingFacility

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

the class ChooseArmorInfUp method execute.

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

Example 10 with ResearchingFacility

use of org.openbw.bwapi4j.unit.ResearchingFacility 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)

Aggregations

ResearchingFacility (org.openbw.bwapi4j.unit.ResearchingFacility)14 Academy (org.openbw.bwapi4j.unit.Academy)4 MachineShop (org.openbw.bwapi4j.unit.MachineShop)4 Armory (org.openbw.bwapi4j.unit.Armory)2 EngineeringBay (org.openbw.bwapi4j.unit.EngineeringBay)2 ScienceFacility (org.openbw.bwapi4j.unit.ScienceFacility)2 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