Search in sources :

Example 6 with SpellSchool

use of pcgen.cdom.identifier.SpellSchool in project pcgen by PCGen.

the class PlayerCharacter method getDC.

public int getDC(final Spell sp, PCClass aClass, int spellLevel, int metaDC, 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 dc = getVariableValue(SettingsHandler.getGame().getSpellBaseDC(), classKey).intValue() + metaDC;
    dc += (int) getTotalBonusTo("DC", "ALLSPELLS");
    if (useStatFromSpell) {
        // get the BASESPELLSTAT from the spell itself
        CDOMSingleRef<PCStat> stat = sp.get(ObjectKey.SPELL_STAT);
        if (stat != null) {
            dc += this.getStatModFor(stat.get());
        }
    }
    if (!sp.getKeyName().isEmpty()) {
        dc += (int) getTotalBonusTo("DC", "SPELL." + sp.getKeyName());
    }
    // DOMAIN.name
    if (!bonDomain.isEmpty()) {
        dc += (int) getTotalBonusTo("DC", bonDomain);
    }
    // CLASS.name
    if (!bonClass.isEmpty()) {
        dc += (int) getTotalBonusTo("DC", bonClass);
    }
    dc += (int) getTotalBonusTo("DC", "TYPE." + spellType);
    if (spellType.equals("ALL")) {
        for (Type aType : sp.getTrueTypeList(false)) {
            dc += (int) getTotalBonusTo("DC", "TYPE." + aType);
        }
    }
    for (SpellSchool aType : sp.getSafeListFor(ListKey.SPELL_SCHOOL)) {
        dc += (int) getTotalBonusTo("DC", "SCHOOL." + aType.toString());
    }
    for (String aType : sp.getSafeListFor(ListKey.SPELL_SUBSCHOOL)) {
        dc += (int) getTotalBonusTo("DC", "SUBSCHOOL." + aType);
    }
    for (String aType : sp.getSafeListFor(ListKey.SPELL_DESCRIPTOR)) {
        dc += (int) getTotalBonusTo("DC", "DESCRIPTOR." + aType);
    }
    // Explicitly should *not* set the dirty flag to true.
    spellLevelTemp = 0;
    return dc;
}
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 7 with SpellSchool

use of pcgen.cdom.identifier.SpellSchool in project pcgen by PCGen.

the class SpellBuilderFacadeImpl method isSpellOfSubType.

private boolean isSpellOfSubType(Spell aSpell) {
    if (subTypeList.isEmpty()) {
        return true;
    }
    boolean finalIsOfType = false;
    for (String s : subTypeList) {
        boolean isOfType = true;
        StringTokenizer aTok = new StringTokenizer(s, ";,");
        while (aTok.hasMoreTokens()) {
            String subType = aTok.nextToken();
            if (subType.startsWith("SCHOOL.")) {
                SpellSchool ss = Globals.getContext().getReferenceContext().silentlyGetConstructedCDOMObject(SpellSchool.class, subType.substring(7));
                if (ss == null || !aSpell.containsInList(ListKey.SPELL_SCHOOL, ss)) {
                    isOfType = false;
                    break;
                }
            }
            if (subType.startsWith("SUBSCHOOL.")) {
                if (!aSpell.containsInList(ListKey.SPELL_SUBSCHOOL, subType.substring(10))) {
                    isOfType = false;
                    break;
                }
            }
            if (subType.startsWith("DESCRIPTOR.")) {
                String descriptor = subType.substring(11);
                if (!aSpell.containsInList(ListKey.SPELL_DESCRIPTOR, descriptor)) {
                    isOfType = false;
                    break;
                }
            }
        }
        if (isOfType) {
            finalIsOfType = true;
            break;
        }
    }
    return finalIsOfType;
}
Also used : SpellSchool(pcgen.cdom.identifier.SpellSchool) StringTokenizer(java.util.StringTokenizer)

Aggregations

SpellSchool (pcgen.cdom.identifier.SpellSchool)7 ArrayList (java.util.ArrayList)2 StringTokenizer (java.util.StringTokenizer)2 Type (pcgen.cdom.enumeration.Type)2 ClassSource (pcgen.cdom.helper.ClassSource)2 CharacterSpell (pcgen.core.character.CharacterSpell)2 Spell (pcgen.core.spell.Spell)2 MessageType (pcgen.core.utils.MessageType)2 AttackType (pcgen.util.enumeration.AttackType)2 TreeSet (java.util.TreeSet)1 CDOMList (pcgen.cdom.base.CDOMList)1 CDOMObject (pcgen.cdom.base.CDOMObject)1 DomainSpellList (pcgen.cdom.list.DomainSpellList)1 ParseResult (pcgen.rules.persistence.token.ParseResult)1 SchoolToken (plugin.primitive.spell.SchoolToken)1 SubSchoolToken (plugin.primitive.spell.SubSchoolToken)1