Search in sources :

Example 1 with UnitType

use of bwapi.UnitType in project BWJSAL by RobinsonMann.

the class ReservedMapTest method canBuildHere_gameCanBuildHereFalse.

@Test
public void canBuildHere_gameCanBuildHereFalse() {
    final TilePosition positionToBuild = new TilePosition(2, 2);
    final Unit builder = Mockito.mock(Unit.class);
    final UnitType typeToBuild = Mockito.mock(UnitType.class);
    verifyNoMoreInteractions(typeToBuild);
    when(this.mockGame.canBuildHere(positionToBuild, typeToBuild, builder)).thenReturn(false);
    assertThat(this.target.canBuildHere(builder, positionToBuild, typeToBuild)).isFalse();
    verify(this.mockGame).canBuildHere(positionToBuild, typeToBuild, builder);
}
Also used : UnitType(bwapi.UnitType) TilePosition(bwapi.TilePosition) Unit(bwapi.Unit) Test(org.junit.Test)

Example 2 with UnitType

use of bwapi.UnitType in project BWJSAL by RobinsonMann.

the class ReservedMapTest method canBuildHere_partialTilesReserved.

@Test
public void canBuildHere_partialTilesReserved() {
    final TilePosition positionToBuild = new TilePosition(2, 2);
    final Unit builder = Mockito.mock(Unit.class);
    final UnitType typeToBuild = Mockito.mock(UnitType.class);
    when(typeToBuild.tileWidth()).thenReturn(2);
    when(typeToBuild.tileHeight()).thenReturn(2);
    when(this.mockGame.canBuildHere(positionToBuild, typeToBuild, builder)).thenReturn(true);
    this.target.reserveTiles(3, 3);
    assertThat(this.target.canBuildHere(builder, positionToBuild, typeToBuild)).isFalse();
    verify(this.mockGame).canBuildHere(positionToBuild, typeToBuild, builder);
    verify(typeToBuild, times(1)).tileWidth();
    verify(typeToBuild, times(1)).tileHeight();
}
Also used : UnitType(bwapi.UnitType) TilePosition(bwapi.TilePosition) Unit(bwapi.Unit) Test(org.junit.Test)

Example 3 with UnitType

use of bwapi.UnitType in project BWJSAL by RobinsonMann.

the class UnitTypeSetup method setUpUnitTypes.

@SneakyThrows
public static void setUpUnitTypes() {
    UnitType mockFirebat = mock(UnitType.class);
    when(mockFirebat.toString()).thenReturn("Firebat");
    setFinalStatic(bwapi.UnitType.class.getField("Terran_Firebat"), mockFirebat);
}
Also used : UnitType(bwapi.UnitType) SneakyThrows(lombok.SneakyThrows)

Example 4 with UnitType

use of bwapi.UnitType in project BWJSAL by RobinsonMann.

the class BuildTimeTrackerTest method modifyUnitTypeToMock.

private void modifyUnitTypeToMock(final String unitTypeName, final Map<UnitType, Integer> requiredUnits) {
    final UnitType mockDrone = Mockito.mock(UnitType.class);
    when(mockDrone.toString()).thenReturn(unitTypeName);
    when(mockDrone.requiredUnits()).thenReturn(requiredUnits);
    setStaticFinalField(UnitType.class, unitTypeName, mockDrone);
}
Also used : UnitType(bwapi.UnitType)

Example 5 with UnitType

use of bwapi.UnitType in project BWJSAL by RobinsonMann.

the class BuildTimeTrackerTest method enemyHasBuilt_mockEnemyRace_hasBuiltForCenterAndWorkersTrue.

@Test
public void enemyHasBuilt_mockEnemyRace_hasBuiltForCenterAndWorkersTrue() throws Exception {
    final UnitType mockCenter = Mockito.mock(UnitType.class);
    final UnitType mockWorker = Mockito.mock(UnitType.class);
    final Race mockRace = createMockRace(mockCenter, mockWorker);
    when(this.mockEnemy.getRace()).thenReturn(mockRace);
    this.target.onStart();
    assertEnemyHasBuilt(mockCenter, "Race's Center UnitType always built");
    assertEnemyHasBuilt(mockWorker, "Race's Worker UnitType always built");
}
Also used : UnitType(bwapi.UnitType) RaceUtils.createMockRace(BWJSAL.utils.RaceUtils.createMockRace) Race(bwapi.Race) Test(org.junit.Test)

Aggregations

UnitType (bwapi.UnitType)13 TilePosition (bwapi.TilePosition)4 Unit (bwapi.Unit)4 Test (org.junit.Test)4 RaceUtils.createMockRace (BWJSAL.utils.RaceUtils.createMockRace)1 Race (bwapi.Race)1 Point (java.awt.Point)1 SneakyThrows (lombok.SneakyThrows)1