From b60cf6258da596af25dec14acc101284904490be Mon Sep 17 00:00:00 2001 From: Midorica Date: Tue, 27 Jun 2023 21:32:46 -0400 Subject: [PATCH] Dummy defrag match handler for SAO --- titles/sao/base.py | 20 +++ titles/sao/handlers/base.py | 255 +++++++++++++++++++++++++++++++++++- 2 files changed, 273 insertions(+), 2 deletions(-) diff --git a/titles/sao/base.py b/titles/sao/base.py index 58bc3df..c2ec49d 100644 --- a/titles/sao/base.py +++ b/titles/sao/base.py @@ -1169,3 +1169,23 @@ class SaoBase: #quest/trial_tower_play_end_unanalyzed_log_fixed resp = SaoEpisodePlayEndUnanalyzedLogFixedResponse(int.from_bytes(bytes.fromhex(request[:4]), "big")+1) return resp.make() + + def handle_cd00(self, request: Any) -> bytes: + #defrag_match/get_defrag_match_basic_data + resp = SaoGetDefragMatchBasicDataResponse(int.from_bytes(bytes.fromhex(request[:4]), "big")+1) + return resp.make() + + def handle_cd02(self, request: Any) -> bytes: + #defrag_match/get_defrag_match_ranking_user_data + resp = SaoGetDefragMatchRankingUserDataResponse(int.from_bytes(bytes.fromhex(request[:4]), "big")+1) + return resp.make() + + def handle_cd04(self, request: Any) -> bytes: + #defrag_match/get_defrag_match_league_point_ranking_list + resp = SaoGetDefragMatchLeaguePointRankingListResponse(int.from_bytes(bytes.fromhex(request[:4]), "big")+1) + return resp.make() + + def handle_cd06(self, request: Any) -> bytes: + #defrag_match/get_defrag_match_league_score_ranking_list + resp = SaoGetDefragMatchLeagueScoreRankingListResponse(int.from_bytes(bytes.fromhex(request[:4]), "big")+1) + return resp.make() \ No newline at end of file diff --git a/titles/sao/handlers/base.py b/titles/sao/handlers/base.py index eea9850..fcae572 100644 --- a/titles/sao/handlers/base.py +++ b/titles/sao/handlers/base.py @@ -1821,8 +1821,8 @@ class SaoCheckYuiMedalGetConditionResponse(SaoBaseResponse): super().__init__(cmd) self.result = 1 self.get_flag = 1 - self.elapsed_days = 1 - self.get_yui_medal_num = 1 + self.elapsed_days = 0 + self.get_yui_medal_num = 0 def make(self) -> bytes: # create a resp struct @@ -2209,5 +2209,256 @@ class SaoSynthesizeEnhancementEquipmentResponse(SaoBaseResponse): # finally, rebuild the resp_data resp_data = resp_struct.build(resp_data) + self.length = len(resp_data) + return super().make() + resp_data + +class SaoGetDefragMatchBasicDataRequest(SaoBaseRequest): + def __init__(self, data: bytes) -> None: + super().__init__(data) + +class SaoGetDefragMatchBasicDataResponse(SaoBaseResponse): + def __init__(self, cmd) -> None: + super().__init__(cmd) + self.result = 1 + self.defrag_match_basic_user_data_size = 1 # number of arrays + + self.seed_flag = 1 + self.ad_confirm_flag = 1 + self.total_league_point = 0 + self.have_league_score = 0 + self.class_num = 1 # 1 to 6 + self.hall_of_fame_confirm_flag = 0 + + def make(self) -> bytes: + # create a resp struct + resp_struct = Struct( + "result" / Int8ul, # result is either 0 or 1 + "defrag_match_basic_user_data_size" / Int32ub, # big endian + + "seed_flag" / Int16ub, #short + "ad_confirm_flag" / Int8ul, # result is either 0 or 1 + "total_league_point" / Int32ub, #int + "have_league_score" / Int16ub, #short + "class_num" / Int16ub, #short + "hall_of_fame_confirm_flag" / Int8ul, # result is either 0 or 1 + + ) + + resp_data = resp_struct.build(dict( + result=self.result, + defrag_match_basic_user_data_size=self.defrag_match_basic_user_data_size, + + seed_flag=self.seed_flag, + ad_confirm_flag=self.ad_confirm_flag, + total_league_point=self.total_league_point, + have_league_score=self.have_league_score, + class_num=self.class_num, + hall_of_fame_confirm_flag=self.hall_of_fame_confirm_flag, + )) + + self.length = len(resp_data) + return super().make() + resp_data + +class SaoGetDefragMatchRankingUserDataRequest(SaoBaseRequest): + def __init__(self, data: bytes) -> None: + super().__init__(data) + +class SaoGetDefragMatchRankingUserDataResponse(SaoBaseResponse): + def __init__(self, cmd) -> None: + super().__init__(cmd) + self.result = 1 + self.ranking_user_data_size = 1 # number of arrays + + self.league_point_rank = 1 + self.league_score_rank = 1 + self.nick_name = "PLAYER" + self.setting_title_id = 20005 # Default saved during profile creation, no changing for those atm + self.favorite_hero_log_id = 101000010 # Default saved during profile creation + self.favorite_hero_log_awakening_stage = 0 + self.favorite_support_log_id = 0 + self.favorite_support_log_awakening_stage = 0 + self.total_league_point = 1 + self.have_league_score = 1 + + def make(self) -> bytes: + # create a resp struct + resp_struct = Struct( + "result" / Int8ul, # result is either 0 or 1 + "ranking_user_data_size" / Int32ub, # big endian + + "league_point_rank" / Int32ub, #int + "league_score_rank" / Int32ub, #int + "nick_name_size" / Int32ub, # big endian + "nick_name" / Int16ul[len(self.nick_name)], + "setting_title_id" / Int32ub, #int + "favorite_hero_log_id" / Int32ub, #int + "favorite_hero_log_awakening_stage" / Int16ub, #short + "favorite_support_log_id" / Int32ub, #int + "favorite_support_log_awakening_stage" / Int16ub, #short + "total_league_point" / Int32ub, #int + "have_league_score" / Int16ub, #short + ) + + resp_data = resp_struct.build(dict( + result=self.result, + ranking_user_data_size=self.ranking_user_data_size, + + league_point_rank=self.league_point_rank, + league_score_rank=self.league_score_rank, + nick_name_size=len(self.nick_name) * 2, + nick_name=[ord(x) for x in self.nick_name], + setting_title_id=self.setting_title_id, + favorite_hero_log_id=self.favorite_hero_log_id, + favorite_hero_log_awakening_stage=self.favorite_hero_log_awakening_stage, + favorite_support_log_id=self.favorite_support_log_id, + favorite_support_log_awakening_stage=self.favorite_support_log_awakening_stage, + total_league_point=self.total_league_point, + have_league_score=self.have_league_score, + )) + + self.length = len(resp_data) + return super().make() + resp_data + +class SaoGetDefragMatchLeaguePointRankingListRequest(SaoBaseRequest): + def __init__(self, data: bytes) -> None: + super().__init__(data) + +class SaoGetDefragMatchLeaguePointRankingListResponse(SaoBaseResponse): + def __init__(self, cmd) -> None: + super().__init__(cmd) + self.result = 1 + self.ranking_user_data_size = 1 # number of arrays + + self.rank = 1 + self.user_id = "1" + self.store_id = "123" + self.store_name = "ARTEMiS" + self.nick_name = "PLAYER" + self.setting_title_id = 20005 + self.favorite_hero_log_id = 101000010 + self.favorite_hero_log_awakening_stage = 0 + self.favorite_support_log_id = 0 + self.favorite_support_log_awakening_stage = 0 + self.class_num = 1 + self.total_league_point = 1 + + def make(self) -> bytes: + # create a resp struct + resp_struct = Struct( + "result" / Int8ul, # result is either 0 or 1 + "ranking_user_data_size" / Int32ub, # big endian + + "rank" / Int32ub, #int + "user_id_size" / Int32ub, # big endian + "user_id" / Int16ul[len(self.user_id)], + "store_id_size" / Int32ub, # big endian + "store_id" / Int16ul[len(self.store_id)], + "store_name_size" / Int32ub, # big endian + "store_name" / Int16ul[len(self.store_name)], + "nick_name_size" / Int32ub, # big endian + "nick_name" / Int16ul[len(self.nick_name)], + "setting_title_id" / Int32ub, #int + "favorite_hero_log_id" / Int32ub, #int + "favorite_hero_log_awakening_stage" / Int16ub, #short + "favorite_support_log_id" / Int32ub, #int + "favorite_support_log_awakening_stage" / Int16ub, #short + "class_num" / Int16ub, #short + "total_league_point" / Int32ub, #int + ) + + resp_data = resp_struct.build(dict( + result=self.result, + ranking_user_data_size=self.ranking_user_data_size, + + rank=self.rank, + user_id_size=len(self.user_id) * 2, + user_id=[ord(x) for x in self.user_id], + store_id_size=len(self.store_id) * 2, + store_id=[ord(x) for x in self.store_id], + store_name_size=len(self.store_name) * 2, + store_name=[ord(x) for x in self.store_name], + nick_name_size=len(self.nick_name) * 2, + nick_name=[ord(x) for x in self.nick_name], + setting_title_id=self.setting_title_id, + favorite_hero_log_id=self.favorite_hero_log_id, + favorite_hero_log_awakening_stage=self.favorite_hero_log_awakening_stage, + favorite_support_log_id=self.favorite_support_log_id, + favorite_support_log_awakening_stage=self.favorite_support_log_awakening_stage, + class_num=self.class_num, + total_league_point=self.total_league_point, + )) + + self.length = len(resp_data) + return super().make() + resp_data + +class SaoGetDefragMatchLeagueScoreRankingListRequest(SaoBaseRequest): + def __init__(self, data: bytes) -> None: + super().__init__(data) + +class SaoGetDefragMatchLeagueScoreRankingListResponse(SaoBaseResponse): + def __init__(self, cmd) -> None: + super().__init__(cmd) + self.result = 1 + self.ranking_user_data_size = 1 # number of arrays + + self.rank = 1 + self.user_id = "1" + self.store_id = "123" + self.store_name = "ARTEMiS" + self.nick_name = "PLAYER" + self.setting_title_id = 20005 + self.favorite_hero_log_id = 101000010 + self.favorite_hero_log_awakening_stage = 0 + self.favorite_support_log_id = 0 + self.favorite_support_log_awakening_stage = 0 + self.class_num = 1 + self.have_league_score = 1 + + def make(self) -> bytes: + # create a resp struct + resp_struct = Struct( + "result" / Int8ul, # result is either 0 or 1 + "ranking_user_data_size" / Int32ub, # big endian + + "rank" / Int32ub, #int + "user_id_size" / Int32ub, # big endian + "user_id" / Int16ul[len(self.user_id)], + "store_id_size" / Int32ub, # big endian + "store_id" / Int16ul[len(self.store_id)], + "store_name_size" / Int32ub, # big endian + "store_name" / Int16ul[len(self.store_name)], + "nick_name_size" / Int32ub, # big endian + "nick_name" / Int16ul[len(self.nick_name)], + "setting_title_id" / Int32ub, #int + "favorite_hero_log_id" / Int32ub, #int + "favorite_hero_log_awakening_stage" / Int16ub, #short + "favorite_support_log_id" / Int32ub, #int + "favorite_support_log_awakening_stage" / Int16ub, #short + "class_num" / Int16ub, #short + "have_league_score" / Int16ub, #short + ) + + resp_data = resp_struct.build(dict( + result=self.result, + ranking_user_data_size=self.ranking_user_data_size, + + rank=self.rank, + user_id_size=len(self.user_id) * 2, + user_id=[ord(x) for x in self.user_id], + store_id_size=len(self.store_id) * 2, + store_id=[ord(x) for x in self.store_id], + store_name_size=len(self.store_name) * 2, + store_name=[ord(x) for x in self.store_name], + nick_name_size=len(self.nick_name) * 2, + nick_name=[ord(x) for x in self.nick_name], + setting_title_id=self.setting_title_id, + favorite_hero_log_id=self.favorite_hero_log_id, + favorite_hero_log_awakening_stage=self.favorite_hero_log_awakening_stage, + favorite_support_log_id=self.favorite_support_log_id, + favorite_support_log_awakening_stage=self.favorite_support_log_awakening_stage, + class_num=self.class_num, + have_league_score=self.have_league_score, + )) + self.length = len(resp_data) return super().make() + resp_data \ No newline at end of file