use of games.strategy.triplea.ui.ObjectiveDummyDelegateBridge in project triplea by triplea-game.
the class EndTurnDelegate method findNationalObjectiveAndTriggerResources.
/**
* Find the resources generated by national objectives and triggers that are currently met.
*/
public static IntegerMap<Resource> findNationalObjectiveAndTriggerResources(final PlayerID player, final GameData data) {
final IDelegateBridge bridge = new ObjectiveDummyDelegateBridge(data);
// Find and test all the conditions for triggers and national objectives
final Set<TriggerAttachment> triggers = new HashSet<>();
final List<RulesAttachment> objectives = new ArrayList<>();
final HashMap<ICondition, Boolean> testedConditions = testNationalObjectivesAndTriggers(player, data, bridge, triggers, objectives);
// Find triggers value
final IntegerMap<Resource> resources;
final boolean useTriggers = Properties.getTriggers(data);
if (useTriggers && !triggers.isEmpty()) {
final Set<TriggerAttachment> toFireTestedAndSatisfied = new HashSet<>(CollectionUtils.getMatches(triggers, AbstractTriggerAttachment.isSatisfiedMatch(testedConditions)));
resources = TriggerAttachment.findResourceIncome(toFireTestedAndSatisfied, bridge);
} else {
resources = new IntegerMap<>();
}
// Find national objectives value
int pus = 0;
for (final RulesAttachment rule : objectives) {
final int uses = rule.getUses();
if (uses == 0 || !rule.isSatisfied(testedConditions)) {
continue;
}
pus += (rule.getObjectiveValue() * rule.getEachMultiple() * Properties.getPuMultiplier(data));
}
resources.add(data.getResourceList().getResource(Constants.PUS), pus);
return resources;
}
Aggregations