Search in sources :

Example 1 with Type

use of pcgen.cdom.enumeration.Type in project pcgen by PCGen.

the class SkillModifier method modifier.

public static Integer modifier(Skill sk, PlayerCharacter aPC) {
    int bonus = 0;
    if (aPC == null) {
        return 0;
    }
    String keyName = sk.getKeyName();
    CDOMSingleRef<PCStat> statref = sk.get(ObjectKey.KEY_STAT);
    if (statref != null) {
        PCStat stat = statref.get();
        bonus = aPC.getStatModFor(stat);
        bonus += aPC.getTotalBonusTo("SKILL", "STAT." + stat.getKeyName());
    }
    bonus += aPC.getTotalBonusTo("SKILL", keyName);
    // loop through all current skill types checking for boni
    for (Type singleType : sk.getTrueTypeList(false)) {
        bonus += aPC.getTotalBonusTo("SKILL", "TYPE." + singleType);
    }
    // now check for any lists of skills, etc
    bonus += aPC.getTotalBonusTo("SKILL", "LIST");
    // now check for ALL
    bonus += aPC.getTotalBonusTo("SKILL", "ALL");
    // function
    if (aPC.isClassSkill(sk)) {
        bonus += aPC.getTotalBonusTo("CSKILL", keyName);
        // loop through all current skill types checking for boni
        for (Type singleType : sk.getTrueTypeList(false)) {
            bonus += aPC.getTotalBonusTo("CSKILL", "TYPE." + singleType);
        }
        bonus += aPC.getTotalBonusTo("CSKILL", "LIST");
    }
    if (!aPC.isClassSkill(sk) && !sk.getSafe(ObjectKey.EXCLUSIVE)) {
        bonus += aPC.getTotalBonusTo("CCSKILL", keyName);
        // loop through all current skill types checking for boni
        for (Type singleType : sk.getTrueTypeList(false)) {
            bonus += aPC.getTotalBonusTo("CCSKILL", "TYPE." + singleType);
        }
        bonus += aPC.getTotalBonusTo("CCSKILL", "LIST");
    }
    // the above two if-blocks try to get
    // BONUS:[C]CSKILL|TYPE=xxx|y to function
    int aCheckBonus = sk.getSafe(ObjectKey.ARMOR_CHECK).calculateBonus(aPC);
    bonus += aCheckBonus;
    String aString = SettingsHandler.getGame().getRankModFormula();
    if (!aString.isEmpty()) {
        aString = aString.replaceAll(Pattern.quote("$$RANK$$"), SkillRankControl.getTotalRank(aPC, sk).toString());
        bonus += aPC.getVariableValue(aString, "").intValue();
    }
    return bonus;
}
Also used : Type(pcgen.cdom.enumeration.Type) PCStat(pcgen.core.PCStat)

Example 2 with Type

use of pcgen.cdom.enumeration.Type in project pcgen by PCGen.

the class PlayerCharacter method getConcentration.

