コード例 #1
0
ファイル: SizeFacetTest.java プロジェクト: neonobjclash/pcgen
 @Test
 public void testGetWithBonus() {
   Race r = new Race();
   r.put(FormulaKey.SIZE, FormulaFactory.getFormulaFor(1));
   rfacet.set(id, r);
   facet.update(id);
   assertEquals(1, facet.sizeInt(id));
   bonusInfo.put(altid, 2.0);
   // No pollution
   facet.update(id);
   assertEquals(1, facet.sizeInt(id));
   bonusInfo.put(id, 2.0);
   facet.update(id);
   assertEquals(3, facet.sizeInt(id));
   PCTemplate t1 = new PCTemplate();
   t1.setName("PCT");
   t1.put(FormulaKey.SIZE, FormulaFactory.getFormulaFor(0));
   tfacet.add(id, t1, this);
   facet.update(id);
   assertEquals(2, facet.sizeInt(id));
   PCTemplate t2 = new PCTemplate();
   t2.setName("Other");
   t2.put(FormulaKey.SIZE, FormulaFactory.getFormulaFor(3));
   tfacet.add(id, t2, this);
   facet.update(id);
   assertEquals(4, facet.sizeInt(id));
   tfacet.remove(id, t2, this);
   facet.update(id);
   assertEquals(2, facet.sizeInt(id));
   bonusInfo.clear();
   facet.update(id);
   assertEquals(0, facet.sizeInt(id));
 }
コード例 #2
0
ファイル: PreDRTest.java プロジェクト: kne1p/pcgen
  public void testMultiAnd() throws Exception {
    final PlayerCharacter character = getCharacter();
    character.setRace(race);

    Prerequisite prereq;

    final PreParserFactory factory = PreParserFactory.getInstance();
    prereq = factory.parse("PREDR:2,+1=10,+2=5");

    assertFalse("Character has no DR", PrereqHandler.passes(prereq, character, null));

    race.addToListFor(ListKey.DAMAGE_REDUCTION, drPlus1);
    character.setRace(race);

    assertFalse("Character DR not 10", PrereqHandler.passes(prereq, character, null));

    DamageReduction drPlus2_5 = new DamageReduction(FormulaFactory.getFormulaFor(5), "+2");
    race.addToListFor(ListKey.DAMAGE_REDUCTION, drPlus2_5);
    // This weirdness is because we are altering the race after application (no-no at runtime)
    character.setRace(null);
    character.setRace(race);

    assertFalse("Character has DR 5/+2", PrereqHandler.passes(prereq, character, null));

    DamageReduction drPlus1_10 = new DamageReduction(FormulaFactory.getFormulaFor(10), "+1");
    race.addToListFor(ListKey.DAMAGE_REDUCTION, drPlus1_10);
    // This weirdness is because we are altering the race after application (no-no at runtime)
    character.setRace(null);
    character.setRace(race);

    assertTrue("Character has DR 10/+1 and 5/+2", PrereqHandler.passes(prereq, character, null));
  }
コード例 #3
0
ファイル: ValuesToken.java プロジェクト: kne1p/pcgen
 private boolean processRange(KitTable kitTable, KitGear optionInfo, String range) {
   if (isEmpty(range) || hasIllegalSeparator(',', range)) {
     return false;
   }
   ParsingSeparator sep = new ParsingSeparator(range, ',');
   String minString = sep.next();
   String maxString;
   if (sep.hasNext()) {
     maxString = sep.next();
   } else {
     maxString = range;
   }
   if (sep.hasNext()) {
     return false;
   }
   Formula min = FormulaFactory.getFormulaFor(minString);
   if (!min.isValid()) {
     Logging.errorPrint("Min Formula in " + getTokenName() + " was not valid: " + min.toString());
     return false;
   }
   Formula max = FormulaFactory.getFormulaFor(maxString);
   if (!max.isValid()) {
     Logging.errorPrint("Max Formula in " + getTokenName() + " was not valid: " + max.toString());
     return false;
   }
   kitTable.addGear(optionInfo, min, max);
   return true;
 }
