1
0
mirror of synced 2024-12-18 16:25:53 +01:00
artemis/titles/wacca/handlers/user_music.py

110 lines
3.2 KiB
Python
Raw Normal View History

from typing import List, Dict
from titles.wacca.handlers.base import BaseRequest, BaseResponse
2023-03-09 17:38:58 +01:00
from titles.wacca.handlers.helpers import (
GenericItemRecv,
SongUpdateDetailV2,
TicketItem,
)
from titles.wacca.handlers.helpers import MusicUpdateDetailV2, MusicUpdateDetailV3
2023-03-09 17:38:58 +01:00
from titles.wacca.handlers.helpers import (
SeasonalInfoV2,
SeasonalInfoV1,
SongUpdateDetailV1,
)
from titles.wacca.handlers.helpers import MusicUpdateDetailV1
2023-03-09 17:38:58 +01:00
# ---user/music/update---
class UserMusicUpdateRequestV1(BaseRequest):
def __init__(self, data: Dict) -> None:
super().__init__(data)
self.profileId: int = self.params[0]
self.songNumber: int = self.params[1]
self.songDetail = SongUpdateDetailV1(self.params[2])
self.itemsObtained: List[GenericItemRecv] = []
for itm in data["params"][3]:
self.itemsObtained.append(GenericItemRecv(itm[0], itm[1], itm[2]))
2023-03-09 17:38:58 +01:00
class UserMusicUpdateRequestV2(UserMusicUpdateRequestV1):
def __init__(self, data: Dict) -> None:
super().__init__(data)
self.songDetail = SongUpdateDetailV2(self.params[2])
2023-03-09 17:38:58 +01:00
class UserMusicUpdateResponseV1(BaseResponse):
def __init__(self) -> None:
super().__init__()
self.songDetail = MusicUpdateDetailV1()
self.seasonInfo = SeasonalInfoV1()
self.rankingInfo: List[List[int]] = []
2023-03-09 17:38:58 +01:00
def make(self) -> Dict:
self.params = [
self.songDetail.make(),
[self.songDetail.songId, self.songDetail.clearCounts.playCt],
self.seasonInfo.make(),
2023-03-09 17:38:58 +01:00
self.rankingInfo,
]
return super().make()
2023-03-09 17:38:58 +01:00
class UserMusicUpdateResponseV2(UserMusicUpdateResponseV1):
def __init__(self) -> None:
super().__init__()
self.songDetail = MusicUpdateDetailV2()
self.seasonInfo = SeasonalInfoV2()
2023-03-09 17:38:58 +01:00
class UserMusicUpdateResponseV3(UserMusicUpdateResponseV2):
def __init__(self) -> None:
super().__init__()
self.songDetail = MusicUpdateDetailV3()
2023-03-09 17:38:58 +01:00
# ---user/music/updateCoop---
class UserMusicUpdateCoopRequest(UserMusicUpdateRequestV2):
def __init__(self, data: Dict) -> None:
super().__init__(data)
self.coopData = self.params[4]
2023-03-09 17:38:58 +01:00
# ---user/music/updateVs---
class UserMusicUpdateVsRequest(UserMusicUpdateRequestV2):
def __init__(self, data: Dict) -> None:
super().__init__(data)
self.vsData = self.params[4]
2023-03-09 17:38:58 +01:00
# ---user/music/unlock---
class UserMusicUnlockRequest(BaseRequest):
def __init__(self, data: Dict) -> None:
super().__init__(data)
self.profileId = self.params[0]
self.songId = self.params[1]
2023-03-09 17:38:58 +01:00
self.difficulty = self.params[2]
self.itemsUsed: List[GenericItemRecv] = []
for itm in self.params[3]:
self.itemsUsed.append(GenericItemRecv(itm[0], itm[1], itm[2]))
2023-03-09 17:38:58 +01:00
class UserMusicUnlockResponse(BaseResponse):
def __init__(self, current_wp: int = 0, tickets_remaining: List[TicketItem] = []) -> None:
super().__init__()
2023-03-09 17:38:58 +01:00
self.wp = current_wp
self.tickets = tickets_remaining
2023-03-09 17:38:58 +01:00
def make(self) -> Dict:
tickets = []
for ticket in self.tickets:
tickets.append(ticket.make())
2023-03-09 17:38:58 +01:00
self.params = [self.wp, tickets]
return super().make()