use of games.strategy.engine.data.ITestDelegateBridge in project triplea by triplea-game.
the class WW2V3Year41Test method testCantTransportParatroopersWithBombersThatMovedPreviously.
@Test
public void testCantTransportParatroopersWithBombersThatMovedPreviously() {
// make sure bombers can't move then pick up paratroopers
final PlayerID germans = germans(gameData);
final Territory germany = territory("Germany", gameData);
final Territory bulgaria = territory("Bulgaria Romania", gameData);
final Territory poland = territory("Poland", gameData);
final Territory ukraine = territory("Ukraine", gameData);
final ITestDelegateBridge bridge = getDelegateBridge(germans);
bridge.setStepName("CombatMove");
moveDelegate(gameData).setDelegateBridgeAndPlayer(bridge);
moveDelegate(gameData).start();
TechAttachment.get(germans).setParatroopers("true");
// Move the bomber first
final List<Unit> bomber = germany.getUnits().getMatches(Matches.unitIsAirTransport());
move(bomber, new Route(germany, poland));
// Pick up a paratrooper
final List<Unit> bomberAndParatroop = new ArrayList<>(bomber);
bomberAndParatroop.addAll(poland.getUnits().getUnits(GameDataTestUtil.infantry(gameData), 1));
// move them
final String error = moveDelegate(gameData).move(bomberAndParatroop, new Route(poland, bulgaria, ukraine));
assertError(error);
}
use of games.strategy.engine.data.ITestDelegateBridge in project triplea by triplea-game.
the class WW2V3Year41Test method testDefendingTrasnportsAutoKilled.
@Test
public void testDefendingTrasnportsAutoKilled() {
final Territory sz13 = gameData.getMap().getTerritory("13 Sea Zone");
final Territory sz12 = gameData.getMap().getTerritory("12 Sea Zone");
final PlayerID british = GameDataTestUtil.british(gameData);
final MoveDelegate moveDelegate = moveDelegate(gameData);
final ITestDelegateBridge bridge = getDelegateBridge(british);
bridge.setStepName("CombatMove");
moveDelegate.setDelegateBridgeAndPlayer(bridge);
moveDelegate.start();
final Route sz12To13 = new Route();
sz12To13.setStart(sz12);
sz12To13.add(sz13);
final String error = moveDelegate.move(sz12.getUnits().getUnits(), sz12To13);
assertEquals(null, error);
assertEquals(3, sz13.getUnits().size());
moveDelegate.end();
// the transport was not removed automatically
assertEquals(3, sz13.getUnits().size());
final BattleDelegate bd = battleDelegate(gameData);
assertFalse(bd.getBattleTracker().getPendingBattleSites(false).isEmpty());
}
use of games.strategy.engine.data.ITestDelegateBridge in project triplea by triplea-game.
the class WW2V3Year41Test method testParatroopersMoveTwice.
@Test
public void testParatroopersMoveTwice() {
// After a battle move to put a bomber + infantry (paratroop) in a first enemy
// territory, you can make a new move (in the same battle move round) to put
// bomber+ infantry in a more internal enemy territory.
final PlayerID germans = germans(gameData);
final Territory germany = territory("Germany", gameData);
final Territory poland = territory("Poland", gameData);
final Territory eastPoland = territory("East Poland", gameData);
final Territory beloRussia = territory("Belorussia", gameData);
final ITestDelegateBridge bridge = getDelegateBridge(germans);
bridge.setStepName("CombatMove");
moveDelegate(gameData).setDelegateBridgeAndPlayer(bridge);
moveDelegate(gameData).start();
TechAttachment.get(germans).setParatroopers("true");
List<Unit> paratroopers = germany.getUnits().getMatches(Matches.unitIsAirTransportable());
paratroopers = paratroopers.subList(0, 1);
final List<Unit> bomberAndParatroop = new ArrayList<>(paratroopers);
bomberAndParatroop.addAll(germany.getUnits().getMatches(Matches.unitIsAirTransport()));
final Route route = new Route(germany, poland, eastPoland);
final List<Unit> airTransports = germany.getUnits().getMatches(Matches.unitIsAirTransport());
for (final Unit airTransport : airTransports) {
for (final Unit unit : paratroopers) {
final Change change = TransportTracker.loadTransportChange((TripleAUnit) airTransport, unit);
bridge.addChange(change);
}
}
// move the units to east poland
// airTransports
String error = moveDelegate(gameData).move(bomberAndParatroop, route);
assertValid(error);
// try to move them further, this should fail
error = moveDelegate(gameData).move(bomberAndParatroop, new Route(eastPoland, beloRussia));
assertError(error);
}
use of games.strategy.engine.data.ITestDelegateBridge in project triplea by triplea-game.
the class WW2V3Year41Test method testMechInfUnitAlreadyMovedSimple.
@Test
public void testMechInfUnitAlreadyMovedSimple() {
final PlayerID germans = germans(gameData);
final Territory france = territory("France", gameData);
final Territory germany = territory("Germany", gameData);
TechAttachment.get(germans).setMechanizedInfantry("true");
final ITestDelegateBridge bridge = getDelegateBridge(germans);
bridge.setStepName("CombatMove");
moveDelegate(gameData).setDelegateBridgeAndPlayer(bridge);
moveDelegate(gameData).start();
// get rid of the infantry in france
removeFrom(france, france.getUnits().getMatches(Matches.unitIsLandTransportable()));
// move an infantry from germany to france
move(germany.getUnits().getMatches(Matches.unitIsLandTransportable()).subList(0, 1), new Route(germany, france));
// try to move all the units in france, the infantry should not be able to move
final Route r = new Route(france, germany);
final String error = moveDelegate(gameData).move(france.getUnits().getUnits(), r);
assertFalse(error == null);
}
use of games.strategy.engine.data.ITestDelegateBridge in project triplea by triplea-game.
the class WW2V3Year41Test method testLoadThroughSubs.
@Test
public void testLoadThroughSubs() {
final ITestDelegateBridge bridge = getDelegateBridge(british(gameData));
bridge.setStepName("britishNonCombatMove");
final MoveDelegate moveDelegate = moveDelegate(gameData);
moveDelegate.setDelegateBridgeAndPlayer(bridge);
moveDelegate.start();
final Territory sz8 = territory("8 Sea Zone", gameData);
final Territory sz7 = territory("7 Sea Zone", gameData);
final Territory sz6 = territory("6 Sea Zone", gameData);
final Territory uk = territory("United Kingdom", gameData);
// add a transport
addTo(sz8, transport(gameData).create(1, british(gameData)));
// move the transport where to the sub is
assertValid(moveDelegate.move(sz8.getUnits().getUnits(), new Route(sz8, sz7)));
// load the transport
load(uk.getUnits().getMatches(Matches.unitIsLandTransportable()), new Route(uk, sz7));
// move the transport out
assertValid(moveDelegate.move(sz7.getUnits().getMatches(Matches.unitOwnedBy(british(gameData))), new Route(sz7, sz6)));
}
Aggregations