Exemple #1
0
        public void CheckRefValue()
        {
            try
            {
                string CheckName         = "Ref";
                int    OnGoingMods       = 0;
                string onGoingModFormula = string.Empty;
                OnGoingMods = GetRefOnGoingMods(ref onGoingModFormula);
                int    ClassMod    = CharacterClasses.GetRefSaveValue();
                int    RaceMod     = CharacterClasses.HasClass("animal companion") ? 0 : Race_Base.RaceRef();
                int    RefMod      = ClassMod + RaceMod + _abilityScores.DexMod + OnGoingMods;
                string calculation = ClassMod.ToString() + " + " + RaceMod.ToString() + " + " + _abilityScores.DexMod.ToString() + " + " + OnGoingMods.ToString();
                //string formula = "ClassMod + RaceMod + DexMod + OnGoingMods";
                string formula = "+" + ClassMod.ToString() + " ClassMod " + " +" + RaceMod.ToString() + " RaceMod "
                                 + " +" + _abilityScores.DexMod.ToString() + " DexMod ";

                if (OnGoingMods != 0)
                {
                    formula += " +" + OnGoingMods.ToString() + " OnGoingMods(" + onGoingModFormula + ")";
                }
                if (_monSBSearch.HasFeat("Lightning Reflexes"))
                {
                    RefMod  += 2;
                    formula += " +2 Lightning Reflexes";
                }
                if (_monSBSearch.HasTrait("Deft Dodger"))
                {
                    RefMod  += 1;
                    formula += " +1 Deft Dodger";
                }
                if (MonSB.SubType.IndexOf("nightshade") >= 0)
                {
                    RefMod  += 2;
                    formula += " +2 nightshade";
                }
                if (_monSBSearch.HasSQ("knowledge of avoidance"))
                {
                    RefMod  += 2;
                    formula += " +2 knowledge of avoidance";
                }

                if (Race_Base.Name() == "Svirfneblin")
                {
                    RefMod  += 2;
                    formula += " +2 Svirfneblin";
                }

                if (_monSBSearch.HasDomain("Protection"))
                {
                    int clericLevel = CharacterClasses.FindClassLevel("cleric");
                    if (clericLevel == 0)
                    {
                        clericLevel = CharacterClasses.FindClassLevel("druid");
                    }
                    int tempMod = (clericLevel / 5) + 1;
                    RefMod  += tempMod;
                    formula += " +" + tempMod.ToString() + " Protection domain";
                }

                if (CharacterClasses.HasClass("Paladin"))
                {
                    int level = CharacterClasses.FindClassLevel("paladin");
                    if (level >= 2) //Divine Grace
                    {
                        RefMod  += _abilityScores.ChaMod;
                        formula += " +" + _abilityScores.ChaMod.ToString() + "Divine Grace";
                    }
                }

                if (CharacterClasses.HasClass("prophet of kalistrade"))
                {
                    int level = CharacterClasses.FindClassLevel("prophet of kalistrade");
                    //Auspicious Display --assumes the bling is present
                    int mod = 1;
                    if (level >= 4)
                    {
                        mod++;
                    }
                    if (level >= 7)
                    {
                        mod++;
                    }
                    if (level >= 10)
                    {
                        mod++;
                    }
                    RefMod  += mod;
                    formula += " + " + mod.ToString() + " Auspicious Display";
                }

                if (CharacterClasses.HasClass("Antipaladin"))
                {
                    int level = CharacterClasses.FindClassLevel("Antipaladin");
                    if (level >= 2) //Unholy Resilience
                    {
                        RefMod  += _abilityScores.ChaMod;
                        formula += " +" + _abilityScores.ChaMod.ToString() + " + Unholy Resilience";
                    }
                }

                if (CharacterClasses.HasClass("Duelist"))
                {
                    int level = CharacterClasses.FindClassLevel("Duelist");
                    if (level >= 4) //grace
                    {
                        RefMod  += 2;
                        formula += " +2 Grace";
                    }
                }

                if (_monSBSearch.HasFamiliar())
                {
                    string familiar = _monSBSearch.FindFamiliarString(false);
                    if (familiar.Contains("weasel"))
                    {
                        RefMod  += 2;
                        formula += " +2 weasel";
                    }
                    if (familiar.Contains("fox"))
                    {
                        RefMod  += 2;
                        formula += " +2 fox";
                    }
                }


                if (_monSBSearch.HasTemplate("graveknight"))
                {
                    RefMod  += 2;
                    formula += " +2 Sacrilegious Aura";
                }

                if (_monSBSearch.HasGear("heartstone"))
                {
                    RefMod  += 2;
                    formula += " + 2 heartstone";
                }

                if (_monSBSearch.HasArchetype("Sharper"))//Lucky Save
                {
                    int rogueLevel = CharacterClasses.FindClassLevel("rogue");
                    int tempMod    = 0;
                    if (rogueLevel >= 3)
                    {
                        tempMod++;
                    }
                    if (rogueLevel >= 9)
                    {
                        tempMod++;
                    }
                    if (rogueLevel >= 15)
                    {
                        tempMod++;
                    }
                    if (tempMod > 0)
                    {
                        RefMod  += tempMod;
                        formula += " + " + tempMod.ToString() + " Lucky Save";
                    }
                }

                RefMod += GetMagicItemSaveMods(ref formula);

                int RefSB = Convert.ToInt32(Utility.GetNonParenValue(MonSB.Ref));

                if (RefMod == RefSB)
                {
                    _messageXML.AddPass(CheckName, formula);
                }
                else
                {
                    _messageXML.AddFail(CheckName, RefMod.ToString(), RefSB.ToString(), formula);
                }
            }
            catch (Exception ex)
            {
                _messageXML.AddFail("CheckRefValue", ex.Message);
            }
        }