1
0
mirror of synced 2024-11-27 23:50:47 +01:00

Rename whole-service route handler, get rid of legacy eacoin handler that's broken due to evaluation order, fix eacoin disable bug that I just discovered.

This commit is contained in:
Jennifer Taylor 2022-10-04 03:31:52 +00:00
parent 15c07b49a9
commit 8c1d272c72
9 changed files with 52 additions and 19 deletions

View File

@ -26,8 +26,9 @@ class Factory(ABC):
"""
The base class every game factory inherits from. Defines a create method
which should return some game class which can handle packets. Game classes
inherit from Base, and have handle_<call>_request methods on them that
Dispatch will look up in order to handle calls.
inherit from Base, and have handle_<call>_requests service methods or
handle_<call>_<method>_request methods on them that Dispatch will look up
in order to handle calls.
"""
MANAGED_CLASSES: List[Type["Base"]]

View File

@ -1,4 +1,3 @@
from typing import Optional
from typing_extensions import Final
from bemani.backend.base import Base, Status
@ -24,11 +23,7 @@ class PASELIHandler(Base):
"""
paseli_padding: int = 1
def handle_eacoin_request(self, request: Node) -> Optional[Node]:
"""
First, a generic handler to catch if paseli is not enabled, so that each
individual method below doesn't need to handle it.
"""
def handle_eacoin_checkin_request(self, request: Node) -> Node:
if not self.config.paseli.enabled:
# Refuse to respond, we don't have PASELI enabled
print("PASELI not enabled, ignoring eacoin request")
@ -36,10 +31,6 @@ class PASELIHandler(Base):
root.set_attribute('status', str(Status.NOT_ALLOWED))
return root
# This is fine, let the individual request handlers handle this packet.
return None
def handle_eacoin_checkin_request(self, request: Node) -> Node:
root = Node.void('eacoin')
cardid = request.child_value('cardid')
pin = request.child_value('passwd')
@ -85,6 +76,13 @@ class PASELIHandler(Base):
return root
def handle_eacoin_opcheckin_request(self, request: Node) -> Node:
if not self.config.paseli.enabled:
# Refuse to respond, we don't have PASELI enabled
print("PASELI not enabled, ignoring eacoin request")
root = Node.void('eacoin')
root.set_attribute('status', str(Status.NOT_ALLOWED))
return root
root = Node.void('eacoin')
passwd = request.child_value('passwd')
@ -118,6 +116,12 @@ class PASELIHandler(Base):
return root
def handle_eacoin_consume_request(self, request: Node) -> Node:
if not self.config.paseli.enabled:
# Refuse to respond, we don't have PASELI enabled
print("PASELI not enabled, ignoring eacoin request")
root = Node.void('eacoin')
root.set_attribute('status', str(Status.NOT_ALLOWED))
return root
def make_resp(status: int, balance: int) -> Node:
root = Node.void('eacoin')
@ -174,6 +178,13 @@ class PASELIHandler(Base):
return make_resp(0, balance)
def handle_eacoin_getlog_request(self, request: Node) -> Node:
if not self.config.paseli.enabled:
# Refuse to respond, we don't have PASELI enabled
print("PASELI not enabled, ignoring eacoin request")
root = Node.void('eacoin')
root.set_attribute('status', str(Status.NOT_ALLOWED))
return root
root = Node.void('eacoin')
sessid = request.child_value('sessid')
logtype = request.child_value('logtype')
@ -389,6 +400,13 @@ class PASELIHandler(Base):
return root
def handle_eacoin_opchpass_request(self, request: Node) -> Node:
if not self.config.paseli.enabled:
# Refuse to respond, we don't have PASELI enabled
print("PASELI not enabled, ignoring eacoin request")
root = Node.void('eacoin')
root.set_attribute('status', str(Status.NOT_ALLOWED))
return root
root = Node.void('eacoin')
oldpass = request.child_value('passwd')
newpass = request.child_value('newpasswd')
@ -423,6 +441,13 @@ class PASELIHandler(Base):
return root
def handle_eacoin_checkout_request(self, request: Node) -> Node:
if not self.config.paseli.enabled:
# Refuse to respond, we don't have PASELI enabled
print("PASELI not enabled, ignoring eacoin request")
root = Node.void('eacoin')
root.set_attribute('status', str(Status.NOT_ALLOWED))
return root
session = request.child_value('sessid')
if session is not None:
# Destroy the session so it can't be used for any other purchases
@ -432,6 +457,13 @@ class PASELIHandler(Base):
return root
def handle_eacoin_opcheckout_request(self, request: Node) -> Node:
if not self.config.paseli.enabled:
# Refuse to respond, we don't have PASELI enabled
print("PASELI not enabled, ignoring eacoin request")
root = Node.void('eacoin')
root.set_attribute('status', str(Status.NOT_ALLOWED))
return root
session = request.child_value('sessid')
if session is not None:
# Destroy the session so it can't be used for any other purchases

View File

@ -147,7 +147,7 @@ class Dispatch:
if response is None:
# Now, try to pass it off to a generic service handler
try:
handler = getattr(game, f'handle_{request.name}_request')
handler = getattr(game, f'handle_{request.name}_requests')
except AttributeError:
handler = None
if handler is not None:

View File

@ -106,7 +106,7 @@ class PopnMusicModernBase(PopnMusicBase, ABC):
return self.GAME_PLAY_RANK_AAA
return self.GAME_PLAY_RANK_S
def handle_lobby24_request(self, request: Node) -> Node:
def handle_lobby24_requests(self, request: Node) -> Node:
# Stub out the entire lobby24 service
return Node.void('lobby24')

View File

@ -254,7 +254,7 @@ class PopnMusicEclale(PopnMusicBase):
self.__construct_common_info(info)
return info
def handle_lobby22_request(self, request: Node) -> Node:
def handle_lobby22_requests(self, request: Node) -> Node:
# Stub out the entire lobby22 service (yes, its lobby22 in Pop'n 23)
return Node.void('lobby22')

View File

@ -636,6 +636,6 @@ class PopnMusicFantasia(PopnMusicBase):
self.update_machine(machine)
return Node.void('game')
def handle_lobby_request(self, request: Node) -> Node:
def handle_lobby_requests(self, request: Node) -> Node:
# Stub out the entire lobby service
return Node.void('lobby')

View File

@ -249,7 +249,7 @@ class PopnMusicLapistoria(PopnMusicBase):
self.update_machine_name(request.child_value('pcb_setting/name'))
return Node.void('pcb22')
def handle_lobby22_request(self, request: Node) -> Node:
def handle_lobby22_requests(self, request: Node) -> Node:
# Stub out the entire lobby22 service
return Node.void('lobby22')

View File

@ -699,6 +699,6 @@ class PopnMusicSunnyPark(PopnMusicBase):
return root
def handle_lobby_request(self, request: Node) -> Node:
def handle_lobby_requests(self, request: Node) -> Node:
# Stub out the entire lobby service
return Node.void('lobby')

View File

@ -616,6 +616,6 @@ class PopnMusicTuneStreet(PopnMusicBase):
return root
def handle_lobby_request(self, request: Node) -> Node:
def handle_lobby_requests(self, request: Node) -> Node:
# Stub out the entire lobby service
return Node.void('lobby')