示例#1
0
 /**
  * Constructs a new FactSetGroup from the given context, FactSetInfo and value.
  *
  * @param context The LoadContext used to resolve references
  * @param fsi The FactSetInfo indicating the underlying characteristics of the Fact that this
  *     FactSetGroup will check
  * @param value The String representation of the value that this FactSetGroup will be looking for
  */
 public FactSetGroup(LoadContext context, FactSetInfo<T, F> fsi, String value) {
   if (fsi.getUsableLocation().equals(CDOMObject.class)) {
     throw new IllegalArgumentException("FactSetGroup cannot be global");
   }
   def = fsi;
   AbstractReferenceContext refContext = context.getReferenceContext();
   allObjects = refContext.getCDOMAllReference(def.getUsableLocation());
   toMatch = def.getFormatManager().convertIndirect(value);
   if (toMatch == null) {
     throw new IllegalArgumentException(
         "Failed to convert "
             + value
             + " as a "
             + def.getFormatManager().getManagedClass().getSimpleName());
   }
 }
示例#2
0
  /**
   * Get the unarmed Damage for this class at the given level.
   *
   * @param aLevel the given level.
   * @param aPC the PC with the level.
   * @param adjustForPCSize whether to adjust the result for the PC's size.
   * @return the unarmed damage string
   */
  String getUDamForEffLevel(int aLevel, final PlayerCharacter aPC, boolean adjustForPCSize) {
    int pcSize = adjustForPCSize ? aPC.sizeInt() : aPC.getDisplay().racialSizeInt();

    //
    // Check "Unarmed Strike", then default to "1d3"
    //
    String aDamage;

    AbstractReferenceContext ref = Globals.getContext().getReferenceContext();
    final Equipment eq =
        ref.silentlyGetConstructedCDOMObject(Equipment.class, "KEY_Unarmed Strike");

    if (eq != null) {
      aDamage = eq.getDamage(aPC);
    } else {
      aDamage = "1d3";
    }

    // resize the damage as if it were a weapon
    if (adjustForPCSize) {
      int defSize = SizeUtilities.getDefaultSizeAdjustment().get(IntegerKey.SIZEORDER);
      aDamage = Globals.adjustDamage(aDamage, defSize, pcSize);
    }

    //
    // Check the UDAM list for monk-like damage
    //
    List<CDOMObject> classObjects = new ArrayList<>();
    // Negative increment to start at highest level until an UDAM is found
    for (int i = aLevel; i >= 1; i--) {
      classObjects.add(aPC.getActiveClassLevel(this, i));
    }
    classObjects.add(this);
    for (CDOMObject cdo : classObjects) {
      List<String> udam = cdo.getListFor(ListKey.UNARMED_DAMAGE);
      if (udam != null) {
        if (udam.size() == 1) {
          aDamage = udam.get(0);
        } else {
          aDamage = udam.get(pcSize);
        }
        break;
      }
    }
    return aDamage;
  }
示例#3
0
 private static synchronized void staticSetUp() {
   if (!staticDone) {
     SettingsHandler.getGame().clearLoadContext();
     AbstractReferenceContext ref = Globals.getContext().getReferenceContext();
     t = BuildUtilities.createSize("Tiny", 0);
     ref.importObject(t);
     s = BuildUtilities.createSize("Small", 1);
     ref.importObject(s);
     m = BuildUtilities.createSize("Medium", 2);
     m.put(ObjectKey.IS_DEFAULT_SIZE, true);
     ref.importObject(m);
     l = BuildUtilities.createSize("Large", 3);
     ref.importObject(l);
     h = BuildUtilities.createSize("Huge", 4);
     ref.importObject(h);
     staticDone = true;
   }
 }
  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());
  }