1
0
mirror of synced 2024-11-27 15:40:48 +01:00

Move logic for handling mdata_ver into central place for Jubeat, fix saucer and fulfill over-sending rival data.

This commit is contained in:
Jennifer Taylor 2023-08-19 19:04:12 +00:00
parent dca2194a57
commit d162d57024
7 changed files with 31 additions and 95 deletions

View File

@ -159,23 +159,31 @@ class JubeatBase(CoreHandler, CardManagerHandler, PASELIHandler, Base):
return self.format_profile(userid, profile) return self.format_profile(userid, profile)
def get_scores_by_extid(self, extid: Optional[int]) -> Optional[Node]: def get_scores_by_extid(
self, extid: Optional[int], partition: int, total_partitions: int
) -> Optional[Node]:
""" """
Given an ExtID, return a formatted score node. Similar rationale to Given an ExtID, return a formatted score node. Similar rationale to
get_profile_by_refid. get_profile_by_refid. Note that this takes into account the game's
desire to partition scores into separate fetches to ensure that we
don't make any one request too long. We handle the logic for that here.
""" """
if extid is None: if extid is None:
return None return None
userid = self.data.remote.user.from_extid(self.game, self.version, extid) userid = self.data.remote.user.from_extid(self.game, self.version, extid)
scores = self.data.remote.music.get_scores(
self.game, self.music_version, userid
)
if scores is None:
return None
profile = self.get_profile(userid) profile = self.get_profile(userid)
if profile is None: if profile is None:
return None return None
if partition != 1:
scores = []
else:
scores = self.data.remote.music.get_scores(
self.game, self.music_version, userid
)
if scores is None:
return None
return self.format_scores(userid, profile, scores) return self.format_scores(userid, profile, scores)
def update_score( def update_score(

View File

@ -1377,20 +1377,8 @@ class JubeatClan(
data = request.child("data") data = request.child("data")
player = data.child("player") player = data.child("player")
extid = player.child_value("jid") extid = player.child_value("jid")
mdata_ver = player.child_value( mdata_ver = player.child_value("mdata_ver")
"mdata_ver" root = self.get_scores_by_extid(extid, mdata_ver, 3)
) # Game requests mdata 3 times per profile for some reason
if mdata_ver != 1:
root = Node.void("gametop")
datanode = Node.void("data")
root.add_child(datanode)
player = Node.void("player")
datanode.add_child(player)
player.add_child(Node.s32("jid", extid))
playdata = Node.void("mdata_list")
player.add_child(playdata)
return root
root = self.get_scores_by_extid(extid)
if root is None: if root is None:
root = Node.void("gametop") root = Node.void("gametop")
root.set_attribute("status", str(Status.NO_PROFILE)) root.set_attribute("status", str(Status.NO_PROFILE))

View File

@ -2178,20 +2178,8 @@ class JubeatFesto(
data = request.child("data") data = request.child("data")
player = data.child("player") player = data.child("player")
extid = player.child_value("jid") extid = player.child_value("jid")
mdata_ver = player.child_value( mdata_ver = player.child_value("mdata_ver")
"mdata_ver" root = self.get_scores_by_extid(extid, mdata_ver, 3)
) # Game requests mdata 3 times per profile for some reason
if mdata_ver != 1:
root = Node.void("gametop")
datanode = Node.void("data")
root.add_child(datanode)
player = Node.void("player")
datanode.add_child(player)
player.add_child(Node.s32("jid", extid))
playdata = Node.void("mdata_list")
player.add_child(playdata)
return root
root = self.get_scores_by_extid(extid)
if root is None: if root is None:
root = Node.void("gametop") root = Node.void("gametop")
root.set_attribute("status", str(Status.NO_PROFILE)) root.set_attribute("status", str(Status.NO_PROFILE))

View File

@ -632,20 +632,8 @@ class JubeatProp(
data = request.child("data") data = request.child("data")
player = data.child("player") player = data.child("player")
extid = player.child_value("jid") extid = player.child_value("jid")
mdata_ver = player.child_value( mdata_ver = player.child_value("mdata_ver")
"mdata_ver" root = self.get_scores_by_extid(extid, mdata_ver, 3)
) # Game requests mdata 3 times per profile for some reason
if mdata_ver != 1:
root = Node.void("gametop")
datanode = Node.void("data")
root.add_child(datanode)
player = Node.void("player")
datanode.add_child(player)
player.add_child(Node.s32("jid", extid))
playdata = Node.void("mdata_list")
player.add_child(playdata)
return root
root = self.get_scores_by_extid(extid)
if root is None: if root is None:
root = Node.void("gametop") root = Node.void("gametop")
root.set_attribute("status", str(Status.NO_PROFILE)) root.set_attribute("status", str(Status.NO_PROFILE))

View File

@ -639,20 +639,8 @@ class JubeatQubell(
data = request.child("data") data = request.child("data")
player = data.child("player") player = data.child("player")
extid = player.child_value("jid") extid = player.child_value("jid")
mdata_ver = player.child_value( mdata_ver = player.child_value("mdata_ver")
"mdata_ver" root = self.get_scores_by_extid(extid, mdata_ver, 3)
) # Game requests mdata 3 times per profile for some reason
if mdata_ver != 1:
root = Node.void("gametop")
datanode = Node.void("data")
root.add_child(datanode)
player = Node.void("player")
datanode.add_child(player)
player.add_child(Node.s32("jid", extid))
playdata = Node.void("mdata_list")
player.add_child(playdata)
return root
root = self.get_scores_by_extid(extid)
if root is None: if root is None:
root = Node.void("gametop") root = Node.void("gametop")
root.set_attribute("status", str(Status.NO_PROFILE)) root.set_attribute("status", str(Status.NO_PROFILE))

View File

@ -185,21 +185,8 @@ class JubeatSaucer(
data = request.child("data") data = request.child("data")
player = data.child("player") player = data.child("player")
extid = player.child_value("jid") extid = player.child_value("jid")
mdata_ver = player.child_value( mdata_ver = player.child_value("mdata_ver")
"mdata_ver" root = self.get_scores_by_extid(extid, mdata_ver, 3)
) # Game requests mdata 3 times per profile for some reason
if mdata_ver != 1:
root = Node.void("gametop")
datanode = Node.void("data")
root.add_child(datanode)
player = Node.void("player")
datanode.add_child(player)
player.add_child(Node.s32("jid", extid))
playdata = Node.void("playdata")
player.add_child(playdata)
playdata.set_attribute("count", "0")
return root
root = self.get_scores_by_extid(extid)
if root is None: if root is None:
root = Node.void("gametop") root = Node.void("gametop")
root.set_attribute("status", str(Status.NO_PROFILE)) root.set_attribute("status", str(Status.NO_PROFILE))
@ -209,7 +196,8 @@ class JubeatSaucer(
data = request.child("data") data = request.child("data")
player = data.child("player") player = data.child("player")
extid = player.child_value("rival") extid = player.child_value("rival")
root = self.get_scores_by_extid(extid) mdata_ver = player.child_value("mdata_ver")
root = self.get_scores_by_extid(extid, mdata_ver, 3)
if root is None: if root is None:
root = Node.void("gametop") root = Node.void("gametop")
root.set_attribute("status", str(Status.NO_PROFILE)) root.set_attribute("status", str(Status.NO_PROFILE))

View File

@ -320,21 +320,8 @@ class JubeatSaucerFulfill(
data = request.child("data") data = request.child("data")
player = data.child("player") player = data.child("player")
extid = player.child_value("jid") extid = player.child_value("jid")
mdata_ver = player.child_value( mdata_ver = player.child_value("mdata_ver")
"mdata_ver" root = self.get_scores_by_extid(extid, mdata_ver, 3)
) # Game requests mdata 3 times per profile for some reason
if mdata_ver != 1:
root = Node.void("gametop")
datanode = Node.void("data")
root.add_child(datanode)
player = Node.void("player")
datanode.add_child(player)
player.add_child(Node.s32("jid", extid))
playdata = Node.void("playdata")
player.add_child(playdata)
playdata.set_attribute("count", "0")
return root
root = self.get_scores_by_extid(extid)
if root is None: if root is None:
root = Node.void("gametop") root = Node.void("gametop")
root.set_attribute("status", str(Status.NO_PROFILE)) root.set_attribute("status", str(Status.NO_PROFILE))
@ -344,7 +331,8 @@ class JubeatSaucerFulfill(
data = request.child("data") data = request.child("data")
player = data.child("player") player = data.child("player")
extid = player.child_value("rival") extid = player.child_value("rival")
root = self.get_scores_by_extid(extid) mdata_ver = player.child_value("mdata_ver")
root = self.get_scores_by_extid(extid, mdata_ver, 3)
if root is None: if root is None:
root = Node.void("gametop") root = Node.void("gametop")
root.set_attribute("status", str(Status.NO_PROFILE)) root.set_attribute("status", str(Status.NO_PROFILE))