From 6f7f08d019c6595f008d10d2c08daf4b32048980 Mon Sep 17 00:00:00 2001 From: beerpsi Date: Sun, 23 Jun 2024 00:08:53 +0700 Subject: [PATCH] [chuni] Improve GetGameMapAreaConditionApi --- titles/chuni/const.py | 17 +- titles/chuni/luminous.py | 394 +++++++++++++++++++++++---------------- 2 files changed, 247 insertions(+), 164 deletions(-) diff --git a/titles/chuni/const.py b/titles/chuni/const.py index ea063fa..9fff524 100644 --- a/titles/chuni/const.py +++ b/titles/chuni/const.py @@ -1,3 +1,6 @@ +from enum import Enum + + class ChuniConstants: GAME_CODE = "SDBT" GAME_CODE_NEW = "SDHD" @@ -42,4 +45,16 @@ class ChuniConstants: @classmethod def game_ver_to_string(cls, ver: int): - return cls.VERSION_NAMES[ver] \ No newline at end of file + return cls.VERSION_NAMES[ver] + + +class MapAreaConditionType(Enum): + UNLOCKED = 0 + MAP_CLEARED = 1 + MAP_AREA_CLEARED = 2 + TROPHY_OBTAINED = 3 + + +class MapAreaConditionLogicalOperator(Enum): + AND = 1 + OR = 2 diff --git a/titles/chuni/luminous.py b/titles/chuni/luminous.py index e3f7024..af4b0f1 100644 --- a/titles/chuni/luminous.py +++ b/titles/chuni/luminous.py @@ -1,9 +1,10 @@ +from datetime import timedelta from typing import Dict from core.config import CoreConfig from core.utils import Utils from titles.chuni.sunplus import ChuniSunPlus -from titles.chuni.const import ChuniConstants +from titles.chuni.const import ChuniConstants, MapAreaConditionLogicalOperator, MapAreaConditionType from titles.chuni.config import ChuniConfig @@ -49,168 +50,6 @@ class ChuniLuminous(ChuniSunPlus): user_data["lastDataVersion"] = "2.20.00" return user_data - async def handle_get_game_map_area_condition_api_request(self, data: Dict) -> Dict: - return { - "length": 1, - "gameMapAreaConditionList": [ - { - "mapAreaId": "2206201", # BlythE ULTIMA - "length": 1, - "mapAreaConditionList": [ - { - "type": "3", - "conditionId": "6832", # MISSION in progress - "logicalOpe": "1", - "startDate": "2023-12-14 07:00:00.0", - "endDate": "2024-01-25 00:00:00.0", - }, - ], - }, - { - "mapAreaId": "2206202", # PRIVATE SERVICE ULTIMA - "length": 1, - "mapAreaConditionList": [ - { - "type": "3", - "conditionId": "6832", # MISSION in progress - "logicalOpe": "1", - "startDate": "2023-12-14 07:00:00.0", - "endDate": "2024-01-25 00:00:00.0", - }, - ], - }, - { - "mapAreaId": "2206203", # New York Back Raise - "length": 1, - "mapAreaConditionList": [ - { - "type": "3", - "conditionId": "6833", # 今宵、劇場に映し出される景色とは――――。 - "logicalOpe": "1", - "startDate": "2023-12-14 07:00:00.0", - "endDate": "2099-12-31 00:00:00.0", - }, - ], - }, - { - "mapAreaId": "2206204", # Spasmodic - "length": 2, - "mapAreaConditionList": [ - { - "type": "3", - "conditionId": "6834", # 今宵、劇場に映し出される景色とは――――。 - "logicalOpe": "1", - "startDate": "2023-12-14 07:00:00.0", - "endDate": "2099-12-31 00:00:00.0", - }, - { - "type": "3", - "conditionId": "6835", # 今宵、劇場に映し出される景色とは――――。 - "logicalOpe": "1", - "startDate": "2023-12-14 07:00:00.0", - "endDate": "2099-12-31 00:00:00.0", - }, - ], - }, - { - "mapAreaId": "2206205", # ΩΩPARTS - "length": 2, - "mapAreaConditionList": [ - { - "type": "3", - "conditionId": "6836", # マターリ進行キボンヌ - "logicalOpe": "1", - "startDate": "2023-12-14 07:00:00.0", - "endDate": "2099-12-31 00:00:00.0", - }, - { - "type": "3", - "conditionId": "6837", # マターリしようよ - "logicalOpe": "1", - "startDate": "2023-12-14 07:00:00.0", - "endDate": "2024-01-25 00:00:00.0", - }, - ], - }, - { - "mapAreaId": "2206206", # Blow My Mind - "length": 1, - "mapAreaConditionList": [ - { - "type": "3", - "conditionId": "6838", # Can you hear me? - "logicalOpe": "1", - "startDate": "2023-12-14 07:00:00.0", - "endDate": "2099-12-31 00:00:00.0", - }, - ], - }, - # TODO: Proper VALLIS-NERIA: Unlock other areas - # { - # "mapAreaId": "2206207", - # "length": 0, - # "mapAreaConditionList": [ - - # ], - # } - { - "mapAreaId": "2206207", - "length": 7, - "mapAreaConditionList": [ - { - "type": "3", - "conditionId": "6832", # MISSION in progress - "logicalOpe": "1", - "startDate": "2023-12-14 07:00:00.0", - "endDate": "2024-01-25 00:00:00.0", - }, - { - "type": "3", - "conditionId": "6833", # 今宵、劇場に映し出される景色とは――――。 - "logicalOpe": "1", - "startDate": "2023-12-14 07:00:00.0", - "endDate": "2099-12-31 00:00:00.0", - }, - { - "type": "3", - "conditionId": "6834", # 今宵、劇場に映し出される景色とは――――。 - "logicalOpe": "1", - "startDate": "2023-12-14 07:00:00.0", - "endDate": "2099-12-31 00:00:00.0", - }, - { - "type": "3", - "conditionId": "6835", # 今宵、劇場に映し出される景色とは――――。 - "logicalOpe": "1", - "startDate": "2023-12-14 07:00:00.0", - "endDate": "2099-12-31 00:00:00.0", - }, - { - "type": "3", - "conditionId": "6836", # マターリ進行キボンヌ - "logicalOpe": "1", - "startDate": "2023-12-14 07:00:00.0", - "endDate": "2099-12-31 00:00:00.0", - }, - { - "type": "3", - "conditionId": "6837", # マターリしようよ - "logicalOpe": "1", - "startDate": "2023-12-14 07:00:00.0", - "endDate": "2024-01-25 00:00:00.0", - }, - { - "type": "3", - "conditionId": "6838", # Can you hear me? - "logicalOpe": "1", - "startDate": "2023-12-14 07:00:00.0", - "endDate": "2099-12-31 00:00:00.0", - }, - ], - } - ] - } - async def handle_get_user_c_mission_api_request(self, data: Dict) -> Dict: user_id = data["userId"] mission_id = data["missionId"] @@ -257,3 +96,232 @@ class ChuniLuminous(ChuniSunPlus): "userId": user_id, "userNetBattleData": net_battle, } + + async def handle_get_game_map_area_condition_api_request(self, data: Dict) -> Dict: + # There is no game data for this, everything is server side. + # However, we can selectively show/hide events as data is imported into the server. + events = await self.data.static.get_enabled_events(self.version) + event_by_id = {evt["eventId"]: evt for evt in events} + conditions = [] + + # The Mystic Rainbow of LUMINOUS map unlocks when any mainline LUMINOUS area + # (ep. I, ep. II, ep. III) are completed. + mystic_area_1_conditions = { + "mapAreaId": 3229301, # Mystic Rainbow of LUMINOUS Area 1 + "length": 0, + "mapAreaConditionList": [], + } + mystic_area_1_added = False + + # Secret AREA: MUSIC GAME + if 14029 in event_by_id: + start_date = event_by_id[14029]["startDate"].strftime(self.date_time_format) + mission_in_progress_end_date = "2099-12-31 00:00:00.0" + + # The "MISSION in progress" trophy required to trigger the secret area + # is only available in the first CHUNITHM mission. If the second mission + # (event ID 14214) was imported into ARTEMiS, we disable the requirement + # for this trophy. + if 14214 in event_by_id: + mission_in_progress_end_date = (event_by_id[14214]["startDate"] - timedelta(hours=2)).strftime(self.date_time_format) + + conditions.extend([ + { + "mapAreaId": 2206201, # BlythE ULTIMA + "length": 1, + # Obtain the trophy "MISSION in progress". + "mapAreaConditionList": [ + { + "type": MapAreaConditionType.TROPHY_OBTAINED.value, + "conditionId": 6832, + "logicalOpe": MapAreaConditionLogicalOperator.AND.value, + "startDate": start_date, + "endDate": mission_in_progress_end_date, + } + ], + }, + { + "mapAreaId": 2206202, # PRIVATE SERVICE ULTIMA + "length": 1, + # Obtain the trophy "MISSION in progress". + "mapAreaConditionList": [ + { + "type": MapAreaConditionType.TROPHY_OBTAINED.value, + "conditionId": 6832, + "logicalOpe": MapAreaConditionLogicalOperator.AND.value, + "startDate": start_date, + "endDate": mission_in_progress_end_date, + } + ], + }, + { + "mapAreaId": 2206203, # New York Back Raise + "length": 1, + # SS NightTheater's EXPERT chart and get the title + # "今宵、劇場に映し出される景色とは――――。" + "mapAreaConditionList": [ + { + "type": MapAreaConditionType.TROPHY_OBTAINED.value, + "conditionId": 6833, + "logicalOpe": MapAreaConditionLogicalOperator.AND.value, + "startDate": start_date, + "endDate": "2099-12-31 00:00:00.0", + }, + ], + }, + { + "mapAreaId": 2206204, # Spasmodic + "length": 2, + # - Get 1 miss on Random (any difficulty) and get the title "当たり待ち" + # - Get 1 miss on 花たちに希望を (any difficulty) and get the title "花たちに希望を" + "mapAreaConditionList": [ + { + "type": MapAreaConditionType.TROPHY_OBTAINED.value, + "conditionId": 6834, + "logicalOpe": MapAreaConditionLogicalOperator.AND.value, + "startDate": start_date, + "endDate": "2099-12-31 00:00:00.0", + }, + { + "type": MapAreaConditionType.TROPHY_OBTAINED.value, + "conditionId": 6835, + "logicalOpe": MapAreaConditionLogicalOperator.AND.value, + "startDate": start_date, + "endDate": "2099-12-31 00:00:00.0", + }, + ], + }, + { + "mapAreaId": 2206205, # ΩΩPARTS + "length": 2, + # - S Sage EXPERT to get the title "マターリ進行キボンヌ" + # - Equip this title and play cab-to-cab with another person with this title + # to get "マターリしようよ". Disabled because it is difficult to play cab2cab + # on data setups. A network operator may consider re-enabling it by uncommenting + # the second condition. + "mapAreaConditionList": [ + { + "type": MapAreaConditionType.TROPHY_OBTAINED.value, + "conditionId": 6836, + "logicalOpe": MapAreaConditionLogicalOperator.AND.value, + "startDate": start_date, + "endDate": "2099-12-31 00:00:00.0", + }, + # { + # "type": MapAreaConditionType.TROPHY_OBTAINED.value, + # "conditionId": 6837, + # "logicalOpe": MapAreaConditionLogicalOperator.AND.value, + # "startDate": start_date, + # "endDate": "2099-12-31 00:00:00.0", + # }, + ], + }, + { + "mapAreaId": 2206206, # Blow My Mind + "length": 1, + # SS on CHAOS EXPERT, Hydra EXPERT, Surive EXPERT and Jakarta PROGRESSION EXPERT + # to get the title "Can you hear me?" + "mapAreaConditionList": [ + { + "type": MapAreaConditionType.TROPHY_OBTAINED.value, + "conditionId": 6838, + "logicalOpe": MapAreaConditionLogicalOperator.AND.value, + "startDate": start_date, + "endDate": "2099-12-31 00:00:00.0", + }, + ], + }, + { + "mapAreaId": 2206207, # VALLIS-NERIA + "length": 6, + # Finish the 6 other areas + "mapAreaConditionList": [ + { + "type": MapAreaConditionType.MAP_AREA_CLEARED.value, + "conditionId": x, + "logicalOpe": MapAreaConditionLogicalOperator.AND.value, + "startDate": start_date, + "endDate": "2099-12-31 00:00:00.0", + } + for x in range(2206201, 2206207) + ], + }, + ]) + + # LUMINOUS ep. I + if 14005 in event_by_id: + start_date = event_by_id[14005]["startDate"].strftime(self.date_time_format) + + if not mystic_area_1_added: + conditions.append(mystic_area_1_conditions) + mystic_area_1_added = True + + mystic_area_1_conditions["length"] += 1 + mystic_area_1_conditions["mapAreaConditionList"].append( + { + "type": MapAreaConditionType.MAP_CLEARED.value, + "conditionId": 3020701, + "logicalOpe": MapAreaConditionLogicalOperator.OR.value, + "startDate": start_date, + "endDate": "2099-12-31 00:00:00.0", + } + ) + + conditions.append( + { + "mapAreaId": 3229302, # Mystic Rainbow of LUMINOUS Area 2, + "length": 1, + # Unlocks when LUMINOUS ep. I is completed. + "mapAreaConditionList": [ + { + "type": MapAreaConditionType.MAP_CLEARED.value, + "conditionId": 3020701, + "logicalOpe": MapAreaConditionLogicalOperator.AND.value, + "startDate": start_date, + "endDate": "2099-12-31 00:00:00.0", + }, + ], + } + ) + + # LUMINOUS ep. II + if 14250 in event_by_id: + start_date = event_by_id[14250]["startDate"].strftime(self.date_time_format) + + if not mystic_area_1_added: + conditions.append(mystic_area_1_conditions) + mystic_area_1_added = True + + mystic_area_1_conditions["length"] += 1 + mystic_area_1_conditions["mapAreaConditionList"].append( + { + "type": MapAreaConditionType.MAP_CLEARED.value, + "conditionId": 3020702, + "logicalOpe": MapAreaConditionLogicalOperator.OR.value, + "startDate": start_date, + "endDate": "2099-12-31 00:00:00.0", + } + ) + + conditions.append( + { + "mapAreaId": 3229303, # Mystic Rainbow of LUMINOUS Area 3, + "length": 1, + # Unlocks when LUMINOUS ep. II is completed. + "mapAreaConditionList": [ + { + "type": MapAreaConditionType.MAP_CLEARED.value, + "conditionId": 3020702, + "logicalOpe": MapAreaConditionLogicalOperator.AND.value, + "startDate": start_date, + "endDate": "2099-12-31 00:00:00.0", + }, + ], + } + ) + + + return { + "length": len(conditions), + "gameMapAreaConditionList": conditions, + }