Search in sources :

Example 1 with GameDataTestUtil.germans

use of games.strategy.triplea.delegate.GameDataTestUtil.germans 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);
}
Also used : BeforeEach(org.junit.jupiter.api.BeforeEach) GameDataTestUtil.move(games.strategy.triplea.delegate.GameDataTestUtil.move) Arrays(java.util.Arrays) GameDataTestUtil.bomber(games.strategy.triplea.delegate.GameDataTestUtil.bomber) GameDataTestUtil.japanese(games.strategy.triplea.delegate.GameDataTestUtil.japanese) Constants(games.strategy.triplea.Constants) UnitAttachment(games.strategy.triplea.attachments.UnitAttachment) GameDataTestUtil.addTo(games.strategy.triplea.delegate.GameDataTestUtil.addTo) TechAttachment(games.strategy.triplea.attachments.TechAttachment) GameDataTestUtil.aaGun(games.strategy.triplea.delegate.GameDataTestUtil.aaGun) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) GameDataTestUtil.moveDelegate(games.strategy.triplea.delegate.GameDataTestUtil.moveDelegate) GameDataTestUtil.makeGameLowLuck(games.strategy.triplea.delegate.GameDataTestUtil.makeGameLowLuck) GameDataTestUtil.americans(games.strategy.triplea.delegate.GameDataTestUtil.americans) GameDataTestUtil.getIndex(games.strategy.triplea.delegate.GameDataTestUtil.getIndex) TestMapGameData(games.strategy.triplea.xml.TestMapGameData) GameDataTestUtil.techDelegate(games.strategy.triplea.delegate.GameDataTestUtil.techDelegate) GameDataTestUtil.removeFrom(games.strategy.triplea.delegate.GameDataTestUtil.removeFrom) ScriptedRandomSource(games.strategy.engine.random.ScriptedRandomSource) GameDataTestUtil.assertValid(games.strategy.triplea.delegate.GameDataTestUtil.assertValid) Collection(java.util.Collection) GameDataTestUtil.load(games.strategy.triplea.delegate.GameDataTestUtil.load) Set(java.util.Set) ITestDelegateBridge(games.strategy.engine.data.ITestDelegateBridge) GameDataTestUtil.territory(games.strategy.triplea.delegate.GameDataTestUtil.territory) SUBS_FIRE(games.strategy.triplea.delegate.BattleStepStrings.SUBS_FIRE) GameDataTestUtil.armour(games.strategy.triplea.delegate.GameDataTestUtil.armour) Test(org.junit.jupiter.api.Test) SUBS_SUBMERGE(games.strategy.triplea.delegate.BattleStepStrings.SUBS_SUBMERGE) GameData(games.strategy.engine.data.GameData) List(java.util.List) PlayerID(games.strategy.engine.data.PlayerID) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) ITripleAPlayer(games.strategy.triplea.player.ITripleAPlayer) REMOVE_CASUALTIES(games.strategy.triplea.delegate.BattleStepStrings.REMOVE_CASUALTIES) GameDataTestUtil.destroyer(games.strategy.triplea.delegate.GameDataTestUtil.destroyer) Mockito.mock(org.mockito.Mockito.mock) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) GameDataTestUtil.infantry(games.strategy.triplea.delegate.GameDataTestUtil.infantry) Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) Proxy(java.lang.reflect.Proxy) GameDataTestUtil.battleship(games.strategy.triplea.delegate.GameDataTestUtil.battleship) SELECT_SUB_CASUALTIES(games.strategy.triplea.delegate.BattleStepStrings.SELECT_SUB_CASUALTIES) Assertions.assertNull(org.junit.jupiter.api.Assertions.assertNull) GameDataTestUtil.placeDelegate(games.strategy.triplea.delegate.GameDataTestUtil.placeDelegate) ArgumentMatchers.anyBoolean(org.mockito.ArgumentMatchers.anyBoolean) ArrayList(java.util.ArrayList) PlaceableUnits(games.strategy.triplea.delegate.dataObjects.PlaceableUnits) Answer(org.mockito.stubbing.Answer) Route(games.strategy.engine.data.Route) GameDataTestUtil.assertError(games.strategy.triplea.delegate.GameDataTestUtil.assertError) InvocationOnMock(org.mockito.invocation.InvocationOnMock) SELECT_CASUALTIES(games.strategy.triplea.delegate.BattleStepStrings.SELECT_CASUALTIES) CasualtyDetails(games.strategy.triplea.delegate.dataObjects.CasualtyDetails) GameDataTestUtil.bidPlaceDelegate(games.strategy.triplea.delegate.GameDataTestUtil.bidPlaceDelegate) CasualtyList(games.strategy.triplea.delegate.dataObjects.CasualtyList) UnitType(games.strategy.engine.data.UnitType) FIRE(games.strategy.triplea.delegate.BattleStepStrings.FIRE) GameDataTestUtil.germans(games.strategy.triplea.delegate.GameDataTestUtil.germans) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) TripleAUnit(games.strategy.triplea.TripleAUnit) TechResults(games.strategy.triplea.delegate.dataObjects.TechResults) ArgumentMatchers.anyInt(org.mockito.ArgumentMatchers.anyInt) TechnologyFrontier(games.strategy.engine.data.TechnologyFrontier) CollectionUtils(games.strategy.util.CollectionUtils) Unit(games.strategy.engine.data.Unit) GameDataTestUtil.submarine(games.strategy.triplea.delegate.GameDataTestUtil.submarine) GameDataTestUtil.transport(games.strategy.triplea.delegate.GameDataTestUtil.transport) Territory(games.strategy.engine.data.Territory) Mockito.when(org.mockito.Mockito.when) GameDataTestUtil.british(games.strategy.triplea.delegate.GameDataTestUtil.british) ChangeFactory(games.strategy.engine.data.changefactory.ChangeFactory) REMOVE_SNEAK_ATTACK_CASUALTIES(games.strategy.triplea.delegate.BattleStepStrings.REMOVE_SNEAK_ATTACK_CASUALTIES) Change(games.strategy.engine.data.Change) ATTACKER_WITHDRAW(games.strategy.triplea.delegate.BattleStepStrings.ATTACKER_WITHDRAW) GameDataTestUtil.assertMoveError(games.strategy.triplea.delegate.GameDataTestUtil.assertMoveError) InvocationHandler(java.lang.reflect.InvocationHandler) Collections(java.util.Collections) PlayerID(games.strategy.engine.data.PlayerID) Territory(games.strategy.engine.data.Territory) ITestDelegateBridge(games.strategy.engine.data.ITestDelegateBridge) ScriptedRandomSource(games.strategy.engine.random.ScriptedRandomSource) InvocationHandler(java.lang.reflect.InvocationHandler) ITripleAPlayer(games.strategy.triplea.player.ITripleAPlayer) Test(org.junit.jupiter.api.Test)

