private static void FillAssociationTablePower(PgSkill skill) { Dictionary <string, ParsingContext> PowerContextTable = ParsingContext.ObjectKeyTable[typeof(PgPower)]; foreach (KeyValuePair <string, ParsingContext> Entry in PowerContextTable) { string PowerKey = Entry.Key; PgPower Power = (PgPower)Entry.Value.Item; if (Power.Skill_Key != skill.Key) { continue; } if (Power.IsUnavailable) { continue; } foreach (ItemSlot Slot in Power.SlotList) { if (!skill.AssociationTablePower.ContainsKey(Slot)) { skill.AssociationTablePower.Add(Slot, new List <string>()); } List <string> PowerListBySlot = skill.AssociationTablePower[Slot]; PowerListBySlot.Add(PowerKey); } } }
private bool FinishItem(PgItemSkillLink item, Dictionary <string, object> contentTable, Dictionary <string, Json.Token> contentTypeTable, List <object> itemCollection, Json.Token lastItemType, string parsedFile, string parsedKey) { if (contentTable.Count == 0) { return(Program.ReportFailure(parsedFile, parsedKey, $"At least one skill expected in a skill link")); } foreach (KeyValuePair <string, object> Entry in contentTable) { string Key = Entry.Key; object Value = Entry.Value; PgSkill ParsedSkill = null !; if (!ParserSkill.Parse((PgSkill valueSkill) => ParsedSkill = valueSkill, Key, parsedFile, parsedKey)) { return(false); } int ParsedLevel = -1; if (!SetIntProperty((int valueInt) => ParsedLevel = valueInt, Value)) { return(false); } if (item.SkillTable.ContainsKey(ParsedSkill.Key)) { return(Program.ReportFailure(parsedFile, parsedKey, $"Skill {Key} already parsed in skill link")); } item.SkillTable.Add(ParsedSkill.Key, ParsedLevel); } return(true); }
public static int SkillToIcon(PgSkill skill) { int IconId = 0; UpdateIconIdFromAbilities(skill, ref IconId); UpdateIconIdFromRecipes(skill, ref IconId); UpdateIconIdFromItems(skill, ref IconId); if (IconId == 0) { if (skill.Key == "AlcoholTolerance") { IconId = 3677; } else if (skill.Key.StartsWith("Anatomy")) { IconId = 4004; } else { foreach (PgSkillAdvancement Item in skill.SkillAdvancementList) { if (Item is PgSkillAdvancementRewardAdvancement) { IconId = PgObject.SkillIconId; } } IconId = PgObject.AbilityIconId; } } return(IconId); }
private bool ParseAdvancementHints(PgSkill item, object value, string parsedFile, string parsedKey) { PgAdvancementHintCollection AdvancementHintList = new PgAdvancementHintCollection(); if (!Inserter <PgAdvancementHint> .AddKeylessArray(AdvancementHintList, value)) { return(false); } foreach (PgAdvancementHint AdvancementHint in AdvancementHintList) { foreach (KeyValuePair <int, string> Entry in AdvancementHint.HintTable) { int Level = Entry.Key; string Hint = Entry.Value; if (!ParseHints(Hint, parsedFile, parsedKey, out PgNpcLocationCollection NpcList)) { return(false); } PgSkillAdvancement NewSkillAdvancement = new PgSkillAdvancementHint() { RawLevel = Level, Hint = Hint, NpcList = NpcList }; ParsingContext.AddSuplementaryObject(NewSkillAdvancement); item.SkillAdvancementList.Add(NewSkillAdvancement); } } return(true); }
private bool ParseInteractionFlagLevelCaps(PgSkill item, object value, string parsedFile, string parsedKey) { PgLevelCapInteractionList ParsedLevelCapInteractionList = null !; if (!Inserter <PgLevelCapInteractionList> .SetItemProperty((PgLevelCapInteractionList valueLevelCapInteractionList) => ParsedLevelCapInteractionList = valueLevelCapInteractionList, value)) { return(false); } foreach (PgLevelCapInteraction Item in ParsedLevelCapInteractionList.List) { int Level = Item.Level; string?SkillKey = Item.Skill_Key; PgSkillAdvancement NewSkillAdvancement = new PgSkillAdvancementLevelCapInteraction() { RawLevel = Level, Skill_Key = SkillKey }; ParsingContext.AddSuplementaryObject(NewSkillAdvancement); item.SkillAdvancementList.Add(NewSkillAdvancement); } return(true); }
private bool FinishItem(PgQuestRewardCollection item, Dictionary <string, object> contentTable, Dictionary <string, Json.Token> contentTypeTable, List <object> itemCollection, Json.Token lastItemType, string parsedFile, string parsedKey) { foreach (KeyValuePair <string, object> Entry in contentTable) { string SkillKey = Entry.Key; object Value = Entry.Value; PgSkill ParsedSkill = null !; if (!Inserter <PgSkill> .SetItemByKey((PgSkill valueSkill) => ParsedSkill = valueSkill, SkillKey)) { return(false); } if (!(Value is int XpValue)) { return(Program.ReportFailure($"Value '{Value}' was expected to be an int")); } PgQuestRewardSkillXp NewReward = new PgQuestRewardSkillXp() { Skill_Key = ParsedSkill.Key, RawXp = XpValue }; item.Add(NewReward); } return(true); }
private bool ParseCompatibleCombatSkills(PgSkill item, object value, string parsedFile, string parsedKey) { if (!Inserter <PgSkill> .AddPgObjectArrayByKey <PgSkill>(item.CompatibleCombatSkillList, value)) { return(false); } item.CompatibleCombatSkillList.Sort(); return(true); }
public static void UpdateIconsAndNames() { Dictionary <string, ParsingContext> SkillParsingTable = ParsingContext.ObjectKeyTable[typeof(PgSkill)]; foreach (KeyValuePair <string, ParsingContext> Entry in SkillParsingTable) { PgSkill Skill = (PgSkill)Entry.Value.Item; Skill.IconId = SkillToIcon(Skill); Debug.Assert(Skill.ObjectIconId != 0); Debug.Assert(Skill.ObjectName.Length > 0); } }
private bool ParseAdvancementTable(PgSkill item, object value, string parsedFile, string parsedKey) { if (value == null) { return(true); } if (!(value is string TableString)) { return(Program.ReportFailure($"Value '{value}' was expected to be a string")); } Dictionary <string, ParsingContext> Table = ParsingContext.ObjectKeyTable[typeof(PgAdvancementTable)]; foreach (KeyValuePair <string, ParsingContext> Entry in Table) { ParsingContext Context = Entry.Value; if (!(Context.Item is PgAdvancementTable AsAdvancementTable)) { return(Program.ReportFailure($"Object '{Context.Item}' was unexpected")); } if (AsAdvancementTable.InternalName == TableString) { foreach (KeyValuePair <int, PgAdvancement> AdvancementEntry in AsAdvancementTable.LevelTable) { int Level = AdvancementEntry.Key; PgAdvancement Advancement = AdvancementEntry.Value; foreach (PgAdvancementEffectAttribute EffectAttribute in Advancement.EffectAttributeList) { PgSkillAdvancement NewSkillAdvancement = new PgSkillAdvancementRewardAdvancement() { RawLevel = Level, EffectAttribute = EffectAttribute }; ParsingContext.AddSuplementaryObject(NewSkillAdvancement); item.SkillAdvancementList.Add(NewSkillAdvancement); } } return(true); } } return(Program.ReportFailure($"Advancement table '{TableString}' not found")); }
private bool ParseReports(PgSkill item, object value, string parsedFile, string parsedKey) { PgReportList ParsedPeportList = null !; if (!Inserter <PgReportList> .SetItemProperty((PgReportList valueReportList) => ParsedPeportList = valueReportList, value)) { return(false); } foreach (PgReport Report in ParsedPeportList.List) { item.ReportList.Add(Report); } return(true); }
public static void UpdateIconIdFromRecipes(PgSkill skill, ref int iconId) { Dictionary <string, ParsingContext> RecipeParsingTable = ParsingContext.ObjectKeyTable[typeof(PgRecipe)]; foreach (KeyValuePair <string, ParsingContext> Entry in RecipeParsingTable) { if (iconId != 0) { break; } PgRecipe Recipe = (PgRecipe)Entry.Value.Item; if (Recipe.Skill_Key == skill.Key && Recipe.IconId != 0) { iconId = Recipe.IconId; } } }
private static void FillAssociationTableAbility(PgSkill skill) { Dictionary <string, ParsingContext> AbilityContextTable = ParsingContext.ObjectKeyTable[typeof(PgAbility)]; foreach (KeyValuePair <string, ParsingContext> Entry in AbilityContextTable) { string AbilityKey = Entry.Key; PgAbility Ability = (PgAbility)Entry.Value.Item; string Skill_Key = Ability.Skill_Key ?? throw new NullReferenceException(); PgSkill AbilitySkill = (PgSkill)(Skill_Key.Length == 0 ? PgSkill.Unknown : (Skill_Key == "AnySkill" ? PgSkill.AnySkill : ParsingContext.ObjectKeyTable[typeof(PgSkill)][Skill_Key].Item)); if (AbilitySkill != skill) { continue; } if (Ability.KeywordList.Contains(AbilityKeyword.Lint_NotLearnable) && Ability.Name != "Sword Slash") { continue; } skill.AssociationListAbility.Add(AbilityKey); } }
public static void UpdateIconIdFromAbilities(PgSkill skill, ref int iconId) { int LowestLevel = int.MaxValue; int LowestLevelIconId = 0; Dictionary <string, ParsingContext> AbilityParsingTable = ParsingContext.ObjectKeyTable[typeof(PgAbility)]; foreach (KeyValuePair <string, ParsingContext> Entry in AbilityParsingTable) { if (iconId != 0) { break; } PgAbility Ability = (PgAbility)Entry.Value.Item; string Skill_Key = Ability.Skill_Key ?? throw new NullReferenceException(); PgSkill AbilitySkill = (PgSkill)(Skill_Key.Length == 0 ? PgSkill.Unknown : (Skill_Key == "AnySkill" ? PgSkill.AnySkill : ParsingContext.ObjectKeyTable[typeof(PgSkill)][Skill_Key].Item)); if (AbilitySkill == skill && Ability.IconId != 0) { if (Ability.KeywordList.Contains(AbilityKeyword.BasicAttack)) { iconId = Ability.IconId; } else if (LowestLevel > Ability.Level) { LowestLevel = Ability.Level; LowestLevelIconId = Ability.IconId; } } } if (iconId == 0 && LowestLevelIconId != 0) { iconId = LowestLevelIconId; } }
public static void UpdateIconIdFromItems(PgSkill skill, ref int iconId) { int LowestLevel = int.MaxValue; int LowestLevelIconId = 0; Dictionary <string, ParsingContext> ItemParsingTable = ParsingContext.ObjectKeyTable[typeof(PgItem)]; foreach (KeyValuePair <string, ParsingContext> Entry in ItemParsingTable) { if (iconId != 0) { break; } PgItem Item = (PgItem)Entry.Value.Item; if (Item.IconId != 0) { foreach (KeyValuePair <string, int> SkillEntry in Item.SkillRequirementTable) { if ((SkillEntry.Key.Length == 0 && skill == PgSkill.Unknown) || (SkillEntry.Key == "AnySkill" && skill == PgSkill.AnySkill) || (SkillEntry.Key == skill.Key)) { if (LowestLevel > SkillEntry.Value) { LowestLevel = SkillEntry.Value; LowestLevelIconId = Item.IconId; } } } } } if (iconId == 0 && LowestLevelIconId != 0) { iconId = LowestLevelIconId; } }
private bool ParseInteraction(PgLevelCapInteractionList item, string interaction, int level, string parsedFile, string parsedKey) { if (interaction.Length > 0 && char.IsDigit(interaction[interaction.Length - 1])) { int FirstDigitIndex = interaction.Length - 1; while (FirstDigitIndex > 0 && char.IsDigit(interaction[FirstDigitIndex - 1])) { FirstDigitIndex--; } if (FirstDigitIndex > 0 && interaction[FirstDigitIndex - 1] != '_' && interaction[FirstDigitIndex - 1] != ' ') { interaction = interaction.Substring(0, FirstDigitIndex) + "_" + interaction.Substring(FirstDigitIndex); } } string[] Split = interaction.Split('_'); if (Split.Length < 3 || Split[0] != "LevelCap") { return(Program.ReportFailure($"Invalid level cap interaction '{interaction}'")); } string MergedSkill = string.Empty; int i; for (i = 1; i + 1 < Split.Length; i++) { if (MergedSkill.Length > 0) { MergedSkill += "_"; } MergedSkill += Split[i]; } if (MergedSkill == "Dance") { MergedSkill = "Performance_Dance"; } PgSkill ParsedSkill = null !; if (!ParserSkill.Parse((PgSkill valueSkill) => ParsedSkill = valueSkill, MergedSkill, parsedFile, parsedKey)) { return(false); } int OtherLevel; if (!int.TryParse(Split[i], out OtherLevel) || OtherLevel <= 0) { return(Program.ReportFailure($"Invalid level cap interaction '{interaction}'")); } if (OtherLevel != level + 10 && OtherLevel != level + 5) { return(Program.ReportFailure("Inconsistent interaction level cap")); } PgLevelCapInteraction NewInteraction = new PgLevelCapInteraction(); NewInteraction.RawLevel = level; NewInteraction.RawRangeUnlock = OtherLevel - level; NewInteraction.Skill_Key = ParsedSkill.Key; ParsingContext.AddSuplementaryObject(NewInteraction); item.List.Add(NewInteraction); return(true); }
private bool ParseRewards(PgSkill item, object value, string parsedFile, string parsedKey) { PgRewardList ParsedRewardList = null !; if (!Inserter <PgRewardList> .SetItemProperty((PgRewardList valueRewardList) => ParsedRewardList = valueRewardList, value)) { return(false); } foreach (PgReward Reward in ParsedRewardList.List) { int Level = Reward.RewardLevel; List <Race> RaceRestrictionList = Reward.RaceRestrictionList; string? AbilityKey = Reward.Ability_Key; string? BonusLevelSkillKey = Reward.BonusLevelSkill_Key; string? RecipeKey = Reward.Recipe_Key; string Notes = Reward.Notes; if (AbilityKey != null) { PgSkillAdvancement NewSkillAdvancement = new PgSkillAdvancementRewardAbility() { RawLevel = Level, RaceRestrictionList = RaceRestrictionList, Ability_Key = AbilityKey }; ParsingContext.AddSuplementaryObject(NewSkillAdvancement); item.SkillAdvancementList.Add(NewSkillAdvancement); } if (BonusLevelSkillKey != null) { PgSkillAdvancement NewSkillAdvancement = new PgSkillAdvancementRewardBonusLevel() { RawLevel = Level, RaceRestrictionList = RaceRestrictionList, BonusLevelSkill_Key = BonusLevelSkillKey }; ParsingContext.AddSuplementaryObject(NewSkillAdvancement); item.SkillAdvancementList.Add(NewSkillAdvancement); } if (RecipeKey != null) { PgSkillAdvancement NewSkillAdvancement = new PgSkillAdvancementRewardRecipe() { RawLevel = Level, RaceRestrictionList = RaceRestrictionList, Recipe_Key = RecipeKey }; ParsingContext.AddSuplementaryObject(NewSkillAdvancement); item.SkillAdvancementList.Add(NewSkillAdvancement); } if (Notes.Length > 0) { PgSkillAdvancement NewSkillAdvancement = new PgSkillAdvancementNotes() { RawLevel = Level, RaceRestrictionList = RaceRestrictionList, Text = Notes }; ParsingContext.AddSuplementaryObject(NewSkillAdvancement); item.SkillAdvancementList.Add(NewSkillAdvancement); } } return(true); }
private bool FinishItem(PgSkill item, Dictionary <string, object> contentTable, Dictionary <string, Json.Token> contentTypeTable, List <object> itemCollection, Json.Token lastItemType, string parsedFile, string parsedKey) { bool Result = true; foreach (KeyValuePair <string, object> Entry in contentTable) { string Key = Entry.Key; object Value = Entry.Value; switch (Key) { case "Id": Result = SetIntProperty((int valueInt) => item.RawId = valueInt, Value); break; case "Description": Result = SetStringProperty((string valueString) => item.Description = Tools.CleanedUpString(valueString), Value); break; case "HideWhenZero": Result = SetBoolProperty((bool valueBool) => item.SetHideWhenZero(valueBool), Value); break; case "XpTable": Result = Inserter <PgXpTable> .SetItemByInternalName((PgXpTable valueXpTable) => item.XpTable = valueXpTable, Value); break; case "AdvancementTable": Result = ParseAdvancementTable(item, Value, parsedFile, parsedKey); break; case "Combat": Result = SetBoolProperty((bool valueBool) => item.SetIsCombatSkill(valueBool), Value); break; case "TSysCompatibleCombatSkills": Result = ParseCompatibleCombatSkills(item, Value, parsedFile, parsedKey); break; case "MaxBonusLevels": Result = SetIntProperty((int valueInt) => item.RawMaxBonusLevels = valueInt, Value); break; case "InteractionFlagLevelCaps": Result = ParseInteractionFlagLevelCaps(item, Value, parsedFile, parsedKey); break; case "AdvancementHints": Result = ParseAdvancementHints(item, Value, parsedFile, parsedKey); break; case "Rewards": Result = ParseRewards(item, Value, parsedFile, parsedKey); break; case "Reports": Result = ParseReports(item, Value, parsedFile, parsedKey); break; case "Name": Result = SetStringProperty((string valueString) => item.Name = valueString, Value); break; case "Parents": Result = Inserter <PgSkill> .AddPgObjectArrayByKey <PgSkill>(item.ParentSkillList, Value); break; case "SkipBonusLevelsIfSkillUnlearned": Result = SetBoolProperty((bool valueBool) => item.SetSkipBonusLevelsIfSkillUnlearned(valueBool), Value); break; case "AuxCombat": Result = SetBoolProperty((bool valueBool) => item.SetAuxCombat(valueBool), Value); break; case "RecipeIngredientKeywords": Result = StringToEnumConversion <ItemKeyword> .TryParseList(Value, item.RecipeIngredientKeywordList); break; case "_RecipeIngredientKeywords": Result = StringToEnumConversion <ItemKeyword> .TryParseList(Value, item.RecipeIngredientKeywordList); break; case "GuestLevelCap": Result = SetIntProperty((int valueInt) => item.RawGuestLevelCap = valueInt, Value); break; case "IsFakeCombatSkill": Result = SetBoolProperty((bool valueBool) => item.SetIsFakeCombatSkill(valueBool), Value); break; case "IsUmbrellaSkill": Result = SetBoolProperty((bool valueBool) => item.SetIsUmbrellaSkill(valueBool), Value); break; default: Result = Program.ReportFailure(parsedFile, parsedKey, $"Key '{Key}' not handled"); break; } if (!Result) { break; } } if (Result) { item.SkillAdvancementList.Sort(SortSkillAdvancementByLevel); } return(Result); }
private static void FillAssociationTable(PgSkill skill) { FillAssociationTablePower(skill); FillAssociationTableAbility(skill); }
private static bool ParseItemEffectAttribute(string effectString, string parsedFile, string parsedKey, out PgPowerEffect powerEffect) { powerEffect = null !; string[] Split = effectString.Split('{'); if (Split.Length != 2 && Split.Length != 3) { return(false); } string AttributeName = Split[0]; string AttributeEffect = Split[1]; if (!AttributeName.EndsWith("}")) { return(false); } AttributeName = AttributeName.Substring(0, AttributeName.Length - 1); if (AttributeName.Contains("{") || AttributeName.Contains("}")) { return(false); } if (AttributeName.Length == 0 || AttributeEffect.Length == 0) { return(false); } PgAttribute ParsedAttribute = null !; if (!Inserter <PgAttribute> .SetItemByKey((PgAttribute valueAttribute) => ParsedAttribute = valueAttribute, AttributeName)) { return(false); } if (Split.Length == 3) { if (!AttributeEffect.EndsWith("}")) { return(false); } AttributeEffect = AttributeEffect.Substring(0, AttributeEffect.Length - 1); } if (!Tools.TryParseFloat(AttributeEffect, out float ParsedEffect, out FloatFormat ParsedEffectFormat)) { return(false); } if (ParsedEffectFormat != FloatFormat.Standard) { return(false); } PgPowerEffectAttribute NewPowerEffectAttribute; if (Split.Length == 3) { string AttributeSkill = Split[2]; PgSkill ParsedSkill = null !; if (AttributeSkill == "AnySkill") { ParsedSkill = PgSkill.AnySkill; } else if (!Inserter <PgSkill> .SetItemByKey((PgSkill valueSkill) => ParsedSkill = valueSkill, AttributeSkill)) { return(false); } NewPowerEffectAttribute = new PgPowerEffectAttribute() { AttributeEffect = ParsedEffect, AttributeEffectFormat = ParsedEffectFormat, Skill_Key = ParsedSkill.Key }; } else { NewPowerEffectAttribute = new PgPowerEffectAttribute() { AttributeEffect = ParsedEffect, AttributeEffectFormat = ParsedEffectFormat } }; NewPowerEffectAttribute.SetAttribute(ParsedAttribute); powerEffect = NewPowerEffectAttribute; return(true); }