use of games.strategy.engine.data.Route in project triplea by triplea-game.
the class WW2V3Year41Test method testMoveParatroopersAsNonPartroops.
@Test
public void testMoveParatroopersAsNonPartroops() {
// move a bomber and a paratrooper
// one step, but as a normal movement
final PlayerID germans = germans(gameData);
final Territory germany = territory("Germany", gameData);
final Territory nwe = territory("Northwestern Europe", gameData);
final ITestDelegateBridge bridge = getDelegateBridge(germans);
bridge.setStepName("CombatMove");
moveDelegate(gameData).setDelegateBridgeAndPlayer(bridge);
moveDelegate(gameData).start();
TechAttachment.get(germans).setParatroopers("true");
List<Unit> paratrooper = germany.getUnits().getMatches(Matches.unitIsAirTransportable());
paratrooper = paratrooper.subList(0, 1);
final List<Unit> bomberAndParatroop = new ArrayList<>(paratrooper);
bomberAndParatroop.addAll(germany.getUnits().getMatches(Matches.unitIsAirTransport()));
// move to nwe, this is a valid move, and it not a partroop move
move(bomberAndParatroop, new Route(germany, nwe));
}
use of games.strategy.engine.data.Route in project triplea by triplea-game.
the class WW2V3Year41Test method testAirCanLandWithAlliedFighters.
@Test
public void testAirCanLandWithAlliedFighters() {
// germany owns madagascar, with 2 fighters in it
// also 1 carrier, and 1 allied fighter in sz 40
// the fighters should not be able to move from madagascar
// to sz 40, since with the allied fighter, their is no room
// on the carrier
final Territory madagascar = territory("French Madagascar", gameData);
final PlayerID germans = germans(gameData);
madagascar.setOwner(germans);
final Territory sz40 = territory("40 Sea Zone", gameData);
addTo(sz40, carrier(gameData).create(1, germans));
addTo(sz40, fighter(gameData).create(1, italians(gameData)));
addTo(madagascar, fighter(gameData).create(2, germans));
final Route route = gameData.getMap().getRoute(madagascar, sz40);
final ITestDelegateBridge bridge = getDelegateBridge(germans);
bridge.setStepName("CombatMove");
moveDelegate(gameData).setDelegateBridgeAndPlayer(bridge);
moveDelegate(gameData).start();
// don't allow kamikaze
bridge.setRemote(dummyPlayer);
final String error = moveDelegate(gameData).move(madagascar.getUnits().getUnits(), route);
assertError(error);
}
use of games.strategy.engine.data.Route in project triplea by triplea-game.
the class WW2V3Year41Test method testLoadedTransportAttackKillsLoadedUnits.
@Test
public void testLoadedTransportAttackKillsLoadedUnits() {
final PlayerID british = british(gameData);
final MoveDelegate moveDelegate = moveDelegate(gameData);
final ITestDelegateBridge bridge = getDelegateBridge(british);
bridge.setStepName("britishCombatMove");
when(dummyPlayer.selectAttackSubs(any())).thenReturn(true);
bridge.setRemote(dummyPlayer);
moveDelegate.setDelegateBridgeAndPlayer(bridge);
moveDelegate.start();
final Territory sz9 = territory("9 Sea Zone", gameData);
final Territory sz7 = territory("7 Sea Zone", gameData);
final Territory uk = territory("United Kingdom", gameData);
final Route sz9ToSz7 = new Route(sz9, territory("8 Sea Zone", gameData), sz7);
// move the transport to attack, this is suicide but valid
final List<Unit> transports = sz9.getUnits().getMatches(Matches.unitIsTransport());
move(transports, sz9ToSz7);
// load the transport
load(uk.getUnits().getMatches(Matches.unitIsLandTransportable()), new Route(uk, sz7));
moveDelegate(gameData).end();
final ScriptedRandomSource randomSource = new ScriptedRandomSource(new int[] { 0, 1 });
bridge.setRandomSource(randomSource);
bridge.setStepName("britishBattle");
final BattleDelegate battleDelegate = battleDelegate(gameData);
battleDelegate.setDelegateBridgeAndPlayer(bridge);
assertEquals(2, TransportTracker.transporting(transports.get(0)).size());
battleDelegate.start();
// battle already fought
// make sure the infantry die with the transport
assertTrue(sz7.getUnits().getMatches(Matches.unitOwnedBy(british)).isEmpty(), sz7.getUnits().toString());
}
use of games.strategy.engine.data.Route in project triplea by triplea-game.
the class WW2V3Year41Test method testMoveUnitsThroughSubs.
@Test
public void testMoveUnitsThroughSubs() {
final ITestDelegateBridge bridge = getDelegateBridge(british(gameData));
bridge.setStepName("britishNonCombatMove");
moveDelegate(gameData).setDelegateBridgeAndPlayer(bridge);
moveDelegate(gameData).start();
final Territory sz6 = territory("6 Sea Zone", gameData);
final Route route = new Route(sz6, territory("7 Sea Zone", gameData), territory("8 Sea Zone", gameData));
final String error = moveDelegate(gameData).move(sz6.getUnits().getUnits(), route);
assertNull(error, error);
}
use of games.strategy.engine.data.Route in project triplea by triplea-game.
the class WW2V3Year41Test method testFighterCantHoverWithNoCarrierToPlace.
@Test
public void testFighterCantHoverWithNoCarrierToPlace() {
// start the move phase
final ITestDelegateBridge bridge = getDelegateBridge(germans(gameData));
bridge.setStepName("CombatMove");
moveDelegate(gameData).setDelegateBridgeAndPlayer(bridge);
moveDelegate(gameData).start();
bridge.setRemote(dummyPlayer);
// the fighter should not be able to move and hover in the sea zone
// since their are no carriers to place
// the fighter has no movement left
final Territory neEurope = territory("Northwestern Europe", gameData);
final Route route = new Route(neEurope, territory("Germany", gameData), territory("Poland", gameData), territory("Baltic States", gameData), territory("5 Sea Zone", gameData));
final String error = moveDelegate(gameData).move(neEurope.getUnits().getMatches(Matches.unitIsAir()), route);
assertNotNull(error);
}
Aggregations