private void ComputeSpellDC(bool IsGnome, ref string formula, string name, int AbilityBonus, ref int Bonus, SpellData SD, ISpellStatBlock Spell) { int Bloodline = 0; int gnomeBonus = 0; int spellClassLevel = Spell.GetSpellLevelByClass(name, _monSBSearch.HasCurse("haunted"), _monSBSearch.HasFeat("Shade of the Uskwood"), _monSBSearch.HasArchetype("Razmiran priest")); if (SD.Domain) { spellClassLevel = SD.Level; } // if (spellClassLevel < 0 && SD.Domain) spellClassLevel = SD.Level; if (spellClassLevel < 0 && _monSBSearch.HasBloodline()) { Dictionary <string, int> bloodlineBonusSpells = CharacterClasses.GetBloodlineBonusSpells(); if (bloodlineBonusSpells.ContainsKey(Spell.name.ToLower())) { spellClassLevel = SD.Level; } } if (spellClassLevel < 0 && _monSBSearch.HasMystery()) { Dictionary <string, int> mysteryBonusSpells = CharacterClasses.GetMysteryBonusSpells(); if (mysteryBonusSpells.ContainsKey(Spell.name.ToLower())) { spellClassLevel = SD.Level; } } if (spellClassLevel < 0 && _monSBSearch.HasPatron()) { List <string> patronBonusSpells = CharacterClasses.GetPatronBonusSpells(); if (patronBonusSpells.Contains(Spell.name.ToLower())) { spellClassLevel = SD.Level; } } if (IsGnome && Spell.school.Contains("illusion")) { gnomeBonus = 1; } if (_monSBSearch.HasBloodline("arcane")) { int sorcererLevel = CharacterClasses.FindClassLevel("sorcerer"); if (sorcererLevel >= 15) { string schoolPower = _monSBSearch.GetSQ("school power"); schoolPower = schoolPower.Replace("spells)", string.Empty).Trim(); int Pos = schoolPower.LastIndexOf(" "); schoolPower = schoolPower.Substring(Pos).Trim(); if (Spell.school.Contains(schoolPower)) { Bloodline += 2; } } } if (_monSBSearch.HasBloodline("fey")) { if (Spell.subschool.Contains("compulsion")) { Bloodline += 2; } } if (_monSBSearch.HasBloodline("stormborn")) { if (Spell.descriptor.Contains("electricity") || Spell.descriptor.Contains("sonic")) { Bloodline += 1; } } if (_monSBSearch.HasBloodline("infernal")) { if (Spell.subschool.Contains("charm")) { Bloodline += 2; } } if (_monSBSearch.HasClassArchetype("winter witch")) { if (Spell.descriptor.Contains("cold")) { Bonus += 1; } } if (_monSBSearch.Race() == "kitsune" && Spell.school.Contains("enchantment")) { Bonus += 1; } if (_monSBSearch.HasSubType("sahkil") && (Spell.school.Contains("emotion") || Spell.school.Contains("fear"))) { Bonus += 2; } List <string> School; if (_monSBSearch.HasElementalSkillFocusFeat(out School)) { if (School.Contains(Spell.descriptor)) { Bonus++; } List <string> School2; if (_monSBSearch.HasGreaterElementalSkillFocusFeat(out School2)) { if (School2.Contains(Spell.descriptor)) { Bonus++; } } } int computedDC = 10 + spellClassLevel + AbilityBonus + Bonus + Bloodline + gnomeBonus; formula = "10 +" + spellClassLevel.ToString() + " spell class level +" + AbilityBonus.ToString() + " ability bonus"; if (Bloodline != 0) { formula += " +" + Bloodline.ToString() + " bloodline"; } if (gnomeBonus != 0) { formula += " +" + gnomeBonus.ToString() + " gnome magic"; } if (Bonus != 0) { formula += " +" + Bonus.ToString() + " skill/spell focus bonus"; } if (computedDC == SD.DC) { _messageXML.AddPass("Spell DC-" + SD.Name); } else { _messageXML.AddFail("Spell DC-" + SD.Name, computedDC.ToString(), SD.DC.ToString(), formula); } }
public void CheckSpellDC(bool IsGnome) { List <string> Names = CharacterClasses.GetClassNames(); SpellList SL = null; string formula = string.Empty; foreach (string name in Names) { formula = string.Empty; if (CharacterClasses.CanClassCastSpells(name.ToLower())) { if (ClassSpells.ContainsKey(name)) { SL = ClassSpells[name]; List <SpellData> ListOfSpells = SL.ListOfSpells; int AbilityScore = MonSB.GetAbilityScoreValue(CharacterClasses.GetSpellBonusAbility(name)); OnGoingStatBlockModifier.StatBlockModifierSubTypes subType = Utility.GetOnGoingAbilitySubTypeFromString(CharacterClasses.GetSpellBonusAbility(name)); AbilityScore += _indvSB.GetOnGoingStatBlockModValue(OnGoingStatBlockModifier.StatBlockModifierTypes.Ability, subType); int AbilityBonus = StatBlockInfo.GetAbilityModifier(AbilityScore); int Bonus = 0; foreach (SpellData SD in ListOfSpells) { try { string Temp = SD.Name; Temp = Temp.Replace("†", string.Empty); List <string> School; Temp = Utility.RemoveSuperScripts(Temp); string search = Utility.SearchMod(Temp); if (search == "empty slot") { continue; } ISpellStatBlock Spell = SpellStatBlock.GetSpellByName(search); Bonus = 0; if (Spell == null) { _messageXML.AddFail("Spell DC", "Missing spell: " + search); } else { if (_monSBSearch.HasSpellFocusFeat(out School)) { if (School.Contains(Spell.school)) { Bonus++; } List <string> School2; if (_monSBSearch.HasGreaterSpellFocusFeat(out School2)) { if (School2.Contains(Spell.school)) { Bonus++; } } if (SLA_SaveFail(SD, Spell)) { _messageXML.AddFail("SLA Save-" + SD.Name, Spell.saving_throw, SD.DC.ToString()); } } if (_monSBSearch.HasElementalSkillFocusFeat(out School)) { if (School.Contains(Spell.school)) { Bonus++; } List <string> School2; if (_monSBSearch.HasGreaterElementalSkillFocusFeat(out School2)) { if (School2.Contains(Spell.school)) { Bonus++; } } if (SLA_SaveFail(SD, Spell)) { _messageXML.AddFail("SLA Save-" + SD.Name, Spell.saving_throw, SD.DC.ToString()); } } if (SD.DC > 0) { ComputeSpellDC(IsGnome, ref formula, name, AbilityBonus, ref Bonus, SD, Spell); } } } catch (Exception ex) { _messageXML.AddFail("CheckSpellDC--" + SD.Name, ex.Message); } } } } } if (!Names.Any() && MonSB.SpellsPrepared.Length > 0) { string temp = MonSB.SpellsPrepared; temp = temp.Substring(0, temp.IndexOf(" ")); if (ClassSpells.ContainsKey(temp)) { SL = ClassSpells[temp]; List <SpellData> ListOfSpells = SL.ListOfSpells; int AbilityBonus = StatBlockInfo.GetAbilityModifier(MonSB.GetAbilityScoreValue(CharacterClasses.GetSpellBonusAbility(temp))); foreach (SpellData SD in ListOfSpells) { if (SD.DC > 0) { int computedDC = 10 + SD.Level + AbilityBonus; formula = "10 +" + SD.Level.ToString() + " spell level +" + AbilityBonus.ToString() + " ability bonus"; if (computedDC == SD.DC) { _messageXML.AddPass("Spell DC-" + SD.Name); } else { _messageXML.AddFail("Spell DC-" + SD.Name, computedDC.ToString(), SD.DC.ToString(), formula); } } } } } if (!Names.Any() && MonSB.SpellsKnown.Length > 0) { string temp = MonSB.SpellsKnown; temp = temp.Substring(0, temp.IndexOf(" ")); if (ClassSpells.ContainsKey(temp)) { SL = ClassSpells[temp]; List <SpellData> ListOfSpells = SL.ListOfSpells; if (temp == "Spells") { temp = "Sorcerer"; } int AbilityBonus = StatBlockInfo.GetAbilityModifier(MonSB.GetAbilityScoreValue(CharacterClasses.GetSpellBonusAbility(temp))); foreach (SpellData SD in ListOfSpells) { if (SD.DC > 0) { int computedDC = 10 + SD.Level + AbilityBonus; formula = "10 +" + SD.Level.ToString() + " spell level +" + AbilityBonus.ToString() + " ability bonus"; if (computedDC == SD.DC) { _messageXML.AddPass("Spell DC-" + SD.Name); } else { _messageXML.AddFail("Spell DC-" + SD.Name, computedDC.ToString(), SD.DC.ToString(), formula); } } } } } }