コード例 #4
0
ファイル: SizeFacetTest.java プロジェクト: neonobjclash/pcgen
 @Test
 public void testGetFromTemplateHigherOverridesRace() {
   Race r = new Race();
   r.put(FormulaKey.SIZE, FormulaFactory.getFormulaFor(3));
   rfacet.set(id, r);
   PCTemplate t1 = new PCTemplate();
   t1.put(FormulaKey.SIZE, FormulaFactory.getFormulaFor(4));
   tfacet.add(id, t1, this);
   facet.update(id);
   assertEquals(4, facet.sizeInt(id));
   tfacet.remove(id, t1, this);
   facet.update(id);
   assertEquals(3, facet.sizeInt(id));
 }
コード例 #5
0
 public void testConditional() {
   Ability source = create(Ability.class, "Source");
   context.ref.reassociateCategory(AbilityCategory.FEAT, source);
   ParseResult result =
       token.parseToken(context, source, "CLASS|Wizard=2|Fireball|PREVARLTEQ:3,MyCasterLevel");
   if (result != ParseResult.SUCCESS) {
     result.printMessages();
     fail("Test Setup Failed");
   }
   finishLoad();
   assertEquals(baseCount(), targetFacetCount());
   CategorizedAbilitySelection cas =
       new CategorizedAbilitySelection(AbilityCategory.FEAT, source, Nature.AUTOMATIC);
   directAbilityFacet.add(id, cas);
   assertFalse(containsExpected());
   PCTemplate varsource = create(PCTemplate.class, "VarSource");
   varsource.put(VariableKey.getConstant("MyCasterLevel"), FormulaFactory.getFormulaFor(4.0));
   Selection<PCTemplate, ?> sel = new Selection<PCTemplate, Object>(varsource, null);
   templateFacet.add(id, sel, this);
   // pc.setDirty(true);
   assertTrue(containsExpected());
   assertEquals(baseCount() + 1, targetFacetCount());
   directAbilityFacet.remove(id, cas);
   pc.setDirty(true);
   assertEquals(baseCount(), targetFacetCount());
 }
コード例 #6
0
ファイル: SizeFacetTest.java プロジェクト: neonobjclash/pcgen
 @Test
 public void testGetAbbWithBonus() {
   assertEquals("M", facet.getSizeAbb(id));
   facet.update(id);
   assertEquals("M", facet.getSizeAbb(id));
   Race r = new Race();
   r.put(FormulaKey.SIZE, FormulaFactory.getFormulaFor(1));
   rfacet.set(id, r);
   facet.update(id);
   assertEquals("S", facet.getSizeAbb(id));
   bonusInfo.put(altid, 2.0);
   // No pollution
   facet.update(id);
   assertEquals("S", facet.getSizeAbb(id));
   bonusInfo.put(id, 2.0);
   facet.update(id);
   assertEquals("L", facet.getSizeAbb(id));
   PCTemplate t1 = new PCTemplate();
   t1.setName("PCT");
   t1.put(FormulaKey.SIZE, FormulaFactory.getFormulaFor(0));
   tfacet.add(id, t1, this);
   facet.update(id);
   assertEquals("M", facet.getSizeAbb(id));
   PCTemplate t2 = new PCTemplate();
   t2.setName("Other");
   t2.put(FormulaKey.SIZE, FormulaFactory.getFormulaFor(3));
   tfacet.add(id, t2, this);
   facet.update(id);
   assertEquals("H", facet.getSizeAbb(id));
   tfacet.remove(id, t2, this);
   facet.update(id);
   assertEquals("M", facet.getSizeAbb(id));
   bonusInfo.put(id, -2.0);
   t1.put(FormulaKey.SIZE, FormulaFactory.getFormulaFor(1));
   facet.update(id);
   assertEquals("T", facet.getSizeAbb(id));
   t2.put(FormulaKey.SIZE, FormulaFactory.getFormulaFor(4));
   tfacet.add(id, t2, this);
   facet.update(id);
   assertEquals("M", facet.getSizeAbb(id));
   tfacet.remove(id, t2, this);
   facet.update(id);
   assertEquals("T", facet.getSizeAbb(id));
   bonusInfo.clear();
   facet.update(id);
   assertEquals("S", facet.getSizeAbb(id));
 }
コード例 #7
0
ファイル: SizeFacetTest.java プロジェクト: neonobjclash/pcgen
 @Test
 public void testGetFromRace() {
   Race r = new Race();
   r.put(FormulaKey.SIZE, FormulaFactory.getFormulaFor(3));
   rfacet.set(id, r);
   facet.update(id);
   assertEquals(3, facet.sizeInt(id));
 }
