From cdb040a65efecceb3d676e65362caf4bc44c5d08 Mon Sep 17 00:00:00 2001 From: UncleJim Date: Fri, 17 Nov 2023 02:03:53 +0000 Subject: [PATCH 01/23] Added round tables, refactored vs_info methonds --- titles/idac/schema/item.py | 66 ++++++++++++++++++++++++++------------ 1 file changed, 46 insertions(+), 20 deletions(-) diff --git a/titles/idac/schema/item.py b/titles/idac/schema/item.py index 80ee7ba..d14fca0 100644 --- a/titles/idac/schema/item.py +++ b/titles/idac/schema/item.py @@ -224,26 +224,41 @@ vs_info = Table( metadata, Column("id", Integer, primary_key=True, nullable=False), Column("user", ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade")), - Column("group_key", String(25)), - Column("win_flg", Integer), - Column("style_car_id", Integer), - Column("course_id", Integer), - Column("course_day", Integer), - Column("players_num", Integer), - Column("winning", Integer), - Column("advantage_1", Integer), - Column("advantage_2", Integer), - Column("advantage_3", Integer), - Column("advantage_4", Integer), - Column("select_course_id", Integer), - Column("select_course_day", Integer), - Column("select_course_random", Integer), - Column("matching_success_sec", Integer), - Column("boost_flag", Integer), - Column("vs_history", Integer), + Column("battle_mode", Integer), + Column("vs_cnt", Integer), + Column("vs_win", Integer), + Column("invalid", Integer), + Column("str", Integer), + Column("str_now", Integer), + Column("lose_now", Integer), Column("break_count", Integer), Column("break_penalty_flag", Integer), - UniqueConstraint("user", "group_key", name="idac_user_vs_info_uk"), + Column("vsinfo_course_data", JSON), + UniqueConstraint("user", "battle_mode", name="idac_user_vs_info_uk"), + mysql_charset="utf8mb4", +) + +round_infos = Table( + "idac_round_info", + metadata, + Column("id", Integer, primary_key=True, nullable=False), + Column("name", String(64)), + Column("season", Integer), + Column("start_dt", TIMESTAMP, server_default=func.now()), + Column("end_dt", TIMESTAMP, server_default=func.now()), + mysql_charset="utf8mb4", +) + +round_info = Table( + "idac_user_round_info", + metadata, + Column("id", Integer, primary_key=True, nullable=False), + Column("user", ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade")), + Column("round_id", Integer), + Column("count", Integer), + Column("win", Integer), + Column("points", Integer), + UniqueConstraint("user", "round_id", name="idac_user_round_info_uk"), mysql_charset="utf8mb4", ) @@ -738,6 +753,16 @@ class IDACItemData(BaseData): return None return result.fetchall() + def get_vs_info_by_mode(self, aime_id: int, battle_mode: int) -> Optional[List[Row]]: + sql = select(vs_info_new).where( + and_(vs_info_new.c.user == aime_id, vs_info_new.c.battle_mode == battle_mode) + ) + + result = self.execute(sql) + if result is None: + return None + return result.fetchall() + def get_stamps(self, aime_id: int) -> Optional[List[Row]]: sql = select(stamp).where( and_( @@ -934,10 +959,11 @@ class IDACItemData(BaseData): return None return result.lastrowid - def put_vs_info(self, aime_id: int, vs_info_data: Dict) -> Optional[int]: + def put_vs_info(self, aime_id: int, battle_mode: int, vs_info_data: Dict) -> Optional[int]: vs_info_data["user"] = aime_id + vs_info_data["battle_mode"] = battle_mode - sql = insert(vs_info).values(**vs_info_data) + sql = insert(vs_info_new).values(**vs_info_data) conflict = sql.on_duplicate_key_update(**vs_info_data) result = self.execute(conflict) From 7b58cae214b85544548b649205c214278eb10d5e Mon Sep 17 00:00:00 2001 From: UncleJim Date: Fri, 17 Nov 2023 02:27:16 +0000 Subject: [PATCH 02/23] hotfix --- titles/idac/schema/item.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/titles/idac/schema/item.py b/titles/idac/schema/item.py index d14fca0..2becc8a 100644 --- a/titles/idac/schema/item.py +++ b/titles/idac/schema/item.py @@ -761,7 +761,7 @@ class IDACItemData(BaseData): result = self.execute(sql) if result is None: return None - return result.fetchall() + return result.fetchone() def get_stamps(self, aime_id: int) -> Optional[List[Row]]: sql = select(stamp).where( From 913987da1d8080b9dc66ac8efa6ab3b152c27b61 Mon Sep 17 00:00:00 2001 From: UncleJim Date: Fri, 17 Nov 2023 02:40:09 +0000 Subject: [PATCH 03/23] refactored vs_info --- titles/idac/season2.py | 107 +++++++++++++++++++++++++++++++++-------- 1 file changed, 86 insertions(+), 21 deletions(-) diff --git a/titles/idac/season2.py b/titles/idac/season2.py index ca57392..d887086 100644 --- a/titles/idac/season2.py +++ b/titles/idac/season2.py @@ -2378,26 +2378,49 @@ class IDACSeason2(IDACBase): }, ) - self.data.item.put_vs_info(user_id, data) - - vs_info = { - "battle_mode": 0, - "vs_cnt": 1, - "vs_win": data.get("win_flg"), - "invalid": 0, - "str": 0, - "str_now": 0, - "lose_now": 0, - "vs_history": data.get("vs_history"), - "course_select_priority": data.get("course_select_priority"), - "vsinfo_course_data": [ - { - "course_id": data.get("course_id"), - "vs_cnt": 1, - "vs_win": data.get("win_flg"), - } - ], - } + vs_info = self.data.item.get_vs_infos_by_mode(user_id, 0) + if vs_info is not None: + vs_info["vs_cnt"] = vs_info["vs_cnt"] + 1 + vs_info["vs_win"] = vs_info["vs_win"] + data.get("win_flg") + vs_info["invalid"] = vs_info["invalid"] + data.get("result") + vs_info["str"] = vs_info["str"] if vs_info["str"] > vs_info["str_now"] else vs_info["str_now"] + vs_info["str_now"] = vs_info["str_now"] + data.get("win_flg") if data.get("win_flg") == 1 else 0 + vs_info["lose_now"] += 1 if data.get("win_flg") == 0 else 0 + vs_info["break_count"] += data.get("break_count") + vs_info["break_penalty_flag"] = data.get("break_penalty_flag") + for course in vs_info["vsinfo_course_data"]: + if course["course_id"] == data.get("course_id"): + course["vs_cnt"] += 1 + course["vs_win"] += data.get("win_flg") + else: + course = {} + course["course_id"] = data.get("course_id") + course["vs_cnt"] = 1 + course["vs_win"] = data.get("win_flg") + vs_info["vsinfo_course_data"].append(course) + self.data.item.put_vs_info(user_id, 0, vs_info) + else: + vs_info = { + "battle_mode": 0, + "vs_cnt": 1, + "vs_win": data.get("win_flg"), + "invalid": data.get("result"), + "str": data.get("win_flg"), + "str_now": data.get("win_flg"), + "lose_now": 1 if data.get("win_flg") == 0 else 0, + "break_count": data.get("break_count"), + "break_penalty_flag": data.get("break_penalty_flag") + #"vs_history": data.get("vs_history"), + #"course_select_priority": data.get("course_select_priority"), + "vsinfo_course_data": [ + { + "course_id": data.get("course_id"), + "vs_cnt": 1, + "vs_win": data.get("win_flg"), + } + ], + } + self.data.item.put_vs_info(user_id, 0, vs_info) return { "status_code": "0", @@ -2476,7 +2499,49 @@ class IDACSeason2(IDACBase): ) # save vs_info in database - self.data.item.put_vs_info(user_id, data) + vs_info = self.data.item.get_vs_infos_by_mode(user_id, 1) + if vs_info is not None: + vs_info["vs_cnt"] = vs_info["vs_cnt"] + 1 + vs_info["vs_win"] = vs_info["vs_win"] + data.get("win_flg") + vs_info["invalid"] = vs_info["invalid"] + data.get("result") + vs_info["str"] = vs_info["str"] if vs_info["str"] > vs_info["str_now"] else vs_info["str_now"] + vs_info["str_now"] = vs_info["str_now"] + data.get("win_flg") if data.get("win_flg") == 1 else 0 + vs_info["lose_now"] += 1 if data.get("win_flg") == 0 else 0 + vs_info["break_count"] += data.get("break_count") + vs_info["break_penalty_flag"] = data.get("break_penalty_flag") + for course in vs_info["vsinfo_course_data"]: + if course["course_id"] == data.get("course_id"): + course["vs_cnt"] += 1 + course["vs_win"] += data.get("win_flg") + else: + course = {} + course["course_id"] = data.get("course_id") + course["vs_cnt"] = 1 + course["vs_win"] = data.get("win_flg") + vs_info["vsinfo_course_data"].append(course) + self.data.item.put_vs_info(user_id, 1, vs_info) + else: + vs_info = { + "battle_mode": 0, + "vs_cnt": 1, + "vs_win": data.get("win_flg"), + "invalid": data.get("result"), + "str": data.get("win_flg"), + "str_now": data.get("win_flg"), + "lose_now": 1 if data.get("win_flg") == 0 else 0, + "break_count": data.get("break_count"), + "break_penalty_flag": data.get("break_penalty_flag") + #"vs_history": data.get("vs_history"), + #"course_select_priority": data.get("course_select_priority"), + "vsinfo_course_data": [ + { + "course_id": data.get("course_id"), + "vs_cnt": 1, + "vs_win": data.get("win_flg"), + } + ], + } + self.data.item.put_vs_info(user_id, 1, vs_info) vs_info = { "battle_mode": 0, From d34bc424c25fba7cf6a82128070f5e35a033018e Mon Sep 17 00:00:00 2001 From: UncleJim Date: Fri, 17 Nov 2023 02:56:40 +0000 Subject: [PATCH 04/23] clean up --- titles/idac/season2.py | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/titles/idac/season2.py b/titles/idac/season2.py index d887086..39cf7d9 100644 --- a/titles/idac/season2.py +++ b/titles/idac/season2.py @@ -2543,25 +2543,6 @@ class IDACSeason2(IDACBase): } self.data.item.put_vs_info(user_id, 1, vs_info) - vs_info = { - "battle_mode": 0, - "vs_cnt": 1, - "vs_win": data.get("win_flg"), - "invalid": 0, - "str": 0, - "str_now": 0, - "lose_now": 0, - "vs_history": data.get("vs_history"), - "course_select_priority": 0, - "vsinfo_course_data": [ - { - "course_id": data.get("course_id"), - "vs_cnt": 1, - "vs_win": data.get("win_flg"), - } - ], - } - return { "status_code": "0", "vsinfo_data": vs_info, From 9c40bad89cac287debd171929d9421dfc4e9ee79 Mon Sep 17 00:00:00 2001 From: UncleJim Date: Fri, 17 Nov 2023 03:00:41 +0000 Subject: [PATCH 05/23] Update titles/idac/schema/item.py --- titles/idac/schema/item.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/titles/idac/schema/item.py b/titles/idac/schema/item.py index 2becc8a..c14e77a 100644 --- a/titles/idac/schema/item.py +++ b/titles/idac/schema/item.py @@ -232,7 +232,7 @@ vs_info = Table( Column("str_now", Integer), Column("lose_now", Integer), Column("break_count", Integer), - Column("break_penalty_flag", Integer), + Column("break_penalty_flag", Boolean), Column("vsinfo_course_data", JSON), UniqueConstraint("user", "battle_mode", name="idac_user_vs_info_uk"), mysql_charset="utf8mb4", From 9605c13e8e667428f9d6382170bfa719e1f51107 Mon Sep 17 00:00:00 2001 From: UncleJim Date: Fri, 17 Nov 2023 03:36:14 +0000 Subject: [PATCH 06/23] implemented simple queue online matchmaking --- titles/idac/matching.py | 80 ++++++++++++++++++++++++++--------------- 1 file changed, 52 insertions(+), 28 deletions(-) diff --git a/titles/idac/matching.py b/titles/idac/matching.py index 396eec8..f4cf06a 100644 --- a/titles/idac/matching.py +++ b/titles/idac/matching.py @@ -8,58 +8,82 @@ from core import CoreConfig from titles.idac.season2 import IDACBase from titles.idac.config import IDACConfig +from random import randint class IDACMatching(resource.Resource): isLeaf = True + SessionQueue = {} + Rooms = {} + def __init__(self, cfg: CoreConfig, game_cfg: IDACConfig) -> None: self.core_config = cfg self.game_config = game_cfg self.base = IDACBase(cfg, game_cfg) self.logger = logging.getLogger("idac") - self.queue = 0 - - def get_matching_state(self): - if self.queue >= 1: - self.queue -= 1 - return 0 + def getMatchingState(self, machineSerial): #We use official state code here + if len(self.SessionQueue) == 1: + self.logger.info(f"IDAC Matching queued player {machineSerial}: empty dict, returned by default") + return self.SessionQueue[machineSerial] + elif self.SessionQueue[machineSerial] == 0: + self.logger.info(f"IDAC Matching queued player {machineSerial}: matched player, returned by default") + return self.SessionQueue[machineSerial] else: - return 1 + for sessionID in self.SessionQueue.keys(): + if sessionID == machineSerial: + continue + if self.SessionQueue[sessionID] == 1: + #uncomment these to process into actual game + #self.SessionQueue[machineSerial] = 0 + #self.SessionQueue[sessionID] = 0 + self.joinRoom(machineSerial, sessionID) + self.logger.info(f"IDAC Matching queued player {machineSerial}: rival {sessionID} found!! return matched state") + return self.SessionQueue[machineSerial] + self.logger.info(f"IDAC Matching queued player {machineSerial}: cannot find any rival, returned by default") + return self.SessionQueue[machineSerial] + + def joinRoom(self, machineSerial, sessionID): #Random room name, It should be handled by game itself in later process + roomName = "INDTA-Zenkoku-Room" #+randint(1, 1001) + self.Rooms[machineSerial] = roomName + self.Rooms[sessionID] = roomName def render_POST(self, req) -> bytes: url = req.uri.decode() req_data = json.loads(req.content.getvalue().decode()) header_application = self.decode_header(req.getAllHeaders()) - user_id = int(header_application["session"]) - - # self.getMatchingStatus(user_id) + machineSerial = header_application["a_serial"] self.logger.info( f"IDAC Matching request from {req.getClientIP()}: {url} - {req_data}" ) - resp = {"status_code": "0"} if url == "/regist": - self.queue = self.queue + 1 + self.SessionQueue[machineSerial] = 1 + self.logger.info(f"IDAC Matching registed player {machineSerial}") + return json.dumps({"status_code": "0"}, ensure_ascii=False).encode("utf-8") + elif url == "/status": - if req_data.get("cancel_flag"): - self.queue = self.queue - 1 - self.logger.info( - f"IDAC Matching endpoint {req.getClientIP()} had quited" - ) + if req_data.get('cancel_flag'): + if machineSerial in self.SessionQueue: + self.SessionQueue.pop(machineSerial) + self.logger.info(f"IDAC Matching endpoint {req.getClientIP()} had quited") + return json.dumps({"status_code": "0", "host": "", "port": self.game_config.server.matching_p2p, "room_name": self.Rooms[machineSerial], "state": 1}, ensure_ascii=False).encode("utf-8") + if machineSerial not in self.Rooms.keys(): + self.Rooms[machineSerial] = "None" + return json.dumps({"status_code": "0", "host": self.game_config.server.matching_host, "port": self.game_config.server.matching_p2p, "room_name": self.Rooms[machineSerial], "state": self.getMatchingState(machineSerial)}, ensure_ascii=False).encode("utf-8") - resp = { - "status_code": "0", - # Only IPv4 is supported - "host": self.game_config.server.matching_host, - "port": self.game_config.server.matching_p2p, - "room_name": "INDTA", - "state": 1, - } - - self.logger.debug(f"Response {resp}") - return json.dumps(resp, ensure_ascii=False).encode("utf-8") + # resp = { + # "status_code": "0", + # # Only IPv4 is supported + # "host": self.game_config.server.matching_host, + # "port": self.game_config.server.matching_p2p, + # "room_name": "INDTA", + # "state": self.get_matching_state(), + # } + # + #self.logger.debug(f"Response {resp}") + #return json.dumps(resp, ensure_ascii=False).encode("utf-8") def decode_header(self, data: Dict) -> Dict: app: str = data[b"application"].decode() From 25ab37561db65172005e47d5268f7cd985bd5ecc Mon Sep 17 00:00:00 2001 From: UncleJim Date: Sun, 19 Nov 2023 11:54:04 +0000 Subject: [PATCH 07/23] fix the logic --- titles/idac/season2.py | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/titles/idac/season2.py b/titles/idac/season2.py index 39cf7d9..d1f6309 100644 --- a/titles/idac/season2.py +++ b/titles/idac/season2.py @@ -2388,16 +2388,18 @@ class IDACSeason2(IDACBase): vs_info["lose_now"] += 1 if data.get("win_flg") == 0 else 0 vs_info["break_count"] += data.get("break_count") vs_info["break_penalty_flag"] = data.get("break_penalty_flag") + course_exists = 0 for course in vs_info["vsinfo_course_data"]: if course["course_id"] == data.get("course_id"): course["vs_cnt"] += 1 course["vs_win"] += data.get("win_flg") - else: - course = {} - course["course_id"] = data.get("course_id") - course["vs_cnt"] = 1 - course["vs_win"] = data.get("win_flg") - vs_info["vsinfo_course_data"].append(course) + course_exists = 1 + if course_exists == 0: + course = {} + course["course_id"] = data.get("course_id") + course["vs_cnt"] = 1 + course["vs_win"] = data.get("win_flg") + vs_info["vsinfo_course_data"].append(course) self.data.item.put_vs_info(user_id, 0, vs_info) else: vs_info = { @@ -2509,16 +2511,18 @@ class IDACSeason2(IDACBase): vs_info["lose_now"] += 1 if data.get("win_flg") == 0 else 0 vs_info["break_count"] += data.get("break_count") vs_info["break_penalty_flag"] = data.get("break_penalty_flag") + course_exists = 0 for course in vs_info["vsinfo_course_data"]: if course["course_id"] == data.get("course_id"): course["vs_cnt"] += 1 course["vs_win"] += data.get("win_flg") - else: - course = {} - course["course_id"] = data.get("course_id") - course["vs_cnt"] = 1 - course["vs_win"] = data.get("win_flg") - vs_info["vsinfo_course_data"].append(course) + course_exists = 1 + if course_exists == 0: + course = {} + course["course_id"] = data.get("course_id") + course["vs_cnt"] = 1 + course["vs_win"] = data.get("win_flg") + vs_info["vsinfo_course_data"].append(course) self.data.item.put_vs_info(user_id, 1, vs_info) else: vs_info = { From 77b22cd77dfc6b0865f7590bc3e0e8b03bc7f256 Mon Sep 17 00:00:00 2001 From: UncleJim Date: Sun, 19 Nov 2023 11:57:32 +0000 Subject: [PATCH 08/23] fix vs_info handles of getdata --- titles/idac/season2.py | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/titles/idac/season2.py b/titles/idac/season2.py index d1f6309..78c859a 100644 --- a/titles/idac/season2.py +++ b/titles/idac/season2.py @@ -716,22 +716,16 @@ class IDACSeason2(IDACBase): for vs in vs_info: vs_info_data.append( { - "battle_mode": 1, - "vs_cnt": 1, - "vs_win": vs["win_flg"], - "invalid": 0, - "str": 0, - "str_now": 0, - "lose_now": 0, - "vs_history": vs["vs_history"], + "battle_mode": vs_info["battle_mode"], + "vs_cnt": vs_info["vs_cnt"], + "vs_win": vs_info["vs_win"], + "invalid": vs_info["invalid"], + "str": vs_info["str"], + "str_now": vs_info["str_now"], + "lose_now": vs_info["lose_now"], + "vs_history": 0, "course_select_priority": 0, - "vsinfo_course_data": [ - { - "course_id": vs["course_id"], - "vs_cnt": 1, - "vs_win": vs["win_flg"], - } - ], + "vsinfo_course_data": vs_info["vsinfo_course_data"], } ) From df9ba9beda67c1283d56540537c25e041f77e6c2 Mon Sep 17 00:00:00 2001 From: UncleJim Date: Mon, 20 Nov 2023 04:40:32 +0000 Subject: [PATCH 09/23] Update titles/idac/season2.py --- titles/idac/season2.py | 144 ++++++++++++++++------------------------- 1 file changed, 54 insertions(+), 90 deletions(-) diff --git a/titles/idac/season2.py b/titles/idac/season2.py index 78c859a..4a6e849 100644 --- a/titles/idac/season2.py +++ b/titles/idac/season2.py @@ -588,6 +588,58 @@ class IDACSeason2(IDACBase): user_id, self.version, updated_stock_data ) + def _update_vs_info(self, user_id: int, battle_mode: int, data: Dict) -> Dict: + vs_info = self.data.item.get_vs_infos_by_mode(user_id, battle_mode) + + if vs_info is not None: + vs_info["vs_cnt"] += 1 + vs_info["vs_win"] = vs_info["vs_win"] + data.get("win_flg") + vs_info["invalid"] = vs_info["invalid"] + data.get("result") + vs_info["str_now"] = vs_info["str_now"] + data.get("win_flg") if data.get("win_flg") == 1 else 0 + vs_info["str"] = vs_info["str"] if vs_info["str"] > vs_info["str_now"] else vs_info["str_now"] + vs_info["lose_now"] += 1 if data.get("win_flg") == 0 else 0 + vs_info["break_count"] += data.get("break_count") + vs_info["break_penalty_flag"] = data.get("break_penalty_flag") + + course_not_exists = True + for course in vs_info["vsinfo_course_data"]: + if course["course_id"] == data.get("course_id"): + course["vs_cnt"] += 1 + course["vs_win"] += data.get("win_flg") + course_not_exists = False + + if course_not_exists: + course = {} + course["course_id"] = data.get("course_id") + course["vs_cnt"] = 1 + course["vs_win"] = data.get("win_flg") + vs_info["vsinfo_course_data"].append(course) + else: + vs_info = { + "battle_mode": battle_mode, + "vs_cnt": 1, + "vs_win": data.get("win_flg"), + "invalid": data.get("result"), + "str": data.get("win_flg"), + "str_now": data.get("win_flg"), + "lose_now": 1 if data.get("win_flg") == 0 else 0, + "break_count": data.get("break_count"), + "break_penalty_flag": data.get("break_penalty_flag") + "vsinfo_course_data": [ + { + "course_id": data.get("course_id"), + "vs_cnt": 1, + "vs_win": data.get("win_flg") + } + ], + } + + self.data.item.put_vs_info(user_id, battle_mode, vs_info) + + vs_info["vs_history"] = data.get("vs_history") + vs_info["course_select_priority"] = data.get("course_select_priority") + return vs_info + def handle_user_getdata_request(self, data: Dict, headers: Dict): user_id = int(headers["session"]) @@ -2372,51 +2424,7 @@ class IDACSeason2(IDACBase): }, ) - vs_info = self.data.item.get_vs_infos_by_mode(user_id, 0) - if vs_info is not None: - vs_info["vs_cnt"] = vs_info["vs_cnt"] + 1 - vs_info["vs_win"] = vs_info["vs_win"] + data.get("win_flg") - vs_info["invalid"] = vs_info["invalid"] + data.get("result") - vs_info["str"] = vs_info["str"] if vs_info["str"] > vs_info["str_now"] else vs_info["str_now"] - vs_info["str_now"] = vs_info["str_now"] + data.get("win_flg") if data.get("win_flg") == 1 else 0 - vs_info["lose_now"] += 1 if data.get("win_flg") == 0 else 0 - vs_info["break_count"] += data.get("break_count") - vs_info["break_penalty_flag"] = data.get("break_penalty_flag") - course_exists = 0 - for course in vs_info["vsinfo_course_data"]: - if course["course_id"] == data.get("course_id"): - course["vs_cnt"] += 1 - course["vs_win"] += data.get("win_flg") - course_exists = 1 - if course_exists == 0: - course = {} - course["course_id"] = data.get("course_id") - course["vs_cnt"] = 1 - course["vs_win"] = data.get("win_flg") - vs_info["vsinfo_course_data"].append(course) - self.data.item.put_vs_info(user_id, 0, vs_info) - else: - vs_info = { - "battle_mode": 0, - "vs_cnt": 1, - "vs_win": data.get("win_flg"), - "invalid": data.get("result"), - "str": data.get("win_flg"), - "str_now": data.get("win_flg"), - "lose_now": 1 if data.get("win_flg") == 0 else 0, - "break_count": data.get("break_count"), - "break_penalty_flag": data.get("break_penalty_flag") - #"vs_history": data.get("vs_history"), - #"course_select_priority": data.get("course_select_priority"), - "vsinfo_course_data": [ - { - "course_id": data.get("course_id"), - "vs_cnt": 1, - "vs_win": data.get("win_flg"), - } - ], - } - self.data.item.put_vs_info(user_id, 0, vs_info) + vs_info = _update_vs_info(user_id, 0, data) return { "status_code": "0", @@ -2495,51 +2503,7 @@ class IDACSeason2(IDACBase): ) # save vs_info in database - vs_info = self.data.item.get_vs_infos_by_mode(user_id, 1) - if vs_info is not None: - vs_info["vs_cnt"] = vs_info["vs_cnt"] + 1 - vs_info["vs_win"] = vs_info["vs_win"] + data.get("win_flg") - vs_info["invalid"] = vs_info["invalid"] + data.get("result") - vs_info["str"] = vs_info["str"] if vs_info["str"] > vs_info["str_now"] else vs_info["str_now"] - vs_info["str_now"] = vs_info["str_now"] + data.get("win_flg") if data.get("win_flg") == 1 else 0 - vs_info["lose_now"] += 1 if data.get("win_flg") == 0 else 0 - vs_info["break_count"] += data.get("break_count") - vs_info["break_penalty_flag"] = data.get("break_penalty_flag") - course_exists = 0 - for course in vs_info["vsinfo_course_data"]: - if course["course_id"] == data.get("course_id"): - course["vs_cnt"] += 1 - course["vs_win"] += data.get("win_flg") - course_exists = 1 - if course_exists == 0: - course = {} - course["course_id"] = data.get("course_id") - course["vs_cnt"] = 1 - course["vs_win"] = data.get("win_flg") - vs_info["vsinfo_course_data"].append(course) - self.data.item.put_vs_info(user_id, 1, vs_info) - else: - vs_info = { - "battle_mode": 0, - "vs_cnt": 1, - "vs_win": data.get("win_flg"), - "invalid": data.get("result"), - "str": data.get("win_flg"), - "str_now": data.get("win_flg"), - "lose_now": 1 if data.get("win_flg") == 0 else 0, - "break_count": data.get("break_count"), - "break_penalty_flag": data.get("break_penalty_flag") - #"vs_history": data.get("vs_history"), - #"course_select_priority": data.get("course_select_priority"), - "vsinfo_course_data": [ - { - "course_id": data.get("course_id"), - "vs_cnt": 1, - "vs_win": data.get("win_flg"), - } - ], - } - self.data.item.put_vs_info(user_id, 1, vs_info) + vs_info = _update_vs_info(user_id, 1, data) return { "status_code": "0", From 4d5823a4f749c2315beb60afc9264f80fd1c9538 Mon Sep 17 00:00:00 2001 From: UncleJim Date: Mon, 20 Nov 2023 04:42:28 +0000 Subject: [PATCH 10/23] Update titles/idac/season2.py --- titles/idac/season2.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/titles/idac/season2.py b/titles/idac/season2.py index 4a6e849..e11b678 100644 --- a/titles/idac/season2.py +++ b/titles/idac/season2.py @@ -588,10 +588,10 @@ class IDACSeason2(IDACBase): user_id, self.version, updated_stock_data ) - def _update_vs_info(self, user_id: int, battle_mode: int, data: Dict) -> Dict: - vs_info = self.data.item.get_vs_infos_by_mode(user_id, battle_mode) - - if vs_info is not None: + def _update_vs_info(self, user_id: int, battle_mode: int, data: Dict) -> Dict: + vs_info = self.data.item.get_vs_infos_by_mode(user_id, battle_mode) + + if vs_info is not None: vs_info["vs_cnt"] += 1 vs_info["vs_win"] = vs_info["vs_win"] + data.get("win_flg") vs_info["invalid"] = vs_info["invalid"] + data.get("result") @@ -600,14 +600,14 @@ class IDACSeason2(IDACBase): vs_info["lose_now"] += 1 if data.get("win_flg") == 0 else 0 vs_info["break_count"] += data.get("break_count") vs_info["break_penalty_flag"] = data.get("break_penalty_flag") - + course_not_exists = True for course in vs_info["vsinfo_course_data"]: if course["course_id"] == data.get("course_id"): course["vs_cnt"] += 1 course["vs_win"] += data.get("win_flg") course_not_exists = False - + if course_not_exists: course = {} course["course_id"] = data.get("course_id") From 581c1506a18ff1b42cd69fa3389c3a8169b69d84 Mon Sep 17 00:00:00 2001 From: UncleJim Date: Mon, 20 Nov 2023 04:50:23 +0000 Subject: [PATCH 11/23] Update titles/idac/season2.py --- titles/idac/season2.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/titles/idac/season2.py b/titles/idac/season2.py index e11b678..4f780e5 100644 --- a/titles/idac/season2.py +++ b/titles/idac/season2.py @@ -588,7 +588,7 @@ class IDACSeason2(IDACBase): user_id, self.version, updated_stock_data ) - def _update_vs_info(self, user_id: int, battle_mode: int, data: Dict) -> Dict: + def _update_vs_info(self, user_id: int, battle_mode: int, data: Dict) -> Dict: vs_info = self.data.item.get_vs_infos_by_mode(user_id, battle_mode) if vs_info is not None: @@ -624,7 +624,7 @@ class IDACSeason2(IDACBase): "str_now": data.get("win_flg"), "lose_now": 1 if data.get("win_flg") == 0 else 0, "break_count": data.get("break_count"), - "break_penalty_flag": data.get("break_penalty_flag") + "break_penalty_flag": data.get("break_penalty_flag"), "vsinfo_course_data": [ { "course_id": data.get("course_id"), From ecd63c02e32b530352abcf7585663cb1b5fa9530 Mon Sep 17 00:00:00 2001 From: UncleJim Date: Mon, 20 Nov 2023 04:54:05 +0000 Subject: [PATCH 12/23] Update titles/idac/schema/item.py --- titles/idac/schema/item.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/titles/idac/schema/item.py b/titles/idac/schema/item.py index c14e77a..b2253af 100644 --- a/titles/idac/schema/item.py +++ b/titles/idac/schema/item.py @@ -233,7 +233,7 @@ vs_info = Table( Column("lose_now", Integer), Column("break_count", Integer), Column("break_penalty_flag", Boolean), - Column("vsinfo_course_data", JSON), + Column("vsinfo_course_data", JSON), UniqueConstraint("user", "battle_mode", name="idac_user_vs_info_uk"), mysql_charset="utf8mb4", ) From b1026fdec06b338b33ac171ac9dd122c835d840e Mon Sep 17 00:00:00 2001 From: UncleJim Date: Fri, 5 Jan 2024 04:04:31 +0000 Subject: [PATCH 13/23] splited course_info from idac_user_vs_info table --- titles/idac/schema/item.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/titles/idac/schema/item.py b/titles/idac/schema/item.py index b2253af..387c2d5 100644 --- a/titles/idac/schema/item.py +++ b/titles/idac/schema/item.py @@ -225,19 +225,29 @@ vs_info = Table( Column("id", Integer, primary_key=True, nullable=False), Column("user", ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade")), Column("battle_mode", Integer), - Column("vs_cnt", Integer), - Column("vs_win", Integer), Column("invalid", Integer), Column("str", Integer), Column("str_now", Integer), Column("lose_now", Integer), Column("break_count", Integer), Column("break_penalty_flag", Boolean), - Column("vsinfo_course_data", JSON), UniqueConstraint("user", "battle_mode", name="idac_user_vs_info_uk"), mysql_charset="utf8mb4", ) +vs_info = Table( + "idac_user_vs_course_info", + metadata, + Column("id", Integer, primary_key=True, nullable=False), + Column("user", ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade")), + Column("battle_mode", Integer), + Column("course_id", Integer), + Column("vs_cnt", Integer), + Column("vs_win", Integer), + UniqueConstraint("user", "battle_mode", "course_id", name="idac_user_vs_course_info_uk"), + mysql_charset="utf8mb4", +) + round_infos = Table( "idac_round_info", metadata, From a2975fc979403528e23c0c6d97d4f3e35d2f4e78 Mon Sep 17 00:00:00 2001 From: UncleJim Date: Fri, 5 Jan 2024 04:07:01 +0000 Subject: [PATCH 14/23] hotfix --- titles/idac/schema/item.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/titles/idac/schema/item.py b/titles/idac/schema/item.py index 387c2d5..b808c6d 100644 --- a/titles/idac/schema/item.py +++ b/titles/idac/schema/item.py @@ -235,7 +235,7 @@ vs_info = Table( mysql_charset="utf8mb4", ) -vs_info = Table( +vs_course_info = Table( "idac_user_vs_course_info", metadata, Column("id", Integer, primary_key=True, nullable=False), From 39031757f4a65db75efab3cdad38355fd512bd82 Mon Sep 17 00:00:00 2001 From: UncleJim Date: Sat, 6 Jan 2024 08:52:35 +0000 Subject: [PATCH 15/23] Implmented course_info query method --- titles/idac/schema/item.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/titles/idac/schema/item.py b/titles/idac/schema/item.py index b808c6d..d60f620 100644 --- a/titles/idac/schema/item.py +++ b/titles/idac/schema/item.py @@ -764,8 +764,8 @@ class IDACItemData(BaseData): return result.fetchall() def get_vs_info_by_mode(self, aime_id: int, battle_mode: int) -> Optional[List[Row]]: - sql = select(vs_info_new).where( - and_(vs_info_new.c.user == aime_id, vs_info_new.c.battle_mode == battle_mode) + sql = select(vs_info).where( + and_(vs_info.c.user == aime_id, vs_info.c.battle_mode == battle_mode) ) result = self.execute(sql) @@ -773,6 +773,21 @@ class IDACItemData(BaseData): return None return result.fetchone() + #This method returns a list of course_info + def get_vs_course_infos_by_mode(self, aime_id: int, battle_mode: int) -> Optional[List[Row]]: + sql = select(vs_course_info).where(vs_info.c.user == aime_id, vs_info.c.battle_mode == battle_mode) + + result = self.execute(sql) + if result is None: + return None + + d, a = {}, [] + for row in result: + for column, value in row.items(): + d = {**d, **{column: value}} + a.append(d) + return a + def get_stamps(self, aime_id: int) -> Optional[List[Row]]: sql = select(stamp).where( and_( From a42993aca746bdee83f0ca192e0db8a6495f6590 Mon Sep 17 00:00:00 2001 From: UncleJim Date: Sat, 6 Jan 2024 14:01:14 +0000 Subject: [PATCH 16/23] implement new vs_info saving method --- titles/idac/season2.py | 118 +++++++++++++++++++++++++++++------------ 1 file changed, 84 insertions(+), 34 deletions(-) diff --git a/titles/idac/season2.py b/titles/idac/season2.py index 4f780e5..6f4e402 100644 --- a/titles/idac/season2.py +++ b/titles/idac/season2.py @@ -592,49 +592,79 @@ class IDACSeason2(IDACBase): vs_info = self.data.item.get_vs_infos_by_mode(user_id, battle_mode) if vs_info is not None: - vs_info["vs_cnt"] += 1 - vs_info["vs_win"] = vs_info["vs_win"] + data.get("win_flg") + vs_info = vs_info._asdict() vs_info["invalid"] = vs_info["invalid"] + data.get("result") vs_info["str_now"] = vs_info["str_now"] + data.get("win_flg") if data.get("win_flg") == 1 else 0 vs_info["str"] = vs_info["str"] if vs_info["str"] > vs_info["str_now"] else vs_info["str_now"] vs_info["lose_now"] += 1 if data.get("win_flg") == 0 else 0 vs_info["break_count"] += data.get("break_count") vs_info["break_penalty_flag"] = data.get("break_penalty_flag") - + + self.data.item.put_vs_info(user_id, battle_mode, vs_info) + + vs_info["vs_cnt"] = 0 + vs_info["vs_win"] = 0 + vs_info["vsinfo_course_data"] = [] + + vs_courses_info = self.data.item.get_vs_course_info_by_mode(user_id, battle_mode) course_not_exists = True - for course in vs_info["vsinfo_course_data"]: - if course["course_id"] == data.get("course_id"): - course["vs_cnt"] += 1 - course["vs_win"] += data.get("win_flg") - course_not_exists = False - + + if vs_courses_info is not None: + for course in vs_courses_info: + course = course._asdict() + if course["course_id"] == data.get("course_id"): + course["vs_cnt"] += 1 + course["vs_win"] += data.get("win_flg") + vs_info["vs_cnt"] += course["vs_cnt"] + vs_info["vs_win"] += course["vs_win"] + self.data.item.put_vs_course_info(user_id, battle_mode, course) + course_not_exists = False + else: + vs_info["vs_cnt"] += course["vs_cnt"] + vs_info["vs_win"] += course["vs_win"] + vs_info["vsinfo_course_data"].append(course) + if course_not_exists: course = {} course["course_id"] = data.get("course_id") course["vs_cnt"] = 1 course["vs_win"] = data.get("win_flg") + vs_info["vs_cnt"] += course["vs_cnt"] + vs_info["vs_win"] += course["vs_win"] vs_info["vsinfo_course_data"].append(course) + self.data.item.put_vs_course_info(user_id, battle_mode, course) else: vs_info = { "battle_mode": battle_mode, - "vs_cnt": 1, - "vs_win": data.get("win_flg"), + #"vs_cnt": 1, + #"vs_win": data.get("win_flg"), "invalid": data.get("result"), "str": data.get("win_flg"), "str_now": data.get("win_flg"), "lose_now": 1 if data.get("win_flg") == 0 else 0, "break_count": data.get("break_count"), "break_penalty_flag": data.get("break_penalty_flag"), - "vsinfo_course_data": [ - { - "course_id": data.get("course_id"), - "vs_cnt": 1, - "vs_win": data.get("win_flg") - } - ], + #"vsinfo_course_data": [ + # { + # "course_id": data.get("course_id"), + # "vs_cnt": 1, + # "vs_win": data.get("win_flg") + # } + #], } + self.data.item.put_vs_info(user_id, battle_mode, vs_info) - self.data.item.put_vs_info(user_id, battle_mode, vs_info) + course_info = { + "course_id": data.get("course_id"), + "vs_cnt": 1, + "vs_win": data.get("win_flg") + } + self.data.item.put_vs_course_info(user_id, battle_mode, course_info) + + vs_info["vs_cnt"] = 1 + vs_info["vs_win"] = data.get("win_flg") + vs_info["vsinfo_course_data"] = [] + vs_info["vsinfo_course_data"].append(course_info) vs_info["vs_history"] = data.get("vs_history") vs_info["course_select_priority"] = data.get("course_select_priority") @@ -765,21 +795,41 @@ class IDACSeason2(IDACBase): # get the users vs info data vs_info_data = [] vs_info = self.data.item.get_vs_infos(user_id) - for vs in vs_info: - vs_info_data.append( - { - "battle_mode": vs_info["battle_mode"], - "vs_cnt": vs_info["vs_cnt"], - "vs_win": vs_info["vs_win"], - "invalid": vs_info["invalid"], - "str": vs_info["str"], - "str_now": vs_info["str_now"], - "lose_now": vs_info["lose_now"], - "vs_history": 0, - "course_select_priority": 0, - "vsinfo_course_data": vs_info["vsinfo_course_data"], - } - ) + if vs_info is not None: + for vs in vs_info: + vs = vs._asdict() + vs_courses_info = self.data.item.get_vs_course_info_by_mode(user_id, vs["battle_mode"]) + total_vs_win = 0 + total_vs_cnt = 0 + courses_info = [] + if vs_courses_info is not None: + for course in vs_courses_info: + tmp = course._asdict() + del tmp["id"] + del tmp["user"] + del tmp["battle_mode"] + + total_vs_win += tmp["vs_win"] + total_vs_cnt += tmp["vs_cnt"] + + courses_info.append(tmp) + + + vs_info_data.append( + { + "battle_mode": vs["battle_mode"], + "vs_cnt": total_vs_cnt, + "vs_win": total_vs_win, + "invalid": vs["invalid"], + "str": vs["str"], + "str_now": vs["str_now"], + "lose_now": vs["lose_now"], + "vs_history": 0, + "course_select_priority": 0, + "vsinfo_course_data": courses_info, + } + ) + # get the user's car cars = self.data.item.get_cars(self.version, user_id, only_pickup=True) From f225b732f2eaeffc21e6dc768b5013f3e8f0f000 Mon Sep 17 00:00:00 2001 From: UncleJim Date: Sat, 6 Jan 2024 14:04:47 +0000 Subject: [PATCH 17/23] implement new vs_info saving method --- titles/idac/schema/item.py | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/titles/idac/schema/item.py b/titles/idac/schema/item.py index d60f620..68d1729 100644 --- a/titles/idac/schema/item.py +++ b/titles/idac/schema/item.py @@ -780,13 +780,7 @@ class IDACItemData(BaseData): result = self.execute(sql) if result is None: return None - - d, a = {}, [] - for row in result: - for column, value in row.items(): - d = {**d, **{column: value}} - a.append(d) - return a + return result.fetchall() def get_stamps(self, aime_id: int) -> Optional[List[Row]]: sql = select(stamp).where( @@ -988,7 +982,7 @@ class IDACItemData(BaseData): vs_info_data["user"] = aime_id vs_info_data["battle_mode"] = battle_mode - sql = insert(vs_info_new).values(**vs_info_data) + sql = insert(vs_info).values(**vs_info_data) conflict = sql.on_duplicate_key_update(**vs_info_data) result = self.execute(conflict) @@ -997,6 +991,19 @@ class IDACItemData(BaseData): return None return result.lastrowid + def put_vs_course_info(self, aime_id: int, battle_mode: int, course_info_data: Dict) -> Optional[int]: + course_info_data["user"] = aime_id + course_info_data["battle_mode"] = battle_mode + + sql = insert(vs_course_info).values(**course_info_data) + conflict = sql.on_duplicate_key_update(**course_info_data) + result = self.execute(conflict) + + if result is None: + self.logger.warn(f"put_vs_course_info: Failed to update! aime_id: {aime_id}") + return None + return result.lastrowid + def put_stamp( self, aime_id: int, stamp_data: Dict ) -> Optional[int]: From 3426a37d2dc13b7167252d6a2f2ee6ec52415eba Mon Sep 17 00:00:00 2001 From: UncleJim Date: Sat, 6 Jan 2024 14:05:28 +0000 Subject: [PATCH 18/23] fix typo --- titles/idac/season2.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/titles/idac/season2.py b/titles/idac/season2.py index 6f4e402..6b94c57 100644 --- a/titles/idac/season2.py +++ b/titles/idac/season2.py @@ -589,7 +589,7 @@ class IDACSeason2(IDACBase): ) def _update_vs_info(self, user_id: int, battle_mode: int, data: Dict) -> Dict: - vs_info = self.data.item.get_vs_infos_by_mode(user_id, battle_mode) + vs_info = self.data.item.get_vs_info_by_mode(user_id, battle_mode) if vs_info is not None: vs_info = vs_info._asdict() From acc3a63030e48497b3eeaa066103e900fde120e9 Mon Sep 17 00:00:00 2001 From: UncleJim Date: Mon, 8 Jan 2024 02:38:35 +0000 Subject: [PATCH 19/23] removed excess columns --- titles/idac/season2.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/titles/idac/season2.py b/titles/idac/season2.py index 6b94c57..89379ec 100644 --- a/titles/idac/season2.py +++ b/titles/idac/season2.py @@ -593,6 +593,9 @@ class IDACSeason2(IDACBase): if vs_info is not None: vs_info = vs_info._asdict() + del vs_info["id"] + del vs_info["user"] + vs_info["invalid"] = vs_info["invalid"] + data.get("result") vs_info["str_now"] = vs_info["str_now"] + data.get("win_flg") if data.get("win_flg") == 1 else 0 vs_info["str"] = vs_info["str"] if vs_info["str"] > vs_info["str_now"] else vs_info["str_now"] @@ -612,6 +615,9 @@ class IDACSeason2(IDACBase): if vs_courses_info is not None: for course in vs_courses_info: course = course._asdict() + del vs_info["id"] + del vs_info["user"] + if course["course_id"] == data.get("course_id"): course["vs_cnt"] += 1 course["vs_win"] += data.get("win_flg") From a883450e5cb6b992540b3c6525cf2f3922b3cf79 Mon Sep 17 00:00:00 2001 From: UncleJim Date: Mon, 8 Jan 2024 02:39:31 +0000 Subject: [PATCH 20/23] oops --- titles/idac/season2.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/titles/idac/season2.py b/titles/idac/season2.py index 89379ec..71109f6 100644 --- a/titles/idac/season2.py +++ b/titles/idac/season2.py @@ -615,8 +615,8 @@ class IDACSeason2(IDACBase): if vs_courses_info is not None: for course in vs_courses_info: course = course._asdict() - del vs_info["id"] - del vs_info["user"] + del course["id"] + del course["user"] if course["course_id"] == data.get("course_id"): course["vs_cnt"] += 1 From 3dd23d4b53a56336946c7bf86a6cb1c15c3a778b Mon Sep 17 00:00:00 2001 From: UncleJim Date: Mon, 8 Jan 2024 03:09:17 +0000 Subject: [PATCH 21/23] Added past round event data for season 1 --- titles/idac/season2.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/titles/idac/season2.py b/titles/idac/season2.py index 71109f6..7d5130d 100644 --- a/titles/idac/season2.py +++ b/titles/idac/season2.py @@ -1910,6 +1910,21 @@ class IDACSeason2(IDACBase): "past_season_timetrial_data": past_timetrial_data, } + def handle_user_getpastseasonrounddata_request(self, data: Dict, headers: Dict): + user_id = headers["session"] + season_id = data.get("season_id") + + # so to get the season 1 data just subtract 1 from the season id + past_timetrial_data = self._generate_time_trial_data(season_id - 1, user_id) + + # TODO: get the current season timetrial data somehow, because after requesting + # GetPastSeasonTAData the game will NOT request GetTAData?! + return { + "status_code": "0", + "season_id": season_id, + "past_season_round_event_data": [{"count": 0,"win": 0,"rank": 0,"area_rank": 0,"point": 0,"total_round_point": 0,"round_name": "DAC稼働記念 1stラウンド","round_id": 0},{"count": 0,"win": 0,"rank": 0,"area_rank": 0,"point": 0,"total_round_point": 0,"round_name": "シーズン1 2ndラウンド","round_id": 1},{"count": 0,"win": 0,"rank": 0,"area_rank": 0,"point": 0,"total_round_point": 0,"round_name": "シーズン1 3rdラウンド","round_id": 2},{"count": 0,"win": 0,"rank": 0,"area_rank": 0,"point": 0,"total_round_point": 0,"round_name": "シーズン1 4thラウンド","round_id": 3},{"count": 0,"win": 0,"rank": 0,"area_rank": 0,"point": 0,"total_round_point": 0,"round_name": "シーズン1 5thラウンド","round_id": 4},{"count": 0,"win": 0,"rank": 0,"area_rank": 0,"point": 0,"total_round_point": 0,"round_name": "シーズン1 6thラウンド","round_id": 5},{"count": 0,"win": 0,"rank": 0,"area_rank": 0,"point": 0,"total_round_point": 0,"round_name": "シーズン1 7thラウンド","round_id": 6},{"count": 0,"win": 0,"rank": 0,"area_rank": 0,"point": 0,"total_round_point": 0,"round_name": "シーズン1 8thラウンド","round_id": 7},{"count": 0,"win": 0,"rank": 0,"area_rank": 0,"point": 0,"total_round_point": 0,"round_name": "シーズン1 9thラウンド","round_id": 8}] + } + def handle_user_gettadata_request(self, data: Dict, headers: Dict): user_id = headers["session"] From 4c1603db091451c6734abd7de0b7a8f94c8153e9 Mon Sep 17 00:00:00 2001 From: UncleJim Date: Mon, 8 Jan 2024 03:10:34 +0000 Subject: [PATCH 22/23] Update titles/idac/season2.py --- titles/idac/season2.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/titles/idac/season2.py b/titles/idac/season2.py index 7d5130d..d948534 100644 --- a/titles/idac/season2.py +++ b/titles/idac/season2.py @@ -1916,9 +1916,7 @@ class IDACSeason2(IDACBase): # so to get the season 1 data just subtract 1 from the season id past_timetrial_data = self._generate_time_trial_data(season_id - 1, user_id) - - # TODO: get the current season timetrial data somehow, because after requesting - # GetPastSeasonTAData the game will NOT request GetTAData?! + return { "status_code": "0", "season_id": season_id, From c0078b252f168505bccf32932d6e4db675d19f6d Mon Sep 17 00:00:00 2001 From: UncleJim Date: Mon, 8 Jan 2024 10:21:30 +0000 Subject: [PATCH 23/23] Update titles/idac/const.py --- titles/idac/const.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/titles/idac/const.py b/titles/idac/const.py index cfae20e..800c899 100644 --- a/titles/idac/const.py +++ b/titles/idac/const.py @@ -6,6 +6,9 @@ class IDACConstants(): VER_IDAC_SEASON_1 = 0 VER_IDAC_SEASON_2 = 1 + BATTLE_MODE_ONLINE = 0 + BATTLE_MODE_OFFLINE = 1 + VERSION_STRING = ( "Initial D THE ARCADE Season 1", "Initial D THE ARCADE Season 2",