mirror of
https://gitea.tendokyu.moe/Hay1tsme/artemis.git
synced 2026-02-11 10:17:28 +08:00
remove unused code from index.py
This commit is contained in:
@@ -1,13 +1,14 @@
|
||||
import datetime
|
||||
from datetime import datetime
|
||||
from typing import Any, List, Dict
|
||||
import logging
|
||||
import json
|
||||
import urllib
|
||||
from urllib import parse
|
||||
|
||||
from core.config import CoreConfig
|
||||
from titles.diva.config import DivaConfig
|
||||
from titles.diva.const import DivaConstants
|
||||
from titles.diva.database import DivaData
|
||||
from titles.diva.handlers import *
|
||||
|
||||
class DivaBase():
|
||||
def __init__(self, cfg: CoreConfig, game_cfg: DivaConfig) -> None:
|
||||
@@ -19,16 +20,16 @@ class DivaBase():
|
||||
self.game = DivaConstants.GAME_CODE
|
||||
self.version = DivaConstants.VER_PROJECT_DIVA_ARCADE_FUTURE_TONE
|
||||
|
||||
dt = datetime.datetime.now()
|
||||
self.time_lut=urllib.parse.quote(dt.strftime("%Y-%m-%d %H:%M:%S:16.0"))
|
||||
dt = datetime.now()
|
||||
self.time_lut=parse.quote(dt.strftime("%Y-%m-%d %H:%M:%S:16.0"))
|
||||
|
||||
def handle_test_request(self, data: Dict) -> Dict:
|
||||
def handle_test_request(self, data: bytes) -> str:
|
||||
return ""
|
||||
|
||||
def handle_game_init_request(self, data: Dict) -> Dict:
|
||||
def handle_game_init_request(self, data: bytes) -> str:
|
||||
return ( f'' )
|
||||
|
||||
def handle_attend_request(self, data: Dict) -> Dict:
|
||||
def handle_attend_request(self, data: bytes) -> str:
|
||||
encoded = "&"
|
||||
params = {
|
||||
'atnd_prm1': '0,1,1,0,0,0,1,0,100,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1',
|
||||
@@ -37,12 +38,12 @@ class DivaBase():
|
||||
'atnd_lut': f'{self.time_lut}',
|
||||
}
|
||||
|
||||
encoded += urllib.parse.urlencode(params)
|
||||
encoded += parse.urlencode(params)
|
||||
encoded = encoded.replace("%2C", ",")
|
||||
|
||||
return encoded
|
||||
|
||||
def handle_ping_request(self, data: Dict) -> Dict:
|
||||
def handle_ping_request(self, data: bytes) -> str:
|
||||
encoded = "&"
|
||||
params = {
|
||||
'ping_b_msg': f'Welcome to {self.core_cfg.server.name} network!',
|
||||
@@ -81,13 +82,13 @@ class DivaBase():
|
||||
'nblss_ltt_ed_tm': "2019-09-22 12:00:00.0",
|
||||
}
|
||||
|
||||
encoded += urllib.parse.urlencode(params)
|
||||
encoded += parse.urlencode(params)
|
||||
encoded = encoded.replace("+", "%20")
|
||||
encoded = encoded.replace("%2C", ",")
|
||||
|
||||
return encoded
|
||||
|
||||
def handle_pv_list_request(self, data: Dict) -> Dict:
|
||||
def handle_pv_list_request(self, data: bytes) -> str:
|
||||
pvlist = ""
|
||||
with open(r"titles/diva/data/PvList0.dat", encoding="utf-8") as shop:
|
||||
lines = shop.readlines()
|
||||
@@ -124,7 +125,7 @@ class DivaBase():
|
||||
|
||||
return ( response )
|
||||
|
||||
def handle_shop_catalog_request(self, data: Dict) -> Dict:
|
||||
def handle_shop_catalog_request(self, data: bytes) -> str:
|
||||
catalog = ""
|
||||
|
||||
shopList = self.data.static.get_enabled_shops(self.version)
|
||||
@@ -132,14 +133,14 @@ class DivaBase():
|
||||
with open(r"titles/diva/data/ShopCatalog.dat", encoding="utf-8") as shop:
|
||||
lines = shop.readlines()
|
||||
for line in lines:
|
||||
line = urllib.parse.quote(line) + ","
|
||||
catalog += f"{urllib.parse.quote(line)}"
|
||||
line = parse.quote(line) + ","
|
||||
catalog += f"{parse.quote(line)}"
|
||||
|
||||
else:
|
||||
for shop in shopList:
|
||||
line = str(shop["shopId"]) + "," + str(shop['unknown_0']) + "," + shop['name'] + "," + str(shop['points']) + "," + shop['start_date'] + "," + shop['end_date'] + "," + str(shop["type"])
|
||||
line = urllib.parse.quote(line) + ","
|
||||
catalog += f"{urllib.parse.quote(line)}"
|
||||
line = parse.quote(line) + ","
|
||||
catalog += f"{parse.quote(line)}"
|
||||
|
||||
catalog = catalog.replace("+", "%20")
|
||||
|
||||
@@ -148,7 +149,7 @@ class DivaBase():
|
||||
|
||||
return ( response )
|
||||
|
||||
def handle_buy_module_request(self, data: Dict) -> Dict:
|
||||
def handle_buy_module_request(self, data: bytes) -> str:
|
||||
profile = self.data.profile.get_profile(data["pd_id"], self.version)
|
||||
module = self.data.static.get_enabled_shop(self.version, int(data["mdl_id"]))
|
||||
|
||||
@@ -178,7 +179,7 @@ class DivaBase():
|
||||
|
||||
return response
|
||||
|
||||
def handle_cstmz_itm_ctlg_request(self, data: Dict) -> Dict:
|
||||
def handle_cstmz_itm_ctlg_request(self, data: bytes) -> str:
|
||||
catalog = ""
|
||||
|
||||
itemList = self.data.static.get_enabled_items(self.version)
|
||||
@@ -186,14 +187,14 @@ class DivaBase():
|
||||
with open(r"titles/diva/data/ItemCatalog.dat", encoding="utf-8") as item:
|
||||
lines = item.readlines()
|
||||
for line in lines:
|
||||
line = urllib.parse.quote(line) + ","
|
||||
catalog += f"{urllib.parse.quote(line)}"
|
||||
line = parse.quote(line) + ","
|
||||
catalog += f"{parse.quote(line)}"
|
||||
|
||||
else:
|
||||
for item in itemList:
|
||||
line = str(item["itemId"]) + "," + str(item['unknown_0']) + "," + item['name'] + "," + str(item['points']) + "," + item['start_date'] + "," + item['end_date'] + "," + str(item["type"])
|
||||
line = urllib.parse.quote(line) + ","
|
||||
catalog += f"{urllib.parse.quote(line)}"
|
||||
line = parse.quote(line) + ","
|
||||
catalog += f"{parse.quote(line)}"
|
||||
|
||||
catalog = catalog.replace("+", "%20")
|
||||
|
||||
@@ -202,7 +203,7 @@ class DivaBase():
|
||||
|
||||
return ( response )
|
||||
|
||||
def handle_buy_cstmz_itm_request(self, data: Dict) -> Dict:
|
||||
def handle_buy_cstmz_itm_request(self, data: bytes) -> str:
|
||||
profile = self.data.profile.get_profile(data["pd_id"], self.version)
|
||||
item = self.data.static.get_enabled_item(self.version, int(data["cstmz_itm_id"]))
|
||||
|
||||
@@ -234,7 +235,7 @@ class DivaBase():
|
||||
|
||||
return response
|
||||
|
||||
def handle_festa_info_request(self, data: Dict) -> Dict:
|
||||
def handle_festa_info_request(self, data: bytes) -> str:
|
||||
encoded = "&"
|
||||
params = {
|
||||
'fi_id': '1,-1',
|
||||
@@ -250,13 +251,13 @@ class DivaBase():
|
||||
'fi_lut': '{self.time_lut}',
|
||||
}
|
||||
|
||||
encoded += urllib.parse.urlencode(params)
|
||||
encoded += parse.urlencode(params)
|
||||
encoded = encoded.replace("+", "%20")
|
||||
encoded = encoded.replace("%2C", ",")
|
||||
|
||||
return encoded
|
||||
|
||||
def handle_contest_info_request(self, data: Dict) -> Dict:
|
||||
def handle_contest_info_request(self, data: bytes) -> str:
|
||||
response = ""
|
||||
|
||||
response += f"&ci_lut={self.time_lut}"
|
||||
@@ -264,7 +265,7 @@ class DivaBase():
|
||||
|
||||
return ( response )
|
||||
|
||||
def handle_qst_inf_request(self, data: Dict) -> Dict:
|
||||
def handle_qst_inf_request(self, data: bytes) -> str:
|
||||
quest = ""
|
||||
|
||||
questList = self.data.static.get_enabled_quests(self.version)
|
||||
@@ -272,7 +273,7 @@ class DivaBase():
|
||||
with open(r"titles/diva/data/QuestInfo.dat", encoding="utf-8") as shop:
|
||||
lines = shop.readlines()
|
||||
for line in lines:
|
||||
quest += f"{urllib.parse.quote(line)},"
|
||||
quest += f"{parse.quote(line)},"
|
||||
|
||||
response = ""
|
||||
response += f"&qi_lut={self.time_lut}"
|
||||
@@ -280,7 +281,7 @@ class DivaBase():
|
||||
else:
|
||||
for quests in questList:
|
||||
line = str(quests["questId"]) + "," + str(quests['quest_order']) + "," + str(quests['kind']) + "," + str(quests['unknown_0']) + "," + quests['start_datetime'] + "," + quests['end_datetime'] + "," + quests["name"] + "," + str(quests["unknown_1"]) + "," + str(quests["unknown_2"]) + "," + str(quests["quest_enable"])
|
||||
quest += f"{urllib.parse.quote(line)}%0A,"
|
||||
quest += f"{parse.quote(line)}%0A,"
|
||||
|
||||
responseline = f"{quest[:-1]},"
|
||||
for i in range(len(questList),59):
|
||||
@@ -294,88 +295,71 @@ class DivaBase():
|
||||
|
||||
return ( response )
|
||||
|
||||
def handle_nv_ranking_request(self, data: Dict) -> Dict:
|
||||
def handle_nv_ranking_request(self, data: bytes) -> str:
|
||||
return ( f'' )
|
||||
|
||||
def handle_ps_ranking_request(self, data: Dict) -> Dict:
|
||||
def handle_ps_ranking_request(self, data: bytes) -> str:
|
||||
return ( f'' )
|
||||
|
||||
def handle_ng_word_request(self, data: Dict) -> Dict:
|
||||
def handle_ng_word_request(self, data: bytes) -> str:
|
||||
return ( f'' )
|
||||
|
||||
def handle_rmt_wp_list_request(self, data: Dict) -> Dict:
|
||||
def handle_rmt_wp_list_request(self, data: bytes) -> str:
|
||||
return ( f'' )
|
||||
|
||||
def handle_pv_def_chr_list_request(self, data: Dict) -> Dict:
|
||||
def handle_pv_def_chr_list_request(self, data: bytes) -> str:
|
||||
return ( f'' )
|
||||
|
||||
def handle_pv_ng_mdl_list_request(self, data: Dict) -> Dict:
|
||||
def handle_pv_ng_mdl_list_request(self, data: bytes) -> str:
|
||||
return ( f'' )
|
||||
|
||||
def handle_cstmz_itm_ng_mdl_lst_request(self, data: Dict) -> Dict:
|
||||
def handle_cstmz_itm_ng_mdl_lst_request(self, data: bytes) -> str:
|
||||
return ( f'' )
|
||||
|
||||
def handle_banner_info_request(self, data: Dict) -> Dict:
|
||||
def handle_banner_info_request(self, data: bytes) -> str:
|
||||
return ( f'' )
|
||||
|
||||
def handle_banner_data_request(self, data: Dict) -> Dict:
|
||||
def handle_banner_data_request(self, data: bytes) -> str:
|
||||
return ( f'' )
|
||||
|
||||
def handle_cm_ply_info_request(self, data: Dict) -> Dict:
|
||||
def handle_cm_ply_info_request(self, data: bytes) -> str:
|
||||
return ( f'' )
|
||||
|
||||
def handle_pstd_h_ctrl_request(self, data: Dict) -> Dict:
|
||||
def handle_pstd_h_ctrl_request(self, data: bytes) -> str:
|
||||
return ( f'' )
|
||||
|
||||
def handle_pstd_item_ng_lst_request(self, data: Dict) -> Dict:
|
||||
def handle_pstd_item_ng_lst_request(self, data: bytes) -> str:
|
||||
return ( f'' )
|
||||
|
||||
def handle_pre_start_request(self, data: Dict) -> str:
|
||||
profile = self.data.profile.get_profile(data["aime_id"], self.version)
|
||||
profile_shop = self.data.item.get_shop(data["aime_id"], self.version)
|
||||
def handle_pre_start_request(self, data: bytes) -> str:
|
||||
req = PreStartRequest(data)
|
||||
resp = PreStartResponse(req.cmd, req.req_id, req.aime_id)
|
||||
profile = self.data.profile.get_profile(req.aime_id, self.version)
|
||||
profile_shop = self.data.item.get_shop(req.aime_id, self.version)
|
||||
|
||||
if profile is None:
|
||||
return f"&ps_result=-3"
|
||||
else:
|
||||
response = "&ps_result=1"
|
||||
response += "&accept_idx=100"
|
||||
response += "&nblss_ltt_stts=-1"
|
||||
response += "&nblss_ltt_tckt=-1"
|
||||
response += "&nblss_ltt_is_opn=-1"
|
||||
response += f"&pd_id={data['aime_id']}"
|
||||
response += f"&player_name={profile['player_name']}"
|
||||
response += f"&sort_kind={profile['player_name']}"
|
||||
response += f"&lv_efct_id={profile['lv_efct_id']}"
|
||||
response += f"&lv_plt_id={profile['lv_plt_id']}"
|
||||
response += f"&lv_str={profile['lv_str']}"
|
||||
response += f"&lv_num={profile['lv_num']}"
|
||||
response += f"&lv_pnt={profile['lv_pnt']}"
|
||||
response += f"&vcld_pts={profile['vcld_pts']}"
|
||||
response += f"&skn_eqp={profile['use_pv_skn_eqp']}"
|
||||
response += f"&btn_se_eqp={profile['use_pv_btn_se_eqp']}"
|
||||
response += f"&sld_se_eqp={profile['use_pv_sld_se_eqp']}"
|
||||
response += f"&chn_sld_se_eqp={profile['use_pv_chn_sld_se_eqp']}"
|
||||
response += f"&sldr_tch_se_eqp={profile['use_pv_sldr_tch_se_eqp']}"
|
||||
response += f"&passwd_stat={profile['passwd_stat']}"
|
||||
resp.ps_result = -3
|
||||
return resp.make()
|
||||
|
||||
# Store stuff to add to rework
|
||||
response += f"&mdl_eqp_tm={self.time_lut}"
|
||||
profile_dict = profile._asdict()
|
||||
profile_dict.pop("id")
|
||||
profile_dict.pop("user")
|
||||
profile_dict.pop("version")
|
||||
|
||||
mdl_eqp_ary = "-999,-999,-999"
|
||||
for k, v in profile_dict.items():
|
||||
if hasattr(resp, k):
|
||||
setattr(resp, k, v)
|
||||
|
||||
if profile_shop is not None and profile_shop:
|
||||
resp.mdl_eqp_ary = profile_shop["mdl_eqp_ary"]
|
||||
|
||||
return resp.make()
|
||||
|
||||
# get the common_modules from the profile shop
|
||||
if profile_shop:
|
||||
mdl_eqp_ary = profile_shop["mdl_eqp_ary"]
|
||||
|
||||
response += f"&mdl_eqp_ary={mdl_eqp_ary}"
|
||||
|
||||
return response
|
||||
|
||||
def handle_registration_request(self, data: Dict) -> Dict:
|
||||
def handle_registration_request(self, data: bytes) -> str:
|
||||
self.data.profile.create_profile(self.version, data["aime_id"], data["player_name"])
|
||||
return (f"&cd_adm_result=1&pd_id={data['aime_id']}")
|
||||
|
||||
def handle_start_request(self, data: Dict) -> Dict:
|
||||
def handle_start_request(self, data: bytes) -> str:
|
||||
profile = self.data.profile.get_profile(data["pd_id"], self.version)
|
||||
profile_shop = self.data.item.get_shop(data["pd_id"], self.version)
|
||||
if profile is None:
|
||||
@@ -455,10 +439,10 @@ class DivaBase():
|
||||
|
||||
return ( response )
|
||||
|
||||
def handle_pd_unlock_request(self, data: Dict) -> Dict:
|
||||
def handle_pd_unlock_request(self, data: bytes) -> str:
|
||||
return ( f'' )
|
||||
|
||||
def handle_spend_credit_request(self, data: Dict) -> Dict:
|
||||
def handle_spend_credit_request(self, data: bytes) -> str:
|
||||
profile = self.data.profile.get_profile(data["pd_id"], self.version)
|
||||
if profile is None: return
|
||||
|
||||
@@ -529,7 +513,7 @@ class DivaBase():
|
||||
|
||||
return pv_result
|
||||
|
||||
def handle_get_pv_pd_request(self, data: Dict) -> Dict:
|
||||
def handle_get_pv_pd_request(self, data: bytes) -> str:
|
||||
song_id = data["pd_pv_id_lst"].split(",")
|
||||
pv = ""
|
||||
|
||||
@@ -555,9 +539,9 @@ class DivaBase():
|
||||
|
||||
self.logger.debug(f"pv_result = {pv_result}")
|
||||
|
||||
pv += urllib.parse.quote(pv_result)
|
||||
pv += parse.quote(pv_result)
|
||||
else:
|
||||
pv += urllib.parse.quote(f"{song}***")
|
||||
pv += parse.quote(f"{song}***")
|
||||
pv += ","
|
||||
|
||||
response = ""
|
||||
@@ -567,10 +551,10 @@ class DivaBase():
|
||||
|
||||
return ( response )
|
||||
|
||||
def handle_stage_start_request(self, data: Dict) -> Dict:
|
||||
def handle_stage_start_request(self, data: bytes) -> str:
|
||||
return ( f'' )
|
||||
|
||||
def handle_stage_result_request(self, data: Dict) -> Dict:
|
||||
def handle_stage_result_request(self, data: bytes) -> str:
|
||||
|
||||
profile = self.data.profile.get_profile(data["pd_id"], self.version)
|
||||
|
||||
@@ -665,7 +649,7 @@ class DivaBase():
|
||||
|
||||
return ( response )
|
||||
|
||||
def handle_end_request(self, data: Dict) -> Dict:
|
||||
def handle_end_request(self, data: bytes) -> str:
|
||||
profile = self.data.profile.get_profile(data["pd_id"], self.version)
|
||||
|
||||
self.data.profile.update_profile(
|
||||
@@ -675,7 +659,7 @@ class DivaBase():
|
||||
)
|
||||
return (f'')
|
||||
|
||||
def handle_shop_exit_request(self, data: Dict) -> Dict:
|
||||
def handle_shop_exit_request(self, data: bytes) -> str:
|
||||
self.data.item.put_shop(data["pd_id"], self.version, data["mdl_eqp_cmn_ary"], data["c_itm_eqp_cmn_ary"], data["ms_itm_flg_cmn_ary"])
|
||||
if int(data["use_pv_mdl_eqp"]) == 1:
|
||||
self.data.pv_customize.put_pv_customize(data["pd_id"], self.version, data["ply_pv_id"],
|
||||
|
||||
Reference in New Issue
Block a user