コード例 #8
0
  /** Test the basic DR Handling */
  public void testBasicDRHandling() {
    DamageReduction dr1 = new DamageReduction(FormulaFactory.getFormulaFor(5), "magic");
    DamageReduction dr2 = new DamageReduction(FormulaFactory.getFormulaFor(5), "-");
    assertFalse(dr1.equals(dr2));

    dr2 = new DamageReduction(FormulaFactory.getFormulaFor(5), "Magic");
    assertTrue(dr1.equals(dr2));

    dr2 = new DamageReduction(FormulaFactory.getFormulaFor(10), "magic");
    assertFalse(dr1.equals(dr2));

    dr1 = new DamageReduction(FormulaFactory.getFormulaFor(10), "magic and good");
    dr2 = new DamageReduction(FormulaFactory.getFormulaFor(10), "good and magic");
    assertTrue(dr1.equals(dr2));

    dr2 = new DamageReduction(FormulaFactory.getFormulaFor(10), "Good and magic");
    assertTrue(dr1.equals(dr2));

    /*
     * TODO DR can be fooled
     */
    // dr1 = new DamageReduction(FormulaFactory.getFormulaFor(10), "magic or
    // good");
    // dr2 = new DamageReduction(FormulaFactory.getFormulaFor(10), "good and
    // magic");
    // assertFalse(dr1.equals(dr2)));
  }
コード例 #9
0
ファイル: SizeFacetTest.java プロジェクト: neonobjclash/pcgen
 @Test
 public void testAvoidPollution() {
   Race r = new Race();
   r.put(FormulaKey.SIZE, FormulaFactory.getFormulaFor(3));
   rfacet.set(id, r);
   facet.update(id);
   assertEquals(2, facet.sizeInt(altid));
   assertEquals(2, facet.racialSizeInt(altid));
 }
コード例 #10
0
ファイル: LanguageToken.java プロジェクト: aroni125/pcgen-svn
  @Override
  protected ParseResult parseNonEmptyToken(LoadContext context, CDOMObject obj, String value) {
    ParsingSeparator sep = new ParsingSeparator(value, '|');
    String activeValue = sep.next();
    Formula count;
    if (!sep.hasNext()) {
      count = FormulaFactory.ONE;
    } else {
      count = FormulaFactory.getFormulaFor(activeValue);
      if (!count.isValid()) {
        return new ParseResult.Fail(
            "Count in " + getTokenName() + " was not valid: " + count.toString());
      }
      if (count.isStatic() && count.resolve(null, "").doubleValue() <= 0) {
        return new ParseResult.Fail("Count in " + getFullName() + " must be > 0");
      }
      activeValue = sep.next();
    }
    if (sep.hasNext()) {
      return new ParseResult.Fail(getFullName() + " had too many pipe separated items: " + value);
    }
    ParseResult pr = checkSeparatorsAndNonEmpty(',', activeValue);
    if (!pr.passed()) {
      return pr;
    }

    List<CDOMReference<Language>> refs = new ArrayList<CDOMReference<Language>>();
    StringTokenizer tok = new StringTokenizer(activeValue, Constants.COMMA);
    while (tok.hasMoreTokens()) {
      String tokText = tok.nextToken();
      CDOMReference<Language> lang = TokenUtilities.getReference(context, LANGUAGE_CLASS, tokText);
      if (lang == null) {
        return new ParseResult.Fail(
            "  Error was encountered while parsing "
                + getFullName()
                + ": "
                + value
                + " had an invalid reference: "
                + tokText);
      }
      refs.add(lang);
    }

    ReferenceChoiceSet<Language> rcs = new ReferenceChoiceSet<Language>(refs);
    if (!rcs.getGroupingState().isValid()) {
      return new ParseResult.Fail(
          "Non-sensical " + getFullName() + ": Contains ANY and a specific reference: " + value);
    }

    ChoiceSet<Language> cs = new ChoiceSet<Language>(getTokenName(), rcs);
    cs.setTitle("Language Choice");
    PersistentTransitionChoice<Language> tc =
        new ConcretePersistentTransitionChoice<Language>(cs, count);
    context.getObjectContext().addToList(obj, ListKey.ADD, tc);
    tc.setChoiceActor(this);
    return ParseResult.SUCCESS;
  }
