Add JSON save and load for shopkeeper and merchant mobiles

ShopKeeperInfo and MerchantInfo only had binary methods, so a zone
holding either type could not be unpacked.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
MagicBotandClaude Opus 5.5 committed 2026-10-24 10:51:30 -04:00
1 parent d4008b1a9f
commit e879110c58
2 files changed
+48

No files matched your search

@@ -48,3 +48,28 @@ class MerchantInfo(MobileInfo):
for l in self.merchant_sell_list: for l in self.merchant_sell_list:
stream.write_qword(l[0]) stream.write_qword(l[0])
stream.write_dword(l[1]) stream.write_dword(l[1])
def save_json(self):
data = super().save_json()
data['merchant_trade_type'] = self.merchant_trade_type
data['merchant_std_buy_margin'] = self.merchant_std_buy_margin
data['merchant_std_sell_margin'] = self.merchant_std_sell_margin
data['merchant_guild_buy_margin'] = self.merchant_guild_buy_margin
data['merchant_guild_sell_margin'] = self.merchant_guild_sell_margin
data['merchant_nation_buy_margin'] = self.merchant_nation_buy_margin
data['merchant_nation_sell_margin'] = self.merchant_nation_sell_margin
data['merchant_buy_list'] = self.merchant_buy_list
data['merchant_sell_list'] = self.merchant_sell_list
return data
def load_json(self, data):
super().load_json(data)
self.merchant_trade_type = data['merchant_trade_type']
self.merchant_std_buy_margin = data['merchant_std_buy_margin']
self.merchant_std_sell_margin = data['merchant_std_sell_margin']
self.merchant_guild_buy_margin = data['merchant_guild_buy_margin']
self.merchant_guild_sell_margin = data['merchant_guild_sell_margin']
self.merchant_nation_buy_margin = data['merchant_nation_buy_margin']
self.merchant_nation_sell_margin = data['merchant_nation_sell_margin']
self.merchant_buy_list = data['merchant_buy_list']
self.merchant_sell_list = data['merchant_sell_list']
@@ -46,3 +46,26 @@ class ShopKeeperInfo(MobileInfo):
for l in self.shopkeeper_sell_list: for l in self.shopkeeper_sell_list:
stream.write_qword(l[0]) stream.write_qword(l[0])
stream.write_dword(l[1]) stream.write_dword(l[1])
def save_json(self):
data = super().save_json()
data['shopkeeper_shop_type'] = self.shopkeeper_shop_type
data['shopkeeper_start_gold'] = self.shopkeeper_start_gold
data['shopkeeper_std_buy_percent'] = self.shopkeeper_std_buy_percent
data['shopkeeper_std_sell_percent'] = self.shopkeeper_std_sell_percent
data['shopkeeper_nation_buy_percent'] = self.shopkeeper_nation_buy_percent
data['shopkeeper_nation_sell_percent'] = self.shopkeeper_nation_sell_percent
data['shopkeeper_buy_list'] = self.shopkeeper_buy_list
data['shopkeeper_sell_list'] = self.shopkeeper_sell_list
return data
def load_json(self, data):
super().load_json(data)
self.shopkeeper_shop_type = data['shopkeeper_shop_type']
self.shopkeeper_start_gold = data['shopkeeper_start_gold']
self.shopkeeper_std_buy_percent = data['shopkeeper_std_buy_percent']
self.shopkeeper_std_sell_percent = data['shopkeeper_std_sell_percent']
self.shopkeeper_nation_buy_percent = data['shopkeeper_nation_buy_percent']
self.shopkeeper_nation_sell_percent = data['shopkeeper_nation_sell_percent']
self.shopkeeper_buy_list = data['shopkeeper_buy_list']
self.shopkeeper_sell_list = data['shopkeeper_sell_list']