3
2
forked from Dniel97/artemis

pokken: restructure database

This commit is contained in:
Hay1tsme 2023-04-12 02:34:29 -04:00
parent 68e25b9c5e
commit bd356af272
6 changed files with 27 additions and 62 deletions

1
.gitignore vendored
View File

@ -158,5 +158,6 @@ cert/*
!cert/server.pem
config/*
deliver/*
*.gz
dbdump-*.json

View File

@ -55,7 +55,7 @@ class AllnetServlet:
self.logger.error("No games detected!")
for _, mod in plugins.items():
if hasattr(mod.index, "get_allnet_info"):
if hasattr(mod, "index") and hasattr(mod.index, "get_allnet_info"):
for code in mod.game_codes:
enabled, uri, host = mod.index.get_allnet_info(
code, self.config, self.config_folder

View File

@ -17,6 +17,7 @@ class PokkenBase:
self.version = 0
self.logger = logging.getLogger("pokken")
self.data = PokkenData(core_cfg)
self.SUPPORT_SET_NONE = 4294967295
def handle_noop(self, request: Any) -> bytes:
res = jackal_pb2.Response()
@ -281,6 +282,12 @@ class PokkenBase:
res.type = jackal_pb2.MessageType.SAVE_INGAME_LOG
return res.SerializeToString()
def handle_save_charge(self, data: jackal_pb2.Request) -> bytes:
res = jackal_pb2.Response()
res.result = 1
res.type = jackal_pb2.MessageType.SAVE_CHARGE
return res.SerializeToString()
def handle_matching_noop(self, data: Dict = {}, client_ip: str = "127.0.0.1") -> Dict:
return {}

View File

@ -87,7 +87,7 @@ class PokkenServlet(resource.Resource):
if not game_cfg.server.enable:
return (False, "")
return (True, "PKF2")
return (True, "PKF1")
def setup(self) -> None:
# TODO: Setup stun, turn (UDP) and admission (WSS) servers
@ -114,6 +114,8 @@ class PokkenServlet(resource.Resource):
endpoint = jackal_pb2.MessageType.DESCRIPTOR.values_by_number[
pokken_request.type
].name.lower()
self.logger.debug(pokken_request)
handler = getattr(self.base, f"handle_{endpoint}", None)
if handler is None:
@ -121,7 +123,6 @@ class PokkenServlet(resource.Resource):
return self.base.handle_noop(pokken_request)
self.logger.info(f"{endpoint} request from {Utils.get_ip_addr(request)}")
self.logger.debug(pokken_request)
ret = handler(pokken_request)
return ret

View File

@ -14,8 +14,9 @@ match_data = Table(
metadata,
Column('id', Integer, primary_key=True, nullable=False),
Column('user', ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade"), nullable=False),
Column('play_mode', Integer),
Column('result', Integer),
Column('num_games', Integer),
Column('play_modes', JSON),
Column('results', JSON),
Column('ex_ko_num', Integer),
Column('wko_num', Integer),
Column('timeup_win_num', Integer),

View File

@ -28,8 +28,10 @@ profile = Table(
Column('score_point', Integer),
Column('grade_max_num', Integer),
Column('extra_counter', Integer), # Optional
Column('tutorial_progress_flag', JSON), # Repeated, Integer
Column('total_play_days', Integer),
Column('play_date_time', Integer),
Column('achievement_flag', JSON), # Repeated, Integer
Column('lucky_box_fail_num', Integer),
Column('event_reward_get_flag', Integer),
Column('rank_pvp_all', Integer),
@ -41,15 +43,19 @@ profile = Table(
Column('use_support_num', Integer),
Column('rankmatch_flag', Integer),
Column('rankmatch_max', Integer), # Optional
Column('rankmatch_progress', JSON), # Repeated, Integer
Column('rankmatch_success', Integer), # Optional
Column('beat_num', Integer), # Optional
Column('title_text_id', Integer),
Column('title_plate_id', Integer),
Column('title_decoration_id', Integer),
Column('support_pokemon_list', JSON), # Repeated, Integer
Column('support_set_1', JSON), # Repeated, Integer
Column('support_set_2', JSON), # Repeated, Integer
Column('support_set_3', JSON), # Repeated, Integer
Column('support_set_1_1', Integer), # Repeated, Integer
Column('support_set_1_2', Integer),
Column('support_set_2_1', Integer), # Repeated, Integer
Column('support_set_2_2', Integer),
Column('support_set_3_1', Integer), # Repeated, Integer
Column('support_set_3_2', Integer),
Column('navi_trainer', Integer),
Column('navi_version_id', Integer),
Column('aid_skill_list', JSON), # Repeated, Integer
@ -84,56 +90,8 @@ profile = Table(
Column('sp_bonus_category_id_2', Integer),
Column('sp_bonus_key_value_2', Integer),
Column('last_play_event_id', Integer), # Optional
mysql_charset="utf8mb4",
)
tutorial_progress = Table(
'pokken_tutorial_progress',
metadata,
Column('id', Integer, primary_key=True, nullable=False),
Column('user', ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade"), nullable=False),
Column('flag', Integer),
UniqueConstraint('user', 'flag', name='pokken_tutorial_progress_uk'),
mysql_charset="utf8mb4",
)
rankmatch_progress = Table(
'pokken_rankmatch_progress',
metadata,
Column('id', Integer, primary_key=True, nullable=False),
Column('user', ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade"), nullable=False),
Column('progress', Integer),
UniqueConstraint('user', 'progress', name='pokken_rankmatch_progress_uk'),
mysql_charset="utf8mb4",
)
achievement_flag = Table(
'pokken_achievement_flag',
metadata,
Column('id', Integer, primary_key=True, nullable=False),
Column('user', ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade"), nullable=False),
Column('flag', Integer),
UniqueConstraint('user', 'flag', name='pokken_achievement_flag_uk'),
mysql_charset="utf8mb4",
)
event_achievement_flag = Table(
'pokken_event_achievement_flag',
metadata,
Column('id', Integer, primary_key=True, nullable=False),
Column('user', ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade"), nullable=False),
Column('flag', Integer),
UniqueConstraint('user', 'flag', name='pokken_event_achievement_flag_uk'),
mysql_charset="utf8mb4",
)
event_achievement_param = Table(
'pokken_event_achievement_param',
metadata,
Column('id', Integer, primary_key=True, nullable=False),
Column('user', ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade"), nullable=False),
Column('param', Integer),
UniqueConstraint('user', 'param', name='pokken_event_achievement_param_uk'),
Column('event_achievement_flag', JSON), # Repeated, Integer
Column('event_achievement_param', JSON), # Repeated, Integer
mysql_charset="utf8mb4",
)
@ -176,10 +134,7 @@ class PokkenProfileData(BaseData):
if result is None:
self.logger.error(f"Failed to update pokken profile name for user {user_id}!")
def update_profile(self, user_id: int, profile_data: Dict) -> None:
"""
TODO: Find out what comes in on the SaveUserRequestData protobuf and save it!
"""
def update_profile_tutorial_flags(self, user_id: int, tutorial_flags: Dict) -> None:
pass
def get_profile(self, user_id: int) -> Optional[Row]: