From a4d52431080795d73709b854e7dd8b63961f1593 Mon Sep 17 00:00:00 2001 From: drmext <71258889+drmext@users.noreply.github.com> Date: Tue, 13 Jun 2023 21:23:13 +0000 Subject: [PATCH] BPL --- modules/iidx/iidx30gamesystem.py | 2 +- modules/iidx/iidx30lobby.py | 88 +++++++++++++++++++++++++------- 2 files changed, 70 insertions(+), 20 deletions(-) diff --git a/modules/iidx/iidx30gamesystem.py b/modules/iidx/iidx30gamesystem.py index b9c6cd0..8bb32ad 100644 --- a/modules/iidx/iidx30gamesystem.py +++ b/modules/iidx/iidx30gamesystem.py @@ -31,7 +31,7 @@ async def iidx30gamesystem_systeminfo(request: Request): E.gradeOpenPhase(val=2), E.isEiseiOpenFlg(val=1), E.WorldTourismOpenList(val=1), - E.BPLBattleOpenPhase(val=2), + E.BPLBattleOpenPhase(val=3), *[ E.music_open( E.music_id(s, __type="s32"), diff --git a/modules/iidx/iidx30lobby.py b/modules/iidx/iidx30lobby.py index 39e630f..18e924e 100644 --- a/modules/iidx/iidx30lobby.py +++ b/modules/iidx/iidx30lobby.py @@ -10,7 +10,8 @@ router = APIRouter(prefix="/lobby", tags=["lobby"]) router.model_whitelist = ["LDJ"] -host = {} +arena_host = {} +bpl_host = {} @router.post("/{gameinfo}/IIDX30lobby/entry") @@ -24,29 +25,29 @@ async def iidx30lobby_entry(request: Request): gp = root.find("address/gp").text la = root.find("address/la").text.split() - if host and time() < host["time"]: + if arena_host and time() < arena_host["time"]: # test menu reset - if host["ga"] == ga: - is_host = 1 - host["time"] = time() + 30 + if arena_host["ga"] == ga: + is_arena_host = 1 + arena_host["time"] = time() + 30 else: - is_host = 0 + is_arena_host = 0 response = E.response( E.IIDX30lobby( - E.host(is_host, __type="bool"), + E.host(is_arena_host, __type="bool"), E.matching_class(arena_class, __type="s32"), E.address( - E.ga(host["ga"], __type="u8"), - E.gp(host["gp"], __type="u16"), - E.la(host["la"], __type="u8"), + E.ga(arena_host["ga"], __type="u8"), + E.gp(arena_host["gp"], __type="u16"), + E.la(arena_host["la"], __type="u8"), ), ) ) else: - host["ga"] = ga - host["gp"] = gp - host["la"] = la - host["time"] = time() + 30 + arena_host["ga"] = ga + arena_host["gp"] = gp + arena_host["la"] = la + arena_host["time"] = time() + 30 response = E.response( E.IIDX30lobby( E.host(1, __type="bool"), @@ -78,10 +79,10 @@ async def iidx30lobby_delete(request: Request): request_info = await core_process_request(request) # normal reset - del host["ga"] - del host["gp"] - del host["la"] - del host["time"] + del arena_host["ga"] + del arena_host["gp"] + del arena_host["la"] + del arena_host["time"] response = E.response(E.IIDX30lobby()) response_body, response_headers = await core_prepare_response(request, response) @@ -92,7 +93,49 @@ async def iidx30lobby_delete(request: Request): async def iidx30lobby_bplbattle_entry(request: Request): request_info = await core_process_request(request) - response = E.response(E.IIDX30lobby()) + root = request_info["root"][0] + sp_dp = root.find("play_style").text + arena_class = root.find("arena_class").text + password = root.find("passward").text # passward + ga = root.find("address/ga").text.split() + gp = root.find("address/gp").text + la = root.find("address/la").text.split() + + if bpl_host and password in bpl_host and time() < bpl_host[password]["time"]: + # test menu reset + if bpl_host[password]["ga"] == ga: + is_bpl_host = 1 + bpl_host[password]["time"] = time() + 30 + else: + is_bpl_host = 0 + response = E.response( + E.IIDX30lobby( + E.host(is_bpl_host, __type="bool"), + E.matching_class(arena_class, __type="s32"), + E.address( + E.ga(bpl_host[password]["ga"], __type="u8"), + E.gp(bpl_host[password]["gp"], __type="u16"), + E.la(bpl_host[password]["la"], __type="u8"), + ), + ) + ) + else: + bpl_host[password] = {} + bpl_host[password]["ga"] = ga + bpl_host[password]["gp"] = gp + bpl_host[password]["la"] = la + bpl_host[password]["time"] = time() + 30 + response = E.response( + E.IIDX30lobby( + E.host(1, __type="bool"), + E.matching_class(arena_class, __type="s32"), + E.address( + E.ga(ga, __type="u8"), + E.gp(gp, __type="u16"), + E.la(la, __type="u8"), + ), + ) + ) response_body, response_headers = await core_prepare_response(request, response) return Response(content=response_body, headers=response_headers) @@ -112,6 +155,13 @@ async def iidx30lobby_bplbattle_update(request: Request): async def iidx30lobby_bplbattle_delete(request: Request): request_info = await core_process_request(request) + root = request_info["root"][0] + ga = root.find("address/ga").text.split() + + # normal reset + for host in bpl_host: + if bpl_host[host]["ga"] == ga: + del bpl_host[host] response = E.response(E.IIDX30lobby()) response_body, response_headers = await core_prepare_response(request, response)