use of games.strategy.engine.data.UnitType in project triplea by triplea-game.
the class LhtrTest method testSubDefenseBonus.
@Test
public void testSubDefenseBonus() {
final UnitType sub = GameDataTestUtil.submarine(gameData);
final UnitAttachment attachment = UnitAttachment.get(sub);
final PlayerID japanese = GameDataTestUtil.japanese(gameData);
// before the advance, subs defend and attack at 2
assertEquals(2, attachment.getDefense(japanese));
assertEquals(2, attachment.getAttack(japanese));
final ITestDelegateBridge bridge = getDelegateBridge(japanese);
TechTracker.addAdvance(japanese, bridge, TechAdvance.findAdvance(TechAdvance.TECH_PROPERTY_SUPER_SUBS, gameData, japanese));
// after tech advance, this is now 3
assertEquals(3, attachment.getDefense(japanese));
assertEquals(3, attachment.getAttack(japanese));
// make sure this only changes for the player with the tech
final PlayerID americans = GameDataTestUtil.americans(gameData);
assertEquals(2, attachment.getDefense(americans));
assertEquals(2, attachment.getAttack(americans));
}
use of games.strategy.engine.data.UnitType 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.UnitType 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.UnitType 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.UnitType 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);
}
Aggregations