forked from Dniel97/artemis
pokken: add skeleton LoadUser response
This commit is contained in:
parent
ac8a660e13
commit
6489e3ca21
@ -1,8 +1,10 @@
|
|||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
import json, logging
|
import json, logging
|
||||||
from typing import Any, Dict
|
from typing import Any, Dict
|
||||||
|
import random
|
||||||
|
|
||||||
from core.config import CoreConfig
|
from core.data import Data
|
||||||
|
from core import CoreConfig
|
||||||
from titles.pokken.config import PokkenConfig
|
from titles.pokken.config import PokkenConfig
|
||||||
from titles.pokken.proto import jackal_pb2
|
from titles.pokken.proto import jackal_pb2
|
||||||
|
|
||||||
@ -13,6 +15,7 @@ class PokkenBase:
|
|||||||
self.game_cfg = game_cfg
|
self.game_cfg = game_cfg
|
||||||
self.version = 0
|
self.version = 0
|
||||||
self.logger = logging.getLogger("pokken")
|
self.logger = logging.getLogger("pokken")
|
||||||
|
self.data = Data(core_cfg)
|
||||||
|
|
||||||
def handle_noop(self, request: Any) -> bytes:
|
def handle_noop(self, request: Any) -> bytes:
|
||||||
res = jackal_pb2.Response()
|
res = jackal_pb2.Response()
|
||||||
@ -123,7 +126,94 @@ class PokkenBase:
|
|||||||
ranking.event_end = True
|
ranking.event_end = True
|
||||||
ranking.modify_date = int(datetime.now().timestamp() / 1000)
|
ranking.modify_date = int(datetime.now().timestamp() / 1000)
|
||||||
res.load_ranking.CopyFrom(ranking)
|
res.load_ranking.CopyFrom(ranking)
|
||||||
|
return res.SerializeToString()
|
||||||
|
|
||||||
|
def handle_load_user(self, request: jackal_pb2.Request) -> bytes:
|
||||||
|
res = jackal_pb2.Response()
|
||||||
|
res.result = 1
|
||||||
|
res.type = jackal_pb2.MessageType.LOAD_USER
|
||||||
|
access_code = request.load_user.access_code
|
||||||
|
user_id = self.data.card.get_user_id_from_card(access_code)
|
||||||
|
|
||||||
|
if user_id is None: # TODO: Toggle auto-register
|
||||||
|
user_id = self.data.user.create_user()
|
||||||
|
card_id = self.data.card.create_card(user_id, access_code)
|
||||||
|
|
||||||
|
self.logger.info(f"Register new card {access_code} (UserId {user_id}, CardId {card_id})")
|
||||||
|
|
||||||
|
# TODO: Check for user data. For now just treat ever card-in as a new user
|
||||||
|
|
||||||
|
load_usr = jackal_pb2.LoadUserResponseData()
|
||||||
|
load_usr.commidserv_result = 1
|
||||||
|
load_usr.load_hash = 1
|
||||||
|
load_usr.cardlock_status = False
|
||||||
|
load_usr.banapass_id = user_id
|
||||||
|
load_usr.access_code = access_code
|
||||||
|
load_usr.new_card_flag = True
|
||||||
|
load_usr.precedent_release_flag = 0xFFFFFFFF
|
||||||
|
load_usr.navi_newbie_flag = True
|
||||||
|
load_usr.navi_enable_flag = True
|
||||||
|
load_usr.pad_vibrate_flag = True
|
||||||
|
load_usr.home_region_code = 0
|
||||||
|
load_usr.home_loc_name = ""
|
||||||
|
load_usr.pref_code = 0
|
||||||
|
load_usr.trainer_name = "Newb" + str(random.randint(1111,999999))
|
||||||
|
load_usr.trainer_rank_point = 0
|
||||||
|
load_usr.wallet = 0
|
||||||
|
load_usr.fight_money = 0
|
||||||
|
load_usr.score_point = 0
|
||||||
|
load_usr.grade_max_num = 0
|
||||||
|
load_usr.total_play_days = 0
|
||||||
|
load_usr.play_date_time = 0
|
||||||
|
load_usr.lucky_box_fail_num = 0
|
||||||
|
load_usr.event_reward_get_flag = 0
|
||||||
|
load_usr.rank_pvp_all = 0
|
||||||
|
load_usr.rank_pvp_loc = 0
|
||||||
|
load_usr.rank_cpu_all = 0
|
||||||
|
load_usr.rank_cpu_loc = 0
|
||||||
|
load_usr.rank_event = 0
|
||||||
|
load_usr.awake_num = 0
|
||||||
|
load_usr.use_support_num = 0
|
||||||
|
load_usr.rankmatch_flag = 0
|
||||||
|
load_usr.title_text_id = 0
|
||||||
|
load_usr.title_plate_id = 0
|
||||||
|
load_usr.title_decoration_id = 0
|
||||||
|
load_usr.navi_trainer = 0
|
||||||
|
load_usr.navi_version_id = 0
|
||||||
|
load_usr.aid_skill = 0
|
||||||
|
load_usr.comment_text_id = 0
|
||||||
|
load_usr.comment_word_id = 0
|
||||||
|
load_usr.latest_use_pokemon = 0
|
||||||
|
load_usr.ex_ko_num = 0
|
||||||
|
load_usr.wko_num = 0
|
||||||
|
load_usr.timeup_win_num = 0
|
||||||
|
load_usr.cool_ko_num = 0
|
||||||
|
load_usr.perfect_ko_num = 0
|
||||||
|
load_usr.record_flag = 0
|
||||||
|
load_usr.site_register_status = 0
|
||||||
|
load_usr.continue_num = 0
|
||||||
|
load_usr.event_state = 0
|
||||||
|
load_usr.event_id = 0
|
||||||
|
load_usr.sp_bonus_category_id_1 = 0
|
||||||
|
load_usr.sp_bonus_key_value_1 = 0
|
||||||
|
load_usr.sp_bonus_category_id_2 = 0
|
||||||
|
load_usr.sp_bonus_key_value_2 = 0
|
||||||
|
|
||||||
|
res.load_user.CopyFrom(load_usr)
|
||||||
|
return res.SerializeToString()
|
||||||
|
|
||||||
|
def handle_set_bnpassid_lock(self, data: jackal_pb2.Request) -> bytes:
|
||||||
|
res = jackal_pb2.Response()
|
||||||
|
res.result = 1
|
||||||
|
res.type = jackal_pb2.MessageType.SET_BNPASSID_LOCK
|
||||||
|
return res.SerializeToString()
|
||||||
|
|
||||||
|
def handle_save_ingame_log(self, data: jackal_pb2.Request) -> bytes:
|
||||||
|
res = jackal_pb2.Response()
|
||||||
|
res.result = 1
|
||||||
|
res.type = jackal_pb2.MessageType.SET_BNPASSID_LOCK
|
||||||
|
return res.SerializeToString()
|
||||||
|
|
||||||
def handle_matching_noop(self, data: Dict = {}, client_ip: str = "127.0.0.1") -> Dict:
|
def handle_matching_noop(self, data: Dict = {}, client_ip: str = "127.0.0.1") -> Dict:
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
|
@ -124,7 +124,6 @@ class PokkenServlet(resource.Resource):
|
|||||||
self.logger.debug(pokken_request)
|
self.logger.debug(pokken_request)
|
||||||
|
|
||||||
ret = handler(pokken_request)
|
ret = handler(pokken_request)
|
||||||
self.logger.debug(f"Response: {ret}")
|
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
def handle_matching(self, request: Request) -> bytes:
|
def handle_matching(self, request: Request) -> bytes:
|
||||||
|
Loading…
Reference in New Issue
Block a user