idac: even more round event implements

This commit is contained in:
UncleJim 2024-05-03 18:21:19 +08:00
parent 75a7dadc30
commit 8b7286ef18
5 changed files with 310 additions and 99 deletions

View File

@ -28,3 +28,7 @@ timetrial:
battle_event:
enabled: True
enabled_battle_event: "touhou_1st"
round_event:
enable: True
enabled_round: "S2R2"

View File

@ -149,6 +149,26 @@ class IDACTBattleGiftConfig:
default="touhou_1st",
)
class IDACRoundConfig:
def __init__(self, parent: "IDACConfig") -> None:
self.__config = parent
@property
def enable(self) -> bool:
return CoreConfig.get_config_field(
self.__config, "idac", "round_event", "enable", default=True
)
@property
def enabled_round(self) -> str:
return CoreConfig.get_config_field(
self.__config,
"idac",
"round_event",
"enabled_round",
default="S1R1",
)
class IDACConfig(dict):
def __init__(self) -> None:
@ -157,3 +177,4 @@ class IDACConfig(dict):
self.stamp = IDACStampConfig(self)
self.timetrial = IDACTimetrialConfig(self)
self.battle_gift = IDACTBattleGiftConfig(self)
self.round_event = IDACRoundConfig(self)

View File

@ -0,0 +1,229 @@
{
"round_event_id": 10,
"round_event_nm": "¥·©`¥º¥ó2¡¡2nd¥é¥¦¥ó¥É",
"start_dt": 1648072800,
"end_dt": 1651086000,
"round_start_rank": 0,
"save_filename": "",
"vscount": [
{
"reward_upper_limit": 180,
"reward_lower_limit": 180,
"reward": [
{
"reward_category": 21,
"reward_type": 462
}
]
},
{
"reward_upper_limit": 120,
"reward_lower_limit": 120,
"reward": [
{
"reward_category": 21,
"reward_type": 461
}
]
},
{
"reward_upper_limit": 80,
"reward_lower_limit": 80,
"reward": [
{
"reward_category": 22,
"reward_type": 516
}
]
},
{
"reward_upper_limit": 40,
"reward_lower_limit": 40,
"reward": [
{
"reward_category": 21,
"reward_type": 484
}
]
},
{
"reward_upper_limit": 10,
"reward_lower_limit": 10,
"reward": [
{
"reward_category": 21,
"reward_type": 483
}
]
}
],
"rank": [
{
"reward_upper_limit": 1,
"reward_lower_limit": 1,
"reward": [
{
"reward_category": 24,
"reward_type": 4333
}
]
},
{
"reward_upper_limit": 2,
"reward_lower_limit": 10,
"reward": [
{
"reward_category": 24,
"reward_type": 4334
}
]
},
{
"reward_upper_limit": 11,
"reward_lower_limit": 50,
"reward": [
{
"reward_category": 24,
"reward_type": 4335
}
]
},
{
"reward_upper_limit": 51,
"reward_lower_limit": 100,
"reward": [
{
"reward_category": 24,
"reward_type": 4336
}
]
},
{
"reward_upper_limit": 101,
"reward_lower_limit": 1000,
"reward": [
{
"reward_category": 24,
"reward_type": 4337
}
]
}
],
"point": [
],
"playable_course_list": [
{
"course_id": 4,
"course_day": 0
},
{
"course_id": 4,
"course_day": 1
},
{
"course_id": 6,
"course_day": 0
},
{
"course_id": 6,
"course_day": 1
},
{
"course_id": 12,
"course_day": 0
},
{
"course_id": 12,
"course_day": 1
},
{
"course_id": 14,
"course_day": 0
},
{
"course_id": 14,
"course_day": 1
},
{
"course_id": 16,
"course_day": 0
},
{
"course_id": 16,
"course_day": 1
},
{
"course_id": 18,
"course_day": 0
},
{
"course_id": 18,
"course_day": 1
},
{
"course_id": 20,
"course_day": 0
},
{
"course_id": 20,
"course_day": 1
},
{
"course_id": 22,
"course_day": 0
},
{
"course_id": 22,
"course_day": 1
},
{
"course_id": 24,
"course_day": 0
},
{
"course_id": 24,
"course_day": 1
},
{
"course_id": 26,
"course_day": 0
},
{
"course_id": 26,
"course_day": 1
},
{
"course_id": 44,
"course_day": 0
},
{
"course_id": 44,
"course_day": 1
},
{
"course_id": 46,
"course_day": 0
},
{
"course_id": 46,
"course_day": 1
},
{
"course_id": 48,
"course_day": 0
},
{
"course_id": 48,
"course_day": 1
},
{
"course_id": 50,
"course_day": 0
},
{
"course_id": 50,
"course_day": 1
}
]
}

View File

@ -93,4 +93,22 @@ class IDACOnlineRounds(BaseData):
return None
return result.lastrowid
# insert if the event does not exist in database
async def _try_load_round_event(
self, round_id: int, round_data: Dict
) -> Optional[int]:
sql = select(round_details).where(
round_details.c.round_id_in_json == round_id
)
result = self.execute(sql)
if result is None:
sql = insert(round_details).values(
round_details.c.round_id_in_json = round_id,
round_details.c.name = round_data["round_event_nm"],
round_details.c.season = 2, #default season 2
)
self.execute(sql)
return result.lastrowid
rid = result.fetchone()
return rid["id"]
#TODO: get top five players of last round event for Boot/GetConfigData

View File

