Format with black.

This commit is contained in:
Jennifer Taylor 2025-10-04 01:28:18 +00:00
parent 411600fec8
commit 036f00d36a
4 changed files with 260 additions and 246 deletions

View File

@ -205,15 +205,15 @@ class DanceEvolution(
self.GRADE_A: self.GAME_GRADE_A,
self.GRADE_AA: self.GAME_GRADE_AA,
self.GRADE_AAA: self.GAME_GRADE_AAA,
}[score.data.get_int('grade')]
}[score.data.get_int("grade")]
scorenode = Node.void("score")
scorenode.add_child(Node.u16("id", score.id))
scorenode.add_child(Node.u8("chart", score.chart))
scorenode.add_child(Node.u32("points", score.points))
scorenode.add_child(Node.u8("grade", grade))
scorenode.add_child(Node.u8("combo", score.data.get_int('combo')))
scorenode.add_child(Node.bool("full_combo", score.data.get_bool('full_combo')))
scorenode.add_child(Node.u8("combo", score.data.get_int("combo")))
scorenode.add_child(Node.bool("full_combo", score.data.get_bool("full_combo")))
scores.add_child(scorenode)
scorecount += 1
@ -272,16 +272,22 @@ class DanceEvolution(
if ptype == "DATA01":
# Common profile stuff.
splits[self.DATA01_NAME_OFFSET] = profile.get_str("name").encode('shift-jis')
splits[self.DATA01_AREA_OFFSET] = profile.get_str("area").encode('shift-jis')
splits[self.DATA01_CLASS_OFFSET] = self._to_hex(profile.get_int("class", 1)).encode('shift-jis')
splits[self.DATA01_GOLD_OFFSET] = self._to_hex(profile.get_int("gold", 0)).encode('shift-jis')
splits[self.DATA01_NAME_OFFSET] = profile.get_str("name").encode("shift-jis")
splits[self.DATA01_AREA_OFFSET] = profile.get_str("area").encode("shift-jis")
splits[self.DATA01_CLASS_OFFSET] = self._to_hex(profile.get_int("class", 1)).encode(
"shift-jis"
)
splits[self.DATA01_GOLD_OFFSET] = self._to_hex(profile.get_int("gold", 0)).encode(
"shift-jis"
)
elif ptype == "DATA03":
# Dance mate stuff, and where scores come back.
splits[self.DATA03_DANCE_MATE_OFFSET] = self._to_hex(dancemates).encode('shift-jis')
splits[self.DATA03_DANCE_MATE_OFFSET] = self._to_hex(dancemates).encode("shift-jis")
elif ptype == "DATA04":
# Cumulative score.
splits[self.DATA04_TOTAL_SCORE_EARNED_OFFSET] = self._to_hex(profile.get_int("cumulative_score", 0)).encode('shift-jis')
splits[self.DATA04_TOTAL_SCORE_EARNED_OFFSET] = self._to_hex(
profile.get_int("cumulative_score", 0)
).encode("shift-jis")
dnode = Node.string(
"d",
@ -338,24 +344,29 @@ class DanceEvolution(
if profiletype == "DATA01":
# Extract relevant info so that it's in the profile normally.
profile.replace_str("name", strdatalist[self.DATA01_NAME_OFFSET].decode('shift-jis'))
profile.replace_int("class", int(strdatalist[self.DATA01_CLASS_OFFSET].decode('shift-jis'), 16))
profile.replace_int("gold", int(strdatalist[self.DATA01_GOLD_OFFSET].decode('shift-jis'), 16))
profile.replace_str("area", strdatalist[self.DATA01_AREA_OFFSET].decode('shift-jis'))
profile.replace_str("name", strdatalist[self.DATA01_NAME_OFFSET].decode("shift-jis"))
profile.replace_int("class", int(strdatalist[self.DATA01_CLASS_OFFSET].decode("shift-jis"), 16))
profile.replace_int("gold", int(strdatalist[self.DATA01_GOLD_OFFSET].decode("shift-jis"), 16))
profile.replace_str("area", strdatalist[self.DATA01_AREA_OFFSET].decode("shift-jis"))
elif profiletype == "DATA02":
# Extract possible dance mate and link it to the player.
potential_dancemate = strdatalist[self.DATA02_DANCE_MATE_NAME_OFFSET].decode('shift-jis')
potential_dancemate = strdatalist[self.DATA02_DANCE_MATE_NAME_OFFSET].decode("shift-jis")
potential_dancemate = potential_dancemate[:10]
if potential_dancemate.strip():
# First, try to find it in our cache.
other_userid = self.cache.get(potential_dancemate.replace(" ", "_"))
if other_userid:
self.data.local.user.put_link(self.game, self.version, userid, "dancemate", other_userid, {"last_played": Time.now()})
self.data.local.user.put_link(
self.game, self.version, userid, "dancemate", other_userid, {"last_played": Time.now()}
)
elif profiletype == "DATA04":
# Keep track of this for fun, because hey, why not?
profile.replace_int("cumulative_score", int(strdatalist[self.DATA04_TOTAL_SCORE_EARNED_OFFSET].decode('shift-jis'), 16))
profile.replace_int(
"cumulative_score",
int(strdatalist[self.DATA04_TOTAL_SCORE_EARNED_OFFSET].decode("shift-jis"), 16),
)
usergamedata[profiletype] = {
"strdata": b",".join(strdatalist),
@ -379,12 +390,15 @@ class DanceEvolution(
if "DATA03" in usergamedata:
strdatalist = usergamedata["DATA03"]["strdata"].split(b",")
first_song_played = int(strdatalist[self.DATA03_FIRST_SONG_OFFSET].decode('shift-jis'), 16)
second_song_played = int(strdatalist[self.DATA03_SECOND_SONG_OFFSET].decode('shift-jis'), 16)
first_song_scored = int(strdatalist[self.DATA03_FIRST_HIGH_SCORE_OFFSET].decode('shift-jis'), 16)
second_song_scored = int(strdatalist[self.DATA03_SECOND_HIGH_SCORE_OFFSET].decode('shift-jis'), 16)
first_song_played = int(strdatalist[self.DATA03_FIRST_SONG_OFFSET].decode("shift-jis"), 16)
second_song_played = int(strdatalist[self.DATA03_SECOND_SONG_OFFSET].decode("shift-jis"), 16)
first_song_scored = int(strdatalist[self.DATA03_FIRST_HIGH_SCORE_OFFSET].decode("shift-jis"), 16)
second_song_scored = int(strdatalist[self.DATA03_SECOND_HIGH_SCORE_OFFSET].decode("shift-jis"), 16)
for played, scored in [(first_song_played, first_song_scored), (second_song_played, second_song_scored)]:
for played, scored in [
(first_song_played, first_song_scored),
(second_song_played, second_song_scored),
]:
if played not in valid_ids:
# Game might be set to 1 song.
continue
@ -460,7 +474,7 @@ class DanceEvolution(
# They could have played some other songs and the game truncated this because it
# only ever sends back until the last nonzero value, so we need to fill in the blanks
# so to speak with all zero bytes.
chunk = usergamedata[key]["bindata"][offset:(offset + 8)]
chunk = usergamedata[key]["bindata"][offset : (offset + 8)]
if len(chunk) < 8:
chunk = chunk + (b"\x00" * (8 - len(chunk)))

View File

@ -44,9 +44,9 @@ class DanceEvolutionClient(BaseClient):
def verify_tax_get_phase(self) -> None:
call = self.call_node()
tax = Node.void('tax')
tax = Node.void("tax")
call.add_child(tax)
tax.set_attribute('method', 'get_phase')
tax.set_attribute("method", "get_phase")
# Swap with server
resp = self.exchange("", call)
@ -58,14 +58,14 @@ class DanceEvolutionClient(BaseClient):
for datakey in ["ARK_ARR0", "ARK_HAS0", "SONGOPEN", "INFO", "IRDATA", "EVTMSG3", "WEEKLYSO"]:
call = self.call_node()
system = Node.void('system')
system = Node.void("system")
call.add_child(system)
system.set_attribute('method', 'getmaster')
data = Node.void('data')
system.set_attribute("method", "getmaster")
data = Node.void("data")
system.add_child(data)
data.add_child(Node.string('gamekind', 'KDM'))
data.add_child(Node.string('datatype', 'S_SRVMSG'))
data.add_child(Node.string('datakey', datakey))
data.add_child(Node.string("gamekind", "KDM"))
data.add_child(Node.string("datatype", "S_SRVMSG"))
data.add_child(Node.string("datakey", datakey))
# Swap with server
resp = self.exchange("", call)
@ -101,218 +101,218 @@ class DanceEvolutionClient(BaseClient):
def _get_base_profile_data(self, include_secondary: bool) -> Dict[str, List[bytes]]:
profiledata = {
"DATA01": [
b'1',
b'0',
b'1', # Class offset.
b'0', # Earned gold offset.
b'0',
b'1',
b'0',
b'0',
b'0',
b'0',
b'0',
b'0',
b'0',
b'0',
b'0',
b'0',
b'0',
b'0.000000',
b'0.000000',
b'0.000000',
b'0.000000',
b'0.000000',
b'0.000000',
b'0.000000',
b'0.000000',
b'', # Name spot, will be filled in later.
b'\x96\xa2\x90\xdd\x92\xe8', # Area spot, hardcoded to "unset".
b'', # Arcade name spot, we don't send this in tests.
b'',
b'',
b'',
b'',
b'',
b"1",
b"0",
b"1", # Class offset.
b"0", # Earned gold offset.
b"0",
b"1",
b"0",
b"0",
b"0",
b"0",
b"0",
b"0",
b"0",
b"0",
b"0",
b"0",
b"0",
b"0.000000",
b"0.000000",
b"0.000000",
b"0.000000",
b"0.000000",
b"0.000000",
b"0.000000",
b"0.000000",
b"", # Name spot, will be filled in later.
b"\x96\xa2\x90\xdd\x92\xe8", # Area spot, hardcoded to "unset".
b"", # Arcade name spot, we don't send this in tests.
b"",
b"",
b"",
b"",
b"",
],
"DATA02": [
b'1',
b'0',
b'0',
b'0',
b'0',
b'0',
b'0',
b'0',
b'0',
b'0',
b'0',
b'0',
b'0',
b'0',
b'0',
b'0',
b'0',
b'0.000000',
b'0.000000',
b'0.000000',
b'0.000000',
b'0.000000',
b'0.000000',
b'0.000000',
b'0.000000',
b'', # Dance Mate name spot, will be filled in later.
b'',
b'',
b'',
b'',
b'',
b'',
b'',
b"1",
b"0",
b"0",
b"0",
b"0",
b"0",
b"0",
b"0",
b"0",
b"0",
b"0",
b"0",
b"0",
b"0",
b"0",
b"0",
b"0",
b"0.000000",
b"0.000000",
b"0.000000",
b"0.000000",
b"0.000000",
b"0.000000",
b"0.000000",
b"0.000000",
b"", # Dance Mate name spot, will be filled in later.
b"",
b"",
b"",
b"",
b"",
b"",
b"",
],
"DATA03": [
b'1',
b'0',
b'0',
b'0',
b'0',
b'0',
b'0',
b'0',
b'0', # Number of dancemates, ignored on send.
b'0',
b'0',
b'0',
b'0',
b'ffffffffffffffff', # First song ID.
b'ffffffffffffffff', # First score ID.
b'ffffffffffffffff', # Second song ID.
b'ffffffffffffffff', # Second score ID.
b'-1.000000',
b'-1.000000',
b'0.000000',
b'0.000000',
b'0.000000',
b'0.000000',
b'0.000000',
b'0.000000',
b'',
b'',
b'',
b'',
b'',
b'',
b'',
b'',
b"1",
b"0",
b"0",
b"0",
b"0",
b"0",
b"0",
b"0",
b"0", # Number of dancemates, ignored on send.
b"0",
b"0",
b"0",
b"0",
b"ffffffffffffffff", # First song ID.
b"ffffffffffffffff", # First score ID.
b"ffffffffffffffff", # Second song ID.
b"ffffffffffffffff", # Second score ID.
b"-1.000000",
b"-1.000000",
b"0.000000",
b"0.000000",
b"0.000000",
b"0.000000",
b"0.000000",
b"0.000000",
b"",
b"",
b"",
b"",
b"",
b"",
b"",
b"",
],
"DATA04": [
b'1',
b'0',
b'0',
b'0',
b'0',
b'0',
b'0',
b'0',
b'0',
b'0', # Total points earned cumulative.
b'0',
b'0',
b'0',
b'0',
b'0',
b'0',
b'0',
b'0.000000',
b'0.000000',
b'0.000000',
b'0.000000',
b'0.000000',
b'0.000000',
b'0.000000',
b'0.000000',
b'',
b'',
b'',
b'',
b'',
b'',
b'',
b'',
b"1",
b"0",
b"0",
b"0",
b"0",
b"0",
b"0",
b"0",
b"0",
b"0", # Total points earned cumulative.
b"0",
b"0",
b"0",
b"0",
b"0",
b"0",
b"0",
b"0.000000",
b"0.000000",
b"0.000000",
b"0.000000",
b"0.000000",
b"0.000000",
b"0.000000",
b"0.000000",
b"",
b"",
b"",
b"",
b"",
b"",
b"",
b"",
],
"RDAT01": [
b'1',
b'0',
b'0',
b'0',
b'0',
b'0',
b'0',
b'0',
b'0',
b'0',
b'0',
b'0',
b'0',
b'0',
b'0',
b'0',
b'0',
b'0.000000',
b'0.000000',
b'0.000000',
b'0.000000',
b'0.000000',
b'0.000000',
b'0.000000',
b'0.000000',
b'',
b'',
b'',
b'',
b'',
b'',
b'',
b'',
b"1",
b"0",
b"0",
b"0",
b"0",
b"0",
b"0",
b"0",
b"0",
b"0",
b"0",
b"0",
b"0",
b"0",
b"0",
b"0",
b"0",
b"0.000000",
b"0.000000",
b"0.000000",
b"0.000000",
b"0.000000",
b"0.000000",
b"0.000000",
b"0.000000",
b"",
b"",
b"",
b"",
b"",
b"",
b"",
b"",
],
}
if include_secondary:
for secondary in ["DATA05", "DATA11", "DATA12", "DATA13", "DATA14", "DATA15"]:
profiledata[secondary] = [
b'1',
b'0',
b'0',
b'0',
b'0',
b'0',
b'0',
b'0',
b'0',
b'0',
b'0',
b'0',
b'0',
b'0',
b'0',
b'0',
b'0',
b'0.000000',
b'0.000000',
b'0.000000',
b'0.000000',
b'0.000000',
b'0.000000',
b'0.000000',
b'0.000000',
b'',
b'',
b'',
b'',
b'',
b'',
b'',
b'',
b"1",
b"0",
b"0",
b"0",
b"0",
b"0",
b"0",
b"0",
b"0",
b"0",
b"0",
b"0",
b"0",
b"0",
b"0",
b"0",
b"0",
b"0.000000",
b"0.000000",
b"0.000000",
b"0.000000",
b"0.000000",
b"0.000000",
b"0.000000",
b"0.000000",
b"",
b"",
b"",
b"",
b"",
b"",
b"",
b"",
]
return profiledata
@ -342,7 +342,7 @@ class DanceEvolutionClient(BaseClient):
if othername:
while len(othername) < 10:
othername = othername + " "
profiledata["DATA02"][25] = othername.encode('shift-jis')
profiledata["DATA02"][25] = othername.encode("shift-jis")
else:
profiledata["DATA02"][25] = b""
@ -461,7 +461,7 @@ class DanceEvolutionClient(BaseClient):
highest_id: int = 0
def _to_hex(number: int) -> bytes:
return hex(number)[2:].encode('shift-jis')
return hex(number)[2:].encode("shift-jis")
for offset, score in enumerate(scores):
sid = score["id"]
@ -540,7 +540,7 @@ class DanceEvolutionClient(BaseClient):
for ptype in profiledata:
profile = [b"ffffffff", ptype.encode("shift-jis")] + profiledata[ptype]
d = Node.string("d", base64.b64encode(b",".join(profile)).decode("ascii"))
d.add_child(Node.string("bin1", base64.b64encode(profilebindata[ptype]).decode('ascii')))
d.add_child(Node.string("bin1", base64.b64encode(profilebindata[ptype]).decode("ascii")))
record.add_child(d)
# Swap with server
@ -579,12 +579,12 @@ class DanceEvolutionClient(BaseClient):
continue
score: Dict[str, int] = {}
score['id'] = child.child_value("id")
score['chart'] = child.child_value("chart")
score['points'] = child.child_value("points")
score['grade'] = child.child_value("grade")
score['combo'] = child.child_value("combo")
score['full_combo'] = 1 if child.child_value("full_combo") else 0
score["id"] = child.child_value("id")
score["chart"] = child.child_value("chart")
score["points"] = child.child_value("points")
score["grade"] = child.child_value("grade")
score["combo"] = child.child_value("combo")
score["full_combo"] = 1 if child.child_value("full_combo") else 0
scores.append(score)
@ -779,7 +779,7 @@ class DanceEvolutionClient(BaseClient):
},
]
scorechunks = [dummyscores[x:(x + 2)] for x in range(0, len(dummyscores), 2)]
scorechunks = [dummyscores[x : (x + 2)] for x in range(0, len(dummyscores), 2)]
for chunk in scorechunks:
self.verify_scores_send(ref_id, self.NAME1, chunk)

View File

@ -220,7 +220,7 @@ class APIClient:
},
GameConstants.DANCE_EVOLUTION: {
VersionConstants.DANCE_EVOLUTION: "1",
}
},
}
.get(game, {})
.get(version)

View File

@ -261,13 +261,13 @@ def updatename() -> Dict[str, Any]:
if (
re.match(
"^["
+ "\uFF20-\uFF3A" # widetext A-Z and @
+ "\uFF40-\uFF5A" # widetext a-z and `
+ "\uFF10-\uFF19" # widetext 0-9
+ "\uFF0C\uFF0E\uFF3F\u0437\u2200\u2207" # ,._ and face symbols
+ "\u3041-\u308D\u308F\u3092\u3093" # hiragana
+ "\u30A1-\u30ED\u30EF\u30F2\u30F3\u30FC" # katakana
+ "\u2605\u266A\uff01\uff1f\uff0b" # allowed symbols
+ "\uff20-\uff3a" # widetext A-Z and @
+ "\uff40-\uff5a" # widetext a-z and `
+ "\uff10-\uff19" # widetext 0-9
+ "\uff0c\uff0e\uff3f\u0437\u2200\u2207" # ,._ and face symbols
+ "\u3041-\u308d\u308f\u3092\u3093" # hiragana
+ "\u30a1-\u30ed\u30ef\u30f2\u30f3\u30fc" # katakana
+ "\u2605\u266a\uff01\uff1f\uff0b" # allowed symbols
+ "\u2212\u00d7\u00f7\uff03\u3002" # allowed symbols
+ "\u2267\u2266\u0434\u0398\u25a1" # allowed symbols
+ "\u76bf\uff1b\uff1a\u301c\uff0a" # allowed symbols