From 4d6afd757f3257bfb7b695f6765c9b21b481d1b8 Mon Sep 17 00:00:00 2001 From: Kevin Trocolli Date: Thu, 20 Apr 2023 00:54:16 -0400 Subject: [PATCH] wacca: add helpers for gacha, event and friend info, fix settings not being applied correctly --- titles/wacca/base.py | 4 +- titles/wacca/handlers/helpers.py | 87 +++++++++++++++++++++------- titles/wacca/handlers/housing.py | 6 +- titles/wacca/handlers/user_status.py | 22 +++++-- titles/wacca/lily.py | 5 ++ 5 files changed, 93 insertions(+), 31 deletions(-) diff --git a/titles/wacca/base.py b/titles/wacca/base.py index d4bf873..5663588 100644 --- a/titles/wacca/base.py +++ b/titles/wacca/base.py @@ -825,7 +825,7 @@ class WaccaBase: resp.songDetail.grades = SongDetailGradeCountsV2(counts=grades) else: resp.songDetail.grades = SongDetailGradeCountsV1(counts=grades) - resp.songDetail.lock_state = 1 + resp.songDetail.lockState = 1 return resp.make() # TODO: Coop and vs data @@ -971,7 +971,7 @@ class WaccaBase: user_id = self.data.profile.profile_to_aime_user(req.profileId) for opt in req.optsUpdated: - self.data.profile.update_option(user_id, opt.opt_id, opt.opt_val) + self.data.profile.update_option(user_id, opt.optId, opt.optVal) for update in req.datesUpdated: pass diff --git a/titles/wacca/handlers/helpers.py b/titles/wacca/handlers/helpers.py index f86be2f..dc836ce 100644 --- a/titles/wacca/handlers/helpers.py +++ b/titles/wacca/handlers/helpers.py @@ -158,11 +158,11 @@ class Notice: class UserOption: def __init__(self, opt_id: int = 0, opt_val: Any = 0) -> None: - self.opt_id = opt_id - self.opt_val = opt_val + self.optId = opt_id + self.optVal = opt_val def make(self) -> List: - return [self.opt_id, self.opt_val] + return [self.optId, self.optVal] class UserStatusV1: @@ -348,13 +348,35 @@ class NavigatorItem(IconItem): class SkillItem: - skill_type: int + skillType: int level: int flag: int badge: int def make(self) -> List: - return [self.skill_type, self.level, self.flag, self.badge] + return [self.skillType, self.level, self.flag, self.badge] + + +class UserEventInfo: + def __init__(self) -> None: + self.eventId = 0 + self.conditionInfo: List[UserEventConditionInfo] = [] + + def make(self) -> List: + conditions = [] + for x in self.conditionInfo: + conditions.append(x.make()) + + return [self.eventId, conditions] + + +class UserEventConditionInfo: + def __init__(self) -> None: + self.achievementCondition = 0 + self.progress = 0 + + def make(self) -> List: + return [self.achievementCondition, self.progress] class UserItemInfoV1: @@ -447,19 +469,19 @@ class UserItemInfoV3(UserItemInfoV2): class SongDetailClearCounts: def __init__( self, - play_ct: int = 0, - clear_ct: int = 0, - ml_ct: int = 0, - fc_ct: int = 0, - am_ct: int = 0, + playCt: int = 0, + clearCt: int = 0, + mlCt: int = 0, + fcCt: int = 0, + amCt: int = 0, counts: Optional[List[int]] = None, ) -> None: if counts is None: - self.playCt = play_ct - self.clearCt = clear_ct - self.misslessCt = ml_ct - self.fullComboCt = fc_ct - self.allMarvelousCt = am_ct + self.playCt = playCt + self.clearCt = clearCt + self.misslessCt = mlCt + self.fullComboCt = fcCt + self.allMarvelousCt = amCt else: self.playCt = counts[0] @@ -773,8 +795,12 @@ class GateDetailV2(GateDetailV1): class GachaInfo: + def __init__(self, gacha_id: int = 0, gacha_roll_ct: int = 0) -> None: + self.gachaId = gacha_id + self.rollCt = gacha_roll_ct + def make(self) -> List: - return [] + return [self.gachaId, self.rollCt] class LastSongDetail: @@ -808,9 +834,30 @@ class LastSongDetail: ] -class FriendDetail: +class FriendScoreDetail: + def __init__(self, song_id: int = 0, difficulty: int = 1, best_score: int = 0) -> None: + self.songId = song_id + self.difficulty = difficulty + self.bestScore = best_score + def make(self) -> List: - return [] + return [self.songId, self.difficulty, self.bestScore] + + +class FriendDetail: + def __init__(self, user_id: int = 0, username: str = "") -> None: + self.friendId = user_id + self.friendUsername = username + self.friendUserType = 1 + self.friendScoreDetail: List[FriendScoreDetail] = [] + + def make(self) -> List: + scores = [] + + for x in self.friendScoreDetail: + scores.append(x.make()) + + return [self.friendId, self.friendUsername, self.friendUserType, scores] class LoginBonusInfo: @@ -942,7 +989,7 @@ class MusicUpdateDetailV1: self.score = 0 self.lowestMissCount = 0 self.maxSkillPts = 0 - self.lock_state = 0 + self.lockState = 0 def make(self) -> List: return [ @@ -954,7 +1001,7 @@ class MusicUpdateDetailV1: self.score, self.lowestMissCount, self.maxSkillPts, - self.lock_state, + self.lockState, ] diff --git a/titles/wacca/handlers/housing.py b/titles/wacca/handlers/housing.py index 8ffa910..f2f079e 100644 --- a/titles/wacca/handlers/housing.py +++ b/titles/wacca/handlers/housing.py @@ -10,10 +10,10 @@ class HousingGetResponse(BaseResponse): def __init__(self, housingId: int) -> None: super().__init__() self.housingId: int = housingId - self.regionId: int = 0 + self.isNewCab: bool = False def make(self) -> Dict: - self.params = [self.housingId, self.regionId] + self.params = [self.housingId, int(self.isNewCab)] return super().make() @@ -32,8 +32,6 @@ class HousingStartRequestV1(BaseRequest): class HousingStartRequestV2(HousingStartRequestV1): def __init__(self, data: Dict) -> None: super(HousingStartRequestV1, self).__init__(data) - self.unknown0: str = self.params[0] - self.errorLog: str = self.params[1] self.creditLog: str = self.params[2] self.info: List[HousingInfo] = [] diff --git a/titles/wacca/handlers/user_status.py b/titles/wacca/handlers/user_status.py index 0e3819d..b09fed6 100644 --- a/titles/wacca/handlers/user_status.py +++ b/titles/wacca/handlers/user_status.py @@ -39,12 +39,16 @@ class UserStatusGetV2Response(UserStatusGetV1Response): def __init__(self) -> None: super().__init__() self.userStatus: UserStatusV2 = UserStatusV2() - self.unknownArr: List = [] + self.options: List[UserOption] = [] def make(self) -> Dict: super().make() + opts = [] - self.params.append(self.unknownArr) + for x in self.options: + opts.append(x.make()) + + self.params.append(opts) return super(UserStatusGetV1Response, self).make() @@ -137,7 +141,7 @@ class UserStatusGetDetailResponseV2(UserStatusGetDetailResponseV1): self.userItems: UserItemInfoV2 = UserItemInfoV2() self.favorites: List[int] = [] self.stoppedSongIds: List[int] = [] - self.eventInfo: List[int] = [] + self.eventInfo: List[UserEventInfo] = [] self.gateInfo: List[GateDetailV1] = [] self.lastSongInfo: LastSongDetail = LastSongDetail() self.gateTutorialFlags: List[GateTutorialFlag] = [] @@ -149,6 +153,8 @@ class UserStatusGetDetailResponseV2(UserStatusGetDetailResponseV1): gates = [] friends = [] tut_flg = [] + evts = [] + gacha = [] for x in self.gateInfo: gates.append(x.make()) @@ -162,14 +168,20 @@ class UserStatusGetDetailResponseV2(UserStatusGetDetailResponseV1): while len(tut_flg) < 5: flag_id = len(tut_flg) + 1 tut_flg.append([flag_id, 0]) + + for x in self.eventInfo: + evts.append(x.make()) + + for x in self.gatchaInfo: + gacha.append(x.make()) self.params.append(self.favorites) self.params.append(self.stoppedSongIds) - self.params.append(self.eventInfo) + self.params.append(evts) self.params.append(gates) self.params.append(self.lastSongInfo.make()) self.params.append(tut_flg) - self.params.append(self.gatchaInfo) + self.params.append(gacha) self.params.append(friends) return super(UserStatusGetDetailResponseV1, self).make() diff --git a/titles/wacca/lily.py b/titles/wacca/lily.py index 122cd47..4ff942b 100644 --- a/titles/wacca/lily.py +++ b/titles/wacca/lily.py @@ -73,6 +73,8 @@ class WaccaLily(WaccaS): self.logger.info(f"No user exists for aime id {req.aimeId}") resp.profileStatus = ProfileStatus.ProfileRegister return resp.make() + + opts = self.data.profile.get_options(req.aimeId) self.logger.info(f"User preview for {req.aimeId} from {req.chipId}") if profile["last_game_ver"] is None: @@ -137,6 +139,9 @@ class WaccaLily(WaccaS): if self.game_config.mods.infinite_wp: resp.userStatus.wp = 999999 + + for opt in opts: + resp.options.append(UserOption(opt["opt_id"], opt["value"])) return resp.make()