コード例 #11
0
ファイル: OptionToken.java プロジェクト: cpmeister/pcgen
  @Override
  protected ParseResult parseNonEmptyToken(LoadContext context, BaseKit kit, String value) {
    ParsingSeparator pipeSep = new ParsingSeparator(value, '|');
    pipeSep.addGroupingPair('[', ']');
    pipeSep.addGroupingPair('(', ')');

    while (pipeSep.hasNext()) {
      String subTok = pipeSep.next();
      if (subTok.length() == 0) {
        return new ParseResult.Fail(
            getTokenName() + " arguments has invalid pipe separator: " + value, context);
      }
      ParseResult pr = checkForIllegalSeparator(',', subTok);
      if (!pr.passed()) {
        return pr;
      }
      ParsingSeparator commaSep = new ParsingSeparator(subTok, ',');
      commaSep.addGroupingPair('[', ']');
      commaSep.addGroupingPair('(', ')');
      String minString = commaSep.next();
      String maxString;
      if (commaSep.hasNext()) {
        maxString = commaSep.next();
      } else {
        maxString = subTok;
      }
      if (commaSep.hasNext()) {
        return new ParseResult.Fail("Token cannot have more than one separator ','", context);
      }
      Formula min = FormulaFactory.getFormulaFor(minString);
      if (!min.isValid()) {
        return new ParseResult.Fail(
            "Min Formula in " + getTokenName() + " was not valid: " + min.toString(), context);
      }
      Formula max = FormulaFactory.getFormulaFor(maxString);
      if (!max.isValid()) {
        return new ParseResult.Fail(
            "Max Formula in " + getTokenName() + " was not valid: " + max.toString(), context);
      }
      kit.setOptionBounds(min, max);
    }
    return ParseResult.SUCCESS;
  }
コード例 #12
0
ファイル: CostpreToken.java プロジェクト: aroni125/pcgen-svn
 @Override
 protected ParseResult parseNonEmptyToken(
     LoadContext context, EquipmentModifier mod, String value) {
   Formula formula = FormulaFactory.getFormulaFor(value);
   if (!formula.isValid()) {
     return new ParseResult.Fail(
         "Formula in " + getTokenName() + " was not valid: " + formula.toString());
   }
   context.getObjectContext().put(mod, FormulaKey.BASECOST, formula);
   return ParseResult.SUCCESS;
 }
コード例 #13
0
ファイル: SizeFacetTest.java プロジェクト: neonobjclash/pcgen
 @Test
 public void testGetAbbWithLevelProgression() {
   Race r = new Race();
   r.put(FormulaKey.SIZE, FormulaFactory.getFormulaFor(1));
   rfacet.set(id, r);
   facet.update(id);
   assertEquals("S", facet.getSizeAbb(id));
   fakeLevels = 6;
   facet.update(id);
   assertEquals("S", facet.getSizeAbb(id));
   r.addToListFor(ListKey.HITDICE_ADVANCEMENT, 2);
   facet.update(id);
   assertEquals("S", facet.getSizeAbb(id));
   r.addToListFor(ListKey.HITDICE_ADVANCEMENT, Integer.MAX_VALUE);
   facet.update(id);
   assertEquals("M", facet.getSizeAbb(id));
   r.removeListFor(ListKey.HITDICE_ADVANCEMENT);
   r.addToListFor(ListKey.HITDICE_ADVANCEMENT, 2);
   r.addToListFor(ListKey.HITDICE_ADVANCEMENT, 5);
   r.addToListFor(ListKey.HITDICE_ADVANCEMENT, 6);
   facet.update(id);
   assertEquals("L", facet.getSizeAbb(id));
   PCTemplate t1 = new PCTemplate();
   t1.setName("PCT");
   t1.put(FormulaKey.SIZE, FormulaFactory.getFormulaFor(0));
   tfacet.add(id, t1, this);
   facet.update(id);
   assertEquals("M", facet.getSizeAbb(id));
   PCTemplate t2 = new PCTemplate();
   t2.setName("Other");
   t2.put(FormulaKey.SIZE, FormulaFactory.getFormulaFor(3));
   tfacet.add(id, t2, this);
   facet.update(id);
   assertEquals("H", facet.getSizeAbb(id));
   tfacet.remove(id, t2, this);
   facet.update(id);
   assertEquals("M", facet.getSizeAbb(id));
   r.removeListFor(ListKey.HITDICE_ADVANCEMENT);
   facet.update(id);
   assertEquals("T", facet.getSizeAbb(id));
 }
