public override MonsterStatBlock ApplyTemplate(MonsterStatBlock MonSB)
        {
            if (!MonSB.DontUseRacialHD)
            {
                TemplateCommon.ChangeHD(MonSB, StatBlockInfo.HitDiceCategories.d8);

                StatBlockInfo.HDBlockInfo tempHDInfo = new StatBlockInfo.HDBlockInfo();
                tempHDInfo.ParseHDBlock(MonSB.HD);
                //tempHDInfo.HDType = StatBlockInfo.HitDiceCategories.d8; //keeps HD, change to d8
                //tempHDInfo.Modifier = 0;
                //MonSB.HD = tempHDInfo.ToString();
                CreatureTypeFoundation CreatureType = CreatureTypeDetailsWrapper.GetRaceDetailClass("undead");
                int fort = StatBlockInfo.ParseSaveBonues(tempHDInfo.Multiplier, CreatureType.FortSaveType);
                CreatureTypeMaster CreatureTypeMaster = new CreatureTypeMaster();
                CreatureTypeMaster.CreatureTypeInstance = CreatureType;
                fort      += StatBlockInfo.GetAbilityModifier(MonSB.GetAbilityScoreValue(CreatureTypeMaster.CreatureTypeInstance.FortMod()));
                MonSB.Fort = fort.ToString();
                int refValue = StatBlockInfo.ParseSaveBonues(tempHDInfo.Multiplier, CreatureType.RefSaveType);
                refValue += StatBlockInfo.GetAbilityModifier(MonSB.GetAbilityScoreValue(StatBlockInfo.DEX));
                MonSB.Ref = refValue.ToString();
                int will = StatBlockInfo.ParseSaveBonues(tempHDInfo.Multiplier, CreatureType.WillSaveType);
                will      += StatBlockInfo.GetAbilityModifier(MonSB.GetAbilityScoreValue(StatBlockInfo.WIS));
                MonSB.Will = will.ToString();
            }


            MonSB.AC_Mods = StatBlockInfo.ChangeAC_Mod(MonSB.AC_Mods, "natural", 6, true);

            MonSB.Feats = StatBlockInfo.AddFeat(MonSB.Feats, "AlertnessB");
            MonSB.Feats = StatBlockInfo.AddFeat(MonSB.Feats, "Combat ReflexesB");
            MonSB.Feats = StatBlockInfo.AddFeat(MonSB.Feats, "DodgeB");
            MonSB.Feats = StatBlockInfo.AddFeat(MonSB.Feats, "Improved InitiativeB");
            MonSB.Feats = StatBlockInfo.AddFeat(MonSB.Feats, "Lightning ReflexesB");
            MonSB.Feats = StatBlockInfo.AddFeat(MonSB.Feats, "ToughnessB");

            MonSB.RacialMods = StatBlockInfo.AddRacialMod(MonSB.RacialMods, "+8 Bluff");
            MonSB.RacialMods = StatBlockInfo.AddRacialMod(MonSB.RacialMods, "+8 Perception");
            MonSB.RacialMods = StatBlockInfo.AddRacialMod(MonSB.RacialMods, "+8 Sense Motive");
            MonSB.RacialMods = StatBlockInfo.AddRacialMod(MonSB.RacialMods, "+8 Stealth");

            TemplateCommon.AddDR(MonSB, "magic and silver", 10);

            TemplateCommon.AddResistance(MonSB, "cold ", 10);
            TemplateCommon.AddResistance(MonSB, "electricity ", 10);

            return(MonSB);
        }
        public RaceBase(object RaceValue, CreatureTypeFoundation creatureType, bool isBestiaryStatBlock,
                        IndividualStatBlock_Combat IndivSB, string searchName, IMonsterStatBlockBusiness monsterStatBlockBusiness)
        {
            BaseRaceType = RaceType.None;
            if (RaceValue == null)
            {
                return;
            }
            _indvSB = IndivSB;

            CreatureTypeMaster = new CreatureTypeMaster();
            CreatureTypeMaster.CreatureTypeInstance = creatureType;
            try
            {
                RaceFoundationType = (RaceFoundation)RaceValue;
                BaseRaceType       = RaceType.Race;
                Race_SB            = monsterStatBlockBusiness.GetBestiaryMonsterByNamePathfinderDefault(RaceFoundationType.Name);
                if (Race_SB == null)
                {
                    if (!string.IsNullOrEmpty(searchName) && searchName != RaceFoundationType.Name)
                    {
                        Race_SB = monsterStatBlockBusiness.GetBestiaryMonsterByNamePathfinderDefault(searchName);
                        if (Race_SB == null)
                        {
                            throw new Exception(RaceFoundationType.Name + " has no Core Race entry");
                        }
                    }
                    else
                    {
                        throw new Exception(RaceFoundationType.Name + " has no Core Race entry");
                    }
                }
                //  IsHumanoid = true;
            }
            catch
            {
                try
                {
                    Race_SB = (MonsterStatBlock)RaceValue;
                    if (Race_SB.Environment.Length > 0 && isBestiaryStatBlock)
                    {
                        BaseRaceType = RaceType.BestiaryStatBlock;
                    }
                    else
                    {
                        BaseRaceType = RaceType.StatBlock;
                    }
                    if (Race_SB.Race.Contains("humanoid") || Race_SB.Type.Contains("humanoid"))
                    {
                        //   IsHumanoid = true;
                    }
                    UseRacialHD = Race_SB.DontUseRacialHD ? false : true;

                    int HD = RacialHDValue();
                    if (CreatureTypeMaster.GetSaveType("will") == StatBlockInfo.SaveBonusType.Varies)
                    {
                        int Will = Convert.ToInt32(Race_SB.Will);
                        if (HasFeat("Iron Will"))
                        {
                            Will -= 2;
                        }
                        WillOverride = StatBlockInfo.ComputeSaveBonusType(HD, Race_SB.GetAbilityScoreValue(StatBlockInfo.WIS), Will);
                    }
                    if (CreatureTypeMaster.GetSaveType("ref") == StatBlockInfo.SaveBonusType.Varies)
                    {
                        int Ref = Convert.ToInt32(Race_SB.Ref);
                        if (HasFeat("Lightning Reflexes"))
                        {
                            Ref -= 2;
                        }
                        Ref        -= GetRefOnGoingMods();
                        RefOverride = StatBlockInfo.ComputeSaveBonusType(HD, Race_SB.GetAbilityScoreValue(StatBlockInfo.DEX), Ref);
                    }
                    if (CreatureTypeMaster.GetSaveType("fort") == StatBlockInfo.SaveBonusType.Varies)
                    {
                        int Fort = Convert.ToInt32(Race_SB.Fort);
                        if (HasFeat("Great Fortitude"))
                        {
                            Fort -= 2;
                        }

                        FortOverride = StatBlockInfo.ComputeSaveBonusType(HD, Race_SB.GetAbilityScoreValue(StatBlockInfo.CON), Fort);
                    }
                    BaseBABType = StatBlockInfo.ComputeBABType(RacialHDValue(), Convert.ToInt32(Race_SB.BaseAtk));
                    ParseSkills();
                }
                catch
                {
                }
            }
        }