public int getConcentration(final Spell sp, final CharacterSpell aSpell, PCClass aClass, int spellLevel, int metaConcentration, CDOMObject ow) {
    String bonDomain = "";
    if (ow instanceof Domain) {
        bonDomain = "DOMAIN." + ow.getKeyName();
        ClassSource source = getDomainSource((Domain) ow);
        if (source != null) {
            aClass = getClassKeyed(source.getPcclass().getKeyName());
        }
    }
    boolean useStatFromSpell = false;
    String bonClass = "";
    String spellType = "";
    String classKey = "";
    if ((aClass != null) || (ow instanceof PCClass)) {
        if ((aClass == null) || (ow instanceof PCClass)) {
            aClass = (PCClass) ow;
        }
        bonClass = "CLASS." + aClass.getKeyName();
        classKey = "CLASS:" + aClass.getKeyName();
        spellType = aClass.getSpellType();
        useStatFromSpell = aClass.getSafe(ObjectKey.USE_SPELL_SPELL_STAT);
    }
    if (!(ow instanceof PCClass) && !(ow instanceof Domain)) {
        // get BASESPELLSTAT from spell itself
        useStatFromSpell = true;
    }
    // set the spell Level used in aPC.getVariableValue()
    // Explicitly should *not* set the dirty flag to true.
    spellLevelTemp = spellLevel;
    // must be done after spellLevel is set above
    int concentration = getVariableValue(aSpell, SettingsHandler.getGame().getSpellBaseConcentration(), classKey).intValue() + metaConcentration;
    concentration += (int) getTotalBonusTo("CONCENTRATION", "ALLSPELLS");
    if (useStatFromSpell) {
        // get the BASESPELLSTAT from the spell itself
        CDOMSingleRef<PCStat> stat = sp.get(ObjectKey.SPELL_STAT);
        if (stat != null) {
            concentration += this.getStatModFor(stat.get());
        }
    }
    if (!sp.getKeyName().isEmpty()) {
        concentration += (int) getTotalBonusTo("CONCENTRATION", "SPELL." + sp.getKeyName());
    }
    // DOMAIN.name
    if (!bonDomain.isEmpty()) {
        concentration += (int) getTotalBonusTo("CONCENTRATION", bonDomain);
    }
    // CLASS.name
    if (!bonClass.isEmpty()) {
        concentration += (int) getTotalBonusTo("CONCENTRATION", bonClass);
    }
    concentration += (int) getTotalBonusTo("CONCENTRATION", "TYPE." + spellType);
    if (spellType.equals("ALL")) {
        for (Type aType : sp.getTrueTypeList(false)) {
            concentration += (int) getTotalBonusTo("CONCENTRATION", "TYPE." + aType);
        }
    }
    for (SpellSchool aType : sp.getSafeListFor(ListKey.SPELL_SCHOOL)) {
        concentration += (int) getTotalBonusTo("CONCENTRATION", "SCHOOL." + aType.toString());
    }
    for (String aType : sp.getSafeListFor(ListKey.SPELL_SUBSCHOOL)) {
        concentration += (int) getTotalBonusTo("CONCENTRATION", "SUBSCHOOL." + aType);
    }
    for (String aType : sp.getSafeListFor(ListKey.SPELL_DESCRIPTOR)) {
        concentration += (int) getTotalBonusTo("CONCENTRATION", "DESCRIPTOR." + aType);
    }
    // Explicitly should *not* set the dirty flag to true.
    spellLevelTemp = 0;
    return concentration;
}
Also used : SpellSchool(pcgen.cdom.identifier.SpellSchool) MessageType(pcgen.core.utils.MessageType) AttackType(pcgen.util.enumeration.AttackType) Type(pcgen.cdom.enumeration.Type) ClassSource(pcgen.cdom.helper.ClassSource)

Example 3 with Type

use of pcgen.cdom.enumeration.Type in project pcgen by PCGen.

the class ChallengeRatingFacet method getClassCRModPriority.

private int getClassCRModPriority(PCClass cl) {
    int crModPriority = 0;
    ClassType aClassType = SettingsHandler.getGame().getClassTypeByName(cl.getClassType());
    if (aClassType != null) {
        int crmp = aClassType.getCRModPriority();
        if (crmp != 0) {
            crModPriority = crmp;
        }
    } else {
        // use old method to determine the class type from TYPE. 
        for (Type type : cl.getTrueTypeList(false)) {
            aClassType = SettingsHandler.getGame().getClassTypeByName(type.toString());
            if (aClassType != null) {
                int crmp = aClassType.getCRModPriority();
                if (crmp != 0) {
                    crModPriority = aClassType.getCRModPriority();
                }
            }
        }
    }
    return crModPriority;
}
Also used : Type(pcgen.cdom.enumeration.Type) ClassType(pcgen.core.ClassType) ClassType(pcgen.core.ClassType)

Example 4 with Type

use of pcgen.cdom.enumeration.Type in project pcgen by PCGen.

the class ChallengeRatingFacet method getClassCRMod.

