Search in sources :

Example 1 with ScienceFacility

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

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

the class ChooseEMP method execute.

@Override
public State execute() {
    try {
        if (gameState.enemyRace != Race.Protoss)
            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.EMP_Shockwave) && !gameState.getPlayer().hasResearched(TechType.EMP_Shockwave)) {
            gameState.chosenUnitUpgrader = chosen;
            gameState.chosenResearch = TechType.EMP_Shockwave;
            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)

Aggregations

ResearchingFacility (org.openbw.bwapi4j.unit.ResearchingFacility)2 ScienceFacility (org.openbw.bwapi4j.unit.ScienceFacility)2