private SpellList CkeckClassSpellDCs(bool isGnome, ref string formula, string name)
        {
            SpellList SL;

            {
                SL = _classSpells[name];
                List <SpellData> listOfSpells = SL.ListOfSpells;
                int abilityScoreValue         = _monsterSB.GetAbilityScoreValue(_characterClasses.GetSpellBonusAbility(name));
                OnGoingStatBlockModifier.StatBlockModifierSubTypes subType = Utility.GetOnGoingAbilitySubTypeFromString(_characterClasses.GetSpellBonusAbility(name));
                abilityScoreValue += _indvSB.GetOnGoingStatBlockModValue(OnGoingStatBlockModifier.StatBlockModifierTypes.Ability, subType);
                int abilityBonus = StatBlockInfo.GetAbilityModifier(abilityScoreValue);

                int bonus = 0;

                foreach (SpellData spellData in listOfSpells)
                {
                    try
                    {
                        string        temp = spellData.Name.Replace("†", string.Empty);
                        List <string> schoolList;

                        temp = Utility.RemoveSuperScripts(temp);

                        string search = Utility.SearchMod(temp);
                        if (search == "empty slot")
                        {
                            continue;
                        }
                        ISpellStatBlock spell = _spellStatBlockBusiness.GetSpellByName(search);
                        bonus = 0;

                        if (spell == null)
                        {
                            _messageXML.AddFail("Spell DC", "Missing spell: " + search);
                        }
                        else
                        {
                            if (_monSBSearch.HasSpellFocusFeat(out schoolList))
                            {
                                if (schoolList.Contains(spell.school))
                                {
                                    bonus++;
                                }
                                List <string> schoolList2;
                                if (_monSBSearch.HasGreaterSpellFocusFeat(out schoolList2))
                                {
                                    if (schoolList2.Contains(spell.school))
                                    {
                                        bonus++;
                                    }
                                }
                                if (SLA_SaveFail(spellData, spell))
                                {
                                    _messageXML.AddFail("SLA Save-" + spellData.Name, spell.saving_throw, spellData.DC.ToString());
                                }
                            }

                            if (_monSBSearch.HasElementalSkillFocusFeat(out schoolList))
                            {
                                if (schoolList.Contains(spell.school))
                                {
                                    bonus++;
                                }
                                List <string> schoolList2;
                                if (_monSBSearch.HasGreaterElementalSkillFocusFeat(out schoolList2))
                                {
                                    if (schoolList2.Contains(spell.school))
                                    {
                                        bonus++;
                                    }
                                }
                                if (SLA_SaveFail(spellData, spell))
                                {
                                    _messageXML.AddFail("SLA Save-" + spellData.Name, spell.saving_throw, spellData.DC.ToString());
                                }
                            }

                            if (spellData.DC > 0)
                            {
                                ComputeSpellDC(isGnome, ref formula, name, abilityBonus, ref bonus, spellData, spell);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        _messageXML.AddFail("CheckSpellDC--" + spellData.Name, ex.Message);
                    }
                }
            }

            return(SL);
        }
Exemple #2
0
        public void ParseConstantSpells()
        {
            string text = _sbCheckerBaseInput.MonsterSB.SpellLikeAbilities;
            string CR   = Environment.NewLine;

            _spellsData.ConstantSpells = new List <string>();

            if (!text.Contains("Constant"))
            {
                return;
            }

            int Pos  = text.IndexOf("Constant");
            int Pos3 = text.IndexOf(CR);

            if (Pos3 == -1)
            {
                Pos3 = text.Length;
            }
            ISpellStatBlock spell = null;
            bool            found = false;

            _sbCheckerBaseInput.IndvSB    = new IndividualStatBlock_Combat();
            _sbCheckerBaseInput.IndvSB.HD = _sbCheckerBaseInput.MonsterSB.HD;


            List <IndividualStatBlock_Combat> list = new List <IndividualStatBlock_Combat> {
                _sbCheckerBaseInput.IndvSB
            };
            int tempPos = Pos3 - Pos;

            if (tempPos < 0)
            {
                tempPos = text.Length - Pos;
            }

            string hold = text.Substring(Pos, tempPos);

            if (hold.Contains(CR))
            {
                Pos  = hold.IndexOf(CR);
                hold = hold.Substring(0, Pos).Trim();
            }
            hold = hold.Replace("Constant-", string.Empty).Trim();
            List <string> spells = hold.Split(',').ToList();

            foreach (string magic in spells)
            {
                string search = magic.Trim();
                if (search.Contains(PathfinderConstants.PAREN_LEFT))
                {
                    search = search.Substring(0, search.IndexOf(PathfinderConstants.PAREN_LEFT));
                }

                search = Utility.SearchMod(search);
                spell  = _spellStatBlockBusiness.GetSpellByName(search);
                if (spell != null)
                {
                    try
                    {
                        _sbCheckerBaseInput.IndvSB.CastSpell(spell.name, FindSpellCasterLevel(magic), list);
                        found = true;
                        _spellsData.ConstantSpells.Add(spell.name);
                    }
                    catch (Exception ex)
                    {
                        _sbCheckerBaseInput.MessageXML.AddFail("ParseConstantSpells", ex.Message);
                    }
                }

                if (!found)
                {
                    _sbCheckerBaseInput.MessageXML.AddInfo("Constant Spell: Issue with " + magic);
                }

                found = false;
            }

            if (_spellsData.ConstantSpells.Any())
            {
                string temp = string.Join(", ", _spellsData.ConstantSpells.ToArray());
                _sbCheckerBaseInput.MessageXML.AddInfo("Constant Spells In Effect: " + temp);
            }
        }
        public void ApplyBeforeCombatMagic()
        {
            if (!_spellsData.BeforeCombatMagic.Any())
            {
                return;
            }
            ISpellStatBlock    spell     = null;
            MagicItemStatBlock magicItem = null;

            _sbCheckerBaseInput.IndvSB.HD = _sbCheckerBaseInput.MonsterSB.HD;

            List <IndividualStatBlock_Combat> list = new List <IndividualStatBlock_Combat> {
                _sbCheckerBaseInput.IndvSB
            };
            Dictionary <string, int> Overrides = new Dictionary <string, int>();
            bool found = false;

            _spellsData.MagicInEffect = new List <string>();

            foreach (string magic in _spellsData.BeforeCombatMagic)
            {
                string search = magic;
                bool   Potion = false;
                bool   Oil    = false;
                Oil    = magic.Contains("oil");
                Potion = magic.Contains("potion");
                search = Utility.SearchMod(search);
                spell  = _spellStatBlockBusiness.GetSpellByName(search);
                if (spell != null && !Potion && !Oil)
                {
                    try
                    {
                        int CL = FindSpellCasterLevel(magic);
                        if (magic == "effortless armor")
                        {
                            int ACPmod = 1;
                            if (CL >= 5)
                            {
                                ACPmod++;
                            }
                            if (CL >= 10)
                            {
                                ACPmod++;
                            }
                            if (CL >= 15)
                            {
                                ACPmod++;
                            }
                            if (CL >= 20)
                            {
                                ACPmod++;
                            }
                            _armorClassData.TotalArmorCheckPenalty += ACPmod;
                            _sbCheckerBaseInput.MessageXML.AddInfo("effortless armor mod " + ACPmod.ToString());
                        }
                        _sbCheckerBaseInput.IndvSB.CastSpell(spell.name, CL, list);
                        found = true;
                        _spellsData.MagicInEffect.Add(spell.name + " CL: " + CL.ToString());
                    }
                    catch (Exception ex)
                    {
                        _sbCheckerBaseInput.MessageXML.AddFail("ApplyBeforeCombatMagic", "ApplyBeforeCombatMagic: Issue with " + magic + "-- " + ex.Message);
                    }
                }
                else
                {
                    magicItem = _magicItemStatBlockBusiness.GetMagicItemByName(magic);
                    if (magicItem != null)
                    {
                        found = true;
                    }
                    else
                    {
                        if (spell != null)
                        {
                            int CL = 0;
                            try
                            {
                                found = UseMagicalEquipment(ref spell, list, Overrides, magic, ref CL);
                            }
                            catch (Exception ex)
                            {
                                _sbCheckerBaseInput.MessageXML.AddInfo("Before Combat Magic: Issue with " + magic + " --" + ex.Message);
                            }
                            if (found)
                            {
                                _spellsData.MagicInEffect.Add(spell.name + " CL: " + CL.ToString());
                            }
                        }
                    }
                }

                if (!found)
                {
                    _sbCheckerBaseInput.MessageXML.AddInfo("Before Combat Magic: Issue with " + magic);
                }

                found = false;
            }


            if (_sbCheckerBaseInput.IndvSB.GetOnGoingStatBlockModsCount() > 0)
            {
                List <OnGoingStatBlockModifier> mods = _sbCheckerBaseInput.IndvSB.GetOnGoingStatBlockMods();

                if (Overrides.Any())
                {
                    foreach (KeyValuePair <string, int> kvp in Overrides)
                    {
                        for (int a = mods.Count - 1; a > 0; a--)
                        {
                            if (mods[a].Name.ToLower().Contains(kvp.Key.ToString()))
                            {
                                mods[a].Modifier = kvp.Value;
                            }
                        }
                    }
                }

                foreach (OnGoingStatBlockModifier mod in mods)
                {
                    //if (mod.ModType == OnGoingStatBlockModifier.StatBlockModifierTypes.AC)
                    //{
                    //    ACMods_Computed.AddModEffect(mod);
                    //}
                    if (mod.ModType == OnGoingStatBlockModifier.StatBlockModifierTypes.Attack)
                    {
                        _onGoingAttackMod += mod.Modifier;
                    }
                }
            }

            List <OnGoingStatBlockModifier> onGoingMods = _sbCheckerBaseInput.IndvSB.GetOnGoingStatBlockMods();

            //remove all ability mods since they have been already incorperated into the SB and we don't want to add them twice
            for (int a = onGoingMods.Count - 1; a >= 0; a--)
            {
                if (onGoingMods[a].ModType == OnGoingStatBlockModifier.StatBlockModifierTypes.Ability)
                {
                    onGoingMods.RemoveAt(a);
                }
            }

            if (_spellsData.MagicInEffect.Any())
            {
                string temp = string.Join(", ", _spellsData.MagicInEffect.ToArray());
                _sbCheckerBaseInput.MessageXML.AddInfo("Magic In Effect: " + temp);
            }
        }