Search in sources :

Example 91 with Route

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

the class MoveDelegateTest method testAirToWater.

@Test
public void testAirToWater() {
    final Route route = new Route();
    route.setStart(egypt);
    route.add(eastMediteranean);
    final IntegerMap<UnitType> map = new IntegerMap<>();
    map.put(fighter, 3);
    map.put(bomber, 3);
    final String 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 92 with Route

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

the class MoveDelegateTest method testNonCombatMoveToConquered.

@Test
public void testNonCombatMoveToConquered() {
    // take over libya
    Route route = new Route();
    route.setStart(equatorialAfrica);
    route.add(libya);
    IntegerMap<UnitType> map = new IntegerMap<>();
    map.put(armour, 1);
    String results = delegate.move(GameDataTestUtil.getUnits(map, route.getStart()), route);
    assertValid(results);
    // go to non combat
    bridge.setStepName("britishNonCombatMove");
    delegate.setDelegateBridgeAndPlayer(bridge);
    delegate.start();
    // move more into libya
    route = new Route();
    route.setStart(equatorialAfrica);
    route.add(libya);
    map = new IntegerMap<>();
    map.put(armour, 1);
    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 93 with Route

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

the class MoveDelegateTest method testUnitsStayWithTransports.

@Test
public void testUnitsStayWithTransports() {
    IntegerMap<UnitType> map = new IntegerMap<>();
    map.put(armour, 2);
    Route route = new Route();
    route.setStart(egypt);
    route.add(redSea);
    String results = delegate.move(GameDataTestUtil.getUnits(map, route.getStart()), route, route.getEnd().getUnits().getUnits());
    assertValid(results);
    map = new IntegerMap<>();
    map.put(armour, 2);
    route = new Route();
    route.setStart(redSea);
    route.add(indianOcean);
    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 94 with Route

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

the class MoveDelegateTest method testTransportCantLoadUnloadAfterBattle.

@Test
public void testTransportCantLoadUnloadAfterBattle() {
    bridge = super.getDelegateBridge(russians);
    bridge.setStepName("russianCombatMove");
    westEurope.setOwner(russians);
    // Attacking force
    final List<Unit> attackTrns = transport.create(1, russians);
    final List<Unit> attackList = bomber.create(2, russians);
    attackList.addAll(attackTrns);
    bridge.setRandomSource(new ScriptedRandomSource(new int[] { 1 }));
    final DiceRoll roll = DiceRoll.rollDice(attackList, false, russians, bridge, new MockBattle(balticSeaZone), "", TerritoryEffectHelper.getEffects(balticSeaZone), null);
    assertEquals(2, roll.getHits());
    bridge.setStepName("russianNonCombatMove");
    // Test the move
    final Collection<Unit> moveInf = infantry.create(2, russians);
    final Route route = new Route();
    route.setStart(karelia);
    route.add(balticSeaZone);
    route.add(westEurope);
    // Once loaded, shouldnt be able to unload
    final String results = delegate.move(moveInf, route);
    assertError(results);
}
Also used : ScriptedRandomSource(games.strategy.engine.random.ScriptedRandomSource) Unit(games.strategy.engine.data.Unit) Route(games.strategy.engine.data.Route) Test(org.junit.jupiter.api.Test)

Example 95 with Route

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

the class MoveDelegateTest method testNonCombatAttack.

@Test
public void testNonCombatAttack() {
    bridge.setStepName("britishNonCombatMove");
    delegate.setDelegateBridgeAndPlayer(bridge);
    delegate.start();
    final Route route = new Route();
    route.setStart(equatorialAfrica);
    route.add(algeria);
    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)

Aggregations

Route (games.strategy.engine.data.Route)200 Test (org.junit.jupiter.api.Test)148 Territory (games.strategy.engine.data.Territory)132 Unit (games.strategy.engine.data.Unit)84 UnitType (games.strategy.engine.data.UnitType)83 ITestDelegateBridge (games.strategy.engine.data.ITestDelegateBridge)77 TripleAUnit (games.strategy.triplea.TripleAUnit)70 IntegerMap (games.strategy.util.IntegerMap)69 PlayerID (games.strategy.engine.data.PlayerID)64 ArrayList (java.util.ArrayList)44 GameData (games.strategy.engine.data.GameData)29 ScriptedRandomSource (games.strategy.engine.random.ScriptedRandomSource)26 HashSet (java.util.HashSet)21 HashMap (java.util.HashMap)20 Collection (java.util.Collection)15 List (java.util.List)12 Set (java.util.Set)12 UnitAttachment (games.strategy.triplea.attachments.UnitAttachment)11 Change (games.strategy.engine.data.Change)10 MoveValidationResult (games.strategy.triplea.delegate.dataObjects.MoveValidationResult)10