sao: fix get_m_gasha_medal_shops

This commit is contained in:
Hay1tsme 2023-11-14 20:51:51 -05:00
parent 1ba14da90c
commit dffa11f420
2 changed files with 69 additions and 5 deletions

View File

@ -894,7 +894,7 @@ class SaoBase:
tmp.sales_end_date = datetime(2100, 1, 1, 0, 0, 0, 0) # always open
resp.data_list.append(tmp)
self.logger.debug(f"Load {len(resp.data_list)} Yui Medal Shops")
return resp.make()
def handle_d5dc(self, header: SaoRequestHeader, request: bytes) -> bytes:
@ -923,12 +923,24 @@ class SaoBase:
tmp.property4_value2 = int(shop['Property4Value2'])
resp.data_list.append(tmp)
self.logger.debug(f"Load {len(resp.data_list)} Yui Medal Shop Items")
return resp.make()
def handle_d5fc(self, header: SaoRequestHeader, request: bytes) -> bytes:
# master_data/get_m_gasha_medal_shops
return SaoNoopResponse(header.cmd + 1).make()
req = GetMGashaMedalShopsRequest(header.cmd + 1).make()
resp = GetMGashaMedalShopsResponse(header.cmd + 1)
shops = self.load_data_csv("GashaMedalShops")
for shop in shops:
tmp = GashaMedalShop.from_args(shop['GashaMedalShopId'], shop['Name'], shop['GashaMedalId'], shop['UseGashaMedalNum'], shop['PurchaseLimit'])
tmp.sales_end_date = datetime(2100, 1, 1, 0, 0, 0, 0) # always open
resp.data_list.append(tmp)
self.logger.debug(f"Load {len(resp.data_list)} Yui Medal Shop Items")
return resp.make()
def handle_d604(self, header: SaoRequestHeader, request: bytes) -> bytes:
# master_data_2/get_m_res_earn_campaign_shops

View File

@ -673,17 +673,29 @@ class YuiMedalShopData(BaseHelper):
self._sz += description[1]
self.selling_yui_medal = decode_short(data, offset + self._sz)
self._sz += SHORT_OFF
self.selling_col = decode_int(data, offset + self._sz)
self._sz += INT_OFF
self.selling_event_item_id = decode_int(data, offset + self._sz)
self._sz += INT_OFF
self.selling_event_item_num = decode_int(data, offset + self._sz)
self._sz += INT_OFF
self.selling_ticket_num = decode_int(data, offset + self._sz)
self._sz += INT_OFF
self.purchase_limit = decode_short(data, offset + self._sz)
self._sz += SHORT_OFF
self.pick_up_flag = decode_byte(data, offset + self._sz)
self._sz += BYTE_OFF
self.product_category = decode_byte(data, offset + self._sz)
self._sz += BYTE_OFF
self.sales_type = decode_byte(data, offset + self._sz)
self._sz += BYTE_OFF
self.target_days = decode_byte(data, offset + self._sz)
self._sz += BYTE_OFF
self.target_hour = decode_byte(data, offset + self._sz)
self._sz += BYTE_OFF
self.interval_hour = decode_byte(data, offset + self._sz)
self._sz += BYTE_OFF
sales_start_date = decode_str(data, offset + self._sz)
self.sales_start_date = prs_dt(sales_start_date[0])
@ -719,7 +731,7 @@ class YuiMedalShopData(BaseHelper):
ret += encode_byte(self.target_days)
ret += encode_byte(self.target_hour)
ret += encode_byte(self.interval_hour)
ret += encode_str(fmt_dt(self.sales_end_date))
ret += encode_str(fmt_dt(self.sales_start_date))
ret += encode_str(fmt_dt(self.sales_end_date))
ret += encode_byte(self.sort)
return ret
@ -807,4 +819,44 @@ class YuiMedalShopItemData(BaseHelper):
class GashaMedalShop(BaseHelper):
def __init__(self, data: bytes, offset: int) -> None:
super().__init__(data, offset)
self.gasha_medal_shop_id = decode_int(data, offset + self._sz)
self._sz += INT_OFF
name = decode_str(data, offset + self._sz)
self.name = name[0]
self._sz += name[1]
self.gasha_medal_id = decode_int(data, offset + self._sz)
self._sz += INT_OFF
self.use_gasha_medal_num = decode_int(data, offset + self._sz)
self._sz += INT_OFF
self.purchase_limit = decode_short(data, offset + self._sz)
self._sz += SHORT_OFF
sales_start_date = decode_str(data, offset + self._sz)
self.sales_start_date = prs_dt(sales_start_date[0])
self._sz += sales_start_date[1]
sales_end_date = decode_str(data, offset + self._sz)
self.sales_end_date = prs_dt(sales_end_date[0])
self._sz += sales_end_date[1]
@classmethod
def from_args(cls, shop_id: int = 0, name: str = "", medal_id: int = 0, medal_num: int = 0, purchase_limit: int = 0) -> "GashaMedalShop":
ret = cls(b"\x00" * 26, 0)
ret.gasha_medal_shop_id = shop_id
ret.name = name
ret.gasha_medal_id = medal_id
ret.use_gasha_medal_num = medal_num
ret.purchase_limit = purchase_limit
return ret
def make(self) -> bytes:
ret = encode_int(self.gasha_medal_shop_id)
ret += encode_str(self.name)
ret += encode_int(self.gasha_medal_id)
ret += encode_int(self.use_gasha_medal_num)
ret += encode_short(self.purchase_limit)
ret += encode_str(fmt_dt(self.sales_start_date))
ret += encode_str(fmt_dt(self.sales_end_date))
return ret