diva: fix start, spend_credit, and get_pv_pd requests

This commit is contained in:
Kevin Trocolli
2023-10-04 23:58:26 -04:00
parent f836b5dd21
commit 5e03193819
5 changed files with 101 additions and 98 deletions

View File

@@ -1,2 +1,3 @@
from titles.diva.handlers.base import *
from titles.diva.handlers.user import *
from .base import *
from .user import *
from .pv import *

View File

@@ -45,14 +45,6 @@ class BaseBinaryRequest:
class BaseRequest:
cmd: str
req_id: str
game_id: str
r_rev: str
kc_serial: str
b_serial: str
country_code: str
def __init__(self, raw: Union[str, bytes]) -> None:
self.raw = raw
try:
@@ -103,10 +95,18 @@ class BaseRequest:
f"time_stamp not in request data {self.raw_dict}"
)
self.cmd: str
self.req_id: str
self.game_id: str
self.r_rev: str
self.kc_serial: str
self.b_serial: str
self.country_code: str
for k, v in self.raw_dict.items():
setattr(self, k, v)
self.place_id = int(self.place_id)
self.place_id = int(self.place_id, 16)
self.start_up_mode = int(self.start_up_mode)
self.cmm_dly_mod = int(self.cmm_dly_mod)
self.cmm_dly_sec = int(self.cmm_dly_sec)
@@ -162,3 +162,26 @@ class AttendResponse(BaseResponse):
ret += "&" + parse.urlencode(ret_dict, safe=",")
return ret
class SpendCreditRequest(BaseRequest):
def __init__(self, raw: str | bytes) -> None:
super().__init__(raw)
try:
self.pd_id = int(self.pd_id)
self.my_qst_id = [int(x) for x in self.my_qst_id.split(",")]
self.my_qst_sts = [int(x) for x in self.my_qst_sts.split(",")]
self.crdt_typ = int(self.crdt_typ)
self.cmpgn_id = [int(x) for x in self.cmpgn_id.split(",")]
self.cmpgn_pb = [int(x) for x in self.cmpgn_pb.split(",")]
except AttributeError as e:
raise DivaRequestParseException(f"StartRequest: {e}")
class SpendCreditResponse(BaseResponse):
def __init__(self, cmd_id: str, req_id: int) -> None:
super().__init__(cmd_id, req_id)
self.cmpgn_rslt = ",".join(["-1,-1,x,-1,-1,x,x,-1,x"] * 6)
self.cmpgn_rslt_num = 0
self.vcld_pts = 0
self.lv_str = ""
self.lv_efct_id = 0
self.lv_plt_id = 0

View File

@@ -0,0 +1,29 @@
from typing import Union, List
from titles.diva.handlers.base import (
BaseRequest,
BaseResponse,
DivaRequestParseException,
)
from datetime import datetime
from urllib import parse
from ..const import DivaConstants
class GetPvPdRequest(BaseRequest):
def __init__(self, raw: str | bytes) -> None:
super().__init__(raw)
try:
self.pd_id = int(self.pd_id)
self.accept_idx = int(self.accept_idx)
self.start_idx = int(self.start_idx)
self.difficulty = int(self.difficulty)
self.pd_pv_id_lst: List[int] = [int(x) for x in self.pd_pv_id_lst.split(',')]
except AttributeError as e:
raise DivaRequestParseException(f"GetPvPdRequest: {e}")
class GetPvPdResponse(BaseResponse):
def __init__(self, cmd_id: str, req_id: int) -> None:
super().__init__(cmd_id, req_id)
self.pd_by_pv_id = ""
self.pdddt_flg = 0
self.pdddt_tm = parse.quote(datetime.now().strftime(DivaConstants.LUT_TIME_FMT))

View File

@@ -8,15 +8,15 @@ from urllib import parse
from ..const import DivaConstants
class PreStartRequest(BaseRequest):
pmm: str
idm: str
mmgameid: str
mmuid: str
a_code: str
aime_id: str
aime_a_code: str
def __init__(self, raw: str) -> None:
self.pmm: str
self.idm: str
self.mmgameid: str
self.mmuid: str
self.a_code: str
self.aime_id: str
self.aime_a_code: str
super().__init__(raw)
try:
self.key_obj_type = int(self.key_obj_type)
@@ -27,8 +27,6 @@ class PreStartRequest(BaseRequest):
class PreStartResponse(BaseResponse):
def __init__(self, cmd_id: str, req_id: int, pd_id: int) -> None:
super().__init__(cmd_id, req_id)
self.ps_result = 1