private void ProcessQuestData(WzFileProperty baseNode) { if (!int.TryParse(baseNode.Name.Split('.')[0], out var questId)) { return; } var entry = new QuestTemplate(questId); if (baseNode["Act"] is WzProperty actInfo) { if (actInfo["0"] is WzProperty startRewards) { entry.StartAct = RegisterQuestAct(startRewards); entry.RepeatInterval = startRewards.GetInt32("interval"); } if (actInfo["1"] is WzProperty endRewards) { entry.EndAct = RegisterQuestAct(endRewards); } } // verified if (baseNode["QuestInfo"] is WzProperty questInfo) { entry.AutoAccept = questInfo.GetInt64("autoAccept") != 0; entry.AutoStart = questInfo.GetInt64("autoStart") != 0; entry.AutoComplete = questInfo.GetInt64("autoComplete") != 0; entry.AutoPreComplete = questInfo.GetInt64("autoPreComplete") != 0; entry.ViewMedalItem = questInfo.GetInt32("viewMedalItem"); } if (baseNode["Check"] is WzProperty checkInfo) // requirements { if (checkInfo["0"] is WzProperty startRequirements) { entry.StartDemand = RegisterQuestDemand(startRequirements); entry.StartScript = startRequirements.GetString("startscript"); entry.StartNPC = startRequirements.GetInt32("npc"); entry.CompletionWaitInterval = startRequirements.GetInt32("interval"); var start = startRequirements.GetString("start"); var end = startRequirements.GetString("end"); if (start.Length > 0) { entry.Start = new DateTime( int.Parse(start.Substring(0, 4)), int.Parse(start.Substring(4, 2)), int.Parse(start.Substring(6, 2)), int.Parse(start.Substring(8, 2)), 0, 0); } if (end.Length > 0) { entry.End = new DateTime( int.Parse(end.Substring(0, 4)), int.Parse(end.Substring(4, 2)), int.Parse(end.Substring(6, 2)), int.Parse(end.Substring(8, 2)), 0, 0); } } if (checkInfo["1"] is WzProperty endRequirements) { entry.EndDemand = RegisterQuestDemand(endRequirements); entry.EndScript = endRequirements.GetString("endscript"); entry.EndNPC = endRequirements.GetInt32("npc"); } if (entry.EndDemand != null) { foreach (var item in entry.EndDemand.DemandMob) { if (!QuestByMobID.ContainsKey(item.MobID)) { QuestByMobID.Add(item.MobID, new HashSet <int>()); } if (!QuestByMobID[item.MobID].Contains(entry.TemplateId)) { QuestByMobID[item.MobID].Add(entry.TemplateId); } } } } InsertItem(entry); }
public void TestBasicTraversal() { var root = new FSDirectory() { Name = "", }; var dir1 = new FSDirectory() { Name = "dir1" }; var dir2 = new FSDirectory() { Name = "dir2" }; root.AddDirectories(dir1, dir2); Assert.AreEqual(root, dir1.Parent); Assert.IsTrue(root.HasChild("dir1")); Assert.IsTrue(root.HasChild("dir2")); var file1 = new FSFile() { Name = "crappyfile.img" }; var file1Object = new WzFileProperty { FileNode = file1, Name = file1.Name, }; file1.Object = file1Object; dir1.AddFiles(file1); file1Object.Set("prop1", "whatever"); file1Object.Set("prop2", 1337); file1Object.Set("uol_1", new WzUOL() { Path = "./prop1", }); Assert.AreEqual(dir1, file1.GetParent()); Assert.AreEqual(file1Object, dir1.GetChild("crappyfile")); Assert.AreEqual(file1Object, dir1.GetChild("crappyfile.img")); { var x = file1Object.Get("uol_1"); Assert.IsNotNull(x); var xnsn = (INameSpaceNode)x; Assert.IsNotNull(xnsn); var xnsn1 = (INameSpaceNode)xnsn.GetParent(); Assert.AreEqual(file1Object, xnsn1); var xnsn2 = (INameSpaceNode)xnsn1.GetParent(); Assert.AreEqual(dir1, xnsn2); var xnsn3 = (INameSpaceNode)xnsn2.GetParent(); Assert.AreEqual(root, xnsn3); } file1Object.Set("uol", new WzUOL { Path = "uol_1" }); Assert.AreEqual(file1Object.Get("uol_1"), ((WzUOL)file1Object.Get("uol")).ActualObject(false)); file1Object.Set("uol", new WzUOL { Path = "uol_1" }); Assert.AreEqual(file1Object.Get("prop1"), ((WzUOL)file1Object.Get("uol")).ActualObject(true)); file1Object.Set("uol", new WzUOL { Path = "./prop2" }); Assert.AreEqual(1337, ((WzUOL)file1Object.Get("uol")).ActualObject()); file1Object.Set("uol", new WzUOL { Path = "prop2" }); Assert.AreEqual(1337, ((WzUOL)file1Object.Get("uol")).ActualObject()); file1Object.Set("uol", new WzUOL { Path = "../crappyfile/prop2" }); Assert.AreEqual(1337, ((WzUOL)file1Object.Get("uol")).ActualObject()); file1Object.Set("uol", new WzUOL { Path = "../crappyfile/prop2" }); Assert.AreEqual(1337, ((WzUOL)file1Object.Get("uol")).ActualObject()); file1Object.Set("uol", new WzUOL { Path = "../crappyfile.img/prop2" }); Assert.AreEqual(1337, ((WzUOL)file1Object.Get("uol")).ActualObject()); file1Object.Set("uol", new WzUOL { Path = "../../dir1/crappyfile/prop2" }); Assert.AreEqual(1337, ((WzUOL)file1Object.Get("uol")).ActualObject()); file1Object.Set("uol", new WzUOL { Path = "../../dir1/crappyfile/uol_1" }); Assert.AreEqual(file1Object.Get("uol_1"), ((WzUOL)file1Object.Get("uol")).ActualObject(false)); file1Object.Set("uol", new WzUOL { Path = "../../dir1/crappyfile/uol_1" }); Assert.AreEqual("whatever", ((WzUOL)file1Object.Get("uol")).ActualObject(true)); }