use of games.strategy.engine.data.ResourceCollection 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.ResourceCollection in project triplea by triplea-game.
the class ResourceCollectionUtilsTest method createResourceCollection.
private ResourceCollection createResourceCollection(final Resource... resources) {
final ResourceCollection resourceCollection = new ResourceCollection(data);
resourceCollection.add(new IntegerMap<>(Arrays.stream(resources).collect(toList()), 42));
return resourceCollection;
}
use of games.strategy.engine.data.ResourceCollection 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.ResourceCollection 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));
}
use of games.strategy.engine.data.ResourceCollection in project triplea by triplea-game.
the class ProductionRepairPanel method getResources.
private ResourceCollection getResources() {
if (bid) {
// TODO bid only allows you to add PU's to the bid... maybe upgrading Bids so multiple resources can be given?
// (actually, bids should
// not cover repairing at all...)
final String propertyName = id.getName() + " bid";
final int bid = data.getProperties().get(propertyName, 0);
final ResourceCollection bidCollection = new ResourceCollection(data);
data.acquireReadLock();
try {
bidCollection.addResource(data.getResourceList().getResource(Constants.PUS), bid);
} finally {
data.releaseReadLock();
}
return bidCollection;
}
return id.getResources();
}
Aggregations