from typing import Dict from core.config import CoreConfig from titles.mai2.festivalplus import Mai2FestivalPlus from titles.mai2.const import Mai2Constants from titles.mai2.config import Mai2Config class Mai2Buddies(Mai2FestivalPlus): def __init__(self, cfg: CoreConfig, game_cfg: Mai2Config) -> None: super().__init__(cfg, game_cfg) self.version = Mai2Constants.VER_MAIMAI_DX_BUDDIES async def handle_cm_get_user_preview_api_request(self, data: Dict) -> Dict: user_data = await super().handle_cm_get_user_preview_api_request(data) # hardcode lastDataVersion for CardMaker user_data["lastDataVersion"] = "1.40.00" return user_data async def handle_get_user_new_item_api_request(self, data: Dict) -> Dict: 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": 3, "itemId": 409506, }