From 5155353360e00e752b21c019d356d4f00bc92d03 Mon Sep 17 00:00:00 2001 From: Midorica Date: Mon, 26 Jun 2023 19:30:03 -0400 Subject: [PATCH] fixing chapter progression after chapter 2 on SAO --- titles/sao/base.py | 16 +++++++++++----- titles/sao/schema/static.py | 8 ++++++++ 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/titles/sao/base.py b/titles/sao/base.py index ece4654..58bc3df 100644 --- a/titles/sao/base.py +++ b/titles/sao/base.py @@ -720,13 +720,19 @@ class SaoBase: if quest_clear_flag is True: # Save stage progression - to be revised to avoid saving worse score - # Reference Episode.csv but Chapter 3,4 and 5 reports id 0 + # Reference Episode.csv but Chapter 2,3,4 and 5 reports id -1, match using /10 + last digits if episode_id > 10000 and episode_id < 11000: + # Starts at 1001 episode_id = episode_id - 9000 - elif episode_id > 20000 and episode_id < 21000: - episode_id = episode_id - 19000 - elif episode_id > 30000 and episode_id < 31000: - episode_id = episode_id - 29000 + elif episode_id > 20000: + # Starts at 2001 + stage_id = str(episode_id)[-2:] + episode_id = episode_id / 10 + episode_id = int(episode_id) + int(stage_id) + + # Match episode_id with the questSceneId saved in the DB through sortNo + questId = self.game_data.static.get_quests_id(episode_id) + episode_id = questId[2] self.game_data.item.put_player_quest(user_id, episode_id, quest_clear_flag, clear_time, combo_num, total_damage, concurrent_destroying_num) diff --git a/titles/sao/schema/static.py b/titles/sao/schema/static.py index 670e3b2..ce9a6a9 100644 --- a/titles/sao/schema/static.py +++ b/titles/sao/schema/static.py @@ -267,6 +267,14 @@ class SaoStaticData(BaseData): return None return result.lastrowid + def get_quests_id(self, sortNo: int) -> Optional[Dict]: + sql = quest.select(quest.c.sortNo == sortNo) + + result = self.execute(sql) + if result is None: + return None + return result.fetchone() + def get_quests_ids(self, version: int, enabled: bool) -> Optional[List[Dict]]: sql = quest.select(quest.c.version == version and quest.c.enabled == enabled).order_by( quest.c.questSceneId.asc()