@ -60,6 +60,23 @@ class IDACSeason2(IDACBase):
"timetrial_event_id"
)
# load the user configured round event (only one)
self.round_event_id = 0
self.round_event = []
if self.game_config.round_event.enable:
round = self.game_config.round_event.enabled_round:
if round is not None:
if not os.path.exists(f"./titles/idac/data/rounds/season{self.version+1}/{round}.json"):
self.logger.warning(f"Round info {round} is enabled but json file does not exist!")
else:
with open(
f"./titles/idac/data/rounds/season{self.version+1}/{round}.json", encoding="UTF-8"
) as f:
self.logger.debug(f"Loading round info {round}...")
tmp = json.load(f)
self.round_event_id = self.data.rounds._try_load_round_event(tmp["round_event_id"], tmp)
self.round_event.append(self._fix_dates(tmp))
# load the user configured battle gifts (only one)
self.battle_gift_event = None
if self.game_config.battle_gift.enable:
@ -170,104 +187,7 @@ class IDACSeason2(IDACBase):
[self.battle_gift_event] if self.battle_gift_event else []
),
# online battle round event
"round_event": [
{
"round_event_id": 30,
"round_event_nm": f"{self.core_cfg.server.name} Event",
"start_dt": int(
datetime.strptime("2023-01-01", "%Y-%m-%d").timestamp()
),
"end_dt": int(
datetime.strptime("2029-01-01", "%Y-%m-%d").timestamp()
),
"round_start_rank": 0,
"save_filename": "0",
# https://info-initialdac.sega.jp/1898/
"vscount": [
{
"reward_upper_limit": 10,
"reward_lower_limit": 10,
"reward": [{"reward_category": 21, "reward_type": 483}],
},
{
"reward_upper_limit": 40,
"reward_lower_limit": 40,
"reward": [{"reward_category": 21, "reward_type": 484}],
},
{
"reward_upper_limit": 80,
"reward_lower_limit": 80,
"reward": [{"reward_category": 22, "reward_type": 516}],
},
{
"reward_upper_limit": 120,
"reward_lower_limit": 120,
"reward": [{"reward_category": 21, "reward_type": 461}],
},
{
"reward_upper_limit": 180,
"reward_lower_limit": 180,
"reward": [{"reward_category": 21, "reward_type": 462}],
},
],
"rank": [],
"point": [],
"playable_course_list": [
{"course_id": 4, "course_day": 0},
{"course_id": 4, "course_day": 1},
{"course_id": 6, "course_day": 0},
{"course_id": 6, "course_day": 1},
{"course_id": 8, "course_day": 0},
{"course_id": 8, "course_day": 1},
{"course_id": 10, "course_day": 0},
{"course_id": 10, "course_day": 1},
{"course_id": 12, "course_day": 0},
{"course_id": 12, "course_day": 1},
{"course_id": 14, "course_day": 0},
{"course_id": 14, "course_day": 1},
{"course_id": 16, "course_day": 0},
{"course_id": 16, "course_day": 1},
{"course_id": 18, "course_day": 0},
{"course_id": 18, "course_day": 1},
{"course_id": 20, "course_day": 0},
{"course_id": 20, "course_day": 1},
{"course_id": 22, "course_day": 0},
{"course_id": 22, "course_day": 1},
{"course_id": 24, "course_day": 0},
{"course_id": 24, "course_day": 1},
{"course_id": 26, "course_day": 0},
{"course_id": 26, "course_day": 1},
{"course_id": 36, "course_day": 0},
{"course_id": 36, "course_day": 1},
{"course_id": 38, "course_day": 0},
{"course_id": 38, "course_day": 1},
{"course_id": 40, "course_day": 0},
{"course_id": 40, "course_day": 1},
{"course_id": 42, "course_day": 0},
{"course_id": 42, "course_day": 1},
{"course_id": 44, "course_day": 0},
{"course_id": 44, "course_day": 1},
{"course_id": 46, "course_day": 0},
{"course_id": 46, "course_day": 1},
{"course_id": 48, "course_day": 0},
{"course_id": 48, "course_day": 1},
{"course_id": 50, "course_day": 0},
{"course_id": 50, "course_day": 1},
{"course_id": 52, "course_day": 0},
{"course_id": 52, "course_day": 1},
{"course_id": 54, "course_day": 0},
{"course_id": 54, "course_day": 1},
{"course_id": 56, "course_day": 0},
{"course_id": 56, "course_day": 1},
{"course_id": 58, "course_day": 0},
{"course_id": 58, "course_day": 1},
{"course_id": 68, "course_day": 0},
{"course_id": 68, "course_day": 1},
{"course_id": 70, "course_day": 0},
{"course_id": 70, "course_day": 1},
],
}
],
"round_event": self.round_event,
"last_round_event": [],
"last_round_event_ranking": [],
"round_event_exp": [],
@ -979,6 +899,25 @@ class IDACSeason2(IDACBase):
}
)
# get the users'd round data
round_info = []
ri = self.data.rounds.get_round_info_by_id(user_id, self.round_event_id)
if ri is not None:
r = self.data.rounds.get_round_rank_by_id(user_id, self.round_event_id)
round_ranking = r._asdict()
tmp = ri._asdict()
del tmp["id"]
del tmp["user"]
del tmp["round_id"]
del tmp["play_dt"]
tmp["rank"] = round_ranking["find_in_set_1"]
# TODO: calculate this
tmp["total_round_point"] = 0
round_info.append(tmp)
# get the user's course, required for the "course proeficiency"
courses = await self.data.item.get_courses(user_id)
course_data = []
@ -1260,7 +1199,7 @@ class IDACSeason2(IDACBase):
# first_distribution related are useless since this is all handled by server
"battle_gift_data": battle_gift_data,
"ticket_data": ticket_data,
"round_event": [],
"round_event": round_info,
"last_round_event": [],
"past_round_event": [],
"total_round_point": 0,