Search in sources :

Example 81 with UnitType

use of games.strategy.engine.data.UnitType in project triplea by triplea-game.

the class MoveDelegateTest method testmultipleMovesExceedingMovementLimit.

@Test
public void testmultipleMovesExceedingMovementLimit() {
    final IntegerMap<UnitType> map = new IntegerMap<>();
    map.put(infantry, 2);
    Route route = new Route();
    route.setStart(eastAfrica);
    route.add(kenya);
    assertEquals(2, eastAfrica.getUnits().size());
    assertEquals(0, kenya.getUnits().size());
    String results = delegate.move(GameDataTestUtil.getUnits(map, route.getStart()), route);
    assertValid(results);
    assertEquals(0, eastAfrica.getUnits().size());
    assertEquals(2, kenya.getUnits().size());
    route = new Route();
    route.setStart(kenya);
    route.add(egypt);
    assertEquals(2, kenya.getUnits().size());
    assertEquals(18, egypt.getUnits().size());
    results = delegate.move(GameDataTestUtil.getUnits(map, route.getStart()), route);
    assertError(results);
    assertEquals(2, kenya.getUnits().size());
    assertEquals(18, egypt.getUnits().size());
}
Also used : IntegerMap(games.strategy.util.IntegerMap) UnitType(games.strategy.engine.data.UnitType) Route(games.strategy.engine.data.Route) Test(org.junit.jupiter.api.Test)

Example 82 with UnitType

use of games.strategy.engine.data.UnitType in project triplea by triplea-game.

the class MoveDelegateTest method testCantMoveThroughConqueredNeutral.

@Test
public void testCantMoveThroughConqueredNeutral() {
    // take over neutral
    Route route = new Route();
    route.setStart(equatorialAfrica);
    route.add(westAfrica);
    IntegerMap<UnitType> map = new IntegerMap<>();
    map.put(armour, 1);
    String results = delegate.move(GameDataTestUtil.getUnits(map, route.getStart()), route);
    assertValid(results);
    // make sure we cant move through it by land
    route = new Route();
    route.setStart(equatorialAfrica);
    route.add(westAfrica);
    route.add(algeria);
    map = new IntegerMap<>();
    map.put(armour, 1);
    results = delegate.move(GameDataTestUtil.getUnits(map, route.getStart()), route);
    assertError(results);
    // make sure we can still move units to the territory
    route = new Route();
    route.setStart(equatorialAfrica);
    route.add(westAfrica);
    map = new IntegerMap<>();
    map.put(armour, 1);
    results = delegate.move(GameDataTestUtil.getUnits(map, route.getStart()), route);
    assertValid(results);
    // make sure air can though
    route = new Route();
    route.setStart(congoSeaZone);
    route.add(westAfricaSeaZone);
    route.add(westAfrica);
    route.add(equatorialAfrica);
    map = new IntegerMap<>();
    map.put(fighter, 3);
    results = delegate.move(GameDataTestUtil.getUnits(map, route.getStart()), route);
    assertValid(results);
}
Also used : IntegerMap(games.strategy.util.IntegerMap) UnitType(games.strategy.engine.data.UnitType) Route(games.strategy.engine.data.Route) Test(org.junit.jupiter.api.Test)

Example 83 with UnitType

use of games.strategy.engine.data.UnitType in project triplea by triplea-game.

the class MoveDelegateTest method testOverrunNeutral.

@Test
public void testOverrunNeutral() {
    final IntegerMap<UnitType> map = new IntegerMap<>();
    map.put(armour, 2);
    final Route route = new Route();
    route.setStart(equatorialAfrica);
    route.add(westAfrica);
    assertEquals(4, equatorialAfrica.getUnits().size());
    assertEquals(0, westAfrica.getUnits().size());
    assertEquals(PlayerID.NULL_PLAYERID, westAfrica.getOwner());
    assertEquals(35, british.getResources().getQuantity(pus));
    final String results = delegate.move(GameDataTestUtil.getUnits(map, route.getStart()), route);
    assertValid(results);
    assertEquals(2, equatorialAfrica.getUnits().size());
    assertEquals(2, westAfrica.getUnits().size());
    assertEquals(westAfrica.getOwner(), british);
    assertEquals(32, british.getResources().getQuantity(pus));
}
Also used : IntegerMap(games.strategy.util.IntegerMap) UnitType(games.strategy.engine.data.UnitType) Route(games.strategy.engine.data.Route) Test(org.junit.jupiter.api.Test)

Example 84 with UnitType

use of games.strategy.engine.data.UnitType in project triplea by triplea-game.

the class MoveDelegateTest method testNonCombatAttackNeutral.

@Test
public void testNonCombatAttackNeutral() {
    bridge.setStepName("britishNonCombatMove");
    delegate.setDelegateBridgeAndPlayer(bridge);
    delegate.start();
    final Route route = new Route();
    route.setStart(equatorialAfrica);
    route.add(westAfrica);
    final IntegerMap<UnitType> map = new IntegerMap<>();
    map.put(armour, 2);
    final String results = delegate.move(GameDataTestUtil.getUnits(map, route.getStart()), route);
    assertError(results);
}
Also used : IntegerMap(games.strategy.util.IntegerMap) UnitType(games.strategy.engine.data.UnitType) Route(games.strategy.engine.data.Route) Test(org.junit.jupiter.api.Test)

Example 85 with UnitType

use of games.strategy.engine.data.UnitType in project triplea by triplea-game.

the class TuvUtilsTest method testCostsForTuvWithConsumesUnit.

@Test
public void testCostsForTuvWithConsumesUnit() {
    final PlayerID germans = GameDataTestUtil.germany(gameData);
    final IntegerMap<UnitType> result = TuvUtils.getCostsForTuv(germans, gameData);
    assertEquals(11, result.getInt(GameDataTestUtil.germanFactory(gameData)));
}
Also used : PlayerID(games.strategy.engine.data.PlayerID) UnitType(games.strategy.engine.data.UnitType) Test(org.junit.jupiter.api.Test)

Aggregations

UnitType (games.strategy.engine.data.UnitType)211 Test (org.junit.jupiter.api.Test)108 IntegerMap (games.strategy.util.IntegerMap)86 Route (games.strategy.engine.data.Route)76 Unit (games.strategy.engine.data.Unit)76 PlayerID (games.strategy.engine.data.PlayerID)64 Territory (games.strategy.engine.data.Territory)58 TripleAUnit (games.strategy.triplea.TripleAUnit)49 ArrayList (java.util.ArrayList)44 ITestDelegateBridge (games.strategy.engine.data.ITestDelegateBridge)36 GameParseException (games.strategy.engine.data.GameParseException)29 ScriptedRandomSource (games.strategy.engine.random.ScriptedRandomSource)23 UnitAttachment (games.strategy.triplea.attachments.UnitAttachment)21 HashSet (java.util.HashSet)17 GameData (games.strategy.engine.data.GameData)15 Change (games.strategy.engine.data.Change)14 CompositeChange (games.strategy.engine.data.CompositeChange)14 Resource (games.strategy.engine.data.Resource)13 NamedAttachable (games.strategy.engine.data.NamedAttachable)11 ProductionRule (games.strategy.engine.data.ProductionRule)11