@Test
 public void testRoundRobinWithEqualType() throws PersistenceLayerException {
   if (isTypeLegal()) {
     construct(primaryContext, "TestWP1");
     construct(primaryContext, "TestWP2");
     construct(secondaryContext, "TestWP1");
     construct(secondaryContext, "TestWP2");
     CDOMObject a = construct(primaryContext, "TestWP3");
     a.addToListFor(ListKey.TYPE, Type.getConstant("OtherTestType"));
     CDOMObject c = construct(secondaryContext, "TestWP3");
     c.addToListFor(ListKey.TYPE, Type.getConstant("OtherTestType"));
     CDOMObject b = construct(primaryContext, "TestWP4");
     b.addToListFor(ListKey.TYPE, Type.getConstant("TestType"));
     CDOMObject d = construct(secondaryContext, "TestWP4");
     d.addToListFor(ListKey.TYPE, Type.getConstant("TestType"));
     runRoundRobin(
         "TestWP1"
             + getJoinCharacter()
             + "TestWP2"
             + getJoinCharacter()
             + "TYPE=OtherTestType"
             + getJoinCharacter()
             + "TYPE=TestType");
   }
 }
Ejemplo n.º 2
0
 @Test
 public void testRoundRobinType() throws PersistenceLayerException {
   Spell a = primaryContext.getReferenceContext().constructCDOMObject(Spell.class, "Fireball");
   a.addToListFor(ListKey.TYPE, Type.getConstant("Foo"));
   Spell b = secondaryContext.getReferenceContext().constructCDOMObject(Spell.class, "Fireball");
   b.addToListFor(ListKey.TYPE, Type.getConstant("Foo"));
   runRoundRobin("TYPE.Foo=2");
 }
Ejemplo n.º 3
0
 /*
  * PCCLASSLEVELONLY Since this is really only something that will be done
  * within a PlayerCharacter (real processing) it is only required in
  * PCClassLevel.
  *
  * As a side note, I'm not sure what I think of accessing the ClassTypes and
  * using one of those to set the response to this request. Should this be
  * done when a PCClassLevel is built? Is that possible? How does that
  * interact with a PlayerCharacter being reimported if those rules change?
  */
 public boolean hasXPPenalty() {
   for (Type type : getTrueTypeList(false)) {
     final ClassType aClassType = SettingsHandler.getGame().getClassTypeByName(type.toString());
     if ((aClassType != null) && !aClassType.getXPPenalty()) {
       return false;
     }
   }
   return true;
 }
 @Test
 public void testRoundRobinTestEquals() throws PersistenceLayerException {
   if (isTypeLegal()) {
     CDOMObject b = construct(primaryContext, "TestWP3");
     b.addToListFor(ListKey.TYPE, Type.getConstant("TestType"));
     CDOMObject d = construct(secondaryContext, "TestWP3");
     d.addToListFor(ListKey.TYPE, Type.getConstant("TestType"));
     runRoundRobin("TYPE=TestType");
   }
 }
 @Test
 public void testValidInputTypeDot() throws PersistenceLayerException {
   if (isTypeLegal()) {
     CDOMObject b = construct(primaryContext, "TestWP3");
     b.addToListFor(ListKey.TYPE, Type.getConstant("TestType"));
     CDOMObject d = construct(secondaryContext, "TestWP3");
     d.addToListFor(ListKey.TYPE, Type.getConstant("TestType"));
     assertTrue(parse("TYPE.TestType"));
     assertCleanConstruction();
   }
 }
