From 62b62db5b58c8c63b93644e5518b8e89af67e983 Mon Sep 17 00:00:00 2001 From: Kevin Trocolli Date: Sat, 18 Mar 2023 12:26:57 -0400 Subject: [PATCH] wacca: fix favorites, purchasing and unlocking songs, incorrectly displayed grades --- titles/wacca/base.py | 23 ++++++++--------------- titles/wacca/handlers/helpers.py | 16 +++++++++++++++- titles/wacca/handlers/user_info.py | 6 +++--- titles/wacca/index.py | 2 +- 4 files changed, 27 insertions(+), 20 deletions(-) diff --git a/titles/wacca/base.py b/titles/wacca/base.py index bc0c09a..275f380 100644 --- a/titles/wacca/base.py +++ b/titles/wacca/base.py @@ -635,14 +635,14 @@ class WaccaBase: new_tickets.append([ticket["id"], ticket["ticket_id"], 9999999999]) for item in req.itemsUsed: - if item.itemType == WaccaConstants.ITEM_TYPES["wp"]: + if item.itemType == WaccaConstants.ITEM_TYPES["wp"] and not self.game_config.mods.infinite_wp: if current_wp >= item.quantity: current_wp -= item.quantity self.data.profile.spend_wp(req.profileId, item.quantity) else: return BaseResponse().make() - elif item.itemType == WaccaConstants.ITEM_TYPES["ticket"]: + elif item.itemType == WaccaConstants.ITEM_TYPES["ticket"] and not self.game_config.mods.infinite_tickets: for x in range(len(new_tickets)): if new_tickets[x][1] == item.itemId: self.data.item.spend_ticket(new_tickets[x][0]) @@ -880,7 +880,7 @@ class WaccaBase: user_id = profile["user"] resp.currentWp = profile["wp"] - if req.purchaseType == PurchaseType.PurchaseTypeWP: + if req.purchaseType == PurchaseType.PurchaseTypeWP and not self.game_config.mods.infinite_wp: resp.currentWp -= req.cost self.data.profile.spend_wp(req.profileId, req.cost) @@ -1070,19 +1070,12 @@ class WaccaBase: ): if item.quantity > WaccaConstants.Difficulty.HARD.value: old_score = self.data.score.get_best_score( - user_id, item.itemId, item.quantity + user_id, item.itemId, item.quantity + ) + if not old_score: + self.data.score.put_best_score( + user_id, item.itemId, item.quantity, 0, [0] * 5, [0] * 13, 0, 0 ) - if not old_score: - self.data.score.put_best_score( - user_id, - item.itemId, - item.quantity, - 0, - [0] * 5, - [0] * 13, - 0, - 0, - ) if item.quantity == 0: item.quantity = WaccaConstants.Difficulty.HARD.value diff --git a/titles/wacca/handlers/helpers.py b/titles/wacca/handlers/helpers.py index 9e9847a..02b8bd7 100644 --- a/titles/wacca/handlers/helpers.py +++ b/titles/wacca/handlers/helpers.py @@ -577,7 +577,21 @@ class SongDetailGradeCountsV2(SongDetailGradeCountsV1): self.ssspCt = counts[12] def make(self) -> List: - return super().make() + [self.spCt, self.sspCt, self.ssspCt] + return [ + self.dCt, + self.cCt, + self.bCt, + self.aCt, + self.aaCt, + self.aaaCt, + self.sCt, + self.spCt, + self.ssCt, + self.sspCt, + self.sssCt, + self.ssspCt, + self.masterCt, + ] class BestScoreDetailV1: diff --git a/titles/wacca/handlers/user_info.py b/titles/wacca/handlers/user_info.py index 8c67db9..bf6b74b 100644 --- a/titles/wacca/handlers/user_info.py +++ b/titles/wacca/handlers/user_info.py @@ -11,9 +11,9 @@ class UserInfoUpdateRequest(BaseRequest): self.profileId = int(self.params[0]) self.optsUpdated: List[UserOption] = [] self.unknown2: List = self.params[2] - self.datesUpdated: List[DateUpdate] = [] - self.favoritesAdded: List[int] = self.params[4] - self.favoritesRemoved: List[int] = self.params[5] + self.datesUpdated: List[DateUpdate] = [] + self.favoritesRemoved: List[int] = self.params[4] + self.favoritesAdded: List[int] = self.params[5] for x in self.params[1]: self.optsUpdated.append(UserOption(x[0], x[1])) diff --git a/titles/wacca/index.py b/titles/wacca/index.py index 0b51849..a59cda1 100644 --- a/titles/wacca/index.py +++ b/titles/wacca/index.py @@ -102,7 +102,7 @@ class WaccaServlet: resp.message = "不正なリクエスト エラーです" return end(resp.make()) - if "/api/" in url_path: + if "api/" in url_path: func_to_find = ( "handle_" + url_path.partition("api/")[2].replace("/", "_") + "_request" )