use of games.strategy.engine.data.Resource in project triplea by triplea-game.
the class PlayerAttachment method setSuicideAttackResources.
private void setSuicideAttackResources(final String value) throws GameParseException {
final String[] s = value.split(":");
if (s.length != 2) {
throw new GameParseException("suicideAttackResources must have exactly 2 fields" + thisErrorMsg());
}
final int attackValue = getInt(s[0]);
if (attackValue < 0) {
throw new GameParseException("suicideAttackResources attack value must be positive" + thisErrorMsg());
}
final Resource r = getData().getResourceList().getResource(s[1]);
if (r == null) {
throw new GameParseException("no such resource: " + s[1] + thisErrorMsg());
}
m_suicideAttackResources.put(r, attackValue);
}
use of games.strategy.engine.data.Resource in project triplea by triplea-game.
the class ResourceCollectionUtilsTest method testExcludeByResources_ShouldIgnoreUnregisteredResources.
@Test
public void testExcludeByResources_ShouldIgnoreUnregisteredResources() {
final Resource gold = createResource("gold");
final ResourceCollection unfiltered = createResourceCollection(pus);
final ResourceCollection filtered = ResourceCollectionUtils.exclude(unfiltered, gold);
assertThat(filtered.getQuantity(pus), is(unfiltered.getQuantity(pus)));
}
use of games.strategy.engine.data.Resource in project triplea by triplea-game.
the class ResourceCollectionUtilsTest method testExcludeByNames_ShouldIgnoreUnregisteredResourceNames.
@Test
public void testExcludeByNames_ShouldIgnoreUnregisteredResourceNames() {
final Resource gold = createResource("gold");
givenGameResources(pus);
final ResourceCollection unfiltered = createResourceCollection(pus);
final ResourceCollection filtered = ResourceCollectionUtils.exclude(unfiltered, gold.getName());
assertThat(filtered.getQuantity(pus), is(unfiltered.getQuantity(pus)));
}
use of games.strategy.engine.data.Resource in project triplea by triplea-game.
the class ResourceCollectionUtilsTest method givenGameResources.
private void givenGameResources(final Resource... resources) {
final ResourceList gameResources = mock(ResourceList.class);
doReturn(null).when(gameResources).getResource(anyString());
for (final Resource resource : resources) {
doReturn(resource).when(gameResources).getResource(resource.getName());
}
when(data.getResourceList()).thenReturn(gameResources);
}
use of games.strategy.engine.data.Resource in project triplea by triplea-game.
the class ResourceCollectionUtilsTest method testGetProductionResources_ShouldIncludeAllResourcesExceptTechTokensAndVPs.
@Test
public void testGetProductionResources_ShouldIncludeAllResourcesExceptTechTokensAndVPs() {
final Resource gold = createResource("gold");
givenGameResources(gold, pus, techTokens, vps);
final ResourceCollection unfiltered = createResourceCollection(gold, pus, techTokens, vps);
final ResourceCollection filtered = ResourceCollectionUtils.getProductionResources(unfiltered);
assertThat(filtered.getQuantity(gold), is(unfiltered.getQuantity(gold)));
assertThat(filtered.getQuantity(pus), is(unfiltered.getQuantity(pus)));
assertThat(filtered.getQuantity(techTokens), is(0));
assertThat(filtered.getQuantity(vps), is(0));
}
Aggregations