1
0
forked from Hay1tsme/artemis

wacca: add region logic

This commit is contained in:
Hay1tsme 2023-03-01 22:27:33 -05:00
parent e46c8e7dbd
commit e961c1dfb3
5 changed files with 63 additions and 59 deletions

View File

@ -73,9 +73,9 @@ class WaccaBase():
prefecture_name = inflection.underscore(game_cfg.server.prefecture_name).replace(' ', '_').upper()
if prefecture_name not in [region.name for region in WaccaConstants.Region]:
self.logger.warning(f"Invalid prefecture name {game_cfg.server.prefecture_name} in config file")
self.region_id = 1
self.region_id = WaccaConstants.Region.HOKKAIDO
else:
self.region_id = int(WaccaConstants.Region[prefecture_name].value)
self.region_id = WaccaConstants.Region[prefecture_name]
def handle_housing_get_request(self, data: Dict) -> Dict:
req = BaseRequest(data)
@ -91,17 +91,12 @@ class WaccaBase():
def handle_housing_start_request(self, data: Dict) -> Dict:
req = HousingStartRequestV1(data)
resp = HousingStartResponseV1(
self.region_id,
[ # Recomended songs
1269,1007,1270,1002,1020,1003,1008,1211,1018,1092,1056,32,
1260,1230,1258,1251,2212,1264,1125,1037,2001,1272,1126,1119,
1104,1070,1047,1044,1027,1004,1001,24,2068,2062,2021,1275,
1249,1207,1203,1107,1021,1009,9,4,3,23,22,2014,13,1276,1247,
1240,1237,1128,1114,1110,1109,1102,1045,1043,1036,1035,1030,
1023,1015
]
)
if req.appVersion.country != "JPN" and req.appVersion.country in [region.name for region in WaccaConstants.Region]:
region_id = WaccaConstants.Region[req.appVersion.country]
else:
region_id = self.region_id
resp = HousingStartResponseV1(region_id)
return resp.make()
def handle_advertise_GetNews_request(self, data: Dict) -> Dict:

View File

@ -153,9 +153,13 @@ class WaccaConstants():
UNITED_STATES = 48
USA = 48
TAIWAN = 49
TWN = 49
HONG_KONG = 50
HKG = 50
SINGAPORE = 51
SGP = 51
KOREA = 52
KOR = 52
VALID_COUNTRIES = set(["JPN", "USA", "KOR", "HKG", "SGP"])

View File

