use of games.strategy.engine.data.UnitType in project triplea by triplea-game.
the class MoveDelegateTest method testReloadTransportAfterRetreatAllied.
@Test
public void testReloadTransportAfterRetreatAllied() {
bridge = super.getDelegateBridge(british);
bridge.setStepName("britishCombatMove");
Route route = new Route();
route.setStart(northSea);
route.add(balticSeaZone);
IntegerMap<UnitType> map = new IntegerMap<>();
map.put(transport, 1);
map.put(infantry, 2);
// Move from the NorthSea to the BalticSea and validate the move
String results = delegate.move(GameDataTestUtil.getUnits(map, route.getStart()), route);
assertValid(results);
// Unload transports into Finland and validate
route = new Route();
route.setStart(balticSeaZone);
route.add(karelia);
map = new IntegerMap<>();
map.put(infantry, 2);
results = delegate.move(GameDataTestUtil.getUnits(map, route.getStart()), route);
assertValid(results);
// Get the attacking sea units that will retreat
final List<Unit> retreatingSeaUnits = new ArrayList<>();
retreatingSeaUnits.addAll(balticSeaZone.getUnits().getMatches(Matches.enemyUnit(germans, gameData)));
// Get the attacking land units that will retreat and their number
final List<Unit> retreatingLandUnits = new ArrayList<>();
retreatingLandUnits.addAll(karelia.getUnits().getMatches(Matches.isUnitAllied(russians, gameData)));
final int retreatingLandSizeInt = retreatingLandUnits.size();
// Get the defending land units that and their number
retreatingLandUnits.addAll(karelia.getUnits().getMatches(Matches.isUnitAllied(british, gameData)));
final List<Unit> defendingLandUnits = new ArrayList<>();
final int defendingLandSizeInt = defendingLandUnits.size();
// Set up the battles and the dependent battles
final IBattle inBalticSeaZone = DelegateFinder.battleDelegate(gameData).getBattleTracker().getPendingBattle(balticSeaZone, false, null);
assertNotNull(balticSeaZone);
// Add some defending units in case there aren't any
final List<Unit> defendList = transport.create(1, germans);
final List<Unit> defendSub = submarine.create(1, germans);
defendList.addAll(defendSub);
// fire the defending transport then the submarine (both miss)
bridge.setRandomSource(new ScriptedRandomSource(new int[] { 1, 2 }));
// Execute the battle and verify no hits
final DiceRoll roll = DiceRoll.rollDice(defendList, true, germans, bridge, new MockBattle(balticSeaZone), "", TerritoryEffectHelper.getEffects(balticSeaZone), null);
assertEquals(0, roll.getHits());
// Get total number of units in Finland before the retreat
final int preCountInt = karelia.getUnits().size();
// Retreat from the Baltic
((MustFightBattle) inBalticSeaZone).externalRetreat(retreatingSeaUnits, northSea, false, bridge);
// Get the total number of units that should be left
final int postCountInt = preCountInt - retreatingLandSizeInt;
// Compare the number of units in Finland to begin with the number after retreating
assertEquals(defendingLandSizeInt, postCountInt);
}
use of games.strategy.engine.data.UnitType 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);
}
use of games.strategy.engine.data.UnitType 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);
}
use of games.strategy.engine.data.UnitType 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);
}
use of games.strategy.engine.data.UnitType 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);
}
Aggregations