2019-12-08 22:43:49 +01:00
|
|
|
import time
|
|
|
|
|
|
|
|
from bemani.backend.jubeat.base import JubeatBase
|
|
|
|
from bemani.protocol import Node
|
|
|
|
|
|
|
|
|
|
|
|
class JubeatLoggerReportHandler(JubeatBase):
|
|
|
|
def handle_logger_report_request(self, request: Node) -> Node:
|
|
|
|
# Handle this by returning nothing, game doesn't care
|
2022-10-15 20:56:30 +02:00
|
|
|
root = Node.void("logger")
|
2019-12-08 22:43:49 +01:00
|
|
|
return root
|
|
|
|
|
|
|
|
|
|
|
|
class JubeatDemodataGetNewsHandler(JubeatBase):
|
|
|
|
def handle_demodata_get_news_request(self, request: Node) -> Node:
|
2022-10-15 20:56:30 +02:00
|
|
|
demodata = Node.void("demodata")
|
|
|
|
data = Node.void("data")
|
2019-12-08 22:43:49 +01:00
|
|
|
demodata.add_child(data)
|
|
|
|
|
2022-10-15 20:56:30 +02:00
|
|
|
officialnews = Node.void("officialnews")
|
2019-12-08 22:43:49 +01:00
|
|
|
data.add_child(officialnews)
|
2022-10-15 20:56:30 +02:00
|
|
|
officialnews.set_attribute("count", "0")
|
2019-12-08 22:43:49 +01:00
|
|
|
|
|
|
|
return demodata
|
|
|
|
|
|
|
|
|
|
|
|
class JubeatDemodataGetHitchartHandler(JubeatBase):
|
|
|
|
def handle_demodata_get_hitchart_request(self, request: Node) -> Node:
|
2022-10-15 20:56:30 +02:00
|
|
|
demodata = Node.void("demodata")
|
|
|
|
data = Node.void("data")
|
2019-12-08 22:43:49 +01:00
|
|
|
demodata.add_child(data)
|
|
|
|
|
|
|
|
# Not sure what this is, maybe date?
|
2022-10-15 20:56:30 +02:00
|
|
|
data.add_child(Node.string("update", time.strftime("%d/%m/%Y")))
|
2019-12-08 22:43:49 +01:00
|
|
|
|
|
|
|
# No idea which songs are licensed or regular, so only return hit chart
|
|
|
|
# for all songs on regular mode.
|
2022-10-15 20:56:30 +02:00
|
|
|
hitchart_lic = Node.void("hitchart_lic")
|
2019-12-08 22:43:49 +01:00
|
|
|
data.add_child(hitchart_lic)
|
2022-10-15 20:56:30 +02:00
|
|
|
hitchart_lic.set_attribute("count", "0")
|
2019-12-08 22:43:49 +01:00
|
|
|
|
2022-08-18 00:29:56 +02:00
|
|
|
songs = self.data.local.music.get_hit_chart(self.game, self.music_version, 10)
|
2022-10-15 20:56:30 +02:00
|
|
|
hitchart_org = Node.void("hitchart_org")
|
2019-12-08 22:43:49 +01:00
|
|
|
data.add_child(hitchart_org)
|
2022-10-15 20:56:30 +02:00
|
|
|
hitchart_org.set_attribute("count", str(len(songs)))
|
2019-12-08 22:43:49 +01:00
|
|
|
rank = 1
|
|
|
|
for song in songs:
|
2022-10-15 20:56:30 +02:00
|
|
|
rankdata = Node.void("rankdata")
|
2019-12-08 22:43:49 +01:00
|
|
|
hitchart_org.add_child(rankdata)
|
2022-10-15 20:56:30 +02:00
|
|
|
rankdata.add_child(Node.s32("music_id", song[0]))
|
|
|
|
rankdata.add_child(Node.s16("rank", rank))
|
|
|
|
rankdata.add_child(Node.s16("prev", rank))
|
2019-12-08 22:43:49 +01:00
|
|
|
rank = rank + 1
|
|
|
|
|
|
|
|
return demodata
|
|
|
|
|
|
|
|
|
|
|
|
class JubeatLobbyCheckHandler(JubeatBase):
|
|
|
|
def handle_lobby_check_request(self, request: Node) -> Node:
|
2022-10-15 20:56:30 +02:00
|
|
|
root = Node.void("lobby")
|
|
|
|
data = Node.void("data")
|
2019-12-08 22:43:49 +01:00
|
|
|
root.add_child(data)
|
|
|
|
|
2022-10-15 20:56:30 +02:00
|
|
|
data.add_child(Node.s16("interval", 0))
|
|
|
|
data.add_child(Node.s16("entry_timeout", 0))
|
|
|
|
entrant_nr = Node.u32("entrant_nr", 0)
|
|
|
|
entrant_nr.set_attribute("time", "0")
|
2019-12-08 22:43:49 +01:00
|
|
|
data.add_child(entrant_nr)
|
|
|
|
|
|
|
|
return root
|
|
|
|
|
|
|
|
|
|
|
|
class JubeatGamendRegisterHandler(JubeatBase):
|
|
|
|
def handle_gameend_regist_request(self, request: Node) -> Node:
|
2022-10-15 20:56:30 +02:00
|
|
|
data = request.child("data")
|
|
|
|
player = data.child("player")
|
2019-12-08 22:43:49 +01:00
|
|
|
|
|
|
|
if player is not None:
|
2022-10-15 20:56:30 +02:00
|
|
|
refid = player.child_value("refid")
|
2019-12-08 22:43:49 +01:00
|
|
|
else:
|
|
|
|
refid = None
|
|
|
|
|
|
|
|
if refid is not None:
|
|
|
|
userid = self.data.remote.user.from_refid(self.game, self.version, refid)
|
|
|
|
else:
|
|
|
|
userid = None
|
|
|
|
|
|
|
|
if userid is not None:
|
|
|
|
oldprofile = self.get_profile(userid)
|
|
|
|
newprofile = self.unformat_profile(userid, request, oldprofile)
|
|
|
|
else:
|
|
|
|
newprofile = None
|
|
|
|
|
|
|
|
if userid is not None and newprofile is not None:
|
|
|
|
self.put_profile(userid, newprofile)
|
|
|
|
|
2022-10-15 20:56:30 +02:00
|
|
|
gameend = Node.void("gameend")
|
|
|
|
data = Node.void("data")
|
2019-12-08 22:43:49 +01:00
|
|
|
gameend.add_child(data)
|
2022-10-15 20:56:30 +02:00
|
|
|
player = Node.void("player")
|
2019-12-08 22:43:49 +01:00
|
|
|
data.add_child(player)
|
2022-10-15 20:56:30 +02:00
|
|
|
player.add_child(Node.s32("session_id", 1))
|
|
|
|
player.add_child(Node.s32("end_final_session_id", 1))
|
2019-12-08 22:43:49 +01:00
|
|
|
return gameend
|
|
|
|
|
|
|
|
|
|
|
|
class JubeatGametopGetMeetingHandler(JubeatBase):
|
|
|
|
def handle_gametop_get_meeting_request(self, request: Node) -> Node:
|
2022-10-15 20:56:30 +02:00
|
|
|
gametop = Node.void("gametop")
|
|
|
|
data = Node.void("data")
|
2019-12-08 22:43:49 +01:00
|
|
|
gametop.add_child(data)
|
2022-10-15 20:56:30 +02:00
|
|
|
meeting = Node.void("meeting")
|
2019-12-08 22:43:49 +01:00
|
|
|
data.add_child(meeting)
|
2022-10-15 20:56:30 +02:00
|
|
|
single = Node.void("single")
|
2019-12-08 22:43:49 +01:00
|
|
|
meeting.add_child(single)
|
2022-10-15 20:56:30 +02:00
|
|
|
single.set_attribute("count", "0")
|
|
|
|
tag = Node.void("tag")
|
2019-12-08 22:43:49 +01:00
|
|
|
meeting.add_child(tag)
|
2022-10-15 20:56:30 +02:00
|
|
|
tag.set_attribute("count", "0")
|
|
|
|
reward = Node.void("reward")
|
2019-12-08 22:43:49 +01:00
|
|
|
data.add_child(reward)
|
2022-10-15 20:56:30 +02:00
|
|
|
reward.add_child(Node.s32("total", -1))
|
|
|
|
reward.add_child(Node.s32("point", -1))
|
2019-12-08 22:43:49 +01:00
|
|
|
return gametop
|