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;
}
}
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;
}
}
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;
}
}
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;
}
}
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;
}
}
Aggregations