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;
}
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;
}
Aggregations