@ -90,8 +90,7 @@ class Version(ShortVersion):
def __str__(self) -> str:
return f"{self.major}.{self.minor}.{self.patch}.{self.country}.{self.role}.{self.build}"
class HousingInfo():
class HousingInfo:
"""
1 is lan install role, 2 is country
"""
@ -105,7 +104,7 @@ class HousingInfo():
def make(self) -> List:
return [ self.id, self.val ]
class Notice():
class Notice:
name: str = ""
title: str = ""
message: str = ""
@ -128,7 +127,7 @@ class Notice():
return [ self.name, self.title, self.message, self.unknown3, self.unknown4, int(self.showTitleScreen),
int(self.showWelcomeScreen), self.startTime, self.endTime, self.voiceline]
class UserOption():
class UserOption:
def __init__(self, opt_id: int = 0, opt_val: Any = 0) -> None:
self.opt_id = opt_id
self.opt_val = opt_val
@ -136,7 +135,7 @@ class UserOption():
def make(self) -> List:
return [self.opt_id, self.opt_val]
class UserStatusV1():
class UserStatusV1:
def __init__(self) -> None:
self.userId: int = 0
self.username: str = ""
@ -194,7 +193,7 @@ class PlayVersionStatus(Enum):
VersionTooNew = 1
VersionUpgrade = 2
class PlayModeCounts():
class PlayModeCounts:
seasonId: int = 0
modeId: int = 0
playNum: int = 0
@ -211,7 +210,7 @@ class PlayModeCounts():
self.playNum
]
class SongUnlock():
class SongUnlock:
songId: int = 0
difficulty: int = 0
whenAppeared: int = 0
@ -231,7 +230,7 @@ class SongUnlock():
self.whenUnlocked
]
class GenericItemRecv():
class GenericItemRecv:
def __init__(self, item_type: int = 1, item_id: int = 1, quantity: int = 1) -> None:
self.itemId = item_id
self.itemType = item_type
@ -240,7 +239,7 @@ class GenericItemRecv():
def make(self) -> List:
return [ self.itemType, self.itemId, self.quantity ]
class GenericItemSend():
class GenericItemSend:
def __init__(self, itemId: int, itemType: int, whenAcquired: int) -> None:
self.itemId = itemId
self.itemType = itemType
@ -268,7 +267,7 @@ class IconItem(GenericItemSend):
self.whenAcquired
]
class TrophyItem():
class TrophyItem:
trophyId: int = 0
season: int = 1
progress: int = 0
@ -288,7 +287,7 @@ class TrophyItem():
self.badgeType
]
class TicketItem():
class TicketItem:
userTicketId: int = 0
ticketId: int = 0
whenExpires: int = 0
@ -321,7 +320,7 @@ class NavigatorItem(IconItem):
self.usesToday
]
class SkillItem():
class SkillItem:
skill_type: int
level: int
flag: int
@ -335,7 +334,7 @@ class SkillItem():
self.badge
]
class UserItemInfoV1():
class UserItemInfoV1:
def __init__(self) -> None:
self.songUnlocks: List[SongUnlock] = []
self.titles: List[GenericItemSend] = []
@ -419,7 +418,7 @@ class UserItemInfoV3(UserItemInfoV2):
ret.append(effect)
return ret
class SongDetailClearCounts():
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, counts: Optional[List[int]] = None) -> None:
if counts is None:
@ -439,7 +438,7 @@ class SongDetailClearCounts():
def make(self) -> List:
return [self.playCt, self.clearCt, self.misslessCt, self.fullComboCt, self.allMarvelousCt]
class SongDetailGradeCountsV1():
class SongDetailGradeCountsV1:
dCt: int
cCt: int
bCt: int
@ -501,7 +500,7 @@ class SongDetailGradeCountsV2(SongDetailGradeCountsV1):
def make(self) -> List:
return super().make() + [self.spCt, self.sspCt, self.ssspCt]
class BestScoreDetailV1():
class BestScoreDetailV1:
songId: int = 0
difficulty: int = 1
clearCounts: SongDetailClearCounts = SongDetailClearCounts()
@ -534,7 +533,7 @@ class BestScoreDetailV1():
class BestScoreDetailV2(BestScoreDetailV1):
gradeCounts: SongDetailGradeCountsV2 = SongDetailGradeCountsV2()
class SongUpdateJudgementCounts():
class SongUpdateJudgementCounts:
marvCt: int
greatCt: int
goodCt: int
@ -549,7 +548,7 @@ class SongUpdateJudgementCounts():
def make(self) -> List:
return [self.marvCt, self.greatCt, self.goodCt, self.missCt]
class SongUpdateDetailV1():
class SongUpdateDetailV1:
def __init__(self, data: List) -> None:
if data is not None:
self.songId = data[0]
@ -579,7 +578,7 @@ class SongUpdateDetailV2(SongUpdateDetailV1):
self.slowCt = data[14]
self.flagNewRecord = False if data[15] == 0 else True
class SeasonalInfoV1():
class SeasonalInfoV1:
def __init__(self) -> None:
self.level: int = 0
self.wpObtained: int = 0
@ -613,7 +612,7 @@ class SeasonalInfoV2(SeasonalInfoV1):
def make(self) -> List:
return super().make() + [self.platesObtained, self.cumulativeGatePts]
class BingoPageStatus():
class BingoPageStatus:
id = 0
location = 1
progress = 0
@ -626,7 +625,7 @@ class BingoPageStatus():
def make(self) -> List:
return [self.id, self.location, self.progress]
class BingoDetail():
class BingoDetail:
def __init__(self, pageNumber: int) -> None:
self.pageNumber = pageNumber
self.pageStatus: List[BingoPageStatus] = []
@ -641,7 +640,7 @@ class BingoDetail():
status
]
class GateDetailV1():
class GateDetailV1:
def __init__(self, gate_id: int = 1, page: int = 1, progress: int = 0, loops: int = 0, last_used: int = 0, mission_flg = 0) -> None:
self.id = gate_id
self.page = page
@ -657,11 +656,11 @@ class GateDetailV2(GateDetailV1):
def make(self) -> List:
return super().make() + [self.missionFlg]
class GachaInfo():
class GachaInfo:
def make(self) -> List:
return []
class LastSongDetail():
class LastSongDetail:
lastSongId = 90
lastSongDiff = 1
lastFolderOrd = 1
@ -680,11 +679,11 @@ class LastSongDetail():
return [self.lastSongId, self.lastSongDiff, self.lastFolderOrd, self.lastFolderId,
self.lastSongOrd]
class FriendDetail():
class FriendDetail:
def make(self) -> List:
return []
class LoginBonusInfo():
class LoginBonusInfo:
def __init__(self) -> None:
self.tickets: List[TicketItem] = []
self.items: List[GenericItemRecv] = []
@ -702,7 +701,7 @@ class LoginBonusInfo():
return [ tks, itms, self.message ]
class VipLoginBonus():
class VipLoginBonus:
id = 1
unknown = 0
item: GenericItemRecv
@ -715,7 +714,7 @@ class VipLoginBonus():
def make(self) -> List:
return [ self.id, self.unknown, self.item.make() ]
class VipInfo():
class VipInfo:
def __init__(self, year: int = 2019, month: int = 1, day: int = 1, num_item: int = 1) -> None:
self.pageYear = year
self.pageMonth = month
@ -746,7 +745,7 @@ class PlayType(Enum):
PlayTypeCoop = 3
PlayTypeStageup = 4
class StageInfo():
class StageInfo:
danId: int = 0
danLevel: int = 0
clearStatus: int = 0
@ -780,7 +779,7 @@ class StageupClearType(Enum):
CLEAR_SILVER = 2
CLEAR_GOLD = 3
class MusicUpdateDetailV1():
class MusicUpdateDetailV1:
def __init__(self) -> None:
self.songId = 0
self.difficulty = 1
@ -818,7 +817,7 @@ class MusicUpdateDetailV3(MusicUpdateDetailV2):
super().__init__()
self.grades = SongDetailGradeCountsV2()
class SongRatingUpdate():
class SongRatingUpdate:
def __init__(self, song_id: int = 0, difficulty: int = 1, new_rating: int = 0) -> None:
self.songId = song_id
self.difficulty = difficulty
@ -831,7 +830,7 @@ class SongRatingUpdate():
self.rating,
]
class GateTutorialFlag():
class GateTutorialFlag:
def __init__(self, tutorial_id: int = 1, flg_watched: bool = False) -> None:
self.tutorialId = tutorial_id
self.flagWatched = flg_watched