コード例 #14
0
ファイル: SizeFacetTest.java プロジェクト: neonobjclash/pcgen
 @Test
 public void testGetFromTemplateLowerOverridesDefault() {
   rfacet.set(id, new Race());
   PCTemplate t1 = new PCTemplate();
   t1.put(FormulaKey.SIZE, FormulaFactory.getFormulaFor(1));
   tfacet.add(id, t1, this);
   facet.update(id);
   assertEquals(1, facet.sizeInt(id));
   tfacet.remove(id, t1, this);
   facet.update(id);
   assertEquals(2, facet.sizeInt(id));
 }
コード例 #15
0
ファイル: SizeFacetTest.java プロジェクト: neonobjclash/pcgen
 @Test
 public void testGetFromTemplateSecondOverrides() {
   Race r = new Race();
   r.put(FormulaKey.SIZE, FormulaFactory.getFormulaFor(1));
   rfacet.set(id, r);
   PCTemplate t1 = new PCTemplate();
   t1.setName("PCT");
   t1.put(FormulaKey.SIZE, FormulaFactory.getFormulaFor(3));
   tfacet.add(id, t1, this);
   PCTemplate t2 = new PCTemplate();
   t2.setName("Other");
   t2.put(FormulaKey.SIZE, FormulaFactory.getFormulaFor(4));
   tfacet.add(id, t2, this);
   facet.update(id);
   assertEquals(4, facet.sizeInt(id));
   tfacet.remove(id, t2, this);
   facet.update(id);
   assertEquals(3, facet.sizeInt(id));
   tfacet.remove(id, t1, this);
   facet.update(id);
   assertEquals(1, facet.sizeInt(id));
 }
コード例 #16
0
ファイル: PJepTest.java プロジェクト: Nylanfs/pcgen
  public void testJepIf() {
    final PlayerCharacter character = new PlayerCharacter();
    Float val;
    val = character.getVariableValue("var(\"UseAlternateDamage\")", "");
    assertEquals("Undefined variable should return 0", 0.0, val.doubleValue(), 0.1);

    Race giantRace = TestHelper.makeRace("Ogre");
    giantRace.put(VariableKey.getConstant("UseAlternateDamage"), FormulaFactory.getFormulaFor(2));
    character.setRace(giantRace);

    val = character.getVariableValue("var(\"UseAlternateDamage\")", "");
    assertEquals("Variable defined to be 2.", 2.0, val.doubleValue(), 0.1);

    val = character.getVariableValue("2==2", "");
    assertEquals("Equality test of 2==2 should be true.", 1.0, val.doubleValue(), 0.1);

    val = character.getVariableValue("3-1==2", "");
    assertEquals("Equality test of 3-1==2 should be true.", 1.0, val.doubleValue(), 0.1);

    val = character.getVariableValue("var(\"UseAlternateDamage\")>1", "");
    assertEquals("Variable defined to be 2 should be more than 1", 1.0, val.doubleValue(), 0.1);

    val = character.getVariableValue("var(\"UseAlternateDamage\")<3", "");
    assertEquals(
        "Variable defined to be 2 should be more than 1 be less than 3",
        1.0,
        val.doubleValue(),
        0.1);

    val = character.getVariableValue("var(\"UseAlternateDamage\")==1", "");
    assertEquals("Variable defined to be 2 should not be equal to 1", 0.0, val.doubleValue(), 0.1);

    val = character.getVariableValue("var(\"UseAlternateDamage\")>=2", "");
    assertEquals("Variable defined to be 2 should be >= 2", 1.0, val.doubleValue(), 0.1);

    val = character.getVariableValue("var(\"UseAlternateDamage\")<=2", "");
    assertEquals("Variable defined to be 2 should be <= 2", 1.0, val.doubleValue(), 0.1);

    val = character.getVariableValue("var(\"UseAlternateDamage\")==2", "");
    assertEquals("Variable defined to be 2 should be == 2", 1.0, val.doubleValue(), 0.1);

    val = character.getVariableValue("IF(var(\"UseAlternateDamage\")==2,-2,5)", "");
    assertEquals("Test should have returned -2", -2, val.doubleValue(), 0.1);
  }
