[chuni] Improve GetGameMapAreaConditionApi

This commit is contained in:
beerpsi 2024-06-23 00:08:53 +07:00
parent 3979a020a6
commit ce124ffe13
2 changed files with 159 additions and 102 deletions

View File

@ -49,11 +49,12 @@ class ChuniConstants:
class MapAreaConditionType(Enum): class MapAreaConditionType(Enum):
UNLOCKED = "0" UNLOCKED = 0
MAP_AREA_CLEARED = "2" MAP_CLEARED = 1
TROPHY_OBTAINED = "3" MAP_AREA_CLEARED = 2
TROPHY_OBTAINED = 3
class MapAreaConditionLogicalOperator(Enum): class MapAreaConditionLogicalOperator(Enum):
OR = "0" AND = 1
AND = "1" OR = 2

View File

@ -1,8 +1,11 @@
from datetime import timedelta
from typing import Dict from typing import Dict
from sqlalchemy.dialects.mysql.base import MySQLExecutionContext
from core.config import CoreConfig from core.config import CoreConfig
from titles.chuni.sunplus import ChuniSunPlus from titles.chuni.sunplus import ChuniSunPlus
from titles.chuni.const import ChuniConstants, MapAreaConditionLogicalOperator, MapAreaConditionType from titles.chuni.const import ChuniConstants, MapAreaConditionLogicalOperator, MapAreaConditionType
from titles.chuni.config import ChuniConfig from titles.chuni.config import ChuniConfig
@ -69,176 +72,229 @@ class ChuniLuminous(ChuniSunPlus):
async def handle_get_game_map_area_condition_api_request(self, data: Dict) -> Dict: 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. # There is no game data for this, everything is server side.
# TODO: Figure out conditions for 1UM1N0US ep.111 # However, we can selectively show/hide events as data is imported into the server.
return { events = await self.data.static.get_enabled_events(self.version)
"length": "7", event_by_id = {evt["eventId"]: evt for evt in events}
"gameMapAreaConditionList": [ conditions = []
# Secret AREA: MUSIC GAME
# 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 "mapAreaId": 2206201, # BlythE ULTIMA
"length": "1", "length": 1,
# Obtain the trophy "MISSION in progress", which is only available # Obtain the trophy "MISSION in progress".
# when running the first CHUNITHM mission
"mapAreaConditionList": [ "mapAreaConditionList": [
{ {
"type": MapAreaConditionType.TROPHY_OBTAINED.value, "type": MapAreaConditionType.TROPHY_OBTAINED.value,
"conditionId": "6832", "conditionId": 6832,
"logicalOpe": MapAreaConditionLogicalOperator.AND.value, "logicalOpe": MapAreaConditionLogicalOperator.AND.value,
"startDate": "2023-12-14 07:00:00.0", "startDate": start_date,
"endDate": "2024-01-25 02:00:00.0", "endDate": mission_in_progress_end_date,
} }
], ],
}, },
{ {
"mapAreaId": "2206202", # PRIVATE SERVICE ULTIMA "mapAreaId": 2206202, # PRIVATE SERVICE ULTIMA
"length": "1", "length": 1,
# Obtain the trophy "MISSION in progress", which is only available # Obtain the trophy "MISSION in progress".
# when running the first CHUNITHM mission
"mapAreaConditionList": [ "mapAreaConditionList": [
{ {
"type": MapAreaConditionType.TROPHY_OBTAINED.value, "type": MapAreaConditionType.TROPHY_OBTAINED.value,
"conditionId": "6832", "conditionId": 6832,
"logicalOpe": MapAreaConditionLogicalOperator.AND.value, "logicalOpe": MapAreaConditionLogicalOperator.AND.value,
"startDate": "2023-12-14 07:00:00.0", "startDate": start_date,
"endDate": "2024-01-25 02:00:00.0", "endDate": mission_in_progress_end_date,
} }
], ],
}, },
{ {
"mapAreaId": "2206203", # New York Back Raise "mapAreaId": 2206203, # New York Back Raise
"length": "1", "length": 1,
# SS NightTheater's EXPERT chart and get the title # SS NightTheater's EXPERT chart and get the title
# "今宵、劇場に映し出される景色とは――――。" # "今宵、劇場に映し出される景色とは――――。"
"mapAreaConditionList": [ "mapAreaConditionList": [
{ {
"type": MapAreaConditionType.TROPHY_OBTAINED.value, "type": MapAreaConditionType.TROPHY_OBTAINED.value,
"conditionId": "6833", "conditionId": 6833,
"logicalOpe": MapAreaConditionLogicalOperator.AND.value, "logicalOpe": MapAreaConditionLogicalOperator.AND.value,
"startDate": "2023-12-14 07:00:00.0", "startDate": start_date,
"endDate": "2099-12-31 00:00:00.0", "endDate": "2099-12-31 00:00:00.0",
}, },
], ],
}, },
{ {
"mapAreaId": "2206204", # Spasmodic "mapAreaId": 2206204, # Spasmodic
"length": "2", "length": 2,
# - Get 1 miss on Random (any difficulty) and get the title "当たり待ち" # - Get 1 miss on Random (any difficulty) and get the title "当たり待ち"
# - Get 1 miss on 花たちに希望を (any difficulty) and get the title "花たちに希望を" # - Get 1 miss on 花たちに希望を (any difficulty) and get the title "花たちに希望を"
"mapAreaConditionList": [ "mapAreaConditionList": [
{ {
"type": MapAreaConditionType.TROPHY_OBTAINED.value, "type": MapAreaConditionType.TROPHY_OBTAINED.value,
"conditionId": "6834", "conditionId": 6834,
"logicalOpe": MapAreaConditionLogicalOperator.AND.value, "logicalOpe": MapAreaConditionLogicalOperator.AND.value,
"startDate": "2023-12-14 07:00:00.0", "startDate": start_date,
"endDate": "2099-12-31 00:00:00.0", "endDate": "2099-12-31 00:00:00.0",
}, },
{ {
"type": MapAreaConditionType.TROPHY_OBTAINED.value, "type": MapAreaConditionType.TROPHY_OBTAINED.value,
"conditionId": "6835", "conditionId": 6835,
"logicalOpe": MapAreaConditionLogicalOperator.AND.value, "logicalOpe": MapAreaConditionLogicalOperator.AND.value,
"startDate": "2023-12-14 07:00:00.0", "startDate": start_date,
"endDate": "2099-12-31 00:00:00.0", "endDate": "2099-12-31 00:00:00.0",
}, },
], ],
}, },
{ {
"mapAreaId": "2206205", # ΩΩPARTS "mapAreaId": 2206205, # ΩΩPARTS
"length": "2", "length": 2,
# - S Sage EXPERT to get the title "マターリ進行キボンヌ" # - S Sage EXPERT to get the title "マターリ進行キボンヌ"
# - Equip this title and play cab-to-cab with another person with this title # - Equip this title and play cab-to-cab with another person with this title
# to get "マターリしようよ" # 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": [ "mapAreaConditionList": [
{ {
"type": MapAreaConditionType.TROPHY_OBTAINED.value, "type": MapAreaConditionType.TROPHY_OBTAINED.value,
"conditionId": "6836", "conditionId": 6836,
"logicalOpe": MapAreaConditionLogicalOperator.AND.value, "logicalOpe": MapAreaConditionLogicalOperator.AND.value,
"startDate": "2023-12-14 07:00:00.0", "startDate": start_date,
"endDate": "2099-12-31 00:00:00.0", "endDate": "2099-12-31 00:00:00.0",
}, },
{ # {
"type": MapAreaConditionType.TROPHY_OBTAINED.value, # "type": MapAreaConditionType.TROPHY_OBTAINED.value,
"conditionId": "6837", # "conditionId": 6837,
"logicalOpe": MapAreaConditionLogicalOperator.AND.value, # "logicalOpe": MapAreaConditionLogicalOperator.AND.value,
"startDate": "2023-12-14 07:00:00.0", # "startDate": start_date,
"endDate": "2024-01-25 02:00:00.0", # "endDate": "2099-12-31 00:00:00.0",
}, # },
], ],
}, },
{ {
"mapAreaId": "2206206", # Blow My Mind "mapAreaId": 2206206, # Blow My Mind
"length": "1", "length": 1,
# SS on CHAOS EXPERT, Hydra EXPERT, Surive EXPERT and Jakarta PROGRESSION EXPERT # SS on CHAOS EXPERT, Hydra EXPERT, Surive EXPERT and Jakarta PROGRESSION EXPERT
# to get the title "Can you hear me?" # to get the title "Can you hear me?"
"mapAreaConditionList": [ "mapAreaConditionList": [
{ {
"type": MapAreaConditionType.TROPHY_OBTAINED.value, "type": MapAreaConditionType.TROPHY_OBTAINED.value,
"conditionId": "6838", "conditionId": 6838,
"logicalOpe": MapAreaConditionLogicalOperator.AND.value, "logicalOpe": MapAreaConditionLogicalOperator.AND.value,
"startDate": "2023-12-14 07:00:00.0", "startDate": start_date,
"endDate": "2099-12-31 00:00:00.0", "endDate": "2099-12-31 00:00:00.0",
}, },
], ],
}, },
{ {
"mapAreaId": "2206207", # VALLIS-NERIA "mapAreaId": 2206207, # VALLIS-NERIA
"length": "6", "length": 6,
# Finish the 6 other areas # Finish the 6 other areas
"mapAreaConditionList": [ "mapAreaConditionList": [
{ {
"type": MapAreaConditionType.MAP_AREA_CLEARED.value, "type": MapAreaConditionType.MAP_AREA_CLEARED.value,
"conditionId": str(x), "conditionId": x,
"logicalOpe": MapAreaConditionLogicalOperator.AND.value, "logicalOpe": MapAreaConditionLogicalOperator.AND.value,
"startDate": "2023-12-14 07:00:00.0", "startDate": start_date,
"endDate": "2099-12-31 00:00:00.0", "endDate": "2099-12-31 00:00:00.0",
} }
for x in range(2206201, 2206207) for x in range(2206201, 2206207)
], ],
}, },
# { ])
# "mapAreaId": "3229301", # Mystic Rainbow of LUMINOUS Area 1
# "length": "1", # LUMINOUS ep. I
# # Unlocks when any of the mainline LUMINOUS maps are completed? if 14005 in event_by_id:
# "mapAreaConditionList": [ start_date = event_by_id[14005]["startDate"].strftime(self.date_time_format)
# # TODO
# ] if not mystic_area_1_added:
# }, conditions.append(mystic_area_1_conditions)
# { mystic_area_1_added = True
# "mapAreaId": "3229302", # Mystic Rainbow of LUMINOUS Area 2
# "length": "5", mystic_area_1_conditions["length"] += 1
# # Unlocks when LUMINOUS ep. I is completed mystic_area_1_conditions["mapAreaConditionList"].append(
# "mapAreaConditionList": [ {
# { "type": MapAreaConditionType.MAP_CLEARED.value,
# "type": MapAreaConditionType.MAP_AREA_CLEARED.value, "conditionId": 3020701,
# "conditionId": str(x), "logicalOpe": MapAreaConditionLogicalOperator.OR.value,
# "logicalOpe": MapAreaConditionLogicalOperator.AND.value, "startDate": start_date,
# "startDate": "2023-12-14 07:00:00.0", "endDate": "2099-12-31 00:00:00.0",
# "endDate": "2099-12-31 00:00:00.0", }
# } )
# for x in range(3220101, 3220106)
# ] conditions.append(
# }, {
# { "mapAreaId": 3229302, # Mystic Rainbow of LUMINOUS Area 2,
# "mapAreaId": "3229303", # Mystic Rainbow of LUMINOUS Area 3 "length": 1,
# "length": "5", # Unlocks when LUMINOUS ep. I is completed.
# # Unlocks when LUMINOUS ep. II is completed "mapAreaConditionList": [
# "mapAreaConditionList": [ {
# { "type": MapAreaConditionType.MAP_CLEARED.value,
# "type": MapAreaConditionType.MAP_AREA_CLEARED.value, "conditionId": 3020701,
# "conditionId": str(x), "logicalOpe": MapAreaConditionLogicalOperator.AND.value,
# "logicalOpe": MapAreaConditionLogicalOperator.AND.value, "startDate": start_date,
# "startDate": "2023-12-14 07:00:00.0", "endDate": "2099-12-31 00:00:00.0",
# "endDate": "2099-12-31 00:00:00.0", },
# } ],
# for x in range(3220201, 3220206) }
# ] )
# },
# { # LUMINOUS ep. II
# "mapAreaId": "3229304", # Mystic Rainbow of LUMINOUS Area 4 if 14250 in event_by_id:
# "length": "5", start_date = event_by_id[14250]["startDate"].strftime(self.date_time_format)
# # Unlocks when LUMINOUS ep. III is completed
# "mapAreaConditionList": [ 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,
} }