public static bool SetNpcNoZone(Action <PgNpcLocation> setter, MapAreaName areaName, string npcId, string parsedFile, string parsedKey, ErrorControl errorControl) { PgNpc ParsedNpc = null !; SpecialNpc NpcEnum = SpecialNpc.Internal_None; string NpcName = string.Empty; PgNpcLocation NpcLocation = new PgNpcLocation(); NpcLocation.NpcId = npcId; if (Inserter <PgNpc> .SetItemByKey((PgNpc valueNpc) => ParsedNpc = valueNpc, npcId, ErrorControl.IgnoreIfNotFound)) { NpcLocation.Npc_Key = ParsedNpc.Key; } else if (StringToEnumConversion <SpecialNpc> .TryParse(npcId, out NpcEnum, ErrorControl.IgnoreIfNotFound)) { NpcLocation.NpcEnum = NpcEnum; } else if (npcId.ToUpper().StartsWith("NPC_")) { NpcLocation.NpcName = npcId.Substring(4); } else { return(Program.ReportFailure(parsedFile, parsedKey, $"'{npcId}' unknown NPC name", errorControl)); } ParsingContext.AddSuplementaryObject(NpcLocation); Debug.Assert(!string.IsNullOrEmpty(NpcLocation.NpcId)); Debug.Assert(NpcLocation.Npc_Key != null || NpcLocation.NpcEnum != SpecialNpc.Internal_None || NpcLocation.NpcName.Length > 0); setter(NpcLocation); return(true); }
private bool ParseHints(string hint, string parsedFile, string parsedKey, out PgNpcLocationCollection npcList) { npcList = new PgNpcLocationCollection(); if (hint.EndsWith("learn a new dance move.")) { return(true); } hint = hint.Replace(" during a Full Moon,", string.Empty); string Pattern; int StartIndex; Pattern = "gain favor with "; StartIndex = hint.IndexOf(Pattern); if (StartIndex < 0) { Pattern = "speak with "; StartIndex = hint.IndexOf(Pattern); } if (StartIndex < 0) { Pattern = "seek out "; StartIndex = hint.IndexOf(Pattern); } if (StartIndex < 0) { if (hint.Contains(" equip ")) { return(true); } return(Program.ReportFailure($"Advancement trigger not found in: {hint}")); } StartIndex += Pattern.Length; int EndIndex; EndIndex = hint.IndexOf(" in ", StartIndex); if (EndIndex < 0) { EndIndex = hint.IndexOf(" outside of ", StartIndex); } if (EndIndex <= StartIndex) { return(Program.ReportFailure($"Bad advancement hint: {hint}")); } string NpcNameString = hint.Substring(StartIndex, EndIndex - StartIndex); string[] NpcNames = NpcNameString.Split(new string[] { " or " }, StringSplitOptions.None); foreach (string NpcName in NpcNames) { PgNpcLocation ParsedNpc = null !; if (!Inserter <PgSkill> .SetNpc((PgNpcLocation npcLocation) => ParsedNpc = npcLocation, $"NPC_{NpcName}", parsedFile, parsedKey)) { return(false); } npcList.Add(ParsedNpc); } if (npcList.Count == 0) { return(Program.ReportFailure($"No NPC name in advancement hint: {hint}")); } return(true); }