コード例 #17
0
ファイル: SkilllistToken.java プロジェクト: cpmeister/pcgen
  @Override
  protected ParseResult parseTokenWithSeparator(LoadContext context, PCClass pcc, String value) {
    StringTokenizer tok = new StringTokenizer(value, Constants.PIPE);
    Formula count = FormulaFactory.getFormulaFor(tok.nextToken());
    if (!count.isValid()) {
      return new ParseResult.Fail(
          "Count in " + getTokenName() + " was not valid: " + count.toString(), context);
    }
    if (!count.isStatic() || count.resolveStatic().intValue() <= 0) {
      return new ParseResult.Fail("Count in " + getTokenName() + " must be > 0", context);
    }
    if (!tok.hasMoreTokens()) {
      return new ParseResult.Fail(
          getTokenName()
              + " must have a | separating "
              + "count from the list of possible values: "
              + value,
          context);
    }
    List<CDOMReference<ClassSkillList>> refs = new ArrayList<>();

    while (tok.hasMoreTokens()) {
      String token = tok.nextToken();
      CDOMReference<ClassSkillList> ref;
      if (Constants.LST_ALL.equals(token)) {
        ref = context.getReferenceContext().getCDOMAllReference(SKILLLIST_CLASS);
      } else {
        ref = context.getReferenceContext().getCDOMReference(SKILLLIST_CLASS, token);
      }
      refs.add(ref);
    }

    ReferenceChoiceSet<ClassSkillList> rcs = new ReferenceChoiceSet<>(refs);
    if (!rcs.getGroupingState().isValid()) {
      return new ParseResult.Fail(
          "Non-sensical " + getTokenName() + ": Contains ANY and a specific reference: " + value);
    }
    ChoiceSet<ClassSkillList> cs = new ChoiceSet<>(getTokenName(), rcs);
    cs.setTitle("Select class whose class-skills this class will inherit");
    TransitionChoice<ClassSkillList> tc = new ConcreteTransitionChoice<>(cs, count);
    context.getObjectContext().put(pcc, ObjectKey.SKILLLIST_CHOICE, tc);
    tc.setRequired(false);
    return ParseResult.SUCCESS;
  }
