diff --git a/v8_server/eamuse/services/__init__.py b/v8_server/eamuse/services/__init__.py
index ec86f9d..b62614d 100644
--- a/v8_server/eamuse/services/__init__.py
+++ b/v8_server/eamuse/services/__init__.py
@@ -1,4 +1,5 @@
from v8_server.eamuse.services.facility import Facility
+from v8_server.eamuse.services.local import Local
from v8_server.eamuse.services.message import Message
from v8_server.eamuse.services.package import Package
from v8_server.eamuse.services.pcbevent import PCBEvent
@@ -8,6 +9,7 @@ from v8_server.eamuse.services.services import ServiceRequest, Services, Service
__all__ = [
"Facility",
+ "Local",
"Message",
"PCBEvent",
"PCBTracker",
diff --git a/v8_server/eamuse/services/local.py b/v8_server/eamuse/services/local.py
new file mode 100644
index 0000000..64f12bd
--- /dev/null
+++ b/v8_server/eamuse/services/local.py
@@ -0,0 +1,173 @@
+from lxml import etree
+from lxml.builder import E
+
+from v8_server.eamuse.services.services import ServiceRequest
+from v8_server.eamuse.utils.xml import XMLBinTypes as T, e_type
+
+
+class Local(object):
+ """
+ Handle the Local request.
+
+ This request handles most of the game specific requests.
+ """
+
+ # Methods
+ SHOPINFO = "shopinfo"
+ SHOPINFO_REGIST = "regist"
+
+ DEMODATA = "demodata"
+ DEMODATA_GET = "get"
+
+ CARDUTIL = "cardutil"
+ CARDUTIL_CHECK = "check"
+
+ @classmethod
+ def shopinfo(cls, req: ServiceRequest) -> etree:
+ """
+ Handle the shopinfo request
+
+ Example Request:
+
+
+
+ あ
+ 31
+ 00010203040506070809
+ 012112345679
+ 010074D435AAD895
+ CA-123
+
+
+ 20
+ 20
+
+
+
+
+ 3
+
+
+ 3
+
+ 3
+
+
+
+ 15
+
+
+
+ 0
+
+
+
+ 8
+
+
+ 0
+
+
+
+
+
+
+ Example Response:
+
+
+
+ 1
+ nowhere
+ 1
+
+
+
+ """
+
+ if req.method == cls.SHOPINFO_REGIST:
+ response = E.response(
+ E.shopinfo(
+ E.data(
+ E.cabid("1", e_type(T.u32)),
+ E.locationid("nowhere"),
+ E.is_send("1", e_type(T.u8)),
+ )
+ )
+ )
+ else:
+ raise Exception(
+ "Not sure how to handle this shopinfo request. "
+ f'method "{req.method}" is unknown for request: {req}'
+ )
+
+ return response
+
+ @classmethod
+ def demodata(cls, req: ServiceRequest) -> etree:
+ """
+ Handle the demodata request.
+
+ # Example Request:
+
+
+
+ CA-123
+
+ 100
+
+
+
+ # Example Response:
+
+
+
+ """
+ # TODO: Figure out what this thing actually needs to send back
+
+ if req.method == cls.DEMODATA_GET:
+ response = E.response(E.demodata({"expire": "600"}))
+ else:
+ raise Exception(
+ "Not sure how to handle this demodata request. "
+ f'method "{req.method}" is unknown for request: {req}'
+ )
+
+ return response
+
+ @classmethod
+ def cardutil(cls, req: ServiceRequest) -> etree:
+ """
+ Handle the Cardutil request.
+
+ # Example Request:
+
+
+
+ ADE0FE0B14AEAEFC
+ E0040100DE52896C
+
+
+
+
+ # Example Response:
+
+
+
+
+
+
+
+ """
+ # TODO: Figure out what this thing actually needs to send back
+
+ if req.method == cls.CARDUTIL_CHECK:
+ response = E.response(
+ E.cardutil(E.card(E.kind("0", e_type(T.s8)), {"no": "1", "state": "0"}))
+ )
+ else:
+ raise Exception(
+ "Not sure how to handle this cardutil request. "
+ f'method "{req.method}" is unknown for request: {req}'
+ )
+
+ return response
diff --git a/v8_server/view/index.py b/v8_server/view/index.py
index 1a7c345..ad99a68 100644
--- a/v8_server/view/index.py
+++ b/v8_server/view/index.py
@@ -7,6 +7,7 @@ from sqlalchemy.orm.exc import MultipleResultsFound
from v8_server import app
from v8_server.eamuse.services import (
Facility,
+ Local,
Message,
Package,
PCBEvent,
@@ -287,53 +288,26 @@ def cardmng() -> Tuple[bytes, Dict[str, str]]:
else:
response = base_response(module)
return eamuse_prepare_xml(response, request)
-
-
-@app.route("/local/service", methods=["POST"])
-def local() -> Tuple[bytes, Dict[str, str]]:
- """
- This is probably a big chunk of implementation. Handle all "local" service requests
- which might have a whole bunch of stuff going on
- """
-
- xml, model, module, method, command = eamuse_read_xml(request)
-
- if module == "shopinfo":
- if method == "regist":
- response = E.response(
- E.shopinfo(
- E.data(
- E.cabid("1", e_type("u32")),
- E.locationid("nowhere"),
- E.is_send("1", e_type("u8")),
- )
- )
- )
- elif module == "demodata":
- # TODO: Not really sure what to return here
- if method == "get":
- response = base_response(module)
- elif module == "cardutil":
- # TODO: Not really sure what to return here
- if method == "check":
- # Return the users game information
-
- # If the user doesn't have any game information yet:
- response = E.response(
- E.cardutil(E.card(E.kind("0", e_type("s8")), {"no": "1", "state": "0"}))
- )
-
- # Else get the user info and send that you idiot
- else:
- response = base_response(module)
-
- return eamuse_prepare_xml(response, request)
-
'''
+@Services.route(ServiceType.LOCAL)
+def local_service() -> FlaskResponse:
+ req = ServiceRequest(request)
+
+ if req.module == Local.SHOPINFO:
+ response = Local.shopinfo(req)
+ elif req.module == Local.DEMODATA:
+ response = Local.demodata(req)
+ elif req.module == Local.CARDUTIL:
+ response = Local.cardutil(req)
+ else:
+ raise Exception(f"Not sure how to handle this Local Request: {req}")
+ return req.response(response)
+
+
@app.route(Services.SERVICES_ROUTE, methods=["POST"])
-def services_service() -> Tuple[bytes, Dict[str, str]]:
- s_req = ServiceRequest(request)
+def services_service() -> FlaskResponse:
+ req = ServiceRequest(request)
services = Services().get_services()
- return s_req.response(services)
+ return req.response(services)