use of games.strategy.util.IntegerMap in project triplea by triplea-game.
the class PacificTest method testJapaneseDestroyerTransport.
@Test
public void testJapaneseDestroyerTransport() {
bridge = getDelegateBridge(japanese);
delegate = new MoveDelegate();
delegate.initialize("MoveDelegate", "MoveDelegate");
delegate.setDelegateBridgeAndPlayer(bridge);
bridge.setStepName("japaneseNonCombatMove");
delegate.start();
final IntegerMap<UnitType> map = new IntegerMap<>();
map.put(infantry, 1);
final Route route = new Route();
route.setStart(bonin);
// movement to force boarding
route.add(sz24);
// verify unit counts before move
assertEquals(2, bonin.getUnits().size());
assertEquals(1, sz24.getUnits().size());
// validate movement
final String results = delegate.move(GameDataTestUtil.getUnits(map, route.getStart()), route, route.getEnd().getUnits().getUnits());
assertValid(results);
// verify unit counts after move
assertEquals(1, bonin.getUnits().size());
assertEquals(2, sz24.getUnits().size());
}
use of games.strategy.util.IntegerMap in project triplea by triplea-game.
the class PlaceDelegateTest method testCanProduce.
@Test
public void testCanProduce() {
final IntegerMap<UnitType> map = new IntegerMap<>();
map.add(infantry, 2);
final PlaceableUnits response = delegate.getPlaceableUnits(GameDataTestUtil.getUnits(map, british), westCanada);
assertFalse(response.isError());
}
use of games.strategy.util.IntegerMap in project triplea by triplea-game.
the class PlaceDelegateTest method testAlreadyProducedUnits.
@Test
public void testAlreadyProducedUnits() {
final IntegerMap<UnitType> map = new IntegerMap<>();
final Map<Territory, Collection<Unit>> alreadyProduced = new HashMap<>();
alreadyProduced.put(westCanada, getInfantry(2, british));
delegate.setProduced(alreadyProduced);
map.add(infantry, 1);
final PlaceableUnits response = delegate.getPlaceableUnits(GameDataTestUtil.getUnits(map, british), westCanada);
assertTrue(response.getMaxUnits() == 0);
}
use of games.strategy.util.IntegerMap in project triplea by triplea-game.
the class VictoryTest method testNotEnoughMultipleResourcesToPurchase.
@Test
public void testNotEnoughMultipleResourcesToPurchase() {
testBridge.setStepName("italianPurchase");
purchaseDelegate.setDelegateBridgeAndPlayer(testBridge);
purchaseDelegate.start();
final IntegerMap<ProductionRule> purchaseList = new IntegerMap<>();
final ProductionRule armourtest = gameData.getProductionRuleList().getProductionRule("buyArmourtest2");
assertNotNull(armourtest);
italianResources.subtract(armourtest.getCosts());
purchaseList.add(armourtest, 1);
final String error = purchaseDelegate.purchase(purchaseList);
assertEquals(PurchaseDelegate.NOT_ENOUGH_RESOURCES, error);
}
use of games.strategy.util.IntegerMap in project triplea by triplea-game.
the class VictoryTest method testNoPuResourcesToPurchase.
@Test
public void testNoPuResourcesToPurchase() {
testBridge.setStepName("italianPurchase");
purchaseDelegate.setDelegateBridgeAndPlayer(testBridge);
purchaseDelegate.start();
final IntegerMap<ProductionRule> purchaseList = new IntegerMap<>();
final ProductionRule buyArmour = gameData.getProductionRuleList().getProductionRule("buyArmourtest3");
assertNotNull(buyArmour);
italianResources.subtract(buyArmour.getCosts());
purchaseList.add(buyArmour, 1);
final String error = purchaseDelegate.purchase(purchaseList);
assertEquals(null, error);
assertEquals(italianResources, italians.getResources().getResourcesCopy());
}
Aggregations