@Test
 public void testChangePrerequisite() throws Exception {
   IGenericTrait unwanted = new ValuedTraitType(AbilityType.Athletics, 4);
   IGenericTrait expected = new ValuedTraitType(AbilityType.Athletics, 2);
   data.addPrerequisite(unwanted);
   data.addPrerequisite(expected);
   assertEquals(1, data.getPrerequisites().length);
   assertTrue(ArrayUtilities.containsValue(data.getPrerequisites(), expected));
   assertFalse(ArrayUtilities.containsValue(data.getPrerequisites(), unwanted));
 }
 @Test(expected = IllegalArgumentException.class)
 public void testCannotRemovePrimaryPrerequisite() throws Exception {
   IGenericTrait expected = new ValuedTraitType(AbilityType.Awareness, 4);
   data.setPrimaryPrerequisite(expected);
   data.removePrerequisite(expected);
   assertEquals(1, data.getPrerequisites().length);
   assertTrue(ArrayUtilities.containsValue(data.getPrerequisites(), expected));
 }
 @Test
 public void testGenericAttributes() throws Exception {
   String xml = "<charm><genericCharmAttribute attribute=\"test\"/></charm>"; // $NON-NLS-1$
   Element rootElement = DocumentUtilities.read(xml).getRootElement();
   ICharmAttribute[] attribute =
       new CharmAttributeBuilder()
           .buildCharmAttributes(rootElement, new ValuedTraitType(AbilityType.Brawl, 3));
   assertTrue(
       ArrayUtilities.containsValue(
           attribute, new CharmAttribute("testBrawl", false))); // $NON-NLS-1$
 }
Example #4
0
 private void readMerged(Element mergedElement, ICharm[] existingCharms) {
   List<Element> charmReferences = ElementUtilities.elements(mergedElement, TAG_CHARM_REFERENCE);
   Set<ICharm> charms = new HashSet<ICharm>(charmReferences.size());
   for (Element charmReference : charmReferences) {
     final String charmId = charmReference.attributeValue(ATTRIB_ID);
     ICharm charm =
         ArrayUtilities.getFirst(
             existingCharms,
             new IPredicate<ICharm>() {
               @Override
               public boolean evaluate(ICharm candidate) {
                 return candidate.getId().equals(charmId);
               }
             });
     Ensure.ensureNotNull("Charm not found " + charmId, charm); // $NON-NLS-1$
     charms.add(charm);
   }
   for (ICharm charm : charms) {
     ((Charm) charm).addMerged(charms);
   }
 }
 public final boolean isCompulsiveCharm(ICharm charm) {
   String[] compulsiveCharmIDs = context.getAdditionalRules().getCompulsiveCharmIDs();
   return ArrayUtilities.containsValue(compulsiveCharmIDs, charm.getId());
 }
Example #6
0
 public boolean isParentOf(ISimpleNode potential) {
   return ArrayUtilities.contains(this.child, potential);
 }
 private boolean isSpellCircleGreaterThanMaximumCircle(CircleType type) {
   return !ArrayUtilities.containsValue(type.getComparableCircles(), maximumCircle)
       || (maximumCircle.compareTo(type) < 0);
 }