use of ecgberht.Util.BaseLocationComparator in project Ecgberht by Jabbo16.
the class CheckEnemyBaseVisible method execute.
@Override
public State execute() {
try {
List<PlayerUnit> enemies = gameState.getGame().getUnits(gameState.getIH().enemy());
if (!enemies.isEmpty()) {
for (UnitInfo u : gameState.unitStorage.getEnemyUnits().values().stream().filter(u -> u.unitType.isBuilding()).collect(Collectors.toSet())) {
if (Util.broodWarDistance(gameState.chosenScout.getPosition(), u.lastPosition) <= 500) {
gameState.enemyMainBase = Util.getClosestBaseLocation(u.lastPosition);
gameState.scoutSLs = new HashSet<>();
if (!gameState.getStrat().name.equals("PlasmaWraithHell")) {
gameState.chosenHarasser = (Worker) gameState.chosenScout;
}
gameState.chosenScout = null;
Util.sendText("!");
gameState.playSound("gearthere.mp3");
if (gameState.enemyStartBase == null) {
gameState.enemyBLs.clear();
gameState.enemyBLs.addAll(gameState.BLs);
gameState.enemyBLs.sort(new BaseLocationComparator(gameState.enemyMainBase));
if (gameState.firstScout) {
gameState.enemyStartBase = gameState.enemyMainBase;
gameState.enemyMainArea = gameState.enemyStartBase.getArea();
gameState.enemyNaturalBase = gameState.enemyBLs.get(1);
gameState.enemyNaturalArea = gameState.enemyNaturalBase.getArea();
}
}
return State.SUCCESS;
}
}
}
return State.FAILURE;
} catch (Exception e) {
System.err.println(this.getClass().getSimpleName());
e.printStackTrace();
return State.ERROR;
}
}
use of ecgberht.Util.BaseLocationComparator in project Ecgberht by Jabbo16.
the class CheckVisibleBase method execute.
@Override
public State execute() {
try {
if (gameState.chosenScout == null)
return State.FAILURE;
if (gameState.scoutSLs.size() == 1 && gameState.enemyMainBase == null) {
gameState.enemyMainBase = gameState.scoutSLs.iterator().next();
gameState.enemyBLs.clear();
gameState.enemyBLs.addAll(gameState.BLs);
gameState.enemyBLs.sort(new BaseLocationComparator(gameState.enemyMainBase));
if (gameState.firstScout) {
gameState.enemyStartBase = gameState.enemyMainBase;
gameState.enemyMainArea = gameState.enemyStartBase.getArea();
gameState.enemyNaturalBase = gameState.enemyBLs.get(1);
gameState.enemyNaturalArea = gameState.enemyNaturalBase.getArea();
}
}
if (!gameState.scoutSLs.isEmpty()) {
for (Base b : gameState.scoutSLs) {
if ((gameState.getGame().getBWMap().isVisible(b.getLocation()))) {
gameState.scoutSLs.remove(b);
return State.SUCCESS;
}
}
}
return State.FAILURE;
} catch (Exception e) {
System.err.println(this.getClass().getSimpleName());
e.printStackTrace();
return State.ERROR;
}
}
Aggregations