2023-02-17 07:02:21 +01:00
|
|
|
from typing import List, Dict, Optional
|
|
|
|
|
|
|
|
from titles.wacca.handlers.base import BaseRequest, BaseResponse
|
|
|
|
from titles.wacca.handlers.helpers import *
|
|
|
|
|
2023-03-09 17:38:58 +01:00
|
|
|
|
2023-02-17 07:02:21 +01:00
|
|
|
# ---user/status/get----
|
|
|
|
class UserStatusGetRequest(BaseRequest):
|
|
|
|
aimeId: int = 0
|
|
|
|
|
|
|
|
def __init__(self, data: Dict) -> None:
|
|
|
|
super().__init__(data)
|
|
|
|
self.aimeId = int(data["params"][0])
|
|
|
|
|
2023-03-09 17:38:58 +01:00
|
|
|
|
2023-02-17 07:02:21 +01:00
|
|
|
class UserStatusGetV1Response(BaseResponse):
|
|
|
|
def __init__(self) -> None:
|
|
|
|
super().__init__()
|
|
|
|
self.userStatus: UserStatusV1 = UserStatusV1()
|
|
|
|
self.setTitleId: int = 0
|
|
|
|
self.setIconId: int = 0
|
|
|
|
self.profileStatus: ProfileStatus = ProfileStatus.ProfileGood
|
|
|
|
self.versionStatus: PlayVersionStatus = PlayVersionStatus.VersionGood
|
2023-03-02 03:48:43 +01:00
|
|
|
self.lastGameVersion: ShortVersion = ShortVersion()
|
2023-02-17 07:02:21 +01:00
|
|
|
|
|
|
|
def make(self) -> Dict:
|
|
|
|
self.params = [
|
|
|
|
self.userStatus.make(),
|
|
|
|
self.setTitleId,
|
|
|
|
self.setIconId,
|
|
|
|
self.profileStatus.value,
|
2023-03-09 17:38:58 +01:00
|
|
|
[self.versionStatus.value, str(self.lastGameVersion)],
|
2023-02-17 07:02:21 +01:00
|
|
|
]
|
2023-03-09 17:38:58 +01:00
|
|
|
|
2023-02-17 07:02:21 +01:00
|
|
|
return super().make()
|
|
|
|
|
2023-03-09 17:38:58 +01:00
|
|
|
|
2023-02-17 07:02:21 +01:00
|
|
|
class UserStatusGetV2Response(UserStatusGetV1Response):
|
|
|
|
def __init__(self) -> None:
|
|
|
|
super().__init__()
|
|
|
|
self.userStatus: UserStatusV2 = UserStatusV2()
|
2023-04-20 06:54:16 +02:00
|
|
|
self.options: List[UserOption] = []
|
2023-02-17 07:02:21 +01:00
|
|
|
|
|
|
|
def make(self) -> Dict:
|
|
|
|
super().make()
|
2023-04-20 06:54:16 +02:00
|
|
|
opts = []
|
|
|
|
|
|
|
|
for x in self.options:
|
|
|
|
opts.append(x.make())
|
2023-02-17 07:02:21 +01:00
|
|
|
|
2023-04-20 06:54:16 +02:00
|
|
|
self.params.append(opts)
|
2023-02-17 07:02:21 +01:00
|
|
|
|
|
|
|
return super(UserStatusGetV1Response, self).make()
|
|
|
|
|
2023-03-09 17:38:58 +01:00
|
|
|
|
2023-02-17 07:02:21 +01:00
|
|
|
# ---user/status/getDetail----
|
|
|
|
class UserStatusGetDetailRequest(BaseRequest):
|
|
|
|
userId: int = 0
|
|
|
|
|
|
|
|
def __init__(self, data: Dict) -> None:
|
|
|
|
super().__init__(data)
|
|
|
|
self.userId = data["params"][0]
|
|
|
|
|
2023-03-09 17:38:58 +01:00
|
|
|
|
2023-02-17 07:02:21 +01:00
|
|
|
class UserStatusGetDetailResponseV1(BaseResponse):
|
|
|
|
def __init__(self) -> None:
|
|
|
|
super().__init__()
|
|
|
|
self.userStatus: UserStatusV1 = UserStatusV1()
|
|
|
|
self.options: List[UserOption] = []
|
|
|
|
self.seasonalPlayModeCounts: List[PlayModeCounts] = []
|
|
|
|
self.userItems: UserItemInfoV1 = UserItemInfoV1()
|
|
|
|
self.scores: List[BestScoreDetailV1] = []
|
2023-03-09 17:38:58 +01:00
|
|
|
self.songPlayStatus: List[int] = [0, 0]
|
2023-02-23 04:22:03 +01:00
|
|
|
self.seasonInfo: SeasonalInfoV1 = SeasonalInfoV1()
|
2023-03-09 17:38:58 +01:00
|
|
|
self.playAreaList: List = [
|
|
|
|
[0],
|
|
|
|
[0, 0, 0, 0, 0, 0],
|
|
|
|
[0, 0, 0, 0, 0, 0, 0],
|
|
|
|
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
|
|
|
[0, 0, 0, 0, 0, 0],
|
|
|
|
[0, 0, 0, 0, 0],
|
|
|
|
[0, 0, 0, 0],
|
|
|
|
[0, 0, 0, 0, 0, 0, 0],
|
|
|
|
[0],
|
|
|
|
]
|
2023-02-17 07:02:21 +01:00
|
|
|
self.songUpdateTime: int = 0
|
|
|
|
|
2023-03-09 17:38:58 +01:00
|
|
|
def make(self) -> Dict:
|
2023-02-17 07:02:21 +01:00
|
|
|
opts = []
|
|
|
|
play_modes = []
|
|
|
|
scores = []
|
|
|
|
|
|
|
|
for x in self.seasonalPlayModeCounts:
|
|
|
|
play_modes.append(x.make())
|
2023-03-09 17:38:58 +01:00
|
|
|
|
2023-02-17 07:02:21 +01:00
|
|
|
for x in self.scores:
|
|
|
|
scores.append(x.make())
|
2023-03-09 17:38:58 +01:00
|
|
|
|
2023-02-17 07:02:21 +01:00
|
|
|
for x in self.options:
|
|
|
|
opts.append(x.make())
|
|
|
|
|
|
|
|
self.params = [
|
|
|
|
self.userStatus.make(),
|
|
|
|
opts,
|
|
|
|
play_modes,
|
|
|
|
self.userItems.make(),
|
|
|
|
scores,
|
|
|
|
self.songPlayStatus,
|
|
|
|
self.seasonInfo.make(),
|
|
|
|
self.playAreaList,
|
2023-03-09 17:38:58 +01:00
|
|
|
self.songUpdateTime,
|
2023-02-17 07:02:21 +01:00
|
|
|
]
|
|
|
|
|
|
|
|
return super().make()
|
2023-03-09 17:38:58 +01:00
|
|
|
|
|
|
|
def find_score_idx(
|
|
|
|
self,
|
|
|
|
song_id: int,
|
|
|
|
difficulty: int = 1,
|
|
|
|
start_idx: int = 0,
|
|
|
|
stop_idx: Optional[int] = None,
|
|
|
|
) -> Optional[int]:
|
2023-02-17 07:02:21 +01:00
|
|
|
if stop_idx is None or stop_idx > len(self.scores):
|
|
|
|
stop_idx = len(self.scores)
|
|
|
|
|
|
|
|
for x in range(start_idx, stop_idx):
|
2023-03-09 17:38:58 +01:00
|
|
|
if (
|
|
|
|
self.scores[x].songId == song_id
|
|
|
|
and self.scores[x].difficulty == difficulty
|
|
|
|
):
|
2023-02-17 07:02:21 +01:00
|
|
|
return x
|
2023-03-09 17:38:58 +01:00
|
|
|
|
2023-02-17 07:02:21 +01:00
|
|
|
return None
|
|
|
|
|
2023-03-09 17:38:58 +01:00
|
|
|
|
2023-02-17 07:02:21 +01:00
|
|
|
class UserStatusGetDetailResponseV2(UserStatusGetDetailResponseV1):
|
|
|
|
def __init__(self) -> None:
|
|
|
|
super().__init__()
|
|
|
|
self.userStatus: UserStatusV2 = UserStatusV2()
|
|
|
|
self.seasonInfo: SeasonalInfoV2 = SeasonalInfoV2()
|
|
|
|
self.userItems: UserItemInfoV2 = UserItemInfoV2()
|
|
|
|
self.favorites: List[int] = []
|
|
|
|
self.stoppedSongIds: List[int] = []
|
2023-04-20 06:54:16 +02:00
|
|
|
self.eventInfo: List[UserEventInfo] = []
|
2023-02-17 07:02:21 +01:00
|
|
|
self.gateInfo: List[GateDetailV1] = []
|
|
|
|
self.lastSongInfo: LastSongDetail = LastSongDetail()
|
|
|
|
self.gateTutorialFlags: List[GateTutorialFlag] = []
|
|
|
|
self.gatchaInfo: List[GachaInfo] = []
|
|
|
|
self.friendList: List[FriendDetail] = []
|
|
|
|
|
2023-03-09 17:38:58 +01:00
|
|
|
def make(self) -> Dict:
|
2023-02-17 07:02:21 +01:00
|
|
|
super().make()
|
|
|
|
gates = []
|
|
|
|
friends = []
|
|
|
|
tut_flg = []
|
2023-04-20 06:54:16 +02:00
|
|
|
evts = []
|
|
|
|
gacha = []
|
2023-02-17 07:02:21 +01:00
|
|
|
|
|
|
|
for x in self.gateInfo:
|
|
|
|
gates.append(x.make())
|
2023-03-09 17:38:58 +01:00
|
|
|
|
2023-02-17 07:02:21 +01:00
|
|
|
for x in self.friendList:
|
|
|
|
friends.append(x.make())
|
2023-03-09 17:38:58 +01:00
|
|
|
|
2023-02-17 07:02:21 +01:00
|
|
|
for x in self.gateTutorialFlags:
|
|
|
|
tut_flg.append(x.make())
|
2023-03-09 17:38:58 +01:00
|
|
|
|
2023-02-17 07:02:21 +01:00
|
|
|
while len(tut_flg) < 5:
|
|
|
|
flag_id = len(tut_flg) + 1
|
|
|
|
tut_flg.append([flag_id, 0])
|
2023-04-24 03:04:52 +02:00
|
|
|
|
2023-04-20 06:54:16 +02:00
|
|
|
for x in self.eventInfo:
|
|
|
|
evts.append(x.make())
|
|
|
|
|
|
|
|
for x in self.gatchaInfo:
|
|
|
|
gacha.append(x.make())
|
2023-02-17 07:02:21 +01:00
|
|
|
|
|
|
|
self.params.append(self.favorites)
|
|
|
|
self.params.append(self.stoppedSongIds)
|
2023-04-20 06:54:16 +02:00
|
|
|
self.params.append(evts)
|
2023-02-17 07:02:21 +01:00
|
|
|
self.params.append(gates)
|
|
|
|
self.params.append(self.lastSongInfo.make())
|
|
|
|
self.params.append(tut_flg)
|
2023-04-20 06:54:16 +02:00
|
|
|
self.params.append(gacha)
|
2023-02-17 07:02:21 +01:00
|
|
|
self.params.append(friends)
|
|
|
|
|
|
|
|
return super(UserStatusGetDetailResponseV1, self).make()
|
|
|
|
|
2023-03-09 17:38:58 +01:00
|
|
|
|
2023-02-17 07:02:21 +01:00
|
|
|
class UserStatusGetDetailResponseV3(UserStatusGetDetailResponseV2):
|
|
|
|
def __init__(self) -> None:
|
|
|
|
super().__init__()
|
|
|
|
self.gateInfo: List[GateDetailV2] = []
|
|
|
|
|
2023-03-09 17:38:58 +01:00
|
|
|
|
2023-02-17 07:02:21 +01:00
|
|
|
class UserStatusGetDetailResponseV4(UserStatusGetDetailResponseV3):
|
|
|
|
def __init__(self) -> None:
|
|
|
|
super().__init__()
|
|
|
|
self.userItems: UserItemInfoV3 = UserItemInfoV3()
|
|
|
|
self.bingoStatus: BingoDetail = BingoDetail(0)
|
|
|
|
self.scores: List[BestScoreDetailV2] = []
|
|
|
|
|
2023-03-09 17:38:58 +01:00
|
|
|
def make(self) -> Dict:
|
2023-02-17 07:02:21 +01:00
|
|
|
super().make()
|
|
|
|
self.params.append(self.bingoStatus.make())
|
|
|
|
|
|
|
|
return super(UserStatusGetDetailResponseV1, self).make()
|
|
|
|
|
2023-03-09 17:38:58 +01:00
|
|
|
|
2023-02-17 07:02:21 +01:00
|
|
|
# ---user/status/login----
|
|
|
|
class UserStatusLoginRequest(BaseRequest):
|
|
|
|
userId: int = 0
|
|
|
|
|
|
|
|
def __init__(self, data: Dict) -> None:
|
|
|
|
super().__init__(data)
|
|
|
|
self.userId = data["params"][0]
|
|
|
|
|
2023-03-09 17:38:58 +01:00
|
|
|
|
2023-02-17 07:02:21 +01:00
|
|
|
class UserStatusLoginResponseV1(BaseResponse):
|
2023-03-09 17:38:58 +01:00
|
|
|
def __init__(
|
|
|
|
self, is_first_login_daily: bool = False, last_login_date: int = 0
|
|
|
|
) -> None:
|
2023-02-17 07:02:21 +01:00
|
|
|
super().__init__()
|
|
|
|
self.dailyBonus: List[LoginBonusInfo] = []
|
|
|
|
self.consecBonus: List[LoginBonusInfo] = []
|
2023-03-09 17:38:58 +01:00
|
|
|
self.otherBonus: List[LoginBonusInfo] = []
|
2023-02-17 07:02:21 +01:00
|
|
|
self.firstLoginDaily = is_first_login_daily
|
|
|
|
self.lastLoginDate = last_login_date
|
|
|
|
|
2023-03-09 17:38:58 +01:00
|
|
|
def make(self) -> Dict:
|
2023-02-23 04:22:03 +01:00
|
|
|
super().make()
|
2023-02-17 07:02:21 +01:00
|
|
|
daily = []
|
|
|
|
consec = []
|
|
|
|
other = []
|
|
|
|
|
|
|
|
for bonus in self.dailyBonus:
|
|
|
|
daily.append(bonus.make())
|
|
|
|
|
|
|
|
for bonus in self.consecBonus:
|
|
|
|
consec.append(bonus.make())
|
|
|
|
|
|
|
|
for bonus in self.otherBonus:
|
|
|
|
other.append(bonus.make())
|
|
|
|
|
2023-03-09 17:38:58 +01:00
|
|
|
self.params = [daily, consec, other, int(self.firstLoginDaily)]
|
2023-02-17 07:02:21 +01:00
|
|
|
return super().make()
|
|
|
|
|
2023-03-09 17:38:58 +01:00
|
|
|
|
2023-02-17 07:02:21 +01:00
|
|
|
class UserStatusLoginResponseV2(UserStatusLoginResponseV1):
|
2023-03-09 17:38:58 +01:00
|
|
|
def __init__(
|
|
|
|
self, is_first_login_daily: bool = False, last_login_date: int = 0
|
|
|
|
) -> None:
|
2023-02-17 07:02:21 +01:00
|
|
|
super().__init__(is_first_login_daily)
|
|
|
|
self.lastLoginDate = last_login_date
|
|
|
|
|
|
|
|
self.vipInfo = VipInfo()
|
2023-03-09 17:38:58 +01:00
|
|
|
|
|
|
|
def make(self) -> Dict:
|
2023-02-17 07:02:21 +01:00
|
|
|
super().make()
|
|
|
|
self.params.append(self.vipInfo.make())
|
|
|
|
self.params.append(self.lastLoginDate)
|
|
|
|
return super(UserStatusLoginResponseV1, self).make()
|
|
|
|
|
2023-03-09 17:38:58 +01:00
|
|
|
|
2023-02-17 07:02:21 +01:00
|
|
|
class UserStatusLoginResponseV3(UserStatusLoginResponseV2):
|
2023-03-09 17:38:58 +01:00
|
|
|
def __init__(
|
|
|
|
self, is_first_login_daily: bool = False, last_login_date: int = 0
|
|
|
|
) -> None:
|
2023-02-23 04:22:03 +01:00
|
|
|
super().__init__(is_first_login_daily, last_login_date)
|
2023-04-24 03:04:52 +02:00
|
|
|
self.unk: List = (
|
|
|
|
[]
|
|
|
|
) # Ticket info, item info, message, title, voice name (not sure how they fit...)
|
2023-02-17 07:02:21 +01:00
|
|
|
|
2023-03-09 17:38:58 +01:00
|
|
|
def make(self) -> Dict:
|
2023-02-17 07:02:21 +01:00
|
|
|
super().make()
|
|
|
|
self.params.append(self.unk)
|
|
|
|
return super(UserStatusLoginResponseV1, self).make()
|
|
|
|
|
2023-03-09 17:38:58 +01:00
|
|
|
|
2023-02-17 07:02:21 +01:00
|
|
|
# ---user/status/create---
|
|
|
|
class UserStatusCreateRequest(BaseRequest):
|
|
|
|
def __init__(self, data: Dict) -> None:
|
|
|
|
super().__init__(data)
|
|
|
|
self.aimeId = data["params"][0]
|
|
|
|
self.username = data["params"][1]
|
|
|
|
|
2023-03-09 17:38:58 +01:00
|
|
|
|
2023-02-17 07:02:21 +01:00
|
|
|
class UserStatusCreateResponseV1(BaseResponse):
|
|
|
|
def __init__(self, userId: int, username: str) -> None:
|
|
|
|
super().__init__()
|
|
|
|
self.userStatus = UserStatusV1()
|
|
|
|
self.userStatus.userId = userId
|
|
|
|
self.userStatus.username = username
|
2023-03-09 17:38:58 +01:00
|
|
|
|
|
|
|
def make(self) -> Dict:
|
|
|
|
self.params = [self.userStatus.make()]
|
2023-02-17 07:02:21 +01:00
|
|
|
return super().make()
|
|
|
|
|
2023-03-09 17:38:58 +01:00
|
|
|
|
2023-02-17 07:02:21 +01:00
|
|
|
class UserStatusCreateResponseV2(UserStatusCreateResponseV1):
|
|
|
|
def __init__(self, userId: int, username: str) -> None:
|
|
|
|
super().__init__(userId, username)
|
2023-03-09 17:38:58 +01:00
|
|
|
self.userStatus: UserStatusV2 = UserStatusV2()
|
2023-02-17 07:02:21 +01:00
|
|
|
self.userStatus.userId = userId
|
|
|
|
self.userStatus.username = username
|
|
|
|
|
2023-03-09 17:38:58 +01:00
|
|
|
|
2023-02-17 07:02:21 +01:00
|
|
|
# ---user/status/logout---
|
|
|
|
class UserStatusLogoutRequest(BaseRequest):
|
|
|
|
userId: int
|
|
|
|
|
|
|
|
def __init__(self, data: Dict) -> None:
|
|
|
|
super().__init__(data)
|
|
|
|
self.userId = data["params"][0]
|
|
|
|
|
2023-03-09 17:38:58 +01:00
|
|
|
|
2023-02-17 07:02:21 +01:00
|
|
|
# ---user/status/update---
|
|
|
|
class UserStatusUpdateRequestV1(BaseRequest):
|
|
|
|
def __init__(self, data: Dict) -> None:
|
|
|
|
super().__init__(data)
|
|
|
|
self.profileId: int = data["params"][0]
|
|
|
|
self.playType: PlayType = PlayType(data["params"][1])
|
|
|
|
self.itemsRecieved: List[GenericItemRecv] = []
|
|
|
|
|
|
|
|
for itm in data["params"][2]:
|
|
|
|
self.itemsRecieved.append(GenericItemRecv(itm[0], itm[1], itm[2]))
|
|
|
|
|
2023-03-09 17:38:58 +01:00
|
|
|
|
2023-02-17 07:02:21 +01:00
|
|
|
class UserStatusUpdateRequestV2(UserStatusUpdateRequestV1):
|
|
|
|
def __init__(self, data: Dict) -> None:
|
|
|
|
super().__init__(data)
|
|
|
|
self.isContinue = bool(data["params"][3])
|
|
|
|
self.isFirstPlayFree = bool(data["params"][4])
|
|
|
|
self.itemsUsed = data["params"][5]
|
2023-03-09 17:38:58 +01:00
|
|
|
self.lastSongInfo = LastSongDetail(
|
|
|
|
data["params"][6][0],
|
|
|
|
data["params"][6][1],
|
|
|
|
data["params"][6][2],
|
|
|
|
data["params"][6][3],
|
|
|
|
data["params"][6][4],
|
|
|
|
)
|