コード例 #18
0
  protected void setUpContext() throws PersistenceLayerException {
    ChooserFactory.pushChooserClassname(RandomChooser.class.getName());
    TokenRegistration.clearTokens();
    TokenRegistration.register(AUTO_LANG_TOKEN);
    TokenRegistration.register(ABILITY_VISIBLE_TOKEN);
    TokenRegistration.register(AUTO_TOKEN);
    TokenRegistration.register(CHOOSE_TOKEN);
    TokenRegistration.register(CHOOSE_LANG_TOKEN);
    TokenRegistration.register(ABILITY_MULT_TOKEN);
    TokenRegistration.register(EQUIP_TYPE_TOKEN);
    TokenRegistration.register(EQUIP_PROFICIENCY_TOKEN);
    TokenRegistration.register(LANGBONUS_PRIM);
    TokenRegistration.register(PC_QUAL);
    TokenRegistration.register(getToken());
    TokenRegistration.register(plugin.bonustokens.Feat.class);

    directAbilityFacet = FacetLibrary.getFacet(DirectAbilityFacet.class);
    activeEqModFacet = FacetLibrary.getFacet(ActiveEqModFacet.class);
    alignmentFacet = FacetLibrary.getFacet(AlignmentFacet.class);
    bioSetFacet = FacetLibrary.getFacet(BioSetFacet.class);
    checkFacet = FacetLibrary.getFacet(CheckFacet.class);
    classFacet = FacetLibrary.getFacet(ClassFacet.class);
    classLevelFacet = FacetLibrary.getFacet(ClassLevelFacet.class);
    companionModFacet = FacetLibrary.getFacet(CompanionModFacet.class);
    deityFacet = FacetLibrary.getFacet(DeityFacet.class);
    domainFacet = FacetLibrary.getFacet(DomainFacet.class);
    expandedCampaignFacet = FacetLibrary.getFacet(ExpandedCampaignFacet.class);
    languageFacet = FacetLibrary.getFacet(LanguageFacet.class);
    raceFacet = FacetLibrary.getFacet(RaceInputFacet.class);
    sizeFacet = FacetLibrary.getFacet(SizeFacet.class);
    skillFacet = FacetLibrary.getFacet(SkillFacet.class);
    statFacet = FacetLibrary.getFacet(StatFacet.class);
    templateInputFacet = FacetLibrary.getFacet(TemplateInputFacet.class);
    templateConsolidationFacet = FacetLibrary.getFacet(TemplateFacet.class);
    weaponProfModelFacet = FacetLibrary.getFacet(WeaponProfModelFacet.class);

    Globals.createEmptyRace();
    Globals.setUseGUI(false);
    Globals.emptyLists();
    GameMode gamemode = SettingsHandler.getGame();
    gamemode.clearLoadContext();

    str = BuildUtilities.createStat("Strength", "STR");
    str.put(VariableKey.getConstant("LOADSCORE"), FormulaFactory.getFormulaFor("STRSCORE"));
    str.put(VariableKey.getConstant("OFFHANDLIGHTBONUS"), FormulaFactory.getFormulaFor(2));
    dex = BuildUtilities.createStat("Dexterity", "DEX");
    PCStat con = BuildUtilities.createStat("Constitution", "CON");
    intel = BuildUtilities.createStat("Intelligence", "INT");
    wis = BuildUtilities.createStat("Wisdom", "WIS");
    cha = BuildUtilities.createStat("Charisma", "CHA");

    AbstractReferenceContext ref = Globals.getContext().getReferenceContext();
    lg = BuildUtilities.createAlignment("Lawful Good", "LG");
    ref.importObject(lg);
    ln = BuildUtilities.createAlignment("Lawful Neutral", "LN");
    ref.importObject(ln);
    le = BuildUtilities.createAlignment("Lawful Evil", "LE");
    ref.importObject(le);
    ng = BuildUtilities.createAlignment("Neutral Good", "NG");
    ref.importObject(ng);
    tn = BuildUtilities.createAlignment("True Neutral", "TN");
    ref.importObject(tn);
    ne = BuildUtilities.createAlignment("Neutral Evil", "NE");
    ref.importObject(ne);
    cg = BuildUtilities.createAlignment("Chaotic Good", "CG");
    ref.importObject(cg);
    cn = BuildUtilities.createAlignment("Chaotic Neutral", "CN");
    ref.importObject(cn);
    ce = BuildUtilities.createAlignment("Chaotic Evil", "CE");
    ref.importObject(ce);
    ref.importObject(BuildUtilities.createAlignment("None", "NONE"));
    ref.importObject(BuildUtilities.createAlignment("Deity's", "Deity"));

    gamemode.setBonusFeatLevels("3|3");

    SettingsHandler.setGame("3.5");

    ref.importObject(str);
    ref.importObject(dex);
    ref.importObject(con);
    ref.importObject(intel);
    ref.importObject(wis);
    ref.importObject(cha);

    fine = BuildUtilities.createSize("Fine");
    diminutive = BuildUtilities.createSize("Diminutive");
    tiny = BuildUtilities.createSize("Tiny");
    small = BuildUtilities.createSize("Small");
    medium = BuildUtilities.createSize("Medium");
    medium.put(ObjectKey.IS_DEFAULT_SIZE, Boolean.TRUE);
    large = BuildUtilities.createSize("Large");
    huge = BuildUtilities.createSize("Huge");
    gargantuan = BuildUtilities.createSize("Gargantuan");
    colossal = BuildUtilities.createSize("Colossal");

    context = Globals.getContext();
    create(Language.class, "Common");
    BuildUtilities.createFact(context, "ClassType", PCClass.class);
    FactDefinition<?, String> fd = BuildUtilities.createFact(context, "SpellType", PCClass.class);
    fd.setSelectable(true);
    context.getReferenceContext().importObject(AbilityCategory.FEAT);
    SourceFileLoader.createLangBonusObject(Globals.getContext());
  }
コード例 #19
0
ファイル: PreDRTest.java プロジェクト: kne1p/pcgen
  @Override
  protected void setUp() throws Exception {
    super.setUp();

    drPlus1 = new DamageReduction(FormulaFactory.getFormulaFor(5), "+1");
  }
