use of games.strategy.engine.data.Route in project triplea by triplea-game.
the class LhtrTest method testFightersDestroyedWhenNoPendingCarriers.
@Test
public void testFightersDestroyedWhenNoPendingCarriers() {
final MoveDelegate delegate = (MoveDelegate) gameData.getDelegateList().getDelegate("move");
delegate.initialize("MoveDelegate", "MoveDelegate");
final PlayerID germans = GameDataTestUtil.germans(gameData);
final ITestDelegateBridge bridge = getDelegateBridge(germans);
bridge.setStepName("germanNonCombatMove");
delegate.setDelegateBridgeAndPlayer(bridge);
delegate.start();
final Territory baltic = gameData.getMap().getTerritory("5 Sea Zone");
final Territory easternEurope = gameData.getMap().getTerritory("Eastern Europe");
// move a fighter to the baltic
final Route route = new Route();
route.setStart(easternEurope);
route.add(baltic);
final UnitType fighterType = GameDataTestUtil.fighter(gameData);
delegate.move(easternEurope.getUnits().getMatches(Matches.unitIsOfType(fighterType)), route);
// end the move phase
delegate.end();
// there is no pending carrier to be placed
// the fighter cannot hover
assertFalse(baltic.getUnits().anyMatch(Matches.unitIsOfType(fighterType)));
}
use of games.strategy.engine.data.Route in project triplea by triplea-game.
the class LhtrTest method testFightersCanLandOnNewPlacedCarrier.
@Test
public void testFightersCanLandOnNewPlacedCarrier() {
final MoveDelegate delegate = (MoveDelegate) gameData.getDelegateList().getDelegate("move");
delegate.initialize("MoveDelegate", "MoveDelegate");
final PlayerID germans = GameDataTestUtil.germans(gameData);
final ITestDelegateBridge bridge = getDelegateBridge(germans);
bridge.setStepName("germanNonCombatMove");
delegate.setDelegateBridgeAndPlayer(bridge);
delegate.start();
final Territory baltic = gameData.getMap().getTerritory("5 Sea Zone");
final Territory easternEurope = gameData.getMap().getTerritory("Eastern Europe");
final UnitType carrirType = GameDataTestUtil.carrier(gameData);
// move a fighter to the baltic
final Route route = new Route();
route.setStart(easternEurope);
route.add(baltic);
final UnitType fighterType = GameDataTestUtil.fighter(gameData);
delegate.move(easternEurope.getUnits().getMatches(Matches.unitIsOfType(fighterType)), route);
// add a carrier to be produced in germany
final TripleAUnit carrier = new TripleAUnit(carrirType, germans, gameData);
gameData.performChange(ChangeFactory.addUnits(germans, Collections.singleton(carrier)));
// end the move phase
delegate.end();
// make sure the fighter is still there
// in lhtr fighters can hover, and carriers placed beneath them
assertTrue(baltic.getUnits().anyMatch(Matches.unitIsOfType(fighterType)));
}
use of games.strategy.engine.data.Route in project triplea by triplea-game.
the class MoveDelegateTest method testAirCanFlyOverWater.
@Test
public void testAirCanFlyOverWater() {
final IntegerMap<UnitType> map = new IntegerMap<>();
map.put(bomber, 2);
final Route route = new Route();
route.setStart(egypt);
// exast movement to force landing
route.add(redSea);
route.add(syria);
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 MoveDelegateTest method testCanReturnToCarrier.
@Test
public void testCanReturnToCarrier() {
final IntegerMap<UnitType> map = new IntegerMap<>();
map.put(fighter, 3);
final Route route = new Route();
route.setStart(congoSeaZone);
route.add(southAtlantic);
route.add(antarticSea);
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 MoveDelegateTest method testMoveTransportsTwice.
@Test
public void testMoveTransportsTwice() {
// move transports
Route route = new Route();
route.setStart(congoSeaZone);
route.add(southAtlantic);
final IntegerMap<UnitType> map = new IntegerMap<>();
map.put(infantry, 2);
map.put(transport, 1);
String results = delegate.move(GameDataTestUtil.getUnits(map, route.getStart()), route);
assertValid(results);
// move again
route = new Route();
route.setStart(southAtlantic);
route.add(angolaSeaZone);
results = delegate.move(GameDataTestUtil.getUnits(map, route.getStart()), route);
assertValid(results);
}
Aggregations