use of games.strategy.engine.data.Route in project triplea by triplea-game.
the class WW2V3Year42Test method testLingeringSeaUnitsCanMoveAwayFromBattle.
@Test
public void testLingeringSeaUnitsCanMoveAwayFromBattle() {
final Territory sz5 = territory("5 Sea Zone", gameData);
final Territory sz6 = territory("6 Sea Zone", gameData);
final Territory sz7 = territory("7 Sea Zone", gameData);
// add a russian battlship
addTo(sz5, battleship(gameData).create(1, russians(gameData)));
final ITestDelegateBridge bridge = getDelegateBridge(germans(gameData));
bridge.setStepName("CombatMove");
moveDelegate(gameData).setDelegateBridgeAndPlayer(bridge);
moveDelegate(gameData).start();
// attack with a german sub
move(sz7.getUnits().getUnits(), new Route(sz7, sz6, sz5));
// move the transport away
move(sz5.getUnits().getMatches(Matches.unitIsTransport()), new Route(sz5, sz6));
moveDelegate(gameData).end();
// adding of lingering units was moved from end of combat-move phase, to start of battle phase
battleDelegate(gameData).setDelegateBridgeAndPlayer(bridge);
BattleDelegate.doInitialize(battleDelegate(gameData).getBattleTracker(), bridge);
// all units in sz5 should be involved in the battle
final MustFightBattle mfb = (MustFightBattle) MoveDelegate.getBattleTracker(gameData).getPendingBattle(sz5, false, null);
assertEquals(4, mfb.getAttackingUnits().size());
}
use of games.strategy.engine.data.Route in project triplea by triplea-game.
the class MustFightBattleTest method testFightWithIsSuicideOnHit.
@Test
public void testFightWithIsSuicideOnHit() throws Exception {
final GameData twwGameData = TestMapGameData.TWW.getGameData();
// Create battle with 1 cruiser attacking 1 mine
final PlayerID usa = GameDataTestUtil.usa(twwGameData);
final PlayerID germany = GameDataTestUtil.germany(twwGameData);
final Territory sz33 = territory("33 Sea Zone", twwGameData);
addTo(sz33, GameDataTestUtil.americanCruiser(twwGameData).create(1, usa));
final Territory sz40 = territory("40 Sea Zone", twwGameData);
addTo(sz40, GameDataTestUtil.germanMine(twwGameData).create(1, germany));
final ITestDelegateBridge bridge = GameDataTestUtil.getDelegateBridge(usa, twwGameData);
bridge.setStepName("CombatMove");
moveDelegate(twwGameData).setDelegateBridgeAndPlayer(bridge);
moveDelegate(twwGameData).start();
move(sz33.getUnits().getUnits(), new Route(sz33, sz40));
moveDelegate(twwGameData).end();
final MustFightBattle battle = (MustFightBattle) AbstractMoveDelegate.getBattleTracker(twwGameData).getPendingBattle(sz40, false, null);
bridge.setRemote(dummyPlayer);
// Set first roll to hit (mine AA) and check that both units are killed
final ScriptedRandomSource randomSource = new ScriptedRandomSource(0, ScriptedRandomSource.ERROR);
bridge.setRandomSource(randomSource);
battle.fight(bridge);
assertEquals(1, randomSource.getTotalRolled());
assertEquals(0, sz40.getUnits().size());
}
use of games.strategy.engine.data.Route in project triplea by triplea-game.
the class PacificTest method testCanLand1AirfieldStart.
@Test
public void testCanLand1AirfieldStart() {
bridge.setStepName("americanCombatMove");
final Route route = new Route();
route.setStart(unitedStates);
route.add(sz5);
route.add(sz7);
route.add(sz8);
route.add(sz20);
route.add(midway);
final IntegerMap<UnitType> map = new IntegerMap<>();
map.put(fighter, 1);
final String results = delegate.move(GameDataTestUtil.getUnits(map, route.getStart()), route);
assertValid(results);
// assertError( results);
}
use of games.strategy.engine.data.Route in project triplea by triplea-game.
the class PacificTest method testCanLand1AirfieldEnd.
@Test
public void testCanLand1AirfieldEnd() {
bridge.setStepName("americanCombatMove");
final Route route = new Route();
route.setStart(unitedStates);
route.add(sz5);
route.add(sz7);
route.add(sz8);
route.add(sz20);
route.add(midway);
final IntegerMap<UnitType> map = new IntegerMap<>();
map.put(fighter, 1);
final String 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 PacificTest method testCanLand2Airfields.
@Test
public void testCanLand2Airfields() {
bridge.setStepName("americanCombatMove");
final Route route = new Route();
route.setStart(unitedStates);
route.add(sz5);
route.add(sz4);
route.add(sz10);
route.add(sz16);
route.add(sz27);
route.add(newBritain);
final IntegerMap<UnitType> map = new IntegerMap<>();
map.put(fighter, 1);
final String results = delegate.move(GameDataTestUtil.getUnits(map, route.getStart()), route);
assertValid(results);
}
Aggregations