forked from Elfocrash/L2dotNET
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMapRegionTest.cs
More file actions
61 lines (53 loc) · 2.16 KB
/
MapRegionTest.cs
File metadata and controls
61 lines (53 loc) · 2.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
using System;
using System.Collections.Generic;
using System.IO;
using System.Xml;
using L2dotNET.templates;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace L2dotNET.Tests
{
[TestClass]
public class MapRegionTest
{
[TestMethod]
public void Test()
{
Dictionary<int, NpcTemplate> _npcs = new Dictionary<int, NpcTemplate>();
XmlDocument doc = new XmlDocument();
string[] xmlFilesArray = Directory.GetFiles(@"data\xml\npcs\");
try
{
StatsSet set = new StatsSet();
//StatsSet petSet = new StatsSet();
foreach (string i in xmlFilesArray)
{
doc.Load(i);
XmlNodeList nodes = doc.DocumentElement?.SelectNodes("/list/npc");
if (nodes == null)
continue;
foreach (XmlNode node in nodes)
{
XmlElement ownerElement = node.Attributes?[0].OwnerElement;
if ((ownerElement != null) && (node.Attributes != null) && "npc".Equals(ownerElement.Name))
{
XmlNamedNodeMap attrs = node.Attributes;
int npcId = int.Parse(attrs.GetNamedItem("id").Value);
int templateId = attrs.GetNamedItem("idTemplate") == null ? npcId : int.Parse(attrs.GetNamedItem("idTemplate").Value);
set.Set("id", npcId);
set.Set("idTemplate", templateId);
set.Set("name", attrs.GetNamedItem("name").Value);
set.Set("title", attrs.GetNamedItem("title").Value);
_npcs.Add(npcId, new NpcTemplate(set));
}
set.Clear();
}
}
}
catch (Exception e)
{
Console.WriteLine($"MapRegionTest Error: {e.Message}");
//_log.log(Level.SEVERE, "NpcTable: Error parsing NPC templates : ", e);
}
}
}
}