use of games.strategy.engine.data.Route 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());
}
use of games.strategy.engine.data.Route 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);
}
use of games.strategy.engine.data.Route 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));
}
use of games.strategy.engine.data.Route 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);
}
use of games.strategy.engine.data.Route in project triplea by triplea-game.
the class MoveValidatorTest method testValidateUnitsCanLoadInHostileSeaZones.
@Test
public void testValidateUnitsCanLoadInHostileSeaZones() throws Exception {
final GameData twwGameData = TestMapGameData.TWW.getGameData();
// Load german unit in sea zone with no enemy ships
final PlayerID germans = GameDataTestUtil.germany(twwGameData);
final Territory northernGermany = territory("Northern Germany", twwGameData);
final Territory sz27 = territory("27 Sea Zone", twwGameData);
final Route r = new Route(northernGermany, sz27);
northernGermany.getUnits().clear();
addTo(northernGermany, GameDataTestUtil.germanInfantry(twwGameData).create(1, germans));
final List<Unit> transport = sz27.getUnits().getMatches(Matches.unitIsTransport());
MoveValidationResult results = MoveValidator.validateMove(northernGermany.getUnits(), r, germans, transport, new HashMap<>(), false, null, twwGameData);
assertTrue(results.isMoveValid());
// Add USA ship to transport sea zone
final PlayerID usa = GameDataTestUtil.usa(twwGameData);
addTo(sz27, GameDataTestUtil.americanCruiser(twwGameData).create(1, usa));
results = MoveValidator.validateMove(northernGermany.getUnits(), r, germans, transport, new HashMap<>(), false, null, twwGameData);
assertFalse(results.isMoveValid());
// Set 'Units Can Load In Hostile Sea Zones' to true
twwGameData.getProperties().set(Constants.UNITS_CAN_LOAD_IN_HOSTILE_SEA_ZONES, true);
results = MoveValidator.validateMove(northernGermany.getUnits(), r, germans, transport, new HashMap<>(), false, null, twwGameData);
assertTrue(results.isMoveValid());
}
Aggregations