From 47de5f98214dd8691904bd1ffb712a23a83d2e85 Mon Sep 17 00:00:00 2001 From: Darren Thompson Date: Thu, 7 Aug 2025 08:16:17 -0400 Subject: [PATCH] File formatter run --- bemani/backend/ddr/ddrsn2.py | 13 ++-- bemani/client/ddr/ddrsn2.py | 144 ++++++++++++++++++++--------------- bemani/utils/read.py | 68 ++++++++--------- traffic/serivice-get.xml | 3 + 4 files changed, 123 insertions(+), 105 deletions(-) create mode 100644 traffic/serivice-get.xml diff --git a/bemani/backend/ddr/ddrsn2.py b/bemani/backend/ddr/ddrsn2.py index d73a82c..c01891c 100644 --- a/bemani/backend/ddr/ddrsn2.py +++ b/bemani/backend/ddr/ddrsn2.py @@ -184,8 +184,8 @@ class PlayerInfoStruct(Structure): ("team", c_uint8), # 0x1d ("unused2", c_uint8), # 0x1e - 0x1f ("show_calories", c_uint8), - ("calories", c_uint32), # 0x20 - ("unused7", c_uint8 * 2), # 0x24 - 0x25 + ("calories", c_uint32), # 0x20 + ("unused7", c_uint8 * 2), # 0x24 - 0x25 ("takeover", c_uint8), # 0x26 ("count_b", c_uint8), # 0x27 ("unused3", c_char * 2), # 0x28 - 0x29 @@ -197,14 +197,16 @@ class PlayerInfoStruct(Structure): ("unlock_prompt_bits", c_uint8 * 12), # 0x64 - 0x6f ("unused5", c_char * 20), # 0x70 - 0x83 ("course", c_uint32 * 3), # 0x84 - 0x8f - ("unused6", c_char * (0x1344 - 0x90)), # 0x90 - 0x1343 + ("unused6", c_char * (0x1344 - 0x90)), # 0x90 - 0x1343 ("battle_records", BattleRecordStruct * 5), # 0x1344 ] class PlayerInfo: @staticmethod - def create(play_stats: PlayStatistics, profile: Profile, total_calories: int, machine_region: int) -> PlayerInfoStruct: + def create( + play_stats: PlayStatistics, profile: Profile, total_calories: int, machine_region: int + ) -> PlayerInfoStruct: player = PlayerInfoStruct() player.count = play_stats.get_int("single_plays") @@ -229,7 +231,6 @@ class PlayerInfo: player.takeover = profile.get_int("takeover") player.count_b = play_stats.get_int("battle_plays") - idx = 0 for entry in profile.get_int_array("gr_s", 5): player.groove_radar[idx] = entry @@ -765,4 +766,4 @@ class DDRSuperNova2( def handle_info_score_request(self, request: Node) -> Node: root = Node.void("score") - return root \ No newline at end of file + return root diff --git a/bemani/client/ddr/ddrsn2.py b/bemani/client/ddr/ddrsn2.py index e5e4e65..6827880 100644 --- a/bemani/client/ddr/ddrsn2.py +++ b/bemani/client/ddr/ddrsn2.py @@ -6,8 +6,11 @@ from bemani.backend.ddr.ddrsn2 import PlayerInfoStruct, ScoreInfoStruct from bemani.client import BaseClient from bemani.protocol import Node + class DDRSN2MusicRecord: - def __init__(self, combo_length: int, full_combo: bool, song_id: int, mode: int, perfect_combo: bool, rank: int, score: int) -> None: + def __init__( + self, combo_length: int, full_combo: bool, song_id: int, mode: int, perfect_combo: bool, rank: int, score: int + ) -> None: self.combo_length = combo_length self.full_combo = full_combo self.song_id = song_id @@ -28,8 +31,23 @@ class DDRSN2MusicRecord: return music + class DDRSN2GameRecord: - def __init__(self, calories: int, exp: int, gr1: int, gr2: int, gr3: int, gr4: int, gr5: int, mode: int, music: int, sort: int, type: int, weight: int): + def __init__( + self, + calories: int, + exp: int, + gr1: int, + gr2: int, + gr3: int, + gr4: int, + gr5: int, + mode: int, + music: int, + sort: int, + type: int, + weight: int, + ): self.calories = calories self.exp = exp self.gr1 = gr1 @@ -66,39 +84,38 @@ class DDRSN2GameRecord: return game - class DDRSN2Client(BaseClient): NAME = "TEST" def verify_info_tenpo(self): call = self.call_node() - info = Node.void('info') + info = Node.void("info") call.add_child(info) - info.set_attribute('area', '0') - info.set_attribute('coin', '02.01.--.--.01.') - info.set_attribute('diff', '3') - info.set_attribute('during', '1') - info.set_attribute('first', '1') - info.set_attribute('ip', '192.0.2.100') - info.set_attribute('lancher', '2.4.1:20070608-0') - info.set_attribute('loc', 'US-1') - info.set_attribute('mac', '00:00:00:00:00:00') - info.set_attribute('method', 'tenpo') - info.set_attribute('name', '.') - info.set_attribute('netid', '014014000001030405D8') - info.set_attribute('pcbid', self.pcbid) - info.set_attribute('region', '') - info.set_attribute('shop', '00Mi') - info.set_attribute('soft', self.config["model"]) - info.set_attribute('stage', '3') - info.set_attribute('ver', '1') + info.set_attribute("area", "0") + info.set_attribute("coin", "02.01.--.--.01.") + info.set_attribute("diff", "3") + info.set_attribute("during", "1") + info.set_attribute("first", "1") + info.set_attribute("ip", "192.0.2.100") + info.set_attribute("lancher", "2.4.1:20070608-0") + info.set_attribute("loc", "US-1") + info.set_attribute("mac", "00:00:00:00:00:00") + info.set_attribute("method", "tenpo") + info.set_attribute("name", ".") + info.set_attribute("netid", "014014000001030405D8") + info.set_attribute("pcbid", self.pcbid) + info.set_attribute("region", "") + info.set_attribute("shop", "00Mi") + info.set_attribute("soft", self.config["model"]) + info.set_attribute("stage", "3") + info.set_attribute("ver", "1") resp = self.exchange("core/info", call) self.assert_path(resp, "response/tenpo/@status") def verify_info_message(self): call = self.call_node() - info = Node.void('info') + info = Node.void("info") call.add_child(info) info.set_attribute("method", "message") info.set_attribute("ver", "1") @@ -109,7 +126,7 @@ class DDRSN2Client(BaseClient): def verify_info_ranking(self): call = self.call_node() - info = Node.void('info') + info = Node.void("info") call.add_child(info) info.set_attribute("method", "ranking") info.set_attribute("ver", "1") @@ -119,7 +136,7 @@ class DDRSN2Client(BaseClient): def verify_player_common(self): call = self.call_node() - player = Node.void('player') + player = Node.void("player") call.add_child(player) player.set_attribute("event", "1") player.set_attribute("method", "common") @@ -132,14 +149,14 @@ class DDRSN2Client(BaseClient): def verify_player_new(self, ref_id: str) -> None: call = self.call_node() - player = Node.void('player') + player = Node.void("player") call.add_child(player) - player.set_attribute('area', '11') - player.set_attribute('method', 'new') - player.set_attribute('name', f'{self.NAME} ') - player.set_attribute('pcbid', self.pcbid) - player.set_attribute('ref_id', ref_id) - player.set_attribute('ver', '1') + player.set_attribute("area", "11") + player.set_attribute("method", "new") + player.set_attribute("name", f"{self.NAME} ") + player.set_attribute("pcbid", self.pcbid) + player.set_attribute("ref_id", ref_id) + player.set_attribute("ver", "1") resp = self.exchange("core/player", call) self.assert_path(resp, "response/player/@status") @@ -147,25 +164,25 @@ class DDRSN2Client(BaseClient): def verify_player_get(self, ref_id: str) -> (PlayerInfoStruct, ScoreInfoStruct, ScoreInfoStruct): call = self.call_node() - player = Node.void('player') + player = Node.void("player") call.add_child(player) - player.set_attribute('method', 'get') - player.set_attribute('part', '0') - player.set_attribute('ref_id', ref_id) - player.set_attribute('ver', '1') + player.set_attribute("method", "get") + player.set_attribute("part", "0") + player.set_attribute("ref_id", ref_id) + player.set_attribute("ver", "1") resp = self.exchange("core/player", call) self.assert_path(resp, "response/player/@md5c") self.assert_path(resp, "response/player/b") chunk0 = base64.b64decode(resp.child_value("player/b")) - player.set_attribute('part', '1') + player.set_attribute("part", "1") resp = self.exchange("core/player", call) self.assert_path(resp, "response/player/@md5c") self.assert_path(resp, "response/player/b") chunk1 = base64.b64decode(resp.child_value("player/b")) - player.set_attribute('part', '2') + player.set_attribute("part", "2") resp = self.exchange("core/player", call) self.assert_path(resp, "response/player/@md5c") self.assert_path(resp, "response/player/b") @@ -179,24 +196,26 @@ class DDRSN2Client(BaseClient): def verify_player_touch(self): call = self.call_node() - player = Node.void('player') + player = Node.void("player") call.add_child(player) - player.set_attribute('err', '0') - player.set_attribute('method', 'touch') - player.set_attribute('mode', '2') - player.set_attribute('pcbid', self.pcbid) - player.set_attribute('style', '0') - player.set_attribute('type', '1') - player.set_attribute('ver', '1') + player.set_attribute("err", "0") + player.set_attribute("method", "touch") + player.set_attribute("mode", "2") + player.set_attribute("pcbid", self.pcbid) + player.set_attribute("style", "0") + player.set_attribute("type", "1") + player.set_attribute("ver", "1") resp = self.exchange("core/player", call) self.assert_path(resp, "response/player/@status") - def verify_player_set(self, ref_id: str, music_records: List[DDRSN2MusicRecord], game_record: DDRSN2GameRecord) -> None: + def verify_player_set( + self, ref_id: str, music_records: List[DDRSN2MusicRecord], game_record: DDRSN2GameRecord + ) -> None: call = self.call_node() - player = Node.void('player') + player = Node.void("player") call.add_child(player) - player.set_attribute('method', 'set') + player.set_attribute("method", "set") player.set_attribute("pcbid", self.pcbid) player.set_attribute("ref_id", ref_id) player.set_attribute("ver", "1") @@ -206,7 +225,7 @@ class DDRSN2Client(BaseClient): player.add_child(game_record.to_node()) - opt = Node.void('opt') + opt = Node.void("opt") player.add_child(opt) opt.set_attribute("opt1", "3") opt.set_attribute("opt2", "0") @@ -225,7 +244,7 @@ class DDRSN2Client(BaseClient): opt.set_attribute("opt15", "0") opt.set_attribute("opt16", "0") - flag = Node.void('flag') + flag = Node.void("flag") player.add_child(flag) flag.set_attribute("off", "48") @@ -252,7 +271,7 @@ class DDRSN2Client(BaseClient): "posevent", "local2", "ntp", - "keepalive" + "keepalive", ] ) @@ -331,11 +350,12 @@ class DDRSN2Client(BaseClient): if s.challenge.score != 0 or s.challenge.lo_score != 0: raise Exception("Player info has scores already!") - # Write scores and verify saving - music_records = [DDRSN2MusicRecord(78, False, 316, 2, False, 3, 751030), - DDRSN2MusicRecord(34, False, 305, 2, False, 4, 625140), - DDRSN2MusicRecord(64, False, 2, 2, False, 4, 716040)] + music_records = [ + DDRSN2MusicRecord(78, False, 316, 2, False, 3, 751030), + DDRSN2MusicRecord(34, False, 305, 2, False, 4, 625140), + DDRSN2MusicRecord(64, False, 2, 2, False, 4, 716040), + ] game_record = DDRSN2GameRecord(32837, 56, 2583, 1012, 680, 239, 181, 2, 2, 1, 2, 333) @@ -362,7 +382,11 @@ class DDRSN2Client(BaseClient): raise Exception("Player info has unexpected groove radar!") # Verify score set - if scores2.records[116].difficult.score == 0 or scores2.records[105].difficult.score == 0 or scores1.records[2].difficult.score == 0: + if ( + scores2.records[116].difficult.score == 0 + or scores2.records[105].difficult.score == 0 + or scores1.records[2].difficult.score == 0 + ): raise Exception("Player info has unexpected scores!") # Verify other scores unset @@ -409,7 +433,3 @@ class DDRSN2Client(BaseClient): else: self.verify_eacoin_consume(sessid, balance, random.randint(0, balance)) self.verify_eacoin_checkout(sessid) - - - - diff --git a/bemani/utils/read.py b/bemani/utils/read.py index 44dda3d..d8c4363 100644 --- a/bemani/utils/read.py +++ b/bemani/utils/read.py @@ -4739,37 +4739,37 @@ class ImportDDR(ImportBase): DDRScrapeConfiguration( version="GDJ:J:A:A:2007100800", offset=0x1E7EA0, - size=0x9c, + size=0x9C, length=359, unpackfmt=( - "> 4, "expert": unpacked[config.double_difficulties + 1] & 0xF, "challenge": (unpacked[config.double_difficulties + 1] & 0xF0) >> 4, - } + }, }, "groove_gauge": { "single": { @@ -5180,16 +5180,11 @@ class ImportDDR(ImportBase): if self.version == VersionConstants.DDR_SUPERNOVA_2: offset = 0x194654 size = 0x14 - length = 0x3d3 + length = 0x3D3 relocation_offset = 0x380000 pack_format = ( - "<" - + "I" # id 0 - + "I" # ssq code 1 - + "I" # title 2 - + "I" # short title 3 - + "xxxx" # alt title? + "<" + "I" + "I" + "I" + "I" + "xxxx" # id 0 # ssq code 1 # title 2 # short title 3 # alt title? ) else: raise CLIException(f"Unsupported version {self.version} for title scrape!") @@ -5226,7 +5221,7 @@ class ImportDDR(ImportBase): for idx, song in enumerate(songs): ssq_code = song["ssqcode"] - if ssq_code == "sunk": # Korean version of SUNKiSS DROP? Has file reference but no title + if ssq_code == "sunk": # Korean version of SUNKiSS DROP? Has file reference but no title ssq_code = "sunj" song["title"] = ssqc_map.get(ssq_code) @@ -5240,7 +5235,6 @@ class ImportDDR(ImportBase): return songs - def lookup(self, server: str, token: str) -> List[Dict[str, Any]]: # Grab music info from remote server music = self.remote_music(server, token) diff --git a/traffic/serivice-get.xml b/traffic/serivice-get.xml new file mode 100644 index 0000000..db2a10f --- /dev/null +++ b/traffic/serivice-get.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file