Ejemplo n.º 6
0
  /*
   * FUTUREREFACTOR This would really be nice to have initilized when the LST files
   * are read in, which is possible because the ClassTypes are all defined as part
   * of the GameMode... however the problem is that the order of the ISMONSTER tag
   * and the TYPE tags cannot be defined - .MODs and .COPYs make it impossible to
   * guarantee an order.  Therefore, this must wait for a two-pass design in the
   * import system - thpr 10/4/06
   */
  public boolean isMonster() {
    Boolean mon = get(ObjectKey.IS_MONSTER);
    if (mon != null) {
      return mon.booleanValue();
    }

    ClassType aClassType = SettingsHandler.getGame().getClassTypeByName(getClassType());

    if ((aClassType != null) && aClassType.isMonster()) {
      return true;
    } else {
      for (Type type : getTrueTypeList(false)) {
        aClassType = SettingsHandler.getGame().getClassTypeByName(type.toString());
        if ((aClassType != null) && aClassType.isMonster()) {
          return true;
        }
      }
    }
    return false;
  }
Ejemplo n.º 7
0
 public static void clearConstants() {
   AspectName.clearConstants();
   Pantheon.clearConstants();
   RaceSubType.clearConstants();
   RaceType.clearConstants();
   Region.clearConstants();
   SubClassCategory.clearConstants();
   SubRace.clearConstants();
   SubRegion.clearConstants();
   Type.clearConstants();
   VariableKey.clearConstants();
 }
Ejemplo n.º 8
0
  @Override
  protected ParseResult parseNonEmptyToken(LoadContext context, CDOMObject cdo, String value) {
    if (value.startsWith(".CLEAR")) {
      context.getObjectContext().removeList(cdo, ListKey.TYPE);
      if (value.length() == 6) {
        return ParseResult.SUCCESS;
      } else if (value.charAt(6) == '.') {
        value = value.substring(7);
        if (isEmpty(value)) {
          return new ParseResult.Fail(
              getTokenName() + "started with .CLEAR. but expected to have a Type after .: " + value,
              context);
        }
      } else {
        return new ParseResult.Fail(
            getTokenName() + "started with .CLEAR but expected next character to be .: " + value,
            context);
      }
    }
    ParseResult pr = checkForIllegalSeparator('.', value);
    if (!pr.passed()) {
      return pr;
    }

    StringTokenizer aTok = new StringTokenizer(value, Constants.DOT);

    boolean bRemove = false;
    boolean bAdd = false;
    while (aTok.hasMoreTokens()) {
      final String aType = aTok.nextToken();
      if ("ADD".equals(aType)) {
        if (bRemove) {
          return new ParseResult.Fail(
              "Non-sensical use of .REMOVE.ADD. in " + getTokenName() + ": " + value, context);
        }
        bRemove = false;
        bAdd = true;
      } else if ("REMOVE".equals(aType)) {
        if (bAdd) {
          return new ParseResult.Fail(
              "Non-sensical use of .ADD.REMOVE. in " + getTokenName() + ": " + value, context);
        }
        bRemove = true;
      } else if ("CLEAR".equals(aType)) {
        return new ParseResult.Fail(
            "Non-sensical use of .CLEAR in " + getTokenName() + ": " + value, context);
      } else if (bRemove) {
        Type type = Type.getConstant(aType);
        context.getObjectContext().removeFromList(cdo, ListKey.TYPE, type);
        bRemove = false;
      } else {
        Type type = Type.getConstant(aType);
        context.getObjectContext().addToList(cdo, ListKey.TYPE, type);
        bAdd = false;
      }
    }
    if (bRemove) {
      return new ParseResult.Fail(
          getTokenName() + "ended with REMOVE, so didn't have any Type to remove: " + value,
          context);
    }
    if (bAdd) {
      return new ParseResult.Fail(
          getTokenName() + "ended with ADD, so didn't have any Type to add: " + value, context);
    }
    return ParseResult.SUCCESS;
  }
Ejemplo n.º 9
0
 private void loadHiddenTypes(DataSetID id, ListKey<String> listKey, Class<?> cl, Campaign c) {
   List<String> hiddentypes = c.getSafeListFor(listKey);
   for (String s : hiddentypes) {
     add(id, cl, Type.getConstant(s), c);
   }
 }
