IsSatisfied implements PrerequisiteProcessor { @Override public void requiresCharmFromSelection(Charm[] prerequisites, int count) { int known = 0; for (Charm charm : prerequisites) { if (arbitrator.isLearned(charm)) { known++; } if (known >= count) { this.satisfied = true; return; } } this.satisfied = false; } IsSatisfied(CharmLearnArbitrator learnArbitrator); static boolean isSatisfied(CharmPrerequisite prerequisite, CharmLearnArbitrator arbitrator); @Override void requiresMagicAttributes(MagicAttribute attribute, int count); @Override void requiresMagicAttributesFromTree(TreeReference tree,
                                              MagicAttribute attribute, int count); @Override void requiresCharm(Charm prerequisite); @Override void requiresCharmFromSelection(Charm[] prerequisites, int count); @Override void requiresCharmsOfTraits(List<RequiredTraitType> traits, CategoryReference category, int count,
                                     int minimumEssence); @Override void requiresCharmsOfAnyOneTrait(int count); public boolean satisfied; }
@Test public void satifiesGroupRequirementsIfEnoughCharmsAreLearned() throws Exception { Charm charm1 = createLearnedCharm("charm1"); Charm charm2 = createLearnedCharm("charm2"); Charm[] prerequisites = new Charm[]{charm1, charm2}; isSatisfied.requiresCharmFromSelection(prerequisites, 2); assertThat(isSatisfied.satisfied, is(true)); }