From c74e0a40eda0406a4aa1a53e09fce7150886e9cf Mon Sep 17 00:00:00 2001 From: drmext <71258889+drmext@users.noreply.github.com> Date: Sat, 20 Apr 2024 16:45:05 +0000 Subject: [PATCH] Fix --- modules/iidx/iidx31gamesystem.py | 1 + modules/iidx/iidx31grade.py | 10 +++- modules/iidx/iidx31music.py | 22 ++++++++ modules/iidx/iidx31pc.py | 93 ++++++++++++++++++++++++++++---- modules/iidx/iidx31streaming.py | 28 ++++++++++ 5 files changed, 142 insertions(+), 12 deletions(-) create mode 100644 modules/iidx/iidx31streaming.py diff --git a/modules/iidx/iidx31gamesystem.py b/modules/iidx/iidx31gamesystem.py index 152a58b..f3d012c 100644 --- a/modules/iidx/iidx31gamesystem.py +++ b/modules/iidx/iidx31gamesystem.py @@ -186,6 +186,7 @@ async def iidx31gamesystem_systeminfo(request: Request): E.CommonBossPhase(val=0), E.Event1Phase(val=0), E.Event1Value(val=0), + E.ExtraBossEventPhase(val=0), E.isNewSongAnother12OpenFlg(val=1), E.isKiwamiOpenFlg(val=1), E.WorldTourismOpenList(val=-1), diff --git a/modules/iidx/iidx31grade.py b/modules/iidx/iidx31grade.py index ccce5f2..6e87262 100644 --- a/modules/iidx/iidx31grade.py +++ b/modules/iidx/iidx31grade.py @@ -89,13 +89,19 @@ async def iidx31grade_raised(request: Request): game_profile["grade_values"] = grades grade_sp = db.table("iidx_class_best").search( - (where("iidx_id") == iidx_id) & (where("gtype") == 0) & (where("cstage") == 4) + (where("game_version") == game_version) + & (where("iidx_id") == iidx_id) + & (where("gtype") == 0) + & (where("cstage") == 4) ) game_profile["grade_single"] = max([x["gid"] for x in grade_sp], default=-1) grade_dp = db.table("iidx_class_best").search( - (where("iidx_id") == iidx_id) & (where("gtype") == 1) & (where("cstage") == 4) + (where("game_version") == game_version) + & (where("iidx_id") == iidx_id) + & (where("gtype") == 1) + & (where("cstage") == 4) ) game_profile["grade_double"] = max([x["gid"] for x in grade_dp], default=-1) diff --git a/modules/iidx/iidx31music.py b/modules/iidx/iidx31music.py index 751d327..c654c58 100644 --- a/modules/iidx/iidx31music.py +++ b/modules/iidx/iidx31music.py @@ -348,6 +348,7 @@ async def iidx31music_reg(request: Request): "opname": config.arcade, "name": game_profile["djname"], "pid": game_profile["region"], + "back": game_profile.get("back", 0), "body": game_profile["body"], "face": game_profile["face"], "hair": game_profile["hair"], @@ -373,6 +374,7 @@ async def iidx31music_reg(request: Request): opname=score["opname"], name=score["name"], pid=score["pid"], + back=score["back"], body=score["body"], face=score["face"], hair=score["hair"], @@ -556,3 +558,23 @@ async def iidx31music_retry(request: Request): response_body, response_headers = await core_prepare_response(request, response) return Response(content=response_body, headers=response_headers) + + +@router.post("/{gameinfo}/IIDX31music/play") +async def iidx31music_play(request: Request): + request_info = await core_process_request(request) + + response = E.response(E.IIDX31music()) + + response_body, response_headers = await core_prepare_response(request, response) + return Response(content=response_body, headers=response_headers) + + +@router.post("/{gameinfo}/IIDX31music/nosave") +async def iidx31music_nosave(request: Request): + request_info = await core_process_request(request) + + response = E.response(E.IIDX31music()) + + response_body, response_headers = await core_prepare_response(request, response) + return Response(content=response_body, headers=response_headers) diff --git a/modules/iidx/iidx31pc.py b/modules/iidx/iidx31pc.py index 40a343b..09c1628 100644 --- a/modules/iidx/iidx31pc.py +++ b/modules/iidx/iidx31pc.py @@ -101,6 +101,7 @@ async def iidx31pc_get(request: Request): rivals[idx]["sg"] = rival_profile["grade_single"] rivals[idx]["da"] = rival_profile["dach"] rivals[idx]["dg"] = rival_profile["grade_double"] + rivals[idx]["back"] = rival_profile.get("back", 0) rivals[idx]["body"] = rival_profile["body"] rivals[idx]["face"] = rival_profile["face"] rivals[idx]["hair"] = rival_profile["hair"] @@ -225,7 +226,7 @@ async def iidx31pc_get(request: Request): E.tdjskin( [ profile.get("submonitor", 0), - 0, + profile.get("subbg", 0), 0, 0, ], @@ -246,11 +247,10 @@ async def iidx31pc_get(request: Request): skin_fullcombo_flg=-1, skin_keybeam_flg=-1, skin_judgestring_flg=-1, - # skin_bgm_flg=profile["skin_customize_flag_bgm"], - # skin_lane_flg3=profile["skin_customize_flag_lane"], ), E.tdjskin_customize_flg( skin_submonitor_flg=-1, + skin_subbg_flg=-1, ), E.spdp_rival( flg=-1 @@ -261,6 +261,7 @@ async def iidx31pc_get(request: Request): E.is_robo(0, __type="bool"), E.shop(name=config.arcade), E.qprodata( + back=rivals[r]["back"], body=rivals[r]["body"], face=rivals[r]["face"], hair=rivals[r]["hair"], @@ -336,6 +337,7 @@ async def iidx31pc_get(request: Request): "lightning_setting_resistance_dp_right", 0 ), keyboard_kind=profile.get("lightning_setting_keyboard_kind", 0), + brightness=profile.get("lightning_setting_brightness", 0), ), E.arena_data( E.achieve_data( @@ -405,9 +407,9 @@ async def iidx31pc_get(request: Request): rank4=3, rank5=1, ), - #E.player_kind_data( + # E.player_kind_data( # kind=(random.choice([random.randint(0, 13), 0])), - #), + # ), E.setting( E.hide_shopname(0, __type="bool"), stats_type=0, @@ -426,9 +428,9 @@ async def iidx31pc_get(request: Request): E.bind_eaappli(), E.ea_premium_course(), E.language_setting(language=profile["language_setting"]), - E.movie_agreement(agreement_version=profile["movie_agreement"]), + E.movie_agreement(agreement_version=profile.get("movie_agreement", 0)), E.movie_setting( - E.hide_name(0, __type="bool"), + E.hide_name(profile.get("hide_name", 0), __type="bool"), ), E.lightning_play_data( spnum=profile["lightning_play_data_spnum"], @@ -761,6 +763,7 @@ async def iidx31pc_get(request: Request): # slot=2, # ), # ), + qproback=profile.get("back", 0), ) ) @@ -771,6 +774,13 @@ async def iidx31pc_get(request: Request): @router.post("/{gameinfo}/IIDX31pc/common") async def iidx31pc_common(request: Request): request_info = await core_process_request(request) + game_version = request_info["game_version"] + + db = get_db() + all_score_stats = db.table("iidx_score_stats").search( + (where("music_id") < (game_version + 1) * 1000) + ) + hits = sorted(all_score_stats, key=lambda d: d["play_count"], reverse=True)[:10] response = E.response( E.IIDX31pc( @@ -799,7 +809,7 @@ async def iidx31pc_common(request: Request): E.movie_agreement(version=1), E.license("None", __type="str"), E.file_recovery(url=str(config.ip)), - E.movie_upload(url=str(config.ip)), + E.movie_upload(url=f"http://{str(config.ip)}:4399/movie/"), # E.button_release_frame(frame=''), # E.trigger_logic_type(type=''), # E.cm_movie_info(type=''), @@ -814,7 +824,21 @@ async def iidx31pc_common(request: Request): E.music_retry(), E.display_asio_logo(), # E.force_rom_check(), - # E.hitchart(), + *[ + E.hitchart( + *[ + E.ranking( + music_id=hit["music_id"], + rank=idx, + ) + for idx, hit in enumerate(hits, start=1) + ], + kind=k, # 0=national, 1=facility + period=p, # 0=all, 1=monthly, 2=weekly + ) + for k in range(2) + for p in range(3) + ], E.lane_gacha(), # E.fps_fix(), # E.save_unsync_log(), @@ -923,8 +947,12 @@ async def iidx31pc_save(request: Request): "resistance_sp_left", "resistance_sp_right", "keyboard_kind", + "brightness", ]: - game_profile["lightning_setting_" + k] = int(lightning_setting.attrib[k]) + if k in lightning_setting.attrib: + game_profile["lightning_setting_" + k] = int( + lightning_setting.attrib[k] + ) slider = lightning_setting.find("slider") if slider is not None: @@ -953,6 +981,16 @@ async def iidx31pc_save(request: Request): game_profile[f"music_memo_{fi}_{ps}_name"] = fn game_profile[f"music_memo_{fi}_{ps}_mids"] = mids + movie_agreement = request_info["root"][0].find("movie_agreement") + if movie_agreement is not None and "agreement_version" in movie_agreement.attrib: + game_profile["movie_agreement"] = int( + movie_agreement.attrib["agreement_version"] + ) + + hide_name = request_info["root"][0].find("movie_setting/hide_name") + if hide_name is not None: + game_profile["hide_name"] = int(hide_name.text) + # lightning_customize_flg = request_info["root"][0].find("lightning_customize_flg") # if lightning_customize_flg is not None: # for k in [ @@ -1038,6 +1076,7 @@ async def iidx31pc_save(request: Request): tdjskin_equips = [] if tdjskin_equips is None else tdjskin_equips tdjskin = { 0: "submonitor", + 1: "subbg", } for tdjskin_equip in tdjskin_equips: skin_id = int(tdjskin_equip.attrib["skin_id"]) @@ -1161,6 +1200,7 @@ async def iidx31pc_reg(request: Request): "face": 0, "hand": 0, "body": 0, + "back": 0, "frame": 0, "turntable": 0, "explosion": 0, @@ -1182,6 +1222,7 @@ async def iidx31pc_reg(request: Request): "note_size": 0, "keybeam_size": 0, "submonitor": 0, + "subbg": 0, "alternate_hcn": 0, "kokokara_start": 0, "d_auto_adjust": 0, @@ -1291,6 +1332,7 @@ async def iidx31pc_reg(request: Request): # Other "language_setting": 0, "movie_agreement": 0, + "hide_name": 0, "lightning_play_data_spnum": 0, "lightning_play_data_dpnum": 0, # Lightning model settings @@ -1302,6 +1344,7 @@ async def iidx31pc_reg(request: Request): "lightning_setting_resistance_sp_right": 0, "lightning_setting_resistance_dp_left": 0, "lightning_setting_resistance_dp_right": 0, + "lightning_setting_brightness": 0, "lightning_setting_skin_0": 0, "lightning_setting_flg_skin_0": 0, # Web UI/Other options @@ -1436,6 +1479,36 @@ async def iidx31pc_eaappliresult(request: Request): return Response(content=response_body, headers=response_headers) +@router.post("/{gameinfo}/IIDX31pc/playstart") +async def iidx31pc_playstart(request: Request): + request_info = await core_process_request(request) + + response = E.response(E.IIDX31pc()) + + response_body, response_headers = await core_prepare_response(request, response) + return Response(content=response_body, headers=response_headers) + + +@router.post("/{gameinfo}/IIDX31pc/playend") +async def iidx31pc_playend(request: Request): + request_info = await core_process_request(request) + + response = E.response(E.IIDX31pc()) + + response_body, response_headers = await core_prepare_response(request, response) + return Response(content=response_body, headers=response_headers) + + +@router.post("/{gameinfo}/IIDX31pc/delete") +async def iidx31pc_delete(request: Request): + request_info = await core_process_request(request) + + response = E.response(E.IIDX31pc()) + + response_body, response_headers = await core_prepare_response(request, response) + return Response(content=response_body, headers=response_headers) + + @router.post("/{gameinfo}/IIDX31pc/logout") async def iidx31pc_logout(request: Request): request_info = await core_process_request(request) diff --git a/modules/iidx/iidx31streaming.py b/modules/iidx/iidx31streaming.py new file mode 100644 index 0000000..1918caf --- /dev/null +++ b/modules/iidx/iidx31streaming.py @@ -0,0 +1,28 @@ +import config + +from fastapi import APIRouter, Request, Response + +from core_common import core_process_request, core_prepare_response, E + +router = APIRouter(prefix="/local2", tags=["local2"]) +router.model_whitelist = ["LDJ"] + + +@router.post("/{gameinfo}/IIDX31streaming/common") +async def iidx31streaming_common(request: Request): + request_info = await core_process_request(request) + + response = E.response(E.IIDX31streaming()) + + response_body, response_headers = await core_prepare_response(request, response) + return Response(content=response_body, headers=response_headers) + + +@router.post("/{gameinfo}/IIDX31streaming/getcm") +async def iidx31streaming_getcm(request: Request): + request_info = await core_process_request(request) + + response = E.response(E.IIDX31streaming()) + + response_body, response_headers = await core_prepare_response(request, response) + return Response(content=response_body, headers=response_headers)