Skip to content

Commit 676f754

Browse files
authored
Parse Smart Push (#46)
* SmartPush * version up
1 parent 4a073db commit 676f754

4 files changed

Lines changed: 43 additions & 1 deletion

File tree

Maple2.File.Parser/Maple2.File.Parser.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<PackageTags>MapleStory2, File, Parser, m2d, xml</PackageTags>
1414
<!-- Use following lines to write the generated files to disk. -->
1515
<EmitCompilerGeneratedFiles Condition=" '$(Configuration)' == 'Debug' ">true</EmitCompilerGeneratedFiles>
16-
<PackageVersion>2.2.4</PackageVersion>
16+
<PackageVersion>2.2.5</PackageVersion>
1717
<TargetFramework>net8.0</TargetFramework>
1818
<PackageReadmeFile>README.md</PackageReadmeFile>
1919
<ImplicitUsings>enable</ImplicitUsings>

Maple2.File.Parser/TableParser.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ public class TableParser {
9494
private readonly XmlSerializer weddingPackageSerializer;
9595
private readonly XmlSerializer weddingRewardSerializer;
9696
private readonly XmlSerializer weddingSkillSerializer;
97+
private readonly XmlSerializer smartPushSerializer;
9798

9899
public TableParser(M2dReader xmlReader) {
99100
this.xmlReader = xmlReader;
@@ -180,6 +181,7 @@ public TableParser(M2dReader xmlReader) {
180181
weddingPackageSerializer = new XmlSerializer(typeof(WeddingPackageRoot));
181182
weddingRewardSerializer = new XmlSerializer(typeof(WeddingRewardRoot));
182183
weddingSkillSerializer = new XmlSerializer(typeof(WeddingSkillRoot));
184+
smartPushSerializer = new XmlSerializer(typeof(SmartPushRoot));
183185

184186
// var seen = new HashSet<string>();
185187
// this.bankTypeSerializer.UnknownAttribute += (sender, args) => {
@@ -1303,4 +1305,15 @@ public IEnumerable<JobTable> ParseJobTable() {
13031305
yield return (entry.id, entry);
13041306
}
13051307
}
1308+
1309+
public IEnumerable<(int Id, SmartPush Button)> ParseSmartPush() {
1310+
string xml = Sanitizer.RemoveEmpty(xmlReader.GetString(xmlReader.GetEntry("table/na/smartpush.xml")));
1311+
var reader = XmlReader.Create(new StringReader(xml));
1312+
var data = smartPushSerializer.Deserialize(reader) as SmartPushRoot;
1313+
Debug.Assert(data != null);
1314+
1315+
foreach (SmartPush entry in data.push) {
1316+
yield return (entry.id, entry);
1317+
}
1318+
}
13061319
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
using System.Xml.Serialization;
2+
using M2dXmlGenerator;
3+
4+
namespace Maple2.File.Parser.Xml.Table;
5+
6+
// ./data/xml/table/na/smartpush.xml
7+
[XmlRoot("ms2")]
8+
public partial class SmartPushRoot {
9+
[M2dFeatureLocale(Selector = "id")] private IList<SmartPush> _push;
10+
}
11+
12+
public partial class SmartPush : IFeatureLocale {
13+
[XmlAttribute] public int id;
14+
[XmlAttribute] public string content = string.Empty;
15+
[XmlAttribute] public string actionType = string.Empty;
16+
[XmlAttribute] public int actionValue;
17+
[XmlAttribute] public long requireMeret;
18+
[XmlAttribute] public string[] requiredItem = Array.Empty<string>();
19+
[XmlAttribute] public string imgPath = string.Empty;
20+
}

Maple2.File.Tests/TableParserTest.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -826,4 +826,13 @@ public void TestWeddingReward() {
826826
continue;
827827
}
828828
}
829+
830+
[TestMethod]
831+
public void TestSmartPush() {
832+
var parser = new TableParser(TestUtils.XmlReader);
833+
834+
foreach ((_, _) in parser.ParseSmartPush()) {
835+
continue;
836+
}
837+
}
829838
}

0 commit comments

Comments
 (0)