artemis/titles/cxb/rev.py

313 lines
11 KiB
Python
Raw Permalink Normal View History

import json
from decimal import Decimal
from base64 import b64encode
from typing import Any, Dict
from hashlib import md5
from datetime import datetime
from core.config import CoreConfig
from core.data import Data, cached
from .config import CxbConfig
from .base import CxbBase
from .const import CxbConstants
2023-03-09 16:38:58 +00:00
class CxbRev(CxbBase):
def __init__(self, cfg: CoreConfig, game_cfg: CxbConfig) -> None:
super().__init__(cfg, game_cfg)
self.version = CxbConstants.VER_CROSSBEATS_REV
2023-03-09 16:38:58 +00:00
2024-01-09 08:07:04 +00:00
async def handle_data_path_list_request(self, data: Dict) -> Dict:
2023-03-09 16:38:58 +00:00
return {"data": ""}
2024-01-09 08:07:04 +00:00
async def handle_data_putlog_request(self, data: Dict) -> Dict:
if data["putlog"]["type"] == "ResultLog":
score_data = json.loads(data["putlog"]["data"])
2023-03-09 16:38:58 +00:00
userid = score_data["usid"]
2024-01-09 19:42:17 +00:00
await self.data.score.put_playlog(
2023-03-09 16:38:58 +00:00
userid,
score_data["mcode"],
score_data["difficulty"],
score_data["score"],
int(Decimal(score_data["clearrate"]) * 100),
score_data["flawless"],
score_data["super"],
score_data["cool"],
score_data["fast"],
score_data["fast2"],
score_data["slow"],
score_data["slow2"],
score_data["fail"],
score_data["combo"],
2024-05-29 02:32:38 +00:00
score_data["grade"],
2023-03-09 16:38:58 +00:00
)
return {"data": True}
return {"data": True}
2023-03-09 16:38:58 +00:00
@cached(lifetime=86400)
2024-01-09 08:07:04 +00:00
async def handle_data_music_list_request(self, data: Dict) -> Dict:
ret_str = ""
2024-02-26 23:35:34 +00:00
with open(r"titles/cxb/data/rev/MusicArchiveList.csv") as music:
lines = music.readlines()
for line in lines:
2023-03-09 16:38:58 +00:00
line_split = line.split(",")
ret_str += f"{line_split[0]},{line_split[1]},{line_split[2]},{line_split[3]},{line_split[4]},{line_split[5]},{line_split[6]},{line_split[7]},{line_split[8]},{line_split[9]},{line_split[10]},{line_split[11]},{line_split[12]},{line_split[13]},{line_split[14]},\r\n"
2023-03-09 16:38:58 +00:00
return {"data": ret_str}
@cached(lifetime=86400)
2024-01-09 08:07:04 +00:00
async def handle_data_item_list_icon_request(self, data: Dict) -> Dict:
ret_str = "\r\n#ItemListIcon\r\n"
2023-03-09 16:38:58 +00:00
with open(
2024-02-26 23:35:34 +00:00
r"titles/cxb/data/rev/Item/ItemArchiveList_Icon.csv", encoding="shift-jis"
2023-03-09 16:38:58 +00:00
) as item:
lines = item.readlines()
for line in lines:
ret_str += f"{line[:-1]}\r\n"
2023-03-09 16:38:58 +00:00
return {"data": ret_str}
2023-03-09 16:38:58 +00:00
@cached(lifetime=86400)
2024-01-09 08:07:04 +00:00
async def handle_data_item_list_skin_notes_request(self, data: Dict) -> Dict:
ret_str = "\r\n#ItemListSkinNotes\r\n"
2023-03-09 16:38:58 +00:00
with open(
2024-02-26 23:35:34 +00:00
r"titles/cxb/data/rev/Item/ItemArchiveList_SkinNotes.csv", encoding="utf-8"
2023-03-09 16:38:58 +00:00
) as item:
lines = item.readlines()
for line in lines:
ret_str += f"{line[:-1]}\r\n"
2023-03-09 16:38:58 +00:00
return {"data": ret_str}
2023-03-09 16:38:58 +00:00
@cached(lifetime=86400)
2024-01-09 08:07:04 +00:00
async def handle_data_item_list_skin_effect_request(self, data: Dict) -> Dict:
ret_str = "\r\n#ItemListSkinEffect\r\n"
2023-03-09 16:38:58 +00:00
with open(
2024-02-26 23:35:34 +00:00
r"titles/cxb/data/rev/Item/ItemArchiveList_SkinEffect.csv", encoding="utf-8"
2023-03-09 16:38:58 +00:00
) as item:
lines = item.readlines()
for line in lines:
ret_str += f"{line[:-1]}\r\n"
2023-03-09 16:38:58 +00:00
return {"data": ret_str}
2023-03-09 16:38:58 +00:00
@cached(lifetime=86400)
2024-01-09 08:07:04 +00:00
async def handle_data_item_list_skin_bg_request(self, data: Dict) -> Dict:
ret_str = "\r\n#ItemListSkinBg\r\n"
2023-03-09 16:38:58 +00:00
with open(
2024-02-26 23:35:34 +00:00
r"titles/cxb/data/rev/Item/ItemArchiveList_SkinBg.csv", encoding="utf-8"
2023-03-09 16:38:58 +00:00
) as item:
lines = item.readlines()
for line in lines:
ret_str += f"{line[:-1]}\r\n"
2023-03-09 16:38:58 +00:00
return {"data": ret_str}
2023-03-09 16:38:58 +00:00
@cached(lifetime=86400)
2024-01-09 08:07:04 +00:00
async def handle_data_item_list_title_request(self, data: Dict) -> Dict:
ret_str = "\r\n#ItemListTitle\r\n"
2023-03-09 16:38:58 +00:00
with open(
2024-02-26 23:35:34 +00:00
r"titles/cxb/data/rev/Item/ItemList_Title.csv", encoding="shift-jis"
2023-03-09 16:38:58 +00:00
) as item:
lines = item.readlines()
for line in lines:
ret_str += f"{line[:-1]}\r\n"
2023-03-09 16:38:58 +00:00
return {"data": ret_str}
2023-03-09 16:38:58 +00:00
@cached(lifetime=86400)
2024-01-09 08:07:04 +00:00
async def handle_data_shop_list_music_request(self, data: Dict) -> Dict:
ret_str = "\r\n#ShopListMusic\r\n"
2023-03-09 16:38:58 +00:00
with open(
2024-02-26 23:35:34 +00:00
r"titles/cxb/data/rev/Shop/ShopList_Music.csv", encoding="shift-jis"
2023-03-09 16:38:58 +00:00
) as shop:
lines = shop.readlines()
for line in lines:
ret_str += f"{line[:-1]}\r\n"
2023-03-09 16:38:58 +00:00
return {"data": ret_str}
2023-03-09 16:38:58 +00:00
@cached(lifetime=86400)
2024-01-09 08:07:04 +00:00
async def handle_data_shop_list_icon_request(self, data: Dict) -> Dict:
ret_str = "\r\n#ShopListIcon\r\n"
2023-03-09 16:38:58 +00:00
with open(
2024-02-26 23:35:34 +00:00
r"titles/cxb/data/rev/Shop/ShopList_Icon.csv", encoding="shift-jis"
2023-03-09 16:38:58 +00:00
) as shop:
lines = shop.readlines()
for line in lines:
ret_str += f"{line[:-1]}\r\n"
2023-03-09 16:38:58 +00:00
return {"data": ret_str}
2023-03-09 16:38:58 +00:00
@cached(lifetime=86400)
2024-01-09 08:07:04 +00:00
async def handle_data_shop_list_title_request(self, data: Dict) -> Dict:
ret_str = "\r\n#ShopListTitle\r\n"
2023-03-09 16:38:58 +00:00
with open(
2024-02-26 23:35:34 +00:00
r"titles/cxb/data/rev/Shop/ShopList_Title.csv", encoding="shift-jis"
2023-03-09 16:38:58 +00:00
) as shop:
lines = shop.readlines()
for line in lines:
ret_str += f"{line[:-1]}\r\n"
2023-03-09 16:38:58 +00:00
return {"data": ret_str}
2024-01-09 08:07:04 +00:00
async def handle_data_shop_list_skin_hud_request(self, data: Dict) -> Dict:
2023-03-09 16:38:58 +00:00
return {"data": ""}
2024-01-09 08:07:04 +00:00
async def handle_data_shop_list_skin_arrow_request(self, data: Dict) -> Dict:
2023-03-09 16:38:58 +00:00
return {"data": ""}
2024-01-09 08:07:04 +00:00
async def handle_data_shop_list_skin_hit_request(self, data: Dict) -> Dict:
2023-03-09 16:38:58 +00:00
return {"data": ""}
2023-03-09 16:38:58 +00:00
@cached(lifetime=86400)
2024-01-09 08:07:04 +00:00
async def handle_data_shop_list_sale_request(self, data: Dict) -> Dict:
ret_str = "\r\n#ShopListSale\r\n"
2023-03-09 16:38:58 +00:00
with open(
2024-02-26 23:35:34 +00:00
r"titles/cxb/data/rev/Shop/ShopList_Sale.csv", encoding="shift-jis"
2023-03-09 16:38:58 +00:00
) as shop:
lines = shop.readlines()
for line in lines:
ret_str += f"{line[:-1]}\r\n"
2023-03-09 16:38:58 +00:00
return {"data": ret_str}
2024-01-09 08:07:04 +00:00
async def handle_data_extra_stage_list_request(self, data: Dict) -> Dict:
2024-02-26 23:35:34 +00:00
ret_str = ""
with open(r"titles/cxb/data/rev/ExtraStageList.csv", encoding="shift-jis") as stage:
lines = stage.readlines()
for line in lines:
ret_str += f"{line[:-1]}\r\n"
return {"data": ret_str}
2023-03-09 16:38:58 +00:00
@cached(lifetime=86400)
2024-01-09 08:07:04 +00:00
async def handle_data_exxxxx_request(self, data: Dict) -> Dict:
extra_num = int(data["dldate"]["filetype"][-4:])
ret_str = ""
2023-03-09 16:38:58 +00:00
with open(
2024-02-26 23:35:34 +00:00
rf"titles/cxb/data/rev/Ex000{extra_num}.csv", encoding="shift-jis"
2023-03-09 16:38:58 +00:00
) as stage:
lines = stage.readlines()
for line in lines:
ret_str += f"{line[:-1]}\r\n"
2023-03-09 16:38:58 +00:00
return {"data": ret_str}
2024-01-09 08:07:04 +00:00
async def handle_data_bonus_list10100_request(self, data: Dict) -> Dict:
2023-03-09 16:38:58 +00:00
return {"data": ""}
2024-01-09 08:07:04 +00:00
async def handle_data_free_coupon_request(self, data: Dict) -> Dict:
2023-03-09 16:38:58 +00:00
return {"data": ""}
2023-03-09 16:38:58 +00:00
@cached(lifetime=86400)
2024-01-09 08:07:04 +00:00
async def handle_data_news_list_request(self, data: Dict) -> Dict:
ret_str = ""
2024-02-26 23:35:34 +00:00
with open(r"titles/cxb/data/rev/NewsList.csv", encoding="UTF-8") as news:
lines = news.readlines()
for line in lines:
ret_str += f"{line[:-1]}\r\n"
2023-03-09 16:38:58 +00:00
return {"data": ret_str}
2024-01-09 08:07:04 +00:00
async def handle_data_tips_request(self, data: Dict) -> Dict:
2023-03-09 16:38:58 +00:00
return {"data": ""}
@cached(lifetime=86400)
2024-01-09 08:07:04 +00:00
async def handle_data_license_request(self, data: Dict) -> Dict:
ret_str = ""
2024-02-26 23:35:34 +00:00
with open(r"titles/cxb/data/rev/License_Offline.csv", encoding="UTF-8") as lic:
lines = lic.readlines()
for line in lines:
ret_str += f"{line[:-1]}\r\n"
2023-03-09 16:38:58 +00:00
return {"data": ret_str}
2023-03-09 16:38:58 +00:00
@cached(lifetime=86400)
2024-01-09 08:07:04 +00:00
async def handle_data_course_list_request(self, data: Dict) -> Dict:
ret_str = ""
2023-03-09 16:38:58 +00:00
with open(
2024-02-26 23:35:34 +00:00
r"titles/cxb/data/rev/Course/CourseList.csv", encoding="UTF-8"
2023-03-09 16:38:58 +00:00
) as course:
lines = course.readlines()
for line in lines:
ret_str += f"{line[:-1]}\r\n"
2023-03-09 16:38:58 +00:00
return {"data": ret_str}
2023-03-09 16:38:58 +00:00
@cached(lifetime=86400)
2024-01-09 08:07:04 +00:00
async def handle_data_csxxxx_request(self, data: Dict) -> Dict:
# Removed the CSVs since the format isnt quite right
extra_num = int(data["dldate"]["filetype"][-4:])
ret_str = ""
2023-03-09 16:38:58 +00:00
with open(
2024-02-26 23:35:34 +00:00
rf"titles/cxb/data/rev/Course/Cs000{extra_num}.csv", encoding="shift-jis"
2023-03-09 16:38:58 +00:00
) as course:
lines = course.readlines()
for line in lines:
ret_str += f"{line[:-1]}\r\n"
2023-03-09 16:38:58 +00:00
return {"data": ret_str}
2023-03-09 16:38:58 +00:00
@cached(lifetime=86400)
2024-01-09 08:07:04 +00:00
async def handle_data_mission_list_request(self, data: Dict) -> Dict:
ret_str = ""
2023-03-09 16:38:58 +00:00
with open(
2024-02-26 23:35:34 +00:00
r"titles/cxb/data/rev/MissionList.csv", encoding="shift-jis"
2023-03-09 16:38:58 +00:00
) as mission:
lines = mission.readlines()
for line in lines:
ret_str += f"{line[:-1]}\r\n"
2023-03-09 16:38:58 +00:00
return {"data": ret_str}
2024-01-09 08:07:04 +00:00
async def handle_data_mission_bonus_request(self, data: Dict) -> Dict:
2023-03-09 16:38:58 +00:00
return {"data": ""}
2024-01-09 08:07:04 +00:00
async def handle_data_unlimited_mission_request(self, data: Dict) -> Dict:
2023-03-09 16:38:58 +00:00
return {"data": ""}
2023-03-09 16:38:58 +00:00
@cached(lifetime=86400)
2024-01-09 08:07:04 +00:00
async def handle_data_event_list_request(self, data: Dict) -> Dict:
ret_str = ""
2023-03-09 16:38:58 +00:00
with open(
2024-02-26 23:35:34 +00:00
r"titles/cxb/data/rev/Event/EventArchiveList.csv", encoding="shift-jis"
2023-03-09 16:38:58 +00:00
) as mission:
lines = mission.readlines()
for line in lines:
ret_str += f"{line[:-1]}\r\n"
2023-03-09 16:38:58 +00:00
return {"data": ret_str}
2024-01-09 08:07:04 +00:00
async def handle_data_event_music_list_request(self, data: Dict) -> Dict:
2023-03-09 16:38:58 +00:00
return {"data": ""}
2024-01-09 08:07:04 +00:00
async def handle_data_event_mission_list_request(self, data: Dict) -> Dict:
2023-03-09 16:38:58 +00:00
return {"data": ""}
2024-01-09 08:07:04 +00:00
async def handle_data_event_achievement_single_high_score_list_request(
2023-03-09 16:38:58 +00:00
self, data: Dict
) -> Dict:
return {"data": ""}
2024-01-09 08:07:04 +00:00
async def handle_data_event_achievement_single_accumulation_request(
2023-03-09 16:38:58 +00:00
self, data: Dict
) -> Dict:
return {"data": ""}
2024-01-09 08:07:04 +00:00
async def handle_data_event_ranking_high_score_list_request(self, data: Dict) -> Dict:
2023-03-09 16:38:58 +00:00
return {"data": ""}
2024-01-09 08:07:04 +00:00
async def handle_data_event_ranking_accumulation_list_request(self, data: Dict) -> Dict:
2023-03-09 16:38:58 +00:00
return {"data": ""}
2024-01-09 08:07:04 +00:00
async def handle_data_event_ranking_stamp_list_request(self, data: Dict) -> Dict:
2023-03-09 16:38:58 +00:00
return {"data": ""}
2024-01-09 08:07:04 +00:00
async def handle_data_event_ranking_store_list_request(self, data: Dict) -> Dict:
2023-03-09 16:38:58 +00:00
return {"data": ""}
2024-01-09 08:07:04 +00:00
async def handle_data_event_ranking_area_list_request(self, data: Dict) -> Dict:
2023-03-09 16:38:58 +00:00
return {"data": ""}
2023-03-09 16:38:58 +00:00
@cached(lifetime=86400)
2024-01-09 08:07:04 +00:00
async def handle_data_event_stamp_list_request(self, data: Dict) -> Dict:
ret_str = ""
2023-03-09 16:38:58 +00:00
with open(
2024-02-26 23:35:34 +00:00
r"titles/cxb/data/rev/Event/EventStampList.csv", encoding="shift-jis"
2023-03-09 16:38:58 +00:00
) as event:
lines = event.readlines()
for line in lines:
ret_str += f"{line[:-1]}\r\n"
2023-03-09 16:38:58 +00:00
return {"data": ret_str}
2024-01-09 08:07:04 +00:00
async def handle_data_event_stamp_map_list_csxxxx_request(self, data: Dict) -> Dict:
2023-03-09 16:38:58 +00:00
return {"data": "1,2,1,1,2,3,9,5,6,7,8,9,10,\r\n"}
2024-01-09 08:07:04 +00:00
async def handle_data_server_state_request(self, data: Dict) -> Dict:
2023-03-09 16:38:58 +00:00
return {"data": True}