use of org.openbw.bwapi4j.unit.Armory in project Ecgberht by Jabbo16.
the class ChooseGoliath method execute.
@Override
public State execute() {
try {
if (gameState.UBs.stream().filter(unit -> unit instanceof Armory).count() < 1)
return State.FAILURE;
int count = 0;
for (Unit u : gameState.getGame().getUnits(gameState.getPlayer())) {
if (!u.exists())
continue;
if (u.getType() == UnitType.Terran_Goliath)
count++;
if (count >= gameState.maxGoliaths)
return State.FAILURE;
}
if (!gameState.Fs.isEmpty()) {
for (Factory b : gameState.Fs) {
if (!b.isTraining() && b.canTrain(UnitType.Terran_Goliath)) {
gameState.chosenUnit = UnitType.Terran_Goliath;
gameState.chosenTrainingFacility = b;
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.Armory in project Ecgberht by Jabbo16.
the class ChooseArmorMechUp method execute.
@Override
public State execute() {
try {
if (gameState.UBs.isEmpty())
return State.FAILURE;
for (ResearchingFacility u : gameState.UBs) {
if (!(u instanceof Armory))
continue;
if (u.canUpgrade(UpgradeType.Terran_Vehicle_Plating) && !u.isResearching() && !u.isUpgrading() && gameState.getPlayer().getUpgradeLevel(UpgradeType.Terran_Vehicle_Plating) < 3) {
gameState.chosenUnitUpgrader = u;
gameState.chosenUpgrade = UpgradeType.Terran_Vehicle_Plating;
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.Armory in project Ecgberht by Jabbo16.
the class ChooseWeaponMechUp method execute.
@Override
public State execute() {
try {
if (gameState.UBs.isEmpty())
return State.FAILURE;
for (ResearchingFacility u : gameState.UBs) {
if (!(u instanceof Armory))
continue;
if (u.canUpgrade(UpgradeType.Terran_Vehicle_Weapons) && !u.isResearching() && !u.isUpgrading() && gameState.getPlayer().getUpgradeLevel(UpgradeType.Terran_Vehicle_Weapons) < 3) {
gameState.chosenUnitUpgrader = u;
gameState.chosenUpgrade = UpgradeType.Terran_Vehicle_Weapons;
return State.SUCCESS;
}
}
return State.FAILURE;
} catch (Exception e) {
System.err.println(this.getClass().getSimpleName());
e.printStackTrace();
return State.ERROR;
}
}
Aggregations