View File

@ -2,6 +2,7 @@ from typing import List, Dict
from titles.wacca.handlers.base import BaseRequest, BaseResponse
from titles.wacca.handlers.helpers import HousingInfo
from titles.wacca.const import WaccaConstants
# ---housing/get----
class HousingGetResponse(BaseResponse):
@ -37,12 +38,22 @@ class HousingStartRequestV2(HousingStartRequestV1):
self.info.append(HousingInfo(info[0], info[1]))
class HousingStartResponseV1(BaseResponse):
def __init__(self, regionId: int, songList: List[int]) -> None:
def __init__(self, regionId: WaccaConstants.Region = WaccaConstants.Region.HOKKAIDO, songList: List[int] = []) -> None:
super().__init__()
self.regionId = regionId
self.songList = songList
self.songList = songList # Recomended songs
if not self.songList:
self.songList = [
1269,1007,1270,1002,1020,1003,1008,1211,1018,1092,1056,32,
1260,1230,1258,1251,2212,1264,1125,1037,2001,1272,1126,1119,
1104,1070,1047,1044,1027,1004,1001,24,2068,2062,2021,1275,
1249,1207,1203,1107,1021,1009,9,4,3,23,22,2014,13,1276,1247,
1240,1237,1128,1114,1110,1109,1102,1045,1043,1036,1035,1030,
1023,1015
]
def make(self) -> Dict:
self.params = [self.regionId, self.songList]
self.params = [self.regionId.value, self.songList]
return super().make()

View File

@ -42,18 +42,13 @@ class WaccaLily(WaccaS):
def handle_housing_start_request(self, data: Dict) -> Dict:
req = HousingStartRequestV2(data)
if req.appVersion.country != "JPN" and req.appVersion.country in [region.name for region in WaccaConstants.Region]:
region_id = WaccaConstants.Region[req.appVersion.country]
else:
region_id = self.region_id
resp = HousingStartResponseV1(
self.region_id,
[ # Recomended songs
1269,1007,1270,1002,1020,1003,1008,1211,1018,1092,1056,32,
1260,1230,1258,1251,2212,1264,1125,1037,2001,1272,1126,1119,
1104,1070,1047,1044,1027,1004,1001,24,2068,2062,2021,1275,
1249,1207,1203,1107,1021,1009,9,4,3,23,22,2014,13,1276,1247,
1240,1237,1128,1114,1110,1109,1102,1045,1043,1036,1035,1030,
1023,1015
]
)
resp = HousingStartResponseV1(region_id)
return resp.make()
def handle_user_status_get_request(self, data: Dict)-> Dict: