public TemplatesAppliedParser(ISBCommonBaseInput sbcommonBaseInput, IMonsterStatBlockBusiness monsterStatBlockBusiness, IIndividualStatBlockBusiness individualStatBlockBusiness) { _sbcommonBaseInput = sbcommonBaseInput; _monsterStatBlockBusiness = monsterStatBlockBusiness; _individualStatBlockBusiness = individualStatBlockBusiness; }
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 { } } }
public new IndividualStatBlock Parse(string Indvidstr, string Source, bool isFrogGods, ref string ErrorMessage) { _sbcommonBaseInput = new SBCommonBaseInput(); _monsterStatBlockBusiness = new MonsterStatBlockBusiness(); _individualStatBlockBusiness = new IndividualStatBlockBusiness(); base.MonSB = new MonsterStatBlock(); _sbcommonBaseInput.MonsterSB = new MonsterStatBlock(); _sbcommonBaseInput.IndvidSB = IndvidSB; SourceSuperScript = string.Empty; Indvidstr = Utility.CommonMonsterFindReplace(Indvidstr, CR); Utility.RemoveSuperScriptsFromList(ItalicPhrases); if (Indvidstr.Contains("Spell-Like Abilities") && Indvidstr.Contains("Spells Prepared")) { if (Indvidstr.IndexOf("Spell-Like Abilities") > Indvidstr.IndexOf("Spells Prepared")) { ErrorMessage = "Spell-Like Abilities before Spells Prepared"; return(IndvidSB); } } base.MonSB = IndvidSB; CR = Utility.FindCR(Indvidstr); int CRPos = Indvidstr.IndexOf(CR); base.UpdateCR(CR); Indvidstr = Utility.CommonMonsterFindReplace(Indvidstr, CR); int DefensePos = Indvidstr.IndexOf("Defense" + CR); if (DefensePos == -1) { Indvidstr = Indvidstr.Replace("Defenses" + CR, "Defense" + CR); DefensePos = Indvidstr.IndexOf("Defense" + CR); } if (DefensePos == -1 && isFrogGods) { int tempCRPos = Indvidstr.IndexOf("CR "); if (tempCRPos == -1) { ErrorMessage = "No CR"; return(IndvidSB); } DefensePos = Indvidstr.IndexOf("AC ", tempCRPos); } if (DefensePos == -1) { ErrorMessage = "Issue with Defense Header"; return(IndvidSB); } string temp = Indvidstr.Substring(0, DefensePos); Indvidstr = Indvidstr.Replace(temp, string.Empty).Trim(); temp = ParseAgeVariantUnique(temp); temp = ParseAgeCategory(temp); //find Race line, if it exists CRPos = temp.IndexOf(CR); //name & CR string nameTemp = temp.Substring(0, CRPos); CRPos = temp.IndexOf(CR, CRPos + 1); //XP line string raceLine = temp.Substring(CRPos, temp.IndexOf(CR, CRPos + 1) - CRPos); CRPos = raceLine.IndexOf(PathfinderConstants.PAREN_LEFT); if (CRPos > 0) { raceLine = raceLine.Substring(0, CRPos); } string raceLineHold; //only non-racial races can have only Prestige classes (i.e. no bases classes), how to test? if (!CommonMethods.FindNumber(raceLine) || HasClass(raceLine) || HasPresteigeClass(raceLine)) { raceLineHold = raceLine; } else { raceLineHold = nameTemp; raceLine = nameTemp; } ParseTemplatesApplied(ref temp, ref raceLine, raceLineHold); if (isFrogGods) { if (temp.Contains("; Perception")) { temp = temp.Replace("; Perception", "; Senses Perception"); } } ParseBasic(temp, ref ErrorMessage); if (ErrorMessage.Length > 0) { return(IndvidSB); } #region SimpleClassTemplate if (IndvidSB.Class.Length == 0) { List <string> simpleClassTemplateList = CommonMethods.GetSimpleClassTemplates(); bool foundSimpleClassTemplate = false; string SimpleClassTemplate = string.Empty; var raceLineLower = raceLine.ToLower(); foreach (string template in simpleClassTemplateList) { var templateLower = template.ToLower(); if (raceLineLower.Contains(templateLower)) { if (templateLower == "bard" && raceLineLower.Contains("bombardier")) { continue; } if (templateLower == "ranger" && raceLineLower.Contains("stranger")) { continue; } foundSimpleClassTemplate = true; SimpleClassTemplate = template; break; } } if (foundSimpleClassTemplate) { IndvidSB.TemplatesApplied += SimpleClassTemplate.ToLower() + "|"; string racelineHold = raceLine; raceLine = raceLine.ToLower().Replace(SimpleClassTemplate.ToLower(), string.Empty); temp = temp.Replace(racelineHold, raceLine); } } #endregion SimpleClassTemplate #region ParseDefense Indvidstr = Indvidstr.Replace("Ofense", "Offense"); DefensePos = Indvidstr.IndexOf("Defense" + CR); if (DefensePos == -1 && isFrogGods) { DefensePos = Indvidstr.IndexOf("AC "); } int OffensePos = Indvidstr.IndexOf("Offense" + CR); if (OffensePos == -1 && isFrogGods) { OffensePos = Indvidstr.IndexOf("Speed "); if (OffensePos == -1) { OffensePos = Indvidstr.IndexOf("Spd "); } if (OffensePos == -1) { ErrorMessage = "Missing Speed value, should be before Melee block"; return(IndvidSB); } } try { temp = Indvidstr.Substring(DefensePos, OffensePos - DefensePos); } catch (Exception ex) { ErrorMessage = "Issue with Finding Offense or Defense Headers --" + ex.Message; return(IndvidSB); } Indvidstr = Indvidstr.Replace(temp, string.Empty).Trim(); try { if (isFrogGods) { if (temp.Contains("; Ref")) { temp = temp.Replace("; Ref", ", Ref"); } if (temp.Contains("; Will")) { temp = temp.Replace("; Will", ", Will"); } } ParseDefense(temp); } catch (Exception ex) { ErrorMessage = "ParseDefense: " + ex.Message; return(IndvidSB); } #endregion ParseDefense #region ParseOffense int TacticsPos = Indvidstr.IndexOf("Tactics" + CR); if (TacticsPos == -1) //no tactics section { TacticsPos = Indvidstr.IndexOf("Statistics" + CR); if (TacticsPos == -1 && isFrogGods) { TacticsPos = Indvidstr.IndexOf("Str "); if (TacticsPos == -1) { ErrorMessage = " Missing Str Heading"; return(IndvidSB); } } else if (TacticsPos == -1) { ErrorMessage = " Missing Statistics Heading"; return(IndvidSB); } } OffensePos = Indvidstr.IndexOf("Offense" + CR); if (OffensePos == -1 && isFrogGods) { OffensePos = Indvidstr.IndexOf("Speed "); if (OffensePos == -1) { OffensePos = Indvidstr.IndexOf("Spd "); } } temp = Indvidstr.Substring(OffensePos, TacticsPos - OffensePos); Indvidstr = Indvidstr.Replace(temp, string.Empty).Trim(); ParseIndividualOffense(ref temp); if (isFrogGods) { if (temp.Contains(", Reach")) { temp = temp.Replace(", Reach", "; Reach"); } } ParseOffense(temp); #endregion ParseOffense #region ParseStatistics int BaseStatisticsPos = Indvidstr.IndexOf("Base Statistics"); int BaseStatisticsOffset = 14; if (BaseStatisticsPos == -1) { BaseStatisticsPos = 0; BaseStatisticsOffset = 0; } int StatisticsPos = Indvidstr.IndexOf("Statistics" + CR, BaseStatisticsPos + BaseStatisticsOffset); if (StatisticsPos == -1 && isFrogGods) { StatisticsPos = Indvidstr.IndexOf("Str "); } if (StatisticsPos == -1) { ErrorMessage = Indvidstr.Contains(string.Empty) ? "Tactics Before Statistics Header" : "Issue with Statistics Header"; return(IndvidSB); } TacticsPos = Indvidstr.IndexOf("Tactics" + CR); if (TacticsPos >= 0) { temp = Indvidstr.Substring(TacticsPos, StatisticsPos - TacticsPos); Indvidstr = Indvidstr.Replace(temp, string.Empty).Trim(); ParseTactics(temp); } int SpecialAbilitiesPos = Indvidstr.IndexOf("Special Abilities" + CR); if (SpecialAbilitiesPos == -1) { SpecialAbilitiesPos = Indvidstr.Length; } StatisticsPos = Indvidstr.IndexOf("Statistics" + CR); if (StatisticsPos == -1 && isFrogGods) { StatisticsPos = Indvidstr.IndexOf("Str "); } temp = Indvidstr.Substring(StatisticsPos, SpecialAbilitiesPos - StatisticsPos); Indvidstr = Indvidstr.Replace(temp, string.Empty).Trim(); ParseIndividualStatistics(ref temp); ParseStatistics(temp, out ErrorMessage); if (ErrorMessage.Length > 0) { return(IndvidSB); } #endregion ParseStatistics SpecialAbilitiesPos = Indvidstr.IndexOf("Special Abilities" + CR); if (SpecialAbilitiesPos >= 0) { ParseSpecialAbilities(Indvidstr); } if (MonSB.Race.Length == 0 && MonSB.Environment.Length == 0) { MonSB.Race = MonSB.name; int Pos = MonSB.Race.IndexOf("Subtier"); if (Pos > 0) { MonSB.Race = MonSB.Race.Substring(0, Pos); } if (MonSB.Race.Contains("Animal Companion")) { MonSB.Race = MonSB.Race.Replace("Animal Companion", string.Empty).Trim(); } if (MonSB.Race.Contains("animal companion")) { MonSB.Race = MonSB.Race.Replace("animal companion", string.Empty).Trim(); } if (MonSB.TemplatesApplied.Length > 0) { string templates = MonSB.TemplatesApplied.Replace("|", PathfinderConstants.SPACE).Trim().ProperCase(); MonSB.name = templates + PathfinderConstants.SPACE + MonSB.name; } else { raceLine = MonSB.name; raceLineHold = MonSB.name; ParseTemplatesApplied(ref temp, ref raceLine, raceLineHold); if (MonSB.TemplatesApplied.Length > 0) { List <string> templates = MonSB.TemplatesApplied.Split('|').ToList(); templates.RemoveAll(x => x == string.Empty); foreach (var template in templates) { MonSB.Race = MonSB.Race.Replace(template, string.Empty); MonSB.Race = MonSB.Race.Replace(template.ProperCase(), string.Empty); } MonSB.Race = MonSB.Race.Trim(); } } } #region CreateFullText IndividualStatBlock_Format IndivSB_Form = new IndividualStatBlock_Format(); IndivSB_Form.ItalicPhrases = ItalicPhrases; IndivSB_Form.BoldPhrases = BoldPhrases; IndivSB_Form.BoldPhrasesSpecialAbilities = BoldPhrasesSpecialAbilities; IndivSB_Form.SourceSuperScript = SourceSuperScript; try { IndvidSB.FullText = IndivSB_Form.CreateFullText(IndvidSB); } catch (Exception ex) { ErrorMessage = "CreateFullText: " + ex.Message; } #endregion CreateFullText return(IndvidSB); }
public RaceBase(object RaceValue, CreatureTypeFoundation CreatureType, string searchName, IMonsterStatBlockBusiness monsterStatBlockBusiness) : this(RaceValue, CreatureType, false, null, searchName, monsterStatBlockBusiness) { }
public RaceParser(ISBCheckerBaseInput sbCheckerBaseInput, IMonsterStatBlockBusiness monsterStatBlockBusiness) { _sbCheckerBaseInput = sbCheckerBaseInput; _creatureType = _sbCheckerBaseInput.CreatureType; _monsterStatBlockBusiness = monsterStatBlockBusiness; }