Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Maple2.File.Parser/Maple2.File.Parser.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<PackageTags>MapleStory2, File, Parser, m2d, xml</PackageTags>
<!-- Use following lines to write the generated files to disk. -->
<EmitCompilerGeneratedFiles Condition=" '$(Configuration)' == 'Debug' ">true</EmitCompilerGeneratedFiles>
<PackageVersion>2.4.31</PackageVersion>
<PackageVersion>2.4.32</PackageVersion>
<TargetFramework>net8.0</TargetFramework>
<PackageReadmeFile>README.md</PackageReadmeFile>
<ImplicitUsings>enable</ImplicitUsings>
Expand Down
13 changes: 13 additions & 0 deletions Maple2.File.Parser/ServerTableParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public class ServerTableParser {
private readonly XmlSerializer spawnNpcSerializer;
private readonly XmlSerializer spawnInteractObjectSerializer;
private readonly XmlSerializer groupSpawnSerializer;
private readonly XmlSerializer shadowExpeditionDropSerializer;
private readonly XmlSerializer fishSerializer;
private readonly XmlSerializer fishingSpotSerializer;
private readonly XmlSerializer fishLureSerializer;
Expand Down Expand Up @@ -91,6 +92,7 @@ public ServerTableParser(M2dReader xmlReader) {
spawnNpcSerializer = new XmlSerializer(typeof(SpawnNpcRoot));
spawnInteractObjectSerializer = new XmlSerializer(typeof(SpawnInteractObjectRoot));
groupSpawnSerializer = new XmlSerializer(typeof(GroupSpawnRoot));
shadowExpeditionDropSerializer = new XmlSerializer(typeof(ShadowExpeditionDropRoot));
fishSerializer = new XmlSerializer(typeof(FishRoot));
fishingSpotSerializer = new XmlSerializer(typeof(FishingSpotRoot));
fishLureSerializer = new XmlSerializer(typeof(FishLureRoot));
Expand Down Expand Up @@ -511,6 +513,17 @@ public ServerTableParser(M2dReader xmlReader) {
}
}

public IEnumerable<ShadowExpeditionDrop> ParseShadowExpeditionDrop() {
string xml = Sanitizer.RemoveEmpty(xmlReader.GetString(xmlReader.GetEntry("table/Server/shadowExpeditionDrop.xml")));
var reader = XmlReader.Create(new StringReader(xml));
var data = shadowExpeditionDropSerializer.Deserialize(reader) as ShadowExpeditionDropRoot;
Debug.Assert(data != null);

foreach (ShadowExpeditionDrop drop in data.shadowExpeditionDrop) {
yield return drop;
}
}

public IEnumerable<(int Id, Fish Fish)> ParseFish() {
string xml = Sanitizer.RemoveEmpty(xmlReader.GetString(xmlReader.GetEntry("table/Server/fish.xml")));
var reader = XmlReader.Create(new StringReader(xml));
Expand Down
17 changes: 17 additions & 0 deletions Maple2.File.Parser/Xml/Table/Server/ShadowExpeditionDrop.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System.Xml.Serialization;
using M2dXmlGenerator;

namespace Maple2.File.Parser.Xml.Table.Server;

// ./data/server/table/Server/shadowExpeditionDrop.xml
[XmlRoot("ms2")]
public class ShadowExpeditionDropRoot {
[XmlElement] public List<ShadowExpeditionDrop> shadowExpeditionDrop;
}

public partial class ShadowExpeditionDrop {
[XmlAttribute] public int step;
// The killed NPC's basic class: 1, 3 or 6, the classes whose npc rankIcon is c, b and a (normal, elite, boss).
[XmlAttribute("class")] public int @class;
[M2dArray] public int[] dropBoxId = Array.Empty<int>();
}
24 changes: 24 additions & 0 deletions Maple2.File.Tests/ServerTableParserTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,30 @@ public void TestGroupSpawn() {
}
}

[TestMethod]
public void TestShadowExpeditionDrop() {
var parser = new ServerTableParser(TestUtils.ServerReader);

List<ShadowExpeditionDrop> drops = parser.ParseShadowExpeditionDrop().ToList();
Assert.AreEqual(102, drops.Count);

// <shadowExpeditionDrop step="1" class="1" dropBoxId="920001001" />
Assert.AreEqual(1, drops[0].step);
Assert.AreEqual(1, drops[0].@class);
CollectionAssert.AreEqual(new[] { 920001001 }, drops[0].dropBoxId);

// <shadowExpeditionDrop step="1" class="3" dropBoxId="920001002,920003001" />
Assert.AreEqual(1, drops[1].step);
Assert.AreEqual(3, drops[1].@class);
CollectionAssert.AreEqual(new[] { 920001002, 920003001 }, drops[1].dropBoxId);

// <shadowExpeditionDrop step="34" class="6" dropBoxId="920001002,920006034,920000034,820000034" />
ShadowExpeditionDrop last = drops[^1];
Assert.AreEqual(34, last.step);
Assert.AreEqual(6, last.@class);
CollectionAssert.AreEqual(new[] { 920001002, 920006034, 920000034, 820000034 }, last.dropBoxId);
}

[TestMethod]
public void TestSpawnInteractObject() {
var parser = new ServerTableParser(TestUtils.ServerReader);
Expand Down
Loading