コード例 #20
0
ファイル: FeatToken.java プロジェクト: timoc/pcgen-svn
  @Override
  protected ParseResult parseNonEmptyToken(LoadContext context, CDOMObject obj, String value) {
    AbilityCategory category = AbilityCategory.FEAT;
    Nature nature = Nature.NORMAL;

    ParsingSeparator sep = new ParsingSeparator(value, '|');
    String activeValue = sep.next();
    Formula count;
    if (!sep.hasNext()) {
      count = FormulaFactory.ONE;
    } else {
      count = FormulaFactory.getFormulaFor(activeValue);
      if (!count.isValid()) {
        return new ParseResult.Fail(
            "Count in " + getTokenName() + " was not valid: " + count.toString(), context);
      }
      if (!count.isValid()) {
        return new ParseResult.Fail(
            "Count in " + getTokenName() + " was not valid: " + count.toString(), context);
      }
      if (count.isStatic() && count.resolveStatic().doubleValue() <= 0) {
        return new ParseResult.Fail("Count in " + getFullName() + " must be > 0", context);
      }
      activeValue = sep.next();
    }
    if (sep.hasNext()) {
      return new ParseResult.Fail(
          getFullName() + " had too many pipe separated items: " + value, context);
    }
    if (isEmpty(activeValue) || hasIllegalSeparator(',', activeValue)) {
      return ParseResult.INTERNAL_ERROR;
    }

    List<CDOMReference<Ability>> refs = new ArrayList<CDOMReference<Ability>>();
    List<PrimitiveChoiceSet<CategorizedAbilitySelection>> pcs =
        new ArrayList<PrimitiveChoiceSet<CategorizedAbilitySelection>>();
    ParsingSeparator tok = new ParsingSeparator(activeValue, ',');

    boolean foundAny = false;
    boolean foundOther = false;

    ReferenceManufacturer<Ability> rm =
        context.ref.getManufacturer(ABILITY_CLASS, AbilityCategory.FEAT);

    while (tok.hasNext()) {
      CDOMReference<Ability> ab = null;
      String token = tok.next();
      if (Constants.LST_CHOICE.equals(token) || Constants.LST_ANY.equals(token)) {
        foundAny = true;
        ab = rm.getAllReference();
      } else if (token.startsWith("CLASS.") || token.startsWith("CLASS=")) {
        String className = token.substring(6);
        if (className.length() == 0) {
          return new ParseResult.Fail(
              getTokenName() + " must have Class name after " + token, context);
        }
        CDOMSingleRef<PCClass> pcc = context.ref.getCDOMReference(PCCLASS_CLASS, className);
        AbilityFromClassChoiceSet acs = new AbilityFromClassChoiceSet(pcc);
        pcs.add(acs);
      } else {
        foundOther = true;
        ab = TokenUtilities.getTypeOrPrimitive(rm, token);
        if (ab == null) {
          return new ParseResult.Fail(
              "  Error was encountered while parsing "
                  + getTokenName()
                  + ": "
                  + value
                  + " had an invalid reference: "
                  + token,
              context);
        }
      }
      if (ab != null) {
        refs.add(ab);
      }
    }

    if (foundAny && foundOther) {
      return new ParseResult.Fail(
          "Non-sensical " + getFullName() + ": Contains ANY and a specific reference: " + value,
          context);
    }

    if (!refs.isEmpty()) {
      AbilityRefChoiceSet rcs = new AbilityRefChoiceSet(category, refs, nature);
      pcs.add(rcs);
    }
    if (pcs.isEmpty()) {
      return new ParseResult.Fail(
          "Internal Error: " + getFullName() + " did not have any references: " + value, context);
    }
    PrimitiveChoiceSet<CategorizedAbilitySelection> ascs;
    if (pcs.size() == 1) {
      ascs = pcs.get(0);
    } else {
      ascs = new CompoundOrChoiceSet<CategorizedAbilitySelection>(pcs, Constants.COMMA);
    }
    ChoiceSet<CategorizedAbilitySelection> cs =
        new ChoiceSet<CategorizedAbilitySelection>(getTokenName(), ascs, true);
    cs.setTitle("Select for removal");
    PersistentTransitionChoice<CategorizedAbilitySelection> tc =
        new ConcretePersistentTransitionChoice<CategorizedAbilitySelection>(cs, count);
    context.getObjectContext().addToList(obj, ListKey.REMOVE, tc);
    tc.allowStack(true);
    tc.setChoiceActor(this);
    return ParseResult.SUCCESS;
  }