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.9</PackageVersion>
<PackageVersion>2.4.10</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 @@ -59,6 +59,7 @@ public class ServerTableParser {
private readonly XmlSerializer itemOptionVariationSerializer;
private readonly XmlSerializer itemOptionRandomSerializer;
private readonly XmlSerializer constantsSerializer;
private readonly XmlSerializer npcStatFactorByPlayerCountSerializer;

public ServerTableParser(M2dReader xmlReader) {
this.xmlReader = xmlReader;
Expand Down Expand Up @@ -101,6 +102,7 @@ public ServerTableParser(M2dReader xmlReader) {
itemOptionVariationSerializer = new XmlSerializer(typeof(ItemOptionVariationRoot));
itemOptionRandomSerializer = new XmlSerializer(typeof(ItemOptionRandomRoot));
constantsSerializer = new XmlSerializer(typeof(Constants));
npcStatFactorByPlayerCountSerializer = new XmlSerializer(typeof(NpcStatFactorByPlayerCountRoot));

// var seen = new HashSet<string>();
// this.bankTypeSerializer.UnknownAttribute += (sender, args) => {
Expand Down Expand Up @@ -702,4 +704,15 @@ public ServerTableParser(M2dReader xmlReader) {
yield return (key.key, key);
}
}

public IEnumerable<NpcStatFactorByPlayerCount> ParseNpcStatFactorByPlayerCount() {
string xml = Sanitizer.RemoveEmpty(xmlReader.GetString(xmlReader.GetEntry("table/Server/npcStatFactorByPlayerCount.xml")));
var reader = XmlReader.Create(new StringReader(xml));
var data = npcStatFactorByPlayerCountSerializer.Deserialize(reader) as NpcStatFactorByPlayerCountRoot;
Debug.Assert(data != null);

foreach (NpcStatFactorByPlayerCount entry in data.PlayerCountFactor) {
yield return (entry);
}
}
}
13 changes: 13 additions & 0 deletions Maple2.File.Parser/TableParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public class TableParser {
private readonly XmlSerializer dungeonRoundDataSerializer;
private readonly XmlSerializer dungeonRankRewardSerializer;
private readonly XmlSerializer dungeonConfigSerializer;
private readonly XmlSerializer dungeonRewardCouponSerializer;
private readonly XmlSerializer enchantScrollSerializer;
private readonly XmlSerializer fishSerializer;
private readonly XmlSerializer fishHabitatSerializer;
Expand Down Expand Up @@ -126,6 +127,7 @@ public TableParser(M2dReader xmlReader, string language) {
dungeonRoundDataSerializer = new XmlSerializer(typeof(DungeonRoundDataRoot));
dungeonRankRewardSerializer = new XmlSerializer(typeof(DungeonRankRewardRoot));
dungeonConfigSerializer = new XmlSerializer(typeof(DungeonConfigRoot));
dungeonRewardCouponSerializer = new XmlSerializer(typeof(DungeonRewardCouponRoot));
enchantScrollSerializer = new XmlSerializer(typeof(EnchantScrollRoot));
fishSerializer = new XmlSerializer(typeof(FishRoot));
fishHabitatSerializer = new XmlSerializer(typeof(FishHabitatRoot));
Expand Down Expand Up @@ -1636,4 +1638,15 @@ public IEnumerable<JobTableNew> ParseJobTableNew() {
yield return (entry.id, entry);
}
}

public IEnumerable<(int Id, DungeonRewardCoupon Coupon)> ParseDungeonRewardCoupon() {
string xml = Sanitizer.RemoveSpaces(xmlReader.GetString(xmlReader.GetEntry($"table/{locale}/dungeonrewardcoupon.xml")));
var reader = XmlReader.Create(new StringReader(xml));
var data = dungeonRewardCouponSerializer.Deserialize(reader) as DungeonRewardCouponRoot;
Debug.Assert(data != null);

foreach (DungeonRewardCoupon entry in data.dungeonRewardCoupon) {
yield return (entry.id, entry);
}
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.
}
21 changes: 21 additions & 0 deletions Maple2.File.Parser/Xml/Table/DungeonRewardCoupon.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using System.Xml.Serialization;

namespace Maple2.File.Parser.Xml.Table;

// ./data/xml/table/na/dungeonrewardcoupon.xml
[XmlRoot("ms2")]
public class DungeonRewardCouponRoot {
[XmlElement] public List<DungeonRewardCoupon> dungeonRewardCoupon;
}

public class DungeonRewardCoupon {
[XmlAttribute] public int id;
[XmlAttribute] public string ticketTag;
[XmlAttribute] public int baseItemID;
[XmlAttribute] public int maxExtraCount;
[XmlElement] public List<DungeonRewardBaseRate> baseRate;
}

public class DungeonRewardBaseRate {
[XmlAttribute] public int v;
}
24 changes: 24 additions & 0 deletions Maple2.File.Parser/Xml/Table/Server/NpcStatFactorByPlayerCount.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using System.Xml.Serialization;

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

// ./data/server/table/Server/npcStatFactorByPlayerCount.xml
[XmlRoot("ms2")]
public class NpcStatFactorByPlayerCountRoot {
[XmlElement] public List<NpcStatFactorByPlayerCount> PlayerCountFactor;
}

public partial class NpcStatFactorByPlayerCount {
[XmlAttribute] public int factorID;
[XmlAttribute] public int @class;
[XmlAttribute] public int playerCount;
[XmlAttribute] public float hpRate;
[XmlAttribute] public float papRate;
[XmlAttribute] public int papValue;
[XmlAttribute] public float mapRate;
[XmlAttribute] public int mapValue;
[XmlAttribute] public float nddRate;
[XmlAttribute] public int nddValue;
[XmlAttribute] public float capRate;
[XmlAttribute] public int capValue;
}
10 changes: 10 additions & 0 deletions Maple2.File.Tests/ServerTableParserTest.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Maple2.File.Parser;
using Maple2.File.Parser.Xml.Table;
using Maple2.File.Parser.Xml.Table.Server;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Maple2.File.Tests;
Expand Down Expand Up @@ -445,5 +446,14 @@ public void TestConstants() {
continue;
}
}

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

foreach (NpcStatFactorByPlayerCount _ in parser.ParseNpcStatFactorByPlayerCount()) {
continue;
}
}
}

7 changes: 7 additions & 0 deletions Maple2.File.Tests/TableParserTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -787,4 +787,11 @@ public void TestClubBuff() {
continue;
}
}

[TestMethod]
public void TestDungeonRewardCoupon() {
foreach ((_, _) in _parser.ParseDungeonRewardCoupon()) {
continue;
}
}
}
Loading