use of bwapi.Unit in project BWJSAL by RobinsonMann.
the class UnitsMutexTest method lockUnit_unitPreviouslyLocked_returnsFalse.
@Test
public void lockUnit_unitPreviouslyLocked_returnsFalse() {
final Unit unit = UnitBuilder.mockUnit();
assertThat(this.target.isUnitLocked(unit)).as("Sanity test that unit unlocked").isFalse();
assertThat(this.target.lockUnit(unit)).as("lock acquired").isTrue();
assertThat(this.target.lockUnit(unit)).as("lock was already acquired").isFalse();
assertThat(this.target.isUnitLocked(unit)).isTrue();
}
use of bwapi.Unit in project BWJSAL by RobinsonMann.
the class UnitsMutexTest method isUnitLocked_unitIsFree_returnsFalse.
@Test
public void isUnitLocked_unitIsFree_returnsFalse() {
final Unit unit = UnitBuilder.mockUnit();
assertThat(this.target.isUnitLocked(unit)).isFalse();
}
use of bwapi.Unit in project BWJSAL by RobinsonMann.
the class EnemyBaseTrackerTest method onUnitDiscover_firstBuildingObservedInsidePossibleEnemyStartingLocation_markBaseLocationAsEnemies.
@Test
public void onUnitDiscover_firstBuildingObservedInsidePossibleEnemyStartingLocation_markBaseLocationAsEnemies() {
final Unit observedUnit = UnitBuilder.mockUnit(UnitType.Protoss_Pylon, this.mockEnemy);
replaceUnitTypeWithMock("Protoss_Pylon");
}
use of bwapi.Unit 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 bwapi.Unit 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