use of games.strategy.engine.data.PlayerID 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.PlayerID 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.PlayerID 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.PlayerID in project triplea by triplea-game.
the class WW2V3Year41Test method testTechTokens.
@Test
public void testTechTokens() {
// Set up the test
final PlayerID germans = GameDataTestUtil.germans(gameData);
final ITestDelegateBridge delegateBridge = getDelegateBridge(germans);
delegateBridge.setStepName("germanTech");
final TechnologyDelegate techDelegate = techDelegate(gameData);
techDelegate.setDelegateBridgeAndPlayer(delegateBridge);
techDelegate.start();
final TechnologyFrontier mech = new TechnologyFrontier("", gameData);
mech.addAdvance(TechAdvance.findAdvance(TechAdvance.TECH_PROPERTY_MECHANIZED_INFANTRY, gameData, null));
// Add tech token
gameData.performChange(ChangeFactory.changeResourcesChange(germans, gameData.getResourceList().getResource(Constants.TECH_TOKENS), 1));
// Check to make sure it was successful
final int initTokens = germans.getResources().getQuantity("techTokens");
assertEquals(1, initTokens);
// Fail the roll
delegateBridge.setRandomSource(new ScriptedRandomSource(new int[] { 3 }));
final TechResults roll = techDelegate.rollTech(1, mech, 0, null);
// Check to make sure it failed
assertEquals(0, roll.getHits());
final int midTokens = germans.getResources().getQuantity("techTokens");
assertEquals(1, midTokens);
// Make a Successful roll
delegateBridge.setRandomSource(new ScriptedRandomSource(new int[] { 5 }));
final TechResults roll2 = techDelegate.rollTech(1, mech, 0, null);
// Check to make sure it succeeded and all tokens were removed
assertEquals(1, roll2.getHits());
final int finalTokens = germans.getResources().getQuantity("techTokens");
assertEquals(0, finalTokens);
}
use of games.strategy.engine.data.PlayerID in project triplea by triplea-game.
the class WW2V3Year41Test method testFighterLandsWhereCarrierCanBePlaced.
@Test
public void testFighterLandsWhereCarrierCanBePlaced() {
final PlayerID germans = germans(gameData);
// germans have 1 carrier to place
addTo(germans, carrier(gameData).create(1, germans), gameData);
// start the move phase
final ITestDelegateBridge bridge = getDelegateBridge(germans);
bridge.setStepName("CombatMove");
moveDelegate(gameData).setDelegateBridgeAndPlayer(bridge);
moveDelegate(gameData).start();
bridge.setRemote(dummyPlayer);
// the fighter should be able to move and hover in the sea zone
// 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));
// the fighter should be able to move, and hover in the sea zone until the carrier is placed
move(neEurope.getUnits().getMatches(Matches.unitIsAir()), route);
}
Aggregations