use of games.strategy.triplea.delegate.GameDataTestUtil.british in project triplea by triplea-game.
the class RevisedTest method testStratBombRaidWithHeavyBombers.
@Test
public void testStratBombRaidWithHeavyBombers() {
final Territory germany = gameData.getMap().getTerritory("Germany");
final Territory uk = gameData.getMap().getTerritory("United Kingdom");
final PlayerID germans = GameDataTestUtil.germans(gameData);
final PlayerID british = GameDataTestUtil.british(gameData);
final BattleTracker tracker = new BattleTracker();
final StrategicBombingRaidBattle battle = new StrategicBombingRaidBattle(germany, gameData, british, tracker);
battle.addAttackChange(gameData.getMap().getRoute(uk, germany), uk.getUnits().getMatches(Matches.unitIsStrategicBomber()), null);
addTo(germany, uk.getUnits().getMatches(Matches.unitIsStrategicBomber()));
tracker.getBattleRecords().addBattle(british, battle.getBattleId(), germany, battle.getBattleType());
final ITestDelegateBridge bridge = getDelegateBridge(british);
TechTracker.addAdvance(british, bridge, TechAdvance.findAdvance(TechAdvance.TECH_PROPERTY_HEAVY_BOMBER, gameData, british));
// aa guns rolls 3, misses, bomber rolls 2 dice at 3
bridge.setRandomSource(new ScriptedRandomSource(new int[] { 3, 2, 2 }));
// if we try to move aa, then the game will ask us if we want to move
// fail if we are called
final InvocationHandler handler = (proxy, method, args) -> null;
final ITripleAPlayer player = (ITripleAPlayer) Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(), new Class<?>[] { ITripleAPlayer.class }, handler);
bridge.setRemote(player);
final int pusBeforeRaid = germans.getResources().getQuantity(gameData.getResourceList().getResource(Constants.PUS));
battle.fight(bridge);
final int pusAfterRaid = germans.getResources().getQuantity(gameData.getResourceList().getResource(Constants.PUS));
assertEquals(pusBeforeRaid - 6, pusAfterRaid);
}
Aggregations