use of ecgberht.GameState in project Ecgberht by Jabbo16.
the class CollectGas method execute.
@Override
public State execute() {
try {
if (((GameState) this.handler).getPlayer().gas() >= 400) {
return State.FAILURE;
}
Unit chosen = ((GameState) this.handler).chosenWorker;
if (!((GameState) this.handler).refineriesAssigned.isEmpty()) {
Unit closestGeyser = null;
int index = 0;
int count = 0;
for (Pair<Pair<Unit, Integer>, Boolean> g : ((GameState) this.handler).refineriesAssigned) {
if ((closestGeyser == null || chosen.getDistance(g.first.first) < chosen.getDistance(closestGeyser)) && g.first.second < 3 && ((GameState) this.handler).mining > 3 && g.second) {
closestGeyser = g.first.first;
index = count;
}
count++;
}
if (closestGeyser != null) {
((GameState) this.handler).refineriesAssigned.get(index).first.second++;
((GameState) this.handler).workerIdle.remove(chosen);
((GameState) this.handler).workerTask.add(new Pair<Unit, Unit>(chosen, closestGeyser));
chosen.gather(closestGeyser, false);
((GameState) this.handler).chosenWorker = null;
return State.SUCCESS;
}
}
return State.FAILURE;
} catch (Exception e) {
System.err.println(this.getClass().getSimpleName());
System.err.println(e);
return State.ERROR;
}
}
use of ecgberht.GameState in project Ecgberht by Jabbo16.
the class ChooseComsatStation method execute.
@Override
public State execute() {
try {
if (!((GameState) this.handler).CCs.isEmpty()) {
for (Unit c : ((GameState) this.handler).CCs.values()) {
if (!c.isTraining() && c.getAddon() == null) {
for (Unit u : ((GameState) this.handler).UBs) {
if (u.getType() == UnitType.Terran_Academy) {
((GameState) this.handler).chosenBuildingAddon = c;
((GameState) this.handler).chosenAddon = UnitType.Terran_Comsat_Station;
return State.SUCCESS;
}
}
}
}
}
((GameState) this.handler).chosenBuildingAddon = null;
((GameState) this.handler).chosenAddon = null;
return State.FAILURE;
} catch (Exception e) {
System.err.println(this.getClass().getSimpleName());
System.err.println(e);
return State.ERROR;
}
}
use of ecgberht.GameState in project Ecgberht by Jabbo16.
the class ChooseMachineShop method execute.
@Override
public State execute() {
try {
if (!((GameState) this.handler).Fs.isEmpty()) {
for (Unit c : ((GameState) this.handler).Fs) {
if (!c.isTraining() && c.getAddon() == null) {
((GameState) this.handler).chosenBuildingAddon = c;
((GameState) this.handler).chosenAddon = UnitType.Terran_Machine_Shop;
return State.SUCCESS;
}
}
}
((GameState) this.handler).chosenBuildingAddon = null;
((GameState) this.handler).chosenAddon = null;
return State.FAILURE;
} catch (Exception e) {
System.err.println(this.getClass().getSimpleName());
System.err.println(e);
return State.ERROR;
}
}
use of ecgberht.GameState in project Ecgberht by Jabbo16.
the class SendScout method execute.
@Override
public State execute() {
try {
if (((GameState) this.handler).enemyBase == null) {
if (!((GameState) this.handler).ScoutSLs.isEmpty()) {
List<BaseLocation> aux = new ArrayList<BaseLocation>();
for (BaseLocation b : ((GameState) this.handler).ScoutSLs) {
if (BWTA.isConnected(b.getTilePosition(), ((GameState) this.handler).chosenScout.getTilePosition())) {
if (((GameState) this.handler).chosenScout.move(b.getPosition().makeValid())) {
return State.SUCCESS;
}
} else {
aux.add(b);
}
}
((GameState) this.handler).ScoutSLs.removeAll(aux);
}
}
((GameState) this.handler).workerIdle.add(((GameState) this.handler).chosenScout);
((GameState) this.handler).chosenScout.stop();
((GameState) this.handler).chosenScout = null;
return State.FAILURE;
} catch (Exception e) {
System.err.println(this.getClass().getSimpleName());
System.err.println(e);
return State.ERROR;
}
}
use of ecgberht.GameState in project Ecgberht by Jabbo16.
the class ChooseMarine method execute.
@Override
public State execute() {
try {
if (!((GameState) this.handler).MBs.isEmpty()) {
for (Unit b : ((GameState) this.handler).MBs) {
if (!b.isTraining()) {
((GameState) this.handler).chosenUnit = UnitType.Terran_Marine;
((GameState) this.handler).chosenBuilding = b;
return State.SUCCESS;
}
}
}
return State.FAILURE;
} catch (Exception e) {
System.err.println(this.getClass().getSimpleName());
System.err.println(e);
return State.ERROR;
}
}
Aggregations