[mai2] Implement GetUserNewItemApi

This commit is contained in:
beerpsi 2024-04-20 10:54:58 +00:00
parent 36ab38b1ee
commit cab91dca28

View File

@ -19,14 +19,63 @@ class Mai2Buddies(Mai2FestivalPlus):
return user_data
async def handle_get_user_new_item_api_request(self, data: Dict) -> Dict:
# TODO: Added in 1.41, implement this?
user_id = data["userId"]
version = data.get("version", 1041000)
user_playlog_list = data.get("userPlaylogList", [])
playlog_length = len(user_playlog_list)
if version != 1041000 or playlog_length == 0:
return {
"userId": user_id,
"itemKind": -1,
"itemId": -1,
}
# Play either the Standard or DX charts of 39, and have a maximum combo of exactly 339,
# and you will receive the nameplate 宇宙旅行券 (Space Travel Ticket).
valid_sankyuu_play = next(
(x for x in user_playlog_list if x["musicId"] in {146, 10146} and x["maxCombo"] == 339),
None
)
if valid_sankyuu_play is not None:
return {
"userId": user_id,
"itemKind": 2,
"itemId": 405604,
}
# Play 月面基地's charts in the following order: BASIC, EXPERT, ADVANCED, MASTER,
# by hitting all BREAK notes and nothing else all in the same set. The player
# receives the icon 旅行スタンプ(???) (Travel Stamp - ???).
if (
playlog_length != 4
or any(x for x in user_playlog_list if x["musicId"] != 11648)
or [x["level"] for x in user_playlog_list] != [0, 2, 1, 3]
):
return {
"userId": user_id,
"itemKind": -1,
"itemId": -1,
}
for play in user_playlog_list:
illegal_hits = (
play["tapCriticalPerfect"] + play["tapPerfect"] + play["tapGreat"] + play["tapGood"]
+ play["holdCriticalPerfect"] + play["holdPerfect"] + play["holdGreat"] + play["holdGood"]
+ play["slideCriticalPerfect"] + play["slidePerfect"] + play["slideGreat"] + play["slideGood"]
+ play["touchCriticalPerfect"] + play["touchPerfect"] + play["touchGreat"] + play["touchGood"]
)
if illegal_hits > 0 or play["breakMiss"] > 0:
return {
"userId": user_id,
"itemKind": -1,
"itemId": -1,
}
return {
"userId": user_id,
"itemKind": -1,
"itemId": -1,
"itemKind": 3,
"itemId": 409506,
}