Aggregations

Change (games.strategy.engine.data.Change)1 GameData (games.strategy.engine.data.GameData)1 ITestDelegateBridge (games.strategy.engine.data.ITestDelegateBridge)1 PlayerID (games.strategy.engine.data.PlayerID)1 Route (games.strategy.engine.data.Route)1 TechnologyFrontier (games.strategy.engine.data.TechnologyFrontier)1 Territory (games.strategy.engine.data.Territory)1 Unit (games.strategy.engine.data.Unit)1 UnitType (games.strategy.engine.data.UnitType)1 ChangeFactory (games.strategy.engine.data.changefactory.ChangeFactory)1 ScriptedRandomSource (games.strategy.engine.random.ScriptedRandomSource)1 Constants (games.strategy.triplea.Constants)1 TripleAUnit (games.strategy.triplea.TripleAUnit)1 TechAttachment (games.strategy.triplea.attachments.TechAttachment)1 UnitAttachment (games.strategy.triplea.attachments.UnitAttachment)1 ATTACKER_WITHDRAW (games.strategy.triplea.delegate.BattleStepStrings.ATTACKER_WITHDRAW)1 FIRE (games.strategy.triplea.delegate.BattleStepStrings.FIRE)1 REMOVE_CASUALTIES (games.strategy.triplea.delegate.BattleStepStrings.REMOVE_CASUALTIES)1 REMOVE_SNEAK_ATTACK_CASUALTIES (games.strategy.triplea.delegate.BattleStepStrings.REMOVE_SNEAK_ATTACK_CASUALTIES)1 SELECT_CASUALTIES (games.strategy.triplea.delegate.BattleStepStrings.SELECT_CASUALTIES)1