diff --git a/Maple2.File.Parser/Maple2.File.Parser.csproj b/Maple2.File.Parser/Maple2.File.Parser.csproj index 32e73d3..e48c7ec 100644 --- a/Maple2.File.Parser/Maple2.File.Parser.csproj +++ b/Maple2.File.Parser/Maple2.File.Parser.csproj @@ -13,7 +13,7 @@ MapleStory2, File, Parser, m2d, xml true - 2.1.29 + 2.1.30 net8.0 README.md enable diff --git a/Maple2.File.Parser/ServerTableParser.cs b/Maple2.File.Parser/ServerTableParser.cs index 9addeb8..86af0f6 100644 --- a/Maple2.File.Parser/ServerTableParser.cs +++ b/Maple2.File.Parser/ServerTableParser.cs @@ -44,6 +44,7 @@ public class ServerTableParser { private readonly XmlSerializer itemMergeOptionSerializer; private readonly XmlSerializer enchantOptionSerializer; private readonly XmlSerializer shopMeretSerializer; + private readonly XmlSerializer shopMeretCustomSerializer; public ServerTableParser(M2dReader xmlReader) { this.xmlReader = xmlReader; @@ -81,6 +82,7 @@ public ServerTableParser(M2dReader xmlReader) { itemMergeOptionSerializer = new XmlSerializer(typeof(ItemMergeOptionRoot)); enchantOptionSerializer = new XmlSerializer(typeof(EnchantOptionRoot)); shopMeretSerializer = new XmlSerializer(typeof(ShopMeretRoot)); + shopMeretCustomSerializer = new XmlSerializer(typeof(ShopMeretCustomRoot)); // var seen = new HashSet(); // this.bankTypeSerializer.UnknownAttribute += (sender, args) => { @@ -627,4 +629,15 @@ public ServerTableParser(M2dReader xmlReader) { yield return (shopMeret.sn, shopMeret); } } + + public IEnumerable<(int Id, ShopMeretCustom ShopMeret)> ParseShopMeretCustom() { + string xml = Sanitizer.RemoveEmpty(xmlReader.GetString(xmlReader.GetEntry("table/Server/shop_merat_custom.xml"))); + var reader = XmlReader.Create(new StringReader(xml)); + var data = shopMeretCustomSerializer.Deserialize(reader) as ShopMeretCustomRoot; + Debug.Assert(data != null); + + foreach (ShopMeretCustom shopMeret in data.item) { + yield return (shopMeret.id, shopMeret); + } + } } diff --git a/Maple2.File.Parser/Xml/Table/Server/ShopMeretCustom.cs b/Maple2.File.Parser/Xml/Table/Server/ShopMeretCustom.cs new file mode 100644 index 0000000..ac08f65 --- /dev/null +++ b/Maple2.File.Parser/Xml/Table/Server/ShopMeretCustom.cs @@ -0,0 +1,41 @@ +using System.Xml.Serialization; +using M2dXmlGenerator; + +namespace Maple2.File.Parser.Xml.Table.Server; + +// ./data/server/table/Server/shop_merat_custom.xml +[XmlRoot("ms2")] +public class ShopMeretCustomRoot { + [XmlElement] public List item; +} + +public partial class ShopMeretCustom { + [XmlAttribute] public int id; + [XmlAttribute] public int tabID; + [XmlAttribute] public string banner = string.Empty; + [XmlAttribute] public int bannerTag; + [XmlAttribute] public int itemID; + [XmlAttribute] public int grade; + [XmlAttribute] public int quantity; + [XmlAttribute] public int bonusQuantity; + [XmlAttribute] public int durationDay; + [XmlAttribute] public byte saleTag; + [XmlAttribute] public int paymentType; + [XmlAttribute] public long price; + [XmlAttribute] public long salePrice; + [XmlAttribute] public string saleStartTime = string.Empty; + [XmlAttribute] public string saleEndTime = string.Empty; + [M2dArray] public int[] jobRequire = Array.Empty(); + [XmlAttribute] public bool noRestock; + [XmlAttribute] public short minLevel; + [XmlAttribute] public short maxLevel; + [XmlAttribute] public int achieveID; + [XmlAttribute] public byte achieveGrade; + [XmlAttribute] public bool pcCafe; + [XmlAttribute] public bool giftable; + [XmlAttribute] public bool showSaleTime; + [XmlAttribute] public string promoName = string.Empty; + [XmlAttribute] public string promoSaleStartTime = string.Empty; + [XmlAttribute] public string promoSaleEndTime = string.Empty; + [XmlElement] public List additionalQuantity; +} diff --git a/Maple2.File.Tests/ServerTableParserTest.cs b/Maple2.File.Tests/ServerTableParserTest.cs index 407a48e..44febb8 100644 --- a/Maple2.File.Tests/ServerTableParserTest.cs +++ b/Maple2.File.Tests/ServerTableParserTest.cs @@ -399,4 +399,13 @@ public void TestMeretShop() { continue; } } + + [TestMethod] + public void TestMeretShopCustom() { + var parser = new ServerTableParser(TestUtils.ServerReader); + + foreach ((_, _) in parser.ParseShopMeretCustom()) { + continue; + } + } }