Ejemplo n.º 10
0
  /**
   * Test to ensure that a number of feat test will correctly require a number of separate feats in
   * any combination of two types.
   *
   * @throws Exception
   */
  public void testMultiFeats() throws Exception {
    final Ability metamagic1 = new Ability();
    metamagic1.addToListFor(ListKey.TYPE, Type.getConstant("METAMAGIC"));
    metamagic1.setName("MM1");
    metamagic1.put(StringKey.KEY_NAME, "MM1");
    metamagic1.setCDOMCategory(AbilityCategory.FEAT);

    final Ability metamagic2 = new Ability();
    metamagic2.addToListFor(ListKey.TYPE, Type.getConstant("METAMAGIC"));
    metamagic2.setName("MM2");
    metamagic2.put(StringKey.KEY_NAME, "MM2");
    metamagic2.setCDOMCategory(AbilityCategory.FEAT);

    final Ability metamagic3 = new Ability();
    metamagic3.addToListFor(ListKey.TYPE, Type.getConstant("METAMAGIC"));
    metamagic3.setName("MM3");
    metamagic3.put(StringKey.KEY_NAME, "MM3");
    metamagic3.setCDOMCategory(AbilityCategory.FEAT);

    final Ability item1 = new Ability();
    item1.addToListFor(ListKey.TYPE, Type.getConstant("ItemCreation"));
    item1.setName("IC1");
    item1.put(StringKey.KEY_NAME, "IC1");
    item1.setCDOMCategory(AbilityCategory.FEAT);

    final Ability item2 = new Ability();
    item2.addToListFor(ListKey.TYPE, Type.getConstant("ItemCreation"));
    item2.setName("IC2");
    item2.put(StringKey.KEY_NAME, "IC2");
    item2.setCDOMCategory(AbilityCategory.FEAT);

    final Ability item3 = new Ability();
    item3.addToListFor(ListKey.TYPE, Type.getConstant("ItemCreation"));
    item3.setName("IC3");
    item3.put(StringKey.KEY_NAME, "IC3");
    item3.setCDOMCategory(AbilityCategory.FEAT);

    final PlayerCharacter character = getCharacter();

    final PreFeatParser producer = new PreFeatParser();

    final Prerequisite prereq =
        producer.parse("FEAT", "3,TYPE=Metamagic,TYPE=ItemCreation", false, false);

    final PreMult test = new PreMult();
    int passes = test.passes(prereq, character, null);
    assertEquals("No feats should not pass", 0, passes);

    character.addAbilityNeedCheck(AbilityCategory.FEAT, metamagic1);
    passes = test.passes(prereq, character, null);
    assertEquals("One feat should not pass", 0, passes);

    character.addAbilityNeedCheck(AbilityCategory.FEAT, metamagic2);
    passes = test.passes(prereq, character, null);
    assertEquals("Two feats should not pass", 0, passes);

    character.addAbilityNeedCheck(AbilityCategory.FEAT, metamagic3);
    passes = test.passes(prereq, character, null);
    assertEquals("Three feats should pass", 1, passes);

    character.removeRealAbility(AbilityCategory.FEAT, metamagic3);
    character.addAbilityNeedCheck(AbilityCategory.FEAT, item1);
    passes = test.passes(prereq, character, null);
    assertEquals("Three feats should pass", 1, passes);

    character.addAbilityNeedCheck(AbilityCategory.FEAT, item2);
    character.addAbilityNeedCheck(AbilityCategory.FEAT, item3);
    character.addAbilityNeedCheck(AbilityCategory.FEAT, metamagic3);
    passes = test.passes(prereq, character, null);
    assertEquals("Six feats should pass", 1, passes);

    character.removeRealAbility(AbilityCategory.FEAT, metamagic3);
    character.removeRealAbility(AbilityCategory.FEAT, item3);
    character.removeRealAbility(AbilityCategory.FEAT, item2);
    character.removeRealAbility(AbilityCategory.FEAT, item1);
    character.removeRealAbility(AbilityCategory.FEAT, metamagic2);
    character.removeRealAbility(AbilityCategory.FEAT, metamagic1);
  }
Ejemplo n.º 11
0
 @Override
 public Type getConstant(String string) {
   return Type.getConstant(string);
 }