private int getClassCRMod(CharID id, PCClass cl) {
    int crMod = 0;
    ClassType aClassType = SettingsHandler.getGame().getClassTypeByName(cl.getClassType());
    if (aClassType != null) {
        String crmf = aClassType.getCRMod();
        Formula crm = FormulaFactory.getFormulaFor(crmf);
        crMod = Math.min(crMod, formulaResolvingFacet.resolve(id, crm, cl.getQualifiedKey()).intValue());
    } else {
        // use old method to determine the class type from TYPE. 
        for (Type type : cl.getTrueTypeList(false)) {
            aClassType = SettingsHandler.getGame().getClassTypeByName(type.toString());
            if (aClassType != null) {
                String crmf = aClassType.getCRMod();
                Formula crm = FormulaFactory.getFormulaFor(crmf);
                crMod = Math.min(crMod, formulaResolvingFacet.resolve(id, crm, cl.getQualifiedKey()).intValue());
            }
        }
    }
    return crMod;
}
Also used : Formula(pcgen.base.formula.Formula) Type(pcgen.cdom.enumeration.Type) ClassType(pcgen.core.ClassType) ClassType(pcgen.core.ClassType)

Example 5 with Type

use of pcgen.cdom.enumeration.Type in project pcgen by PCGen.

the class EquipmentList method createItem.

private static void createItem(Equipment eq, final EquipmentModifier eqMod, final SizeAdjustment sa, final PlayerCharacter aPC, final String choice, final EquipmentChoice equipChoice) {
    if (eq == null) {
        return;
    }
    try {
        //
        if (!eq.getSafe(ObjectKey.MOD_CONTROL).getModifiersAllowed() || (eq.isArmor() && (eq.getACMod(aPC).intValue() == 0) && ((eqMod != null) && !eqMod.getDisplayName().equalsIgnoreCase("MASTERWORK")))) {
            return;
        }
        eq = eq.clone();
        if (eq == null) {
            Logging.errorPrint("could not clone item");
            return;
        }
        if (eqMod != null) {
            eq.addEqModifier(eqMod, true, aPC, choice, equipChoice);
            if (eq.isWeapon() && eq.isDouble()) {
                eq.addEqModifier(eqMod, false, aPC, choice, equipChoice);
            }
        }
        if (sa != null) {
            eq.resizeItem(aPC, sa);
        }
        //
        // Change the names, to protect the innocent
        //
        final String sKeyName = eq.nameItemFromModifiers(aPC);
        final Equipment eqExists = Globals.getContext().getReferenceContext().silentlyGetConstructedCDOMObject(Equipment.class, sKeyName);
        if (eqExists != null) {
            return;
        }
        final Type newType;
        if (isAutoGeneration()) {
            newType = Type.AUTO_GEN;
        } else {
            newType = Type.CUSTOM;
        }
        if (!eq.isType(newType.toString())) {
            eq.addType(newType);
        }
        Globals.getContext().getReferenceContext().importObject(eq);
    } catch (NumberFormatException exception) {
        Logging.errorPrint("createItem: exception: " + eq.getName());
    }
}
Also used : Type(pcgen.cdom.enumeration.Type)

Aggregations

Type (pcgen.cdom.enumeration.Type)27 ArrayList (java.util.ArrayList)6 MessageType (pcgen.core.utils.MessageType)6 EquipmentHead (pcgen.cdom.inst.EquipmentHead)4 Skill (pcgen.core.Skill)4 StringTokenizer (java.util.StringTokenizer)3 PCStat (pcgen.core.PCStat)3 BonusObj (pcgen.core.bonus.BonusObj)3 AttackType (pcgen.util.enumeration.AttackType)3 HashMap (java.util.HashMap)2 ClassSource (pcgen.cdom.helper.ClassSource)2 SpellSchool (pcgen.cdom.identifier.SpellSchool)2 ChangeArmorType (pcgen.cdom.processor.ChangeArmorType)2 ClassType (pcgen.core.ClassType)2 Equipment (pcgen.core.Equipment)2 WeaponProf (pcgen.core.WeaponProf)2 CharacterDisplay (pcgen.core.display.CharacterDisplay)2 ParseResult (pcgen.rules.persistence.token.ParseResult)2 HashSet (java.util.HashSet)1 LinkedHashSet (java.util.LinkedHashSet)1