use of bwta.BaseLocation in project Ecgberht by Jabbo16.
the class CheckEnemyBaseVisible method execute.
@Override
public State execute() {
try {
if (!((GameState) this.handler).getGame().enemy().getUnits().isEmpty()) {
for (Unit u : ((GameState) this.handler).getGame().enemy().getUnits()) {
if (u.getType().isBuilding()) {
if (((GameState) this.handler).getGame().getUnitsInRadius(((GameState) this.handler).chosenScout.getPosition(), 500).contains(u)) {
((GameState) this.handler).enemyBase = BWTA.getNearestBaseLocation(u.getTilePosition());
((GameState) this.handler).ScoutSLs = new HashSet<BaseLocation>();
// ((GameState)this.handler).choosenScout.stop();
// ((GameState)this.handler).workerIdle.add(((GameState)this.handler).choosenScout);
((GameState) this.handler).chosenHarasser = ((GameState) this.handler).chosenScout;
((GameState) this.handler).chosenScout = null;
((GameState) this.handler).getGame().sendText(Utils.formatText("!", Utils.Yellow));
((GameState) this.handler).playSound("gear.mp3");
((GameState) this.handler).EnemyBLs.clear();
((GameState) this.handler).EnemyBLs.addAll(((GameState) this.handler).BLs);
// ((GameState)this.handler).EnemyBLs.sort(new BaseLocationComparator(true));
return State.SUCCESS;
}
}
}
}
return State.FAILURE;
} catch (Exception e) {
System.err.println(this.getClass().getSimpleName());
System.err.println(e);
return State.ERROR;
}
}
use of bwta.BaseLocation in project BWJSAL by RobinsonMann.
the class InformationManagerAcceptanceTest method resourceDepotToBaseLocationMappingCorrectlyKeptUpToDate.
/**
* Verify that enemy base location manually set via setBaseAsEnemy is removed
* when a command center that was later observed is destroyed.
*
* This test verifies that base locations can be tied to resource depots even
* if the base location was already marked as an enemy location.
*/
@Test
public void resourceDepotToBaseLocationMappingCorrectlyKeptUpToDate() {
final Race enemyRace = createMockRace(mock(UnitType.class), mock(UnitType.class));
when(this.enemy.getRace()).thenReturn(enemyRace);
final BaseLocation selfStartingLocation = mock(BaseLocation.class);
final BaseLocation enemyStartingLocation = mock(BaseLocation.class);
final BaseLocation otherStartingLocation = mock(BaseLocation.class);
setStartingLocationsOnMock(this.bwtaWrapper, selfStartingLocation, enemyStartingLocation, otherStartingLocation);
setSelfStartingLocationOnMock(this.bwtaWrapper, this.self, selfStartingLocation);
this.target.onStart();
assertThat(this.target.getEnemyBases()).as("no known enemy bases").isEmpty();
// manually set base as enemy
this.target.setBaseAsEnemy(enemyStartingLocation);
assertThat(this.target.getEnemyBases()).as("sanctity test that setBaseAsEnemy actual sets the base as an enemy base").containsExactly(enemyStartingLocation);
// observe enemy command center in enemy base
final TilePosition commandCenterPosition = mock(TilePosition.class);
setNearestBaseLocationOnMock(this.bwtaWrapper, commandCenterPosition, enemyStartingLocation);
final Unit commandCenter = UnitBuilder.mockUnit(this.enemy, mockResourceDepotUnitType(), commandCenterPosition);
this.target.onUnitDiscover(commandCenter);
// command center destroyed
this.target.onUnitDestroy(commandCenter);
// verify location is not enemy
assertThat(this.target.getEnemyBases()).as("because all bases mapped to base location have been destroyed, no more bases for enemy").isEmpty();
}
use of bwta.BaseLocation in project BWJSAL by RobinsonMann.
the class EnemyBaseTrackerTest method onStart_twoBases_enemyBaseDeducible.
@Test
public void onStart_twoBases_enemyBaseDeducible() {
final BaseLocation selfLocation = Mockito.mock(BaseLocation.class);
final BaseLocation enemyLocation = Mockito.mock(BaseLocation.class);
when(this.mockBwta.getStartLocations()).thenReturn(Lists.newArrayList(selfLocation, enemyLocation));
when(this.mockBwta.getStartLocation(mockSelf)).thenReturn(selfLocation);
this.target.onStart();
assertThat(this.target.getEnemyBases()).as("Enemy base deduce from onStart").containsExactly(enemyLocation);
}
use of bwta.BaseLocation in project BWJSAL by RobinsonMann.
the class EnhancedUi method drawBases.
private void drawBases() {
for (BaseLocation baseLocation : bwtaWrapper.getBaseLocations()) {
Position basePosition = baseLocation.getPosition();
drawUtils.highlightBaseLocation(baseLocation, BASE_BOX_COLOR);
for (Unit mineral : baseLocation.getMinerals()) {
drawUtils.highlightMineralField(mineral, MINERAL_CIRCLE_COLOR);
}
// Highlight vespene geysers
for (Unit geyser : baseLocation.getGeysers()) {
drawUtils.highlightGeyser(geyser, GEYSER_COLOR);
}
// Draw a yellow circle around the base location if it is an island expansion
if (baseLocation.isIsland()) {
drawUtils.highlightIslandBaseLocation(baseLocation, BASE_ISLAND_COLOR);
}
}
}
use of bwta.BaseLocation in project BWJSAL by RobinsonMann.
the class EnemyBaseTracker method onUnitDestroy.
@Override
public void onUnitDestroy(final Unit destroyedUnit) {
if (this.game.self().isEnemy(destroyedUnit.getPlayer()) == false) {
return;
}
// If this is an enemy unit we may need to remove a base location
if (destroyedUnit.getType().isResourceDepot() == false) {
return;
}
final BaseLocation resourceDepotBaseLocation = this.bwta.getNearestBaseLocation(destroyedUnit.getTilePosition());
if (this.baseLocationToCenter.containsKey(resourceDepotBaseLocation) == false) {
return;
}
final List<Unit> resourceDepotsAtNearestBaseLocation = this.baseLocationToCenter.get(resourceDepotBaseLocation);
if (resourceDepotsAtNearestBaseLocation.contains(destroyedUnit) == false) {
return;
}
resourceDepotsAtNearestBaseLocation.remove(destroyedUnit);
if (resourceDepotsAtNearestBaseLocation.isEmpty()) {
this.enemyBaseLocations.remove(resourceDepotBaseLocation);
}
}
Aggregations