diff --git a/core/title.py b/core/title.py index 6d83f46..8387065 100644 --- a/core/title.py +++ b/core/title.py @@ -1,4 +1,4 @@ -from twisted.web import resource +from typing import Dict, Any import logging, coloredlogs from logging.handlers import TimedRotatingFileHandler from twisted.web.http import Request @@ -13,6 +13,7 @@ class TitleServlet(): self.config = core_cfg self.config_folder = cfg_folder self.data = Data(core_cfg) + self.title_registry: Dict[str, Any] = {} self.logger = logging.getLogger("title") if not hasattr(self.logger, "initialized"): @@ -34,9 +35,32 @@ class TitleServlet(): if "game_registry" not in globals(): globals()["game_registry"] = Utils.get_all_titles() + + for folder, mod in globals()["game_registry"].items(): + if hasattr(mod, "game_codes") and hasattr(mod, "index"): + handler_cls = mod.index(self.config, self.config_folder) + if hasattr(handler_cls, "setup"): + handler_cls.setup() + + for code in mod.game_codes: + self.title_registry[code] = handler_cls + + else: + self.logger.error(f"{folder} missing game_code or index in __init__.py") + + self.logger.info(f"Serving {len(globals()['game_registry'])} game codes") + + def render_GET(self, request: Request, endpoints: dict) -> bytes: + print(endpoints) - def handle_GET(self, request: Request): - pass - - def handle_POST(self, request: Request): - pass \ No newline at end of file + def render_POST(self, request: Request, endpoints: dict) -> bytes: + print(endpoints) + code = endpoints["game"] + if code not in self.title_registry: + self.logger.warn(f"Unknown game code {code}") + + index = self.title_registry[code] + if not hasattr(index, "render_POST"): + self.logger.warn(f"{code} does not dispatch on POST") + + return index.render_POST(request, endpoints["version"], endpoints["endpoint"]) diff --git a/core/utils.py b/core/utils.py index bdb856d..a14f9ff 100644 --- a/core/utils.py +++ b/core/utils.py @@ -18,4 +18,5 @@ class Utils: except ImportError as e: print(f"{dir} - {e}") + raise return ret diff --git a/dbutils.py b/dbutils.py index b70b351..8e6024b 100644 --- a/dbutils.py +++ b/dbutils.py @@ -1,6 +1,47 @@ +import yaml import argparse +from core.config import CoreConfig +from core.data import Data -if __name__ == "__main__": - parser = argparse.ArgumentParser(description="ARTEMiS main entry point") - parser.add_argument("--config", "-c", type=str, default="config", help="Configuration folder") - args = parser.parse_args() \ No newline at end of file +if __name__=='__main__': + parser = argparse.ArgumentParser(description="Database utilities") + parser.add_argument("--config", "-c", type=str, help="Config folder to use", default="config") + parser.add_argument("--version", "-v", type=str, help="Version of the database to upgrade/rollback to") + parser.add_argument("--game", "-g", type=str, help="Game code of the game who's schema will be updated/rolled back. Ex. SDFE") + parser.add_argument("action", type=str, help="DB Action, create, recreate, upgrade, or rollback") + args = parser.parse_args() + + cfg = CoreConfig() + cfg.update(yaml.safe_load(open(f"{args.config}/core.yaml"))) + data = Data(cfg) + + if args.action == "create": + data.create_database() + + elif args.action == "recreate": + data.recreate_database() + + elif args.action == "upgrade" or args.action == "rollback": + if args.version is None: + print("Must set game and version to migrate to") + exit(0) + + if args.game is None: + print("No game set, upgrading core schema") + data.migrate_database("CORE", int(args.version)) + + else: + data.migrate_database(args.game, int(args.version), args.action) + + elif args.action == "migrate": + print("Migrating from old schema to new schema") + data.restore_from_old_schema() + + elif args.action == "dump": + print("Dumping old schema to migrate to new schema") + data.dump_db() + + elif args.action == "generate": + pass + + data.logger.info("Done") diff --git a/example_config/chuni.yaml b/example_config/chuni.yaml new file mode 100644 index 0000000..3794f06 --- /dev/null +++ b/example_config/chuni.yaml @@ -0,0 +1,6 @@ +server: + enable: True + loglevel: "info" + +crypto: + encrypted_only: False \ No newline at end of file diff --git a/example_config/cxb.yaml b/example_config/cxb.yaml new file mode 100644 index 0000000..08948bd --- /dev/null +++ b/example_config/cxb.yaml @@ -0,0 +1,9 @@ +server: + enable: True + loglevel: "info" + hostname: "localhost" + ssl_enable: False + port: 8082 + port_secure: 443 + ssl_cert: "cert/title.crt" + ssl_key: "cert/title.key" diff --git a/example_config/diva.yaml b/example_config/diva.yaml new file mode 100644 index 0000000..1354910 --- /dev/null +++ b/example_config/diva.yaml @@ -0,0 +1,4 @@ +server: + enable: True + loglevel: "info" + diff --git a/example_config/mai2.yaml b/example_config/mai2.yaml new file mode 100644 index 0000000..a04dda5 --- /dev/null +++ b/example_config/mai2.yaml @@ -0,0 +1,3 @@ +server: + enable: True + loglevel: "info" diff --git a/example_config/nginx_example.conf b/example_config/nginx_example.conf new file mode 100644 index 0000000..3b8bf3c --- /dev/null +++ b/example_config/nginx_example.conf @@ -0,0 +1,60 @@ +# Allnet +server { + listen 80; + server_name naominet.jp; + + location / { + proxy_pass http://localhost:8000/; + } +} + +# Non-SSL titles +server { + listen 80; + server_name your.hostname.here; + + location / { + proxy_pass http://localhost:8080/; + } +} + +# SSL titles +server { + listen 443 ssl default_server; + listen [::]:443 ssl default_server; + server_name your.hostname.here; + + ssl_certificate /path/to/cert/title.crt; + ssl_certificate_key /path/to/cert/title.key; + ssl_session_timeout 1d; + ssl_session_cache shared:MozSSL:10m; + ssl_session_tickets off; + + ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; + ssl_ciphers "ALL:@SECLEVEL=0"; + ssl_prefer_server_ciphers off; + + location / { + proxy_pass http://localhost:8080/; + } +} + +# Billing +server { + listen 8443 ssl; + server_name ib.naominet.jp; + + ssl_certificate /path/to/cert/server.pem; + ssl_certificate_key /path/to/cert/server.key; + ssl_session_timeout 1d; + ssl_session_cache shared:MozSSL:10m; + ssl_session_tickets off; + + ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; + ssl_ciphers "ALL:@SECLEVEL=1"; + ssl_prefer_server_ciphers off; + + location / { + proxy_pass http://localhost:8444/; + } +} \ No newline at end of file diff --git a/example_config/ongeki.yaml b/example_config/ongeki.yaml new file mode 100644 index 0000000..a04dda5 --- /dev/null +++ b/example_config/ongeki.yaml @@ -0,0 +1,3 @@ +server: + enable: True + loglevel: "info" diff --git a/example_config/wacca.yaml b/example_config/wacca.yaml new file mode 100644 index 0000000..4c898a4 --- /dev/null +++ b/example_config/wacca.yaml @@ -0,0 +1,32 @@ +server: + enable: True + loglevel: "info" + +mods: + always_vip: True + infinite_tickets: True + infinite_wp: True + +gates: + enabled_gates: + - 1 + - 2 + - 3 + - 4 + - 5 + - 6 + - 7 + - 8 + - 9 + - 10 + - 11 + - 12 + - 13 + - 14 + - 15 + - 16 + - 17 + - 18 + - 19 + - 21 + - 22 diff --git a/index.py b/index.py index ad712b5..8b8ee86 100644 --- a/index.py +++ b/index.py @@ -4,10 +4,83 @@ import yaml from os import path, mkdir, access, W_OK from core import * -from twisted.web import server +from twisted.web import server, resource from twisted.internet import reactor, endpoints -from txroutes import Dispatcher +from twisted.web.http import Request +from routes import Mapper +class HttpDispatcher(resource.Resource): + def __init__(self, cfg: CoreConfig, config_dir: str): + super().__init__() + self.config = cfg + self.isLeaf = True + self.map_get = Mapper() + self.map_post = Mapper() + + self.allnet = AllnetServlet(cfg, config_dir) + self.title = TitleServlet(cfg, config_dir) + + self.map_post.connect('allnet_poweron', '/sys/servlet/PowerOn', controller="allnet", action='handle_poweron', conditions=dict(method=['POST'])) + self.map_post.connect('allnet_downloadorder', '/sys/servlet/DownloadOrder', controller="allnet", action='handle_dlorder', conditions=dict(method=['POST'])) + self.map_post.connect('allnet_billing', '/request', controller="allnet", action='handle_billing_request', conditions=dict(method=['POST'])) + + self.map_get.connect("title_get", "/{game}/{version}/{endpoint:.*?}", controller="title", action="render_GET", requirements=dict(game=R"S...")) + self.map_post.connect("title_post", "/{game}/{version}/{endpoint:.*?}", controller="title", action="render_POST", requirements=dict(game=R"S...")) + + def render_POST(self, request: Request) -> bytes: + test = self.map_get.match(request.uri.decode()) + if test is None: + return b"" + + controller = getattr(self, test["controller"], None) + if controller is None: + return b"" + + handler = getattr(controller, test["action"], None) + if handler is None: + return b"" + + url_vars = test + url_vars.pop("controller") + url_vars.pop("action") + + if len(url_vars) > 0: + ret = handler(request, url_vars) + else: + ret = handler(request) + + if type(ret) == str: + return ret.encode() + elif type(ret) == bytes: + return ret + else: + return b"" + + def render_POST(self, request: Request) -> bytes: + test = self.map_post.match(request.uri.decode()) + if test is None: + return b"" + + controller = getattr(self, test["controller"], None) + if controller is None: + return b"" + + handler = getattr(controller, test["action"], None) + if handler is None: + return b"" + + url_vars = test + url_vars.pop("controller") + url_vars.pop("action") + ret = handler(request, url_vars) + + if type(ret) == str: + return ret.encode() + elif type(ret) == bytes: + return ret + else: + return b"" + if __name__ == "__main__": parser = argparse.ArgumentParser(description="ARTEMiS main entry point") parser.add_argument("--config", "-c", type=str, default="config", help="Configuration folder") @@ -42,16 +115,8 @@ if __name__ == "__main__": billing_server_str = f"ssl:{cfg.billing.port}:interface={cfg.server.listen_address}"\ f":privateKey={cfg.billing.ssl_key}:certKey={cfg.billing.ssl_cert}" - allnet_cls = AllnetServlet(cfg, args.config) - title_cls = TitleServlet(cfg, args.config) + dispatcher = HttpDispatcher(cfg, args.config) - dispatcher = Dispatcher() - dispatcher.connect('allnet_poweron', '/sys/servlet/PowerOn', allnet_cls, action='handle_poweron', conditions=dict(method=['POST'])) - dispatcher.connect('allnet_downloadorder', '/sys/servlet/DownloadOrder', allnet_cls, action='handle_dlorder', conditions=dict(method=['POST'])) - dispatcher.connect('allnet_billing', '/request', allnet_cls, action='handle_billing_request', conditions=dict(method=['POST'])) - dispatcher.connect("title_get", "/{game}/{version}/{endpoint}", title_cls, action="handle_GET", conditions=dict(method=['GET'])) - dispatcher.connect("title_post", "/{game}/{version}/{endpoint}", title_cls, action="handle_POST", conditions=dict(method=['POST'])) - endpoints.serverFromString(reactor, allnet_server_str).listen(server.Site(dispatcher)) endpoints.serverFromString(reactor, adb_server_str).listen(AimedbFactory(cfg)) diff --git a/read.py b/read.py new file mode 100644 index 0000000..ffc4812 --- /dev/null +++ b/read.py @@ -0,0 +1,129 @@ +# vim: set fileencoding=utf-8 +import argparse +import re +import os +import yaml +import importlib +import logging, coloredlogs + +from logging.handlers import TimedRotatingFileHandler +from typing import List, Optional + +from core import CoreConfig +from core.utils import Utils + +class BaseReader(): + def __init__(self, config: CoreConfig, version: int, bin_dir: Optional[str], opt_dir: Optional[str], extra: Optional[str]) -> None: + self.logger = logging.getLogger("reader") + self.config = config + self.bin_dir = bin_dir + self.opt_dir = opt_dir + self.version = version + self.extra = extra + + + def get_data_directories(self, directory: str) -> List[str]: + ret: List[str] = [] + + for root, dirs, files in os.walk(directory): + for dir in dirs: + if re.fullmatch("[A-Z0-9]{4,4}", dir) is not None: + ret.append(f"{root}/{dir}") + + return ret + +if __name__ == "__main__": + parser = argparse.ArgumentParser(description='Import Game Information') + parser.add_argument( + '--series', + action='store', + type=str, + required=True, + help='The game series we are importing.', + ) + parser.add_argument( + '--version', + dest='version', + action='store', + type=int, + required=True, + help='The game version we are importing.', + ) + parser.add_argument( + '--binfolder', + dest='bin', + action='store', + type=str, + help='Folder containing A000 base data', + ) + parser.add_argument( + '--optfolder', + dest='opt', + action='store', + type=str, + help='Folder containing Option data folders', + ) + parser.add_argument( + "--config", + type=str, + default="config", + help="Folder containing the core configuration for importing to DB. Defaults to 'config'.", + ) + parser.add_argument( + "--extra", + type=str, + help="Any extra data that a reader might require.", + ) + + # Parse args, validate invariants. + args = parser.parse_args() + + config = CoreConfig() + config.update(yaml.safe_load(open(f"{args.config}/core.yaml"))) + + log_fmt_str = "[%(asctime)s] Reader | %(levelname)s | %(message)s" + log_fmt = logging.Formatter(log_fmt_str) + logger = logging.getLogger("reader") + + fileHandler = TimedRotatingFileHandler("{0}/{1}.log".format(config.server.logs, "reader"), when="d", backupCount=10) + fileHandler.setFormatter(log_fmt) + + consoleHandler = logging.StreamHandler() + consoleHandler.setFormatter(log_fmt) + + logger.addHandler(fileHandler) + logger.addHandler(consoleHandler) + + logger.setLevel(logging.INFO) + coloredlogs.install(level=logging.INFO, logger=logger, fmt=log_fmt_str) + + if args.series is None or args.version is None: + logger.error("Game or version not specified") + parser.print_help() + exit(1) + + if args.bin is None and args.opt is None: + logger.error("Must specify either bin or opt directory") + parser.print_help() + exit(1) + + if args.bin is not None and (args.bin.endswith("\\") or args.bin.endswith("/")): + bin_arg = args.bin[:-1] + else: + bin_arg = args.bin + + if args.opt is not None and (args.opt.endswith("\\") or args.opt.endswith("/")): + opt_arg = args.opt[:-1] + else: + opt_arg = args.opt + + logger.info("Starting importer...") + + titles = Utils.get_all_titles() + + for dir, mod in titles.items(): + if args.series in mod.game_codes: + handler = mod.reader(config, args.version, bin_arg, opt_arg, args.extra) + handler.read() + + logger.info("Done") diff --git a/requirements.txt b/requirements.txt index 8dffde0..9ab1628 100644 Binary files a/requirements.txt and b/requirements.txt differ diff --git a/requirements_win.txt b/requirements_win.txt index 412f961..f5804d3 100644 Binary files a/requirements_win.txt and b/requirements_win.txt differ diff --git a/titles/chuni/__init__.py b/titles/chuni/__init__.py new file mode 100644 index 0000000..3883aeb --- /dev/null +++ b/titles/chuni/__init__.py @@ -0,0 +1,18 @@ +from titles.chuni.index import ChuniServlet +from titles.chuni.const import ChuniConstants +from titles.chuni.database import ChuniData +from titles.chuni.read import ChuniReader + +index = ChuniServlet +database = ChuniData +reader = ChuniReader + +use_default_title = True +include_protocol = True +title_secure = False +game_codes = [ChuniConstants.GAME_CODE, ChuniConstants.GAME_CODE_NEW] +trailing_slash = True +use_default_host = False +host = "" + +current_schema_version = 1 diff --git a/titles/chuni/air.py b/titles/chuni/air.py new file mode 100644 index 0000000..46f8337 --- /dev/null +++ b/titles/chuni/air.py @@ -0,0 +1,16 @@ +from typing import Dict + +from core.config import CoreConfig +from titles.chuni.base import ChuniBase +from titles.chuni.const import ChuniConstants +from titles.chuni.config import ChuniConfig + +class ChuniAir(ChuniBase): + def __init__(self, core_cfg: CoreConfig, game_cfg: ChuniConfig) -> None: + super().__init__(core_cfg, game_cfg) + self.version = ChuniConstants.VER_CHUNITHM_AIR + + def handle_get_game_setting_api_request(self, data: Dict) -> Dict: + ret = super().handle_get_game_setting_api_request(data) + ret["gameSetting"]["dataVersion"] = "1.10.00" + return ret \ No newline at end of file diff --git a/titles/chuni/airplus.py b/titles/chuni/airplus.py new file mode 100644 index 0000000..77498fb --- /dev/null +++ b/titles/chuni/airplus.py @@ -0,0 +1,16 @@ +from typing import Dict + +from core.config import CoreConfig +from titles.chuni.base import ChuniBase +from titles.chuni.const import ChuniConstants +from titles.chuni.config import ChuniConfig + +class ChuniAirPlus(ChuniBase): + def __init__(self, core_cfg: CoreConfig, game_cfg: ChuniConfig) -> None: + super().__init__(core_cfg, game_cfg) + self.version = ChuniConstants.VER_CHUNITHM_AIR_PLUS + + def handle_get_game_setting_api_request(self, data: Dict) -> Dict: + ret = super().handle_get_game_setting_api_request(data) + ret["gameSetting"]["dataVersion"] = "1.15.00" + return ret \ No newline at end of file diff --git a/titles/chuni/amazon.py b/titles/chuni/amazon.py new file mode 100644 index 0000000..d822665 --- /dev/null +++ b/titles/chuni/amazon.py @@ -0,0 +1,18 @@ +from datetime import datetime, timedelta +from typing import Dict, Any +import pytz + +from core.config import CoreConfig +from titles.chuni.base import ChuniBase +from titles.chuni.const import ChuniConstants +from titles.chuni.config import ChuniConfig + +class ChuniAmazon(ChuniBase): + def __init__(self, core_cfg: CoreConfig, game_cfg: ChuniConfig) -> None: + super().__init__(core_cfg, game_cfg) + self.version = ChuniConstants.VER_CHUNITHM_AMAZON + + def handle_get_game_setting_api_request(self, data: Dict) -> Dict: + ret = super().handle_get_game_setting_api_request(data) + ret["gameSetting"]["dataVersion"] = "1.30.00" + return ret diff --git a/titles/chuni/amazonplus.py b/titles/chuni/amazonplus.py new file mode 100644 index 0000000..5e901cd --- /dev/null +++ b/titles/chuni/amazonplus.py @@ -0,0 +1,18 @@ +from datetime import datetime, timedelta +from typing import Dict, Any +import pytz + +from core.config import CoreConfig +from titles.chuni.base import ChuniBase +from titles.chuni.const import ChuniConstants +from titles.chuni.config import ChuniConfig + +class ChuniAmazonPlus(ChuniBase): + def __init__(self, core_cfg: CoreConfig, game_cfg: ChuniConfig) -> None: + super().__init__(core_cfg, game_cfg) + self.version = ChuniConstants.VER_CHUNITHM_AMAZON_PLUS + + def handle_get_game_setting_api_request(self, data: Dict) -> Dict: + ret = super().handle_get_game_setting_api_request(data) + ret["gameSetting"]["dataVersion"] = "1.35.00" + return ret diff --git a/titles/chuni/base.py b/titles/chuni/base.py new file mode 100644 index 0000000..bf32f63 --- /dev/null +++ b/titles/chuni/base.py @@ -0,0 +1,572 @@ +import logging +import json +from datetime import datetime, timedelta +from time import strftime + +import pytz +from typing import Dict, Any + +from core.config import CoreConfig +from titles.chuni.const import ChuniConstants +from titles.chuni.database import ChuniData +from titles.chuni.config import ChuniConfig + +class ChuniBase(): + def __init__(self, core_cfg: CoreConfig, game_cfg: ChuniConfig) -> None: + self.core_cfg = core_cfg + self.game_cfg = game_cfg + self.data = ChuniData(core_cfg) + self.date_time_format = "%Y-%m-%d %H:%M:%S" + self.logger = logging.getLogger("chuni") + self.game = ChuniConstants.GAME_CODE + self.version = ChuniConstants.VER_CHUNITHM + + def handle_game_login_api_request(self, data: Dict) -> Dict: + #self.data.base.log_event("chuni", "login", logging.INFO, {"version": self.version, "user": data["userId"]}) + return { "returnCode": 1 } + + def handle_game_logout_api_request(self, data: Dict) -> Dict: + #self.data.base.log_event("chuni", "logout", logging.INFO, {"version": self.version, "user": data["userId"]}) + return { "returnCode": 1 } + + def handle_get_game_charge_api_request(self, data: Dict) -> Dict: + game_charge_list = self.data.static.get_enabled_charges(self.version) + + charges = [] + for x in range(len(game_charge_list)): + charges.append({ + "orderId": x, + "chargeId": game_charge_list[x]["chargeId"], + "price": 1, + "startDate": "2017-12-05 07:00:00.0", + "endDate": "2099-12-31 00:00:00.0", + "salePrice": 1, + "saleStartDate": "2017-12-05 07:00:00.0", + "saleEndDate": "2099-12-31 00:00:00.0" + }) + return { + "length": len(charges), + "gameChargeList": charges + } + + def handle_get_game_event_api_request(self, data: Dict) -> Dict: + game_events = self.data.static.get_enabled_events(self.version) + + event_list = [] + for evt_row in game_events: + tmp = {} + tmp["id"] = evt_row["eventId"] + tmp["type"] = evt_row["type"] + tmp["startDate"] = "2017-12-05 07:00:00.0" + tmp["endDate"] = "2099-12-31 00:00:00.0" + event_list.append(tmp) + + return { + "type": data["type"], + "length": len(event_list), + "gameEventList": event_list + } + + def handle_get_game_idlist_api_request(self, data: Dict) -> Dict: + return { "type": data["type"], "length": 0, "gameIdlistList": [] } + + def handle_get_game_message_api_request(self, data: Dict) -> Dict: + return { "type": data["type"], "length": "0", "gameMessageList": [] } + + def handle_get_game_ranking_api_request(self, data: Dict) -> Dict: + return { "type": data["type"], "gameRankingList": [] } + + def handle_get_game_sale_api_request(self, data: Dict) -> Dict: + return { "type": data["type"], "length": 0, "gameSaleList": [] } + + def handle_get_game_setting_api_request(self, data: Dict) -> Dict: + reboot_start = datetime.strftime(datetime.now() - timedelta(hours=4), self.date_time_format) + reboot_end = datetime.strftime(datetime.now() - timedelta(hours=3), self.date_time_format) + return { + "gameSetting": { + "dataVersion": "1.00.00", + "isMaintenance": "false", + "requestInterval": 10, + "rebootStartTime": reboot_start, + "rebootEndTime": reboot_end, + "isBackgroundDistribute": "false", + "maxCountCharacter": 300, + "maxCountItem": 300, + "maxCountMusic": 300, + }, + "isDumpUpload": "false", + "isAou": "false", + } + + def handle_get_user_activity_api_request(self, data: Dict) -> Dict: + user_activity_list = self.data.profile.get_profile_activity(data["userId"], data["kind"]) + + activity_list = [] + + for activity in user_activity_list: + tmp = activity._asdict() + tmp.pop("user") + tmp["id"] = tmp["activityId"] + tmp.pop("activityId") + activity_list.append(tmp) + + return { + "userId": data["userId"], + "length": len(activity_list), + "kind": data["kind"], + "userActivityList": activity_list + } + + def handle_get_user_character_api_request(self, data: Dict) -> Dict: + characters = self.data.item.get_characters(data["userId"]) + if characters is None: return {} + next_idx = -1 + + characterList = [] + for x in range(int(data["nextIndex"]), len(characters)): + tmp = characters[x]._asdict() + tmp.pop("user") + tmp.pop("id") + characterList.append(tmp) + + if len(characterList) >= int(data["maxCount"]): + break + + if len(characterList) >= int(data["maxCount"]) and len(characters) > int(data["maxCount"]) + int(data["nextIndex"]): + next_idx = int(data["maxCount"]) + int(data["nextIndex"]) + 1 + + return { + "userId": data["userId"], + "length": len(characterList), + "nextIndex": next_idx, + "userCharacterList": characterList + } + + def handle_get_user_charge_api_request(self, data: Dict) -> Dict: + user_charge_list = self.data.profile.get_profile_charge(data["userId"]) + + charge_list = [] + for charge in user_charge_list: + tmp = charge._asdict() + tmp.pop("id") + tmp.pop("user") + charge_list.append(tmp) + + return { + "userId": data["userId"], + "length": len(charge_list), + "userChargeList": charge_list + } + + def handle_get_user_course_api_request(self, data: Dict) -> Dict: + user_course_list = self.data.score.get_courses(data["userId"]) + if user_course_list is None: + return { + "userId": data["userId"], + "length": 0, + "nextIndex": -1, + "userCourseList": [] + } + + course_list = [] + next_idx = int(data["nextIndex"]) + max_ct = int(data["maxCount"]) + + for x in range(next_idx, len(user_course_list)): + tmp = user_course_list[x]._asdict() + tmp.pop("user") + tmp.pop("id") + course_list.append(tmp) + + if len(user_course_list) >= max_ct: + break + + if len(user_course_list) >= max_ct: + next_idx = next_idx + max_ct + else: + next_idx = -1 + + return { + "userId": data["userId"], + "length": len(course_list), + "nextIndex": next_idx, + "userCourseList": course_list + } + + def handle_get_user_data_api_request(self, data: Dict) -> Dict: + p = self.data.profile.get_profile_data(data["userId"], self.version) + if p is None: return {} + + profile = p._asdict() + profile.pop("id") + profile.pop("user") + profile.pop("version") + + return { + "userId": data["userId"], + "userData": profile + } + + def handle_get_user_data_ex_api_request(self, data: Dict) -> Dict: + p = self.data.profile.get_profile_data_ex(data["userId"], self.version) + if p is None: return {} + + profile = p._asdict() + profile.pop("id") + profile.pop("user") + profile.pop("version") + + return { + "userId": data["userId"], + "userDataEx": profile + } + + def handle_get_user_duel_api_request(self, data: Dict) -> Dict: + user_duel_list = self.data.item.get_duels(data["userId"]) + if user_duel_list is None: return {} + + duel_list = [] + for duel in user_duel_list: + tmp = duel._asdict() + tmp.pop("id") + tmp.pop("user") + duel_list.append(tmp) + + return { + "userId": data["userId"], + "length": len(duel_list), + "userDuelList": duel_list + } + + def handle_get_user_favorite_item_api_request(self, data: Dict) -> Dict: + return { + "userId": data["userId"], + "length": 0, + "kind": data["kind"], + "nextIndex": -1, + "userFavoriteItemList": [] + } + + def handle_get_user_favorite_music_api_request(self, data: Dict) -> Dict: + """ + This is handled via the webui, which we don't have right now + """ + + return { + "userId": data["userId"], + "length": 0, + "userFavoriteMusicList": [] + } + + def handle_get_user_item_api_request(self, data: Dict) -> Dict: + kind = int(int(data["nextIndex"]) / 10000000000) + next_idx = int(int(data["nextIndex"]) % 10000000000) + user_item_list = self.data.item.get_items(data["userId"], kind) + + if user_item_list is None or len(user_item_list) == 0: + return {"userId": data["userId"], "nextIndex": -1, "itemKind": kind, "userItemList": []} + + items: list[Dict[str, Any]] = [] + for i in range(next_idx, len(user_item_list)): + tmp = user_item_list[i]._asdict() + tmp.pop("user") + tmp.pop("id") + items.append(tmp) + if len(items) >= int(data["maxCount"]): + break + + xout = kind * 10000000000 + next_idx + len(items) + + if len(items) < int(data["maxCount"]): nextIndex = 0 + else: nextIndex = xout + + return {"userId": data["userId"], "nextIndex": nextIndex, "itemKind": kind, "length": len(items), "userItemList": items} + + def handle_get_user_login_bonus_api_request(self, data: Dict) -> Dict: + """ + Unsure how to get this to trigger... + """ + return { + "userId": data["userId"], + "length": 2, + "userLoginBonusList": [ + { + "presetId": '10', + "bonusCount": '0', + "lastUpdateDate": "1970-01-01 09:00:00", + "isWatched": "true" + }, + { + "presetId": '20', + "bonusCount": '0', + "lastUpdateDate": "1970-01-01 09:00:00", + "isWatched": "true" + }, + ] + } + + def handle_get_user_map_api_request(self, data: Dict) -> Dict: + user_map_list = self.data.item.get_maps(data["userId"]) + if user_map_list is None: return {} + + map_list = [] + for map in user_map_list: + tmp = map._asdict() + tmp.pop("id") + tmp.pop("user") + map_list.append(tmp) + + return { + "userId": data["userId"], + "length": len(map_list), + "userMapList": map_list + } + + def handle_get_user_music_api_request(self, data: Dict) -> Dict: + music_detail = self.data.score.get_scores(data["userId"]) + if music_detail is None: + return { + "userId": data["userId"], + "length": 0, + "nextIndex": -1, + "userMusicList": [] #240 + } + song_list = [] + next_idx = int(data["nextIndex"]) + max_ct = int(data["maxCount"]) + + for x in range(next_idx, len(music_detail)): + found = False + tmp = music_detail[x]._asdict() + tmp.pop("user") + tmp.pop("id") + + for song in song_list: + if song["userMusicDetailList"][0]["musicId"] == tmp["musicId"]: + found = True + song["userMusicDetailList"].append(tmp) + song["length"] = len(song["userMusicDetailList"]) + + if not found: + song_list.append({ + "length": 1, + "userMusicDetailList": [tmp] + }) + + if len(song_list) >= max_ct: + break + + if len(song_list) >= max_ct: + next_idx += max_ct + else: + next_idx = 0 + + return { + "userId": data["userId"], + "length": len(song_list), + "nextIndex": next_idx, + "userMusicList": song_list #240 + } + + def handle_get_user_option_api_request(self, data: Dict) -> Dict: + p = self.data.profile.get_profile_option(data["userId"]) + + option = p._asdict() + option.pop("id") + option.pop("user") + + return { + "userId": data["userId"], + "userGameOption": option + } + + def handle_get_user_option_ex_api_request(self, data: Dict) -> Dict: + p = self.data.profile.get_profile_option_ex(data["userId"]) + + option = p._asdict() + option.pop("id") + option.pop("user") + + return { + "userId": data["userId"], + "userGameOptionEx": option + } + + def read_wtf8(self, src): + return bytes([ord(c) for c in src]).decode("utf-8") + + def handle_get_user_preview_api_request(self, data: Dict) -> Dict: + profile = self.data.profile.get_profile_preview(data["userId"], self.version) + if profile is None: return None + profile_character = self.data.item.get_character(data["userId"], profile["characterId"]) + + if profile_character is None: + chara = {} + else: + chara = profile_character._asdict() + chara.pop("id") + chara.pop("user") + + return { + "userId": data["userId"], + # Current Login State + "isLogin": False, + "lastLoginDate": profile["lastPlayDate"], + # User Profile + "userName": profile["userName"], + "reincarnationNum": profile["reincarnationNum"], + "level": profile["level"], + "exp": profile["exp"], + "playerRating": profile["playerRating"], + "lastGameId": profile["lastGameId"], + "lastRomVersion": profile["lastRomVersion"], + "lastDataVersion": profile["lastDataVersion"], + "lastPlayDate": profile["lastPlayDate"], + "trophyId": profile["trophyId"], + "nameplateId": profile["nameplateId"], + # Current Selected Character + "userCharacter": chara, + # User Game Options + "playerLevel": profile["playerLevel"], + "rating": profile["rating"], + "headphone": profile["headphone"], + "chargeState": "1", + "userNameEx": profile["userName"], + } + + def handle_get_user_recent_rating_api_request(self, data: Dict) -> Dict: + recet_rating_list = self.data.profile.get_profile_recent_rating(data["userId"]) + if recet_rating_list is None: + return { + "userId": data["userId"], + "length": 0, + "userRecentRatingList": [], + } + + return { + "userId": data["userId"], + "length": len(recet_rating_list["recentRating"]), + "userRecentRatingList": recet_rating_list["recentRating"], + } + + def handle_get_user_region_api_request(self, data: Dict) -> Dict: + # TODO: Region + return { + "userId": data["userId"], + "length": 0, + "userRegionList": [], + } + + def handle_get_user_team_api_request(self, data: Dict) -> Dict: + # TODO: Team + return { + "userId": data["userId"], + "teamId": 0 + } + + def handle_get_team_course_setting_api_request(self, data: Dict) -> Dict: + return { + "userId": data["userId"], + "length": 0, + "nextIndex": 0, + "teamCourseSettingList": [], + } + + def handle_get_team_course_rule_api_request(self, data: Dict) -> Dict: + return { + "userId": data["userId"], + "length": 0, + "nextIndex": 0, + "teamCourseRuleList": [], + } + + def handle_upsert_user_all_api_request(self, data: Dict) -> Dict: + upsert = data["upsertUserAll"] + user_id = data["userId"] + + if "userData" in upsert: + try: + upsert["userData"][0]["userName"] = self.read_wtf8(upsert["userData"][0]["userName"]) + except: pass + + self.data.profile.put_profile_data(user_id, self.version, upsert["userData"][0]) + if "userDataEx" in upsert: + self.data.profile.put_profile_data_ex(user_id, self.version, upsert["userDataEx"][0]) + if "userGameOption" in upsert: + self.data.profile.put_profile_option(user_id, upsert["userGameOption"][0]) + if "userGameOptionEx" in upsert: + self.data.profile.put_profile_option_ex(user_id, upsert["userGameOptionEx"][0]) + if "userRecentRatingList" in upsert: + self.data.profile.put_profile_recent_rating(user_id, upsert["userRecentRatingList"]) + + if "userCharacterList" in upsert: + for character in upsert["userCharacterList"]: + self.data.item.put_character(user_id, character) + + if "userMapList" in upsert: + for map in upsert["userMapList"]: + self.data.item.put_map(user_id, map) + + if "userCourseList" in upsert: + for course in upsert["userCourseList"]: + self.data.score.put_course(user_id, course) + + if "userDuelList" in upsert: + for duel in upsert["userDuelList"]: + self.data.item.put_duel(user_id, duel) + + if "userItemList" in upsert: + for item in upsert["userItemList"]: + self.data.item.put_item(user_id, item) + + if "userActivityList" in upsert: + for activity in upsert["userActivityList"]: + self.data.profile.put_profile_activity(user_id, activity) + + if "userChargeList" in upsert: + for charge in upsert["userChargeList"]: + self.data.profile.put_profile_charge(user_id, charge) + + if "userMusicDetailList" in upsert: + for song in upsert["userMusicDetailList"]: + self.data.score.put_score(user_id, song) + + if "userPlaylogList" in upsert: + for playlog in upsert["userPlaylogList"]: + self.data.score.put_playlog(user_id, playlog) + + if "userTeamPoint" in upsert: + # TODO: team stuff + pass + + if "userMapAreaList" in upsert: + for map_area in upsert["userMapAreaList"]: + self.data.item.put_map_area(user_id, map_area) + + if "userOverPowerList" in upsert: + for overpower in upsert["userOverPowerList"]: + self.data.profile.put_profile_overpower(user_id, overpower) + + if "userEmoneyList" in upsert: + for emoney in upsert["userEmoneyList"]: + self.data.profile.put_profile_emoney(user_id, emoney) + + return { "returnCode": "1" } + + def handle_upsert_user_chargelog_api_request(self, data: Dict) -> Dict: + return { "returnCode": "1" } + + def handle_upsert_client_bookkeeping_api_request(self, data: Dict) -> Dict: + return { "returnCode": "1" } + + def handle_upsert_client_develop_api_request(self, data: Dict) -> Dict: + return { "returnCode": "1" } + + def handle_upsert_client_error_api_request(self, data: Dict) -> Dict: + return { "returnCode": "1" } + + def handle_upsert_client_setting_api_request(self, data: Dict) -> Dict: + return { "returnCode": "1" } + + def handle_upsert_client_testmode_api_request(self, data: Dict) -> Dict: + return { "returnCode": "1" } diff --git a/titles/chuni/config.py b/titles/chuni/config.py new file mode 100644 index 0000000..f3a0a7e --- /dev/null +++ b/titles/chuni/config.py @@ -0,0 +1,36 @@ +from core.config import CoreConfig +from typing import Dict + +class ChuniServerConfig(): + def __init__(self, parent_config: "ChuniConfig") -> None: + self.__config = parent_config + + @property + def enable(self) -> bool: + return CoreConfig.get_config_field(self.__config, 'chuni', 'server', 'enable', default=True) + + @property + def loglevel(self) -> int: + return CoreConfig.str_to_loglevel(CoreConfig.get_config_field(self.__config, 'chuni', 'server', 'loglevel', default="info")) + +class ChuniCryptoConfig(): + def __init__(self, parent_config: "ChuniConfig") -> None: + self.__config = parent_config + + @property + def keys(self) -> Dict: + """ + in the form of: + internal_version: [key, iv] + all values are hex strings + """ + return CoreConfig.get_config_field(self.__config, 'chuni', 'crypto', 'keys', default={}) + + @property + def encrypted_only(self) -> bool: + return CoreConfig.get_config_field(self.__config, 'chuni', 'crypto', 'encrypted_only', default=False) + +class ChuniConfig(dict): + def __init__(self) -> None: + self.server = ChuniServerConfig(self) + self.crypto = ChuniCryptoConfig(self) \ No newline at end of file diff --git a/titles/chuni/const.py b/titles/chuni/const.py new file mode 100644 index 0000000..ebc8cf2 --- /dev/null +++ b/titles/chuni/const.py @@ -0,0 +1,24 @@ +class ChuniConstants(): + GAME_CODE = "SDBT" + GAME_CODE_NEW = "SDHD" + + VER_CHUNITHM = 0 + VER_CHUNITHM_PLUS = 1 + VER_CHUNITHM_AIR = 2 + VER_CHUNITHM_AIR_PLUS = 3 + VER_CHUNITHM_STAR = 4 + VER_CHUNITHM_STAR_PLUS = 5 + VER_CHUNITHM_AMAZON = 6 + VER_CHUNITHM_AMAZON_PLUS = 7 + VER_CHUNITHM_CRYSTAL = 8 + VER_CHUNITHM_CRYSTAL_PLUS = 9 + VER_CHUNITHM_PARADISE = 10 + VER_CHUNITHM_NEW = 11 + VER_CHUNITHM_NEW_PLUS = 12 + + VERSION_NAMES = ["Chunithm", "Chunithm+", "Chunithm Air", "Chunithm Air+", "Chunithm Star", "Chunithm Star+", "Chunithm Amazon", + "Chunithm Amazon+", "Chunithm Crystal", "Chunithm Crystal+", "Chunithm Paradise", "Chunithm New!!", "Chunithm New!!+"] + + @classmethod + def game_ver_to_string(cls, ver: int): + return cls.VERSION_NAMES[ver] diff --git a/titles/chuni/crystal.py b/titles/chuni/crystal.py new file mode 100644 index 0000000..d492f0b --- /dev/null +++ b/titles/chuni/crystal.py @@ -0,0 +1,18 @@ +from datetime import datetime, timedelta +from typing import Dict, Any +import pytz + +from core.config import CoreConfig +from titles.chuni.base import ChuniBase +from titles.chuni.const import ChuniConstants +from titles.chuni.config import ChuniConfig + +class ChuniCrystal(ChuniBase): + def __init__(self, core_cfg: CoreConfig, game_cfg: ChuniConfig) -> None: + super().__init__(core_cfg, game_cfg) + self.version = ChuniConstants.VER_CHUNITHM_CRYSTAL + + def handle_get_game_setting_api_request(self, data: Dict) -> Dict: + ret = super().handle_get_game_setting_api_request(data) + ret["gameSetting"]["dataVersion"] = "1.40.00" + return ret diff --git a/titles/chuni/crystalplus.py b/titles/chuni/crystalplus.py new file mode 100644 index 0000000..b06eb5b --- /dev/null +++ b/titles/chuni/crystalplus.py @@ -0,0 +1,18 @@ +from datetime import datetime, timedelta +from typing import Dict, Any +import pytz + +from core.config import CoreConfig +from titles.chuni.base import ChuniBase +from titles.chuni.const import ChuniConstants +from titles.chuni.config import ChuniConfig + +class ChuniCrystalPlus(ChuniBase): + def __init__(self, core_cfg: CoreConfig, game_cfg: ChuniConfig) -> None: + super().__init__(core_cfg, game_cfg) + self.version = ChuniConstants.VER_CHUNITHM_CRYSTAL_PLUS + + def handle_get_game_setting_api_request(self, data: Dict) -> Dict: + ret = super().handle_get_game_setting_api_request(data) + ret["gameSetting"]["dataVersion"] = "1.45.00" + return ret diff --git a/titles/chuni/database.py b/titles/chuni/database.py new file mode 100644 index 0000000..c55149b --- /dev/null +++ b/titles/chuni/database.py @@ -0,0 +1,12 @@ +from core.data import Data +from core.config import CoreConfig +from titles.chuni.schema import * + +class ChuniData(Data): + def __init__(self, cfg: CoreConfig) -> None: + super().__init__(cfg) + + self.item = ChuniItemData(cfg, self.session) + self.profile = ChuniProfileData(cfg, self.session) + self.score = ChuniScoreData(cfg, self.session) + self.static = ChuniStaticData(cfg, self.session) \ No newline at end of file diff --git a/titles/chuni/index.py b/titles/chuni/index.py new file mode 100644 index 0000000..25f31b5 --- /dev/null +++ b/titles/chuni/index.py @@ -0,0 +1,172 @@ +from twisted.web.http import Request +import logging, coloredlogs +from logging.handlers import TimedRotatingFileHandler +import zlib +import yaml +import json +import inflection +import string +from Crypto.Cipher import AES +from Crypto.Util.Padding import pad + +from core import CoreConfig +from titles.chuni.config import ChuniConfig +from titles.chuni.const import ChuniConstants +from titles.chuni.base import ChuniBase +from titles.chuni.plus import ChuniPlus +from titles.chuni.air import ChuniAir +from titles.chuni.airplus import ChuniAirPlus +from titles.chuni.star import ChuniStar +from titles.chuni.starplus import ChuniStarPlus +from titles.chuni.amazon import ChuniAmazon +from titles.chuni.amazonplus import ChuniAmazonPlus +from titles.chuni.crystal import ChuniCrystal +from titles.chuni.crystalplus import ChuniCrystalPlus +from titles.chuni.paradise import ChuniParadise +from titles.chuni.new import ChuniNew +from titles.chuni.newplus import ChuniNewPlus + +class ChuniServlet(): + def __init__(self, core_cfg: CoreConfig, cfg_dir: str) -> None: + self.core_cfg = core_cfg + self.game_cfg = ChuniConfig() + self.game_cfg.update(yaml.safe_load(open(f"{cfg_dir}/chuni.yaml"))) + + self.versions = [ + ChuniBase(core_cfg, self.game_cfg), + ChuniPlus(core_cfg, self.game_cfg), + ChuniAir(core_cfg, self.game_cfg), + ChuniAirPlus(core_cfg, self.game_cfg), + ChuniStar(core_cfg, self.game_cfg), + ChuniStarPlus(core_cfg, self.game_cfg), + ChuniAmazon(core_cfg, self.game_cfg), + ChuniAmazonPlus(core_cfg, self.game_cfg), + ChuniCrystal(core_cfg, self.game_cfg), + ChuniCrystalPlus(core_cfg, self.game_cfg), + ChuniParadise(core_cfg, self.game_cfg), + ChuniNew(core_cfg, self.game_cfg), + ChuniNewPlus(core_cfg, self.game_cfg), + ] + + self.logger = logging.getLogger("chuni") + + if not hasattr(self.logger, "inited"): + log_fmt_str = "[%(asctime)s] Chunithm | %(levelname)s | %(message)s" + log_fmt = logging.Formatter(log_fmt_str) + fileHandler = TimedRotatingFileHandler("{0}/{1}.log".format(self.core_cfg.server.log_dir, "chuni"), encoding='utf8', + when="d", backupCount=10) + + fileHandler.setFormatter(log_fmt) + + consoleHandler = logging.StreamHandler() + consoleHandler.setFormatter(log_fmt) + + self.logger.addHandler(fileHandler) + self.logger.addHandler(consoleHandler) + + self.logger.setLevel(self.game_cfg.server.loglevel) + coloredlogs.install(level=self.game_cfg.server.loglevel, logger=self.logger, fmt=log_fmt_str) + self.logger.inited = True + + def render_POST(self, request: Request, version: int, url_path: str) -> bytes: + req_raw = request.content.getvalue() + url_split = url_path.split("/") + encrtped = False + internal_ver = 0 + endpoint = url_split[len(url_split) - 1] + + if version < 105: # 1.0 + internal_ver = ChuniConstants.VER_CHUNITHM + elif version >= 105 and version < 110: # Plus + internal_ver = ChuniConstants.VER_CHUNITHM_PLUS + elif version >= 110 and version < 115: # Air + internal_ver = ChuniConstants.VER_CHUNITHM_AIR + elif version >= 115 and version < 120: # Air Plus + internal_ver = ChuniConstants.VER_CHUNITHM_AIR_PLUS + elif version >= 120 and version < 125: # Star + internal_ver = ChuniConstants.VER_CHUNITHM_STAR + elif version >= 125 and version < 130: # Star Plus + internal_ver = ChuniConstants.VER_CHUNITHM_STAR_PLUS + elif version >= 130 and version < 135: # Amazon + internal_ver = ChuniConstants.VER_CHUNITHM_AMAZON + elif version >= 135 and version < 140: # Amazon Plus + internal_ver = ChuniConstants.VER_CHUNITHM_AMAZON_PLUS + elif version >= 140 and version < 145: # Crystal + internal_ver = ChuniConstants.VER_CHUNITHM_CRYSTAL + elif version >= 145 and version < 150: # Crystal Plus + internal_ver = ChuniConstants.VER_CHUNITHM_CRYSTAL_PLUS + elif version >= 150 and version < 200: # Paradise + internal_ver = ChuniConstants.VER_CHUNITHM_PARADISE + elif version >= 200 and version < 205: # New + internal_ver = ChuniConstants.VER_CHUNITHM_NEW + elif version >= 205 and version < 210: # New Plus + internal_ver = ChuniConstants.VER_CHUNITHM_NEW_PLUS + + if all(c in string.hexdigits for c in endpoint) and len(endpoint) == 32: + # If we get a 32 character long hex string, it's a hash and we're + # doing encrypted. The likelyhood of false positives is low but + # technically not 0 + endpoint = request.getHeader("User-Agent").split("#")[0] + try: + crypt = AES.new( + bytes.fromhex(self.game_cfg.crypto.keys[str(internal_ver)][0]), + AES.MODE_CBC, + bytes.fromhex(self.game_cfg.crypto.keys[str(internal_ver)][1]) + ) + + req_raw = crypt.decrypt(req_raw) + + except: + self.logger.error(f"Failed to decrypt v{version} request to {endpoint} -> {req_raw}") + return zlib.compress("{\"stat\": \"0\"}".encode("utf-8")) + + encrtped = True + + if not encrtped and self.game_cfg.crypto.encrypted_only: + self.logger.error(f"Unencrypted v{version} {endpoint} request, but config is set to encrypted only: {req_raw}") + return zlib.compress("{\"stat\": \"0\"}".encode("utf-8")) + + try: + unzip = zlib.decompress(req_raw) + + except zlib.error as e: + self.logger.error(f"Failed to decompress v{version} {endpoint} request -> {e}") + return b"" + + req_data = json.loads(unzip) + + self.logger.info(f"v{version} {endpoint} request - {req_data}") + + func_to_find = "handle_" + inflection.underscore(endpoint) + "_request" + + try: + handler = getattr(self.versions[internal_ver], func_to_find) + resp = handler(req_data) + + except AttributeError as e: + self.logger.warning(f"Unhandled v{version} request {endpoint} - {e}") + return zlib.compress("{\"stat\": \"0\"}".encode("utf-8")) + + except Exception as e: + self.logger.error(f"Error handling v{version} method {endpoint} - {e}") + return zlib.compress("{\"stat\": \"0\"}".encode("utf-8")) + + if resp == None: + resp = {'returnCode': 1} + + self.logger.info(f"Response {resp}") + + zipped = zlib.compress(json.dumps(resp, ensure_ascii=False).encode("utf-8")) + + if not encrtped: + return zipped + + padded = pad(zipped, 16) + + crypt = AES.new( + bytes.fromhex(self.game_cfg.crypto.keys[str(internal_ver)][0]), + AES.MODE_CBC, + bytes.fromhex(self.game_cfg.crypto.keys[str(internal_ver)][1]) + ) + + return crypt.encrypt(padded) diff --git a/titles/chuni/new.py b/titles/chuni/new.py new file mode 100644 index 0000000..909284e --- /dev/null +++ b/titles/chuni/new.py @@ -0,0 +1,128 @@ +import logging +from datetime import datetime, timedelta + +from typing import Dict + +from core.config import CoreConfig +from titles.chuni.const import ChuniConstants +from titles.chuni.database import ChuniData +from titles.chuni.base import ChuniBase +from titles.chuni.config import ChuniConfig + +class ChuniNew(ChuniBase): + + ITEM_TYPE = { + "character": 20, + "story": 21, + "card": 22 + } + + def __init__(self, core_cfg: CoreConfig, game_cfg: ChuniConfig) -> None: + self.core_cfg = core_cfg + self.game_cfg = game_cfg + self.data = ChuniData(core_cfg) + self.date_time_format = "%Y-%m-%d %H:%M:%S" + self.logger = logging.getLogger("chuni") + self.game = ChuniConstants.GAME_CODE + self.version = ChuniConstants.VER_CHUNITHM_NEW + + def handle_get_game_setting_api_request(self, data: Dict) -> Dict: + match_start = datetime.strftime(datetime.now() - timedelta(hours=10), self.date_time_format) + match_end = datetime.strftime(datetime.now() + timedelta(hours=10), self.date_time_format) + reboot_start = datetime.strftime(datetime.now() - timedelta(hours=11), self.date_time_format) + reboot_end = datetime.strftime(datetime.now() - timedelta(hours=10), self.date_time_format) + return { + "gameSetting": { + "isMaintenance": "false", + "requestInterval": 10, + "rebootStartTime": reboot_start, + "rebootEndTime": reboot_end, + "isBackgroundDistribute": "false", + "maxCountCharacter": 300, + "maxCountItem": 300, + "maxCountMusic": 300, + "matchStartTime": match_start, + "matchEndTime": match_end, + "matchTimeLimit": 99, + "matchErrorLimit": 9999, + "romVersion": "2.00.00", + "dataVersion": "2.00.00", + "matchingUri": f"http://{self.core_cfg.server.hostname}:{self.core_cfg.title.port}/SDHD/200/ChuniServlet/", + "matchingUriX": f"http://{self.core_cfg.server.hostname}:{self.core_cfg.title.port}/SDHD/200/ChuniServlet/", + "udpHolePunchUri": f"http://{self.core_cfg.server.hostname}:{self.core_cfg.title.port}/SDHD/200/ChuniServlet/", + "reflectorUri": f"http://{self.core_cfg.server.hostname}:{self.core_cfg.title.port}/SDHD/200/ChuniServlet/", + }, + "isDumpUpload": "false", + "isAou": "false", + } + + def handle_delete_token_api_request(self, data: Dict) -> Dict: + return { "returnCode": "1" } + + def handle_create_token_api_request(self, data: Dict) -> Dict: + return { "returnCode": "1" } + + def handle_get_user_map_area_api_request(self, data: Dict) -> Dict: + user_map_areas = self.data.item.get_map_areas(data["userId"]) + + map_areas = [] + for map_area in user_map_areas: + tmp = map_area._asdict() + tmp.pop("id") + tmp.pop("user") + map_areas.append(tmp) + + return { + "userId": data["userId"], + "userMapAreaList": map_areas + } + + def handle_get_user_symbol_chat_setting_api_request(self, data: Dict) -> Dict: + return { + "userId": data["userId"], + "symbolCharInfoList": [] + } + + def handle_get_user_preview_api_request(self, data: Dict) -> Dict: + profile = self.data.profile.get_profile_preview(data["userId"], self.version) + if profile is None: return None + profile_character = self.data.item.get_character(data["userId"], profile["characterId"]) + + if profile_character is None: + chara = {} + else: + chara = profile_character._asdict() + chara.pop("id") + chara.pop("user") + + data1 = { + "userId": data["userId"], + # Current Login State + "isLogin": False, + "lastLoginDate": profile["lastPlayDate"], + # User Profile + "userName": profile["userName"], + "reincarnationNum": profile["reincarnationNum"], + "level": profile["level"], + "exp": profile["exp"], + "playerRating": profile["playerRating"], + "lastGameId": profile["lastGameId"], + "lastRomVersion": profile["lastRomVersion"], + "lastDataVersion": profile["lastDataVersion"], + "lastPlayDate": profile["lastPlayDate"], + "emoneyBrandId": 0, + "trophyId": profile["trophyId"], + # Current Selected Character + "userCharacter": chara, + # User Game Options + "playerLevel": profile["playerLevel"], + "rating": profile["rating"], + "headphone": profile["headphone"], + "chargeState": 0, + "userNameEx": "0", + "banState": 0, + "classEmblemMedal": profile["classEmblemMedal"], + "classEmblemBase": profile["classEmblemBase"], + "battleRankId": profile["battleRankId"], + } + return data1 diff --git a/titles/chuni/newplus.py b/titles/chuni/newplus.py new file mode 100644 index 0000000..c048f8a --- /dev/null +++ b/titles/chuni/newplus.py @@ -0,0 +1,23 @@ +from datetime import datetime, timedelta +from typing import Dict, Any +import pytz + +from core.config import CoreConfig +from titles.chuni.new import ChuniNew +from titles.chuni.const import ChuniConstants +from titles.chuni.config import ChuniConfig + +class ChuniNewPlus(ChuniNew): + def __init__(self, core_cfg: CoreConfig, game_cfg: ChuniConfig) -> None: + super().__init__(core_cfg, game_cfg) + self.version = ChuniConstants.VER_CHUNITHM_NEW_PLUS + + def handle_get_game_setting_api_request(self, data: Dict) -> Dict: + ret = super().handle_get_game_setting_api_request(data) + ret["gameSetting"]["romVersion"] = "2.05.00" + ret["gameSetting"]["dataVersion"] = "2.05.00" + ret["gameSetting"]["matchingUri"] = f"http://{self.core_cfg.server.hostname}:{self.core_cfg.title.port}/SDHD/205/ChuniServlet/" + ret["gameSetting"]["matchingUriX"] = f"http://{self.core_cfg.server.hostname}:{self.core_cfg.title.port}/SDHD/205/ChuniServlet/" + ret["gameSetting"]["udpHolePunchUri"] = f"http://{self.core_cfg.server.hostname}:{self.core_cfg.title.port}/SDHD/205/ChuniServlet/" + ret["gameSetting"]["reflectorUri"] = f"http://{self.core_cfg.server.hostname}:{self.core_cfg.title.port}/SDHD/205/ChuniServlet/" + return ret diff --git a/titles/chuni/paradise.py b/titles/chuni/paradise.py new file mode 100644 index 0000000..19e92ca --- /dev/null +++ b/titles/chuni/paradise.py @@ -0,0 +1,18 @@ +from datetime import datetime, timedelta +from typing import Dict, Any +import pytz + +from core.config import CoreConfig +from titles.chuni.base import ChuniBase +from titles.chuni.const import ChuniConstants +from titles.chuni.config import ChuniConfig + +class ChuniParadise(ChuniBase): + def __init__(self, core_cfg: CoreConfig, game_cfg: ChuniConfig) -> None: + super().__init__(core_cfg, game_cfg) + self.version = ChuniConstants.VER_CHUNITHM_PARADISE + + def handle_get_game_setting_api_request(self, data: Dict) -> Dict: + ret = super().handle_get_game_setting_api_request(data) + ret["gameSetting"]["dataVersion"] = "1.50.00" + return ret diff --git a/titles/chuni/plus.py b/titles/chuni/plus.py new file mode 100644 index 0000000..492d4f6 --- /dev/null +++ b/titles/chuni/plus.py @@ -0,0 +1,16 @@ +from typing import Dict + +from core.config import CoreConfig +from titles.chuni.base import ChuniBase +from titles.chuni.const import ChuniConstants +from titles.chuni.config import ChuniConfig + +class ChuniPlus(ChuniBase): + def __init__(self, core_cfg: CoreConfig, game_cfg: ChuniConfig) -> None: + super().__init__(core_cfg, game_cfg) + self.version = ChuniConstants.VER_CHUNITHM_PLUS + + def handle_get_game_setting_api_request(self, data: Dict) -> Dict: + ret = super().handle_get_game_setting_api_request(data) + ret["gameSetting"]["dataVersion"] = "1.05.00" + return ret \ No newline at end of file diff --git a/titles/chuni/read.py b/titles/chuni/read.py new file mode 100644 index 0000000..dd67c03 --- /dev/null +++ b/titles/chuni/read.py @@ -0,0 +1,157 @@ +from typing import Optional +from os import walk, path +import xml.etree.ElementTree as ET +from read import BaseReader + +from core.config import CoreConfig +from titles.chuni.database import ChuniData +from titles.chuni.const import ChuniConstants + +class ChuniReader(BaseReader): + def __init__(self, config: CoreConfig, version: int, bin_dir: Optional[str], opt_dir: Optional[str], extra: Optional[str]) -> None: + super().__init__(config, version, bin_dir, opt_dir, extra) + self.data = ChuniData(config) + + try: + self.logger.info(f"Start importer for {ChuniConstants.game_ver_to_string(version)}") + except IndexError: + self.logger.error(f"Invalid chunithm version {version}") + exit(1) + + def read(self) -> None: + data_dirs = [] + if self.bin_dir is not None: + data_dirs += self.get_data_directories(self.bin_dir) + + if self.opt_dir is not None: + data_dirs += self.get_data_directories(self.opt_dir) + + for dir in data_dirs: + self.logger.info(f"Read from {dir}") + self.read_events(f"{dir}/event") + self.read_music(f"{dir}/music") + self.read_charges(f"{dir}/chargeItem") + self.read_avatar(f"{dir}/avatarAccessory") + + def read_events(self, evt_dir: str) -> None: + for root, dirs, files in walk(evt_dir): + for dir in dirs: + if path.exists(f"{root}/{dir}/Event.xml"): + with open(f"{root}/{dir}/Event.xml", 'rb') as fp: + bytedata = fp.read() + strdata = bytedata.decode('UTF-8') + + xml_root = ET.fromstring(strdata) + for name in xml_root.findall('name'): + id = name.find('id').text + name = name.find('str').text + for substances in xml_root.findall('substances'): + event_type = substances.find('type').text + + result = self.data.static.put_event(self.version, id, event_type, name) + if result is not None: + self.logger.info(f"Inserted event {id}") + else: + self.logger.warn(f"Failed to insert event {id}") + + def read_music(self, music_dir: str) -> None: + for root, dirs, files in walk(music_dir): + for dir in dirs: + if path.exists(f"{root}/{dir}/Music.xml"): + with open(f"{root}/{dir}/Music.xml", 'rb') as fp: + bytedata = fp.read() + strdata = bytedata.decode('UTF-8') + + xml_root = ET.fromstring(strdata) + for name in xml_root.findall('name'): + song_id = name.find('id').text + title = name.find('str').text + + for artistName in xml_root.findall('artistName'): + artist = artistName.find('str').text + + for genreNames in xml_root.findall('genreNames'): + for list_ in genreNames.findall('list'): + for StringID in list_.findall('StringID'): + genre = StringID.find('str').text + + for jaketFile in xml_root.findall('jaketFile'): #nice typo, SEGA + jacket_path = jaketFile.find('path').text + + for fumens in xml_root.findall('fumens'): + for MusicFumenData in fumens.findall('MusicFumenData'): + fumen_path = MusicFumenData.find('file').find("path") + + if fumen_path.text is not None: + chart_id = MusicFumenData.find('type').find('id').text + if chart_id == "4": + level = float(xml_root.find("starDifType").text) + we_chara = xml_root.find("worldsEndTagName").find("str").text + else: + level = float(f"{MusicFumenData.find('level').text}.{MusicFumenData.find('levelDecimal').text}") + we_chara = None + + result = self.data.static.put_music( + self.version, + song_id, + chart_id, + title, + artist, + level, + genre, + jacket_path, + we_chara + ) + + if result is not None: + self.logger.info(f"Inserted music {song_id} chart {chart_id}") + else: + self.logger.warn(f"Failed to insert music {song_id} chart {chart_id}") + + def read_charges(self, charge_dir: str) -> None: + for root, dirs, files in walk(charge_dir): + for dir in dirs: + if path.exists(f"{root}/{dir}/ChargeItem.xml"): + with open(f"{root}/{dir}/ChargeItem.xml", 'rb') as fp: + bytedata = fp.read() + strdata = bytedata.decode('UTF-8') + + xml_root = ET.fromstring(strdata) + for name in xml_root.findall('name'): + id = name.find('id').text + name = name.find('str').text + expirationDays = xml_root.find('expirationDays').text + consumeType = xml_root.find('consumeType').text + sellingAppeal = bool(xml_root.find('sellingAppeal').text) + + result = self.data.static.put_charge(self.version, id, name, expirationDays, consumeType, sellingAppeal) + + if result is not None: + self.logger.info(f"Inserted charge {id}") + else: + self.logger.warn(f"Failed to insert charge {id}") + + def read_avatar(self, avatar_dir: str) -> None: + for root, dirs, files in walk(avatar_dir): + for dir in dirs: + if path.exists(f"{root}/{dir}/AvatarAccessory.xml"): + with open(f"{root}/{dir}/AvatarAccessory.xml", 'rb') as fp: + bytedata = fp.read() + strdata = bytedata.decode('UTF-8') + + xml_root = ET.fromstring(strdata) + for name in xml_root.findall('name'): + id = name.find('id').text + name = name.find('str').text + category = xml_root.find('category').text + for image in xml_root.findall('image'): + iconPath = image.find('path').text + for texture in xml_root.findall('texture'): + texturePath = texture.find('path').text + + result = self.data.static.put_avatar(self.version, id, name, category, iconPath, texturePath) + + if result is not None: + self.logger.info(f"Inserted avatarAccessory {id}") + else: + self.logger.warn(f"Failed to insert avatarAccessory {id}") diff --git a/titles/chuni/schema/__init__.py b/titles/chuni/schema/__init__.py new file mode 100644 index 0000000..18c408e --- /dev/null +++ b/titles/chuni/schema/__init__.py @@ -0,0 +1,6 @@ +from titles.chuni.schema.profile import ChuniProfileData +from titles.chuni.schema.score import ChuniScoreData +from titles.chuni.schema.item import ChuniItemData +from titles.chuni.schema.static import ChuniStaticData + +__all__ = ["ChuniProfileData", "ChuniScoreData", "ChuniItemData", "ChuniStaticData"] \ No newline at end of file diff --git a/titles/chuni/schema/item.py b/titles/chuni/schema/item.py new file mode 100644 index 0000000..6973558 --- /dev/null +++ b/titles/chuni/schema/item.py @@ -0,0 +1,207 @@ +from typing import Dict, List, Optional +from sqlalchemy import Table, Column, UniqueConstraint, PrimaryKeyConstraint, and_ +from sqlalchemy.types import Integer, String, TIMESTAMP, Boolean, JSON +from sqlalchemy.engine.base import Connection +from sqlalchemy.schema import ForeignKey +from sqlalchemy.sql import func, select +from sqlalchemy.dialects.mysql import insert +from sqlalchemy.engine import Row + +from core.data.schema import BaseData, metadata + +character = Table( + "chuni_item_character", + metadata, + Column("id", Integer, primary_key=True, nullable=False), + Column("user", ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade"), nullable=False), + Column("characterId", Integer), + Column("level", Integer), + Column("param1", Integer), + Column("param2", Integer), + Column("isValid", Boolean), + Column("skillId", Integer), + Column("isNewMark", Boolean), + Column("playCount", Integer), + Column("friendshipExp", Integer), + Column("assignIllust", Integer), + Column("exMaxLv", Integer), + UniqueConstraint("user", "characterId", name="chuni_item_character_uk"), + mysql_charset='utf8mb4' +) + +item = Table( + "chuni_item_item", + metadata, + Column("id", Integer, primary_key=True, nullable=False), + Column("user", ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade"), nullable=False), + Column("itemId", Integer), + Column("itemKind", Integer), + Column("stock", Integer), + Column("isValid", Boolean), + UniqueConstraint("user", "itemId", "itemKind", name="chuni_item_item_uk"), + mysql_charset='utf8mb4' +) + +duel = Table( + "chuni_item_duel", + metadata, + Column("id", Integer, primary_key=True, nullable=False), + Column("user", ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade"), nullable=False), + Column("duelId", Integer), + Column("progress", Integer), + Column("point", Integer), + Column("isClear", Boolean), + Column("lastPlayDate", String(25)), + Column("param1", Integer), + Column("param2", Integer), + Column("param3", Integer), + Column("param4", Integer), + UniqueConstraint("user", "duelId", name="chuni_item_duel_uk"), + mysql_charset='utf8mb4' +) + +map = Table( + "chuni_item_map", + metadata, + Column("id", Integer, primary_key=True, nullable=False), + Column("user", ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade"), nullable=False), + Column("mapId", Integer), + Column("position", Integer), + Column("isClear", Boolean), + Column("areaId", Integer), + Column("routeNumber", Integer), + Column("eventId", Integer), + Column("rate", Integer), + Column("statusCount", Integer), + Column("isValid", Boolean), + UniqueConstraint("user", "mapId", name="chuni_item_map_uk"), + mysql_charset='utf8mb4' +) + +map_area = Table( + "chuni_item_map_area", + metadata, + Column("id", Integer, primary_key=True, nullable=False), + Column("user", ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade"), nullable=False), + Column("mapAreaId", Integer), + Column("rate", Integer), + Column("isClear", Boolean), + Column("isLocked", Boolean), + Column("position", Integer), + Column("statusCount", Integer), + Column("remainGridCount", Integer), + UniqueConstraint("user", "mapAreaId", name="chuni_item_map_area_uk"), + mysql_charset='utf8mb4' +) + +class ChuniItemData(BaseData): + def put_character(self, user_id: int, character_data: Dict) -> Optional[int]: + character_data["user"] = user_id + + character_data = self.fix_bools(character_data) + + sql = insert(character).values(**character_data) + conflict = sql.on_duplicate_key_update(**character_data) + + result = self.execute(conflict) + if result is None: return None + return result.lastrowid + + def get_character(self, user_id: int, character_id: int) -> Optional[Dict]: + sql = select(character).where(and_( + character.c.user == user_id, + character.c.characterId == character_id + )) + + result = self.execute(sql) + if result is None: return None + return result.fetchone() + + def get_characters(self, user_id: int) -> Optional[List[Row]]: + sql = select(character).where(character.c.user == user_id) + + result = self.execute(sql) + if result is None: return None + return result.fetchall() + + def put_item(self, user_id: int, item_data: Dict) -> Optional[int]: + item_data["user"] = user_id + + item_data = self.fix_bools(item_data) + + sql = insert(item).values(**item_data) + conflict = sql.on_duplicate_key_update(**item_data) + + result = self.execute(conflict) + if result is None: return None + return result.lastrowid + + def get_items(self, user_id: int, kind: int = None) -> Optional[List[Row]]: + if kind is None: + sql = select(item).where(item.c.user == user_id) + else: + sql = select(item).where(and_( + item.c.user == user_id, + item.c.itemKind == kind + )) + + result = self.execute(sql) + if result is None: return None + return result.fetchall() + + def put_duel(self, user_id: int, duel_data: Dict) -> Optional[int]: + duel_data["user"] = user_id + + duel_data = self.fix_bools(duel_data) + + sql = insert(duel).values(**duel_data) + conflict = sql.on_duplicate_key_update(**duel_data) + + result = self.execute(conflict) + if result is None: return None + return result.lastrowid + + def get_duels(self, user_id: int) -> Optional[List[Row]]: + sql = select(duel).where(duel.c.user == user_id) + + result = self.execute(sql) + if result is None: return None + return result.fetchall() + + def put_map(self, user_id: int, map_data: Dict) -> Optional[int]: + map_data["user"] = user_id + + map_data = self.fix_bools(map_data) + + sql = insert(map).values(**map_data) + conflict = sql.on_duplicate_key_update(**map_data) + + result = self.execute(conflict) + if result is None: return None + return result.lastrowid + + def get_maps(self, user_id: int) -> Optional[List[Row]]: + sql = select(map).where(map.c.user == user_id) + + result = self.execute(sql) + if result is None: return None + return result.fetchall() + + def put_map_area(self, user_id: int, map_area_data: Dict) -> Optional[int]: + map_area_data["user"] = user_id + + map_area_data = self.fix_bools(map_area_data) + + sql = insert(map_area).values(**map_area_data) + conflict = sql.on_duplicate_key_update(**map_area_data) + + result = self.execute(conflict) + if result is None: return None + return result.lastrowid + + def get_map_areas(self, user_id: int) -> Optional[List[Row]]: + sql = select(map_area).where(map_area.c.user == user_id) + + result = self.execute(sql) + if result is None: return None + return result.fetchall() \ No newline at end of file diff --git a/titles/chuni/schema/profile.py b/titles/chuni/schema/profile.py new file mode 100644 index 0000000..f23f54d --- /dev/null +++ b/titles/chuni/schema/profile.py @@ -0,0 +1,551 @@ +from typing import Dict, List, Optional +from sqlalchemy import Table, Column, UniqueConstraint, PrimaryKeyConstraint, and_ +from sqlalchemy.types import Integer, String, TIMESTAMP, Boolean, JSON, BigInteger +from sqlalchemy.engine.base import Connection +from sqlalchemy.schema import ForeignKey +from sqlalchemy.engine import Row +from sqlalchemy.sql import func, select +from sqlalchemy.dialects.mysql import insert + +from core.data.schema import BaseData, metadata + +profile = Table( + "chuni_profile_data", + metadata, + Column("id", Integer, primary_key=True, nullable=False), + Column("user", ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade"), nullable=False), + Column("version", Integer, nullable=False), + Column("exp", Integer), + Column("level", Integer), + Column("point", Integer), + Column("frameId", Integer), + Column("isMaimai", Boolean), + Column("trophyId", Integer), + Column("userName", String(25)), + Column("isWebJoin", Boolean), + Column("playCount", Integer), + Column("lastGameId", String(25)), + Column("totalPoint", BigInteger), + Column("characterId", Integer), + Column("firstGameId", String(25)), + Column("friendCount", Integer), + Column("lastPlaceId", Integer), + Column("nameplateId", Integer), + Column("totalMapNum", Integer), + Column("lastAllNetId", Integer), + Column("lastClientId", String(25)), + Column("lastPlayDate", String(25)), + Column("lastRegionId", Integer), + Column("playerRating", Integer), + Column("totalHiScore", Integer), + Column("webLimitDate", String(25)), + Column("firstPlayDate", String(25)), + Column("highestRating", Integer), + Column("lastPlaceName", String(25)), + Column("multiWinCount", Integer), + Column("acceptResCount", Integer), + Column("lastRegionName", String(25)), + Column("lastRomVersion", String(25)), + Column("multiPlayCount", Integer), + Column("firstRomVersion", String(25)), + Column("lastDataVersion", String(25)), + Column("requestResCount", Integer), + Column("successResCount", Integer), + Column("eventWatchedDate", String(25)), + Column("firstDataVersion", String(25)), + Column("reincarnationNum", Integer), + Column("playedTutorialBit", Integer), + Column("totalBasicHighScore", Integer), + Column("totalExpertHighScore", Integer), + Column("totalMasterHighScore", Integer), + Column("totalRepertoireCount", Integer), + Column("firstTutorialCancelNum", Integer), + Column("totalAdvancedHighScore", Integer), + Column("masterTutorialCancelNum", Integer), + Column("ext1", Integer), # Added in chunew + Column("ext2", Integer), + Column("ext3", Integer), + Column("ext4", Integer), + Column("ext5", Integer), + Column("ext6", Integer), + Column("ext7", Integer), + Column("ext8", Integer), + Column("ext9", Integer), + Column("ext10", Integer), + Column("extStr1", String(255)), + Column("extStr2", String(255)), + Column("extLong1", Integer), + Column("extLong2", Integer), + Column("mapIconId", Integer), + Column("compatibleCmVersion", String(25)), + Column("medal", Integer), + Column("voiceId", Integer), + Column("teamId", Integer, ForeignKey("chuni_profile_team.id", ondelete="SET NULL", onupdate="SET NULL")), + Column("avatarBack", Integer, server_default="0"), + Column("avatarFace", Integer, server_default="0"), + Column("eliteRankPoint", Integer, server_default="0"), + Column("stockedGridCount", Integer, server_default="0"), + Column("netBattleLoseCount", Integer, server_default="0"), + Column("netBattleHostErrCnt", Integer, server_default="0"), + Column("netBattle4thCount", Integer, server_default="0"), + Column("overPowerRate", Integer, server_default="0"), + Column("battleRewardStatus", Integer, server_default="0"), + Column("avatarPoint", Integer, server_default="0"), + Column("netBattle1stCount", Integer, server_default="0"), + Column("charaIllustId", Integer, server_default="0"), + Column("avatarItem", Integer, server_default="0"), + Column("userNameEx", String(8), server_default=""), + Column("netBattleWinCount", Integer, server_default="0"), + Column("netBattleCorrection", Integer, server_default="0"), + Column("classEmblemMedal", Integer, server_default="0"), + Column("overPowerPoint", Integer, server_default="0"), + Column("netBattleErrCnt", Integer, server_default="0"), + Column("battleRankId", Integer, server_default="0"), + Column("netBattle3rdCount", Integer, server_default="0"), + Column("netBattleConsecutiveWinCount", Integer, server_default="0"), + Column("overPowerLowerRank", Integer, server_default="0"), + Column("avatarWear", Integer, server_default="0"), + Column("classEmblemBase", Integer, server_default="0"), + Column("battleRankPoint", Integer, server_default="0"), + Column("netBattle2ndCount", Integer, server_default="0"), + Column("totalUltimaHighScore", Integer, server_default="0"), + Column("skillId", Integer, server_default="0"), + Column("lastCountryCode", String(5), server_default="JPN"), + Column("isNetBattleHost", Boolean, server_default="0"), + Column("avatarFront", Integer, server_default="0"), + Column("avatarSkin", Integer, server_default="0"), + Column("battleRewardCount", Integer, server_default="0"), + Column("battleRewardIndex", Integer, server_default="0"), + Column("netBattlePlayCount", Integer, server_default="0"), + Column("exMapLoopCount", Integer, server_default="0"), + Column("netBattleEndState", Integer, server_default="0"), + Column("avatarHead", Integer, server_default="0"), + UniqueConstraint("user", "version", name="chuni_profile_profile_uk"), + mysql_charset='utf8mb4' +) + +profile_ex = Table( + "chuni_profile_data_ex", + metadata, + Column("id", Integer, primary_key=True, nullable=False), + Column("user", ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade"), nullable=False), + Column("version", Integer, nullable=False), + Column("ext1", Integer), + Column("ext2", Integer), + Column("ext3", Integer), + Column("ext4", Integer), + Column("ext5", Integer), + Column("ext6", Integer), + Column("ext7", Integer), + Column("ext8", Integer), + Column("ext9", Integer), + Column("ext10", Integer), + Column("ext11", Integer), + Column("ext12", Integer), + Column("ext13", Integer), + Column("ext14", Integer), + Column("ext15", Integer), + Column("ext16", Integer), + Column("ext17", Integer), + Column("ext18", Integer), + Column("ext19", Integer), + Column("ext20", Integer), + Column("medal", Integer), + Column("extStr1", String(255)), + Column("extStr2", String(255)), + Column("extStr3", String(255)), + Column("extStr4", String(255)), + Column("extStr5", String(255)), + Column("voiceId", Integer), + Column("extLong1", Integer), + Column("extLong2", Integer), + Column("extLong3", Integer), + Column("extLong4", Integer), + Column("extLong5", Integer), + Column("mapIconId", Integer), + Column("compatibleCmVersion", String(25)), + UniqueConstraint("user", "version", name="chuni_profile_data_ex_uk"), + mysql_charset='utf8mb4' +) + +option = Table( + "chuni_profile_option", + metadata, + Column("id", Integer, primary_key=True, nullable=False), + Column("user", ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade"), nullable=False), + Column("speed", Integer), + Column("bgInfo", Integer), + Column("rating", Integer), + Column("privacy", Integer), + Column("judgePos", Integer), + Column("matching", Integer), + Column("guideLine", Integer), + Column("headphone", Integer), + Column("optionSet", Integer), + Column("fieldColor", Integer), + Column("guideSound", Integer), + Column("successAir", Integer), + Column("successTap", Integer), + Column("judgeAttack", Integer), + Column("playerLevel", Integer), + Column("soundEffect", Integer), + Column("judgeJustice", Integer), + Column("successExTap", Integer), + Column("successFlick", Integer), + Column("successSkill", Integer), + Column("successSlideHold", Integer), + Column("successTapTimbre", Integer), + Column("ext1", Integer), # Added in chunew + Column("ext2", Integer), + Column("ext3", Integer), + Column("ext4", Integer), + Column("ext5", Integer), + Column("ext6", Integer), + Column("ext7", Integer), + Column("ext8", Integer), + Column("ext9", Integer), + Column("ext10", Integer), + Column("categoryDetail", Integer, server_default="0"), + Column("judgeTimingOffset_120", Integer, server_default="0"), + Column("resultVoiceShort", Integer, server_default="0"), + Column("judgeAppendSe", Integer, server_default="0"), + Column("judgeCritical", Integer, server_default="0"), + Column("trackSkip", Integer, server_default="0"), + Column("selectMusicFilterLv", Integer, server_default="0"), + Column("sortMusicFilterLv", Integer, server_default="0"), + Column("sortMusicGenre", Integer, server_default="0"), + Column("speed_120", Integer, server_default="0"), + Column("judgeTimingOffset", Integer, server_default="0"), + Column("mirrorFumen", Integer, server_default="0"), + Column("playTimingOffset_120", Integer, server_default="0"), + Column("hardJudge", Integer, server_default="0"), + Column("notesThickness", Integer, server_default="0"), + Column("fieldWallPosition", Integer, server_default="0"), + Column("playTimingOffset", Integer, server_default="0"), + Column("fieldWallPosition_120", Integer, server_default="0"), + UniqueConstraint("user", name="chuni_profile_option_uk"), + mysql_charset='utf8mb4' +) + +option_ex = Table( + "chuni_profile_option_ex", + metadata, + Column("id", Integer, primary_key=True, nullable=False), + Column("user", ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade"), nullable=False), + Column("ext1", Integer), + Column("ext2", Integer), + Column("ext3", Integer), + Column("ext4", Integer), + Column("ext5", Integer), + Column("ext6", Integer), + Column("ext7", Integer), + Column("ext8", Integer), + Column("ext9", Integer), + Column("ext10", Integer), + Column("ext11", Integer), + Column("ext12", Integer), + Column("ext13", Integer), + Column("ext14", Integer), + Column("ext15", Integer), + Column("ext16", Integer), + Column("ext17", Integer), + Column("ext18", Integer), + Column("ext19", Integer), + Column("ext20", Integer), + UniqueConstraint("user", name="chuni_profile_option_ex_uk"), + mysql_charset='utf8mb4' +) + +recent_rating = Table( + "chuni_profile_recent_rating", + metadata, + Column("id", Integer, primary_key=True, nullable=False), + Column("user", ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade"), nullable=False), + Column("recentRating", JSON), + UniqueConstraint("user", name="chuni_profile_recent_rating_uk"), + mysql_charset='utf8mb4' +) + +region = Table( + "chuni_profile_region", + metadata, + Column("id", Integer, primary_key=True, nullable=False), + Column("user", ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade"), nullable=False), + Column("regionId", Integer), + Column("playCount", Integer), + UniqueConstraint("user", "regionId", name="chuni_profile_region_uk"), + mysql_charset='utf8mb4' +) + +activity = Table( + "chuni_profile_activity", + metadata, + Column("id", Integer, primary_key=True, nullable=False), + Column("user", ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade"), nullable=False), + Column("kind", Integer), + Column("activityId", Integer), # Reminder: Change this to ID in base.py or the game will be sad + Column("sortNumber", Integer), + Column("param1", Integer), + Column("param2", Integer), + Column("param3", Integer), + Column("param4", Integer), + UniqueConstraint("user", "kind", "activityId", name="chuni_profile_activity_uk"), + mysql_charset='utf8mb4' +) + +charge = Table( + "chuni_profile_charge", + metadata, + Column("id", Integer, primary_key=True, nullable=False), + Column("user", ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade"), nullable=False), + Column("chargeId", Integer), + Column("stock", Integer), + Column("purchaseDate", String(25)), + Column("validDate", String(25)), + Column("param1", Integer), + Column("param2", Integer), + Column("paramDate", String(25)), + UniqueConstraint("user", "chargeId", name="chuni_profile_charge_uk"), + mysql_charset='utf8mb4' +) + +emoney = Table( + "chuni_profile_emoney", + metadata, + Column("id", Integer, primary_key=True, nullable=False), + Column("user", ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade"), nullable=False), + Column("ext1", Integer), + Column("ext2", Integer), + Column("ext3", Integer), + Column("type", Integer), + Column("emoneyBrand", Integer), + Column("emoneyCredit", Integer), + UniqueConstraint("user", "emoneyBrand", name="chuni_profile_emoney_uk"), + mysql_charset='utf8mb4' +) + +overpower = Table( + "chuni_profile_overpower", + metadata, + Column("id", Integer, primary_key=True, nullable=False), + Column("user", ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade"), nullable=False), + Column("genreId", Integer), + Column("difficulty", Integer), + Column("rate", Integer), + Column("point", Integer), + UniqueConstraint("user", "genreId", "difficulty", name="chuni_profile_emoney_uk"), + mysql_charset='utf8mb4' +) + +team = Table( + "chuni_profile_team", + metadata, + Column("id", Integer, primary_key=True, nullable=False), + Column("teamName", String(255)), + Column("teamPoint", Integer), + mysql_charset='utf8mb4' +) + +class ChuniProfileData(BaseData): + def put_profile_data(self, aime_id: int, version: int, profile_data: Dict) -> Optional[int]: + profile_data["user"] = aime_id + profile_data["version"] = version + if "accessCode" in profile_data: + profile_data.pop("accessCode") + + profile_data = self.fix_bools(profile_data) + + sql = insert(profile).values(**profile_data) + conflict = sql.on_duplicate_key_update(**profile_data) + result = self.execute(conflict) + + if result is None: + self.logger.warn(f"put_profile_data: Failed to update! aime_id: {aime_id}") + return None + return result.lastrowid + + def get_profile_preview(self, aime_id: int, version: int) -> Optional[Row]: + sql = select([profile, option]).join(option, profile.c.user == option.c.user).filter( + and_(profile.c.user == aime_id, profile.c.version == version) + ) + + result = self.execute(sql) + if result is None: return None + return result.fetchone() + + def get_profile_data(self, aime_id: int, version: int) -> Optional[Row]: + sql = select(profile).where(and_( + profile.c.user == aime_id, + profile.c.version == version, + )) + + result = self.execute(sql) + if result is None: return None + return result.fetchone() + + def put_profile_data_ex(self, aime_id: int, version: int, profile_ex_data: Dict) -> Optional[int]: + profile_ex_data["user"] = aime_id + profile_ex_data["version"] = version + if "accessCode" in profile_ex_data: + profile_ex_data.pop("accessCode") + + sql = insert(profile_ex).values(**profile_ex_data) + conflict = sql.on_duplicate_key_update(**profile_ex_data) + result = self.execute(conflict) + + if result is None: + self.logger.warn(f"put_profile_data_ex: Failed to update! aime_id: {aime_id}") + return None + return result.lastrowid + + def get_profile_data_ex(self, aime_id: int, version: int) -> Optional[Row]: + sql = select(profile_ex).where(and_( + profile_ex.c.user == aime_id, + profile_ex.c.version == version, + )) + + result = self.execute(sql) + if result is None: return None + return result.fetchone() + + def put_profile_option(self, aime_id: int, option_data: Dict) -> Optional[int]: + option_data["user"] = aime_id + + sql = insert(option).values(**option_data) + conflict = sql.on_duplicate_key_update(**option_data) + result = self.execute(conflict) + + if result is None: + self.logger.warn(f"put_profile_option: Failed to update! aime_id: {aime_id}") + return None + return result.lastrowid + + def get_profile_option(self, aime_id: int) -> Optional[Row]: + sql = select(option).where(option.c.user == aime_id) + + result = self.execute(sql) + if result is None: return None + return result.fetchone() + + def put_profile_option_ex(self, aime_id: int, option_ex_data: Dict) -> Optional[int]: + option_ex_data["user"] = aime_id + + sql = insert(option_ex).values(**option_ex_data) + conflict = sql.on_duplicate_key_update(**option_ex_data) + result = self.execute(conflict) + + if result is None: + self.logger.warn(f"put_profile_option_ex: Failed to update! aime_id: {aime_id}") + return None + return result.lastrowid + + def get_profile_option_ex(self, aime_id: int) -> Optional[Row]: + sql = select(option_ex).where(option_ex.c.user == aime_id) + + result = self.execute(sql) + if result is None: return None + return result.fetchone() + + def put_profile_recent_rating(self, aime_id: int, recent_rating_data: List[Dict]) -> Optional[int]: + sql = insert(recent_rating).values( + user = aime_id, + recentRating = recent_rating_data + ) + conflict = sql.on_duplicate_key_update(recentRating = recent_rating_data) + + result = self.execute(conflict) + if result is None: + self.logger.warn(f"put_profile_recent_rating: Failed to update! aime_id: {aime_id}") + return None + return result.lastrowid + + def get_profile_recent_rating(self, aime_id: int) -> Optional[Row]: + sql = select(recent_rating).where(recent_rating.c.user == aime_id) + + result = self.execute(sql) + if result is None: return None + return result.fetchone() + + def put_profile_activity(self, aime_id: int, activity_data: Dict) -> Optional[int]: + # The game just uses "id" but we need to distinguish that from the db column "id" + activity_data["user"] = aime_id + activity_data["activityId"] = activity_data["id"] + activity_data.pop("id") + + sql = insert(activity).values(**activity_data) + conflict = sql.on_duplicate_key_update(**activity_data) + result = self.execute(conflict) + + if result is None: + self.logger.warn(f"put_profile_activity: Failed to update! aime_id: {aime_id}") + return None + return result.lastrowid + + def get_profile_activity(self, aime_id: int, kind: int) -> Optional[List[Row]]: + sql = select(activity).where(and_( + activity.c.user == aime_id, + activity.c.kind == kind + )) + + result = self.execute(sql) + if result is None: return None + return result.fetchall() + + def put_profile_charge(self, aime_id: int, charge_data: Dict) -> Optional[int]: + charge_data["user"] = aime_id + + sql = insert(charge).values(**charge_data) + conflict = sql.on_duplicate_key_update(**charge_data) + result = self.execute(conflict) + + if result is None: + self.logger.warn(f"put_profile_charge: Failed to update! aime_id: {aime_id}") + return None + return result.lastrowid + + def get_profile_charge(self, aime_id: int) -> Optional[List[Row]]: + sql = select(charge).where(charge.c.user == aime_id) + + result = self.execute(sql) + if result is None: return None + return result.fetchall() + + def add_profile_region(self, aime_id: int, region_id: int) -> Optional[int]: + pass + + def get_profile_regions(self, aime_id: int) -> Optional[List[Row]]: + pass + + def put_profile_emoney(self, aime_id: int, emoney_data: Dict) -> Optional[int]: + emoney_data["user"] = aime_id + + sql = insert(emoney).values(**emoney_data) + conflict = sql.on_duplicate_key_update(**emoney_data) + + result = self.execute(conflict) + if result is None: return None + return result.lastrowid + + def get_profile_emoney(self, aime_id: int) -> Optional[List[Row]]: + sql = select(emoney).where(emoney.c.user == aime_id) + + result = self.execute(sql) + if result is None: return None + return result.fetchall() + + def put_profile_overpower(self, aime_id: int, overpower_data: Dict) -> Optional[int]: + overpower_data["user"] = aime_id + + sql = insert(overpower).values(**overpower_data) + conflict = sql.on_duplicate_key_update(**overpower_data) + + result = self.execute(conflict) + if result is None: return None + return result.lastrowid + + def get_profile_overpower(self, aime_id: int) -> Optional[List[Row]]: + sql = select(overpower).where(overpower.c.user == aime_id) + + result = self.execute(sql) + if result is None: return None + return result.fetchall() diff --git a/titles/chuni/schema/score.py b/titles/chuni/schema/score.py new file mode 100644 index 0000000..353401f --- /dev/null +++ b/titles/chuni/schema/score.py @@ -0,0 +1,178 @@ +from typing import Dict, List, Optional +from sqlalchemy import Table, Column, UniqueConstraint, PrimaryKeyConstraint, and_ +from sqlalchemy.types import Integer, String, TIMESTAMP, Boolean, JSON, BigInteger +from sqlalchemy.engine.base import Connection +from sqlalchemy.schema import ForeignKey +from sqlalchemy.engine import Row +from sqlalchemy.sql import func, select +from sqlalchemy.dialects.mysql import insert + +from core.data.schema import BaseData, metadata + +course = Table( + "chuni_score_course", + metadata, + Column("id", Integer, primary_key=True, nullable=False), + Column("user", ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade"), nullable=False), + Column("courseId", Integer), + Column("classId", Integer), + Column("playCount", Integer), + Column("scoreMax", Integer), + Column("isFullCombo", Boolean), + Column("isAllJustice", Boolean), + Column("isSuccess", Boolean), + Column("scoreRank", Integer), + Column("eventId", Integer), + Column("lastPlayDate", String(25)), + Column("param1", Integer), + Column("param2", Integer), + Column("param3", Integer), + Column("param4", Integer), + Column("isClear", Boolean), + UniqueConstraint("user", "courseId", name="chuni_score_course_uk"), + mysql_charset='utf8mb4' +) + +best_score = Table( + "chuni_score_best", + metadata, + Column("id", Integer, primary_key=True, nullable=False), + Column("user", ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade"), nullable=False), + Column("musicId", Integer), + Column("level", Integer), + Column("playCount", Integer), + Column("scoreMax", Integer), + Column("resRequestCount", Integer), + Column("resAcceptCount", Integer), + Column("resSuccessCount", Integer), + Column("missCount", Integer), + Column("maxComboCount", Integer), + Column("isFullCombo", Boolean), + Column("isAllJustice", Boolean), + Column("isSuccess", Boolean), + Column("fullChain", Integer), + Column("maxChain", Integer), + Column("scoreRank", Integer), + Column("isLock", Boolean), + Column("ext1", Integer), + Column("theoryCount", Integer), + UniqueConstraint("user", "musicId", "level", name="chuni_score_best_uk"), + mysql_charset='utf8mb4' +) + +playlog = Table( + "chuni_score_playlog", + metadata, + Column("id", Integer, primary_key=True, nullable=False), + Column("user", ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade"), nullable=False), + Column("orderId", Integer), + Column("sortNumber", Integer), + Column("placeId", Integer), + Column("playDate", String(20)), + Column("userPlayDate", String(20)), + Column("musicId", Integer), + Column("level", Integer), + Column("customId", Integer), + Column("playedUserId1", Integer), + Column("playedUserId2", Integer), + Column("playedUserId3", Integer), + Column("playedUserName1", String(20)), + Column("playedUserName2", String(20)), + Column("playedUserName3", String(20)), + Column("playedMusicLevel1", Integer), + Column("playedMusicLevel2", Integer), + Column("playedMusicLevel3", Integer), + Column("playedCustom1", Integer), + Column("playedCustom2", Integer), + Column("playedCustom3", Integer), + Column("track", Integer), + Column("score", Integer), + Column("rank", Integer), + Column("maxCombo", Integer), + Column("maxChain", Integer), + Column("rateTap", Integer), + Column("rateHold", Integer), + Column("rateSlide", Integer), + Column("rateAir", Integer), + Column("rateFlick", Integer), + Column("judgeGuilty", Integer), + Column("judgeAttack", Integer), + Column("judgeJustice", Integer), + Column("judgeCritical", Integer), + Column("eventId", Integer), + Column("playerRating", Integer), + Column("isNewRecord", Boolean), + Column("isFullCombo", Boolean), + Column("fullChainKind", Integer), + Column("isAllJustice", Boolean), + Column("isContinue", Boolean), + Column("isFreeToPlay", Boolean), + Column("characterId", Integer), + Column("skillId", Integer), + Column("playKind", Integer), + Column("isClear", Boolean), + Column("skillLevel", Integer), + Column("skillEffect", Integer), + Column("placeName", String(255)), + Column("isMaimai", Boolean), + Column("commonId", Integer), + Column("charaIllustId", Integer), + Column("romVersion", String(255)), + Column("judgeHeaven", Integer), + mysql_charset='utf8mb4' +) + +class ChuniScoreData(BaseData): + def get_courses(self, aime_id: int) -> Optional[Row]: + sql = select(course).where(course.c.user == aime_id) + + result = self.execute(sql) + if result is None: return None + return result.fetchall() + + def put_course(self, aime_id: int, course_data: Dict) -> Optional[int]: + course_data["user"] = aime_id + course_data = self.fix_bools(course_data) + + sql = insert(course).values(**course_data) + conflict = sql.on_duplicate_key_update(**course_data) + + result = self.execute(conflict) + if result is None: return None + return result.lastrowid + + def get_scores(self, aime_id: int) -> Optional[Row]: + sql = select(best_score).where(best_score.c.user == aime_id) + + result = self.execute(sql) + if result is None: return None + return result.fetchall() + + def put_score(self, aime_id: int, score_data: Dict) -> Optional[int]: + score_data["user"] = aime_id + score_data = self.fix_bools(score_data) + + sql = insert(best_score).values(**score_data) + conflict = sql.on_duplicate_key_update(**score_data) + + result = self.execute(conflict) + if result is None: return None + return result.lastrowid + + def get_playlogs(self, aime_id: int) -> Optional[Row]: + sql = select(playlog).where(playlog.c.user == aime_id) + + result = self.execute(sql) + if result is None: return None + return result.fetchall() + + def put_playlog(self, aime_id: int, playlog_data: Dict) -> Optional[int]: + playlog_data["user"] = aime_id + playlog_data = self.fix_bools(playlog_data) + + sql = insert(playlog).values(**playlog_data) + conflict = sql.on_duplicate_key_update(**playlog_data) + + result = self.execute(conflict) + if result is None: return None + return result.lastrowid diff --git a/titles/chuni/schema/static.py b/titles/chuni/schema/static.py new file mode 100644 index 0000000..99dd3e8 --- /dev/null +++ b/titles/chuni/schema/static.py @@ -0,0 +1,223 @@ +from typing import Dict, List, Optional +from sqlalchemy import Table, Column, UniqueConstraint, PrimaryKeyConstraint, and_ +from sqlalchemy.types import Integer, String, TIMESTAMP, Boolean, JSON, Float +from sqlalchemy.engine.base import Connection +from sqlalchemy.engine import Row +from sqlalchemy.schema import ForeignKey +from sqlalchemy.sql import func, select +from sqlalchemy.dialects.mysql import insert + +from core.data.schema import BaseData, metadata + +events = Table( + "chuni_static_events", + metadata, + Column("id", Integer, primary_key=True, nullable=False), + Column("version", Integer, nullable=False), + Column("eventId", Integer), + Column("type", Integer), + Column("name", String(255)), + Column("enabled", Boolean, server_default="1"), + UniqueConstraint("version", "eventId", name="chuni_static_events_uk"), + mysql_charset='utf8mb4' +) + +music = Table( + "chuni_static_music", + metadata, + Column("id", Integer, primary_key=True, nullable=False), + Column("version", Integer, nullable=False), + Column("songId", Integer), + Column("chartId", Integer), + Column("title", String(255)), + Column("artist", String(255)), + Column("level", Float), + Column("genre", String(255)), + Column("jacketPath", String(255)), + Column("worldsEndTag", String(20)), + UniqueConstraint("version", "songId", "chartId", name="chuni_static_music_uk"), + mysql_charset='utf8mb4' +) + +charge = Table( + "chuni_static_charge", + metadata, + Column("id", Integer, primary_key=True, nullable=False), + Column("version", Integer, nullable=False), + Column("chargeId", Integer), + Column("name", String(255)), + Column("expirationDays", Integer), + Column("consumeType", Integer), + Column("sellingAppeal", Boolean), + Column("enabled", Boolean, server_default="1"), + UniqueConstraint("version", "chargeId", name="chuni_static_charge_uk"), + mysql_charset='utf8mb4' +) + +avatar = Table( + "chuni_static_avatar", + metadata, + Column("id", Integer, primary_key=True, nullable=False), + Column("version", Integer, nullable=False), + Column("avatarAccessoryId", Integer), + Column("name", String(255)), + Column("category", Integer), + Column("iconPath", String(255)), + Column("texturePath", String(255)), + UniqueConstraint("version", "avatarAccessoryId", name="chuni_static_avatar_uk"), + mysql_charset='utf8mb4' +) + +class ChuniStaticData(BaseData): + def put_event(self, version: int, event_id: int, type: int, name: str) -> Optional[int]: + sql = insert(events).values( + version = version, + eventId = event_id, + type = type, + name = name + ) + + conflict = sql.on_duplicate_key_update( + name = name + ) + + result = self.execute(conflict) + if result is None: return None + return result.lastrowid + + def update_event(self, version: int, event_id: int, enabled: bool) -> Optional[bool]: + sql = events.update(and_(events.c.version == version, events.c.eventId == event_id)).values( + enabled = enabled + ) + + result = self.execute(sql) + if result is None: + self.logger.warn(f"update_event: failed to update event! version: {version}, event_id: {event_id}, enabled: {enabled}") + return None + + event = self.get_event(version, event_id) + if event is None: + self.logger.warn(f"update_event: failed to fetch event {event_id} after updating") + return None + return event["enabled"] + + def get_event(self, version: int, event_id: int) -> Optional[Row]: + sql = select(events).where(and_(events.c.version == version, events.c.eventId == event_id)) + + result = self.execute(sql) + if result is None: return None + return result.fetchone() + + def get_enabled_events(self, version: int) -> Optional[List[Row]]: + sql = select(events).where(and_(events.c.version == version, events.c.enabled == True)) + + result = self.execute(sql) + if result is None: return None + return result.fetchall() + + def get_events(self, version: int) -> Optional[List[Row]]: + sql = select(events).where(events.c.version == version) + + result = self.execute(sql) + if result is None: return None + return result.fetchall() + + def put_music(self, version: int, song_id: int, chart_id: int, title: int, artist: str, + level: float, genre: str, jacketPath: str, we_tag: str) -> Optional[int]: + + sql = insert(music).values( + version = version, + songId = song_id, + chartId = chart_id, + title = title, + artist = artist, + level = level, + genre = genre, + jacketPath = jacketPath, + worldsEndTag = we_tag, + ) + + conflict = sql.on_duplicate_key_update( + title = title, + artist = artist, + level = level, + genre = genre, + jacketPath = jacketPath, + worldsEndTag = we_tag, + ) + + result = self.execute(conflict) + if result is None: return None + return result.lastrowid + + def put_charge(self, version: int, charge_id: int, name: str, expiration_days: int, + consume_type: int, selling_appeal: bool) -> Optional[int]: + sql = insert(charge).values( + version = version, + chargeId = charge_id, + name = name, + expirationDays = expiration_days, + consumeType = consume_type, + sellingAppeal = selling_appeal, + ) + + conflict = sql.on_duplicate_key_update( + name = name, + expirationDays = expiration_days, + consumeType = consume_type, + sellingAppeal = selling_appeal, + ) + + result = self.execute(conflict) + if result is None: return None + return result.lastrowid + + def get_enabled_charges(self, version: int) -> Optional[List[Row]]: + sql = select(charge).where(and_( + charge.c.version == version, + charge.c.enabled == True + )) + + result = self.execute(sql) + if result is None: return None + return result.fetchall() + + def get_charges(self, version: int) -> Optional[List[Row]]: + sql = select(charge).where(charge.c.version == version) + + result = self.execute(sql) + if result is None: return None + return result.fetchall() + + def get_music_chart(self, version: int, song_id: int, chart_id: int) -> Optional[List[Row]]: + sql = select(music).where(and_( + music.c.version == version, + music.c.songId == song_id, + music.c.chartId == chart_id + )) + + result = self.execute(sql) + if result is None: return None + return result.fetchone() + + def put_avatar(self, version: int, avatarAccessoryId: int, name: str, category: int, iconPath: str, texturePath: str) -> Optional[int]: + sql = insert(avatar).values( + version = version, + avatarAccessoryId = avatarAccessoryId, + name = name, + category = category, + iconPath = iconPath, + texturePath = texturePath, + ) + + conflict = sql.on_duplicate_key_update( + name = name, + category = category, + iconPath = iconPath, + texturePath = texturePath, + ) + + result = self.execute(conflict) + if result is None: return None + return result.lastrowid + diff --git a/titles/chuni/star.py b/titles/chuni/star.py new file mode 100644 index 0000000..03408dc --- /dev/null +++ b/titles/chuni/star.py @@ -0,0 +1,16 @@ +from typing import Dict + +from core.config import CoreConfig +from titles.chuni.base import ChuniBase +from titles.chuni.const import ChuniConstants +from titles.chuni.config import ChuniConfig + +class ChuniStar(ChuniBase): + def __init__(self, core_cfg: CoreConfig, game_cfg: ChuniConfig) -> None: + super().__init__(core_cfg, game_cfg) + self.version = ChuniConstants.VER_CHUNITHM_STAR + + def handle_get_game_setting_api_request(self, data: Dict) -> Dict: + ret = super().handle_get_game_setting_api_request(data) + ret["gameSetting"]["dataVersion"] = "1.20.00" + return ret \ No newline at end of file diff --git a/titles/chuni/starplus.py b/titles/chuni/starplus.py new file mode 100644 index 0000000..95000ef --- /dev/null +++ b/titles/chuni/starplus.py @@ -0,0 +1,16 @@ +from typing import Dict + +from core.config import CoreConfig +from titles.chuni.base import ChuniBase +from titles.chuni.const import ChuniConstants +from titles.chuni.config import ChuniConfig + +class ChuniStarPlus(ChuniBase): + def __init__(self, core_cfg: CoreConfig, game_cfg: ChuniConfig) -> None: + super().__init__(core_cfg, game_cfg) + self.version = ChuniConstants.VER_CHUNITHM_STAR_PLUS + + def handle_get_game_setting_api_request(self, data: Dict) -> Dict: + ret = super().handle_get_game_setting_api_request(data) + ret["gameSetting"]["dataVersion"] = "1.25.00" + return ret \ No newline at end of file diff --git a/titles/cxb/__init__.py b/titles/cxb/__init__.py new file mode 100644 index 0000000..d57dde0 --- /dev/null +++ b/titles/cxb/__init__.py @@ -0,0 +1,21 @@ +from titles.cxb.index import CxbServlet +from titles.cxb.const import CxbConstants +from titles.cxb.database import CxbData +from titles.cxb.read import CxbReader + +index = CxbServlet +database = CxbData +reader = CxbReader + +use_default_title = False +include_protocol = True +title_secure = True +game_codes = [CxbConstants.GAME_CODE] +trailing_slash = True +use_default_host = False + +include_port = True +uri = "http://$h:$p/" # If you care about the allnet response you're probably running with no SSL +host = "" + +current_schema_version = 1 \ No newline at end of file diff --git a/titles/cxb/base.py b/titles/cxb/base.py new file mode 100644 index 0000000..7b021bb --- /dev/null +++ b/titles/cxb/base.py @@ -0,0 +1,426 @@ +import logging +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 titles.cxb.config import CxbConfig +from titles.cxb.const import CxbConstants +from titles.cxb.database import CxbData + +class CxbBase(): + def __init__(self, cfg: CoreConfig, game_cfg: CxbConfig) -> None: + self.config = cfg # Config file + self.game_config = game_cfg + self.data = CxbData(cfg) # Database + self.game = CxbConstants.GAME_CODE + self.logger = logging.getLogger("cxb") + self.version = CxbConstants.VER_CROSSBEATS_REV + + def handle_action_rpreq_request(self, data: Dict) -> Dict: + return({}) + + def handle_action_hitreq_request(self, data: Dict) -> Dict: + return({"data":[]}) + + def handle_auth_usercheck_request(self, data: Dict) -> Dict: + profile = self.data.profile.get_profile_index(0, data["usercheck"]["authid"], self.version) + if profile is not None: + self.logger.info(f"User {data['usercheck']['authid']} has CXB profile") + return({"exist": "true", "logout": "true"}) + + self.logger.info(f"No profile for aime id {data['usercheck']['authid']}") + return({"exist": "false", "logout": "true"}) + + def handle_auth_entry_request(self, data: Dict) -> Dict: + self.logger.info(f"New profile for {data['entry']['authid']}") + return({"token": data["entry"]["authid"], "uid": data["entry"]["authid"]}) + + def handle_auth_login_request(self, data: Dict) -> Dict: + profile = self.data.profile.get_profile_index(0, data["login"]["authid"], self.version) + + if profile is not None: + self.logger.info(f"Login user {data['login']['authid']}") + return({"token": data["login"]["authid"], "uid": data["login"]["authid"]}) + + self.logger.warn(f"User {data['login']['authid']} does not have a profile") + return({}) + + def handle_action_loadrange_request(self, data: Dict) -> Dict: + range_start = data['loadrange']['range'][0] + range_end = data['loadrange']['range'][1] + uid = data['loadrange']['uid'] + + self.logger.info(f"Load data for {uid}") + profile = self.data.profile.get_profile(uid, self.version) + songs = self.data.score.get_best_scores(uid) + + data1 = [] + index = [] + versionindex = [] + + for profile_index in profile: + profile_data = profile_index["data"] + + if int(range_start) == 800000: + return({"index":range_start, "data":[], "version":10400}) + + if not ( int(range_start) <= int(profile_index[3]) <= int(range_end) ): + continue + #Prevent loading of the coupons within the profile to use the force unlock instead + elif 500 <= int(profile_index[3]) <= 510: + continue + #Prevent loading of songs saved in the profile + elif 100000 <= int(profile_index[3]) <= 110000: + continue + #Prevent loading of the shop list / unlocked titles & icons saved in the profile + elif 200000 <= int(profile_index[3]) <= 210000: + continue + #Prevent loading of stories in the profile + elif 900000 <= int(profile_index[3]) <= 900200: + continue + else: + index.append(profile_index[3]) + data1.append(b64encode(bytes(json.dumps(profile_data, separators=(',', ':')), 'utf-8')).decode('utf-8')) + + ''' + 100000 = Songs + 200000 = Shop + 300000 = Courses + 400000 = Events + 500000 = Challenges + 600000 = Bonuses + 700000 = rcLog + 800000 = Partners + 900000 = Stories + ''' + + # Coupons + for i in range(500,510): + index.append(str(i)) + couponid = int(i) - 500 + dataValue = [{ + "couponId":str(couponid), + "couponNum":"1", + "couponLog":[], + }] + data1.append(b64encode(bytes(json.dumps(dataValue[0], separators=(',', ':')), 'utf-8')).decode('utf-8')) + + + # ShopList_Title + for i in range(200000,201451): + index.append(str(i)) + shopid = int(i) - 200000 + dataValue = [{ + "shopId":shopid, + "shopState":"2", + "isDisable":"t", + "isDeleted":"f", + "isSpecialFlag":"f" + }] + data1.append(b64encode(bytes(json.dumps(dataValue[0], separators=(',', ':')), 'utf-8')).decode('utf-8')) + + #ShopList_Icon + for i in range(202000,202264): + index.append(str(i)) + shopid = int(i) - 200000 + dataValue = [{ + "shopId":shopid, + "shopState":"2", + "isDisable":"t", + "isDeleted":"f", + "isSpecialFlag":"f" + }] + data1.append(b64encode(bytes(json.dumps(dataValue[0], separators=(',', ':')), 'utf-8')).decode('utf-8')) + + #Stories + for i in range(900000,900003): + index.append(str(i)) + storyid = int(i) - 900000 + dataValue = [{ + "storyId":storyid, + "unlockState1":["t"] * 10, + "unlockState2":["t"] * 10, + "unlockState3":["t"] * 10, + "unlockState4":["t"] * 10, + "unlockState5":["t"] * 10, + "unlockState6":["t"] * 10, + "unlockState7":["t"] * 10, + "unlockState8":["t"] * 10, + "unlockState9":["t"] * 10, + "unlockState10":["t"] * 10, + "unlockState11":["t"] * 10, + "unlockState12":["t"] * 10, + "unlockState13":["t"] * 10, + "unlockState14":["t"] * 10, + "unlockState15":["t"] * 10, + "unlockState16":["t"] * 10 + }] + data1.append(b64encode(bytes(json.dumps(dataValue[0], separators=(',', ':')), 'utf-8')).decode('utf-8')) + + for song in songs: + song_data = song["data"] + songCode = [] + + songCode.append({ + "mcode": song_data['mcode'], + "musicState": song_data['musicState'], + "playCount": song_data['playCount'], + "totalScore": song_data['totalScore'], + "highScore": song_data['highScore'], + "everHighScore": song_data['everHighScore'] if 'everHighScore' in song_data else ["0","0","0","0","0"], + "clearRate": song_data['clearRate'], + "rankPoint": song_data['rankPoint'], + "normalCR": song_data['normalCR'] if 'normalCR' in song_data else ["0","0","0","0","0"], + "survivalCR": song_data['survivalCR'] if 'survivalCR' in song_data else ["0","0","0","0","0"], + "ultimateCR": song_data['ultimateCR'] if 'ultimateCR' in song_data else ["0","0","0","0","0"], + "nohopeCR": song_data['nohopeCR'] if 'nohopeCR' in song_data else ["0","0","0","0","0"], + "combo": song_data['combo'], + "coupleUserId": song_data['coupleUserId'], + "difficulty": song_data['difficulty'], + "isFullCombo": song_data['isFullCombo'], + "clearGaugeType": song_data['clearGaugeType'], + "fieldType": song_data['fieldType'], + "gameType": song_data['gameType'], + "grade": song_data['grade'], + "unlockState": song_data['unlockState'], + "extraState": song_data['extraState'] + }) + index.append(song_data['index']) + data1.append(b64encode(bytes(json.dumps(songCode[0], separators=(',', ':')), 'utf-8')).decode('utf-8')) + + for v in index: + try: + v_profile = self.data.profile.get_profile_index(0, uid, self.version) + v_profile_data = v_profile["data"] + versionindex.append(int(v_profile_data["appVersion"])) + except: + versionindex.append('10400') + + return({"index":index, "data":data1, "version":versionindex}) + + def handle_action_saveindex_request(self, data: Dict) -> Dict: + save_data = data['saveindex'] + + try: + #REV Omnimix Version Fetcher + gameversion = data['saveindex']['data'][0][2] + self.logger.warning(f"Game Version is {gameversion}") + except: + pass + + if "10205" in gameversion: + self.logger.info(f"Saving CrossBeats REV profile for {data['saveindex']['uid']}") + #Alright.... time to bring the jank code + + for value in data['saveindex']['data']: + + if 'playedUserId' in value[1]: + self.data.profile.put_profile(data['saveindex']['uid'], self.version, value[0], value[1]) + if 'mcode' not in value[1]: + self.data.profile.put_profile(data['saveindex']['uid'], self.version, value[0], value[1]) + if 'shopId' in value: + continue + if 'mcode' in value[1] and 'musicState' in value[1]: + song_json = json.loads(value[1]) + + songCode = [] + songCode.append({ + "mcode": song_json['mcode'], + "musicState": song_json['musicState'], + "playCount": song_json['playCount'], + "totalScore": song_json['totalScore'], + "highScore": song_json['highScore'], + "clearRate": song_json['clearRate'], + "rankPoint": song_json['rankPoint'], + "combo": song_json['combo'], + "coupleUserId": song_json['coupleUserId'], + "difficulty": song_json['difficulty'], + "isFullCombo": song_json['isFullCombo'], + "clearGaugeType": song_json['clearGaugeType'], + "fieldType": song_json['fieldType'], + "gameType": song_json['gameType'], + "grade": song_json['grade'], + "unlockState": song_json['unlockState'], + "extraState": song_json['extraState'], + "index": value[0] + }) + self.data.score.put_best_score(data['saveindex']['uid'], song_json['mcode'], self.version, value[0], songCode[0]) + return({}) + else: + self.logger.info(f"Saving CrossBeats REV Sunrise profile for {data['saveindex']['uid']}") + + #Sunrise + try: + profileIndex = save_data['index'].index('0') + except: + return({"data":""}) #Maybe + + profile = json.loads(save_data["data"][profileIndex]) + aimeId = profile["aimeId"] + i = 0 + + for index, value in enumerate(data["saveindex"]["data"]): + if int(data["saveindex"]["index"][index]) == 101: + self.data.profile.put_profile(aimeId, self.version, data["saveindex"]["index"][index], value) + if int(data["saveindex"]["index"][index]) >= 700000 and int(data["saveindex"]["index"][index])<= 701000: + self.data.profile.put_profile(aimeId, self.version, data["saveindex"]["index"][index], value) + if int(data["saveindex"]["index"][index]) >= 500 and int(data["saveindex"]["index"][index]) <= 510: + self.data.profile.put_profile(aimeId, self.version, data["saveindex"]["index"][index], value) + if 'playedUserId' in value: + self.data.profile.put_profile(aimeId, self.version, data["saveindex"]["index"][index], json.loads(value)) + if 'mcode' not in value and "normalCR" not in value: + self.data.profile.put_profile(aimeId, self.version, data["saveindex"]["index"][index], json.loads(value)) + if 'shopId' in value: + continue + + # MusicList Index for the profile + indexSongList = [] + for value in data["saveindex"]["index"]: + if int(value) in range(100000,110000): + indexSongList.append(value) + + for index, value in enumerate(data["saveindex"]["data"]): + if 'mcode' not in value: + continue + if 'playedUserId' in value: + continue + + data1 = json.loads(value) + + songCode = [] + songCode.append({ + "mcode": data1['mcode'], + "musicState": data1['musicState'], + "playCount": data1['playCount'], + "totalScore": data1['totalScore'], + "highScore": data1['highScore'], + "everHighScore": data1['everHighScore'], + "clearRate": data1['clearRate'], + "rankPoint": data1['rankPoint'], + "normalCR": data1['normalCR'], + "survivalCR": data1['survivalCR'], + "ultimateCR": data1['ultimateCR'], + "nohopeCR": data1['nohopeCR'], + "combo": data1['combo'], + "coupleUserId": data1['coupleUserId'], + "difficulty": data1['difficulty'], + "isFullCombo": data1['isFullCombo'], + "clearGaugeType": data1['clearGaugeType'], + "fieldType": data1['fieldType'], + "gameType": data1['gameType'], + "grade": data1['grade'], + "unlockState": data1['unlockState'], + "extraState": data1['extraState'], + "index": indexSongList[i] + }) + + self.data.score.put_best_score(aimeId, data1['mcode'], self.version, indexSongList[i], songCode[0]) + i += 1 + return({}) + + def handle_action_sprankreq_request(self, data: Dict) -> Dict: + uid = data['sprankreq']['uid'] + self.logger.info(f"Get best rankings for {uid}") + p = self.data.score.get_best_rankings(uid) + + rankList: list[Dict[str, Any]] = [] + + for rank in p: + if rank["song_id"] is not None: + rankList.append({ + "sc": [rank["score"],rank["song_id"]], + "rid": rank["rev_id"], + "clear": rank["clear"] + }) + else: + rankList.append({ + "sc": [rank["score"]], + "rid": rank["rev_id"], + "clear": rank["clear"] + }) + + return({ + "uid": data["sprankreq"]["uid"], + "aid": data["sprankreq"]["aid"], + "rank": rankList, + "rankx":[1,1,1] + }) + + def handle_action_getadv_request(self, data: Dict) -> Dict: + return({"data":[{"r":"1","i":"100300","c":"20"}]}) + + def handle_action_getmsg_request(self, data: Dict) -> Dict: + return({"msgs":[]}) + + def handle_auth_logout_request(self, data: Dict) -> Dict: + return({"auth":True}) + + def handle_action_rankreg_request(self, data: Dict) -> Dict: + uid = data['rankreg']['uid'] + self.logger.info(f"Put {len(data['rankreg']['data'])} rankings for {uid}") + + for rid in data['rankreg']['data']: + #REV S2 + if "clear" in rid: + try: + self.data.score.put_ranking(user_id=uid, rev_id=int(rid["rid"]), song_id=int(rid["sc"][1]), score=int(rid["sc"][0]), clear=rid["clear"]) + except: + self.data.score.put_ranking(user_id=uid, rev_id=int(rid["rid"]), song_id=0, score=int(rid["sc"][0]), clear=rid["clear"]) + #REV + else: + try: + self.data.score.put_ranking(user_id=uid, rev_id=int(rid["rid"]), song_id=int(rid["sc"][1]), score=int(rid["sc"][0]), clear=0) + except: + self.data.score.put_ranking(user_id=uid, rev_id=int(rid["rid"]), song_id=0, score=int(rid["sc"][0]), clear=0) + return({}) + + def handle_action_addenergy_request(self, data: Dict) -> Dict: + uid = data['addenergy']['uid'] + self.logger.info(f"Add energy to user {uid}") + profile = self.data.profile.get_profile_index(0, uid, self.version) + data1 = profile["data"] + p = self.data.item.get_energy(uid) + energy = p["energy"] + + if not p: + self.data.item.put_energy(uid, 5) + + return({ + "class": data1["myClass"], + "granted": "5", + "total": "5", + "threshold": "1000" + }) + + array = [] + + newenergy = int(energy) + 5 + self.data.item.put_energy(uid, newenergy) + + if int(energy) <= 995: + array.append({ + "class": data1["myClass"], + "granted": "5", + "total": str(energy), + "threshold": "1000" + }) + else: + array.append({ + "class": data1["myClass"], + "granted": "0", + "total": str(energy), + "threshold": "1000" + }) + return array[0] + + def handle_action_eventreq_request(self, data: Dict) -> Dict: + self.logger.info(data) + return {"eventreq": ""} + + def handle_action_stampreq_request(self, data: Dict) -> Dict: + self.logger.info(data) + return {"stampreq": ""} diff --git a/titles/cxb/config.py b/titles/cxb/config.py new file mode 100644 index 0000000..e83c1f1 --- /dev/null +++ b/titles/cxb/config.py @@ -0,0 +1,41 @@ +from core.config import CoreConfig + +class CxbServerConfig(): + def __init__(self, parent_config: "CxbConfig"): + self.__config = parent_config + + @property + def enable(self) -> bool: + return CoreConfig.get_config_field(self.__config, 'cxb', 'server', 'enable', default=True) + + @property + def loglevel(self) -> int: + return CoreConfig.str_to_loglevel(CoreConfig.get_config_field(self.__config, 'cxb', 'server', 'loglevel', default="info")) + + @property + def hostname(self) -> str: + return CoreConfig.get_config_field(self.__config, 'cxb', 'server', 'hostname', default="localhost") + + @property + def ssl_enable(self) -> bool: + return CoreConfig.get_config_field(self.__config, 'cxb', 'server', 'ssl_enable', default=False) + + @property + def port(self) -> int: + return CoreConfig.get_config_field(self.__config, 'cxb', 'server', 'port', default=8082) + + @property + def port_secure(self) -> int: + return CoreConfig.get_config_field(self.__config, 'cxb', 'server', 'port_secure', default=443) + + @property + def ssl_cert(self) -> str: + return CoreConfig.get_config_field(self.__config, 'cxb', 'server', 'ssl_cert', default="cert/title.crt") + + @property + def ssl_key(self) -> str: + return CoreConfig.get_config_field(self.__config, 'cxb', 'server', 'ssl_key', default="cert/title.key") + +class CxbConfig(dict): + def __init__(self) -> None: + self.server = CxbServerConfig(self) diff --git a/titles/cxb/const.py b/titles/cxb/const.py new file mode 100644 index 0000000..338b8a5 --- /dev/null +++ b/titles/cxb/const.py @@ -0,0 +1,15 @@ +class CxbConstants(): + GAME_CODE = "SDCA" + + CONFIG_NAME = "cxb.yaml" + + VER_CROSSBEATS_REV = 0 + VER_CROSSBEATS_REV_SUNRISE_S1 = 1 + VER_CROSSBEATS_REV_SUNRISE_S2 = 2 + VER_CROSSBEATS_REV_SUNRISE_S2_OMNI = 3 + + VERSION_NAMES = ("crossbeats REV.", "crossbeats REV. SUNRISE", "crossbeats REV. SUNRISE S2", "crossbeats REV. SUNRISE S2 Omnimix") + + @classmethod + def game_ver_to_string(cls, ver: int): + return cls.VERSION_NAMES[ver] \ No newline at end of file diff --git a/titles/cxb/database.py b/titles/cxb/database.py new file mode 100644 index 0000000..8fed1dc --- /dev/null +++ b/titles/cxb/database.py @@ -0,0 +1,13 @@ + +from core.data import Data +from core.config import CoreConfig +from titles.cxb.schema import CxbProfileData, CxbScoreData, CxbItemData, CxbStaticData + +class CxbData(Data): + def __init__(self, cfg: CoreConfig) -> None: + super().__init__(cfg) + + self.profile = CxbProfileData(self.config, self.session) + self.score = CxbScoreData(self.config, self.session) + self.item = CxbItemData(self.config, self.session) + self.static = CxbStaticData(self.config, self.session) diff --git a/titles/cxb/index.py b/titles/cxb/index.py new file mode 100644 index 0000000..62dc70d --- /dev/null +++ b/titles/cxb/index.py @@ -0,0 +1,145 @@ +from twisted.web.http import Request +from twisted.web import resource, server +from twisted.internet import reactor, endpoints +import yaml +import json +import re +import inflection +import logging, coloredlogs +from logging.handlers import TimedRotatingFileHandler +from typing import Dict + +from core.config import CoreConfig +from titles.cxb.config import CxbConfig +from titles.cxb.const import CxbConstants +from titles.cxb.rev import CxbRev +from titles.cxb.rss1 import CxbRevSunriseS1 +from titles.cxb.rss2 import CxbRevSunriseS2 + +class CxbServlet(resource.Resource): + def __init__(self, core_cfg: CoreConfig, cfg_dir: str) -> None: + self.isLeaf = True + self.cfg_dir = cfg_dir + self.core_cfg = core_cfg + self.game_cfg = CxbConfig() + self.game_cfg.update(yaml.safe_load(open(f"{cfg_dir}/cxb.yaml"))) + + self.logger = logging.getLogger("cxb") + log_fmt_str = "[%(asctime)s] CXB | %(levelname)s | %(message)s" + log_fmt = logging.Formatter(log_fmt_str) + fileHandler = TimedRotatingFileHandler("{0}/{1}.log".format(self.core_cfg.server.log_dir, "cxb"), encoding='utf8', + when="d", backupCount=10) + + fileHandler.setFormatter(log_fmt) + + consoleHandler = logging.StreamHandler() + consoleHandler.setFormatter(log_fmt) + + self.logger.addHandler(fileHandler) + self.logger.addHandler(consoleHandler) + + self.logger.setLevel(self.game_cfg.server.loglevel) + coloredlogs.install(level=self.game_cfg.server.loglevel, logger=self.logger, fmt=log_fmt_str) + + self.versions = [ + CxbRev(core_cfg, self.game_cfg), + CxbRevSunriseS1(core_cfg, self.game_cfg), + CxbRevSunriseS2(core_cfg, self.game_cfg), + ] + + def setup(self): + if self.game_cfg.server.enable: + endpoints.serverFromString(reactor, f"tcp:{self.game_cfg.server.port}:interface={self.core_cfg.server.listen_address}")\ + .listen(server.Site(CxbServlet(self.core_cfg, self.cfg_dir))) + + if self.core_cfg.server.is_develop and self.game_cfg.server.ssl_enable: + endpoints.serverFromString(reactor, f"ssl:{self.game_cfg.server.port_secure}"\ + f":interface={self.core_cfg.server.listen_address}:privateKey={self.game_cfg.server.ssl_key}:"\ + f"certKey={self.game_cfg.server.ssl_cert}")\ + .listen(server.Site(CxbServlet(self.core_cfg, self.cfg_dir))) + + self.logger.info(f"Crossbeats title server ready on port {self.game_cfg.server.port} & {self.game_cfg.server.port_secure}") + else: + self.logger.info(f"Crossbeats title server ready on port {self.game_cfg.server.port}") + + + def render_POST(self, request: Request): + version = 0 + internal_ver = 0 + func_to_find = "" + cmd = "" + subcmd = "" + req_url = request.uri.decode() + url_split = req_url.split("/") + req_bytes = request.content.getvalue() + + try: + req_json: Dict = json.loads(req_bytes) + + except Exception as e: + try: + req_json: Dict = json.loads(req_bytes.decode().replace('"', '\\"').replace("'", '"')) + + except Exception as f: + self.logger.warn(f"Error decoding json: {e} / {f} - {req_url} - {req_bytes}") + return b"" + + if req_json == {}: + self.logger.warn(f"Empty json request to {req_url}") + return b"" + + cmd = url_split[len(url_split) - 1] + subcmd = list(req_json.keys())[0] + + if subcmd == "dldate": + if not type(req_json["dldate"]) is dict or "filetype" not in req_json["dldate"]: + self.logger.warn(f"Malformed dldate request: {req_url} {req_json}") + return b"" + + filetype = req_json["dldate"]["filetype"] + filetype_split = filetype.split("/") + version = int(filetype_split[0]) + filetype_inflect_split = inflection.underscore(filetype).split("/") + + match = re.match("^([A-Za-z]*)(\d\d\d\d)$", filetype_split[len(filetype_split) - 1]) + if match: + subcmd = f"{inflection.underscore(match.group(1))}xxxx" + else: + subcmd = f"{filetype_inflect_split[len(filetype_inflect_split) - 1]}" + else: + filetype = subcmd + + func_to_find = f"handle_{cmd}_{subcmd}_request" + + if version <= 10102: + version_string = "Rev" + internal_ver = CxbConstants.VER_CROSSBEATS_REV + + elif version == 10113 or version == 10103: + version_string = "Rev SunriseS1" + internal_ver = CxbConstants.VER_CROSSBEATS_REV_SUNRISE_S1 + + elif version >= 10114 or version == 10104: + version_string = "Rev SunriseS2" + internal_ver = CxbConstants.VER_CROSSBEATS_REV_SUNRISE_S2 + + else: + version_string = "Base" + + self.logger.info(f"{version_string} Request {req_url} -> {filetype}") + self.logger.debug(req_json) + + try: + handler = getattr(self.versions[internal_ver], func_to_find) + resp = handler(req_json) + + except AttributeError as e: + self.logger.warning(f"Unhandled {version_string} request {req_url} - {e}") + resp = {} + + except Exception as e: + self.logger.error(f"Error handling {version_string} method {req_url} - {e}") + raise + + self.logger.debug(f"{version_string} Response {resp}") + return json.dumps(resp, ensure_ascii=False).encode("utf-8") diff --git a/titles/cxb/read.py b/titles/cxb/read.py new file mode 100644 index 0000000..6117f4e --- /dev/null +++ b/titles/cxb/read.py @@ -0,0 +1,62 @@ +from typing import Optional, Dict, List +from os import walk, path +import urllib +import csv + +from read import BaseReader +from core.config import CoreConfig +from titles.cxb.database import CxbData +from titles.cxb.const import CxbConstants + +class CxbReader(BaseReader): + def __init__(self, config: CoreConfig, version: int, bin_arg: Optional[str], opt_arg: Optional[str], extra: Optional[str]) -> None: + super().__init__(config, version, bin_arg, opt_arg, extra) + self.data = CxbData(config) + + try: + self.logger.info(f"Start importer for {CxbConstants.game_ver_to_string(version)}") + except IndexError: + self.logger.error(f"Invalid project cxb version {version}") + exit(1) + + def read(self) -> None: + pull_bin_ram = True + + if not path.exists(f"{self.bin_dir}"): + self.logger.warn(f"Couldn't find csv file in {self.bin_dir}, skipping") + pull_bin_ram = False + + if pull_bin_ram: + self.read_csv(f"{self.bin_dir}") + + def read_csv(self, bin_dir: str) -> None: + self.logger.info(f"Read csv from {bin_dir}") + + try: + fullPath = bin_dir + "/export.csv" + with open(fullPath, encoding="UTF-8") as fp: + reader = csv.DictReader(fp) + for row in reader: + song_id = row["mcode"] + index = row["index"] + title = row["name"] + artist = row["artist"] + genre = row["category"] + + if not "N/A" in row["standard"]: + self.logger.info(f"Added song {song_id} chart 0") + self.data.static.put_music(self.version, song_id, index, 0, title, artist, genre, int(row["standard"].replace("Standard ","").replace("N/A","0"))) + if not "N/A" in row["hard"]: + self.logger.info(f"Added song {song_id} chart 1") + self.data.static.put_music(self.version, song_id, index, 1, title, artist, genre, int(row["hard"].replace("Hard ","").replace("N/A","0"))) + if not "N/A" in row["master"]: + self.logger.info(f"Added song {song_id} chart 2") + self.data.static.put_music(self.version, song_id, index, 2, title, artist, genre, int(row["master"].replace("Master ","").replace("N/A","0"))) + if not "N/A" in row["unlimited"]: + self.logger.info(f"Added song {song_id} chart 3") + self.data.static.put_music(self.version, song_id, index, 3, title, artist, genre, int(row["unlimited"].replace("Unlimited ","").replace("N/A","0"))) + if not "N/A" in row["easy"]: + self.logger.info(f"Added song {song_id} chart 4") + self.data.static.put_music(self.version, song_id, index, 4, title, artist, genre, int(row["easy"].replace("Easy ","").replace("N/A","0"))) + except: + self.logger.warn(f"Couldn't read csv file in {self.bin_dir}, skipping") diff --git a/titles/cxb/rev.py b/titles/cxb/rev.py new file mode 100644 index 0000000..9a24c17 --- /dev/null +++ b/titles/cxb/rev.py @@ -0,0 +1,256 @@ +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 titles.cxb.config import CxbConfig +from titles.cxb.base import CxbBase +from titles.cxb.const import CxbConstants + +class CxbRev(CxbBase): + def __init__(self, cfg: CoreConfig, game_cfg: CxbConfig) -> None: + super().__init__(cfg, game_cfg) + self.version = CxbConstants.VER_CROSSBEATS_REV + + def handle_data_path_list_request(self, data: Dict) -> Dict: + return { "data": "" } + + def handle_data_putlog_request(self, data: Dict) -> Dict: + if data["putlog"]["type"] == "ResultLog": + score_data = json.loads(data["putlog"]["data"]) + userid = score_data['usid'] + + self.data.score.put_playlog(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"]) + return({"data":True}) + return {"data": True } + + @cached(lifetime=86400) + def handle_data_music_list_request(self, data: Dict) -> Dict: + ret_str = "" + with open(r"titles/cxb/rev_data/MusicArchiveList.csv") as music: + lines = music.readlines() + for line in lines: + 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" + + return({"data":ret_str}) + + @cached(lifetime=86400) + def handle_data_item_list_icon_request(self, data: Dict) -> Dict: + ret_str = "\r\n#ItemListIcon\r\n" + with open(r"titles/cxb/rev_data/Item/ItemArchiveList_Icon.csv", encoding="utf-8") as item: + lines = item.readlines() + for line in lines: + ret_str += f"{line[:-1]}\r\n" + return({"data":ret_str}) + + @cached(lifetime=86400) + def handle_data_item_list_skin_notes_request(self, data: Dict) -> Dict: + ret_str = "\r\n#ItemListSkinNotes\r\n" + with open(r"titles/cxb/rev_data/Item/ItemArchiveList_SkinNotes.csv", encoding="utf-8") as item: + lines = item.readlines() + for line in lines: + ret_str += f"{line[:-1]}\r\n" + return({"data":ret_str}) + + @cached(lifetime=86400) + def handle_data_item_list_skin_effect_request(self, data: Dict) -> Dict: + ret_str = "\r\n#ItemListSkinEffect\r\n" + with open(r"titles/cxb/rev_data/Item/ItemArchiveList_SkinEffect.csv", encoding="utf-8") as item: + lines = item.readlines() + for line in lines: + ret_str += f"{line[:-1]}\r\n" + return({"data":ret_str}) + + @cached(lifetime=86400) + def handle_data_item_list_skin_bg_request(self, data: Dict) -> Dict: + ret_str = "\r\n#ItemListSkinBg\r\n" + with open(r"titles/cxb/rev_data/Item/ItemArchiveList_SkinBg.csv", encoding="utf-8") as item: + lines = item.readlines() + for line in lines: + ret_str += f"{line[:-1]}\r\n" + return({"data":ret_str}) + + @cached(lifetime=86400) + def handle_data_item_list_title_request(self, data: Dict) -> Dict: + ret_str = "\r\n#ItemListTitle\r\n" + with open(r"titles/cxb/rev_data/Item/ItemList_Title.csv", encoding="shift-jis") as item: + lines = item.readlines() + for line in lines: + ret_str += f"{line[:-1]}\r\n" + return({"data":ret_str}) + + @cached(lifetime=86400) + def handle_data_shop_list_music_request(self, data: Dict) -> Dict: + ret_str = "\r\n#ShopListMusic\r\n" + with open(r"titles/cxb/rev_data/Shop/ShopList_Music.csv", encoding="shift-jis") as shop: + lines = shop.readlines() + for line in lines: + ret_str += f"{line[:-1]}\r\n" + return({"data":ret_str}) + + @cached(lifetime=86400) + def handle_data_shop_list_icon_request(self, data: Dict) -> Dict: + ret_str = "\r\n#ShopListIcon\r\n" + with open(r"titles/cxb/rev_data/Shop/ShopList_Icon.csv", encoding="shift-jis") as shop: + lines = shop.readlines() + for line in lines: + ret_str += f"{line[:-1]}\r\n" + return({"data":ret_str}) + + @cached(lifetime=86400) + def handle_data_shop_list_title_request(self, data: Dict) -> Dict: + ret_str = "\r\n#ShopListTitle\r\n" + with open(r"titles/cxb/rev_data/Shop/ShopList_Title.csv", encoding="shift-jis") as shop: + lines = shop.readlines() + for line in lines: + ret_str += f"{line[:-1]}\r\n" + return({"data":ret_str}) + + def handle_data_shop_list_skin_hud_request(self, data: Dict) -> Dict: + return({"data":""}) + + def handle_data_shop_list_skin_arrow_request(self, data: Dict) -> Dict: + return({"data":""}) + + def handle_data_shop_list_skin_hit_request(self, data: Dict) -> Dict: + return({"data":""}) + + @cached(lifetime=86400) + def handle_data_shop_list_sale_request(self, data: Dict) -> Dict: + ret_str = "\r\n#ShopListSale\r\n" + with open(r"titles/cxb/rev_data/Shop/ShopList_Sale.csv", encoding="shift-jis") as shop: + lines = shop.readlines() + for line in lines: + ret_str += f"{line[:-1]}\r\n" + return({"data":ret_str}) + + def handle_data_extra_stage_list_request(self, data: Dict) -> Dict: + return({"data":""}) + + @cached(lifetime=86400) + def handle_data_exxxxx_request(self, data: Dict) -> Dict: + extra_num = int(data["dldate"]["filetype"][-4:]) + ret_str = "" + with open(fr"titles/cxb/rev_data/Ex000{extra_num}.csv", encoding="shift-jis") as stage: + lines = stage.readlines() + for line in lines: + ret_str += f"{line[:-1]}\r\n" + return({"data":ret_str}) + + def handle_data_bonus_list10100_request(self, data: Dict) -> Dict: + return({"data": ""}) + + def handle_data_free_coupon_request(self, data: Dict) -> Dict: + return({"data": ""}) + + @cached(lifetime=86400) + def handle_data_news_list_request(self, data: Dict) -> Dict: + ret_str = "" + with open(r"titles/cxb/rev_data/NewsList.csv", encoding="UTF-8") as news: + lines = news.readlines() + for line in lines: + ret_str += f"{line[:-1]}\r\n" + return({"data":ret_str}) + + def handle_data_tips_request(self, data: Dict) -> Dict: + return({"data":""}) + + @cached(lifetime=86400) + def handle_data_license_request(self, data: Dict) -> Dict: + ret_str = "" + with open(r"titles/cxb/rev_data/License_Offline.csv", encoding="UTF-8") as lic: + lines = lic.readlines() + for line in lines: + ret_str += f"{line[:-1]}\r\n" + return({"data":ret_str}) + + @cached(lifetime=86400) + def handle_data_course_list_request(self, data: Dict) -> Dict: + ret_str = "" + with open(r"titles/cxb/rev_data/Course/CourseList.csv", encoding="UTF-8") as course: + lines = course.readlines() + for line in lines: + ret_str += f"{line[:-1]}\r\n" + return({"data":ret_str}) + + @cached(lifetime=86400) + 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 = "" + with open(fr"titles/cxb/rev_data/Course/Cs000{extra_num}.csv", encoding="shift-jis") as course: + lines = course.readlines() + for line in lines: + ret_str += f"{line[:-1]}\r\n" + return({"data":ret_str}) + + @cached(lifetime=86400) + def handle_data_mission_list_request(self, data: Dict) -> Dict: + ret_str = "" + with open(r"titles/cxb/rev_data/MissionList.csv", encoding="shift-jis") as mission: + lines = mission.readlines() + for line in lines: + ret_str += f"{line[:-1]}\r\n" + return({"data":ret_str}) + + def handle_data_mission_bonus_request(self, data: Dict) -> Dict: + return({"data": ""}) + + def handle_data_unlimited_mission_request(self, data: Dict) -> Dict: + return({"data": ""}) + + @cached(lifetime=86400) + def handle_data_event_list_request(self, data: Dict) -> Dict: + ret_str = "" + with open(r"titles/cxb/rev_data/Event/EventArchiveList.csv", encoding="shift-jis") as mission: + lines = mission.readlines() + for line in lines: + ret_str += f"{line[:-1]}\r\n" + return({"data":ret_str}) + + def handle_data_event_music_list_request(self, data: Dict) -> Dict: + return({"data": ""}) + + def handle_data_event_mission_list_request(self, data: Dict) -> Dict: + return({"data": ""}) + + def handle_data_event_achievement_single_high_score_list_request(self, data: Dict) -> Dict: + return({"data": ""}) + + def handle_data_event_achievement_single_accumulation_request(self, data: Dict) -> Dict: + return({"data": ""}) + + def handle_data_event_ranking_high_score_list_request(self, data: Dict) -> Dict: + return({"data": ""}) + + def handle_data_event_ranking_accumulation_list_request(self, data: Dict) -> Dict: + return({"data": ""}) + + def handle_data_event_ranking_stamp_list_request(self, data: Dict) -> Dict: + return({"data": ""}) + + def handle_data_event_ranking_store_list_request(self, data: Dict) -> Dict: + return({"data": ""}) + + def handle_data_event_ranking_area_list_request(self, data: Dict) -> Dict: + return({"data": ""}) + + @cached(lifetime=86400) + def handle_data_event_stamp_list_request(self, data: Dict) -> Dict: + ret_str = "" + with open(r"titles/cxb/rev_data/Event/EventStampList.csv", encoding="shift-jis") as event: + lines = event.readlines() + for line in lines: + ret_str += f"{line[:-1]}\r\n" + return({"data":ret_str}) + + def handle_data_event_stamp_map_list_csxxxx_request(self, data: Dict) -> Dict: + return({"data": "1,2,1,1,2,3,9,5,6,7,8,9,10,\r\n"}) + + def handle_data_server_state_request(self, data: Dict) -> Dict: + return({"data": True}) diff --git a/titles/cxb/rev_data/Course/CourseList.csv b/titles/cxb/rev_data/Course/CourseList.csv new file mode 100644 index 0000000..bf6a3b6 Binary files /dev/null and b/titles/cxb/rev_data/Course/CourseList.csv differ diff --git a/titles/cxb/rev_data/Course/Cs0000.csv b/titles/cxb/rev_data/Course/Cs0000.csv new file mode 100644 index 0000000..7dfcd49 Binary files /dev/null and b/titles/cxb/rev_data/Course/Cs0000.csv differ diff --git a/titles/cxb/rev_data/Course/Cs0001.csv b/titles/cxb/rev_data/Course/Cs0001.csv new file mode 100644 index 0000000..7dfcd49 Binary files /dev/null and b/titles/cxb/rev_data/Course/Cs0001.csv differ diff --git a/titles/cxb/rev_data/Course/Cs0002.csv b/titles/cxb/rev_data/Course/Cs0002.csv new file mode 100644 index 0000000..7dfcd49 Binary files /dev/null and b/titles/cxb/rev_data/Course/Cs0002.csv differ diff --git a/titles/cxb/rev_data/Course/Cs0003.csv b/titles/cxb/rev_data/Course/Cs0003.csv new file mode 100644 index 0000000..7dfcd49 Binary files /dev/null and b/titles/cxb/rev_data/Course/Cs0003.csv differ diff --git a/titles/cxb/rev_data/Course/Cs0004.csv b/titles/cxb/rev_data/Course/Cs0004.csv new file mode 100644 index 0000000..7dfcd49 Binary files /dev/null and b/titles/cxb/rev_data/Course/Cs0004.csv differ diff --git a/titles/cxb/rev_data/Course/Cs0005.csv b/titles/cxb/rev_data/Course/Cs0005.csv new file mode 100644 index 0000000..7dfcd49 Binary files /dev/null and b/titles/cxb/rev_data/Course/Cs0005.csv differ diff --git a/titles/cxb/rev_data/Course/Cs0006.csv b/titles/cxb/rev_data/Course/Cs0006.csv new file mode 100644 index 0000000..7dfcd49 Binary files /dev/null and b/titles/cxb/rev_data/Course/Cs0006.csv differ diff --git a/titles/cxb/rev_data/Course/Cs0007.csv b/titles/cxb/rev_data/Course/Cs0007.csv new file mode 100644 index 0000000..7dfcd49 Binary files /dev/null and b/titles/cxb/rev_data/Course/Cs0007.csv differ diff --git a/titles/cxb/rev_data/Course/Cs0008.csv b/titles/cxb/rev_data/Course/Cs0008.csv new file mode 100644 index 0000000..7dfcd49 Binary files /dev/null and b/titles/cxb/rev_data/Course/Cs0008.csv differ diff --git a/titles/cxb/rev_data/Course/Cs0009.csv b/titles/cxb/rev_data/Course/Cs0009.csv new file mode 100644 index 0000000..7dfcd49 Binary files /dev/null and b/titles/cxb/rev_data/Course/Cs0009.csv differ diff --git a/titles/cxb/rev_data/Event/EventArchiveList.csv b/titles/cxb/rev_data/Event/EventArchiveList.csv new file mode 100644 index 0000000..d15ccb2 Binary files /dev/null and b/titles/cxb/rev_data/Event/EventArchiveList.csv differ diff --git a/titles/cxb/rev_data/Event/EventStampList.csv b/titles/cxb/rev_data/Event/EventStampList.csv new file mode 100644 index 0000000..070b792 Binary files /dev/null and b/titles/cxb/rev_data/Event/EventStampList.csv differ diff --git a/titles/cxb/rev_data/Ex0000.csv b/titles/cxb/rev_data/Ex0000.csv new file mode 100644 index 0000000..8658453 Binary files /dev/null and b/titles/cxb/rev_data/Ex0000.csv differ diff --git a/titles/cxb/rev_data/Ex0001.csv b/titles/cxb/rev_data/Ex0001.csv new file mode 100644 index 0000000..53ba1e2 Binary files /dev/null and b/titles/cxb/rev_data/Ex0001.csv differ diff --git a/titles/cxb/rev_data/ExtraStageList.csv b/titles/cxb/rev_data/ExtraStageList.csv new file mode 100644 index 0000000..068fd0a Binary files /dev/null and b/titles/cxb/rev_data/ExtraStageList.csv differ diff --git a/titles/cxb/rev_data/Item/ItemArchiveList_Icon.csv b/titles/cxb/rev_data/Item/ItemArchiveList_Icon.csv new file mode 100644 index 0000000..f61eb72 Binary files /dev/null and b/titles/cxb/rev_data/Item/ItemArchiveList_Icon.csv differ diff --git a/titles/cxb/rev_data/Item/ItemArchiveList_SkinBg.csv b/titles/cxb/rev_data/Item/ItemArchiveList_SkinBg.csv new file mode 100644 index 0000000..c93f003 Binary files /dev/null and b/titles/cxb/rev_data/Item/ItemArchiveList_SkinBg.csv differ diff --git a/titles/cxb/rev_data/Item/ItemArchiveList_SkinEffect.csv b/titles/cxb/rev_data/Item/ItemArchiveList_SkinEffect.csv new file mode 100644 index 0000000..7c39c75 Binary files /dev/null and b/titles/cxb/rev_data/Item/ItemArchiveList_SkinEffect.csv differ diff --git a/titles/cxb/rev_data/Item/ItemArchiveList_SkinNotes.csv b/titles/cxb/rev_data/Item/ItemArchiveList_SkinNotes.csv new file mode 100644 index 0000000..1441690 Binary files /dev/null and b/titles/cxb/rev_data/Item/ItemArchiveList_SkinNotes.csv differ diff --git a/titles/cxb/rev_data/Item/ItemList_Title.csv b/titles/cxb/rev_data/Item/ItemList_Title.csv new file mode 100644 index 0000000..0fcc5cf Binary files /dev/null and b/titles/cxb/rev_data/Item/ItemList_Title.csv differ diff --git a/titles/cxb/rev_data/License_Offline.csv b/titles/cxb/rev_data/License_Offline.csv new file mode 100644 index 0000000..3122453 Binary files /dev/null and b/titles/cxb/rev_data/License_Offline.csv differ diff --git a/titles/cxb/rev_data/MissionList.csv b/titles/cxb/rev_data/MissionList.csv new file mode 100644 index 0000000..9050a43 Binary files /dev/null and b/titles/cxb/rev_data/MissionList.csv differ diff --git a/titles/cxb/rev_data/MusicArchiveList.csv b/titles/cxb/rev_data/MusicArchiveList.csv new file mode 100644 index 0000000..49cd012 Binary files /dev/null and b/titles/cxb/rev_data/MusicArchiveList.csv differ diff --git a/titles/cxb/rev_data/NewsList.csv b/titles/cxb/rev_data/NewsList.csv new file mode 100644 index 0000000..8facf2f Binary files /dev/null and b/titles/cxb/rev_data/NewsList.csv differ diff --git a/titles/cxb/rev_data/Shop/ShopList_Icon.csv b/titles/cxb/rev_data/Shop/ShopList_Icon.csv new file mode 100644 index 0000000..2673e63 Binary files /dev/null and b/titles/cxb/rev_data/Shop/ShopList_Icon.csv differ diff --git a/titles/cxb/rev_data/Shop/ShopList_Music.csv b/titles/cxb/rev_data/Shop/ShopList_Music.csv new file mode 100644 index 0000000..0e672c2 Binary files /dev/null and b/titles/cxb/rev_data/Shop/ShopList_Music.csv differ diff --git a/titles/cxb/rev_data/Shop/ShopList_Sale.csv b/titles/cxb/rev_data/Shop/ShopList_Sale.csv new file mode 100644 index 0000000..1e71623 Binary files /dev/null and b/titles/cxb/rev_data/Shop/ShopList_Sale.csv differ diff --git a/titles/cxb/rev_data/Shop/ShopList_SkinBg.csv b/titles/cxb/rev_data/Shop/ShopList_SkinBg.csv new file mode 100644 index 0000000..44c4843 Binary files /dev/null and b/titles/cxb/rev_data/Shop/ShopList_SkinBg.csv differ diff --git a/titles/cxb/rev_data/Shop/ShopList_SkinEffect.csv b/titles/cxb/rev_data/Shop/ShopList_SkinEffect.csv new file mode 100644 index 0000000..cc419a4 Binary files /dev/null and b/titles/cxb/rev_data/Shop/ShopList_SkinEffect.csv differ diff --git a/titles/cxb/rev_data/Shop/ShopList_SkinNotes.csv b/titles/cxb/rev_data/Shop/ShopList_SkinNotes.csv new file mode 100644 index 0000000..8550a96 Binary files /dev/null and b/titles/cxb/rev_data/Shop/ShopList_SkinNotes.csv differ diff --git a/titles/cxb/rev_data/Shop/ShopList_Title.csv b/titles/cxb/rev_data/Shop/ShopList_Title.csv new file mode 100644 index 0000000..76f2e32 Binary files /dev/null and b/titles/cxb/rev_data/Shop/ShopList_Title.csv differ diff --git a/titles/cxb/rev_data/SkinArchiveList.csv b/titles/cxb/rev_data/SkinArchiveList.csv new file mode 100644 index 0000000..4279ed1 Binary files /dev/null and b/titles/cxb/rev_data/SkinArchiveList.csv differ diff --git a/titles/cxb/rss1.py b/titles/cxb/rss1.py new file mode 100644 index 0000000..e480238 --- /dev/null +++ b/titles/cxb/rss1.py @@ -0,0 +1,257 @@ +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 titles.cxb.config import CxbConfig +from titles.cxb.base import CxbBase +from titles.cxb.const import CxbConstants + +class CxbRevSunriseS1(CxbBase): + def __init__(self, cfg: CoreConfig, game_cfg: CxbConfig) -> None: + super().__init__(cfg, game_cfg) + self.version = CxbConstants.VER_CROSSBEATS_REV_SUNRISE_S1 + + def handle_data_path_list_request(self, data: Dict) -> Dict: + return { "data": "" } + + @cached(lifetime=86400) + def handle_data_music_list_request(self, data: Dict) -> Dict: + ret_str = "" + with open(r"titles/cxb/rss1_data/MusicArchiveList.csv") as music: + lines = music.readlines() + for line in lines: + 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" + + return({"data":ret_str}) + + @cached(lifetime=86400) + def handle_data_item_list_detail_request(self, data: Dict) -> Dict: + #ItemListIcon load + ret_str = "#ItemListIcon\r\n" + with open(r"titles/cxb/rss1_data/Item/ItemList_Icon.csv", encoding="shift-jis") as item: + lines = item.readlines() + for line in lines: + ret_str += f"{line[:-1]}\r\n" + + #ItemListTitle load + ret_str += "\r\n#ItemListTitle\r\n" + with open(r"titles/cxb/rss1_data/Item/ItemList_Title.csv", encoding="shift-jis") as item: + lines = item.readlines() + for line in lines: + ret_str += f"{line[:-1]}\r\n" + + return({"data":ret_str}) + + @cached(lifetime=86400) + def handle_data_shop_list_detail_request(self, data: Dict) -> Dict: + #ShopListIcon load + ret_str = "#ShopListIcon\r\n" + with open(r"titles/cxb/rss1_data/Shop/ShopList_Icon.csv", encoding="utf-8") as shop: + lines = shop.readlines() + for line in lines: + ret_str += f"{line[:-1]}\r\n" + + #ShopListMusic load + ret_str += "\r\n#ShopListMusic\r\n" + with open(r"titles/cxb/rss1_data/Shop/ShopList_Music.csv", encoding="utf-8") as shop: + lines = shop.readlines() + for line in lines: + ret_str += f"{line[:-1]}\r\n" + + #ShopListSale load + ret_str += "\r\n#ShopListSale\r\n" + with open(r"titles/cxb/rss1_data/Shop/ShopList_Sale.csv", encoding="shift-jis") as shop: + lines = shop.readlines() + for line in lines: + ret_str += f"{line[:-1]}\r\n" + + #ShopListSkinBg load + ret_str += "\r\n#ShopListSkinBg\r\n" + with open(r"titles/cxb/rss1_data/Shop/ShopList_SkinBg.csv", encoding="shift-jis") as shop: + lines = shop.readlines() + for line in lines: + ret_str += f"{line[:-1]}\r\n" + + #ShopListSkinEffect load + ret_str += "\r\n#ShopListSkinEffect\r\n" + with open(r"titles/cxb/rss1_data/Shop/ShopList_SkinEffect.csv", encoding="shift-jis") as shop: + lines = shop.readlines() + for line in lines: + ret_str += f"{line[:-1]}\r\n" + + #ShopListSkinNotes load + ret_str += "\r\n#ShopListSkinNotes\r\n" + with open(r"titles/cxb/rss1_data/Shop/ShopList_SkinNotes.csv", encoding="shift-jis") as shop: + lines = shop.readlines() + for line in lines: + ret_str += f"{line[:-1]}\r\n" + + #ShopListTitle load + ret_str += "\r\n#ShopListTitle\r\n" + with open(r"titles/cxb/rss1_data/Shop/ShopList_Title.csv", encoding="utf-8") as shop: + lines = shop.readlines() + for line in lines: + ret_str += f"{line[:-1]}\r\n" + return({"data":ret_str}) + + def handle_data_extra_stage_list_request(self, data: Dict) -> Dict: + return({"data":""}) + + def handle_data_ex0001_request(self, data: Dict) -> Dict: + return({"data":""}) + + def handle_data_one_more_extra_list_request(self, data: Dict) -> Dict: + return({"data":""}) + + def handle_data_bonus_list10100_request(self, data: Dict) -> Dict: + return({"data":""}) + + def handle_data_oe0001_request(self, data: Dict) -> Dict: + return({"data":""}) + + def handle_data_free_coupon_request(self, data: Dict) -> Dict: + return({"data":""}) + + @cached(lifetime=86400) + def handle_data_news_list_request(self, data: Dict) -> Dict: + ret_str = "" + with open(r"titles/cxb/rss1_data/NewsList.csv", encoding="UTF-8") as news: + lines = news.readlines() + for line in lines: + ret_str += f"{line[:-1]}\r\n" + return({"data":ret_str}) + + def handle_data_tips_request(self, data: Dict) -> Dict: + return({"data":""}) + + def handle_data_release_info_list_request(self, data: Dict) -> Dict: + return({"data":""}) + + @cached(lifetime=86400) + def handle_data_random_music_list_request(self, data: Dict) -> Dict: + ret_str = "" + with open(r"titles/cxb/rss1_data/MusicArchiveList.csv") as music: + lines = music.readlines() + count = 0 + for line in lines: + line_split = line.split(",") + ret_str += str(count) + "," + line_split[0] + "," + line_split[0] + ",\r\n" + + return({"data":ret_str}) + + @cached(lifetime=86400) + def handle_data_license_request(self, data: Dict) -> Dict: + ret_str = "" + with open(r"titles/cxb/rss1_data/License.csv", encoding="UTF-8") as licenses: + lines = licenses.readlines() + for line in lines: + ret_str += f"{line[:-1]}\r\n" + return({"data":ret_str}) + + @cached(lifetime=86400) + def handle_data_course_list_request(self, data: Dict) -> Dict: + ret_str = "" + with open(r"titles/cxb/rss1_data/Course/CourseList.csv", encoding="UTF-8") as course: + lines = course.readlines() + for line in lines: + ret_str += f"{line[:-1]}\r\n" + return({"data":ret_str}) + + @cached(lifetime=86400) + def handle_data_csxxxx_request(self, data: Dict) -> Dict: + extra_num = int(data["dldate"]["filetype"][-4:]) + ret_str = "" + with open(fr"titles/cxb/rss1_data/Course/Cs{extra_num}.csv", encoding="shift-jis") as course: + lines = course.readlines() + for line in lines: + ret_str += f"{line[:-1]}\r\n" + return({"data":ret_str}) + + def handle_data_mission_list_request(self, data: Dict) -> Dict: + return({"data":""}) + + def handle_data_mission_bonus_request(self, data: Dict) -> Dict: + return({"data":""}) + + def handle_data_unlimited_mission_request(self, data: Dict) -> Dict: + return({"data":""}) + + def handle_data_partner_list_request(self, data: Dict) -> Dict: + ret_str = "" + # Lord forgive me for the sins I am about to commit + for i in range(0,10): + ret_str += f"80000{i},{i},{i},0,10000,,\r\n" + ret_str += f"80000{i},{i},{i},1,10500,,\r\n" + ret_str += f"80000{i},{i},{i},2,10500,,\r\n" + for i in range(10,13): + ret_str += f"8000{i},{i},{i},0,10000,,\r\n" + ret_str += f"8000{i},{i},{i},1,10500,,\r\n" + ret_str += f"8000{i},{i},{i},2,10500,,\r\n" + ret_str +="\r\n---\r\n0,150,100,100,100,100,\r\n" + for i in range(1,130): + ret_str +=f"{i},100,100,100,100,100,\r\n" + + ret_str += "---\r\n" + return({"data": ret_str}) + + @cached(lifetime=86400) + def handle_data_partnerxxxx_request(self, data: Dict) -> Dict: + partner_num = int(data["dldate"]["filetype"][-4:]) + ret_str = f"{partner_num},,{partner_num},1,10000,\r\n" + with open(r"titles/cxb/rss1_data/Partner0000.csv") as partner: + lines = partner.readlines() + for line in lines: + ret_str += f"{line[:-1]}\r\n" + return({"data": ret_str}) + + def handle_data_server_state_request(self, data: Dict) -> Dict: + return({"data": True}) + + def handle_data_settings_request(self, data: Dict) -> Dict: + return({"data": "2,\r\n"}) + + def handle_data_story_list_request(self, data: Dict) -> Dict: + #story id, story name, game version, start time, end time, course arc, unlock flag, song mcode for menu + ret_str = "\r\n" + ret_str += f"st0000,RISING PURPLE,10104,1464370990,4096483201,Cs1000,-1,purple,\r\n" + ret_str += f"st0001,REBEL YELL,10104,1467999790,4096483201,Cs1000,-1,chaset,\r\n" + ret_str += f"st0002,REMNANT,10104,1502127790,4096483201,Cs1000,-1,overcl,\r\n" + return({"data": ret_str}) + + def handle_data_stxxxx_request(self, data: Dict) -> Dict: + story_num = int(data["dldate"]["filetype"][-4:]) + ret_str = "" + for i in range(1,11): + ret_str +=f"{i},st000{story_num}_{i-1},,,,,,,,,,,,,,,,1,,-1,1,\r\n" + return({"data": ret_str}) + + def handle_data_event_stamp_list_request(self, data: Dict) -> Dict: + return({"data":"Cs1032,1,1,1,1,1,1,1,1,1,1,\r\n"}) + + def handle_data_premium_list_request(self, data: Dict) -> Dict: + return({"data": "1,,,,10,,,,,99,,,,,,,,,100,,\r\n"}) + + def handle_data_event_list_request(self, data: Dict) -> Dict: + return({"data":""}) + + def handle_data_event_detail_list_request(self, data: Dict) -> Dict: + event_id = data["dldate"]["filetype"].split("/")[2] + if "EventStampMapListCs1002" in event_id: + return({"data":"1,2,1,1,2,3,9,5,6,7,8,9,10,\r\n"}) + elif "EventStampList" in event_id: + return({"data":"Cs1002,1,1,1,1,1,1,1,1,1,1,\r\n"}) + else: + return({"data":""}) + + def handle_data_event_stamp_map_list_csxxxx_request(self, data: Dict) -> Dict: + event_id = data["dldate"]["filetype"].split("/")[2] + if "EventStampMapListCs1002" in event_id: + return({"data":"1,2,1,1,2,3,9,5,6,7,8,9,10,\r\n"}) + else: + return({"data":""}) diff --git a/titles/cxb/rss1_data/Course/CourseList.csv b/titles/cxb/rss1_data/Course/CourseList.csv new file mode 100644 index 0000000..845bc50 Binary files /dev/null and b/titles/cxb/rss1_data/Course/CourseList.csv differ diff --git a/titles/cxb/rss1_data/Course/Cs0000.csv b/titles/cxb/rss1_data/Course/Cs0000.csv new file mode 100644 index 0000000..47a0fc3 Binary files /dev/null and b/titles/cxb/rss1_data/Course/Cs0000.csv differ diff --git a/titles/cxb/rss1_data/Course/Cs0001.csv b/titles/cxb/rss1_data/Course/Cs0001.csv new file mode 100644 index 0000000..47a0fc3 Binary files /dev/null and b/titles/cxb/rss1_data/Course/Cs0001.csv differ diff --git a/titles/cxb/rss1_data/Course/Cs0002.csv b/titles/cxb/rss1_data/Course/Cs0002.csv new file mode 100644 index 0000000..47a0fc3 Binary files /dev/null and b/titles/cxb/rss1_data/Course/Cs0002.csv differ diff --git a/titles/cxb/rss1_data/Course/Cs0003.csv b/titles/cxb/rss1_data/Course/Cs0003.csv new file mode 100644 index 0000000..47a0fc3 Binary files /dev/null and b/titles/cxb/rss1_data/Course/Cs0003.csv differ diff --git a/titles/cxb/rss1_data/Course/Cs0004.csv b/titles/cxb/rss1_data/Course/Cs0004.csv new file mode 100644 index 0000000..47a0fc3 Binary files /dev/null and b/titles/cxb/rss1_data/Course/Cs0004.csv differ diff --git a/titles/cxb/rss1_data/Ex0000.csv b/titles/cxb/rss1_data/Ex0000.csv new file mode 100644 index 0000000..8658453 Binary files /dev/null and b/titles/cxb/rss1_data/Ex0000.csv differ diff --git a/titles/cxb/rss1_data/ExtraStageList.csv b/titles/cxb/rss1_data/ExtraStageList.csv new file mode 100644 index 0000000..30e1b23 Binary files /dev/null and b/titles/cxb/rss1_data/ExtraStageList.csv differ diff --git a/titles/cxb/rss1_data/Item/ItemList_Icon.csv b/titles/cxb/rss1_data/Item/ItemList_Icon.csv new file mode 100644 index 0000000..f61eb72 Binary files /dev/null and b/titles/cxb/rss1_data/Item/ItemList_Icon.csv differ diff --git a/titles/cxb/rss1_data/Item/ItemList_Title.csv b/titles/cxb/rss1_data/Item/ItemList_Title.csv new file mode 100644 index 0000000..2334385 Binary files /dev/null and b/titles/cxb/rss1_data/Item/ItemList_Title.csv differ diff --git a/titles/cxb/rss1_data/License.csv b/titles/cxb/rss1_data/License.csv new file mode 100644 index 0000000..8e5f1b7 Binary files /dev/null and b/titles/cxb/rss1_data/License.csv differ diff --git a/titles/cxb/rss1_data/MissionList.csv b/titles/cxb/rss1_data/MissionList.csv new file mode 100644 index 0000000..979d4ec Binary files /dev/null and b/titles/cxb/rss1_data/MissionList.csv differ diff --git a/titles/cxb/rss1_data/MusicArchiveList.csv b/titles/cxb/rss1_data/MusicArchiveList.csv new file mode 100644 index 0000000..7b9d5ae Binary files /dev/null and b/titles/cxb/rss1_data/MusicArchiveList.csv differ diff --git a/titles/cxb/rss1_data/NewsList.csv b/titles/cxb/rss1_data/NewsList.csv new file mode 100644 index 0000000..e95551c Binary files /dev/null and b/titles/cxb/rss1_data/NewsList.csv differ diff --git a/titles/cxb/rss1_data/Partner0000.csv b/titles/cxb/rss1_data/Partner0000.csv new file mode 100644 index 0000000..973e5a9 Binary files /dev/null and b/titles/cxb/rss1_data/Partner0000.csv differ diff --git a/titles/cxb/rss1_data/Shop/ShopList_Icon.csv b/titles/cxb/rss1_data/Shop/ShopList_Icon.csv new file mode 100644 index 0000000..673ad1b Binary files /dev/null and b/titles/cxb/rss1_data/Shop/ShopList_Icon.csv differ diff --git a/titles/cxb/rss1_data/Shop/ShopList_Music.csv b/titles/cxb/rss1_data/Shop/ShopList_Music.csv new file mode 100644 index 0000000..0e672c2 Binary files /dev/null and b/titles/cxb/rss1_data/Shop/ShopList_Music.csv differ diff --git a/titles/cxb/rss1_data/Shop/ShopList_Sale.csv b/titles/cxb/rss1_data/Shop/ShopList_Sale.csv new file mode 100644 index 0000000..5e9fb72 Binary files /dev/null and b/titles/cxb/rss1_data/Shop/ShopList_Sale.csv differ diff --git a/titles/cxb/rss1_data/Shop/ShopList_SkinBg.csv b/titles/cxb/rss1_data/Shop/ShopList_SkinBg.csv new file mode 100644 index 0000000..44c4843 Binary files /dev/null and b/titles/cxb/rss1_data/Shop/ShopList_SkinBg.csv differ diff --git a/titles/cxb/rss1_data/Shop/ShopList_SkinEffect.csv b/titles/cxb/rss1_data/Shop/ShopList_SkinEffect.csv new file mode 100644 index 0000000..bb6486e Binary files /dev/null and b/titles/cxb/rss1_data/Shop/ShopList_SkinEffect.csv differ diff --git a/titles/cxb/rss1_data/Shop/ShopList_SkinNotes.csv b/titles/cxb/rss1_data/Shop/ShopList_SkinNotes.csv new file mode 100644 index 0000000..0b496f2 Binary files /dev/null and b/titles/cxb/rss1_data/Shop/ShopList_SkinNotes.csv differ diff --git a/titles/cxb/rss1_data/Shop/ShopList_Title.csv b/titles/cxb/rss1_data/Shop/ShopList_Title.csv new file mode 100644 index 0000000..24d4cd9 Binary files /dev/null and b/titles/cxb/rss1_data/Shop/ShopList_Title.csv differ diff --git a/titles/cxb/rss2.py b/titles/cxb/rss2.py new file mode 100644 index 0000000..5ae98f4 --- /dev/null +++ b/titles/cxb/rss2.py @@ -0,0 +1,262 @@ +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 titles.cxb.config import CxbConfig +from titles.cxb.base import CxbBase +from titles.cxb.const import CxbConstants + +class CxbRevSunriseS2(CxbBase): + def __init__(self, cfg: CoreConfig, game_cfg: CxbConfig) -> None: + super().__init__(cfg, game_cfg) + self.version = CxbConstants.VER_CROSSBEATS_REV_SUNRISE_S2_OMNI + + def handle_data_path_list_request(self, data: Dict) -> Dict: + return { "data": "" } + + @cached(lifetime=86400) + def handle_data_music_list_request(self, data: Dict) -> Dict: + ret_str = "" + with open(r"titles/cxb/rss2_data/MusicArchiveList.csv") as music: + lines = music.readlines() + for line in lines: + 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" + + return({"data":ret_str}) + + @cached(lifetime=86400) + def handle_data_item_list_detail_request(self, data: Dict) -> Dict: + #ItemListIcon load + ret_str = "#ItemListIcon\r\n" + with open(r"titles/cxb/rss2_data/Item/ItemList_Icon.csv", encoding="utf-8") as item: + lines = item.readlines() + for line in lines: + ret_str += f"{line[:-1]}\r\n" + + #ItemListTitle load + ret_str += "\r\n#ItemListTitle\r\n" + with open(r"titles/cxb/rss2_data/Item/ItemList_Title.csv", encoding="utf-8") as item: + lines = item.readlines() + for line in lines: + ret_str += f"{line[:-1]}\r\n" + + return({"data":ret_str}) + + @cached(lifetime=86400) + def handle_data_shop_list_detail_request(self, data: Dict) -> Dict: + #ShopListIcon load + ret_str = "#ShopListIcon\r\n" + with open(r"titles/cxb/rss2_data/Shop/ShopList_Icon.csv", encoding="utf-8") as shop: + lines = shop.readlines() + for line in lines: + ret_str += f"{line[:-1]}\r\n" + + #ShopListMusic load + ret_str += "\r\n#ShopListMusic\r\n" + with open(r"titles/cxb/rss2_data/Shop/ShopList_Music.csv", encoding="utf-8") as shop: + lines = shop.readlines() + for line in lines: + ret_str += f"{line[:-1]}\r\n" + + #ShopListSale load + ret_str += "\r\n#ShopListSale\r\n" + with open(r"titles/cxb/rss2_data/Shop/ShopList_Sale.csv", encoding="shift-jis") as shop: + lines = shop.readlines() + for line in lines: + ret_str += f"{line[:-1]}\r\n" + + #ShopListSkinBg load + ret_str += "\r\n#ShopListSkinBg\r\n" + with open(r"titles/cxb/rss2_data/Shop/ShopList_SkinBg.csv", encoding="shift-jis") as shop: + lines = shop.readlines() + for line in lines: + ret_str += f"{line[:-1]}\r\n" + + #ShopListSkinEffect load + ret_str += "\r\n#ShopListSkinEffect\r\n" + with open(r"titles/cxb/rss2_data/Shop/ShopList_SkinEffect.csv", encoding="shift-jis") as shop: + lines = shop.readlines() + for line in lines: + ret_str += f"{line[:-1]}\r\n" + + #ShopListSkinNotes load + ret_str += "\r\n#ShopListSkinNotes\r\n" + with open(r"titles/cxb/rss2_data/Shop/ShopList_SkinNotes.csv", encoding="shift-jis") as shop: + lines = shop.readlines() + for line in lines: + ret_str += f"{line[:-1]}\r\n" + + #ShopListTitle load + ret_str += "\r\n#ShopListTitle\r\n" + with open(r"titles/cxb/rss2_data/Shop/ShopList_Title.csv", encoding="utf-8") as shop: + lines = shop.readlines() + for line in lines: + ret_str += f"{line[:-1]}\r\n" + return({"data":ret_str}) + + def handle_data_extra_stage_list_request(self, data: Dict) -> Dict: + return({"data":""}) + + def handle_data_ex0001_request(self, data: Dict) -> Dict: + return({"data":""}) + + def handle_data_one_more_extra_list_request(self, data: Dict) -> Dict: + return({"data":""}) + + def handle_data_bonus_list10100_request(self, data: Dict) -> Dict: + return({"data":""}) + + def handle_data_oe0001_request(self, data: Dict) -> Dict: + return({"data":""}) + + def handle_data_free_coupon_request(self, data: Dict) -> Dict: + return({"data":""}) + + @cached(lifetime=86400) + def handle_data_news_list_request(self, data: Dict) -> Dict: + ret_str = "" + with open(r"titles/cxb/rss2_data/NewsList.csv", encoding="UTF-8") as news: + lines = news.readlines() + for line in lines: + ret_str += f"{line[:-1]}\r\n" + return({"data":ret_str}) + + def handle_data_tips_request(self, data: Dict) -> Dict: + return({"data":""}) + + def handle_data_release_info_list_request(self, data: Dict) -> Dict: + return({"data":""}) + + @cached(lifetime=86400) + def handle_data_random_music_list_request(self, data: Dict) -> Dict: + ret_str = "" + with open(r"titles/cxb/rss2_data/MusicArchiveList.csv") as music: + lines = music.readlines() + count = 0 + for line in lines: + line_split = line.split(",") + ret_str += str(count) + "," + line_split[0] + "," + line_split[0] + ",\r\n" + + return({"data":ret_str}) + + @cached(lifetime=86400) + def handle_data_license_request(self, data: Dict) -> Dict: + ret_str = "" + with open(r"titles/cxb/rss2_data/License.csv", encoding="UTF-8") as licenses: + lines = licenses.readlines() + for line in lines: + ret_str += f"{line[:-1]}\r\n" + return({"data":ret_str}) + + @cached(lifetime=86400) + def handle_data_course_list_request(self, data: Dict) -> Dict: + ret_str = "" + with open(r"titles/cxb/rss2_data/Course/CourseList.csv", encoding="UTF-8") as course: + lines = course.readlines() + for line in lines: + ret_str += f"{line[:-1]}\r\n" + return({"data":ret_str}) + + @cached(lifetime=86400) + def handle_data_csxxxx_request(self, data: Dict) -> Dict: + extra_num = int(data["dldate"]["filetype"][-4:]) + ret_str = "" + with open(fr"titles/cxb/rss2_data/Course/Cs{extra_num}.csv", encoding="shift-jis") as course: + lines = course.readlines() + for line in lines: + ret_str += f"{line[:-1]}\r\n" + return({"data":ret_str}) + + def handle_data_mission_list_request(self, data: Dict) -> Dict: + return({"data":""}) + + def handle_data_mission_bonus_request(self, data: Dict) -> Dict: + return({"data":""}) + + def handle_data_unlimited_mission_request(self, data: Dict) -> Dict: + return({"data":""}) + + def handle_data_partner_list_request(self, data: Dict) -> Dict: + ret_str = "" + # Lord forgive me for the sins I am about to commit + for i in range(0,10): + ret_str += f"80000{i},{i},{i},0,10000,,\r\n" + ret_str += f"80000{i},{i},{i},1,10500,,\r\n" + ret_str += f"80000{i},{i},{i},2,10500,,\r\n" + for i in range(10,13): + ret_str += f"8000{i},{i},{i},0,10000,,\r\n" + ret_str += f"8000{i},{i},{i},1,10500,,\r\n" + ret_str += f"8000{i},{i},{i},2,10500,,\r\n" + ret_str +="\r\n---\r\n0,150,100,100,100,100,\r\n" + for i in range(1,130): + ret_str +=f"{i},100,100,100,100,100,\r\n" + + ret_str += "---\r\n" + return({"data": ret_str}) + + @cached(lifetime=86400) + def handle_data_partnerxxxx_request(self, data: Dict) -> Dict: + partner_num = int(data["dldate"]["filetype"][-4:]) + ret_str = f"{partner_num},,{partner_num},1,10000,\r\n" + with open(r"titles/cxb/rss2_data/Partner0000.csv") as partner: + lines = partner.readlines() + for line in lines: + ret_str += f"{line[:-1]}\r\n" + return({"data": ret_str}) + + def handle_data_server_state_request(self, data: Dict) -> Dict: + return({"data": True}) + + def handle_data_settings_request(self, data: Dict) -> Dict: + return({"data": "2,\r\n"}) + + def handle_data_story_list_request(self, data: Dict) -> Dict: + #story id, story name, game version, start time, end time, course arc, unlock flag, song mcode for menu + ret_str = "\r\n" + ret_str += f"st0000,RISING PURPLE,10104,1464370990,4096483201,Cs1000,-1,purple,\r\n" + ret_str += f"st0001,REBEL YELL,10104,1467999790,4096483201,Cs1000,-1,chaset,\r\n" + ret_str += f"st0002,REMNANT,10104,1502127790,4096483201,Cs1000,-1,overcl,\r\n" + return({"data": ret_str}) + + def handle_data_stxxxx_request(self, data: Dict) -> Dict: + story_num = int(data["dldate"]["filetype"][-4:]) + ret_str = "" + # Each stories appears to have 10 pieces based on the wiki but as on how they are set.... no clue + for i in range(1,11): + ret_str +=f"{i},st000{story_num}_{i-1},,,,,,,,,,,,,,,,1,,-1,1,\r\n" + return({"data": ret_str}) + + def handle_data_event_stamp_list_request(self, data: Dict) -> Dict: + return({"data":"Cs1002,1,1,1,1,1,1,1,1,1,1,\r\n"}) + + def handle_data_premium_list_request(self, data: Dict) -> Dict: + return({"data": "1,,,,10,,,,,99,,,,,,,,,100,,\r\n"}) + + def handle_data_event_list_request(self, data: Dict) -> Dict: + return({"data":"Cs4001,0,10000,1601510400,1604188799,1,nv2006,1,\r\nCs4005,0,10000,1609459200,1615766399,1,nv2006,1,\r\n"}) + + def handle_data_event_detail_list_request(self, data: Dict) -> Dict: + event_id = data["dldate"]["filetype"].split("/")[2] + if "Cs4001" in event_id: + return({"data":"#EventMusicList\r\n1,zonzon2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,\r\n2,moonki,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,\r\n3,tricko,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,\r\n"}) + elif "Cs4005" in event_id: + return({"data":"#EventMusicList\r\n2,firstl,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,\r\n2,valent,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,\r\n2,dazzli2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,\r\n"}) + elif "EventStampMapListCs1002" in event_id: + return({"data":"1,2,1,1,2,3,9,5,6,7,8,9,10,\r\n"}) + elif "EventStampList" in event_id: + return({"data":"Cs1002,1,1,1,1,1,1,1,1,1,1,\r\n"}) + else: + return({"data":""}) + + def handle_data_event_stamp_map_list_csxxxx_request(self, data: Dict) -> Dict: + event_id = data["dldate"]["filetype"].split("/")[2] + if "EventStampMapListCs1002" in event_id: + return({"data":"1,2,1,1,2,3,9,5,6,7,8,9,10,\r\n"}) + else: + return({"data":""}) diff --git a/titles/cxb/rss2_data/Course/CourseList.csv b/titles/cxb/rss2_data/Course/CourseList.csv new file mode 100644 index 0000000..41225e2 Binary files /dev/null and b/titles/cxb/rss2_data/Course/CourseList.csv differ diff --git a/titles/cxb/rss2_data/Course/Cs2000.csv b/titles/cxb/rss2_data/Course/Cs2000.csv new file mode 100644 index 0000000..38a3f5f Binary files /dev/null and b/titles/cxb/rss2_data/Course/Cs2000.csv differ diff --git a/titles/cxb/rss2_data/Course/Cs2001.csv b/titles/cxb/rss2_data/Course/Cs2001.csv new file mode 100644 index 0000000..94d4a43 Binary files /dev/null and b/titles/cxb/rss2_data/Course/Cs2001.csv differ diff --git a/titles/cxb/rss2_data/Course/Cs2002.csv b/titles/cxb/rss2_data/Course/Cs2002.csv new file mode 100644 index 0000000..0820970 Binary files /dev/null and b/titles/cxb/rss2_data/Course/Cs2002.csv differ diff --git a/titles/cxb/rss2_data/Course/Cs2003.csv b/titles/cxb/rss2_data/Course/Cs2003.csv new file mode 100644 index 0000000..540a574 Binary files /dev/null and b/titles/cxb/rss2_data/Course/Cs2003.csv differ diff --git a/titles/cxb/rss2_data/Course/Cs2004.csv b/titles/cxb/rss2_data/Course/Cs2004.csv new file mode 100644 index 0000000..292133e Binary files /dev/null and b/titles/cxb/rss2_data/Course/Cs2004.csv differ diff --git a/titles/cxb/rss2_data/Ex0000.csv b/titles/cxb/rss2_data/Ex0000.csv new file mode 100644 index 0000000..8658453 Binary files /dev/null and b/titles/cxb/rss2_data/Ex0000.csv differ diff --git a/titles/cxb/rss2_data/ExtraStageList.csv b/titles/cxb/rss2_data/ExtraStageList.csv new file mode 100644 index 0000000..44f252c Binary files /dev/null and b/titles/cxb/rss2_data/ExtraStageList.csv differ diff --git a/titles/cxb/rss2_data/Item/ItemList_Icon.csv b/titles/cxb/rss2_data/Item/ItemList_Icon.csv new file mode 100644 index 0000000..19cbe0c Binary files /dev/null and b/titles/cxb/rss2_data/Item/ItemList_Icon.csv differ diff --git a/titles/cxb/rss2_data/Item/ItemList_Title.csv b/titles/cxb/rss2_data/Item/ItemList_Title.csv new file mode 100644 index 0000000..3285ead Binary files /dev/null and b/titles/cxb/rss2_data/Item/ItemList_Title.csv differ diff --git a/titles/cxb/rss2_data/License.csv b/titles/cxb/rss2_data/License.csv new file mode 100644 index 0000000..3122453 Binary files /dev/null and b/titles/cxb/rss2_data/License.csv differ diff --git a/titles/cxb/rss2_data/MissionList.csv b/titles/cxb/rss2_data/MissionList.csv new file mode 100644 index 0000000..8928eb1 Binary files /dev/null and b/titles/cxb/rss2_data/MissionList.csv differ diff --git a/titles/cxb/rss2_data/MusicArchiveList.csv b/titles/cxb/rss2_data/MusicArchiveList.csv new file mode 100644 index 0000000..3f68dfe Binary files /dev/null and b/titles/cxb/rss2_data/MusicArchiveList.csv differ diff --git a/titles/cxb/rss2_data/NewsList.csv b/titles/cxb/rss2_data/NewsList.csv new file mode 100644 index 0000000..258a566 Binary files /dev/null and b/titles/cxb/rss2_data/NewsList.csv differ diff --git a/titles/cxb/rss2_data/Partner0000.csv b/titles/cxb/rss2_data/Partner0000.csv new file mode 100644 index 0000000..b26e80b Binary files /dev/null and b/titles/cxb/rss2_data/Partner0000.csv differ diff --git a/titles/cxb/rss2_data/Shop/ShopList_Icon.csv b/titles/cxb/rss2_data/Shop/ShopList_Icon.csv new file mode 100644 index 0000000..3467344 Binary files /dev/null and b/titles/cxb/rss2_data/Shop/ShopList_Icon.csv differ diff --git a/titles/cxb/rss2_data/Shop/ShopList_Music.csv b/titles/cxb/rss2_data/Shop/ShopList_Music.csv new file mode 100644 index 0000000..cf5127b Binary files /dev/null and b/titles/cxb/rss2_data/Shop/ShopList_Music.csv differ diff --git a/titles/cxb/rss2_data/Shop/ShopList_Sale.csv b/titles/cxb/rss2_data/Shop/ShopList_Sale.csv new file mode 100644 index 0000000..64438de Binary files /dev/null and b/titles/cxb/rss2_data/Shop/ShopList_Sale.csv differ diff --git a/titles/cxb/rss2_data/Shop/ShopList_SkinBg.csv b/titles/cxb/rss2_data/Shop/ShopList_SkinBg.csv new file mode 100644 index 0000000..4c0bef2 Binary files /dev/null and b/titles/cxb/rss2_data/Shop/ShopList_SkinBg.csv differ diff --git a/titles/cxb/rss2_data/Shop/ShopList_SkinEffect.csv b/titles/cxb/rss2_data/Shop/ShopList_SkinEffect.csv new file mode 100644 index 0000000..228155c Binary files /dev/null and b/titles/cxb/rss2_data/Shop/ShopList_SkinEffect.csv differ diff --git a/titles/cxb/rss2_data/Shop/ShopList_SkinNotes.csv b/titles/cxb/rss2_data/Shop/ShopList_SkinNotes.csv new file mode 100644 index 0000000..4fd4cf2 Binary files /dev/null and b/titles/cxb/rss2_data/Shop/ShopList_SkinNotes.csv differ diff --git a/titles/cxb/rss2_data/Shop/ShopList_Title.csv b/titles/cxb/rss2_data/Shop/ShopList_Title.csv new file mode 100644 index 0000000..f42f002 Binary files /dev/null and b/titles/cxb/rss2_data/Shop/ShopList_Title.csv differ diff --git a/titles/cxb/rss2_data/Tips.csv b/titles/cxb/rss2_data/Tips.csv new file mode 100644 index 0000000..7890089 Binary files /dev/null and b/titles/cxb/rss2_data/Tips.csv differ diff --git a/titles/cxb/schema/__init__.py b/titles/cxb/schema/__init__.py new file mode 100644 index 0000000..ce70412 --- /dev/null +++ b/titles/cxb/schema/__init__.py @@ -0,0 +1,6 @@ +from titles.cxb.schema.profile import CxbProfileData +from titles.cxb.schema.score import CxbScoreData +from titles.cxb.schema.item import CxbItemData +from titles.cxb.schema.static import CxbStaticData + +__all__ = [CxbProfileData, CxbScoreData, CxbItemData, CxbStaticData] diff --git a/titles/cxb/schema/item.py b/titles/cxb/schema/item.py new file mode 100644 index 0000000..80d8427 --- /dev/null +++ b/titles/cxb/schema/item.py @@ -0,0 +1,45 @@ +from typing import Optional, Dict, List +from sqlalchemy import Table, Column, UniqueConstraint, PrimaryKeyConstraint, and_, case +from sqlalchemy.types import Integer, String, TIMESTAMP, Boolean +from sqlalchemy.schema import ForeignKey +from sqlalchemy.sql import func +from sqlalchemy.dialects.mysql import insert + +from core.data.schema import BaseData, metadata + +energy = Table( + "cxb_rev_energy", + metadata, + Column("id", Integer, primary_key=True, nullable=False), + Column("user", ForeignKey("aime_user.id", ondelete="cascade"), nullable=False), + Column("energy", Integer, nullable=False, server_default="0"), + UniqueConstraint("user", name="cxb_rev_energy_uk"), + mysql_charset='utf8mb4' +) + +class CxbItemData(BaseData): + def put_energy(self, user_id: int, rev_energy: int) -> Optional[int]: + sql = insert(energy).values( + user = user_id, + energy = rev_energy + ) + + conflict = sql.on_duplicate_key_update( + energy = rev_energy + ) + + result = self.execute(conflict) + if result is None: + self.logger.error(f"{__name__} failed to insert item! user: {user_id}, energy: {rev_energy}") + return None + + return result.lastrowid + + def get_energy(self, user_id: int) -> Optional[Dict]: + sql = energy.select( + and_(energy.c.user == user_id) + ) + + result = self.execute(sql) + if result is None: return None + return result.fetchone() diff --git a/titles/cxb/schema/profile.py b/titles/cxb/schema/profile.py new file mode 100644 index 0000000..1f731b4 --- /dev/null +++ b/titles/cxb/schema/profile.py @@ -0,0 +1,72 @@ +from typing import Optional, Dict, List +from sqlalchemy import Table, Column, UniqueConstraint, PrimaryKeyConstraint, and_ +from sqlalchemy.types import Integer, String, TIMESTAMP, Boolean, JSON +from sqlalchemy.schema import ForeignKey +from sqlalchemy.sql import func, select +from sqlalchemy.dialects.mysql import insert + +from core.data.schema import BaseData, metadata + +profile = Table( + "cxb_profile", + metadata, + Column("id", Integer, primary_key=True, nullable=False), + Column("user", ForeignKey("aime_user.id", ondelete="cascade"), nullable=False), + Column("version", Integer, nullable=False), + Column("index", Integer, nullable=False), + Column("data", JSON, nullable=False), + UniqueConstraint("user", "index", name="cxb_profile_uk"), + mysql_charset='utf8mb4' +) + +class CxbProfileData(BaseData): + def put_profile(self, user_id: int, version: int, index: int, data: JSON) -> Optional[int]: + sql = insert(profile).values( + user = user_id, + version = version, + index = index, + data = data + ) + + conflict = sql.on_duplicate_key_update( + index = index, + data = data + ) + + result = self.execute(conflict) + if result is None: + self.logger.error(f"{__name__} failed to update! user: {user_id}, index: {index}, data: {data}") + return None + + return result.lastrowid + + def get_profile(self, aime_id: int, version: int) -> Optional[List[Dict]]: + """ + Given a game version and either a profile or aime id, return the profile + """ + sql = profile.select(and_( + profile.c.version == version, + profile.c.user == aime_id + )) + + result = self.execute(sql) + if result is None: return None + return result.fetchall() + + def get_profile_index(self, index: int, aime_id: int = None, version: int = None) -> Optional[Dict]: + """ + Given a game version and either a profile or aime id, return the profile + """ + if aime_id is not None and version is not None and index is not None: + sql = profile.select(and_( + profile.c.version == version, + profile.c.user == aime_id, + profile.c.index == index + )) + else: + self.logger.error(f"get_profile: Bad arguments!! aime_id {aime_id} version {version}") + return None + + result = self.execute(sql) + if result is None: return None + return result.fetchone() diff --git a/titles/cxb/schema/score.py b/titles/cxb/schema/score.py new file mode 100644 index 0000000..014e535 --- /dev/null +++ b/titles/cxb/schema/score.py @@ -0,0 +1,166 @@ +from sqlalchemy import Table, Column, UniqueConstraint, PrimaryKeyConstraint, and_ +from sqlalchemy.types import Integer, String, TIMESTAMP, JSON, Boolean +from sqlalchemy.schema import ForeignKey +from sqlalchemy.sql import func +from sqlalchemy.dialects.mysql import insert +from typing import Optional, List, Dict, Any + +from core.data.schema import BaseData, metadata +from core.data import cached + +score = Table( + "cxb_score", + metadata, + Column("id", Integer, primary_key=True, nullable=False), + Column("user", ForeignKey("aime_user.id", ondelete="cascade"), nullable=False), + Column("game_version", Integer), + Column("song_mcode", String(7)), + Column("song_index", Integer), + Column("data", JSON), + UniqueConstraint("user", "song_mcode", "song_index", name="cxb_score_uk"), + mysql_charset='utf8mb4' +) + +playlog = Table( + "cxb_playlog", + metadata, + Column("id", Integer, primary_key=True, nullable=False), + Column("user", ForeignKey("aime_user.id", ondelete="cascade"), nullable=False), + Column("song_mcode", String(7)), + Column("chart_id", Integer), + Column("score", Integer), + Column("clear", Integer), + Column("flawless", Integer), + Column("super", Integer), + Column("cool", Integer), + Column("fast", Integer), + Column("fast2", Integer), + Column("slow", Integer), + Column("slow2", Integer), + Column("fail", Integer), + Column("combo", Integer), + Column("date_scored", TIMESTAMP, server_default=func.now()), + mysql_charset='utf8mb4' +) + +ranking = Table( + "cxb_ranking", + metadata, + Column("id", Integer, primary_key=True, nullable=False), + Column("user", ForeignKey("aime_user.id", ondelete="cascade"), nullable=False), + Column("rev_id", Integer), + Column("song_id", Integer), + Column("score", Integer), + Column("clear", Integer), + UniqueConstraint("user", "rev_id", name="cxb_ranking_uk"), + mysql_charset='utf8mb4' +) + +class CxbScoreData(BaseData): + def put_best_score(self, user_id: int, song_mcode: str, game_version: int, song_index: int, data: JSON) -> Optional[int]: + """ + Update the user's best score for a chart + """ + sql = insert(score).values( + user=user_id, + song_mcode=song_mcode, + game_version=game_version, + song_index=song_index, + data=data + ) + + conflict = sql.on_duplicate_key_update( + data = sql.inserted.data + ) + + result = self.execute(conflict) + if result is None: + self.logger.error(f"{__name__} failed to insert best score! profile: {user_id}, song: {song_mcode}, data: {data}") + return None + + return result.lastrowid + + def put_playlog(self, user_id: int, song_mcode: str, chart_id: int, score: int, clear: int, flawless: int, this_super: int, + cool: int, this_fast: int, this_fast2: int, this_slow: int, this_slow2: int, fail: int, combo: int) -> Optional[int]: + """ + Add an entry to the user's play log + """ + sql = playlog.insert().values( + user=user_id, + song_mcode=song_mcode, + chart_id=chart_id, + score=score, + clear=clear, + flawless=flawless, + super=this_super, + cool=cool, + fast=this_fast, + fast2=this_fast2, + slow=this_slow, + slow2=this_slow2, + fail=fail, + combo=combo + ) + + result = self.execute(sql) + if result is None: + self.logger.error(f"{__name__} failed to insert playlog! profile: {user_id}, song: {song_mcode}, chart: {chart_id}") + return None + + return result.lastrowid + + def put_ranking(self, user_id: int, rev_id: int, song_id: int, score: int, clear: int) -> Optional[int]: + """ + Add an entry to the user's ranking logs + """ + if song_id == 0: + sql = insert(ranking).values( + user=user_id, + rev_id=rev_id, + score=score, + clear=clear + ) + else: + sql = insert(ranking).values( + user=user_id, + rev_id=rev_id, + song_id=song_id, + score=score, + clear=clear + ) + + conflict = sql.on_duplicate_key_update( + score = score + ) + + result = self.execute(conflict) + if result is None: + self.logger.error(f"{__name__} failed to insert ranking log! profile: {user_id}, score: {score}, clear: {clear}") + return None + + return result.lastrowid + + def get_best_score(self, user_id: int, song_mcode: int) -> Optional[Dict]: + sql = score.select( + and_(score.c.user == user_id, score.c.song_mcode == song_mcode) + ) + + result = self.execute(sql) + if result is None: return None + return result.fetchone() + + def get_best_scores(self, user_id: int) -> Optional[Dict]: + sql = score.select(score.c.user == user_id) + + result = self.execute(sql) + if result is None: return None + return result.fetchall() + + def get_best_rankings(self, user_id: int) -> Optional[List[Dict]]: + sql = ranking.select( + ranking.c.user == user_id + ) + + result = self.execute(sql) + if result is None: return None + return result.fetchall() diff --git a/titles/cxb/schema/static.py b/titles/cxb/schema/static.py new file mode 100644 index 0000000..6b16ac4 --- /dev/null +++ b/titles/cxb/schema/static.py @@ -0,0 +1,74 @@ +from typing import Dict, List, Optional +from sqlalchemy import Table, Column, UniqueConstraint, PrimaryKeyConstraint, and_ +from sqlalchemy.types import Integer, String, TIMESTAMP, Boolean, JSON, Float +from sqlalchemy.engine.base import Connection +from sqlalchemy.engine import Row +from sqlalchemy.schema import ForeignKey +from sqlalchemy.sql import func, select +from sqlalchemy.dialects.mysql import insert + +from core.data.schema import BaseData, metadata + +music = Table( + "cxb_static_music", + metadata, + Column("id", Integer, primary_key=True, nullable=False), + Column("version", Integer, nullable=False), + Column("songId", String(255)), + Column("index", Integer), + Column("chartId", Integer), + Column("title", String(255)), + Column("artist", String(255)), + Column("category", String(255)), + Column("level", Float), + UniqueConstraint("version", "songId", "chartId", "index", name="cxb_static_music_uk"), + mysql_charset='utf8mb4' +) + +class CxbStaticData(BaseData): + def put_music(self, version: int, mcode: str, index: int, chart: int, title: str, artist: str, category: str, level: float ) -> Optional[int]: + sql = insert(music).values( + version = version, + songId = mcode, + index = index, + chartId = chart, + title = title, + artist = artist, + category = category, + level = level + ) + + conflict = sql.on_duplicate_key_update( + title = title, + artist = artist, + category = category, + level = level + ) + + result = self.execute(conflict) + if result is None: return None + return result.lastrowid + + def get_music(self, version: int, song_id: Optional[int] = None) -> Optional[List[Row]]: + if song_id is None: + sql = select(music).where(music.c.version == version) + else: + sql = select(music).where(and_( + music.c.version == version, + music.c.songId == song_id, + )) + + result = self.execute(sql) + if result is None: return None + return result.fetchall() + + def get_music_chart(self, version: int, song_id: int, chart_id: int) -> Optional[List[Row]]: + sql = select(music).where(and_( + music.c.version == version, + music.c.songId == song_id, + music.c.chartId == chart_id + )) + + result = self.execute(sql) + if result is None: return None + return result.fetchone() diff --git a/titles/diva/__init__.py b/titles/diva/__init__.py new file mode 100644 index 0000000..acc7ce4 --- /dev/null +++ b/titles/diva/__init__.py @@ -0,0 +1,18 @@ +from titles.diva.index import DivaServlet +from titles.diva.const import DivaConstants +from titles.diva.database import DivaData +from titles.diva.read import DivaReader + +index = DivaServlet +database = DivaData +reader = DivaReader + +use_default_title = True +include_protocol = True +title_secure = False +game_codes = [DivaConstants.GAME_CODE] +trailing_slash = True +use_default_host = False +host = "" + +current_schema_version = 1 \ No newline at end of file diff --git a/titles/diva/base.py b/titles/diva/base.py new file mode 100644 index 0000000..aef5841 --- /dev/null +++ b/titles/diva/base.py @@ -0,0 +1,506 @@ +import datetime +from typing import Any, List, Dict +import logging +import json +import urllib + +from core.config import CoreConfig +from titles.diva.config import DivaConfig +from titles.diva.const import DivaConstants +from titles.diva.database import DivaData + +class DivaBase(): + def __init__(self, cfg: CoreConfig, game_cfg: DivaConfig) -> None: + self.core_cfg = cfg # Config file + self.game_config = game_cfg + self.data = DivaData(cfg) # Database + self.date_time_format = "%Y-%m-%d %H:%M:%S" + self.logger = logging.getLogger("diva") + 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")) + + def handle_test_request(self, data: Dict) -> Dict: + return "" + + def handle_game_init_request(self, data: Dict) -> Dict: + return ( f'' ) + + def handle_attend_request(self, data: Dict) -> Dict: + 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', + 'atnd_prm2': '30,10,100,4,1,50,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,1,1,1,1,1,1,1,1', + 'atnd_prm3': '100,0,1,1,1,1,1,1,1,1,2,3,4,1,1,1,3,4,5,1,1,1,4,5,6,1,1,1,5,6,7,4,4,4,9,10,14,5,10,10,25,20,50,30,90,5,10,10,25,20,50,30,90,5,10,10,25,20,50,30,90,5,10,10,25,20,50,30,90,5,10,10,25,20,50,30,90,10,30,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0', + 'atnd_lut': f'{self.time_lut}', + } + + encoded += urllib.parse.urlencode(params) + encoded = encoded.replace("%2C", ",") + + return encoded + + def handle_ping_request(self, data: Dict) -> Dict: + encoded = "&" + params = { + 'ping_b_msg': f'Welcome to {self.core_cfg.server.name} network!', + 'ping_m_msg': 'xxx', + 'atnd_lut': f'{self.time_lut}', + 'fi_lut': f'{self.time_lut}', + 'ci_lut': f'{self.time_lut}', + 'qi_lut': f'{self.time_lut}', + 'pvl_lut': '2021-05-22 12:08:16.0', + 'shp_ctlg_lut': '2020-06-10 19:44:16.0', + 'cstmz_itm_ctlg_lut': '2019-10-08 20:23:12.0', + 'ngwl_lut': '2019-10-08 20:23:12.0', + 'rnk_nv_lut': '2020-06-10 19:51:30.0', + 'rnk_ps_lut': f'{self.time_lut}', + 'bi_lut': '2020-09-18 10:00:00.0', + 'cpi_lut': '2020-10-25 09:25:10.0', + 'bdlol_lut': '2020-09-18 10:00:00.0', + 'p_std_hc_lut': '2019-08-01 04:00:36.0', + 'p_std_i_n_lut': '2019-08-01 04:00:36.0', + 'pdcl_lut': '2019-08-01 04:00:36.0', + 'pnml_lut': '2019-08-01 04:00:36.0', + 'cinml_lut': '2019-08-01 04:00:36.0', + 'rwl_lut': '2019-08-01 04:00:36.0', + 'req_inv_cmd_num': '-1,-1,-1,-1,-1,-1,-1,-1,-1,-1', + 'req_inv_cmd_prm1': '-1,-1,-1,-1,-1,-1,-1,-1,-1,-1', + 'req_inv_cmd_prm2': '-1,-1,-1,-1,-1,-1,-1,-1,-1,-1', + 'req_inv_cmd_prm3': '-1,-1,-1,-1,-1,-1,-1,-1,-1,-1', + 'req_inv_cmd_prm4': '-1,-1,-1,-1,-1,-1,-1,-1,-1,-1', + 'pow_save_flg': 0, + 'nblss_dnt_p': 100, + 'nblss_ltt_rl_vp': 1500, + 'nblss_ex_ltt_flg': 1, + 'nblss_dnt_st_tm': "2019-07-15 12:00:00.0", + 'nblss_dnt_ed_tm': "2019-09-17 12:00:00.0", + 'nblss_ltt_st_tm': "2019-09-18 12:00:00.0", + 'nblss_ltt_ed_tm': "2019-09-22 12:00:00.0", + } + + encoded += urllib.parse.urlencode(params) + encoded = encoded.replace("+", "%20") + encoded = encoded.replace("%2C", ",") + + return encoded + + def handle_pv_list_request(self, data: Dict) -> Dict: + pvlist = "" + with open(r"titles/diva/data/PvList0.dat", encoding="utf-8") as shop: + lines = shop.readlines() + for line in lines: + pvlist += f"{line}" + pvlist += "," + + with open(r"titles/diva/data/PvList1.dat", encoding="utf-8") as shop: + lines = shop.readlines() + for line in lines: + pvlist += f"{line}" + pvlist += "," + + with open(r"titles/diva/data/PvList2.dat", encoding="utf-8") as shop: + lines = shop.readlines() + for line in lines: + pvlist += f"{line}" + pvlist += "," + + with open(r"titles/diva/data/PvList3.dat", encoding="utf-8") as shop: + lines = shop.readlines() + for line in lines: + pvlist += f"{line}" + pvlist += "," + + with open(r"titles/diva/data/PvList4.dat", encoding="utf-8") as shop: + lines = shop.readlines() + for line in lines: + pvlist += f"{line}" + + response = "" + response += f"&pvl_lut={self.time_lut}" + response += f"&pv_lst={pvlist}" + + return ( response ) + + def handle_shop_catalog_request(self, data: Dict) -> Dict: + catalog = "" + + shopList = self.data.static.get_enabled_shop(self.version) + if not shopList: + 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)}" + catalog = catalog.replace("+", "%20") + + response = "" + response += f"&shp_ctlg_lut={self.time_lut}" + response += f"&shp_ctlg={catalog[:-3]}" + 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)}" + + catalog = catalog.replace("+", "%20") + + response = "" + response += f"&shp_ctlg_lut={self.time_lut}" + response += f"&shp_ctlg={catalog[:-3]}" + + return ( response ) + + def handle_cstmz_itm_ctlg_request(self, data: Dict) -> Dict: + catalog = "" + + itemList = self.data.static.get_enabled_items(self.version) + if not itemList: + 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)}" + catalog = catalog.replace("+", "%20") + + response = "" + response += f"&cstmz_itm_ctlg_lut={self.time_lut}" + response += f"&cstmz_itm_ctlg={catalog[:-3]}" + 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)}" + + catalog = catalog.replace("+", "%20") + + response = "" + response += f"&cstmz_itm_ctlg_lut={self.time_lut}" + response += f"&cstmz_itm_ctlg={catalog[:-3]}" + + return ( response ) + + def handle_festa_info_request(self, data: Dict) -> Dict: + encoded = "&" + params = { + 'fi_id': '1,-1', + 'fi_name': f'{self.core_cfg.server.name} Opening,xxx', + 'fi_kind': '0,0', + 'fi_difficulty': '-1,-1', + 'fi_pv_id_lst': 'ALL,ALL', + 'fi_attr': '7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF,7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF', + 'fi_add_vp': '10,0', + 'fi_mul_vp': '1,1', + 'fi_st': '2022-06-17 17:00:00.0,2014-07-08 18:10:11.0', + 'fi_et': '2029-01-01 10:00:00.0,2014-07-08 18:10:11.0', + 'fi_lut': '{self.time_lut}', + } + + encoded += urllib.parse.urlencode(params) + encoded = encoded.replace("+", "%20") + encoded = encoded.replace("%2C", ",") + + return encoded + + def handle_contest_info_request(self, data: Dict) -> Dict: + response = "" + + response += f"&ci_lut={self.time_lut}" + response += "&ci_str=%2A%2A%2A,%2A%2A%2A,%2A%2A%2A,%2A%2A%2A,%2A%2A%2A,%2A%2A%2A,%2A%2A%2A,%2A%2A%2A" + + return ( response ) + + def handle_qst_inf_request(self, data: Dict) -> Dict: + quest = "" + + questList = self.data.static.get_enabled_quests(self.version) + if not questList: + 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)}," + + response = "" + response += f"&qi_lut={self.time_lut}" + response += f"&qhi_str={quest[:-1]}" + 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," + + responseline = f"{quest[:-1]}," + for i in range(len(questList),59): + responseline += "%2A%2A%2A%0A," + + response = "" + response += f"&qi_lut={self.time_lut}" + response += f"&qhi_str={responseline}%2A%2A%2A" + + response += "&qrai_str=%2D1%2C%2D1%2C%2D1%2C%2D1%2C%2D1%2C%2D1%2C%2D1%2C%2D1%2C%2D1%2C%2D1%2C%2D1,%2D1%2C%2D1%2C%2D1%2C%2D1%2C%2D1%2C%2D1%2C%2D1%2C%2D1%2C%2D1%2C%2D1%2C%2D1,%2D1%2C%2D1%2C%2D1%2C%2D1%2C%2D1%2C%2D1%2C%2D1%2C%2D1%2C%2D1%2C%2D1%2C%2D1" + + return ( response ) + + def handle_nv_ranking_request(self, data: Dict) -> Dict: + return ( f'' ) + + def handle_ps_ranking_request(self, data: Dict) -> Dict: + return ( f'' ) + + def handle_ng_word_request(self, data: Dict) -> Dict: + return ( f'' ) + + def handle_rmt_wp_list_request(self, data: Dict) -> Dict: + return ( f'' ) + + def handle_pv_def_chr_list_request(self, data: Dict) -> Dict: + return ( f'' ) + + def handle_pv_ng_mdl_list_request(self, data: Dict) -> Dict: + return ( f'' ) + + def handle_cstmz_itm_ng_mdl_lst_request(self, data: Dict) -> Dict: + return ( f'' ) + + def handle_banner_info_request(self, data: Dict) -> Dict: + return ( f'' ) + + def handle_banner_data_request(self, data: Dict) -> Dict: + return ( f'' ) + + def handle_cm_ply_info_request(self, data: Dict) -> Dict: + return ( f'' ) + + def handle_pstd_h_ctrl_request(self, data: Dict) -> Dict: + return ( f'' ) + + def handle_pstd_item_ng_lst_request(self, data: Dict) -> Dict: + return ( f'' ) + + def handle_pre_start_request(self, data: Dict) -> Dict: + profile = self.data.profile.get_profile(data["aime_id"], self.version) + profile_shop = self.data.item.get_shop(data["aime_id"], self.version) + if profile is None: + return ( f"&ps_result=-3") + else: + response = "" + response += "&ps_result=1" + response += f"&pd_id={data['aime_id']}" + response += "&nblss_ltt_stts=-1" + response += "&nblss_ltt_tckt=-1" + response += "&nblss_ltt_is_opn=-1" + response += f"&vcld_pts={profile['vcld_pts']}" + response += f"&player_name={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']}" + + #Store stuff to add to rework + response += f"&mdl_eqp_tm={self.time_lut}" + + if profile_shop: + response += f"&mdl_eqp_ary={profile_shop['mdl_eqp_ary']}" + + response += f"&c_itm_eqp_ary=-999,-999,-999,-999,-999,-999,-999,-999,-999,-999,-999,-999" + response += f"&ms_itm_flg_ary=1,1,1,1,1,1,1,1,1,1,1,1" + + return ( response ) + + def handle_registration_request(self, data: Dict) -> Dict: #DONE + 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: + 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: return + + response = "" + response += f"&pd_id={data['pd_id']}" + response += "&start_result=1" + + response += "&accept_idx=100" + response += f"&hp_vol={profile['hp_vol']}" + response += f"&btn_se_vol={profile['btn_se_vol']}" + response += f"&btn_se_vol2={profile['btn_se_vol2']}" + response += f"&sldr_se_vol2={profile['sldr_se_vol2']}" + response += f"&sort_kind={profile['sort_kind']}" + response += f"&player_name={profile['player_name']}" + response += f"&lv_num={profile['lv_num']}" + response += f"&lv_pnt={profile['lv_pnt']}" + response += f"&lv_efct_id={profile['lv_efct_id']}" + response += f"&lv_plt_id={profile['lv_plt_id']}" + response += "&mdl_have=FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + response += "&cstmz_itm_have=FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + response += f"&use_pv_mdl_eqp={profile['use_pv_mdl_eqp']}" + response += f"&use_pv_btn_se_eqp={profile['use_pv_btn_se_eqp']}" + response += f"&use_pv_sld_se_eqp={profile['use_pv_sld_se_eqp']}" + response += f"&use_pv_chn_sld_se_eqp={profile['use_pv_chn_sld_se_eqp']}" + response += f"&use_pv_sldr_tch_se_eqp={profile['use_pv_sldr_tch_se_eqp']}" + response += f"&vcld_pts={profile['lv_efct_id']}" + response += f"&nxt_pv_id={profile['nxt_pv_id']}" + response += f"&nxt_dffclty={profile['nxt_dffclty']}" + response += f"&nxt_edtn={profile['nxt_edtn']}" + response += f"&dsp_clr_brdr={profile['dsp_clr_brdr']}" + response += f"&dsp_intrm_rnk={profile['dsp_intrm_rnk']}" + response += f"&dsp_clr_sts={profile['dsp_clr_sts']}" + response += f"&rgo_sts={profile['rgo_sts']}" + + #To be fully fixed + if "my_qst_id" not in profile: + response += f"&my_qst_id=-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" + response += f"&my_qst_sts=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" + else: + response += f"&my_qst_id={profile['my_qst_id']}" + response += f"&my_qst_sts={profile['my_qst_sts']}" + + response += f"&my_qst_prgrs=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" + response += f"&my_qst_et=2022-06-19%2010%3A28%3A52.0,2022-06-19%2010%3A28%3A52.0,2022-06-19%2010%3A28%3A52.0,2100-01-01%2008%3A59%3A59.0,2100-01-01%2008%3A59%3A59.0,xxx,xxx,xxx,xxx,xxx,xxx,xxx,xxx,xxx,xxx,xxx,xxx,xxx,xxx,xxx,xxx,xxx,xxx,xxx,xxx" + response += f"&clr_sts=0,0,0,0,0,0,0,0,56,52,35,6,6,3,1,0,0,0,0,0" + + #Store stuff to add to rework + response += f"&mdl_eqp_tm={self.time_lut}" + + if profile_shop: + response += f"&mdl_eqp_ary={profile_shop['mdl_eqp_ary']}" + + response += f"&c_itm_eqp_ary=-999,-999,-999,-999,-999,-999,-999,-999,-999,-999,-999,-999" + response += f"&ms_itm_flg_ary=1,1,1,1,1,1,1,1,1,1,1,1" + + return ( response ) + + def handle_pd_unlock_request(self, data: Dict) -> Dict: + return ( f'' ) + + def handle_spend_credit_request(self, data: Dict) -> Dict: + profile = self.data.profile.get_profile(data["pd_id"], self.version) + if profile is None: return + + response = "" + + response += "&cmpgn_rslt=-1,-1,x,-1,-1,x,x,-1,x,-1,-1,x,-1,-1,x,x,-1,x,-1,-1,x,-1,-1,x,x,-1,x,-1,-1,x,-1,-1,x,x,-1,x,-1,-1,x,-1,-1,x,x,-1,x,-1,-1,x,-1,-1,x,x,-1,x" + response += "&cmpgn_rslt_num=0" + response += f"&vcld_pts={profile['vcld_pts']}" + response += f"&lv_str={profile['lv_str']}" + response += f"&lv_efct_id={profile['lv_efct_id']}" + response += f"&lv_plt_id={profile['lv_plt_id']}" + + return ( response ) + + def handle_get_pv_pd_request(self, data: Dict) -> Dict: + song_id = data["pd_pv_id_lst"].split(",") + pv = "" + + for song in song_id: + if int(song) > 0: + pd_db_song = self.data.score.get_best_score(data["pd_id"], int(song), data["difficulty"]) + if pd_db_song is not None: + + pv += urllib.parse.quote(f"{song},0,{pd_db_song['clr_kind']},{pd_db_song['score']},{pd_db_song['atn_pnt']},{pd_db_song['sort_kind']},-999,-999,-999,-999,-999,-999,-999,-999,-999,-999,-999,-999,-999,-999,-999,1,1,1,1,1,1,1,1,1,1,1,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1337,1,1,1,0,0,0") + + else: + #self.logger.debug(f"No score saved for ID: {song}!") + pv += urllib.parse.quote(f"{song},0,-1,-1,-1,0,-999,-999,-999,-999,-999,-999,-999,-999,-999,-999,-999,-999,-999,-999,-999,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,0,0,0") + + #pv_no, edition, rslt, max_score, max_atn_pnt, challenge_kind, module_eqp[-999,-999,-999], customize_eqp[-999,-999,-999,-999,-999,-999,-999,-999,-999,-999,-999,-999], customize_flag[1,1,1,1,1,1,1,1,1,1,1,1], skin, btn_se, sld_se, chsld_se, sldtch_se, rvl_pd_id, rvl_score, rvl_attn_pnt, countrywide_ranking, rgo_hispeed, rgo_hidden, rgo_sudden, rgo_hispeed_cleared, rgo_hidden_cleared, rgo_sudden_cleared, chain_challenge_num, chain_challenge_max, chain_challenge_open, version + else: + pv += urllib.parse.quote(f"{song}***") + pv += "," + + response = "" + response += f"&pd_by_pv_id={pv[:-1]}" + response += "&pdddt_flg=0" + response += f"&pdddt_tm={self.time_lut}" + + return ( response ) + + def handle_stage_start_request(self, data: Dict) -> Dict: + return ( f'' ) + + def handle_stage_result_request(self, data: Dict) -> Dict: + + profile = self.data.profile.get_profile(data["pd_id"], self.version) + + pd_song_list = data["stg_ply_pv_id"].split(",") + pd_song_difficulty = data["stg_difficulty"].split(",") + pd_song_max_score = data["stg_score"].split(",") + pd_song_max_atn_pnt = data["stg_atn_pnt"].split(",") + pd_song_ranking = data["stg_clr_kind"].split(",") + pd_song_sort_kind = data["sort_kind"] + pd_song_cool_cnt = data["stg_cool_cnt"].split(",") + pd_song_fine_cnt = data["stg_fine_cnt"].split(",") + pd_song_safe_cnt = data["stg_safe_cnt"].split(",") + pd_song_sad_cnt = data["stg_sad_cnt"].split(",") + pd_song_worst_cnt = data["stg_wt_wg_cnt"].split(",") + pd_song_max_combo = data["stg_max_cmb"].split(",") + + for index, value in enumerate(pd_song_list): + if "-1" not in pd_song_list[index]: + profile_pd_db_song = self.data.score.get_best_score(data["pd_id"], pd_song_list[index], pd_song_difficulty[index]) + if profile_pd_db_song is None: + self.data.score.put_best_score(data["pd_id"], self.version, pd_song_list[index], pd_song_difficulty[index], pd_song_max_score[index], pd_song_max_atn_pnt[index], pd_song_ranking[index], pd_song_sort_kind, pd_song_cool_cnt[index], pd_song_fine_cnt[index], pd_song_safe_cnt[index], pd_song_sad_cnt[index], pd_song_worst_cnt[index], pd_song_max_combo[index]) + self.data.score.put_playlog(data["pd_id"], self.version, pd_song_list[index], pd_song_difficulty[index], pd_song_max_score[index], pd_song_max_atn_pnt[index], pd_song_ranking[index], pd_song_sort_kind, pd_song_cool_cnt[index], pd_song_fine_cnt[index], pd_song_safe_cnt[index], pd_song_sad_cnt[index], pd_song_worst_cnt[index], pd_song_max_combo[index]) + elif int(pd_song_max_score[index]) >= int(profile_pd_db_song["score"]): + self.data.score.put_best_score(data["pd_id"], self.version, pd_song_list[index], pd_song_difficulty[index], pd_song_max_score[index], pd_song_max_atn_pnt[index], pd_song_ranking[index], pd_song_sort_kind, pd_song_cool_cnt[index], pd_song_fine_cnt[index], pd_song_safe_cnt[index], pd_song_sad_cnt[index], pd_song_worst_cnt[index], pd_song_max_combo[index]) + self.data.score.put_playlog(data["pd_id"], self.version, pd_song_list[index], pd_song_difficulty[index], pd_song_max_score[index], pd_song_max_atn_pnt[index], pd_song_ranking[index], pd_song_sort_kind, pd_song_cool_cnt[index], pd_song_fine_cnt[index], pd_song_safe_cnt[index], pd_song_sad_cnt[index], pd_song_worst_cnt[index], pd_song_max_combo[index]) + elif int(pd_song_max_score[index]) != int(profile_pd_db_song["score"]): + self.data.score.put_playlog(data["pd_id"], self.version, pd_song_list[index], pd_song_difficulty[index], pd_song_max_score[index], pd_song_max_atn_pnt[index], pd_song_ranking[index], pd_song_sort_kind, pd_song_cool_cnt[index], pd_song_fine_cnt[index], pd_song_safe_cnt[index], pd_song_sad_cnt[index], pd_song_worst_cnt[index], pd_song_max_combo[index]) + + # Profile saving based on registration list + + old_level = int(profile['lv_num']) + new_level = (int(data["ttl_vp_add"]) + int(profile["lv_pnt"])) / 12 + + self.data.profile.update_profile(data["pd_id"], int(new_level), int(profile["lv_pnt"]) + int(data["ttl_vp_add"]), int(data["vcld_pts"]), int(data["hp_vol"]), int(data["btn_se_vol"]), int(data["btn_se_vol2"]), int(data["sldr_se_vol2"]), int(data["sort_kind"]), int(data["use_pv_mdl_eqp"]), profile["use_pv_btn_se_eqp"], profile["use_pv_sld_se_eqp"], profile["use_pv_chn_sld_se_eqp"], profile["use_pv_sldr_tch_se_eqp"], int(data["ply_pv_id"]), int(data["nxt_dffclty"]), int(data["nxt_edtn"]), profile["dsp_clr_brdr"], profile["dsp_intrm_rnk"], profile["dsp_clr_sts"], profile["rgo_sts"], profile["lv_efct_id"], profile["lv_plt_id"], data["my_qst_id"], data["my_qst_sts"]) + + response = "" + + response += "&chllng_kind=-1" + response += f"&lv_num_old={int(old_level)}" + response += f"&lv_pnt_old={int(profile['lv_pnt'])}" + response += f"&lv_num={int(profile['lv_num'])}" + response += f"&lv_str={profile['lv_str']}" + response += f"&lv_pnt={int(profile['lv_pnt']) + int(data['ttl_vp_add'])}" + response += f"&lv_efct_id={int(profile['lv_efct_id'])}" + response += f"&lv_plt_id={int(profile['lv_plt_id'])}" + response += f"&vcld_pts={int(data['vcld_pts'])}" + response += f"&prsnt_vcld_pts={int(profile['vcld_pts'])}" + response += "&cerwd_kind=-1" + response += "&cerwd_value=-1" + response += "&cerwd_str_0=***" + response += "&cerwd_str_1=***" + response += "&ttl_str_ary=xxx,xxx,xxx,xxx,xxx" + response += "&ttl_plt_id_ary=-1,-1,-1,-1,-1" + response += "&ttl_desc_ary=xxx,xxx,xxx,xxx,xxx" + response += "&skin_id_ary=xxx,xxx,xxx,xxx,xxx" + response += "&skin_name_ary=xxx,xxx,xxx,xxx,xxx" + response += "&skin_illust_ary=xxx,xxx,xxx,xxx,xxx" + response += "&skin_desc_ary=xxx,xxx,xxx,xxx,xxx" + if "my_qst_id" not in profile: + response += f"&my_qst_id=-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" + else: + response += f"&my_qst_id={profile['my_qst_id']}" + response += "&my_qst_r_qid=-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" + response += "&my_qst_r_knd=-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" + response += "&my_qst_r_vl=-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" + response += "&my_qst_r_nflg=-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" + response += "&my_ccd_r_qid=-1,-1,-1,-1,-1" + response += "&my_ccd_r_hnd=-1,-1,-1,-1,-1" + response += "&my_ccd_r_vp=-1,-1,-1,-1,-1" + + return ( response ) + + def handle_end_request(self, data: Dict) -> Dict: + profile = self.data.profile.get_profile(data["pd_id"], self.version) + self.data.profile.update_profile(data["pd_id"], profile["lv_num"], profile["lv_pnt"], profile["vcld_pts"], profile["hp_vol"], profile["btn_se_vol"], profile["btn_se_vol2"], profile["sldr_se_vol2"], profile["sort_kind"], profile["use_pv_mdl_eqp"], profile["use_pv_btn_se_eqp"], profile["use_pv_sld_se_eqp"], profile["use_pv_chn_sld_se_eqp"], profile["use_pv_sldr_tch_se_eqp"], profile["nxt_pv_id"], profile["nxt_dffclty"], profile["nxt_edtn"], profile["dsp_clr_brdr"], profile["dsp_intrm_rnk"], profile["dsp_clr_sts"], profile["rgo_sts"], profile["lv_efct_id"], profile["lv_plt_id"], data["my_qst_id"], data["my_qst_sts"]) + return ( f'' ) + + def handle_shop_exit_request(self, data: Dict) -> Dict: + self.data.item.put_shop(data["pd_id"], self.version, data["mdl_eqp_cmn_ary"]) + + response = "" + response += "&shp_rslt=1" + return ( response ) diff --git a/titles/diva/config.py b/titles/diva/config.py new file mode 100644 index 0000000..aba99f2 --- /dev/null +++ b/titles/diva/config.py @@ -0,0 +1,17 @@ +from core.config import CoreConfig + +class DivaServerConfig(): + def __init__(self, parent_config: "DivaConfig") -> None: + self.__config = parent_config + + @property + def enable(self) -> bool: + return CoreConfig.get_config_field(self.__config, 'diva', 'server', 'enable', default=True) + + @property + def loglevel(self) -> int: + return CoreConfig.str_to_loglevel(CoreConfig.get_config_field(self.__config, 'diva', 'server', 'loglevel', default="info")) + +class DivaConfig(dict): + def __init__(self) -> None: + self.server = DivaServerConfig(self) \ No newline at end of file diff --git a/titles/diva/const.py b/titles/diva/const.py new file mode 100644 index 0000000..44bbe36 --- /dev/null +++ b/titles/diva/const.py @@ -0,0 +1,11 @@ +class DivaConstants(): + GAME_CODE = "SBZV" + + VER_PROJECT_DIVA_ARCADE = 0 + VER_PROJECT_DIVA_ARCADE_FUTURE_TONE = 1 + + VERSION_NAMES = ("Project Diva Arcade", "Project Diva Arcade Future Tone") + + @classmethod + def game_ver_to_string(cls, ver: int): + return cls.VERSION_NAMES[ver] \ No newline at end of file diff --git a/titles/diva/data/ItemCatalog.dat b/titles/diva/data/ItemCatalog.dat new file mode 100644 index 0000000..0459830 --- /dev/null +++ b/titles/diva/data/ItemCatalog.dat @@ -0,0 +1,204 @@ +0,0,縁なしメガネ(銀),50,2013-09-13,2029-01-01,0 +1,0,縁なしメガネ(赤),50,2013-09-13,2029-01-01,1 +2,0,ナイロールメガネ(銀),100,2013-09-13,2029-01-01,2 +3,0,ナイロールメガネ(茶),100,2014-03-18,2029-01-01,3 +4,0,フルフレームメガネ(橙),100,2014-03-18,2029-01-01,4 +5,0,フルフレームメガネ(黒),100,2013-09-13,2029-01-01,5 +6,0,アンダーリムメガネ(青),50,2014-02-12,2029-01-01,8 +7,0,アンダーリムメガネ(ピンク),50,2014-05-15,2029-01-01,9 +8,0,ぐるぐるメガネ,150,2014-09-26,2029-01-01,15 +9,0,三角メガネ(黒),100,2013-12-25,2029-01-01,10 +10,0,三角メガネ(赤),100,2014-03-18,2029-01-01,11 +11,0,サングラス,150,2015-01-09,2029-01-01,16 +12,0,ゴーグル,150,2014-12-02,2029-01-01,17 +13,0,電脳バイザー,150,2015-01-09,2029-01-01,18 +14,0,片眼鏡,150,2015-04-01,2029-01-01,14 +15,0,アイマスク,150,2014-10-23,2029-01-01,19 +16,0,キラ目マスク,200,2015-05-20,2029-01-01,20 +17,0,眼帯(黒),150,2013-09-13,2029-01-01,23 +18,0,眼帯(緑),150,2013-12-25,2029-01-01,24 +19,0,眼帯(黄),150,2014-02-12,2029-01-01,25 +20,0,眼帯(オレンジ),150,2014-05-15,2029-01-01,26 +21,0,眼帯(ピンク),150,2014-05-15,2029-01-01,27 +22,0,眼帯(青),150,2013-09-13,2029-01-01,28 +23,0,眼帯(赤),150,2013-09-13,2029-01-01,29 +24,0,眼帯(白),150,2015-07-22,2029-01-01,22 +25,0,京劇仮面(青),200,2016-01-08,2029-01-01,33 +26,0,京劇仮面(赤),200,2016-01-08,2029-01-01,34 +27,0,バタフライマスク,200,2015-07-22,2029-01-01,30 +28,0,マスカレードマスク,200,2014-07-24,2029-01-01,31 +30,0,ガスマスク,200,2015-07-22,2029-01-01,39 +31,0,能面(般若),200,2015-07-22,2029-01-01,40 +32,0,能面(女),200,2015-05-20,2029-01-01,41 +33,0,能面(翁),200,2015-05-20,2029-01-01,42 +34,0,白マスク,150,2014-07-24,2029-01-01,35 +35,0,白マスク(ペロ舌),200,2014-09-26,2029-01-01,36 +36,0,白マスク(ω),200,2014-12-02,2029-01-01,37 +37,0,白マスク(ε),200,2015-05-20,2029-01-01,38 +38,0,ネコひげ,50,2015-04-01,2029-01-01,43 +39,0,天使の輪,200,2015-07-22,2029-01-01,10 +40,0,ひよこ,200,2014-07-24,2029-01-01,11 +41,0,ナースキャップ,100,2013-09-13,2029-01-01,0 +42,0,メイドカチューシャ,100,2013-12-25,2029-01-01,1 +43,0,ネコミミ(黒),200,2013-09-13,2029-01-01,2 +44,0,ネコミミ(白),200,2013-12-25,2029-01-01,3 +45,0,ネコミミ(トラ),200,2014-03-18,2029-01-01,4 +46,0,ウサミミ(黒),200,2014-02-12,2029-01-01,5 +47,0,ウサミミ(白),200,2013-09-13,2029-01-01,6 +48,0,ウサミミ(ピンク),200,2014-09-26,2029-01-01,7 +49,0,一本角,150,2014-03-18,2029-01-01,8 +50,0,悪魔の角,200,2015-05-20,2029-01-01,9 +51,0,クセ毛 A(緑),150,2014-05-15,2029-01-01,12 +52,0,クセ毛 B(黄),150,2014-07-24,2029-01-01,22 +53,0,クセ毛 C(黄),150,2014-09-26,2029-01-01,31 +54,0,クセ毛 D(ピンク),150,2014-10-23,2029-01-01,41 +55,0,クセ毛 E(青),150,2014-12-02,2029-01-01,51 +56,0,クセ毛 F(こげ茶),150,2015-01-09,2029-01-01,61 +57,0,蝶ネクタイ(金),100,2013-12-25,2029-01-01,0 +58,0,蝶ネクタイ(黒),100,2013-09-13,2029-01-01,1 +59,0,蝶ネクタイ(赤),100,2013-09-13,2029-01-01,2 +60,0,リボン(青),150,2014-02-12,2029-01-01,3 +61,0,リボン(黄),150,2013-09-13,2029-01-01,4 +62,0,リボン(ピンク),150,2013-09-13,2029-01-01,5 +67,0,鈴(金),150,2014-10-23,2029-01-01,6 +68,0,鈴(銀),150,2014-10-23,2029-01-01,7 +69,0,光の翼,200,2014-12-02,2029-01-01,1 +70,0,天使の翼,200,2015-07-22,2029-01-01,0 +71,0,蝶の羽根,200,2015-04-01,2029-01-01,3 +72,0,悪魔の翼,200,2015-05-20,2029-01-01,2 +73,0,ぬいぐるみ,200,2013-09-13,2029-01-01,8 +74,0,リュックサック,150,2013-09-13,2029-01-01,4 +75,0,ナップサック,100,2013-12-25,2029-01-01,5 +76,0,ランドセル(黒),150,2014-02-12,2029-01-01,6 +77,0,ランドセル(赤),150,2014-02-12,2029-01-01,7 +78,0,ロケット,150,2014-07-24,2029-01-01,9 +79,0,ネコしっぽ(黒),200,2013-09-13,2029-01-01,11 +80,0,ネコしっぽ(白),200,2013-12-25,2029-01-01,12 +81,0,ネコしっぽ(トラ),200,2014-03-18,2029-01-01,13 +82,0,ウサしっぽ(黒),200,2014-02-12,2029-01-01,14 +83,0,ウサしっぽ(白),200,2013-09-13,2029-01-01,15 +84,0,ウサしっぽ(ピンク),200,2014-09-26,2029-01-01,16 +85,0,狐しっぽ,350,2014-05-15,2029-01-01,17 +86,0,悪魔の尾,200,2015-01-09,2029-01-01,18 +87,0,赤ぷよぼう,400,2016-09-21,2029-01-01,66 +88,0,緑ぷよのかみどめ,400,2016-09-21,2029-01-01,67 +89,0,ゼンマイ,150,2015-07-22,2029-01-01,10 +97,0,ゴールドクラウン,350,2016-01-08,2029-01-01,70 +98,0,プラチナクラウン,350,2016-01-08,2029-01-01,71 +99,0,シャープメガネ(藍),100,2014-09-26,2029-01-01,6 +100,0,シャープメガネ(紫),100,2013-12-25,2029-01-01,7 +101,0,丸メガネ(銀),150,2013-12-25,2029-01-01,12 +102,0,丸メガネ(べっ甲),150,2014-03-18,2029-01-01,13 +103,0,たこルカ,400,2016-05-18,2029-01-01,68 +104,0,シテヤンヨ,400,2016-03-17,2029-01-01,69 +105,0,はちゅねミク,400,2014-12-02,2029-01-01,19 +106,0,リンの幼虫,400,2016-01-08,2029-01-01,20 +107,0,劇画マスク,200,2016-01-08,2029-01-01,21 +115,0,シャープサングラス,150,2014-07-24,2029-01-01,45 +116,0,水中メガネ,200,2014-12-02,2029-01-01,44 +117,0,パーティー眼鏡,100,2015-04-01,2029-01-01,48 +118,0,ピエロ鼻,50,2015-05-20,2029-01-01,46 +119,0,キツネ面,200,2016-03-17,2029-01-01,47 +120,0,ミニシルクハット,350,2014-05-15,2029-01-01,74 +121,0,コック帽,50,2013-09-13,2029-01-01,73 +122,0,烏帽子,50,2015-04-01,2029-01-01,72 +123,0,ミクダヨー,1500,2015-04-01,2029-01-01,76 +124,0,記章,100,2014-10-23,2029-01-01,8 +131,0,ポスター付リュックサック,150,2014-03-18,2029-01-01,21 +132,0,リコーダー付ランドセル(黒),150,2015-01-09,2029-01-01,22 +133,0,リコーダー付ランドセル(赤),150,2015-01-09,2029-01-01,23 +134,0,ミクダヨー(ミニ),500,2014-10-23,2029-01-01,75 +135,0,クセ毛 A(黄),150,2014-05-15,2029-01-01,13 +136,0,クセ毛 A(ピンク),150,2014-05-15,2029-01-01,14 +137,0,クセ毛 A(青),150,2014-05-15,2029-01-01,15 +138,0,クセ毛 A(こげ茶),150,2014-05-15,2029-01-01,16 +139,0,クセ毛 A(金),150,2014-05-15,2029-01-01,17 +140,0,クセ毛 A(銀),150,2014-05-15,2029-01-01,18 +141,0,クセ毛 A(茶),150,2014-05-15,2029-01-01,19 +142,0,クセ毛 A(赤),150,2014-05-15,2029-01-01,20 +143,0,クセ毛 B(緑),150,2014-07-24,2029-01-01,21 +144,0,クセ毛 B(ピンク),150,2014-07-24,2029-01-01,23 +145,0,クセ毛 B(青),150,2014-07-24,2029-01-01,24 +146,0,クセ毛 B(こげ茶),150,2014-07-24,2029-01-01,25 +147,0,クセ毛 B(金),150,2014-07-24,2029-01-01,26 +148,0,クセ毛 B(銀),150,2014-07-24,2029-01-01,27 +149,0,クセ毛 B(茶),150,2014-07-24,2029-01-01,28 +150,0,クセ毛 B(赤),150,2014-07-24,2029-01-01,29 +151,0,クセ毛 C(緑),150,2014-09-26,2029-01-01,30 +152,0,クセ毛 C(ピンク),150,2014-09-26,2029-01-01,32 +153,0,クセ毛 C(青),150,2014-09-26,2029-01-01,33 +154,0,クセ毛 C(こげ茶),150,2014-09-26,2029-01-01,34 +155,0,クセ毛 C(金),150,2014-09-26,2029-01-01,35 +156,0,クセ毛 C(銀),150,2014-09-26,2029-01-01,36 +157,0,クセ毛 C(茶),150,2014-09-26,2029-01-01,37 +158,0,クセ毛 C(赤),150,2014-09-26,2029-01-01,38 +159,0,クセ毛 D(緑),150,2014-10-23,2029-01-01,39 +160,0,クセ毛 D(黄),150,2014-10-23,2029-01-01,40 +161,0,クセ毛 D(青),150,2014-10-23,2029-01-01,42 +162,0,クセ毛 D(こげ茶),150,2014-10-23,2029-01-01,43 +163,0,クセ毛 D(金),150,2014-10-23,2029-01-01,44 +164,0,クセ毛 D(銀),150,2014-10-23,2029-01-01,45 +165,0,クセ毛 D(茶),150,2014-10-23,2029-01-01,46 +166,0,クセ毛 D(赤),150,2014-10-23,2029-01-01,47 +167,0,クセ毛 E(緑),150,2014-12-02,2029-01-01,48 +168,0,クセ毛 E(黄),150,2014-12-02,2029-01-01,49 +169,0,クセ毛 E(ピンク),150,2014-12-02,2029-01-01,50 +170,0,クセ毛 E(こげ茶),150,2014-12-02,2029-01-01,52 +171,0,クセ毛 E(金),150,2014-12-02,2029-01-01,53 +172,0,クセ毛 E(銀),150,2014-12-02,2029-01-01,54 +173,0,クセ毛 E(茶),150,2014-12-02,2029-01-01,55 +174,0,クセ毛 E(赤),150,2014-12-02,2029-01-01,56 +175,0,クセ毛 F(緑),150,2015-01-09,2029-01-01,57 +176,0,クセ毛 F(黄),150,2015-01-09,2029-01-01,58 +177,0,クセ毛 F(ピンク),150,2015-01-09,2029-01-01,59 +178,0,クセ毛 F(青),150,2015-01-09,2029-01-01,60 +179,0,クセ毛 F(金),150,2015-01-09,2029-01-01,62 +180,0,クセ毛 F(銀),150,2015-01-09,2029-01-01,63 +181,0,クセ毛 F(茶),150,2015-01-09,2029-01-01,64 +182,0,クセ毛 F(赤),150,2015-01-09,2029-01-01,65 +183,0,イヌミミ,200,2015-10-15,2029-01-01,77 +184,0,羊角,200,2016-09-21,2029-01-01,78 +185,0,悪魔の頭羽,200,2016-09-21,2029-01-01,79 +186,0,とりの巣,200,2016-03-17,2029-01-01,80 +187,0,おばけの三角ずきん,200,2016-07-20,2029-01-01,81 +188,0,パラボラアンテナ,200,2016-11-24,2029-01-01,82 +189,0,パーティ帽(赤),100,2016-12-15,2029-01-01,83 +190,0,パーティ帽(青),100,2016-12-15,2029-01-01,84 +191,0,パーティ帽(黄),100,2016-12-15,2029-01-01,85 +192,0,ホホジロザメ,300,2016-07-20,2029-01-01,86 +193,0,パンプキンヘッド,300,2015-10-15,2029-01-01,87 +194,0,雪だるまヘッド(ノーマル),300,2016-12-15,2029-01-01,88 +195,0,雪だるまヘッド(笑顔),300,2016-12-15,2029-01-01,89 +196,0,ハート(頭),200,2017-01-18,2029-01-01,90 +197,0,ぷんぷん,200,2016-11-24,2029-01-01,91 +198,0,汗(右),100,2015-10-15,2029-01-01,92 +199,0,汗(左),100,2015-10-15,2029-01-01,93 +200,0,!?,200,2016-11-24,2029-01-01,94 +201,0,でかメガネ,150,2016-07-20,2029-01-01,49 +204,0,つけひげ,150,2016-12-15,2029-01-01,52 +205,0,くちばし,100,2016-03-17,2029-01-01,53 +208,0,目隠し線,200,2016-05-18,2029-01-01,56 +210,0,つけえり,150,2015-04-01,2029-01-01,15 +211,0,ハーモニカ,150,2016-03-17,2029-01-01,16 +212,0,金メダル,200,2016-05-18,2029-01-01,17 +213,0,銀メダル,150,2016-05-18,2029-01-01,18 +214,0,銅メダル,100,2016-05-18,2029-01-01,19 +215,0,前かけ(緑),100,2016-11-24,2029-01-01,20 +216,0,前かけ(黄),100,2016-11-24,2029-01-01,21 +217,0,前かけ(橙),100,2016-11-24,2029-01-01,22 +218,0,前かけ(ピンク),100,2016-11-24,2029-01-01,23 +219,0,前かけ(青),100,2016-11-24,2029-01-01,24 +220,0,前かけ(赤),100,2016-11-24,2029-01-01,25 +221,0,初心者マーク,150,2016-07-20,2029-01-01,26 +222,0,タイマー(緑),50,2015-10-15,2029-01-01,27 +223,0,タイマー(赤),50,2015-10-15,2029-01-01,28 +224,0,ハート(胸),200,2017-01-18,2029-01-01,29 +225,0,失恋ハート,200,2017-01-18,2029-01-01,30 +226,0,機械の翼,200,2016-03-17,2029-01-01,24 +227,0,スクールバッグ,150,2017-01-18,2029-01-01,25 +228,0,押しボタン,200,2016-05-18,2029-01-01,26 +229,0,イヌしっぽ,200,2015-10-15,2029-01-01,27 +230,0,恐竜しっぽ,200,2016-07-20,2029-01-01,28 +231,0,猫又しっぽ,300,2016-09-21,2029-01-01,29 +232,0,九尾しっぽ,300,2016-12-15,2029-01-01,30 +233,0,ぶらさがりネコ,300,2017-01-18,2029-01-01,31 \ No newline at end of file diff --git a/titles/diva/data/PvList0.dat b/titles/diva/data/PvList0.dat new file mode 100644 index 0000000..7596877 --- /dev/null +++ b/titles/diva/data/PvList0.dat @@ -0,0 +1 @@ +1%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C2%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-04-08%252C2029-01-01%2C3%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-08-07%252C2029-01-01%2C4%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C5%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-02-12%252C2029-01-01%2C6%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-08-07%252C2029-01-01%2C7%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-12-03%a252C2029-01-01%2C8%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-09-05%252C2029-01-01%2C9%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C10%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-01-08%252C2029-01-01%2C11%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-05-23%252C2029-01-01%2C16%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C18%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C19%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C20%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C22%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C23%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-08-08%252C2029-01-01%2C24%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-10-03%252C2029-01-01%2C25%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C27%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-02-12%252C2029-01-01%2C28%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-08-07%252C2029-01-01%2C30%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-10-22%252C2029-01-01%2C37%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-06-06%252C2029-01-01%2C38%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-05-13%252C2029-01-01%2C39%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-01-08%252C2029-01-01%2C40%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2011-10-18%252C2029-01-01%2C41%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C42%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2012-02-03%252C2029-01-01%2C43%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-01-08%252C2029-01-01%2C44%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C45%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-02-12%252C2029-01-01%2C46%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-04-08%252C2029-01-01%2C47%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2011-11-30%252C2029-01-01%2C48%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C49%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-06-17%252C2029-01-01%2C50%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-02-12%252C2029-01-01%2C51%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-02-18%252C2029-01-01%2C52%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-04-08%252C2029-01-01%2C53%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-09-24%252C2029-01-01%2C54%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-08-08%252C2029-01-01%2C55%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-08-08%252C2029-01-01%2C56%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C57%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-12-03%252C2029-01-01%2C58%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-02-12%252C2029-01-01%2C59%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C60%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-04-08%252C2029-01-01%2C61%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2012-02-03%252C2029-01-01%2C62%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-07-16%252C2029-01-01%2C63%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-02-12%252C2029-01-01%2C64%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-05-13%252C2029-01-01%2C65%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-03-12%252C2029-01-01%2C66%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-11-13%252C2029-01-01%2C68%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C79%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2012-10-26%252C2029-01-01%2C81%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-02-12%252C2029-01-01%2C83%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2012-10-26%252C2029-01-01%2C86%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2012-10-26%252C2029-01-01%2C88%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-01-08%252C2029-01-01%2C92%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2012-10-26%252C2029-01-01%2C93%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2013-01-31%252C2029-01-01%2C94%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-09-24%252C2029-01-01%2C95%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2012-10-26%252C2029-01-01%2C96%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-02-18%252C2029-01-01%2C97%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2012-10-26%252C2029-01-01%2C102%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C204%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C206%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C208%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-09-05%252C2029-01-01%2C213%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2011-11-30%252C2029-01-01%2C216%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2013-08-31%252C2029-01-01%2C219%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-06-10%252C2029-01-01%2C220%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2013-08-31%252C2029-01-01%2C221%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-10-14%252C2029-01-01%2C225%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-10-22%252C2029-01-01%2C232%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-06-17%252C2029-01-01%2C234%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-02-12%252C2029-01-01%2C235%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2013-12-20%252C2029-01-01%2C241%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-02-12%252C2029-01-01%2C242%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-08-07%252C2029-01-01%2C243%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-07-16%252C2029-01-01%2C244%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-01-08%252C2029-01-01%2C247%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-08-08%252C2029-01-01%2C248%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-08-07%252C2029-01-01%2C249%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-02-12%252C2029-01-01%2C250%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-05-13%252C2029-01-01%2C251%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-09-24%252C2029-01-01%2C253%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-08-08%252C2029-01-01%2C254%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-12-21%252C2029-01-01%2C255%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-06-17%252C2029-01-01%2C257%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-04-08%252C2029-01-01%2C259%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-04-08%252C2029-01-01%2C260%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-04-08%252C2029-01-01%2C261%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-06-17%252C2029-01-01%2C262%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-10-14%252C2029-01-01%2C263%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-12-21%252C2029-01-01%2C265%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-10-14%252C2029-01-01%2C266%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2017-12-13%252C2029-01-01%2C267%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2017-12-13%252C2029-01-01%2C402%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-02-12%252C2029-01-01%2C405%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-01-08%252C2029-01-01%2C409%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C410%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2013-01-31%252C2029-01-01%2C415%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-06-10%252C2029-01-01%2C416%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C418%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C419%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C424%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-03-12%252C2029-01-01%2C427%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2011-12-15%252C2029-01-01%2C429%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-08-07%252C2029-01-01%2C430%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2013-01-31%252C2029-01-01%2C432%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-05-27%252C2029-01-01%2C433%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-02-12%252C2029-01-01%2C434%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-07-15%252C2029-01-01%2C436%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2012-09-27%252C2029-01-01%2C439%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-12-04%252C2029-01-01%2C440%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-12-04%252C2029-01-01%2C442%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-02-12%252C2029-01-01%2C443%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-05-23%252C2029-01-01%2C600%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C601%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-02-10%252C2029-01-01%2C602%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C604%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-08-08%252C2029-01-01%2C605%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-04-08%252C2029-01-01%2C608%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-05-27%252C2029-01-01%2C609%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-05-13%252C2029-01-01%2C610%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-05-27%252C2029-01-01%2C611%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C612%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-08-07%252C2029-01-01%2C613%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C615%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2013-12-20%252C2029-01-01%2C616%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C618%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-07-15%252C2029-01-01%2C620%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C622%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2013-12-20%252C2029-01-01%2C623%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-05-13%252C2029-01-01%2C624%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-07-15%252C2029-01-01%2C626%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C627%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-03-12%252C2029-01-01%2C628%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C630%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-09-18%252C2029-01-01%2C631%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-01-08%252C2029-01-01%2C637%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-03-12%252C2029-01-01%2C638%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C640%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-12-04%252C2029-01-01%2C641%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-12-04%252C2029-01-01%2C642%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-09-18%252C2029-01-01%2C710%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-02-12%252C2029-01-01%2C722%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-07-16%252C2029-01-01%2C723%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-07-16%252C2029-01-01%2C724%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-08-08%252C2029-01-01%2C725%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-01-08%252C2029-01-01%2C726%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-10-22%252C2029-01-01%2C727%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-05-11%252C2029-01-01%2C728%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-12-03%252C2029-01-01%2C729%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-06-16%252C2029-01-01%2C730%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-01-08%252C2029-01-01%2C731%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-12-03%252C2029-01-01%2C732%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-08-08%252C2029-01-01%2C733%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-01-08%252C2029-01-01%2C734%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-10-22%252C2029-01-01%2C736%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-08-08%252C2029-01-01%2C737%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-12-03%252C2029-01-01%2C739%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-08-07%252C2029-01-01%2C740%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-08-08%252C2029-01-01%2C832%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-08-08%252C2029-01-01%2C \ No newline at end of file diff --git a/titles/diva/data/PvList1.dat b/titles/diva/data/PvList1.dat new file mode 100644 index 0000000..89285de --- /dev/null +++ b/titles/diva/data/PvList1.dat @@ -0,0 +1 @@ +1%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C2%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-04-08%252C2029-01-01%2C3%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-08-07%252C2029-01-01%2C5%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-02-12%252C2029-01-01%2C8%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-09-05%252C2029-01-01%2C11%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-05-23%252C2029-01-01%2C12%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C13%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-08-07%252C2029-01-01%2C14%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-10-03%252C2029-01-01%2C15%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-10-03%252C2029-01-01%2C17%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-07-16%252C2029-01-01%2C20%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C21%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C22%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C23%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-08-08%252C2029-01-01%2C24%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-10-03%252C2029-01-01%2C25%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C27%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-02-12%252C2029-01-01%2C28%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-08-07%252C2029-01-01%2C29%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-10-14%252C2029-01-01%2C30%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-10-22%252C2029-01-01%2C31%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-04-08%252C2029-01-01%2C32%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-11-13%252C2029-01-01%2C37%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-06-06%252C2029-01-01%2C38%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-05-13%252C2029-01-01%2C39%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-01-08%252C2029-01-01%2C40%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2011-10-18%252C2029-01-01%2C41%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C42%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2012-02-03%252C2029-01-01%2C43%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-01-08%252C2029-01-01%2C44%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C45%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-02-12%252C2029-01-01%2C46%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-04-08%252C2029-01-01%2C47%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2011-11-30%252C2029-01-01%2C48%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C49%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-06-17%252C2029-01-01%2C50%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-02-12%252C2029-01-01%2C51%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-02-18%252C2029-01-01%2C52%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-04-08%252C2029-01-01%2C53%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-09-24%252C2029-01-01%2C54%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-08-08%252C2029-01-01%2C55%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-08-08%252C2029-01-01%2C56%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C57%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-12-03%252C2029-01-01%2C58%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-02-12%252C2029-01-01%2C59%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C60%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-04-08%252C2029-01-01%2C61%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2012-02-03%252C2029-01-01%2C62%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-07-16%252C2029-01-01%2C63%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-02-12%252C2029-01-01%2C64%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-05-13%252C2029-01-01%2C65%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-03-12%252C2029-01-01%2C66%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-11-13%252C2029-01-01%2C67%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C68%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C79%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2012-10-26%252C2029-01-01%2C81%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-02-12%252C2029-01-01%2C82%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-02-12%252C2029-01-01%2C83%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2012-10-26%252C2029-01-01%2C84%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-10-14%252C2029-01-01%2C85%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-12-03%252C2029-01-01%2C86%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2012-10-26%252C2029-01-01%2C87%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-04-08%252C2029-01-01%2C88%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-01-08%252C2029-01-01%2C89%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-10-14%252C2029-01-01%2C90%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-07-16%252C2029-01-01%2C91%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2012-10-26%252C2029-01-01%2C92%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2012-10-26%252C2029-01-01%2C93%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2013-01-31%252C2029-01-01%2C94%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-09-24%252C2029-01-01%2C95%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2012-10-26%252C2029-01-01%2C96%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-02-18%252C2029-01-01%2C97%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2012-10-26%252C2029-01-01%2C101%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-09-05%252C2029-01-01%2C102%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C103%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2013-08-31%252C2029-01-01%2C104%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2013-08-31%252C2029-01-01%2C201%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C202%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-02-12%252C2029-01-01%2C203%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2013-01-31%252C2029-01-01%2C204%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C205%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C206%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C207%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C208%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-09-05%252C2029-01-01%2C209%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-05-13%252C2029-01-01%2C210%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-08-08%252C2029-01-01%2C211%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-08-08%252C2029-01-01%2C212%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-10-22%252C2029-01-01%2C213%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2011-11-30%252C2029-01-01%2C214%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2013-08-31%252C2029-01-01%2C215%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2012-05-28%252C2029-01-01%2C216%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2013-08-31%252C2029-01-01%2C218%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2013-08-31%252C2029-01-01%2C219%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-06-10%252C2029-01-01%2C220%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2013-08-31%252C2029-01-01%2C221%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-10-14%252C2029-01-01%2C222%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2013-08-31%252C2029-01-01%2C223%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2013-12-20%252C2029-01-01%2C224%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-01-08%252C2029-01-01%2C225%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-10-22%252C2029-01-01%2C226%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-11-13%252C2029-01-01%2C227%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2013-08-31%252C2029-01-01%2C228%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2013-08-31%252C2029-01-01%2C231%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-08-07%252C2029-01-01%2C232%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-06-17%252C2029-01-01%2C233%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-08-08%252C2029-01-01%2C234%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-02-12%252C2029-01-01%2C235%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2013-12-20%252C2029-01-01%2C236%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2013-12-20%252C2029-01-01%2C238%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-02-10%252C2029-01-01%2C239%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2013-12-20%252C2029-01-01%2C240%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2013-12-20%252C2029-01-01%2C241%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-02-12%252C2029-01-01%2C242%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-08-07%252C2029-01-01%2C243%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-07-16%252C2029-01-01%2C244%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-01-08%252C2029-01-01%2C246%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-04-08%252C2029-01-01%2C247%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-08-08%252C2029-01-01%2C248%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-08-07%252C2029-01-01%2C249%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-02-12%252C2029-01-01%2C250%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-05-13%252C2029-01-01%2C251%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-09-24%252C2029-01-01%2C253%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-08-08%252C2029-01-01%2C254%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-12-21%252C2029-01-01%2C255%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-06-17%252C2029-01-01%2C257%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-04-08%252C2029-01-01%2C259%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-04-08%252C2029-01-01%2C260%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-04-08%252C2029-01-01%2C261%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-06-17%252C2029-01-01%2C262%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-10-14%252C2029-01-01%2C263%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-12-21%252C2029-01-01%2C265%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-10-14%252C2029-01-01%2C266%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2017-12-13%252C2029-01-01%2C267%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2017-12-13%252C2029-01-01%2C401%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-09-05%252C2029-01-01%2C402%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-02-12%252C2029-01-01%2C403%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-10-03%252C2029-01-01%2C404%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-11-13%252C2029-01-01%2C405%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-01-08%252C2029-01-01%2C407%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-10-22%252C2029-01-01%2C408%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C409%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C410%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2013-01-31%252C2029-01-01%2C411%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C412%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C413%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-06-17%252C2029-01-01%2C414%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-01-08%252C2029-01-01%2C415%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-06-10%252C2029-01-01%2C416%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C417%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C418%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C419%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C420%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C421%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-06-10%252C2029-01-01%2C422%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-04-08%252C2029-01-01%2C423%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-04-08%252C2029-01-01%2C424%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-03-12%252C2029-01-01%2C425%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2011-12-15%252C2029-01-01%2C426%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2011-12-15%252C2029-01-01%2C427%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2011-12-15%252C2029-01-01%2C428%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-04-08%252C2029-01-01%2C429%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-08-07%252C2029-01-01%2C430%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2013-01-31%252C2029-01-01%2C431%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2012-05-28%252C2029-01-01%2C432%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-05-27%252C2029-01-01%2C433%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-02-12%252C2029-01-01%2C434%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-07-15%252C2029-01-01%2C435%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-10-14%252C2029-01-01%2C436%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2012-09-27%252C2029-01-01%2C437%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2012-09-27%252C2029-01-01%2C438%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-02-12%252C2029-01-01%2C439%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-12-04%252C2029-01-01%2C440%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-12-04%252C2029-01-01%2C441%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-01-08%252C2029-01-01%2C442%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-02-12%252C2029-01-01%2C443%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-05-23%252C2029-01-01%2C600%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C601%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-02-10%252C2029-01-01%2C602%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C603%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C604%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-08-08%252C2029-01-01%2C605%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-04-08%252C2029-01-01%2C607%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C608%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-05-27%252C2029-01-01%2C609%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-05-13%252C2029-01-01%2C610%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-05-27%252C2029-01-01%2C611%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C612%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-08-07%252C2029-01-01%2C613%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C614%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-05-27%252C2029-01-01%2C615%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2013-12-20%252C2029-01-01%2C616%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C617%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-08-08%252C2029-01-01%2C618%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-07-15%252C2029-01-01%2C619%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C620%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C621%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C622%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2013-12-20%252C2029-01-01%2C623%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-05-13%252C2029-01-01%2C624%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-07-15%252C2029-01-01%2C625%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-08-07%252C2029-01-01%2C626%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C627%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-03-12%252C2029-01-01%2C628%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C629%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-02-10%252C2029-01-01%2C630%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-09-18%252C2029-01-01%2C631%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-01-08%252C2029-01-01%2C637%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-03-12%252C2029-01-01%2C638%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C639%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-05-27%252C2029-01-01%2C640%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-12-04%252C2029-01-01%2C641%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-12-04%252C2029-01-01%2C642%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-09-18%252C2029-01-01%2C710%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-02-12%252C2029-01-01%2C722%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-07-16%252C2029-01-01%2C723%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-07-16%252C2029-01-01%2C724%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-08-08%252C2029-01-01%2C725%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-01-08%252C2029-01-01%2C726%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-10-22%252C2029-01-01%2C727%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-05-11%252C2029-01-01%2C728%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-12-03%252C2029-01-01%2C729%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-06-16%252C2029-01-01%2C730%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-01-08%252C2029-01-01%2C731%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-12-03%252C2029-01-01%2C732%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-08-08%252C2029-01-01%2C733%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-01-08%252C2029-01-01%2C734%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-10-22%252C2029-01-01%2C736%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-08-08%252C2029-01-01%2C737%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-12-03%252C2029-01-01%2C738%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-01-08%252C2029-01-01%2C739%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-08-07%252C2029-01-01%2C740%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-08-08%252C2029-01-01%2C832%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-08-08%252C2029-01-01 \ No newline at end of file diff --git a/titles/diva/data/PvList2.dat b/titles/diva/data/PvList2.dat new file mode 100644 index 0000000..fff1552 --- /dev/null +++ b/titles/diva/data/PvList2.dat @@ -0,0 +1 @@ +1%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C2%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-04-08%252C2029-01-01%2C3%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-08-07%252C2029-01-01%2C4%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C5%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-02-12%252C2029-01-01%2C6%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-08-07%252C2029-01-01%2C7%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-12-03%252C2029-01-01%2C8%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-09-05%252C2029-01-01%2C9%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C10%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-01-08%252C2029-01-01%2C11%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-05-23%252C2029-01-01%2C12%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C13%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-08-07%252C2029-01-01%2C14%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-10-03%252C2029-01-01%2C15%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-10-03%252C2029-01-01%2C16%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C17%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-07-16%252C2029-01-01%2C18%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C19%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C20%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C21%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C22%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C23%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-08-08%252C2029-01-01%2C24%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-10-03%252C2029-01-01%2C25%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C27%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-02-12%252C2029-01-01%2C28%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-08-07%252C2029-01-01%2C29%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-10-14%252C2029-01-01%2C30%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-10-22%252C2029-01-01%2C31%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-04-08%252C2029-01-01%2C32%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-11-13%252C2029-01-01%2C37%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-06-06%252C2029-01-01%2C38%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-05-13%252C2029-01-01%2C39%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-01-08%252C2029-01-01%2C40%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2011-10-18%252C2029-01-01%2C41%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C42%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2012-02-03%252C2029-01-01%2C43%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-01-08%252C2029-01-01%2C44%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C45%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-02-12%252C2029-01-01%2C46%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-04-08%252C2029-01-01%2C47%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2011-11-30%252C2029-01-01%2C48%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C49%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-06-17%252C2029-01-01%2C50%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-02-12%252C2029-01-01%2C51%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-02-18%252C2029-01-01%2C52%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-04-08%252C2029-01-01%2C53%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-09-24%252C2029-01-01%2C54%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-08-08%252C2029-01-01%2C55%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-08-08%252C2029-01-01%2C56%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C57%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-12-03%252C2029-01-01%2C58%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-02-12%252C2029-01-01%2C59%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C60%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-04-08%252C2029-01-01%2C61%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2012-02-03%252C2029-01-01%2C62%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-07-16%252C2029-01-01%2C63%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-02-12%252C2029-01-01%2C64%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-05-13%252C2029-01-01%2C65%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-03-12%252C2029-01-01%2C66%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-11-13%252C2029-01-01%2C67%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C68%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C79%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2012-10-26%252C2029-01-01%2C81%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-02-12%252C2029-01-01%2C82%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-02-12%252C2029-01-01%2C83%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2012-10-26%252C2029-01-01%2C84%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-10-14%252C2029-01-01%2C85%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-12-03%252C2029-01-01%2C86%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2012-10-26%252C2029-01-01%2C87%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-04-08%252C2029-01-01%2C88%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-01-08%252C2029-01-01%2C89%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-10-14%252C2029-01-01%2C90%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-07-16%252C2029-01-01%2C91%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2012-10-26%252C2029-01-01%2C92%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2012-10-26%252C2029-01-01%2C93%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2013-01-31%252C2029-01-01%2C94%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-09-24%252C2029-01-01%2C95%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2012-10-26%252C2029-01-01%2C96%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-02-18%252C2029-01-01%2C97%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2012-10-26%252C2029-01-01%2C101%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-09-05%252C2029-01-01%2C102%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C103%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2013-08-31%252C2029-01-01%2C104%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2013-08-31%252C2029-01-01%2C201%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C202%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-02-12%252C2029-01-01%2C203%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2013-01-31%252C2029-01-01%2C204%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C205%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C206%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C207%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C208%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-09-05%252C2029-01-01%2C209%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-05-13%252C2029-01-01%2C210%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-08-08%252C2029-01-01%2C211%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-08-08%252C2029-01-01%2C212%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-10-22%252C2029-01-01%2C213%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2011-11-30%252C2029-01-01%2C214%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2013-08-31%252C2029-01-01%2C215%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2012-05-28%252C2029-01-01%2C216%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2013-08-31%252C2029-01-01%2C218%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2013-08-31%252C2029-01-01%2C219%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-06-10%252C2029-01-01%2C220%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2013-08-31%252C2029-01-01%2C221%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-10-14%252C2029-01-01%2C222%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2013-08-31%252C2029-01-01%2C223%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2013-12-20%252C2029-01-01%2C224%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-01-08%252C2029-01-01%2C225%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-10-22%252C2029-01-01%2C226%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-11-13%252C2029-01-01%2C227%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2013-08-31%252C2029-01-01%2C228%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2013-08-31%252C2029-01-01%2C231%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-08-07%252C2029-01-01%2C232%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-06-17%252C2029-01-01%2C233%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-08-08%252C2029-01-01%2C234%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-02-12%252C2029-01-01%2C235%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2013-12-20%252C2029-01-01%2C236%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2013-12-20%252C2029-01-01%2C238%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-02-10%252C2029-01-01%2C239%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2013-12-20%252C2029-01-01%2C240%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2013-12-20%252C2029-01-01%2C241%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-02-12%252C2029-01-01%2C242%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-08-07%252C2029-01-01%2C243%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-07-16%252C2029-01-01%2C244%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-01-08%252C2029-01-01%2C246%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-04-08%252C2029-01-01%2C247%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-08-08%252C2029-01-01%2C248%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-08-07%252C2029-01-01%2C249%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-02-12%252C2029-01-01%2C250%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-05-13%252C2029-01-01%2C251%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-09-24%252C2029-01-01%2C253%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-08-08%252C2029-01-01%2C254%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-12-21%252C2029-01-01%2C255%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-06-17%252C2029-01-01%2C257%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-04-08%252C2029-01-01%2C259%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-04-08%252C2029-01-01%2C260%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-04-08%252C2029-01-01%2C261%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-06-17%252C2029-01-01%2C262%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-10-14%252C2029-01-01%2C263%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-12-21%252C2029-01-01%2C265%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-10-14%252C2029-01-01%2C266%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2017-12-13%252C2029-01-01%2C267%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2017-12-13%252C2029-01-01%2C401%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-09-05%252C2029-01-01%2C402%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-02-12%252C2029-01-01%2C403%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-10-03%252C2029-01-01%2C404%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-11-13%252C2029-01-01%2C405%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-01-08%252C2029-01-01%2C407%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-10-22%252C2029-01-01%2C408%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C409%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C410%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2013-01-31%252C2029-01-01%2C411%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C412%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C413%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-06-17%252C2029-01-01%2C414%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-01-08%252C2029-01-01%2C415%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-06-10%252C2029-01-01%2C416%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C417%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C418%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C419%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C420%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C421%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-06-10%252C2029-01-01%2C422%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-04-08%252C2029-01-01%2C423%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-04-08%252C2029-01-01%2C424%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-03-12%252C2029-01-01%2C425%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2011-12-15%252C2029-01-01%2C426%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2011-12-15%252C2029-01-01%2C427%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2011-12-15%252C2029-01-01%2C428%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-04-08%252C2029-01-01%2C429%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-08-07%252C2029-01-01%2C430%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2013-01-31%252C2029-01-01%2C431%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2012-05-28%252C2029-01-01%2C432%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-05-27%252C2029-01-01%2C433%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-02-12%252C2029-01-01%2C434%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-07-15%252C2029-01-01%2C435%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-10-14%252C2029-01-01%2C436%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2012-09-27%252C2029-01-01%2C437%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2012-09-27%252C2029-01-01%2C438%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-02-12%252C2029-01-01%2C439%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-12-04%252C2029-01-01%2C440%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-12-04%252C2029-01-01%2C441%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-01-08%252C2029-01-01%2C442%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-02-12%252C2029-01-01%2C443%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-05-23%252C2029-01-01%2C600%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C601%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-02-10%252C2029-01-01%2C602%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C603%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C604%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-08-08%252C2029-01-01%2C605%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-04-08%252C2029-01-01%2C607%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C608%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-05-27%252C2029-01-01%2C609%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-05-13%252C2029-01-01%2C610%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-05-27%252C2029-01-01%2C611%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C612%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-08-07%252C2029-01-01%2C613%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C614%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-05-27%252C2029-01-01%2C615%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2013-12-20%252C2029-01-01%2C616%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C617%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-08-08%252C2029-01-01%2C618%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-07-15%252C2029-01-01%2C619%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C620%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C621%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C622%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2013-12-20%252C2029-01-01%2C623%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-05-13%252C2029-01-01%2C624%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-07-15%252C2029-01-01%2C625%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-08-07%252C2029-01-01%2C626%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C627%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-03-12%252C2029-01-01%2C628%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C629%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-02-10%252C2029-01-01%2C630%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-09-18%252C2029-01-01%2C631%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-01-08%252C2029-01-01%2C637%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-03-12%252C2029-01-01%2C638%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C639%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-05-27%252C2029-01-01%2C640%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-12-04%252C2029-01-01%2C641%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-12-04%252C2029-01-01%2C642%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-09-18%252C2029-01-01%2C710%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-02-12%252C2029-01-01%2C722%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-07-16%252C2029-01-01%2C723%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-07-16%252C2029-01-01%2C724%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-08-08%252C2029-01-01%2C725%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-01-08%252C2029-01-01%2C726%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-10-22%252C2029-01-01%2C727%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-05-11%252C2029-01-01%2C728%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-12-03%252C2029-01-01%2C729%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-06-16%252C2029-01-01%2C730%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-01-08%252C2029-01-01%2C731%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-12-03%252C2029-01-01%2C732%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-08-08%252C2029-01-01%2C733%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-01-08%252C2029-01-01%2C734%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-10-22%252C2029-01-01%2C736%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-08-08%252C2029-01-01%2C737%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-12-03%252C2029-01-01%2C738%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-01-08%252C2029-01-01%2C739%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-08-07%252C2029-01-01%2C740%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-08-08%252C2029-01-01%2C832%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-08-08%252C2029-01-01%2C900%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2020-04-11%252C2029-01-01 \ No newline at end of file diff --git a/titles/diva/data/PvList3.dat b/titles/diva/data/PvList3.dat new file mode 100644 index 0000000..f2bdfaf --- /dev/null +++ b/titles/diva/data/PvList3.dat @@ -0,0 +1 @@ +1%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C1%252C1%252C1%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C2%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-04-08%252C2029-01-01%2C2%252C1%252C1%252C2000-01-01%252C2029-01-01%252C2016-04-08%252C2029-01-01%2C3%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-08-07%252C2029-01-01%2C3%252C1%252C1%252C2000-01-01%252C2029-01-01%252C2014-08-07%252C2029-01-01%2C4%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C5%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-02-12%252C2029-01-01%2C5%252C1%252C1%252C2000-01-01%252C2029-01-01%252C2016-02-12%252C2029-01-01%2C6%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-08-07%252C2029-01-01%2C6%252C1%252C1%252C2000-01-01%252C2029-01-01%252C2014-08-07%252C2029-01-01%2C7%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-12-03%252C2029-01-01%2C7%252C1%252C1%252C2000-01-01%252C2029-01-01%252C2015-12-03%252C2029-01-01%2C8%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-09-05%252C2029-01-01%2C8%252C1%252C1%252C2000-01-01%252C2029-01-01%252C2014-09-05%252C2029-01-01%2C9%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C10%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-01-08%252C2029-01-01%2C10%252C1%252C1%252C2000-01-01%252C2029-01-01%252C2016-01-08%252C2029-01-01%2C11%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-05-23%252C2029-01-01%2C11%252C1%252C1%252C2000-01-01%252C2029-01-01%252C2014-05-23%252C2029-01-01%2C12%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C13%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-08-07%252C2029-01-01%2C13%252C1%252C1%252C2000-01-01%252C2029-01-01%252C2014-08-07%252C2029-01-01%2C14%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-10-03%252C2029-01-01%2C14%252C1%252C1%252C2000-01-01%252C2029-01-01%252C2014-10-03%252C2029-01-01%2C15%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-10-03%252C2029-01-01%2C15%252C1%252C1%252C2000-01-01%252C2029-01-01%252C2014-10-03%252C2029-01-01%2C16%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C17%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-07-16%252C2029-01-01%2C17%252C1%252C1%252C2000-01-01%252C2029-01-01%252C2015-07-16%252C2029-01-01%2C18%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C19%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C19%252C1%252C1%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C20%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C21%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C22%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C23%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-08-08%252C2029-01-01%2C23%252C1%252C1%252C2000-01-01%252C2029-01-01%252C2016-08-08%252C2029-01-01%2C24%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-10-03%252C2029-01-01%2C24%252C1%252C1%252C2000-01-01%252C2029-01-01%252C2014-10-03%252C2029-01-01%2C25%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C27%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-02-12%252C2029-01-01%2C27%252C1%252C1%252C2000-01-01%252C2029-01-01%252C2016-02-12%252C2029-01-01%2C28%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-08-07%252C2029-01-01%2C28%252C1%252C1%252C2000-01-01%252C2029-01-01%252C2015-08-07%252C2029-01-01%2C29%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-10-14%252C2029-01-01%2C29%252C1%252C1%252C2000-01-01%252C2029-01-01%252C2016-10-14%252C2029-01-01%2C30%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-10-22%252C2029-01-01%2C30%252C1%252C1%252C2000-01-01%252C2029-01-01%252C2015-10-22%252C2029-01-01%2C31%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-04-08%252C2029-01-01%2C31%252C1%252C1%252C2000-01-01%252C2029-01-01%252C2016-04-08%252C2029-01-01%2C32%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-11-13%252C2029-01-01%2C32%252C1%252C1%252C2000-01-01%252C2029-01-01%252C2014-11-13%252C2029-01-01%2C37%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-06-06%252C2029-01-01%2C37%252C1%252C1%252C2000-01-01%252C2029-01-01%252C2014-06-06%252C2029-01-01%2C38%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-05-13%252C2029-01-01%2C38%252C1%252C1%252C2000-01-01%252C2029-01-01%252C2015-05-13%252C2029-01-01%2C39%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-01-08%252C2029-01-01%2C39%252C1%252C1%252C2000-01-01%252C2029-01-01%252C2015-01-08%252C2029-01-01%2C40%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2011-10-18%252C2029-01-01%2C40%252C1%252C1%252C2000-01-01%252C2029-01-01%252C2011-10-18%252C2029-01-01%2C41%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C42%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2012-02-03%252C2029-01-01%2C43%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-01-08%252C2029-01-01%2C43%252C1%252C1%252C2000-01-01%252C2029-01-01%252C2015-01-08%252C2029-01-01%2C44%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C45%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-02-12%252C2029-01-01%2C45%252C1%252C1%252C2000-01-01%252C2029-01-01%252C2015-02-12%252C2029-01-01%2C46%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-04-08%252C2029-01-01%2C46%252C1%252C1%252C2000-01-01%252C2029-01-01%252C2016-04-08%252C2029-01-01%2C47%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2011-11-30%252C2029-01-01%2C48%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C49%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-06-17%252C2029-01-01%2C49%252C1%252C1%252C2000-01-01%252C2029-01-01%252C2016-06-17%252C2029-01-01%2C50%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-02-12%252C2029-01-01%2C50%252C1%252C1%252C2000-01-01%252C2029-01-01%252C2015-02-12%252C2029-01-01%2C51%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-02-18%252C2029-01-01%2C51%252C1%252C1%252C2000-01-01%252C2029-01-01%252C2016-02-18%252C2029-01-01%2C52%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-04-08%252C2029-01-01%2C52%252C1%252C1%252C2000-01-01%252C2029-01-01%252C2016-04-08%252C2029-01-01%2C53%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-09-24%252C2029-01-01%2C53%252C1%252C1%252C2000-01-01%252C2029-01-01%252C2015-09-24%252C2029-01-01%2C54%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-08-08%252C2029-01-01%2C54%252C1%252C1%252C2000-01-01%252C2029-01-01%252C2016-08-08%252C2029-01-01%2C55%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-08-08%252C2029-01-01%2C55%252C1%252C1%252C2000-01-01%252C2029-01-01%252C2016-08-08%252C2029-01-01%2C56%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C57%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-12-03%252C2029-01-01%2C57%252C1%252C1%252C2000-01-01%252C2029-01-01%252C2015-12-03%252C2029-01-01%2C58%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-02-12%252C2029-01-01%2C58%252C1%252C1%252C2000-01-01%252C2029-01-01%252C2016-02-12%252C2029-01-01%2C59%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C59%252C1%252C1%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C60%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-04-08%252C2029-01-01%2C60%252C1%252C1%252C2000-01-01%252C2029-01-01%252C2015-04-08%252C2029-01-01%2C61%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2012-02-03%252C2029-01-01%2C61%252C1%252C1%252C2000-01-01%252C2029-01-01%252C2012-02-03%252C2029-01-01%2C62%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-07-16%252C2029-01-01%2C62%252C1%252C1%252C2000-01-01%252C2029-01-01%252C2015-07-16%252C2029-01-01%2C63%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-02-12%252C2029-01-01%2C63%252C1%252C1%252C2000-01-01%252C2029-01-01%252C2015-02-12%252C2029-01-01%2C64%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-05-13%252C2029-01-01%2C64%252C1%252C1%252C2000-01-01%252C2029-01-01%252C2015-05-13%252C2029-01-01%2C65%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-03-12%252C2029-01-01%2C65%252C1%252C1%252C2000-01-01%252C2029-01-01%252C2015-03-12%252C2029-01-01%2C66%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-11-13%252C2029-01-01%2C66%252C1%252C1%252C2000-01-01%252C2029-01-01%252C2014-11-13%252C2029-01-01%2C67%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C68%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C79%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2012-10-26%252C2029-01-01%2C81%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-02-12%252C2029-01-01%2C81%252C1%252C1%252C2000-01-01%252C2029-01-01%252C2015-02-12%252C2029-01-01%2C82%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-02-12%252C2029-01-01%2C82%252C1%252C1%252C2000-01-01%252C2029-01-01%252C2016-02-12%252C2029-01-01%2C83%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2012-10-26%252C2029-01-01%2C84%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-10-14%252C2029-01-01%2C84%252C1%252C1%252C2000-01-01%252C2029-01-01%252C2016-10-14%252C2029-01-01%2C85%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-12-03%252C2029-01-01%2C85%252C1%252C1%252C2000-01-01%252C2029-01-01%252C2015-12-03%252C2029-01-01%2C86%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2012-10-26%252C2029-01-01%2C87%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-04-08%252C2029-01-01%2C87%252C1%252C1%252C2000-01-01%252C2029-01-01%252C2015-04-08%252C2029-01-01%2C88%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-01-08%252C2029-01-01%2C88%252C1%252C1%252C2000-01-01%252C2029-01-01%252C2015-01-08%252C2029-01-01%2C89%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-10-14%252C2029-01-01%2C89%252C1%252C1%252C2000-01-01%252C2029-01-01%252C2016-10-14%252C2029-01-01%2C90%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-07-16%252C2029-01-01%2C90%252C1%252C1%252C2000-01-01%252C2029-01-01%252C2015-07-16%252C2029-01-01%2C91%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2012-10-26%252C2029-01-01%2C92%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2012-10-26%252C2029-01-01%2C93%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2013-01-31%252C2029-01-01%2C94%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-09-24%252C2029-01-01%2C94%252C1%252C1%252C2000-01-01%252C2029-01-01%252C2015-09-24%252C2029-01-01%2C95%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2012-10-26%252C2029-01-01%2C96%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-02-18%252C2029-01-01%2C96%252C1%252C1%252C2000-01-01%252C2029-01-01%252C2016-02-18%252C2029-01-01%2C97%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2012-10-26%252C2029-01-01%2C101%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-09-05%252C2029-01-01%2C101%252C1%252C1%252C2000-01-01%252C2029-01-01%252C2014-09-05%252C2029-01-01%2C102%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C103%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2013-08-31%252C2029-01-01%2C104%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2013-08-31%252C2029-01-01%2C201%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C201%252C1%252C1%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C202%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-02-12%252C2029-01-01%2C202%252C1%252C1%252C2000-01-01%252C2029-01-01%252C2016-02-12%252C2029-01-01%2C203%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2013-01-31%252C2029-01-01%2C204%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C205%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C206%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C207%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C208%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-09-05%252C2029-01-01%2C208%252C1%252C1%252C2000-01-01%252C2029-01-01%252C2014-09-05%252C2029-01-01%2C209%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-05-13%252C2029-01-01%2C209%252C1%252C1%252C2000-01-01%252C2029-01-01%252C2015-05-13%252C2029-01-01%2C210%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-08-08%252C2029-01-01%2C210%252C1%252C1%252C2000-01-01%252C2029-01-01%252C2016-08-08%252C2029-01-01%2C211%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-08-08%252C2029-01-01%2C211%252C1%252C1%252C2000-01-01%252C2029-01-01%252C2016-08-08%252C2029-01-01%2C212%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-10-22%252C2029-01-01%2C212%252C1%252C1%252C2000-01-01%252C2029-01-01%252C2015-10-22%252C2029-01-01%2C213%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2011-11-30%252C2029-01-01%2C214%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2013-08-31%252C2029-01-01%2C215%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2012-05-28%252C2029-01-01%2C216%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2013-08-31%252C2029-01-01%2C218%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2013-08-31%252C2029-01-01%2C219%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-06-10%252C2029-01-01%2C219%252C1%252C1%252C2000-01-01%252C2029-01-01%252C2015-06-10%252C2029-01-01%2C220%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2013-08-31%252C2029-01-01%2C221%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-10-14%252C2029-01-01%2C221%252C1%252C1%252C2000-01-01%252C2029-01-01%252C2016-10-14%252C2029-01-01%2C222%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2013-08-31%252C2029-01-01%2C223%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2013-12-20%252C2029-01-01%2C224%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-01-08%252C2029-01-01%2C224%252C1%252C1%252C2000-01-01%252C2029-01-01%252C2016-01-08%252C2029-01-01%2C225%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-10-22%252C2029-01-01%2C226%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-11-13%252C2029-01-01%2C226%252C1%252C1%252C2000-01-01%252C2029-01-01%252C2014-11-13%252C2029-01-01%2C227%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2013-08-31%252C2029-01-01%2C228%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2013-08-31%252C2029-01-01%2C231%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-08-07%252C2029-01-01%2C231%252C1%252C1%252C2000-01-01%252C2029-01-01%252C2015-08-07%252C2029-01-01%2C232%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-06-17%252C2029-01-01%2C232%252C1%252C1%252C2000-01-01%252C2029-01-01%252C2016-06-17%252C2029-01-01%2C233%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-08-08%252C2029-01-01%2C234%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-02-12%252C2029-01-01%2C234%252C1%252C1%252C2000-01-01%252C2029-01-01%252C2016-02-12%252C2029-01-01%2C235%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2013-12-20%252C2029-01-01%2C236%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2013-12-20%252C2029-01-01%2C238%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-02-10%252C2029-01-01%2C239%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2013-12-20%252C2029-01-01%2C240%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2013-12-20%252C2029-01-01%2C241%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-02-12%252C2029-01-01%2C242%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-08-07%252C2029-01-01%2C243%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-07-16%252C2029-01-01%2C244%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-01-08%252C2029-01-01%2C246%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-04-08%252C2029-01-01%2C247%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-08-08%252C2029-01-01%2C248%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-08-07%252C2029-01-01%2C249%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-02-12%252C2029-01-01%2C250%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-05-13%252C2029-01-01%2C251%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-09-24%252C2029-01-01%2C253%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-08-08%252C2029-01-01%2C254%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-12-21%252C2029-01-01%2C255%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-06-17%252C2029-01-01%2C257%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-04-08%252C2029-01-01%2C259%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-04-08%252C2029-01-01%2C260%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-04-08%252C2029-01-01%2C261%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-06-17%252C2029-01-01%2C262%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-10-14%252C2029-01-01%2C263%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-12-21%252C2029-01-01%2C265%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-10-14%252C2029-01-01%2C266%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2017-12-13%252C2029-01-01%2C267%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2017-12-13%252C2029-01-01%2C401%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-09-05%252C2029-01-01%2C401%252C1%252C1%252C2000-01-01%252C2029-01-01%252C2014-09-05%252C2029-01-01%2C402%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-02-12%252C2029-01-01%2C402%252C1%252C1%252C2000-01-01%252C2029-01-01%252C2016-02-12%252C2029-01-01%2C403%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-10-03%252C2029-01-01%2C403%252C1%252C1%252C2000-01-01%252C2029-01-01%252C2014-10-03%252C2029-01-01%2C404%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-11-13%252C2029-01-01%2C404%252C1%252C1%252C2000-01-01%252C2029-01-01%252C2014-11-13%252C2029-01-01%2C405%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-01-08%252C2029-01-01%2C405%252C1%252C1%252C2000-01-01%252C2029-01-01%252C2016-01-08%252C2029-01-01%2C407%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-10-22%252C2029-01-01%2C407%252C1%252C1%252C2000-01-01%252C2029-01-01%252C2015-10-22%252C2029-01-01%2C408%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C409%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C410%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2013-01-31%252C2029-01-01%2C411%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C412%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C413%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-06-17%252C2029-01-01%2C413%252C1%252C1%252C2000-01-01%252C2029-01-01%252C2016-06-17%252C2029-01-01%2C414%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-01-08%252C2029-01-01%2C414%252C1%252C1%252C2000-01-01%252C2029-01-01%252C2015-01-08%252C2029-01-01%2C415%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-06-10%252C2029-01-01%2C415%252C1%252C1%252C2000-01-01%252C2029-01-01%252C2015-06-10%252C2029-01-01%2C416%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C417%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C418%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C419%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C420%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C421%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-06-10%252C2029-01-01%2C421%252C1%252C1%252C2000-01-01%252C2029-01-01%252C2015-06-10%252C2029-01-01%2C422%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-04-08%252C2029-01-01%2C422%252C1%252C1%252C2000-01-01%252C2029-01-01%252C2015-04-08%252C2029-01-01%2C423%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-04-08%252C2029-01-01%2C423%252C1%252C1%252C2000-01-01%252C2029-01-01%252C2016-04-08%252C2029-01-01%2C424%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-03-12%252C2029-01-01%2C424%252C1%252C1%252C2000-01-01%252C2029-01-01%252C2015-03-12%252C2029-01-01%2C425%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2011-12-15%252C2029-01-01%2C426%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2011-12-15%252C2029-01-01%2C427%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2011-12-15%252C2029-01-01%2C428%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-04-08%252C2029-01-01%2C428%252C1%252C1%252C2000-01-01%252C2029-01-01%252C2016-04-08%252C2029-01-01%2C429%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-08-07%252C2029-01-01%2C429%252C1%252C1%252C2000-01-01%252C2029-01-01%252C2015-08-07%252C2029-01-01%2C430%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2013-01-31%252C2029-01-01%2C431%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2012-05-28%252C2029-01-01%2C432%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-05-27%252C2029-01-01%2C433%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-02-12%252C2029-01-01%2C434%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-07-15%252C2029-01-01%2C435%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-10-14%252C2029-01-01%2C436%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2012-09-27%252C2029-01-01%2C437%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2012-09-27%252C2029-01-01%2C438%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-02-12%252C2029-01-01%2C439%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-12-04%252C2029-01-01%2C440%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-12-04%252C2029-01-01%2C441%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-01-08%252C2029-01-01%2C442%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-02-12%252C2029-01-01%2C443%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-05-23%252C2029-01-01%2C600%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C601%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-02-10%252C2029-01-01%2C602%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C603%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C604%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-08-08%252C2029-01-01%2C605%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-04-08%252C2029-01-01%2C607%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C608%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-05-27%252C2029-01-01%2C609%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-05-13%252C2029-01-01%2C610%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-05-27%252C2029-01-01%2C611%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C612%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-08-07%252C2029-01-01%2C613%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C614%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-05-27%252C2029-01-01%2C615%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2013-12-20%252C2029-01-01%2C616%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C617%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-08-08%252C2029-01-01%2C618%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-07-15%252C2029-01-01%2C619%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C620%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C621%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C622%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2013-12-20%252C2029-01-01%2C623%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-05-13%252C2029-01-01%2C624%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-07-15%252C2029-01-01%2C625%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-08-07%252C2029-01-01%2C626%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C627%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-03-12%252C2029-01-01%2C628%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C629%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-02-10%252C2029-01-01%2C630%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-09-18%252C2029-01-01%2C631%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-01-08%252C2029-01-01%2C637%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-03-12%252C2029-01-01%2C638%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2010-11-25%252C2029-01-01%2C639%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-05-27%252C2029-01-01%2C640%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-12-04%252C2029-01-01%2C641%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-12-04%252C2029-01-01%2C642%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2014-09-18%252C2029-01-01%2C710%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-02-12%252C2029-01-01%2C722%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-07-16%252C2029-01-01%2C723%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-07-16%252C2029-01-01%2C724%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-08-08%252C2029-01-01%2C725%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-01-08%252C2029-01-01%2C726%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-10-22%252C2029-01-01%2C727%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-05-11%252C2029-01-01%2C728%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-12-03%252C2029-01-01%2C729%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-06-16%252C2029-01-01%2C730%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-01-08%252C2029-01-01%2C731%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-12-03%252C2029-01-01%2C732%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-08-08%252C2029-01-01%2C733%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-01-08%252C2029-01-01%2C734%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-10-22%252C2029-01-01%2C736%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-08-08%252C2029-01-01%2C737%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-12-03%252C2029-01-01%2C738%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-01-08%252C2029-01-01%2C739%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2015-08-07%252C2029-01-01%2C740%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-08-08%252C2029-01-01%2C832%252C1%252C0%252C2000-01-01%252C2029-01-01%252C2016-08-08%252C2029-01-01 \ No newline at end of file diff --git a/titles/diva/data/PvList4.dat b/titles/diva/data/PvList4.dat new file mode 100644 index 0000000..cf07be9 --- /dev/null +++ b/titles/diva/data/PvList4.dat @@ -0,0 +1 @@ +%2A%2A%2A \ No newline at end of file diff --git a/titles/diva/data/QuestInfo.dat b/titles/diva/data/QuestInfo.dat new file mode 100644 index 0000000..702a9d1 --- /dev/null +++ b/titles/diva/data/QuestInfo.dat @@ -0,0 +1,60 @@ +1001,1,0,0,2022-06-18 09:00:00.0,2022-06-20 09:00:00.0,Play in the Simple Mode or Contest Mode,1,1,1 +1010,10,0,0,2022-06-18 09:00:00.0,2022-06-20 09:00:00.0,Play with a randomly selected Miku module,1,1,1 +1011,11,0,0,2022-06-18 09:00:00.0,2022-06-20 09:00:00.0,Hit COOL 500 times or more,1,3,1 +1012,12,0,0,2022-06-18 09:00:00.0,2022-06-20 09:00:00.0,Take a photo in the PV watching mode,1,1,1 +1013,13,0,0,2022-06-18 09:00:00.0,2022-06-20 09:00:00.0,Play with the SE turned OFF,1,1,1 +1002,2,0,0,2022-06-18 09:00:00.0,2022-06-20 09:00:00.0,Do some Max Chain Slides,1,1,1 +1003,3,0,0,2022-06-18 09:00:00.0,2022-06-20 09:00:00.0,Challenge yourself to beat a trial,1,1,1 +1004,4,0,0,2022-06-18 09:00:00.0,2022-06-20 09:00:00.0,Play a song on ,1,2,1 +1005,5,0,0,2022-06-18 09:00:00.0,2022-06-20 09:00:00.0,Play a chart by Misora,1,2,1 +1006,6,0,0,2022-06-18 09:00:00.0,2022-06-20 09:00:00.0,Score at least 390390 pts in any song,1,1,1 +1007,7,0,0,2022-06-18 09:00:00.0,2022-06-20 09:00:00.0,Play a song chosen at random,1,1,1 +1008,8,0,0,2022-06-18 09:00:00.0,2022-06-20 09:00:00.0,Play with at least 100 percent result,1,1,1 +1009,9,0,0,2022-06-18 09:00:00.0,2022-06-20 09:00:00.0,Play with the 169 module,1,1,1 +3001,1,2,0,2001-01-01 09:00:00.0,2100-01-01 08:59:59.0,Clear a song with the HISPEED mode,1,2,1 +3002,2,2,0,2001-01-01 09:00:00.0,2100-01-01 08:59:59.0,Clear a song with the HIDDEN mode,1,2,1 +3003,3,2,0,2001-01-01 09:00:00.0,2100-01-01 08:59:59.0,Clear a song with the SUDDEN mode,1,2,1 +3004,4,2,0,2001-01-01 09:00:00.0,2100-01-01 08:59:59.0,Enhance your Chain-Perfect Trial streak,1,4,1 +3005,5,2,0,2001-01-01 09:00:00.0,2100-01-01 08:59:59.0,Beat your rival in a song by percentage,1,4,1 +2001,1,1,0,2022-06-18 09:00:00.0,2022-06-25 09:00:00.0,Hit COOL at least 1300 times,1,3,1 +2002,2,1,0,2022-06-18 09:00:00.0,2022-06-25 09:00:00.0,Hit COOL at least 2000 times,1,3,1 +2003,3,1,0,2022-06-18 09:00:00.0,2022-06-25 09:00:00.0,Achieve a sum of MAX COMBO of 730 or more,1,3,1 +2004,4,1,0,2022-06-18 09:00:00.0,2022-06-25 09:00:00.0,Achieve a sum of MAX COMBO of 960 or more,1,3,1 +2005,5,1,0,2022-06-18 09:00:00.0,2022-06-25 09:00:00.0,Score at least 440000 pts in any song,1,1,1 +*** +*** +*** +*** +*** +*** +*** +*** +*** +*** +*** +*** +*** +*** +*** +*** +*** +*** +*** +*** +*** +*** +*** +*** +*** +*** +*** +*** +*** +*** +*** +*** +*** +*** +*** +*** +*** diff --git a/titles/diva/data/ShopCatalog.dat b/titles/diva/data/ShopCatalog.dat new file mode 100644 index 0000000..6274caf --- /dev/null +++ b/titles/diva/data/ShopCatalog.dat @@ -0,0 +1,401 @@ +0,0,初音ミク,0,2009-01-01,2029-01-01,1 +1,0,弱音ハク,50,2009-01-01,2029-01-01,1 +2,0,亞北ネル,50,2009-01-01,2029-01-01,4 +3,0,メイコスタイル,100,2009-01-01,2029-01-01,2 +4,0,リンスタイル,100,2009-01-01,2029-01-01,3 +5,0,スペチャン5,100,2009-01-01,2029-01-01,4 +6,0,スペチャン39,50,2009-01-01,2029-01-01,5 +7,0,ガリア軍第7小隊,100,2009-01-01,2029-01-01,6 +8,0,P-スタイルPB,50,2009-01-01,2029-01-01,31 +9,0,P-スタイルCW,50,2009-01-01,2029-01-01,32 +10,0,P-スタイルIS,50,2009-01-01,2029-01-01,33 +11,0,P-スタイルRP,50,2009-01-01,2029-01-01,34 +12,0,P-スタイルLP,50,2009-01-01,2029-01-01,35 +13,0,P-スタイルFB,50,2009-01-01,2029-01-01,36 +14,0,P-スタイルMG,50,2009-01-01,2029-01-01,37 +15,0,P-スタイルCG,300,2009-01-01,2029-01-01,38 +16,0,チア,50,2009-01-01,2029-01-01,7 +17,0,プラグイン,100,2009-01-01,2029-01-01,8 +18,0,ゴシック,100,2009-01-01,2029-01-01,9 +19,0,プリンセス,50,2009-01-01,2029-01-01,10 +20,0,ミコ,100,2009-01-01,2029-01-01,11 +21,0,にゃんこ,50,2009-01-01,2029-01-01,12 +22,0,ねむねむ,100,2009-01-01,2029-01-01,13 +23,0,ハートハンター,100,2009-01-01,2029-01-01,14 +24,0,ボーカル,50,2009-01-01,2029-01-01,15 +25,0,パンク,100,2009-01-01,2029-01-01,16 +26,0,ダンサー,50,2009-01-01,2029-01-01,17 +27,0,スター,100,2009-01-01,2029-01-01,18 +28,0,フェアリー,100,2009-01-01,2029-01-01,19 +29,0,スクール,100,2009-01-01,2029-01-01,20 +30,0,スノウ,50,2009-01-01,2029-01-01,21 +31,0,アラビアン,100,2009-01-01,2029-01-01,22 +32,0,みやび,50,2009-01-01,2029-01-01,23 +33,0,チャイナ,300,2009-01-01,2029-01-01,24 +34,0,マジシャン,50,2009-01-01,2029-01-01,25 +35,0,ホワイトドレス,100,2009-01-01,2029-01-01,26 +36,0,パイレーツ,50,2009-01-01,2029-01-01,27 +37,0,VN02,100,2009-01-01,2029-01-01,28 +38,0,ギャラクシー,100,2009-01-01,2029-01-01,29 +39,0,ハツネミク,100,2009-01-01,2029-01-01,30 +40,0,鏡音リン,50,2009-01-01,2029-01-01,1 +41,0,鏡音レン,50,2009-01-01,2029-01-01,1 +42,0,巡音ルカ,50,2009-01-01,2029-01-01,1 +43,0,咲音メイコ,300,2009-01-01,2029-01-01,7 +44,0,メイコ,50,2009-01-01,2029-01-01,1 +45,0,カイト,50,2009-01-01,2029-01-01,1 +46,0,初音ミク スイムウェアS,1000,2009-01-01,2029-01-01,140 +47,0,初音ミク スイムウェア,1000,2009-01-01,2029-01-01,141 +48,0,鏡音リン スイムウェア,1000,2009-01-01,2029-01-01,39 +49,0,鏡音レン スイムウェア,300,2009-01-01,2029-01-01,33 +50,0,巡音ルカ スイムウェア,1000,2009-01-01,2029-01-01,31 +51,0,メイコ スイムウェア,1000,2009-01-01,2029-01-01,24 +52,0,カイト スイムウェア,300,2009-01-01,2029-01-01,31 +53,0,初音ミク アペンド,300,2010-08-31,2029-01-01,152 +54,0,ホワイトワンピース,100,2010-11-16,2029-01-01,49 +55,0,ナチュラル,200,2010-11-16,2029-01-01,48 +56,0,スピリチュアル,200,2010-11-16,2029-01-01,41 +57,0,カラフルドロップ,200,2010-12-27,2029-01-01,57 +58,0,初音ミク 蝶,100,2010-11-16,2029-01-01,40 +59,0,チアフルキャンディ,200,2010-12-27,2029-01-01,6 +60,0,スクールジャージ,100,2010-12-27,2029-01-01,3 +61,0,巡音ルカ 華,100,2010-11-16,2029-01-01,2 +62,0,初音ミク クリスマス,150,2010-11-30,2029-01-01,153 +63,0,鏡音リン クリスマス,150,2010-11-30,2029-01-01,50 +64,0,鏡音レン クリスマス,150,2010-11-30,2029-01-01,41 +65,0,巡音ルカ クリスマス,150,2010-11-30,2029-01-01,40 +66,0,メイコ クリスマス,150,2010-11-30,2029-01-01,32 +67,0,カイト クリスマス,150,2010-11-30,2029-01-01,41 +68,0,雪ミク 2010,300,2011-01-31,2029-01-01,154 +69,0,ヴィンテージドレス,200,2011-02-17,2029-01-01,39 +70,0,ピンクポップス,100,2011-01-31,2029-01-01,55 +71,0,ピンクポップス AS,100,2011-01-31,2029-01-01,56 +72,0,リアクター,200,2011-02-24,2029-01-01,3 +73,0,パンキッシュ,200,2011-02-24,2029-01-01,2 +74,0,ハードロック,200,2011-01-31,2029-01-01,5 +75,0,クラシック,200,2011-02-17,2029-01-01,2 +76,0,スカーレット,200,2011-02-17,2029-01-01,3 +77,0,雪ミク 2011,300,2011-01-31,2029-01-01,155 +78,0,おさんぽスタイル,150,2011-07-26,2029-01-01,42 +79,0,みくずきん,150,2011-05-20,2029-01-01,43 +80,0,イエロー,150,2011-11-01,2029-01-01,44 +81,0,ジャー★ジ,150,2011-09-08,2029-01-01,45 +82,0,ノーブル,150,2011-05-20,2029-01-01,46 +83,0,パウダー,150,2011-09-08,2029-01-01,47 +84,0,エールダンジュ,150,2011-11-01,2029-01-01,50 +85,0,スペイシーナース,200,2012-03-13,2029-01-01,51 +86,0,初音ミク キュート,200,2011-07-26,2029-01-01,52 +87,0,エンジェル,200,2012-01-10,2029-01-01,53 +88,0,サイハテミク,150,2011-07-26,2029-01-01,54 +89,0,∞,200,2012-02-14,2029-01-01,58 +90,0,初音ミク スイムウェアB,1000,2011-07-26,2029-01-01,143 +91,0,アシンメトリーR,200,2011-09-08,2029-01-01,2 +92,0,EoEスタイル,200,2011-11-01,2029-01-01,4 +93,0,鏡音リン キュート,200,2011-07-26,2029-01-01,5 +94,0,鏡音リン スイムウェアT,1000,2011-07-26,2029-01-01,41 +95,0,アシンメトリーL,200,2011-09-08,2029-01-01,4 +96,0,鏡音レン スイムウェアWS,750,2011-07-26,2029-01-01,35 +97,0,シフォンワンピース,150,2011-06-21,2029-01-01,3 +98,0,フロイライン,200,2011-09-08,2029-01-01,4 +99,0,VFスーツ,200,2012-01-10,2029-01-01,6 +100,0,巡音ルカ スイムウェアP,1000,2011-07-26,2029-01-01,32 +101,0,キャンパス,200,2012-02-14,2029-01-01,3 +102,0,ネコサイバー,300,2011-06-21,2029-01-01,4 +103,0,カイト スイムウェアV,750,2011-07-26,2029-01-01,32 +104,0,カイト スイムウェアV AS,750,2011-07-26,2029-01-01,34 +105,0,ふわふわコート,200,2011-11-01,2029-01-01,2 +106,0,モダンガール,150,2012-03-13,2029-01-01,4 +107,0,モダンガール AS,150,2012-03-13,2029-01-01,5 +108,0,メイコ スイムウェアB,1000,2011-07-26,2029-01-01,26 +109,0,エスニック,200,2011-05-20,2029-01-01,5 +110,0,亞北ネル スイムウェア,1000,2011-07-26,2029-01-01,12 +111,0,サイバーダイブ,200,2011-05-20,2029-01-01,2 +112,0,弱音ハク スイムウェア,1000,2011-07-26,2029-01-01,11 +113,0,ブラックワンピース,300,2011-05-20,2029-01-01,8 +114,0,ブラックワンピース NS,300,2011-05-20,2029-01-01,9 +115,0,咲音メイコ スイムウェア,1000,2011-07-26,2029-01-01,13 +116,0,メイコ 大正浪漫,250,2011-11-01,2029-01-01,30 +117,0,鏡音リン スクールウェア,250,2011-12-06,2029-01-01,45 +118,0,鏡音レン スクールウェア,250,2011-12-06,2029-01-01,40 +119,0,巡音ルカ 魔女っ娘Style,250,2012-01-31,2029-01-01,37 +120,0,カイト ホワイトブレザー,250,2012-02-14,2029-01-01,38 +121,0,フェアリーマカロン,300,2011-06-21,2029-01-01,41 +122,0,セクシープディング,300,2011-06-21,2029-01-01,33 +124,0,ホワイト・イヴ,250,2012-11-05,2029-01-01,61 +125,0,Hello World.,250,2012-10-04,2029-01-01,68 +126,0,レーシングミク2010ver.,200,2012-11-22,2029-01-01,62 +127,0,レーシングミク2011ver.,250,2012-12-06,2029-01-01,63 +128,0,フェイ・イェン スタイル,250,2012-11-22,2029-01-01,66 +129,0,回転少女,250,2012-11-05,2029-01-01,71 +130,0,ラセツトムクロ,250,2012-05-24,2029-01-01,69 +131,0,オービット,250,2012-11-05,2029-01-01,60 +132,0,パッチワーク,250,2012-04-26,2029-01-01,65 +133,0,ソニックスタイル,250,2012-08-31,2029-01-01,59 +134,0,チロル,250,2012-10-04,2029-01-01,64 +135,0,コンフリクト,200,2012-04-26,2029-01-01,70 +136,0,シャイニー,250,2012-07-05,2029-01-01,72 +137,0,TYPE2020,250,2012-08-31,2029-01-01,67 +138,0,部活少女,250,2012-07-31,2029-01-01,6 +139,0,ゴシック・パープル,250,2012-07-31,2029-01-01,3 +141,0,鏡音リン アペンド,300,2011-12-27,2029-01-01,51 +142,0,ネームレス No.1,200,2012-12-27,2029-01-01,8 +143,0,レーシングリン2010ver.,200,2012-11-22,2029-01-01,12 +144,0,ブラックスター,250,2012-09-14,2029-01-01,7 +145,0,陽炎,250,2012-04-26,2029-01-01,11 +146,0,鏡音リン 蘇芳,150,2012-04-05,2029-01-01,9 +147,0,鏡音レン アペンド,300,2011-12-27,2029-01-01,42 +148,0,ブルームーン,250,2012-09-14,2029-01-01,5 +149,0,鏡音レン 藍鉄,150,2012-04-05,2029-01-01,6 +150,0,ストレンジダーク,250,2012-07-05,2029-01-01,8 +151,0,ネームレス No.7,200,2012-12-27,2029-01-01,9 +153,0,サイレンス,250,2012-07-05,2029-01-01,7 +154,0,レーシングルカ2010ver.,200,2012-11-22,2029-01-01,10 +155,0,サイバーネイション,300,2011-12-15,2029-01-01,42 +156,0,ナギサ・レプカ,200,2012-10-04,2029-01-01,8 +157,0,ナギサ・レプカ AS,200,2012-10-04,2029-01-01,9 +158,0,時雨,250,2012-05-24,2029-01-01,6 +159,0,スミレ,250,2012-07-05,2029-01-01,5 +160,0,VFニンジャ,200,2013-02-15,2029-01-01,7 +161,0,VFニンジャ AS,200,2013-02-15,2029-01-01,8 +162,0,怪盗ブラックテール,250,2012-11-05,2029-01-01,6 +163,0,紅葉,250,2012-05-24,2029-01-01,8 +164,0,レーシングメイコ2010ver.,200,2012-11-22,2029-01-01,9 +165,0,ローレライ,250,2012-08-31,2029-01-01,7 +166,0,ノスタルジー,250,2012-07-31,2029-01-01,10 +167,0,雪ミク 2012,300,2011-12-19,2029-01-01,156 +168,0,AMERICANA,300,2012-07-31,2029-01-01,167 +169,0,桜ミク,300,2012-04-05,2029-01-01,168 +170,0,巡音ルカ コンフリクト,300,2012-04-26,2029-01-01,43 +171,0,鏡音リン 蘇芳 妖狐,200,2012-04-05,2029-01-01,10 +172,0,鏡音レン 藍鉄 妖狐,200,2012-04-05,2029-01-01,7 +188,0,ドリーマー,250,2013-01-30,2029-01-01,120 +189,0,初音ミク 妄想ガール,250,2012-12-06,2029-01-01,121 +190,0,雪ミク 2013,300,2012-12-17,2029-01-01,157 +191,0,鏡音リン 妄想ガール,250,2012-12-06,2029-01-01,29 +192,0,ロジカリスト,250,2012-12-06,2029-01-01,25 +193,0,オンザロック,250,2013-01-30,2029-01-01,22 +194,0,雪ミク 2013 AS,300,2012-12-17,2029-01-01,158 +195,0,ディープスカイ,250,2014-02-25,2029-01-01,73 +196,0,紫揚羽,250,2015-04-23,2029-01-01,74 +197,0,メモリア,250,2015-03-26,2029-01-01,75 +198,0,理系少女,250,2014-06-10,2029-01-01,76 +199,0,ピエレッタ,250,2013-09-25,2029-01-01,77 +200,0,イノセント,250,2014-04-17,2029-01-01,78 +201,0,堕悪天使,250,2014-04-17,2029-01-01,79 +202,0,サマーメモリー,250,2014-08-28,2029-01-01,80 +203,0,初音ミク 翠玉,250,2016-05-26,2029-01-01,81 +204,0,ソリチュード,250,2015-04-23,2029-01-01,82 +205,0,ホーリーゴッデス,250,2015-05-28,2029-01-01,83 +206,0,フォニュエールスタイル,250,2014-07-29,2029-01-01,84 +207,0,ねこねこケープ,250,2014-06-10,2029-01-01,85 +208,0,アジテーション,250,2013-09-25,2029-01-01,86 +209,0,スターヴォイス,200,2013-09-25,2029-01-01,87 +210,0,ハートビート,250,2014-09-17,2029-01-01,89 +211,0,パンジー,250,2013-09-25,2029-01-01,90 +212,0,レーシングミク2012ver.,250,2013-03-12,2029-01-01,91 +213,0,わがまま工場長,250,2015-05-28,2029-01-01,92 +214,0,Hello,Good night.,250,2014-02-25,2029-01-01,93 +215,0,初音ミク みずたまビキニ,1000,2013-07-04,2029-01-01,145 +216,0,初音ミク スクール競泳,1000,2013-06-06,2029-01-01,144 +217,0,初音ミク 浴衣スタイル,200,2013-07-31,2029-01-01,94 +218,0,らんみんぐ,250,2013-04-26,2029-01-01,95 +219,0,リボンガール,250,2013-01-30,2029-01-01,96 +220,0,メランコリー,250,2014-01-15,2029-01-01,13 +221,0,トランスミッター,250,2014-04-17,2029-01-01,14 +222,0,鏡音リン 桜月,250,2013-12-10,2029-01-01,15 +223,0,鏡音リン 雨,250,2014-07-29,2029-01-01,16 +224,0,鏡音リン しましまビキニ,1000,2013-07-04,2029-01-01,42 +225,0,鏡音リン SW スクール,1000,2013-06-06,2029-01-01,43 +226,0,鏡音リン 浴衣スタイル,150,2013-07-31,2029-01-01,17 +227,0,魔導師のタマゴ,250,2013-09-11,2029-01-01,19 +228,0,スタイリッシュエナジーR,250,2013-04-05,2029-01-01,20 +229,0,トラッドスクール,250,2012-12-27,2029-01-01,21 +230,0,スターマイン,250,2013-09-25,2029-01-01,10 +231,0,レシーバー,250,2014-04-17,2029-01-01,11 +232,0,鏡音レン 鳳月,250,2014-07-29,2029-01-01,12 +233,0,鏡音レン 鶴,250,2013-12-10,2029-01-01,13 +234,0,バッドボーイ,200,2013-09-25,2029-01-01,14 +235,0,鏡音レン SW ボクサー,1000,2013-06-06,2029-01-01,36 +236,0,鏡音レン 浴衣スタイル,200,2013-07-31,2029-01-01,16 +237,0,スタイリッシュエナジーL,250,2013-04-05,2029-01-01,17 +238,0,生徒会執行部,250,2012-12-27,2029-01-01,18 +239,0,バッドボーイ AS,200,2013-09-25,2029-01-01,15 +240,0,ゆるふわコーデ,250,2014-06-25,2029-01-01,11 +241,0,エターナルホワイト,250,2013-12-10,2029-01-01,12 +242,0,アムール,250,2014-04-17,2029-01-01,13 +243,0,巡音ルカ 紅玉,250,2016-05-26,2029-01-01,14 +244,0,巡音ルカ リゾートビキニ,1000,2013-07-04,2029-01-01,34 +245,0,巡音ルカ 競泳タイプ,1000,2013-06-06,2029-01-01,35 +246,0,巡音ルカ 浴衣スタイル,200,2013-07-31,2029-01-01,15 +247,0,森の妖精姫,250,2013-09-11,2029-01-01,16 +248,0,クイン・ビー,250,2013-04-26,2029-01-01,17 +249,0,放課後モード,250,2013-01-30,2029-01-01,18 +250,0,レクイエム,250,2013-12-17,2029-01-01,9 +251,0,ギルティ,250,2014-04-17,2029-01-01,10 +252,0,ジェネラル,200,2013-09-25,2029-01-01,11 +253,0,KAITO ハーフスパッツ,1000,2013-06-06,2029-01-01,36 +254,0,KAITO 浴衣スタイル,200,2013-07-31,2029-01-01,13 +255,0,ジーニアス,250,2013-05-15,2029-01-01,14 +256,0,学ラン★パーカー,250,2013-02-15,2029-01-01,15 +257,0,ジェネラル AS,200,2013-09-25,2029-01-01,12 +258,0,ブルークリスタル,250,2014-11-05,2029-01-01,10 +259,0,ノエル・ルージュ,250,2013-12-10,2029-01-01,11 +260,0,MEIKO ロングパレオ,1000,2013-07-04,2029-01-01,27 +261,0,MEIKO ウォーターポロ,1000,2013-06-06,2029-01-01,28 +262,0,MEIKO 浴衣スタイル,200,2013-07-31,2029-01-01,12 +263,0,ホイッスル,250,2013-05-15,2029-01-01,13 +264,0,グラデュエート,250,2013-02-15,2029-01-01,14 +265,0,BBオペレーター,250,2013-03-12,2029-01-01,15 +266,0,鏡音リン 浴衣スタイル AS,150,2013-07-31,2029-01-01,18 +267,0,カイト V3,300,2013-03-12,2029-01-01,42 +268,0,深海少女,250,2013-07-31,2029-01-01,169 +269,0,ハニーウィップ,250,2014-10-02,2029-01-01,148 +270,0,壱ノ桜・桜花,150,2015-03-26,2029-01-01,149 +271,0,リンちゃん愛し隊1号,200,2014-12-18,2029-01-01,151 +272,0,シザーズ,250,2014-06-25,2029-01-01,46 +273,0,弐ノ桜・胡蝶,200,2015-03-26,2029-01-01,47 +274,0,鏡音リン Future Style,300,2014-12-18,2029-01-01,49 +275,0,トリッカー,250,2014-12-18,2029-01-01,38 +276,0,弐ノ桜・扇舞,200,2015-03-26,2029-01-01,39 +277,0,参ノ桜・楓香,200,2015-03-26,2029-01-01,38 +278,0,リンちゃん愛し隊2号,200,2014-12-18,2029-01-01,39 +279,0,零ノ桜・蒼雪,150,2015-03-26,2029-01-01,39 +280,0,零ノ桜・紅椿,200,2015-03-26,2029-01-01,31 +281,0,リンケージ,250,2013-12-17,2029-01-01,147 +282,0,スターヴォイス AS,200,2013-09-25,2029-01-01,88 +283,0,重音テト,300,2013-09-25,2029-01-01,14 +284,0,雪ミク 2014,300,2013-12-17,2029-01-01,159 +285,0,雪ミク 2014 AS,100,2029-01-01,2029-01-01,160 +286,0,CA 初音ミク,250,2014-01-15,2029-01-01,122 +287,0,CA 鏡音リン,250,2014-01-15,2029-01-01,30 +288,0,CA 巡音ルカ,250,2014-01-15,2029-01-01,26 +289,0,CA メイコ,250,2014-01-15,2029-01-01,19 +290,0,マジカルミライ,300,2014-02-12,2029-01-01,170 +291,0,Cheerful ミク,150,2014-02-25,2029-01-01,123 +292,0,Cheerful ミク AS,150,2014-02-25,2029-01-01,124 +293,0,Cheerful リン,200,2014-02-25,2029-01-01,31 +294,0,Cheerful レン,200,2014-02-25,2029-01-01,26 +295,0,Cheerful ルカ,200,2014-02-25,2029-01-01,27 +296,0,Cheerful カイト,200,2014-02-25,2029-01-01,23 +297,0,Cheerful メイコ,200,2014-02-25,2029-01-01,20 +298,0,Cheerful カイト AS,200,2029-01-01,2029-01-01,24 +299,0,初音ミク V3,300,2014-08-28,2029-01-01,171 +300,0,アバンガード,250,2015-07-30,2029-01-01,97 +301,0,ナナイロライン,250,2015-08-28,2029-01-01,98 +302,0,ブレス・ユー,250,2015-10-08,2029-01-01,99 +303,0,花詞,250,2015-11-05,2029-01-01,100 +304,0,華車,250,2015-11-05,2029-01-01,101 +305,0,リグレット,250,2015-11-05,2029-01-01,102 +306,0,マリオネット,250,2015-11-05,2029-01-01,104 +308,0,ライアー,250,2016-01-28,2029-01-01,105 +309,0,月光アゲハ,250,2015-12-22,2029-01-01,106 +310,0,サイレン,250,2015-10-08,2029-01-01,107 +311,0,ローザ・ビアンカ,250,2016-06-30,2029-01-01,108 +313,0,メテオライト,250,2015-07-30,2029-01-01,111 +314,0,シャノワール,200,2015-06-26,2029-01-01,112 +315,0,シャノワール AS,200,2015-06-26,2029-01-01,113 +316,0,シュープリーム,250,2016-04-01,2029-01-01,114 +317,0,オレンジブロッサム,250,2015-08-28,2029-01-01,115 +318,0,ディメンション,250,2015-07-30,2029-01-01,116 +319,0,ストリートポップ,250,2016-01-28,2029-01-01,117 +320,0,ゆるふわパステル,250,2016-01-28,2029-01-01,118 +321,0,夢見るパンダ,250,2015-06-26,2029-01-01,22 +322,0,フェイカー,250,2016-01-28,2029-01-01,23 +323,0,ヒマワリ,200,2015-12-22,2029-01-01,24 +324,0,ソレイユ,250,2015-12-22,2029-01-01,26 +325,0,フェアリーワンピース,250,2015-12-22,2029-01-01,27 +326,0,恋するシロクマ,250,2015-06-26,2029-01-01,19 +327,0,アヤサキ,200,2015-12-22,2029-01-01,20 +328,0,シエル,250,2015-12-22,2029-01-01,22 +329,0,イレイザー,250,2016-01-28,2029-01-01,23 +330,0,ホワイトエッジ,250,2015-12-22,2029-01-01,24 +331,0,サクセサー,250,2015-07-30,2029-01-01,19 +332,0,テンプテーション,250,2016-01-28,2029-01-01,20 +334,0,リクルーター,250,2015-01-27,2029-01-01,22 +335,0,フローラル,250,2016-01-28,2029-01-01,23 +336,0,ローザ・ブルー,250,2016-06-30,2029-01-01,16 +338,0,オリジネイター,250,2016-01-28,2029-01-01,19 +339,0,ホリデイ,250,2015-11-05,2029-01-01,20 +340,0,ブレイジング,250,2015-11-05,2029-01-01,16 +341,0,マリーン・リボン,250,2015-11-05,2029-01-01,17 +343,0,うさみみパーカー,250,2016-08-31,2029-01-01,119 +344,0,アルパーカー R,250,2016-09-29,2029-01-01,28 +345,0,アルパーカー L,250,2016-09-29,2029-01-01,25 +346,0,ねこみみパーカー,250,2016-08-31,2029-01-01,24 +347,0,おサカナつなぎ,250,2016-10-27,2029-01-01,21 +348,0,ひつじさんウェア,250,2016-10-27,2029-01-01,18 +349,0,初音ミク スイムウェア/ST,1000,2016-07-28,2029-01-01,142 +350,0,鏡音リン スイムウェア/ST,1000,2016-07-28,2029-01-01,40 +351,0,鏡音レン スイムウェア/ST,300,2016-07-28,2029-01-01,34 +352,0,巡音ルカ スイムウェアP/ST,1000,2016-07-28,2029-01-01,33 +353,0,KAITO スイムウェアV/ST,750,2016-07-28,2029-01-01,33 +354,0,KAITO スイムウェアV AS/ST,750,2016-07-28,2029-01-01,35 +355,0,MEIKO スイムウェア/ST,1000,2016-07-28,2029-01-01,25 +356,0,M・S・J,300,2016-04-01,2029-01-01,15 +359,0,out of the gravity,250,2014-08-28,2029-01-01,126 +360,0,インタビュア ミク,250,2014-10-02,2029-01-01,127 +361,0,インタビュア ルカ,250,2014-10-02,2029-01-01,28 +362,0,スイートパンプキン,300,2014-10-02,2029-01-01,172 +363,0,MEIKO V3,300,2014-11-05,2029-01-01,34 +364,0,雪ミク 2015,300,2014-12-18,2029-01-01,161 +365,0,壱ノ桜・白桜花,150,2015-03-26,2029-01-01,150 +366,0,零ノ桜・白雪,150,2015-03-26,2029-01-01,40 +367,0,ダイヤモンドダスト,250,2015-01-27,2029-01-01,25 +368,0,アイスフォグ,250,2015-01-27,2029-01-01,27 +369,0,テレカクシパーカー 黄色,250,2015-04-23,2029-01-01,28 +370,0,テレカクシパーカー 青色,250,2015-04-23,2029-01-01,26 +371,0,スチャラカハツネ,250,2015-05-28,2029-01-01,130 +372,0,マジックシェフ,250,2015-06-26,2029-01-01,32 +373,0,グラデーションリゾート,1000,2015-08-06,2029-01-01,146 +374,0,ミラクルスターリゾート,1000,2015-08-06,2029-01-01,44 +375,0,ポップスターリゾート,1000,2015-08-06,2029-01-01,37 +376,0,トゥインクルリゾート,1000,2015-08-06,2029-01-01,36 +377,0,プレイドリゾート,1000,2015-08-06,2029-01-01,37 +378,0,バイカラーリボンリゾート,1000,2015-08-06,2029-01-01,29 +379,0,ありふれミク,250,2015-08-28,2029-01-01,128 +380,0,P4Dスタイル,300,2016-06-23,2029-01-01,173 +381,0,PIANO*GIRL,250,2015-10-08,2029-01-01,129 +382,0,重音テト スイムウェア,1000,2015-11-05,2029-01-01,16 +383,0,巡音ルカV4X,300,2016-01-28,2029-01-01,44 +385,0,Trip The Light Fantastic,250,2016-04-27,2029-01-01,132 +386,0,Poppin Delight,250,2016-04-27,2029-01-01,33 +387,0,Bebop Knave,250,2016-04-27,2029-01-01,29 +389,0,プランセス・ブランシュ,250,2016-04-27,2029-01-01,133 +390,0,プランス・ブラン,250,2016-04-27,2029-01-01,27 +391,0,アドレサンスプリンセス,250,2016-04-27,2029-01-01,343 +392,0,アドレサンスナイト,250,2016-04-27,2029-01-01,30 +393,0,マーチ・ヘイヤ,250,2016-08-31,2029-01-01,136 +394,0,アゲアゲアゲイン,250,2016-02-26,2029-01-01,131 +395,0,エトワール,250,2016-06-30,2029-01-01,135 +398,0,フェアウェル,250,2016-06-30,2029-01-01,134 +399,0,天袖,250,2016-12-21,2029-01-01,36 +402,0,雪ミク 2016,300,2015-12-22,2029-01-01,162 +403,0,パジャマパーティ ミク,250,2017-01-26,2029-01-01,139 +404,0,パジャマパーティ リン,250,2017-01-26,2029-01-01,38 +405,0,パジャマパーティ レン,250,2017-01-26,2029-01-01,32 +406,0,パジャマパーティ ルカ,250,2017-01-26,2029-01-01,30 +407,0,パジャマパーティ カイト,250,2017-01-26,2029-01-01,30 +408,0,パジャマパーティ メイコ,250,2017-01-26,2029-01-01,23 +409,0,Phantom Thief ミク,250,2016-10-27,2029-01-01,137 +410,0,Phantom Thief リン,250,2016-10-27,2029-01-01,35 +411,0,Phantom Thief メイコ,250,2016-10-27,2029-01-01,21 +412,0,Phantom Thief カイト,250,2016-10-27,2029-01-01,28 +413,0,鉄道員・鶯,250,2016-12-21,2029-01-01,138 +414,0,鉄道員・金糸雀,250,2016-12-21,2029-01-01,37 +415,0,鉄道員・銀朱,250,2016-12-21,2029-01-01,31 +416,0,鉄道員・薔薇,250,2016-12-21,2029-01-01,29 +417,0,鉄道員・空,250,2016-12-21,2029-01-01,29 +418,0,鉄道員・紅葡萄,250,2016-12-21,2029-01-01,22 +419,0,雪ミク 2017,300,2016-12-21,2029-01-01,163 +420,0,ヒマワリ AS,200,2015-12-22,2029-01-01,25 +421,0,アヤサキ AS,200,2015-12-22,2029-01-01,21 +422,0,みくりすたる☆,300,2016-05-26,2029-01-01,125 +423,0,マイディアバニー,1000,2017-08-31,2029-01-01,174 +424,0,ローザ・ノッテ,250,2016-12-21,2029-01-01,110 +425,0,ローザ・ルーノ,250,2016-12-21,2029-01-01,18 +426,0,GHOST,250,2017-12-13,2029-01-01,175 +427,0,セレブレーション,300,2017-12-13,2029-01-01,176 +428,0,雪ミク 2018 AS,300,2019-04-24,2029-01-01,165 +429,0,雪ミク 2019,300,2019-04-24,2029-01-01,166 +430,0,雪ミク 2018,300,2019-04-24,2029-01-01,164 +431,0,Catch The Wave,900,2020-02-20,2029-01-01,177 diff --git a/titles/diva/database.py b/titles/diva/database.py new file mode 100644 index 0000000..f43c42e --- /dev/null +++ b/titles/diva/database.py @@ -0,0 +1,12 @@ +from core.data import Data +from core.config import CoreConfig +from titles.diva.schema import DivaProfileData, DivaScoreData, DivaItemData, DivaStaticData + +class DivaData(Data): + def __init__(self, cfg: CoreConfig) -> None: + super().__init__(cfg) + + self.profile = DivaProfileData(self.config, self.session) + self.score = DivaScoreData(self.config, self.session) + self.item = DivaItemData(self.config, self.session) + self.static = DivaStaticData(self.config, self.session) diff --git a/titles/diva/index.py b/titles/diva/index.py new file mode 100644 index 0000000..d48a125 --- /dev/null +++ b/titles/diva/index.py @@ -0,0 +1,105 @@ +from twisted.web.http import Request +import yaml +import logging, coloredlogs +from logging.handlers import TimedRotatingFileHandler +import zlib +import json +import urllib.parse +import base64 + +from core.config import CoreConfig +from titles.diva.config import DivaConfig +from titles.diva.base import DivaBase + +class DivaServlet(): + def __init__(self, core_cfg: CoreConfig, cfg_dir: str) -> None: + self.core_cfg = core_cfg + self.game_cfg = DivaConfig() + self.game_cfg.update(yaml.safe_load(open(f"{cfg_dir}/diva.yaml"))) + + self.base = DivaBase(core_cfg, self.game_cfg) + + self.logger = logging.getLogger("diva") + log_fmt_str = "[%(asctime)s] Diva | %(levelname)s | %(message)s" + log_fmt = logging.Formatter(log_fmt_str) + fileHandler = TimedRotatingFileHandler("{0}/{1}.log".format(self.core_cfg.server.log_dir, "diva"), encoding='utf8', + when="d", backupCount=10) + + fileHandler.setFormatter(log_fmt) + + consoleHandler = logging.StreamHandler() + consoleHandler.setFormatter(log_fmt) + + self.logger.addHandler(fileHandler) + self.logger.addHandler(consoleHandler) + + self.logger.setLevel(self.game_cfg.server.loglevel) + coloredlogs.install(level=self.game_cfg.server.loglevel, logger=self.logger, fmt=log_fmt_str) + + def render_POST(self, req: Request, version: int, url_path: str) -> bytes: + req_raw = req.content.getvalue() + url_header = req.getAllHeaders() + + #Ping Dispatch + if "THIS_STRING_SEPARATES"in str(url_header): + binary_request = req_raw.splitlines() + binary_cmd_decoded = binary_request[3].decode("utf-8") + binary_array = binary_cmd_decoded.split('&') + + bin_req_data = {} + + for kvp in binary_array: + split_bin = kvp.split("=") + bin_req_data[split_bin[0]] = split_bin[1] + + self.logger.info(f"Binary {bin_req_data['cmd']} Request") + self.logger.debug(bin_req_data) + + handler = getattr(self.base, f"handle_{bin_req_data['cmd']}_request") + resp = handler(bin_req_data) + + self.logger.debug(f"Response cmd={bin_req_data['cmd']}&req_id={bin_req_data['req_id']}&stat=ok{resp}") + return f"cmd={bin_req_data['cmd']}&req_id={bin_req_data['req_id']}&stat=ok{resp}".encode('utf-8') + + #Main Dispatch + json_string = json.dumps(req_raw.decode("utf-8")) #Take the response and decode as UTF-8 and dump + b64string = json_string.replace(r'\n', '\n') # Remove all \n and separate them as new lines + gz_string = base64.b64decode(b64string) # Decompressing the base64 string + + try: + url_data = zlib.decompress( gz_string ).decode("utf-8") # Decompressing the gzip + except zlib.error as e: + self.logger.error(f"Failed to defalte! {e} -> {gz_string}") + return "stat=0" + + req_kvp = urllib.parse.unquote(url_data) + req_data = {} + + # We then need to split each parts with & so we can reuse them to fill out the requests + splitted_request = str.split(req_kvp, "&") + for kvp in splitted_request: + split = kvp.split("=") + req_data[split[0]] = split[1] + + self.logger.info(f"{req_data['cmd']} Request") + self.logger.debug(req_data) + + func_to_find = f"handle_{req_data['cmd']}_request" + + # Load the requests + try: + handler = getattr(self.base, func_to_find) + resp = handler(req_data) + + except AttributeError as e: + self.logger.warning(f"Unhandled {req_data['cmd']} request {e}") + return f"cmd={req_data['cmd']}&req_id={req_data['req_id']}&stat=ok".encode('utf-8') + + except Exception as e: + self.logger.error(f"Error handling method {func_to_find} {e}") + return f"cmd={req_data['cmd']}&req_id={req_data['req_id']}&stat=ok".encode('utf-8') + + req.responseHeaders.addRawHeader(b"content-type", b"text/plain") + self.logger.debug(f"Response cmd={req_data['cmd']}&req_id={req_data['req_id']}&stat=ok{resp}") + + return f"cmd={req_data['cmd']}&req_id={req_data['req_id']}&stat=ok{resp}".encode('utf-8') diff --git a/titles/diva/read.py b/titles/diva/read.py new file mode 100644 index 0000000..c597315 --- /dev/null +++ b/titles/diva/read.py @@ -0,0 +1,203 @@ +from typing import Optional, Dict, List +from os import walk, path +import urllib + +from read import BaseReader +from core.config import CoreConfig +from titles.diva.database import DivaData +from titles.diva.const import DivaConstants + +class DivaReader(BaseReader): + def __init__(self, config: CoreConfig, version: int, bin_dir: Optional[str], opt_dir: Optional[str], extra: Optional[str]) -> None: + super().__init__(config, version, bin_dir, opt_dir, extra) + self.data = DivaData(config) + + try: + self.logger.info(f"Start importer for {DivaConstants.game_ver_to_string(version)}") + except IndexError: + self.logger.error(f"Invalid project diva version {version}") + exit(1) + + def read(self) -> None: + pull_bin_ram = True + pull_bin_rom = True + pull_opt_rom = True + + if not path.exists(f"{self.bin_dir}/ram"): + self.logger.warn(f"Couldn't find ram folder in {self.bin_dir}, skipping") + pull_bin_ram = False + + if not path.exists(f"{self.bin_dir}/rom"): + self.logger.warn(f"Couldn't find rom folder in {self.bin_dir}, skipping") + pull_bin_rom = False + + if self.opt_dir is not None: + opt_dirs = self.get_data_directories(self.opt_dir) + else: + pull_opt_rom = False + self.logger.warn("No option directory specified, skipping") + + if pull_bin_ram: + self.read_ram(f"{self.bin_dir}/ram") + if pull_bin_rom: + self.read_rom(f"{self.bin_dir}/rom") + if pull_opt_rom: + for dir in opt_dirs: + self.read_rom(f"{dir}/rom") + + def read_ram(self, ram_root_dir: str) -> None: + self.logger.info(f"Read RAM from {ram_root_dir}") + + if path.exists(f"{ram_root_dir}/databank"): + for root, dirs, files in walk(f"{ram_root_dir}/databank"): + for file in files: + if file.startswith("ShopCatalog_") or file.startswith("CustomizeItemCatalog_") or \ + (file.startswith("QuestInfo") and not file.startswith("QuestInfoTm")): + + with open(f"{root}/{file}", "r") as f: + file_data: str = urllib.parse.unquote(urllib.parse.unquote(f.read())) + if file_data == "***": + self.logger.info(f"{file} is empty, skipping") + continue + + file_lines: List[str] = file_data.split("\n") + + for line in file_lines: + split = line.split(",") + + if not split[0]: + split.pop(0) + + if file.startswith("ShopCatalog_"): + for x in range(0, len(split), 7): + self.logger.info(f"Added shop item {split[x+0]}") + + self.data.static.put_shop(self.version, split[x+0], split[x+2], split[x+6], split[x+3], + split[x+1], split[x+4], split[x+5]) + + elif file.startswith("CustomizeItemCatalog_") and len(split) >= 7: + for x in range(0, len(split), 7): + self.logger.info(f"Added item {split[x+0]}") + + self.data.static.put_items(self.version, split[x+0], split[x+2], split[x+6], split[x+3], + split[x+1], split[x+4], split[x+5]) + + elif file.startswith("QuestInfo") and len(split) >= 9: + self.logger.info(f"Added quest {split[0]}") + + self.data.static.put_quests(self.version, split[0], split[6], split[2], split[3], + split[7], split[8], split[1], split[4], split[5]) + + else: + continue + else: + self.logger.warn(f"Databank folder not found in {ram_root_dir}, skipping") + + def read_rom(self, rom_root_dir: str) -> None: + self.logger.info(f"Read ROM from {rom_root_dir}") + pv_list: Dict[str, Dict] = {} + + if path.exists(f"{rom_root_dir}/mdata_pv_db.txt"): + file_path = f"{rom_root_dir}/mdata_pv_db.txt" + elif path.exists(f"{rom_root_dir}/pv_db.txt"): + file_path = f"{rom_root_dir}/pv_db.txt" + else: + self.logger.warn(f"Cannot find pv_db.txt or mdata_pv_db.txt in {rom_root_dir}, skipping") + return + + with open(file_path, "r", encoding="utf-8") as f: + + for line in f.readlines(): + + if line.startswith("#") or not line: + continue + + line_split = line.split("=") + if len(line_split) != 2: + continue + + key = line_split[0] + val = line_split[1] + if val.endswith("\n"): + val = val[:-1] + + key_split = key.split(".") + pv_id = key_split[0] + key_args = [] + + for x in range(1, len(key_split)): + key_args.append(key_split[x]) + + try: + pv_list[pv_id] = self.add_branch(pv_list[pv_id], key_args, val) + except KeyError: + pv_list[pv_id] = {} + pv_list[pv_id] = self.add_branch(pv_list[pv_id], key_args, val) + + + for pv_id, pv_data in pv_list.items(): + song_id = int(pv_id.split("_")[1]) + if "songinfo" not in pv_data: + continue + if "illustrator" not in pv_data["songinfo"]: + pv_data["songinfo"]["illustrator"] = "-" + if "arranger" not in pv_data["songinfo"]: + pv_data["songinfo"]["arranger"] = "-" + if "lyrics" not in pv_data["songinfo"]: + pv_data["songinfo"]["lyrics"] = "-" + if "music" not in pv_data["songinfo"]: + pv_data["songinfo"]["music"] = "-" + + if "easy" in pv_data['difficulty'] and '0' in pv_data['difficulty']['easy']: + diff = pv_data['difficulty']['easy']['0']['level'].split('_') + self.logger.info(f"Added song {song_id} chart 0") + + self.data.static.put_music(self.version, song_id, 0, pv_data["song_name"], pv_data["songinfo"]["arranger"], + pv_data["songinfo"]["illustrator"], pv_data["songinfo"]["lyrics"], pv_data["songinfo"]["music"], + float(f"{diff[2]}.{diff[3]}"), pv_data["bpm"], pv_data["date"]) + + if "normal" in pv_data['difficulty'] and '0' in pv_data['difficulty']['normal']: + diff = pv_data['difficulty']['normal']['0']['level'].split('_') + self.logger.info(f"Added song {song_id} chart 1") + + self.data.static.put_music(self.version, song_id, 1, pv_data["song_name"], pv_data["songinfo"]["arranger"], + pv_data["songinfo"]["illustrator"], pv_data["songinfo"]["lyrics"], pv_data["songinfo"]["music"], + float(f"{diff[2]}.{diff[3]}"), pv_data["bpm"], pv_data["date"]) + + if "hard" in pv_data['difficulty'] and '0' in pv_data['difficulty']['hard']: + diff = pv_data['difficulty']['hard']['0']['level'].split('_') + self.logger.info(f"Added song {song_id} chart 2") + + self.data.static.put_music(self.version, song_id, 2, pv_data["song_name"], pv_data["songinfo"]["arranger"], + pv_data["songinfo"]["illustrator"], pv_data["songinfo"]["lyrics"], pv_data["songinfo"]["music"], + float(f"{diff[2]}.{diff[3]}"), pv_data["bpm"], pv_data["date"]) + + if "extreme" in pv_data['difficulty']: + if "0" in pv_data['difficulty']['extreme']: + diff = pv_data['difficulty']['extreme']['0']['level'].split('_') + self.logger.info(f"Added song {song_id} chart 3") + + self.data.static.put_music(self.version, song_id, 3, pv_data["song_name"], pv_data["songinfo"]["arranger"], + pv_data["songinfo"]["illustrator"], pv_data["songinfo"]["lyrics"], pv_data["songinfo"]["music"], + float(f"{diff[2]}.{diff[3]}"), pv_data["bpm"], pv_data["date"]) + + if "1" in pv_data['difficulty']['extreme']: + diff = pv_data['difficulty']['extreme']['1']['level'].split('_') + self.logger.info(f"Added song {song_id} chart 4") + + self.data.static.put_music(self.version, song_id, 4, pv_data["song_name"], pv_data["songinfo"]["arranger"], + pv_data["songinfo"]["illustrator"], pv_data["songinfo"]["lyrics"], pv_data["songinfo"]["music"], + float(f"{diff[2]}.{diff[3]}"), pv_data["bpm"], pv_data["date"]) + + def add_branch(self, tree: Dict, vector: List, value: str): + """ + Recursivly adds nodes to a dictionary + Author: iJames on StackOverflow + """ + key = vector[0] + tree[key] = value \ + if len(vector) == 1 \ + else self.add_branch(tree[key] if key in tree else {}, + vector[1:], + value) + return tree \ No newline at end of file diff --git a/titles/diva/schema/__init__.py b/titles/diva/schema/__init__.py new file mode 100644 index 0000000..57431ef --- /dev/null +++ b/titles/diva/schema/__init__.py @@ -0,0 +1,6 @@ +from titles.diva.schema.profile import DivaProfileData +from titles.diva.schema.score import DivaScoreData +from titles.diva.schema.item import DivaItemData +from titles.diva.schema.static import DivaStaticData + +__all__ = [DivaProfileData, DivaScoreData, DivaItemData, DivaStaticData] diff --git a/titles/diva/schema/item.py b/titles/diva/schema/item.py new file mode 100644 index 0000000..96d8ca5 --- /dev/null +++ b/titles/diva/schema/item.py @@ -0,0 +1,50 @@ +from typing import Optional, Dict, List +from sqlalchemy import Table, Column, UniqueConstraint, PrimaryKeyConstraint, and_, case +from sqlalchemy.types import Integer, String, TIMESTAMP, Boolean +from sqlalchemy.schema import ForeignKey +from sqlalchemy.sql import func +from sqlalchemy.dialects.mysql import insert + +from core.data.schema import BaseData, metadata + +shop = Table( + "diva_profile_shop", + metadata, + Column("id", Integer, primary_key=True, nullable=False), + Column("user", ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade"), nullable=False), + Column("version", Integer, nullable=False), + Column("mdl_eqp_ary", String(32)), + UniqueConstraint("user", "version", name="diva_profile_shop_uk"), + mysql_charset='utf8mb4' +) + +class DivaItemData(BaseData): + def put_shop(self, aime_id: int, version: int, mdl_eqp_ary: str) -> None: + sql = insert(shop).values( + version=version, + user=aime_id, + mdl_eqp_ary=mdl_eqp_ary + ) + + conflict = sql.on_duplicate_key_update( + mdl_eqp_ary = sql.inserted.mdl_eqp_ary + ) + + result = self.execute(conflict) + if result is None: + self.logger.error(f"{__name__} Failed to insert diva profile! aime id: {aime_id} array: {mdl_eqp_ary}") + return None + return result.lastrowid + + def get_shop(self, aime_id: int, version: int) -> Optional[List[Dict]]: + """ + Given a game version and either a profile or aime id, return the profile + """ + sql = shop.select(and_( + shop.c.version == version, + shop.c.user == aime_id + )) + + result = self.execute(sql) + if result is None: return None + return result.fetchone() \ No newline at end of file diff --git a/titles/diva/schema/profile.py b/titles/diva/schema/profile.py new file mode 100644 index 0000000..72d68ed --- /dev/null +++ b/titles/diva/schema/profile.py @@ -0,0 +1,113 @@ +from typing import Optional, Dict, List +from sqlalchemy import Table, Column, UniqueConstraint, PrimaryKeyConstraint, and_ +from sqlalchemy.types import Integer, String, TIMESTAMP, Boolean, JSON +from sqlalchemy.schema import ForeignKey +from sqlalchemy.sql import func, select +from sqlalchemy.dialects.mysql import insert + +from core.data.schema import BaseData, metadata + +profile = Table( + "diva_profile", + metadata, + Column("id", Integer, primary_key=True, nullable=False), + Column("user", ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade"), nullable=False), + Column("version", Integer, nullable=False), + Column("player_name", String(8), nullable=False), + Column("lv_str", String(24), nullable=False, server_default="Dab on 'em"), + Column("lv_num", Integer, nullable=False, server_default="0"), + Column("lv_pnt", Integer, nullable=False, server_default="0"), + Column("vcld_pts", Integer, nullable=False, server_default="0"), + Column("hp_vol", Integer, nullable=False, server_default="100"), + Column("btn_se_vol", Integer, nullable=False, server_default="100"), + Column("btn_se_vol2", Integer, nullable=False, server_default="100"), + Column("sldr_se_vol2", Integer, nullable=False, server_default="100"), + Column("sort_kind", Integer, nullable=False, server_default="2"), + Column("use_pv_mdl_eqp", String(8), nullable=False, server_default="true"), + Column("use_pv_btn_se_eqp", String(8), nullable=False, server_default="true"), + Column("use_pv_sld_se_eqp", String(8), nullable=False, server_default="false"), + Column("use_pv_chn_sld_se_eqp", String(8), nullable=False, server_default="false"), + Column("use_pv_sldr_tch_se_eqp", String(8), nullable=False, server_default="false"), + Column("nxt_pv_id", Integer, nullable=False, server_default="708"), + Column("nxt_dffclty", Integer, nullable=False, server_default="2"), + Column("nxt_edtn", Integer, nullable=False, server_default="0"), + Column("dsp_clr_brdr", Integer, nullable=False, server_default="7"), + Column("dsp_intrm_rnk", Integer, nullable=False, server_default="1"), + Column("dsp_clr_sts", Integer, nullable=False, server_default="1"), + Column("rgo_sts", Integer, nullable=False, server_default="1"), + Column("lv_efct_id", Integer, nullable=False, server_default="0"), + Column("lv_plt_id", Integer, nullable=False, server_default="1"), + Column("my_qst_id", String(128), server_default="-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"), + Column("my_qst_sts", String(128), server_default="-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"), + UniqueConstraint("user", "version", name="diva_profile_uk"), + mysql_charset='utf8mb4' +) + +class DivaProfileData(BaseData): + def create_profile(self, version: int, aime_id: int, player_name: str) -> Optional[int]: + """ + Given a game version, aime id, and player_name, create a profile and return it's ID + """ + sql = insert(profile).values( + version=version, + user=aime_id, + player_name=player_name + ) + + conflict = sql.on_duplicate_key_update( + player_name = sql.inserted.player_name + ) + + result = self.execute(conflict) + if result is None: + self.logger.error(f"{__name__} Failed to insert diva profile! aime id: {aime_id} username: {player_name}") + return None + return result.lastrowid + + def update_profile(self, profile_id: int, lv_num: int, lv_pnt: int, vcld_pts: int, hp_vol: int, btn_se_vol: int, btn_se_vol2: int, sldr_se_vol2: int, sort_kind: int, use_pv_mdl_eqp: str, use_pv_btn_se_eqp: str, use_pv_sld_se_eqp: str, use_pv_chn_sld_se_eqp: str, use_pv_sldr_tch_se_eqp: str, nxt_pv_id: int, nxt_dffclty: int, nxt_edtn: int, dsp_clr_brdr: int, dsp_intrm_rnk: int, dsp_clr_sts: int, rgo_sts: int, lv_efct_id: int, lv_plt_id: int, my_qst_id: str, my_qst_sts: str) -> None: + sql = profile.update(profile.c.user == profile_id).values( + + lv_num = lv_num, + lv_pnt = lv_pnt, + vcld_pts = vcld_pts, + hp_vol = hp_vol, + btn_se_vol = btn_se_vol, + btn_se_vol2 = btn_se_vol2, + sldr_se_vol2 = sldr_se_vol2, + sort_kind = sort_kind, + use_pv_mdl_eqp = use_pv_mdl_eqp, + use_pv_btn_se_eqp = use_pv_btn_se_eqp, + use_pv_sld_se_eqp = use_pv_sld_se_eqp, + use_pv_chn_sld_se_eqp = use_pv_chn_sld_se_eqp, + use_pv_sldr_tch_se_eqp = use_pv_sldr_tch_se_eqp, + nxt_pv_id = nxt_pv_id, + nxt_dffclty = nxt_dffclty, + nxt_edtn = nxt_edtn, + dsp_clr_brdr = dsp_clr_brdr, + dsp_intrm_rnk = dsp_intrm_rnk, + dsp_clr_sts = dsp_clr_sts, + rgo_sts = rgo_sts, + lv_efct_id = lv_efct_id, + lv_plt_id = lv_plt_id, + my_qst_id = my_qst_id, + my_qst_sts = my_qst_sts + + ) + + result = self.execute(sql) + if result is None: + self.logger.error(f"update_profile: failed to update profile! profile: {profile_id}") + return None + + def get_profile(self, aime_id: int, version: int) -> Optional[List[Dict]]: + """ + Given a game version and either a profile or aime id, return the profile + """ + sql = profile.select(and_( + profile.c.version == version, + profile.c.user == aime_id + )) + + result = self.execute(sql) + if result is None: return None + return result.fetchone() diff --git a/titles/diva/schema/score.py b/titles/diva/schema/score.py new file mode 100644 index 0000000..6cd0346 --- /dev/null +++ b/titles/diva/schema/score.py @@ -0,0 +1,141 @@ +from sqlalchemy import Table, Column, UniqueConstraint, PrimaryKeyConstraint, and_ +from sqlalchemy.types import Integer, String, TIMESTAMP, JSON, Boolean +from sqlalchemy.schema import ForeignKey +from sqlalchemy.sql import func +from sqlalchemy.dialects.mysql import insert +from typing import Optional, List, Dict, Any + +from core.data.schema import BaseData, metadata +from core.data import cached + +score = Table( + "diva_score", + metadata, + Column("id", Integer, primary_key=True, nullable=False), + Column("user", ForeignKey("aime_user.id", ondelete="cascade"), nullable=False), + Column("version", Integer), + Column("pv_id", Integer), + Column("difficulty", Integer), + Column("score", Integer), + Column("atn_pnt", Integer), + Column("clr_kind", Integer), + Column("sort_kind", Integer), + Column("cool", Integer), + Column("fine", Integer), + Column("safe", Integer), + Column("sad", Integer), + Column("worst", Integer), + Column("max_combo", Integer), + UniqueConstraint("user", "pv_id", "difficulty", name="diva_score_uk"), + mysql_charset='utf8mb4' +) + +playlog = Table( + "diva_playlog", + metadata, + Column("id", Integer, primary_key=True, nullable=False), + Column("user", ForeignKey("aime_user.id", ondelete="cascade"), nullable=False), + Column("version", Integer), + Column("pv_id", Integer), + Column("difficulty", Integer), + Column("score", Integer), + Column("atn_pnt", Integer), + Column("clr_kind", Integer), + Column("sort_kind", Integer), + Column("cool", Integer), + Column("fine", Integer), + Column("safe", Integer), + Column("sad", Integer), + Column("worst", Integer), + Column("max_combo", Integer), + Column("date_scored", TIMESTAMP, server_default=func.now()), + mysql_charset='utf8mb4' +) + +class DivaScoreData(BaseData): + def put_best_score(self, user_id: int, game_version: int, song_id: int, difficulty: int, song_score: int, atn_pnt: int, + clr_kind: int, sort_kind:int, cool: int, fine: int, safe: int, sad: int, worst: int, max_combo: int) -> Optional[int]: + """ + Update the user's best score for a chart + """ + sql = insert(score).values( + user=user_id, + version=game_version, + pv_id = song_id, + difficulty=difficulty, + score=song_score, + atn_pnt = atn_pnt, + clr_kind = clr_kind, + sort_kind = sort_kind, + cool = cool, + fine = fine, + safe = safe, + sad = sad, + worst = worst, + max_combo = max_combo, + ) + + conflict = sql.on_duplicate_key_update( + score=song_score, + atn_pnt = atn_pnt, + clr_kind = clr_kind, + sort_kind = sort_kind, + cool = cool, + fine = fine, + safe = safe, + sad = sad, + worst = worst, + max_combo = max_combo, + ) + + result = self.execute(conflict) + if result is None: + self.logger.error(f"{__name__} failed to insert best score! profile: {user_id}, song: {song_id}") + return None + + return result.lastrowid + + def put_playlog(self, user_id: int, game_version: int, song_id: int, difficulty: int, song_score: int, atn_pnt: int, + clr_kind: int, sort_kind:int, cool: int, fine: int, safe: int, sad: int, worst: int, max_combo: int) -> Optional[int]: + """ + Add an entry to the user's play log + """ + sql = playlog.insert().values( + user=user_id, + version=game_version, + pv_id = song_id, + difficulty=difficulty, + score=song_score, + atn_pnt = atn_pnt, + clr_kind = clr_kind, + sort_kind = sort_kind, + cool = cool, + fine = fine, + safe = safe, + sad = sad, + worst = worst, + max_combo = max_combo + ) + + result = self.execute(sql) + if result is None: + self.logger.error(f"{__name__} failed to insert playlog! profile: {user_id}, song: {song_id}, chart: {difficulty}") + return None + + return result.lastrowid + + def get_best_score(self, user_id: int, pv_id: int, chart_id: int) -> Optional[Dict]: + sql = score.select( + and_(score.c.user == user_id, score.c.pv_id == pv_id, score.c.difficulty == chart_id) + ) + + result = self.execute(sql) + if result is None: return None + return result.fetchone() + + def get_best_scores(self, user_id: int) -> Optional[Dict]: + sql = score.select(score.c.user == user_id) + + result = self.execute(sql) + if result is None: return None + return result.fetchall() diff --git a/titles/diva/schema/static.py b/titles/diva/schema/static.py new file mode 100644 index 0000000..6544420 --- /dev/null +++ b/titles/diva/schema/static.py @@ -0,0 +1,222 @@ +from typing import Dict, List, Optional +from sqlalchemy import Table, Column, UniqueConstraint, PrimaryKeyConstraint, and_ +from sqlalchemy.types import Integer, String, TIMESTAMP, Boolean, JSON, Float +from sqlalchemy.engine.base import Connection +from sqlalchemy.engine import Row +from sqlalchemy.schema import ForeignKey +from sqlalchemy.sql import func, select +from sqlalchemy.dialects.mysql import insert + +from core.data.schema import BaseData, metadata + +music = Table( + "diva_static_music", + metadata, + Column("id", Integer, primary_key=True, nullable=False), + Column("version", Integer, nullable=False), + Column("songId", Integer), + Column("chartId", Integer), + Column("title", String(255)), + Column("vocaloid_arranger", String(255)), + Column("pv_illustrator", String(255)), + Column("lyrics", String(255)), + Column("bg_music", String(255)), + Column("level", Float), + Column("bpm", Integer), + Column("date", String(255)), + UniqueConstraint("version", "songId", "chartId", name="diva_static_music_uk"), + mysql_charset='utf8mb4' +) + +quests = Table( + "diva_static_quests", + metadata, + Column("id", Integer, primary_key=True, nullable=False), + Column("version", Integer, nullable=False), + Column("questId", Integer), + Column("name", String(255)), + Column("quest_enable", Boolean, server_default="1"), + Column("kind", Integer), + Column("unknown_0", Integer), + Column("unknown_1", Integer), + Column("unknown_2", Integer), + Column("quest_order", Integer), + Column("start_datetime", String(255)), + Column("end_datetime", String(255)), + + UniqueConstraint("version", "questId", name="diva_static_quests_uk"), + mysql_charset='utf8mb4' +) + +shop = Table( + "diva_static_shop", + metadata, + Column("id", Integer, primary_key=True, nullable=False), + Column("version", Integer, nullable=False), + Column("shopId", Integer), + Column("name", String(255)), + Column("type", Integer), + Column("points", Integer), + Column("unknown_0", Integer), + Column("start_date", String(255)), + Column("end_date", String(255)), + Column("enabled", Boolean, server_default="1"), + UniqueConstraint("version", "shopId", name="diva_static_shop_uk"), + mysql_charset='utf8mb4' +) + +items = Table( + "diva_static_items", + metadata, + Column("id", Integer, primary_key=True, nullable=False), + Column("version", Integer, nullable=False), + Column("itemId", Integer), + Column("name", String(255)), + Column("type", Integer), + Column("points", Integer), + Column("unknown_0", Integer), + Column("start_date", String(255)), + Column("end_date", String(255)), + Column("enabled", Boolean, server_default="1"), + UniqueConstraint("version", "itemId", name="diva_static_items_uk"), + mysql_charset='utf8mb4' +) + +class DivaStaticData(BaseData): + def put_quests(self, version: int, questId: int, name: str, kind: int, unknown_0: int, unknown_1: int, unknown_2: int, quest_order: int, start_datetime: str, end_datetime: str) -> Optional[int]: + sql = insert(quests).values( + version = version, + questId = questId, + name = name, + kind = kind, + unknown_0 = unknown_0, + unknown_1 = unknown_1, + unknown_2 = unknown_2, + quest_order = quest_order, + start_datetime = start_datetime, + end_datetime = end_datetime + ) + + conflict = sql.on_duplicate_key_update( + name = name + ) + + result = self.execute(conflict) + if result is None: return None + return result.lastrowid + + def get_enabled_quests(self, version: int) -> Optional[List[Row]]: + sql = select(quests).where(and_(quests.c.version == version, quests.c.quest_enable == True)) + + result = self.execute(sql) + if result is None: return None + return result.fetchall() + + def put_shop(self, version: int, shopId: int, name: str, type: int, points: int, unknown_0: int, start_date: str, end_date: str) -> Optional[int]: + sql = insert(shop).values( + version = version, + shopId = shopId, + name = name, + type = type, + points = points, + unknown_0 = unknown_0, + start_date = start_date, + end_date = end_date + ) + + conflict = sql.on_duplicate_key_update( + name = name + ) + + result = self.execute(conflict) + if result is None: return None + return result.lastrowid + + def get_enabled_shop(self, version: int) -> Optional[List[Row]]: + sql = select(shop).where(and_(shop.c.version == version, shop.c.enabled == True)) + + result = self.execute(sql) + if result is None: return None + return result.fetchall() + + def put_items(self, version: int, itemId: int, name: str, type: int, points: int, unknown_0: int, start_date: str, end_date: str) -> Optional[int]: + sql = insert(items).values( + version = version, + itemId = itemId, + name = name, + type = type, + points = points, + unknown_0 = unknown_0, + start_date = start_date, + end_date = end_date + ) + + conflict = sql.on_duplicate_key_update( + name = name + ) + + result = self.execute(conflict) + if result is None: return None + return result.lastrowid + + def get_enabled_items(self, version: int) -> Optional[List[Row]]: + sql = select(items).where(and_(items.c.version == version, items.c.enabled == True)) + + result = self.execute(sql) + if result is None: return None + return result.fetchall() + + def put_music(self, version: int, song: int, chart: int, title: str, arranger: str, illustrator: str, + lyrics: str, music_comp: str, level: float, bpm: int, date: str) -> Optional[int]: + sql = insert(music).values( + version = version, + songId = song, + chartId = chart, + title = title, + vocaloid_arranger = arranger, + pv_illustrator = illustrator, + lyrics = lyrics, + bg_music = music_comp, + level = level, + bpm = bpm, + date = date + ) + + conflict = sql.on_duplicate_key_update( + title = title, + vocaloid_arranger = arranger, + pv_illustrator = illustrator, + lyrics = lyrics, + bg_music = music_comp, + level = level, + bpm = bpm, + date = date + ) + + result = self.execute(conflict) + if result is None: return None + return result.lastrowid + + def get_music(self, version: int, song_id: Optional[int] = None) -> Optional[List[Row]]: + if song_id is None: + sql = select(music).where(music.c.version == version) + else: + sql = select(music).where(and_( + music.c.version == version, + music.c.songId == song_id, + )) + + result = self.execute(sql) + if result is None: return None + return result.fetchall() + + def get_music_chart(self, version: int, song_id: int, chart_id: int) -> Optional[List[Row]]: + sql = select(music).where(and_( + music.c.version == version, + music.c.songId == song_id, + music.c.chartId == chart_id + )) + + result = self.execute(sql) + if result is None: return None + return result.fetchone() diff --git a/titles/mai2/__init__.py b/titles/mai2/__init__.py new file mode 100644 index 0000000..1c51244 --- /dev/null +++ b/titles/mai2/__init__.py @@ -0,0 +1,18 @@ +from titles.mai2.index import Mai2Servlet +from titles.mai2.const import Mai2Constants +from titles.mai2.database import Mai2Data +from titles.mai2.read import Mai2Reader + +index = Mai2Servlet +database = Mai2Data +reader = Mai2Reader + +use_default_title = True +include_protocol = True +title_secure = False +game_codes = [Mai2Constants.GAME_CODE] +trailing_slash = True +use_default_host = False +host = "" + +current_schema_version = 1 \ No newline at end of file diff --git a/titles/mai2/base.py b/titles/mai2/base.py new file mode 100644 index 0000000..4b0b81c --- /dev/null +++ b/titles/mai2/base.py @@ -0,0 +1,477 @@ +from datetime import datetime, date, timedelta +from typing import Dict +import logging + +from core.config import CoreConfig +from titles.mai2.const import Mai2Constants +from titles.mai2.config import Mai2Config +from titles.mai2.database import Mai2Data + +class Mai2Base(): + def __init__(self, cfg: CoreConfig, game_cfg: Mai2Config) -> None: + self.core_config = cfg + self.game_config = game_cfg + self.game = Mai2Constants.GAME_CODE + self.version = Mai2Constants.VER_MAIMAI_DX + self.data = Mai2Data(cfg) + self.logger = logging.getLogger("mai2") + + def handle_get_game_setting_api_request(self, data: Dict): + reboot_start = date.strftime(datetime.now() + timedelta(hours=3), Mai2Constants.DATE_TIME_FORMAT) + reboot_end = date.strftime(datetime.now() + timedelta(hours=4), Mai2Constants.DATE_TIME_FORMAT) + return { + "gameSetting": { + "isMaintenance": "false", + "requestInterval": 10, + "rebootStartTime": reboot_start, + "rebootEndTime": reboot_end, + "movieUploadLimit": 10000, + "movieStatus": 0, + "movieServerUri": "", + "deliverServerUri": "", + "oldServerUri": "", + "usbDlServerUri": "", + "rebootInterval": 0 + }, + "isAouAccession": "true", + } + + def handle_get_game_ranking_api_request(self, data: Dict) -> Dict: + return {"length": 0, "gameRankingList": []} + + def handle_get_game_tournament_info_api_request(self, data: Dict) -> Dict: + # TODO: Tournament support + return {"length": 0, "gameTournamentInfoList": []} + + def handle_get_game_event_api_request(self, data: Dict) -> Dict: + events = self.data.static.get_enabled_events(self.version) + events_lst = [] + if events is None: return {"type": data["type"], "length": 0, "gameEventList": []} + + for event in events: + events_lst.append({ + "type": event["type"], + "id": event["eventId"], + "startDate": "2017-12-05 07:00:00.0", + "endDate": "2099-12-31 00:00:00.0" + }) + + return {"type": data["type"], "length": len(events_lst), "gameEventList": events_lst} + + def handle_get_game_ng_music_id_api_request(self, data: Dict) -> Dict: + return {"length": 0, "musicIdList": []} + + def handle_get_game_charge_api_request(self, data: Dict) -> Dict: + game_charge_list = self.data.static.get_enabled_tickets(self.version, 1) + if game_charge_list is None: return {"length": 0, "gameChargeList": []} + + charge_list = [] + for x in range(len(game_charge_list)): + charge_list.append({ + "orderId": x, + "chargeId": game_charge_list[x]["ticketId"], + "price": game_charge_list[x]["price"], + "startDate": "2017-12-05 07:00:00.0", + "endDate": "2099-12-31 00:00:00.0" + }) + + return {"length": len(charge_list), "gameChargeList": charge_list} + + def handle_upsert_client_setting_api_request(self, data: Dict) -> Dict: + pass + + def handle_upsert_client_upload_api_request(self, data: Dict) -> Dict: + pass + + def handle_upsert_client_bookkeeping_api_request(self, data: Dict) -> Dict: + pass + + def handle_upsert_client_testmode_api_request(self, data: Dict) -> Dict: + pass + + def handle_get_user_preview_api_request(self, data: Dict) -> Dict: + p = self.data.profile.get_profile_detail(data["userId"], self.version) + o = self.data.profile.get_profile_option(data["userId"], self.version) + if p is None or o is None: return {} # Register + profile = p._asdict() + option = o._asdict() + + return { + "userId": data["userId"], + "userName": profile["userName"], + "isLogin": False, + "lastGameId": profile["lastGameId"], + "lastDataVersion": profile["lastDataVersion"], + "lastRomVersion": profile["lastRomVersion"], + "lastLoginDate": profile["lastLoginDate"], + "lastPlayDate": profile["lastPlayDate"], + "playerRating": profile["playerRating"], + "nameplateId": 0, # Unused + "iconId": profile["iconId"], + "trophyId": 0, # Unused + "partnerId": profile["partnerId"], + "frameId": profile["frameId"], + "dispRate": option["dispRate"], # 0: all/begin, 1: disprate, 2: dispDan, 3: hide, 4: end + "totalAwake": profile["totalAwake"], + "isNetMember": profile["isNetMember"], + "dailyBonusDate": profile["dailyBonusDate"], + "headPhoneVolume": option["headPhoneVolume"], + "isInherit": False, # Not sure what this is or does?? + "banState": profile["banState"] if profile["banState"] is not None else 0 # New with uni+ + } + + def handle_user_login_api_request(self, data: Dict) -> Dict: + profile = self.data.profile.get_profile_detail(data["userId"], self.version) + + if profile is not None: + lastLoginDate = profile["lastLoginDate"] + loginCt = profile["playCount"] + + if "regionId" in data: + self.data.profile.put_profile_region(data["userId"], data["regionId"]) + else: + loginCt = 0 + lastLoginDate = "2017-12-05 07:00:00.0" + + return { + "returnCode": 1, + "lastLoginDate": lastLoginDate, + "loginCount": loginCt, + "consecutiveLoginCount": 0, # We don't really have a way to track this... + "loginId": loginCt # Used with the playlog! + } + + def handle_upload_user_playlog_api_request(self, data: Dict) -> Dict: + user_id = data["userId"] + playlog = data["userPlaylog"] + + self.data.score.put_playlog(user_id, playlog) + + def handle_upsert_user_all_api_request(self, data: Dict) -> Dict: + user_id = data["userId"] + upsert = data["upsertUserAll"] + + if "userData" in upsert and len(upsert["userData"]) > 0: + upsert["userData"][0]["isNetMember"] = 1 + upsert["userData"][0].pop("accessCode") + self.data.profile.put_profile_detail(user_id, self.version, upsert["userData"][0]) + + if "userExtend" in upsert and len(upsert["userExtend"]) > 0: + self.data.profile.put_profile_extend(user_id, self.version, upsert["userExtend"][0]) + + if "userGhost" in upsert: + for ghost in upsert["userGhost"]: + self.data.profile.put_profile_extend(user_id, self.version, ghost) + + if "userOption" in upsert and len(upsert["userOption"]) > 0: + self.data.profile.put_profile_option(user_id, self.version, upsert["userOption"][0]) + + if "userRatingList" in upsert and len(upsert["userRatingList"]) > 0: + self.data.profile.put_profile_rating(user_id, self.version, upsert["userRatingList"][0]) + + if "userActivityList" in upsert and len(upsert["userActivityList"]) > 0: + for k,v in upsert["userActivityList"][0].items(): + for act in v: + self.data.profile.put_profile_activity(user_id, act) + + if upsert["isNewCharacterList"] and int(upsert["isNewCharacterList"]) > 0: + for char in upsert["userCharacterList"]: + self.data.item.put_character(user_id, char["characterId"], char["level"], char["awakening"], char["useCount"]) + + if upsert["isNewItemList"] and int(upsert["isNewItemList"]) > 0: + for item in upsert["userItemList"]: + self.data.item.put_item(user_id, int(item["itemKind"]), item["itemId"], item["stock"], item["isValid"]) + + if upsert["isNewLoginBonusList"] and int(upsert["isNewLoginBonusList"]) > 0: + for login_bonus in upsert["userLoginBonusList"]: + self.data.item.put_login_bonus(user_id, login_bonus["bonusId"], login_bonus["point"], login_bonus["isCurrent"], login_bonus["isComplete"]) + + if upsert["isNewMapList"] and int(upsert["isNewMapList"]) > 0: + for map in upsert["userMapList"]: + self.data.item.put_map(user_id, map["mapId"], map["distance"], map["isLock"], map["isClear"], map["isComplete"]) + + if upsert["isNewMusicDetailList"] and int(upsert["isNewMusicDetailList"]) > 0: + for music in upsert["userMusicDetailList"]: + self.data.score.put_best_score(user_id, music) + + if upsert["isNewCourseList"] and int(upsert["isNewCourseList"]) > 0: + for course in upsert["userCourseList"]: + self.data.score.put_course(user_id, course) + + if upsert["isNewFavoriteList"] and int(upsert["isNewFavoriteList"]) > 0: + for fav in upsert["userFavoriteList"]: + self.data.item.put_favorite(user_id, fav["kind"], fav["itemIdList"]) + + if "isNewFriendSeasonRankingList" in upsert and int(upsert["isNewFriendSeasonRankingList"]) > 0: + for fsr in upsert["userFriendSeasonRankingList"]: + pass + + def handle_user_logout_api_request(self, data: Dict) -> Dict: + pass + + def handle_get_user_data_api_request(self, data: Dict) -> Dict: + profile = self.data.profile.get_profile_detail(data["userId"], self.version) + if profile is None: return + + profile_dict = profile._asdict() + profile_dict.pop("id") + profile_dict.pop("user") + profile_dict.pop("version") + + return { + "userId": data["userId"], + "userData": profile_dict + } + + def handle_get_user_extend_api_request(self, data: Dict) -> Dict: + extend = self.data.profile.get_profile_extend(data["userId"], self.version) + if extend is None: return + + extend_dict = extend._asdict() + extend_dict.pop("id") + extend_dict.pop("user") + extend_dict.pop("version") + + return { + "userId": data["userId"], + "userExtend": extend_dict + } + + def handle_get_user_option_api_request(self, data: Dict) -> Dict: + options = self.data.profile.get_profile_option(data["userId"], self.version) + if options is None: return + + options_dict = options._asdict() + options_dict.pop("id") + options_dict.pop("user") + options_dict.pop("version") + + return { + "userId": data["userId"], + "userOption": options_dict + } + + def handle_get_user_card_api_request(self, data: Dict) -> Dict: + return {"userId": data["userId"], "nextIndex": 0, "userCardList": []} + + def handle_get_user_charge_api_request(self, data: Dict) -> Dict: + return {"userId": data["userId"], "length": 0, "userChargeList": []} + + def handle_get_user_item_api_request(self, data: Dict) -> Dict: + kind = int(data["nextIndex"] / 10000000000) + next_idx = int(data["nextIndex"] % 10000000000) + user_items = self.data.item.get_items(data["userId"], kind) + user_item_list = [] + next_idx = 0 + + for x in range(next_idx, data["maxCount"]): + try: + user_item_list.append({"item_kind": user_items[x]["item_kind"], "item_id": user_items[x]["item_id"], + "stock": user_items[x]["stock"], "isValid": user_items[x]["is_valid"]}) + except: break + + if len(user_item_list) == data["maxCount"]: + next_idx = data["nextIndex"] + data["maxCount"] + 1 + break + + return {"userId": data["userId"], "nextIndex": next_idx, "itemKind": kind, "userItemList": user_item_list} + + def handle_get_user_character_api_request(self, data: Dict) -> Dict: + characters = self.data.item.get_characters(data["userId"]) + chara_list = [] + for chara in characters: + chara_list.append({ + "characterId": chara["character_id"], + "level": chara["level"], + "awakening": chara["awakening"], + "useCount": chara["use_count"], + }) + + return {"userId": data["userId"], "userCharacterList": chara_list} + + def handle_get_user_favorite_api_request(self, data: Dict) -> Dict: + favorites = self.data.item.get_favorites(data["userId"], data["itemKind"]) + if favorites is None: return + + userFavs = [] + for fav in favorites: + userFavs.append({ + "userId": data["userId"], + "itemKind": fav["itemKind"], + "itemIdList": fav["itemIdList"] + }) + + return { + "userId": data["userId"], + "userFavoriteData": userFavs + } + + def handle_get_user_ghost_api_request(self, data: Dict) -> Dict: + ghost = self.data.profile.get_profile_ghost(data["userId"], self.version) + if ghost is None: return + + ghost_dict = ghost._asdict() + ghost_dict.pop("user") + ghost_dict.pop("id") + ghost_dict.pop("version_int") + + return { + "userId": data["userId"], + "userGhost": ghost_dict + } + + def handle_get_user_rating_api_request(self, data: Dict) -> Dict: + rating = self.data.profile.get_profile_rating(data["userId"], self.version) + if rating is None: return + + rating_dict = rating._asdict() + rating_dict.pop("user") + rating_dict.pop("id") + rating_dict.pop("version") + + return { + "userId": data["userId"], + "userRating": rating_dict + } + + def handle_get_user_activity_api_request(self, data: Dict) -> Dict: + """ + kind 1 is playlist, kind 2 is music list + """ + playlist = self.data.profile.get_profile_activity(data["userId"], 1) + musiclist = self.data.profile.get_profile_activity(data["userId"], 2) + if playlist is None or musiclist is None: return + + plst = [] + mlst = [] + + for play in playlist: + tmp = play._asdict() + tmp["id"] = tmp["activityId"] + tmp.pop("activityId") + tmp.pop("user") + plst.append(tmp) + + for music in musiclist: + tmp = music._asdict() + tmp["id"] = tmp["activityId"] + tmp.pop("activityId") + tmp.pop("user") + mlst.append(tmp) + + return { + "userActivity": { + "playList": plst, + "musicList": mlst + } + } + + def handle_get_user_course_api_request(self, data: Dict) -> Dict: + user_courses = self.data.score.get_courses(data["userId"]) + + course_list = [] + for course in user_courses: + tmp = course._asdict() + tmp.pop("user") + tmp.pop("id") + course_list.append(tmp) + + return {"userId": data["userId"], "nextIndex": 0, "userCourseList": course_list} + + def handle_get_user_portrait_api_request(self, data: Dict) -> Dict: + # No support for custom pfps + return {"length": 0, "userPortraitList": []} + + def handle_get_user_friend_season_ranking_api_request(self, data: Dict) -> Dict: + friend_season_ranking = self.data.item.get_friend_season_ranking(data["userId"]) + friend_season_ranking_list = [] + next_index = 0 + + for x in range(data["nextIndex"], data["maxCount"] + data["nextIndex"]): + try: + friend_season_ranking_list.append({ + "mapId": friend_season_ranking_list[x]["map_id"], + "distance": friend_season_ranking_list[x]["distance"], + "isLock": friend_season_ranking_list[x]["is_lock"], + "isClear": friend_season_ranking_list[x]["is_clear"], + "isComplete": friend_season_ranking_list[x]["is_complete"], + }) + except: + break + + # We're capped and still have some left to go + if len(friend_season_ranking_list) == data["maxCount"] and len(friend_season_ranking) > data["maxCount"] + data["nextIndex"]: + next_index = data["maxCount"] + data["nextIndex"] + + return {"userId": data["userId"], "nextIndex": next_index, "userFriendSeasonRankingList": friend_season_ranking_list} + + def handle_get_user_map_api_request(self, data: Dict) -> Dict: + maps = self.data.item.get_maps(data["userId"]) + map_list = [] + next_index = 0 + + for x in range(data["nextIndex"], data["maxCount"] + data["nextIndex"]): + try: + map_list.append({ + "mapId": maps[x]["map_id"], + "distance": maps[x]["distance"], + "isLock": maps[x]["is_lock"], + "isClear": maps[x]["is_clear"], + "isComplete": maps[x]["is_complete"], + }) + except: + break + + # We're capped and still have some left to go + if len(map_list) == data["maxCount"] and len(maps) > data["maxCount"] + data["nextIndex"]: + next_index = data["maxCount"] + data["nextIndex"] + + return {"userId": data["userId"], "nextIndex": next_index, "userMapList": map_list} + + def handle_get_user_login_bonus_api_request(self, data: Dict) -> Dict: + login_bonuses = self.data.item.get_login_bonuses(data["userId"]) + login_bonus_list = [] + next_index = 0 + + for x in range(data["nextIndex"], data["maxCount"] + data["nextIndex"]): + try: + login_bonus_list.append({ + "bonusId": login_bonuses[x]["bonus_id"], + "point": login_bonuses[x]["point"], + "isCurrent": login_bonuses[x]["is_current"], + "isComplete": login_bonuses[x]["is_complete"], + }) + except: + break + + # We're capped and still have some left to go + if len(login_bonus_list) == data["maxCount"] and len(login_bonuses) > data["maxCount"] + data["nextIndex"]: + next_index = data["maxCount"] + data["nextIndex"] + + return {"userId": data["userId"], "nextIndex": next_index, "userLoginBonusList": login_bonus_list} + + def handle_get_user_region_api_request(self, data: Dict) -> Dict: + return {"userId": data["userId"], "length": 0, "userRegionList": []} + + def handle_get_user_music_api_request(self, data: Dict) -> Dict: + songs = self.data.score.get_best_scores(data["userId"]) + music_detail_list = [] + next_index = 0 + + if songs is not None: + for song in songs: + music_detail_list.append({ + "musicId": song["song_id"], + "level": song["chart_id"], + "playCount": song["play_count"], + "achievement": song["achievement"], + "comboStatus": song["combo_status"], + "syncStatus": song["sync_status"], + "deluxscoreMax": song["dx_score"], + "scoreRank": song["score_rank"], + }) + if len(music_detail_list) == data["maxCount"]: + next_index = data["maxCount"] + data["nextIndex"] + break + + return {"userId": data["userId"], "nextIndex": next_index, "userMusicList": [{"userMusicDetailList": music_detail_list}]} diff --git a/titles/mai2/config.py b/titles/mai2/config.py new file mode 100644 index 0000000..7fe9a33 --- /dev/null +++ b/titles/mai2/config.py @@ -0,0 +1,17 @@ +from core.config import CoreConfig + +class Mai2ServerConfig(): + def __init__(self, parent: "Mai2Config") -> None: + self.__config = parent + + @property + def enable(self) -> bool: + return CoreConfig.get_config_field(self.__config, 'mai2', 'server', 'enable', default=True) + + @property + def loglevel(self) -> int: + return CoreConfig.str_to_loglevel(CoreConfig.get_config_field(self.__config, 'mai2', 'server', 'loglevel', default="info")) + +class Mai2Config(dict): + def __init__(self) -> None: + self.server = Mai2ServerConfig(self) \ No newline at end of file diff --git a/titles/mai2/const.py b/titles/mai2/const.py new file mode 100644 index 0000000..c6ae129 --- /dev/null +++ b/titles/mai2/const.py @@ -0,0 +1,51 @@ +class Mai2Constants(): + GRADE = { + "D": 0, + "C": 1, + "B": 2, + "BB": 3, + "BBB": 4, + "A": 5, + "AA": 6, + "AAA": 7, + "S": 8, + "S+": 9, + "SS": 10, + "SS+": 11, + "SSS": 12, + "SSS+": 13 + } + FC = { + "None": 0, + "FC": 1, + "FC+": 2, + "AP": 3, + "AP+": 4 + } + SYNC = { + "None": 0, + "FS": 1, + "FS+": 2, + "FDX": 3, + "FDX+": 4 + } + + DATE_TIME_FORMAT = "%Y-%m-%d %H:%M:%S" + + GAME_CODE = "SDEZ" + + CONFIG_NAME = "mai2.yaml" + + VER_MAIMAI_DX = 0 + VER_MAIMAI_DX_PLUS = 1 + VER_MAIMAI_DX_SPLASH = 2 + VER_MAIMAI_DX_SPLASH_PLUS = 3 + VER_MAIMAI_DX_UNIVERSE = 4 + VER_MAIMAI_DX_UNIVERSE_PLUS = 5 + + VERSION_STRING = ("maimai Delux", "maimai Delux PLUS", "maimai Delux Splash", "maimai Delux Splash PLUS", "maimai Delux Universe", + "maimai Delux Universe PLUS") + + @classmethod + def game_ver_to_string(cls, ver: int): + return cls.VERSION_STRING[ver] \ No newline at end of file diff --git a/titles/mai2/database.py b/titles/mai2/database.py new file mode 100644 index 0000000..7a19e75 --- /dev/null +++ b/titles/mai2/database.py @@ -0,0 +1,12 @@ +from core.data import Data +from core.config import CoreConfig +from titles.mai2.schema import Mai2ItemData, Mai2ProfileData, Mai2StaticData, Mai2ScoreData + +class Mai2Data(Data): + def __init__(self, cfg: CoreConfig) -> None: + super().__init__(cfg) + + self.profile = Mai2ProfileData(self.config, self.session) + self.item = Mai2ItemData(self.config, self.session) + self.static = Mai2StaticData(self.config, self.session) + self.score = Mai2ScoreData(self.config, self.session) \ No newline at end of file diff --git a/titles/mai2/index.py b/titles/mai2/index.py new file mode 100644 index 0000000..a4a8f3e --- /dev/null +++ b/titles/mai2/index.py @@ -0,0 +1,109 @@ +from twisted.web.http import Request +import json +import inflection +import yaml +import string +import logging, coloredlogs +import zlib +from logging.handlers import TimedRotatingFileHandler + +from core.config import CoreConfig +from titles.mai2.config import Mai2Config +from titles.mai2.const import Mai2Constants +from titles.mai2.base import Mai2Base +from titles.mai2.plus import Mai2Plus +from titles.mai2.splash import Mai2Splash +from titles.mai2.splashplus import Mai2SplashPlus +from titles.mai2.universe import Mai2Universe +from titles.mai2.universeplus import Mai2UniversePlus + + +class Mai2Servlet(): + def __init__(self, core_cfg: CoreConfig, cfg_dir: str) -> None: + self.core_cfg = core_cfg + self.game_cfg = Mai2Config() + self.game_cfg.update(yaml.safe_load(open(f"{cfg_dir}/{Mai2Constants.CONFIG_NAME}"))) + + self.versions = [ + Mai2Base(core_cfg, self.game_cfg), + Mai2Plus(core_cfg, self.game_cfg), + Mai2Splash(core_cfg, self.game_cfg), + Mai2SplashPlus(core_cfg, self.game_cfg), + Mai2Universe(core_cfg, self.game_cfg), + Mai2UniversePlus(core_cfg, self.game_cfg), + ] + + self.logger = logging.getLogger("mai2") + log_fmt_str = "[%(asctime)s] Mai2 | %(levelname)s | %(message)s" + log_fmt = logging.Formatter(log_fmt_str) + fileHandler = TimedRotatingFileHandler("{0}/{1}.log".format(self.core_cfg.server.log_dir, "mai2"), encoding='utf8', + when="d", backupCount=10) + + fileHandler.setFormatter(log_fmt) + + consoleHandler = logging.StreamHandler() + consoleHandler.setFormatter(log_fmt) + + self.logger.addHandler(fileHandler) + self.logger.addHandler(consoleHandler) + + self.logger.setLevel(self.game_cfg.server.loglevel) + coloredlogs.install(level=self.game_cfg.server.loglevel, logger=self.logger, fmt=log_fmt_str) + + def render_POST(self, request: Request, version: int, url_path: str) -> bytes: + req_raw = request.content.getvalue() + url = request.uri.decode() + url_split = url_path.split("/") + internal_ver = 0 + endpoint = url_split[len(url_split) - 1] + + if version < 105: # 1.0 + internal_ver = Mai2Constants.VER_MAIMAI_DX + elif version >= 105 and version < 110: # Plus + internal_ver = Mai2Constants.VER_MAIMAI_DX_PLUS + elif version >= 110 and version < 115: # Splash + internal_ver = Mai2Constants.VER_MAIMAI_DX_SPLASH + elif version >= 115 and version < 120: # Splash Plus + internal_ver = Mai2Constants.VER_MAIMAI_DX_SPLASH_PLUS + elif version >= 120 and version < 125: # Universe + internal_ver = Mai2Constants.VER_MAIMAI_DX_UNIVERSE + elif version >= 125: # Universe Plus + internal_ver = Mai2Constants.VER_MAIMAI_DX_UNIVERSE_PLUS + + if all(c in string.hexdigits for c in endpoint) and len(endpoint) == 32: + # If we get a 32 character long hex string, it's a hash and we're + # doing encrypted. The likelyhood of false positives is low but + # technically not 0 + self.logger.error("Encryption not supported at this time") + + try: + unzip = zlib.decompress(req_raw) + + except zlib.error as e: + self.logger.error(f"Failed to decompress v{version} {endpoint} request -> {e}") + return zlib.compress("{\"stat\": \"0\"}".encode("utf-8")) + + req_data = json.loads(unzip) + + self.logger.info(f"v{version} {endpoint} request - {req_data}") + + func_to_find = "handle_" + inflection.underscore(endpoint) + "_request" + + try: + handler = getattr(self.versions[internal_ver], func_to_find) + resp = handler(req_data) + + except AttributeError as e: + self.logger.warning(f"Unhandled v{version} request {endpoint} - {e}") + return zlib.compress("{\"stat\": \"0\"}".encode("utf-8")) + + except Exception as e: + self.logger.error(f"Error handling v{version} method {endpoint} - {e}") + return zlib.compress("{\"stat\": \"0\"}".encode("utf-8")) + + if resp == None: + resp = {'returnCode': 1} + + self.logger.info(f"Response {resp}") + + return zlib.compress(json.dumps(resp, ensure_ascii=False).encode("utf-8")) diff --git a/titles/mai2/plus.py b/titles/mai2/plus.py new file mode 100644 index 0000000..2af7bf6 --- /dev/null +++ b/titles/mai2/plus.py @@ -0,0 +1,14 @@ +from typing import Any, List, Dict +from datetime import datetime, timedelta +import pytz +import json + +from core.config import CoreConfig +from titles.mai2.base import Mai2Base +from titles.mai2.config import Mai2Config +from titles.mai2.const import Mai2Constants + +class Mai2Plus(Mai2Base): + def __init__(self, cfg: CoreConfig, game_cfg: Mai2Config) -> None: + super().__init__(cfg, game_cfg) + self.version = Mai2Constants.VER_MAIMAI_DX_PLUS \ No newline at end of file diff --git a/titles/mai2/read.py b/titles/mai2/read.py new file mode 100644 index 0000000..1652292 --- /dev/null +++ b/titles/mai2/read.py @@ -0,0 +1,103 @@ +from decimal import Decimal +import logging +import os +import re +import xml.etree.ElementTree as ET +from typing import Any, Dict, List, Optional + +from core.config import CoreConfig +from core.data import Data +from read import BaseReader +from titles.mai2.const import Mai2Constants +from titles.mai2.database import Mai2Data + +class Mai2Reader(BaseReader): + def __init__(self, config: CoreConfig, version: int, bin_dir: Optional[str], opt_dir: Optional[str], extra: Optional[str]) -> None: + super().__init__(config, version, bin_dir, opt_dir, extra) + self.data = Mai2Data(config) + + try: + self.logger.info(f"Start importer for {Mai2Constants.game_ver_to_string(version)}") + except IndexError: + self.logger.error(f"Invalid maidx version {version}") + exit(1) + + def read(self) -> None: + data_dirs = [] + if self.bin_dir is not None: + data_dirs += self.get_data_directories(self.bin_dir) + + if self.opt_dir is not None: + data_dirs += self.get_data_directories(self.opt_dir) + + for dir in data_dirs: + self.logger.info(f"Read from {dir}") + self.get_events(f"{dir}/event") + self.read_music(f"{dir}/music") + self.read_tickets(f"{dir}/ticket") + + def get_events(self, base_dir: str) -> None: + self.logger.info(f"Reading events from {base_dir}...") + + for root, dirs, files in os.walk(base_dir): + for dir in dirs: + if os.path.exists(f"{root}/{dir}/Event.xml"): + with open(f"{root}/{dir}/Event.xml", encoding="utf-8") as f: + + troot = ET.fromstring(f.read()) + + name = troot.find('name').find('str').text + id = int(troot.find('name').find('id').text) + event_type = int(troot.find('infoType').text) + + self.data.static.put_game_event(self.version, event_type, id, name) + self.logger.info(f"Added event {id}...") + + def read_music(self, base_dir: str) -> None: + self.logger.info(f"Reading music from {base_dir}...") + + for root, dirs, files in os.walk(base_dir): + for dir in dirs: + if os.path.exists(f"{root}/{dir}/Music.xml"): + with open(f"{root}/{dir}/Music.xml", encoding="utf-8") as f: + troot = ET.fromstring(f.read()) + + song_id = int(troot.find('name').find('id').text) + title = troot.find('name').find('str').text + artist = troot.find('artistName').find('str').text + genre = troot.find('genreName').find('str').text + bpm = int(troot.find('bpm').text) + added_ver = troot.find('AddVersion').find('str').text + + note_data = troot.find('notesData').findall('Notes') + + for dif in note_data: + path = dif.find('file').find('path').text + if path is not None: + if os.path.exists(f"{root}/{dir}/{path}"): + chart_id = int(path.split(".")[0].split('_')[1]) + diff_num = float(f"{dif.find('level').text}.{dif.find('levelDecimal').text}") + note_designer = dif.find('notesDesigner').find('str').text + + self.data.static.put_game_music(self.version, song_id, chart_id, title, artist, + genre, bpm, added_ver, diff_num, note_designer) + + self.logger.info(f"Added music id {song_id} chart {chart_id}") + + def read_tickets(self, base_dir: str) -> None: + self.logger.info(f"Reading tickets from {base_dir}...") + + for root, dirs, files in os.walk(base_dir): + for dir in dirs: + if os.path.exists(f"{root}/{dir}/Ticket.xml"): + with open(f"{root}/{dir}/Ticket.xml", encoding="utf-8") as f: + + troot = ET.fromstring(f.read()) + + name = troot.find('name').find('str').text + id = int(troot.find('name').find('id').text) + ticket_type = int(troot.find('ticketKind').find('id').text) + price = int(troot.find('creditNum').text) + + self.data.static.put_game_ticket(self.version, id, ticket_type, price, name) + self.logger.info(f"Added ticket {id}...") diff --git a/titles/mai2/schema/__init__.py b/titles/mai2/schema/__init__.py new file mode 100644 index 0000000..c2be969 --- /dev/null +++ b/titles/mai2/schema/__init__.py @@ -0,0 +1,6 @@ +from titles.mai2.schema.profile import Mai2ProfileData +from titles.mai2.schema.item import Mai2ItemData +from titles.mai2.schema.static import Mai2StaticData +from titles.mai2.schema.score import Mai2ScoreData + +__all__ = [Mai2ProfileData, Mai2ItemData, Mai2StaticData, Mai2ScoreData] \ No newline at end of file diff --git a/titles/mai2/schema/item.py b/titles/mai2/schema/item.py new file mode 100644 index 0000000..4f283d3 --- /dev/null +++ b/titles/mai2/schema/item.py @@ -0,0 +1,298 @@ +from core.data.schema import BaseData, metadata + +from typing import Optional, Dict, List +from sqlalchemy import Table, Column, UniqueConstraint, PrimaryKeyConstraint, and_ +from sqlalchemy.types import Integer, String, TIMESTAMP, Boolean, JSON +from sqlalchemy.schema import ForeignKey +from sqlalchemy.sql import func, select +from sqlalchemy.dialects.mysql import insert +from sqlalchemy.engine import Row + +character = Table( + "mai2_item_character", + metadata, + Column("id", Integer, primary_key=True, nullable=False), + Column("user", ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade"), nullable=False), + Column("character_id", Integer, nullable=False), + Column("level", Integer, nullable=False, server_default="1"), + Column("awakening", Integer, nullable=False, server_default="0"), + Column("use_count", Integer, nullable=False, server_default="0"), + UniqueConstraint("user", "character_id", name="mai2_item_character_uk"), + mysql_charset='utf8mb4' +) + +card = Table( + "mai2_item_card", + metadata, + Column("id", Integer, primary_key=True, nullable=False), + Column("user", ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade"), nullable=False), + Column("card_kind", Integer, nullable=False), + Column("card_id", Integer, nullable=False), + Column("chara_id", Integer, nullable=False), + Column("map_id", Integer, nullable=False), + Column("start_date", String(255), nullable=False), + Column("end_date", String(255), nullable=False), + UniqueConstraint("user", "card_kind", "card_id", name="mai2_item_card_uk"), + mysql_charset='utf8mb4' +) + +item = Table( + "mai2_item_item", + metadata, + Column("id", Integer, primary_key=True, nullable=False), + Column("user", ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade"), nullable=False), + Column("item_kind", Integer, nullable=False), + Column("item_id", Integer, nullable=False), + Column("stock", Integer, nullable=False, server_default="1"), + Column("is_valid", Boolean, nullable=False, server_default="1"), + UniqueConstraint("user", "item_kind", "item_id", name="mai2_item_item_uk"), + mysql_charset='utf8mb4' +) + +map = Table( + "mai2_item_map", + metadata, + Column("id", Integer, primary_key=True, nullable=False), + Column("user", ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade"), nullable=False), + Column("map_id", Integer, nullable=False), + Column("distance", Integer, nullable=False), + Column("is_lock", Boolean, nullable=False, server_default="0"), + Column("is_clear", Boolean, nullable=False, server_default="0"), + Column("is_complete", Boolean, nullable=False, server_default="0"), + UniqueConstraint("user", "map_id", name="mai2_item_map_uk"), + mysql_charset='utf8mb4' +) + +login_bonus = Table( + "mai2_item_login_bonus", + metadata, + Column("id", Integer, primary_key=True, nullable=False), + Column("user", ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade"), nullable=False), + Column("bonus_id", Integer, nullable=False), + Column("point", Integer, nullable=False), + Column("is_current", Boolean, nullable=False, server_default="0"), + Column("is_complete", Boolean, nullable=False, server_default="0"), + UniqueConstraint("user", "bonus_id", name="mai2_item_login_bonus_uk"), + mysql_charset='utf8mb4' +) + +friend_season_ranking = Table( + "mai2_item_friend_season_ranking", + metadata, + Column("id", Integer, primary_key=True, nullable=False), + Column("user", ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade"), nullable=False), + Column("season_id", Integer, nullable=False), + Column("point", Integer, nullable=False), + Column("rank", Integer, nullable=False), + Column("reward_get", Boolean, nullable=False), + Column("user_name", String(8), nullable=False), + Column("record_date", String(255), nullable=False), + UniqueConstraint("user", "season_id", "user_name", name="mai2_item_login_bonus_uk"), + mysql_charset='utf8mb4' +) + +favorite = Table( + "mai2_item_favorite", + metadata, + Column("id", Integer, primary_key=True, nullable=False), + Column("user", ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade"), nullable=False), + Column("itemKind", Integer, nullable=False), + Column("itemIdList", JSON), + UniqueConstraint("user", "itemKind", name="mai2_item_favorite_uk"), + mysql_charset='utf8mb4' +) + +charge = Table( + "mai2_item_charge", + metadata, + Column("id", Integer, primary_key=True, nullable=False), + Column("user", ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade"), nullable=False), + Column("charge_id", Integer, nullable=False), + Column("stock", Integer, nullable=False), + Column("purchase_date", String(255), nullable=False), + Column("valid_date", String(255), nullable=False), + UniqueConstraint("user", "charge_id", name="mai2_item_charge_uk"), + mysql_charset='utf8mb4' +) + +class Mai2ItemData(BaseData): + def put_item(self, user_id: int, item_kind: int, item_id: int, stock: int, is_valid: bool) -> None: + sql = insert(item).values( + user=user_id, + item_kind=item_kind, + item_id=item_id, + stock=stock, + is_valid=is_valid, + ) + + conflict = sql.on_duplicate_key_update( + stock=stock, + is_valid=is_valid, + ) + + result = self.execute(conflict) + if result is None: + self.logger.warn(f"put_item: failed to insert item! user_id: {user_id}, item_kind: {item_kind}, item_id: {item_id}") + return None + return result.lastrowid + + def get_items(self, user_id: int, item_kind: int = None) -> Optional[List[Row]]: + if item_kind is None: + sql = item.select(item.c.user == user_id) + else: + sql = item.select(and_(item.c.user == user_id, item.c.item_kind == item_kind)) + + result = self.execute(sql) + if result is None: return None + return result.fetchall() + + def get_item(self, user_id: int, item_kind: int, item_id: int) -> Optional[Row]: + sql = item.select(and_(item.c.user == user_id, item.c.item_kind == item_kind, item.c.item_id == item_id)) + + result = self.execute(sql) + if result is None: return None + return result.fetchone() + + def put_login_bonus(self, user_id: int, bonus_id: int, point: int, is_current: bool, is_complete: bool) -> None: + sql = insert(login_bonus).values( + user=user_id, + bonus_id=bonus_id, + point=point, + is_current=is_current, + is_complete=is_complete, + ) + + conflict = sql.on_duplicate_key_update( + point=point, + is_current=is_current, + is_complete=is_complete, + ) + + result = self.execute(conflict) + if result is None: + self.logger.warn(f"put_login_bonus: failed to insert item! user_id: {user_id}, bonus_id: {bonus_id}, point: {point}") + return None + return result.lastrowid + + def get_login_bonuses(self, user_id: int) -> Optional[List[Row]]: + sql = login_bonus.select(login_bonus.c.user == user_id) + + result = self.execute(sql) + if result is None: return None + return result.fetchall() + + def get_login_bonus(self, user_id: int, bonus_id: int) -> Optional[Row]: + sql = login_bonus.select(and_(login_bonus.c.user == user_id, login_bonus.c.bonus_id == bonus_id)) + + result = self.execute(sql) + if result is None: return None + return result.fetchone() + + def put_map(self, user_id: int, map_id: int, distance: int, is_lock: bool, is_clear: bool, is_complete: bool) -> None: + sql = insert(map).values( + user=user_id, + map_id=map_id, + distance=distance, + is_lock=is_lock, + is_clear=is_clear, + is_complete=is_complete, + ) + + conflict = sql.on_duplicate_key_update( + distance=distance, + is_lock=is_lock, + is_clear=is_clear, + is_complete=is_complete, + ) + + result = self.execute(conflict) + if result is None: + self.logger.warn(f"put_map: failed to insert item! user_id: {user_id}, map_id: {map_id}, distance: {distance}") + return None + return result.lastrowid + + def get_maps(self, user_id: int) -> Optional[List[Row]]: + sql = map.select(map.c.user == user_id) + + result = self.execute(sql) + if result is None: return None + return result.fetchall() + + def get_map(self, user_id: int, map_id: int) -> Optional[Row]: + sql = map.select(and_(map.c.user == user_id, map.c.map_id == map_id)) + + result = self.execute(sql) + if result is None: return None + return result.fetchone() + + def put_character(self, user_id: int, character_id: int, level: int, awakening: int, use_count: int) -> None: + sql = insert(character).values( + user=user_id, + character_id=character_id, + level=level, + awakening=awakening, + use_count=use_count, + ) + + conflict = sql.on_duplicate_key_update( + level=level, + awakening=awakening, + use_count=use_count, + ) + + result = self.execute(conflict) + if result is None: + self.logger.warn(f"put_character: failed to insert item! user_id: {user_id}, character_id: {character_id}, level: {level}") + return None + return result.lastrowid + + def get_characters(self, user_id: int) -> Optional[List[Row]]: + sql = character.select(character.c.user == user_id) + + result = self.execute(sql) + if result is None: return None + return result.fetchall() + + def get_character(self, user_id: int, character_id: int) -> Optional[Row]: + sql = character.select(and_(character.c.user == user_id, character.c.character_id == character_id)) + + result = self.execute(sql) + if result is None: return None + return result.fetchone() + + def get_friend_season_ranking(self, user_id: int) -> Optional[Row]: + sql = friend_season_ranking.select(friend_season_ranking.c.user == user_id) + + result = self.execute(sql) + if result is None:return None + return result.fetchone() + + def put_favorite(self, user_id: int, kind: int, item_id_list: List[int]) -> Optional[int]: + sql = insert(favorite).values( + user=user_id, + kind=kind, + item_id_list=item_id_list + ) + + conflict = sql.on_duplicate_key_update( + item_id_list=item_id_list + ) + + result = self.execute(conflict) + if result is None: + self.logger.warn(f"put_favorite: failed to insert item! user_id: {user_id}, kind: {kind}") + return None + return result.lastrowid + + def get_favorites(self, user_id: int, kind: int = None) -> Optional[Row]: + if kind is None: + sql = favorite.select(favorite.c.user == user_id) + else: + sql = favorite.select(and_( + favorite.c.user == user_id, + favorite.c.itemKind == kind + )) + + result = self.execute(sql) + if result is None:return None + return result.fetchall() \ No newline at end of file diff --git a/titles/mai2/schema/profile.py b/titles/mai2/schema/profile.py new file mode 100644 index 0000000..346645c --- /dev/null +++ b/titles/mai2/schema/profile.py @@ -0,0 +1,402 @@ +from core.data.schema import BaseData, metadata +from titles.mai2.const import Mai2Constants + +from typing import Optional, Dict, List +from sqlalchemy import Table, Column, UniqueConstraint, PrimaryKeyConstraint, and_ +from sqlalchemy.types import Integer, String, TIMESTAMP, Boolean, JSON, BigInteger +from sqlalchemy.schema import ForeignKey +from sqlalchemy.sql import func, select +from sqlalchemy.engine import Row +from sqlalchemy.dialects.mysql import insert +from datetime import datetime + +detail = Table( + "mai2_profile_detail", + metadata, + Column("id", Integer, primary_key=True, nullable=False), + Column("user", ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade"), nullable=False), + Column("version", Integer, nullable=False), + Column("userName", String(25)), + Column("isNetMember", Integer), + Column("iconId", Integer), + Column("plateId", Integer), + Column("titleId", Integer), + Column("partnerId", Integer), + Column("frameId", Integer), + Column("selectMapId", Integer), + Column("totalAwake", Integer), + Column("gradeRating", Integer), + Column("musicRating", Integer), + Column("playerRating", Integer), + Column("highestRating", Integer), + Column("gradeRank", Integer), + Column("classRank", Integer), + Column("courseRank", Integer), + Column("charaSlot", JSON), + Column("charaLockSlot", JSON), + Column("contentBit", BigInteger), + Column("playCount", Integer), + Column("eventWatchedDate", String(25)), + Column("lastGameId", String(25)), + Column("lastRomVersion", String(25)), + Column("lastDataVersion", String(25)), + Column("lastLoginDate", String(25)), + Column("lastPairLoginDate", String(25)), # new with uni+ + Column("lastPlayDate", String(25)), + Column("lastTrialPlayDate", String(25)), # new with uni+ + Column("lastPlayCredit", Integer), + Column("lastPlayMode", Integer), + Column("lastPlaceId", Integer), + Column("lastPlaceName", String(25)), + Column("lastAllNetId", Integer), + Column("lastRegionId", Integer), + Column("lastRegionName", String(25)), + Column("lastClientId", String(25)), + Column("lastCountryCode", String(25)), + Column("lastSelectEMoney", Integer), + Column("lastSelectTicket", Integer), + Column("lastSelectCourse", Integer), + Column("lastCountCourse", Integer), + Column("firstGameId", String(25)), + Column("firstRomVersion", String(25)), + Column("firstDataVersion", String(25)), + Column("firstPlayDate", String(25)), + Column("compatibleCmVersion", String(25)), + Column("dailyBonusDate", String(25)), + Column("dailyCourseBonusDate", String(25)), + Column("playVsCount", Integer), + Column("playSyncCount", Integer), + Column("winCount", Integer), + Column("helpCount", Integer), + Column("comboCount", Integer), + Column("totalDeluxscore", BigInteger), + Column("totalBasicDeluxscore", BigInteger), + Column("totalAdvancedDeluxscore", BigInteger), + Column("totalExpertDeluxscore", BigInteger), + Column("totalMasterDeluxscore", BigInteger), + Column("totalReMasterDeluxscore", BigInteger), + Column("totalSync", Integer), + Column("totalBasicSync", Integer), + Column("totalAdvancedSync", Integer), + Column("totalExpertSync", Integer), + Column("totalMasterSync", Integer), + Column("totalReMasterSync", Integer), + Column("totalAchievement", BigInteger), + Column("totalBasicAchievement", BigInteger), + Column("totalAdvancedAchievement", BigInteger), + Column("totalExpertAchievement", BigInteger), + Column("totalMasterAchievement", BigInteger), + Column("totalReMasterAchievement", BigInteger), + Column("playerOldRating", BigInteger), + Column("playerNewRating", BigInteger), + Column("dateTime", BigInteger), + Column("banState", Integer), # new with uni+ + UniqueConstraint("user", "version", name="mai2_profile_detail_uk"), + mysql_charset='utf8mb4' +) + +ghost = Table( + "mai2_profile_ghost", + metadata, + Column("id", Integer, primary_key=True, nullable=False), + Column("user", ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade"), nullable=False), + Column("version_int", Integer, nullable=False), + Column("name", String(25)), + Column("iconId", Integer), + Column("plateId", Integer), + Column("titleId", Integer), + Column("rate", Integer), + Column("udemaeRate", Integer), + Column("courseRank", Integer), + Column("classRank", Integer), + Column("classValue", Integer), + Column("playDatetime", String(25)), + Column("shopId", Integer), + Column("regionCode", Integer), + Column("typeId", Integer), + Column("musicId", Integer), + Column("difficulty", Integer), + Column("version", Integer), + Column("resultBitList", JSON), + Column("resultNum", Integer), + Column("achievement", Integer), + UniqueConstraint("user", "version", "musicId", "difficulty", name="mai2_profile_ghost_uk"), + mysql_charset='utf8mb4' +) + +extend = Table( + "mai2_profile_extend", + metadata, + Column("id", Integer, primary_key=True, nullable=False), + Column("user", ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade"), nullable=False), + Column("version", Integer, nullable=False), + Column("selectMusicId", Integer), + Column("selectDifficultyId", Integer), + Column("categoryIndex", Integer), + Column("musicIndex", Integer), + Column("extraFlag", Integer), + Column("selectScoreType", Integer), + Column("extendContentBit", BigInteger), + Column("isPhotoAgree", Boolean), + Column("isGotoCodeRead", Boolean), + Column("selectResultDetails", Boolean), + Column("sortCategorySetting", Integer), + Column("sortMusicSetting", Integer), + Column("selectedCardList", JSON), + Column("encountMapNpcList", JSON), + UniqueConstraint("user", "version", name="mai2_profile_extend_uk"), + mysql_charset='utf8mb4' +) + +option = Table( + "mai2_profile_option", + metadata, + Column("id", Integer, primary_key=True, nullable=False), + Column("user", ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade"), nullable=False), + Column("version", Integer, nullable=False), + Column("selectMusicId", Integer), + Column("optionKind", Integer), + Column("noteSpeed", Integer), + Column("slideSpeed", Integer), + Column("touchSpeed", Integer), + Column("tapDesign", Integer), + Column("holdDesign", Integer), + Column("slideDesign", Integer), + Column("starType", Integer), + Column("outlineDesign", Integer), + Column("noteSize", Integer), + Column("slideSize", Integer), + Column("touchSize", Integer), + Column("starRotate", Integer), + Column("dispCenter", Integer), + Column("dispChain", Integer), + Column("dispRate", Integer), + Column("dispBar", Integer), + Column("touchEffect", Integer), + Column("submonitorAnimation", Integer), + Column("submonitorAchive", Integer), + Column("submonitorAppeal", Integer), + Column("matching", Integer), + Column("trackSkip", Integer), + Column("brightness", Integer), + Column("mirrorMode", Integer), + Column("dispJudge", Integer), + Column("dispJudgePos", Integer), + Column("dispJudgeTouchPos", Integer), + Column("adjustTiming", Integer), + Column("judgeTiming", Integer), + Column("ansVolume", Integer), + Column("tapHoldVolume", Integer), + Column("criticalSe", Integer), + Column("breakSe", Integer), + Column("breakVolume", Integer), + Column("exSe", Integer), + Column("exVolume", Integer), + Column("slideSe", Integer), + Column("slideVolume", Integer), + Column("touchHoldVolume", Integer), + Column("damageSeVolume", Integer), + Column("headPhoneVolume", Integer), + Column("sortTab", Integer), + Column("sortMusic", Integer), + UniqueConstraint("user", "version", name="mai2_profile_option_uk"), + mysql_charset='utf8mb4' +) + +rating = Table( + "mai2_profile_rating", + metadata, + Column("id", Integer, primary_key=True, nullable=False), + Column("user", ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade"), nullable=False), + Column("version", Integer, nullable=False), + Column("rating", Integer), + Column("ratingList", JSON), + Column("newRatingList", JSON), + Column("nextRatingList", JSON), + Column("nextNewRatingList", JSON), + Column("udemae", JSON), + UniqueConstraint("user", "version", name="mai2_profile_rating_uk"), + mysql_charset='utf8mb4' +) + +region = Table( + "mai2_profile_region", + metadata, + Column("id", Integer, primary_key=True, nullable=False), + Column("user", ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade"), nullable=False), + Column("regionId", Integer), + Column("playCount", Integer, server_default="1"), + Column("created", String(25)), + UniqueConstraint("user", "regionId", name="mai2_profile_region_uk"), + mysql_charset='utf8mb4' +) + +activity = Table( + "mai2_profile_activity", + metadata, + Column("id", Integer, primary_key=True, nullable=False), + Column("user", ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade"), nullable=False), + Column("kind", Integer, nullable=False), + Column("activityId", Integer, nullable=False), + Column("param1", Integer, nullable=False), + Column("param2", Integer, nullable=False), + Column("param3", Integer, nullable=False), + Column("param4", Integer, nullable=False), + Column("sortNumber", Integer, nullable=False), + UniqueConstraint("user", "kind", "activityId", name="mai2_profile_activity_uk"), + mysql_charset='utf8mb4' +) + +class Mai2ProfileData(BaseData): + def put_profile_detail(self, user_id: int, version: int, detail_data: Dict) -> Optional[Row]: + detail_data["user"] = user_id + detail_data["version"] = version + sql = insert(detail).values(**detail_data) + + conflict = sql.on_duplicate_key_update(**detail_data) + + result = self.execute(conflict) + if result is None: + self.logger.warn(f"put_profile: Failed to create profile! user_id {user_id}") + return None + return result.lastrowid + + def get_profile_detail(self, user_id: int, version: int) -> Optional[Row]: + sql = select(detail).where(and_(detail.c.user == user_id, detail.c.version == version)) + + result = self.execute(sql) + if result is None:return None + return result.fetchone() + + def put_profile_ghost(self, user_id: int, version: int, ghost_data: Dict) -> Optional[int]: + ghost_data["user"] = user_id + ghost_data["version_int"] = version + + sql = insert(ghost).values(**ghost_data) + conflict = sql.on_duplicate_key_update(**ghost_data) + + result = self.execute(conflict) + if result is None: + self.logger.warn(f"put_profile_ghost: failed to update! {user_id}") + return None + return result.lastrowid + + def get_profile_ghost(self, user_id: int, version: int) -> Optional[Row]: + sql = select(ghost).where(and_(ghost.c.user == user_id, ghost.c.version_int == version)) + + result = self.execute(sql) + if result is None:return None + return result.fetchone() + + def put_profile_extend(self, user_id: int, version: int, extend_data: Dict) -> Optional[int]: + extend_data["user"] = user_id + extend_data["version"] = version + + sql = insert(extend).values(**extend_data) + conflict = sql.on_duplicate_key_update(**extend_data) + + result = self.execute(conflict) + if result is None: + self.logger.warn(f"put_profile_extend: failed to update! {user_id}") + return None + return result.lastrowid + + def get_profile_extend(self, user_id: int, version: int) -> Optional[Row]: + sql = select(extend).where(and_(extend.c.user == user_id, extend.c.version == version)) + + result = self.execute(sql) + if result is None:return None + return result.fetchone() + + def put_profile_option(self, user_id: int, version: int, option_data: Dict) -> Optional[int]: + option_data["user"] = user_id + option_data["version"] = version + + sql = insert(option).values(**option_data) + conflict = sql.on_duplicate_key_update(**option_data) + + result = self.execute(conflict) + if result is None: + self.logger.warn(f"put_profile_option: failed to update! {user_id}") + return None + return result.lastrowid + + def get_profile_option(self, user_id: int, version: int) -> Optional[Row]: + sql = select(option).where(and_(option.c.user == user_id, option.c.version == version)) + + result = self.execute(sql) + if result is None:return None + return result.fetchone() + + def put_profile_rating(self, user_id: int, version: int, rating_data: Dict) -> Optional[int]: + rating_data["user"] = user_id + rating_data["version"] = version + + sql = insert(rating).values(**rating_data) + conflict = sql.on_duplicate_key_update(**rating_data) + + result = self.execute(conflict) + if result is None: + self.logger.warn(f"put_profile_rating: failed to update! {user_id}") + return None + return result.lastrowid + + def get_profile_rating(self, user_id: int, version: int) -> Optional[Row]: + sql = select(rating).where(and_(rating.c.user == user_id, rating.c.version == version)) + + result = self.execute(sql) + if result is None:return None + return result.fetchone() + + def put_profile_region(self, user_id: int, region_id: int) -> Optional[int]: + sql = insert(region).values( + user = user_id, + regionId = region_id, + created = datetime.strftime(datetime.now(), Mai2Constants.DATE_TIME_FORMAT) + ) + + conflict = sql.on_duplicate_key_update( + playCount = region.c.playCount + 1 + ) + + result = self.execute(conflict) + if result is None: + self.logger.warn(f"put_region: failed to update! {user_id}") + return None + return result.lastrowid + + def get_regions(self, user_id: int) -> Optional[List[Dict]]: + sql = select(region).where(region.c.user == user_id) + + result = self.execute(sql) + if result is None:return None + return result.fetchall() + + def put_profile_activity(self, user_id: int, activity_data: Dict) -> Optional[int]: + if "id" in activity_data: + activity_data["activityId"] = activity_data["id"] + activity_data.pop("id") + + activity_data["user"] = user_id + + sql = insert(activity).values(**activity_data) + + conflict = sql.on_duplicate_key_update(**activity_data) + + result = self.execute(conflict) + if result is None: + self.logger.warn(f"put_profile_activity: failed to update! user_id: {user_id}") + return None + return result.lastrowid + + def get_profile_activity(self, user_id: int, kind: int = None) -> Optional[Row]: + sql = activity.select( + and_( + activity.c.user == user_id, + (activity.c.kind == kind) if kind is not None else True, + ) + ) + + result = self.execute(sql) + if result is None:return None + return result.fetchone() diff --git a/titles/mai2/schema/score.py b/titles/mai2/schema/score.py new file mode 100644 index 0000000..0ef6da4 --- /dev/null +++ b/titles/mai2/schema/score.py @@ -0,0 +1,226 @@ +from typing import Dict, List, Optional +from sqlalchemy import Table, Column, UniqueConstraint, PrimaryKeyConstraint, and_ +from sqlalchemy.types import Integer, String, TIMESTAMP, Boolean, JSON, BigInteger +from sqlalchemy.schema import ForeignKey +from sqlalchemy.sql import func, select +from sqlalchemy.engine import Row +from sqlalchemy.dialects.mysql import insert + +from core.data.schema import BaseData, metadata + +best_score = Table( + "mai2_score_best", + metadata, + Column("id", Integer, primary_key=True, nullable=False), + Column("user", ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade"), nullable=False), + Column("musicId", Integer), + Column("level", Integer), + Column("playCount", Integer), + Column("achievement", Integer), + Column("comboStatus", Integer), + Column("syncStatus", Integer), + Column("deluxscoreMax", Integer), + Column("scoreRank", Integer), + UniqueConstraint("user", "musicId", "level", name="mai2_score_best_uk"), + mysql_charset='utf8mb4' +) + +playlog = Table( + "mai2_playlog", + metadata, + Column("id", Integer, primary_key=True, nullable=False), + Column("user", ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade"), nullable=False), + Column("userId", BigInteger), + Column("orderId", Integer), + Column("playlogId", BigInteger), + Column("version", Integer), + Column("placeId", Integer), + Column("placeName", String(255)), + Column("loginDate", BigInteger), + Column("playDate", String(255)), + Column("userPlayDate", String(255)), + Column("type", Integer), + Column("musicId", Integer), + Column("level", Integer), + Column("trackNo", Integer), + Column("vsMode", Integer), + Column("vsUserName", String(255)), + Column("vsStatus", Integer), + Column("vsUserRating", Integer), + Column("vsUserAchievement", Integer), + Column("vsUserGradeRank", Integer), + Column("vsRank", Integer), + Column("playerNum", Integer), + Column("playedUserId1", BigInteger), + Column("playedUserName1", String(255)), + Column("playedMusicLevel1", Integer), + Column("playedUserId2", BigInteger), + Column("playedUserName2", String(255)), + Column("playedMusicLevel2", Integer), + Column("playedUserId3", BigInteger), + Column("playedUserName3", String(255)), + Column("playedMusicLevel3", Integer), + Column("characterId1", Integer), + Column("characterLevel1", Integer), + Column("characterAwakening1", Integer), + Column("characterId2", Integer), + Column("characterLevel2", Integer), + Column("characterAwakening2", Integer), + Column("characterId3", Integer), + Column("characterLevel3", Integer), + Column("characterAwakening3", Integer), + Column("characterId4", Integer), + Column("characterLevel4", Integer), + Column("characterAwakening4", Integer), + Column("characterId5", Integer), + Column("characterLevel5", Integer), + Column("characterAwakening5", Integer), + Column("achievement", Integer), + Column("deluxscore", Integer), + Column("scoreRank", Integer), + Column("maxCombo", Integer), + Column("totalCombo", Integer), + Column("maxSync", Integer), + Column("totalSync", Integer), + Column("tapCriticalPerfect", Integer), + Column("tapPerfect", Integer), + Column("tapGreat", Integer), + Column("tapGood", Integer), + Column("tapMiss", Integer), + Column("holdCriticalPerfect", Integer), + Column("holdPerfect", Integer), + Column("holdGreat", Integer), + Column("holdGood", Integer), + Column("holdMiss", Integer), + Column("slideCriticalPerfect", Integer), + Column("slidePerfect", Integer), + Column("slideGreat", Integer), + Column("slideGood", Integer), + Column("slideMiss", Integer), + Column("touchCriticalPerfect", Integer), + Column("touchPerfect", Integer), + Column("touchGreat", Integer), + Column("touchGood", Integer), + Column("touchMiss", Integer), + Column("breakCriticalPerfect", Integer), + Column("breakPerfect", Integer), + Column("breakGreat", Integer), + Column("breakGood", Integer), + Column("breakMiss", Integer), + Column("isTap", Boolean), + Column("isHold", Boolean), + Column("isSlide", Boolean), + Column("isTouch", Boolean), + Column("isBreak", Boolean), + Column("isCriticalDisp", Boolean), + Column("isFastLateDisp", Boolean), + Column("fastCount", Integer), + Column("lateCount", Integer), + Column("isAchieveNewRecord", Boolean), + Column("isDeluxscoreNewRecord", Boolean), + Column("comboStatus", Integer), + Column("syncStatus", Integer), + Column("isClear", Boolean), + Column("beforeRating", Integer), + Column("afterRating", Integer), + Column("beforeGrade", Integer), + Column("afterGrade", Integer), + Column("afterGradeRank", Integer), + Column("beforeDeluxRating", Integer), + Column("afterDeluxRating", Integer), + Column("isPlayTutorial", Boolean), + Column("isEventMode", Boolean), + Column("isFreedomMode", Boolean), + Column("playMode", Integer), + Column("isNewFree", Boolean), + Column("extNum1", Integer), + Column("extNum2", Integer), + mysql_charset='utf8mb4' +) + +course = Table( + "mai2_score_course", + metadata, + Column("id", Integer, primary_key=True, nullable=False), + Column("user", ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade"), nullable=False), + Column("courseId", Integer), + Column("isLastClear", Boolean), + Column("totalRestlife", Integer), + Column("totalAchievement", Integer), + Column("totalDeluxscore", Integer), + Column("playCount", Integer), + Column("clearDate", String(25)), + Column("lastPlayDate", String(25)), + Column("bestAchievement", Integer), + Column("bestAchievementDate", String(25)), + Column("bestDeluxscore", Integer), + Column("bestDeluxscoreDate", String(25)), + UniqueConstraint("user", "courseId", name="mai2_score_best_uk"), + mysql_charset='utf8mb4' +) + +class Mai2ScoreData(BaseData): + def put_best_score(self, user_id: int, score_data: Dict) -> Optional[int]: + sql = insert(best_score).values(**score_data) + + conflict = sql.on_duplicate_key_update(**score_data) + + result = self.execute(conflict) + if result is None: + self.logger.error(f"put_best_score: Failed to insert best score! user_id {user_id}") + return None + return result.lastrowid + + def get_best_scores(self, user_id: int, song_id: int = None) -> Optional[List[Row]]: + sql = best_score.select( + and_( + best_score.c.user == user_id, + (best_score.c.song_id == song_id) if song_id is not None else True + ) + ) + + result = self.execute(sql) + if result is None: return None + return result.fetchall() + + def get_best_score(self, user_id: int, song_id: int, chart_id: int) -> Optional[Row]: + sql = best_score.select( + and_( + best_score.c.user == user_id, + best_score.c.song_id == song_id, + best_score.c.chart_id == chart_id + ) + ) + + result = self.execute(sql) + if result is None: return None + return result.fetchone() + + def put_playlog(self, user_id: int, playlog_data: Dict) -> Optional[int]: + sql = insert(playlog).values(**playlog_data) + + conflict = sql.on_duplicate_key_update(**playlog_data) + + result = self.execute(conflict) + if result is None: + self.logger.error(f"put_playlog: Failed to insert! user_id {user_id}") + return None + return result.lastrowid + + def put_course(self, user_id: int, course_data: Dict) -> Optional[int]: + sql = insert(course).values(**course_data) + + conflict = sql.on_duplicate_key_update(**course_data) + + result = self.execute(conflict) + if result is None: + self.logger.error(f"put_course: Failed to insert! user_id {user_id}") + return None + return result.lastrowid + + def get_courses(self, user_id: int) -> Optional[List[Row]]: + sql = course.select(best_score.c.user == user_id) + + result = self.execute(sql) + if result is None: return None + return result.fetchone() diff --git a/titles/mai2/schema/static.py b/titles/mai2/schema/static.py new file mode 100644 index 0000000..733e2ef --- /dev/null +++ b/titles/mai2/schema/static.py @@ -0,0 +1,178 @@ +from core.data.schema.base import BaseData, metadata + +from typing import Optional, Dict, List +from sqlalchemy import Table, Column, UniqueConstraint, PrimaryKeyConstraint, and_ +from sqlalchemy.types import Integer, String, TIMESTAMP, Boolean, JSON, Float +from sqlalchemy.schema import ForeignKey +from sqlalchemy.sql import func, select +from sqlalchemy.engine import Row +from sqlalchemy.dialects.mysql import insert + +event = Table( + "mai2_static_event", + metadata, + Column("id", Integer, primary_key=True, nullable=False), + Column("version", Integer,nullable=False), + Column("eventId", Integer), + Column("type", Integer), + Column("name", String(255)), + Column("enabled", Boolean, server_default="1"), + UniqueConstraint("version", "eventId", "type", name="mai2_static_event_uk"), + mysql_charset='utf8mb4' +) + +music = Table( + "mai2_static_music", + metadata, + Column("id", Integer, primary_key=True, nullable=False), + Column("version", Integer,nullable=False), + Column("songId", Integer), + Column("chartId", Integer), + Column("title", String(255)), + Column("artist", String(255)), + Column("genre", String(255)), + Column("bpm", Integer), + Column("addedVersion", String(255)), + Column("difficulty", Float), + Column("noteDesigner", String(255)), + UniqueConstraint("songId", "chartId", "version", name="mai2_static_music_uk"), + mysql_charset='utf8mb4' +) + +ticket = Table( + "mai2_static_ticket", + metadata, + Column("id", Integer, primary_key=True, nullable=False), + Column("version", Integer,nullable=False), + Column("ticketId", Integer), + Column("kind", Integer), + Column("name", String(255)), + Column("price", Integer, server_default="1"), + Column("enabled", Boolean, server_default="1"), + UniqueConstraint("version","ticketId", name="mai2_static_ticket_uk"), + mysql_charset='utf8mb4' +) + +class Mai2StaticData(BaseData): + def put_game_event(self, version: int, type: int, event_id: int, name: str) -> Optional[int]: + sql = insert(event).values( + version = version, + type = type, + eventId = event_id, + name = name, + ) + + conflict = sql.on_duplicate_key_update( + eventId = event_id + ) + + result = self.execute(conflict) + if result is None: + self.logger.warning(f"put_game_event: Failed to insert event! event_id {event_id} type {type} name {name}") + return result.lastrowid + + def get_game_events(self, version: int) -> Optional[List[Row]]: + sql = event.select(event.c.version == version) + + result = self.execute(sql) + if result is None: + return None + return result.fetchall() + + def get_enabled_events(self, version: int) -> Optional[List[Row]]: + sql = select(event).where(and_( + event.c.version == version, + event.c.enabled == True + )) + + result = self.execute(sql) + if result is None: return None + return result.fetchall() + + def toggle_game_events(self, version: int, event_id: int, toggle: bool) -> Optional[List]: + sql = event.update(and_(event.c.version == version, event.c.event_id == event_id)).values( + enabled = int(toggle) + ) + + result = self.execute(sql) + if result is None: + self.logger.warning(f"toggle_game_events: Failed to update event! event_id {event_id} toggle {toggle}") + return result.last_updated_params() + + def put_game_music(self, version: int, song_id: int, chart_id: int, title: str, artist: str, + genre: str, bpm: str, added_version: str, difficulty: float, note_designer: str) -> None: + sql = insert(music).values( + version = version, + songId = song_id, + chartId = chart_id, + title = title, + artist = artist, + genre = genre, + bpm = bpm, + addedVersion = added_version, + difficulty = difficulty, + noteDesigner = note_designer, + ) + + conflict = sql.on_duplicate_key_update( + title = title, + artist = artist, + genre = genre, + bpm = bpm, + addedVersion = added_version, + difficulty = difficulty, + noteDesigner = note_designer, + ) + + result = self.execute(conflict) + if result is None: + self.logger.warn(f"Failed to insert song {song_id} chart {chart_id}") + return None + return result.lastrowid + + def put_game_ticket(self, version: int, ticket_id: int, ticket_type: int, ticket_price: int, name: str) -> Optional[int]: + sql = insert(ticket).values( + version = version, + ticketId = ticket_id, + kind = ticket_type, + price = ticket_price, + name = name + ) + + conflict = sql.on_duplicate_key_update( + price = ticket_price + ) + + result = self.execute(conflict) + if result is None: + self.logger.warn(f"Failed to insert charge {ticket_id} type {ticket_type}") + return None + return result.lastrowid + + def get_enabled_tickets(self, version: int, kind: int = None) -> Optional[List[Row]]: + if kind is not None: + sql = select(ticket).where(and_( + ticket.c.version == version, + ticket.c.enabled == True, + ticket.c.kind == kind + )) + else: + sql = select(ticket).where(and_( + ticket.c.version == version, + ticket.c.enabled == True + )) + + result = self.execute(sql) + if result is None:return None + return result.fetchall() + + def get_music_chart(self, version: int, song_id: int, chart_id: int) -> Optional[List[Row]]: + sql = select(music).where(and_( + music.c.version == version, + music.c.songId == song_id, + music.c.chartId == chart_id + )) + + result = self.execute(sql) + if result is None: return None + return result.fetchone() diff --git a/titles/mai2/splash.py b/titles/mai2/splash.py new file mode 100644 index 0000000..690645b --- /dev/null +++ b/titles/mai2/splash.py @@ -0,0 +1,14 @@ +from typing import Any, List, Dict +from datetime import datetime, timedelta +import pytz +import json + +from core.config import CoreConfig +from titles.mai2.base import Mai2Base +from titles.mai2.config import Mai2Config +from titles.mai2.const import Mai2Constants + +class Mai2Splash(Mai2Base): + def __init__(self, cfg: CoreConfig, game_cfg: Mai2Config) -> None: + super().__init__(cfg, game_cfg) + self.version = Mai2Constants.VER_MAIMAI_DX_SPLASH \ No newline at end of file diff --git a/titles/mai2/splashplus.py b/titles/mai2/splashplus.py new file mode 100644 index 0000000..eb6f940 --- /dev/null +++ b/titles/mai2/splashplus.py @@ -0,0 +1,14 @@ +from typing import Any, List, Dict +from datetime import datetime, timedelta +import pytz +import json + +from core.config import CoreConfig +from titles.mai2.base import Mai2Base +from titles.mai2.config import Mai2Config +from titles.mai2.const import Mai2Constants + +class Mai2SplashPlus(Mai2Base): + def __init__(self, cfg: CoreConfig, game_cfg: Mai2Config) -> None: + super().__init__(cfg, game_cfg) + self.version = Mai2Constants.VER_MAIMAI_DX_SPLASH_PLUS \ No newline at end of file diff --git a/titles/mai2/universe.py b/titles/mai2/universe.py new file mode 100644 index 0000000..be6472c --- /dev/null +++ b/titles/mai2/universe.py @@ -0,0 +1,14 @@ +from typing import Any, List, Dict +from datetime import datetime, timedelta +import pytz +import json + +from core.config import CoreConfig +from titles.mai2.base import Mai2Base +from titles.mai2.const import Mai2Constants +from titles.mai2.config import Mai2Config + +class Mai2Universe(Mai2Base): + def __init__(self, cfg: CoreConfig, game_cfg: Mai2Config) -> None: + super().__init__(cfg, game_cfg) + self.version = Mai2Constants.VER_MAIMAI_DX_UNIVERSE \ No newline at end of file diff --git a/titles/mai2/universeplus.py b/titles/mai2/universeplus.py new file mode 100644 index 0000000..795206e --- /dev/null +++ b/titles/mai2/universeplus.py @@ -0,0 +1,14 @@ +from typing import Any, List, Dict +from datetime import datetime, timedelta +import pytz +import json + +from core.config import CoreConfig +from titles.mai2.base import Mai2Base +from titles.mai2.const import Mai2Constants +from titles.mai2.config import Mai2Config + +class Mai2UniversePlus(Mai2Base): + def __init__(self, cfg: CoreConfig, game_cfg: Mai2Config) -> None: + super().__init__(cfg, game_cfg) + self.version = Mai2Constants.VER_MAIMAI_DX_UNIVERSE_PLUS \ No newline at end of file diff --git a/titles/ongeki/__init__.py b/titles/ongeki/__init__.py new file mode 100644 index 0000000..26e107c --- /dev/null +++ b/titles/ongeki/__init__.py @@ -0,0 +1,18 @@ +from titles.ongeki.index import OngekiServlet +from titles.ongeki.const import OngekiConstants +from titles.ongeki.database import OngekiData +from titles.ongeki.read import OngekiReader + +index = OngekiServlet +database = OngekiData +reader = OngekiReader + +use_default_title = True +include_protocol = True +title_secure = False +game_codes = [OngekiConstants.GAME_CODE] +trailing_slash = True +use_default_host = False +host = "" + +current_schema_version = 2 \ No newline at end of file diff --git a/titles/ongeki/base.py b/titles/ongeki/base.py new file mode 100644 index 0000000..8778645 --- /dev/null +++ b/titles/ongeki/base.py @@ -0,0 +1,934 @@ +from datetime import date, datetime, timedelta +from typing import Any, Dict, List +import json +import logging +from enum import Enum + +from core.config import CoreConfig +from core.data.cache import cached +from titles.ongeki.const import OngekiConstants +from titles.ongeki.config import OngekiConfig +from titles.ongeki.database import OngekiData +from titles.ongeki.config import OngekiConfig + +class OngekiBattleGrade(Enum): + FAILED = 0 + DRAW = 1 + USUALLY = 2 + GOOD = 3 + GREAT = 4 + EXCELLENT = 5 + UNBELIEVABLE_GOLD = 6 + UNBELIEVABLE_RAINBOW = 7 + +class OngekiBattlePointGrade(Enum): + FRESHMAN = 0 + KYU10 = 1 + KYU9 = 2 + KYU8 = 3 + KYU7 = 4 + KYU6 = 5 + KYU5 = 6 + KYU4 = 7 + KYU3 = 8 + KYU2 = 9 + KYU1 = 10 + DAN1 = 11 + DAN2 = 12 + DAN3 = 13 + DAN4 = 14 + DAN5 = 15 + DAN6 = 16 + DAN7 = 17 + DAN8 = 18 + DAN9 = 19 + DAN10 = 20 + SODEN = 21 + +class OngekiTechnicalGrade(Enum): + D = 0 + C = 1 + B = 2 + BB = 3 + BBB = 4 + A = 5 + AA = 6 + AAA = 7 + S = 8 + SS = 9 + SSS = 10 + SSSp = 11 + +class OngekiDifficulty(Enum): + BASIC = 0 + ADVANCED = 1 + EXPERT = 2 + MASTER = 3 + LUNATIC = 10 + +class OngekiGPLogKind(Enum): + NONE = 0 + BUY1_START = 1 + BUY2_START = 2 + BUY3_START = 3 + BUY1_ADD = 4 + BUY2_ADD = 5 + BUY3_ADD = 6 + FIRST_PLAY = 7 + COMPENSATION = 8 + + PAY_PLAY = 11 + PAY_TIME = 12 + PAY_MAS_UNLOCK = 13 + PAY_MONEY = 14 + +class OngekiBase(): + + def __init__(self, core_cfg: CoreConfig, game_cfg: OngekiConfig) -> None: + self.core_cfg = core_cfg + self.game_cfg = game_cfg + self.data = OngekiData(core_cfg) + self.date_time_format = "%Y-%m-%d %H:%M:%S" + self.date_time_format_ext = "%Y-%m-%d %H:%M:%S.%f" # needs to be lopped off at [:-5] + self.date_time_format_short = "%Y-%m-%d" + self.logger = logging.getLogger("ongeki") + self.game = OngekiConstants.GAME_CODE + self.version = OngekiConstants.VER_ONGEKI + + def handle_get_game_setting_api_request(self, data: Dict) -> Dict: + reboot_start = date.strftime(datetime.now() + timedelta(hours=3), self.date_time_format) + reboot_end = date.strftime(datetime.now() + timedelta(hours=4), self.date_time_format) + return { + "gameSetting": { + "dataVersion": "1.00.00", + "onlineDataVersion": "1.00.00", + "isMaintenance": "false", + "requestInterval": 10, + "rebootStartTime": reboot_start, + "rebootEndTime": reboot_end, + "isBackgroundDistribute": "false", + "maxCountCharacter": 50, + "maxCountCard": 300, + "maxCountItem": 300, + "maxCountMusic": 50, + "maxCountMusicItem": 300, + "macCountRivalMusic": 300, + }, + "isDumpUpload": "false", + "isAou": "true", + } + + def handle_get_game_idlist_api_request(self, data: Dict) -> Dict: + """ + Gets lists of song IDs, either disabled songs or recomended songs depending on type? + """ + # type - int + # id - int + return {"type": data["type"], "length": 0, "gameIdlistList": []} + + def handle_get_game_ranking_api_request(self, data: Dict) -> Dict: + return {"length": 0, "gameRankingList": []} + + def handle_get_game_point_api_request(self, data: Dict) -> Dict: + """ + Sets the GP ammount for A and B sets for 1 - 3 crdits + """ + return {"length":6,"gamePointList":[ + {"type":0,"cost":100,"startDate":"2000-01-01 05:00:00.0","endDate":"2099-01-01 05:00:00.0"}, + {"type":1,"cost":200,"startDate":"2000-01-01 05:00:00.0","endDate":"2099-01-01 05:00:00.0"}, + {"type":2,"cost":300,"startDate":"2000-01-01 05:00:00.0","endDate":"2099-01-01 05:00:00.0"}, + {"type":3,"cost":120,"startDate":"2000-01-01 05:00:00.0","endDate":"2099-01-01 05:00:00.0"}, + {"type":4,"cost":240,"startDate":"2000-01-01 05:00:00.0","endDate":"2099-01-01 05:00:00.0"}, + {"type":5,"cost":360,"startDate":"2000-01-01 05:00:00.0","endDate":"2099-01-01 05:00:00.0"} + ]} + + def handle_game_login_api_request(self, data: Dict) -> Dict: + return {"returnCode": 1, "apiName": "gameLogin"} + + def handle_game_logout_api_request(self, data: Dict) -> Dict: + return {"returnCode": 1, "apiName": "gameLogout"} + + def handle_extend_lock_time_api_request(self, data: Dict) -> Dict: + return {"returnCode": 1, "apiName": "ExtendLockTimeApi"} + + def handle_get_game_reward_api_request(self, data: Dict) -> Dict: + # TODO: reward list + return {"length": 0, "gameRewardList": []} + + def handle_get_game_present_api_request(self, data: Dict) -> Dict: + return {"length": 0, "gamePresentList": []} + + def handle_get_game_message_api_request(self, data: Dict) -> Dict: + return {"length": 0, "gameMessageList": []} + + def handle_get_game_sale_api_request(self, data: Dict) -> Dict: + return {"length": 0, "gameSaleList": []} + + def handle_get_game_tech_music_api_request(self, data: Dict) -> Dict: + return {"length": 0, "gameTechMusicList": []} + + def handle_upsert_client_setting_api_request(self, data: Dict) -> Dict: + return {"returnCode": 1, "apiName": "UpsertClientSettingApi"} + + def handle_upsert_client_testmode_api_request(self, data: Dict) -> Dict: + return {"returnCode": 1, "apiName": "UpsertClientTestmodeApi"} + + def handle_upsert_client_bookkeeping_api_request(self, data: Dict) -> Dict: + return {"returnCode": 1, "apiName": "upsertClientBookkeeping"} + + def handle_upsert_client_develop_api_request(self, data: Dict) -> Dict: + return {"returnCode": 1, "apiName": "upsertClientDevelop"} + + def handle_upsert_client_error_api_request(self, data: Dict) -> Dict: + return {"returnCode": 1, "apiName": "upsertClientError"} + + def handle_upsert_user_gplog_api_request(self, data: Dict) -> Dict: + user = data["userId"] + if user >= 200000000000000: # Account for guest play + user = None + + self.data.log.put_gp_log(user, data["usedCredit"], data["placeName"], data["userGplog"]["trxnDate"], + data["userGplog"]["placeId"], data["userGplog"]["kind"], data["userGplog"]["pattern"], data["userGplog"]["currentGP"]) + + return {"returnCode": 1, "apiName": "UpsertUserGplogApi"} + + def handle_extend_lock_time_api_request(self, data: Dict) -> Dict: + return {"returnCode": 1, "apiName": "ExtendLockTimeApi"} + + def handle_get_game_event_api_request(self, data: Dict) -> Dict: + evts = self.data.static.get_enabled_events(self.version) + + evt_list = [] + for event in evts: + evt_list.append({ + "type": event["type"], + "id": event["eventId"], + "startDate": "2017-12-05 07:00:00.0", + "endDate": "2099-12-31 00:00:00.0" + }) + + return {"type": data["type"], "length": len(evt_list), "gameEventList": evt_list} + + def handle_get_game_id_list_api_request(self, data: Dict) -> Dict: + game_idlist: list[str, Any] = [] #1 to 230 & 8000 to 8050 + + if data["type"] == 1: + for i in range(1,231): + game_idlist.append({"type": 1, "id": i}) + return {"type": data["type"], "length": len(game_idlist), "gameIdlistList": game_idlist} + elif data["type"] == 2: + for i in range(8000,8051): + game_idlist.append({"type": 2, "id": i}) + return {"type": data["type"], "length": len(game_idlist), "gameIdlistList": game_idlist} + + def handle_get_user_region_api_request(self, data: Dict) -> Dict: + return {"userId": data["userId"], "length": 0, "userRegionList": []} + + def handle_get_user_preview_api_request(self, data: Dict) -> Dict: + profile = self.data.profile.get_profile_preview(data["userId"], self.version) + + if profile is None: + return { + "userId": data["userId"], + "isLogin": False, + "lastLoginDate": "0000-00-00 00:00:00", + "userName": "", + "reincarnationNum": 0, + "level": 0, + "exp": 0, + "playerRating": 0, + "lastGameId": "", + "lastRomVersion": "", + "lastDataVersion": "", + "lastPlayDate": "", + "nameplateId": 0, + "trophyId": 0, + "cardId": 0, + "dispPlayerLv": 0, + "dispRating": 0, + "dispBP": 0, + "headphone": 0, + "banStatus": 0, + "isWarningConfirmed": True, + } + + return { + "userId": data["userId"], + "isLogin": False, + "lastLoginDate": profile["lastPlayDate"], + "userName": profile["userName"], + "reincarnationNum": profile["reincarnationNum"], + "level": profile["level"], + "exp": profile["exp"], + "playerRating": profile["playerRating"], + "lastGameId": profile["lastGameId"], + "lastRomVersion": profile["lastRomVersion"], + "lastDataVersion": profile["lastDataVersion"], + "lastPlayDate": profile["lastPlayDate"], + "nameplateId": profile["nameplateId"], + "trophyId": profile["trophyId"], + "cardId": profile["cardId"], + "dispPlayerLv": profile["dispPlayerLv"], + "dispRating": profile["dispRating"], + "dispBP": profile["dispBP"], + "headphone": profile["headphone"], + "banStatus": profile["banStatus"], + "isWarningConfirmed": True, + } + + def handle_get_user_tech_count_api_request(self, data: Dict) -> Dict: + """ + Gets the number of AB and ABPs a player has per-difficulty (7, 7+, 8, etc) + The game sends this in upsert so we don't have to calculate it all out thankfully + """ + utcl = self.data.score.get_tech_count(data["userId"]) + userTechCountList = [] + + for tc in utcl: + tc.pop("id") + tc.pop("user") + userTechCountList.append(tc) + + return { + "userId": data["userId"], + "length": len(userTechCountList), + "userTechCountList": userTechCountList, + } + + def handle_get_user_tech_event_api_request(self, data: Dict) -> Dict: + user_tech_event_list = self.data.item.get_tech_event(data["userId"]) + if user_tech_event_list is None: return {} + + tech_evt = [] + for evt in user_tech_event_list: + tmp = evt._asdict() + tmp.pop("id") + tmp.pop("user") + tech_evt.append(tmp) + + return { + "userId": data["userId"], + "length": len(tech_evt), + "userTechEventList": tech_evt, + } + + def handle_get_user_tech_event_ranking_api_request(self, data: Dict) -> Dict: + #user_event_ranking_list = self.data.item.get_tech_event_ranking(data["userId"]) + #if user_event_ranking_list is None: return {} + + evt_ranking = [] + #for evt in user_event_ranking_list: + # tmp = evt._asdict() + # tmp.pop("id") + # tmp.pop("user") + # evt_ranking.append(tmp) + + return { + "userId": data["userId"], + "length": len(evt_ranking), + "userTechEventRankingList": evt_ranking, + } + + def handle_get_user_kop_api_request(self, data: Dict) -> Dict: + kop_list = self.data.profile.get_kop(data["userId"]) + if kop_list is None: return {} + + for kop in kop_list: + kop.pop("user") + kop.pop("id") + + return { + "userId": data["userId"], + "length": len(kop_list), + "userKopList": kop_list, + } + + def handle_get_user_music_api_request(self, data: Dict) -> Dict: + song_list = self.util_generate_music_list(data["userId"]) + max_ct = data["maxCount"] + next_idx = data["nextIndex"] + start_idx = next_idx + end_idx = max_ct + start_idx + + if len(song_list[start_idx:]) > max_ct: + next_idx += max_ct + + else: + next_idx = -1 + + return { + "userId": data["userId"], + "length": len(song_list[start_idx:end_idx]), + "nextIndex": next_idx, + "userMusicList": song_list[start_idx:end_idx] + } + + def handle_get_user_item_api_request(self, data: Dict) -> Dict: + kind = data["nextIndex"] / 10000000000 + p = self.data.item.get_items(data["userId"], kind) + + if p is None: + return {"userId": data["userId"], "nextIndex": -1, "itemKind": kind, "userItemList": []} + + items: list[Dict[str, Any]] = [] + for i in range(data["nextIndex"] % 10000000000, len(p)): + if len(items) > data["maxCount"]: + break + tmp = p[i]._asdict() + tmp.pop("user") + tmp.pop("id") + items.append(tmp) + + xout = kind * 10000000000 + (data["nextIndex"] % 10000000000) + len(items) + + if len(items) < data["maxCount"] or data["maxCount"] == 0: nextIndex = 0 + else: nextIndex = xout + + return {"userId": data["userId"], "nextIndex": int(nextIndex), "itemKind": int(kind), "length": len(items), "userItemList": items} + + def handle_get_user_option_api_request(self, data: Dict) -> Dict: + o = self.data.profile.get_profile_options(data["userId"]) + if o is None: return {} + + # get the dict representation of the row so we can modify values + user_opts = o._asdict() + + # remove the values the game doesn't want + user_opts.pop("id") + user_opts.pop("user") + + return {"userId": data["userId"], "userOption": user_opts} + + def handle_get_user_data_api_request(self, data: Dict) -> Dict: + p = self.data.profile.get_profile_data(data["userId"], self.version) + if p is None: return {} + + cards = self.data.card.get_user_cards(data["userId"]) + if cards is None or len(cards) == 0: + # This should never happen + self.logger.error(f"handle_get_user_data_api_request: Internal error - No cards found for user id {data['userId']}") + return {} + + # get the dict representation of the row so we can modify values + user_data = p._asdict() + + # remove the values the game doesn't want + user_data.pop("id") + user_data.pop("user") + user_data.pop("version") + + # TODO: replace datetime objects with strings + + # add access code that we don't store + user_data["accessCode"] = cards[0]["access_code"] + + return {"userId": data["userId"], "userData":user_data} + + def handle_get_user_event_ranking_api_request(self, data: Dict) -> Dict: + #user_event_ranking_list = self.data.item.get_event_ranking(data["userId"]) + #if user_event_ranking_list is None: return {} + + evt_ranking = [] + #for evt in user_event_ranking_list: + # tmp = evt._asdict() + # tmp.pop("id") + # tmp.pop("user") + # evt_ranking.append(tmp) + + return { + "userId": data["userId"], + "length": len(evt_ranking), + "userEventRankingList": evt_ranking, + } + + def handle_get_user_login_bonus_api_request(self, data: Dict) -> Dict: + user_login_bonus_list = self.data.item.get_login_bonuses(data["userId"]) + if user_login_bonus_list is None: return {} + + login_bonuses = [] + for scenerio in user_login_bonus_list: + tmp = scenerio._asdict() + tmp.pop("id") + tmp.pop("user") + login_bonuses.append(tmp) + + return { + "userId": data["userId"], + "length": len(login_bonuses), + "userLoginBonusList": login_bonuses + } + + def handle_get_user_bp_base_request(self, data: Dict) -> Dict: + p = self.data.profile.get_profile(self.game, self.version, user_id = data["userId"]) + if p is None: return {} + profile = json.loads(p["data"]) + return { + "userId": data["userId"], + "length": len(profile["userBpBaseList"]), + "userBpBaseList": profile["userBpBaseList"], + } + + def handle_get_user_recent_rating_api_request(self, data: Dict) -> Dict: + recent_rating = self.data.profile.get_profile_recent_rating(data["userId"]) + if recent_rating is None: return {} + + userRecentRatingList = recent_rating["recentRating"] + + return { + "userId": data["userId"], + "length": len(userRecentRatingList), + "userRecentRatingList": userRecentRatingList, + } + + def handle_get_user_activity_api_request(self, data: Dict) -> Dict: + activity = self.data.profile.get_profile_activity(data["userId"], data["kind"]) + if activity is None: return {} + + user_activity = [] + + for act in activity: + user_activity.append({ + "kind": act["kind"], + "id": act["activityId"], + "sortNumber": act["sortNumber"], + "param1": act["param1"], + "param2": act["param2"], + "param3": act["param3"], + "param4": act["param4"], + }) + + return { + "userId": data["userId"], + "length": len(user_activity), + "kind": data["kind"], + "userActivityList": user_activity + } + + def handle_get_user_story_api_request(self, data: Dict) -> Dict: + user_stories = self.data.item.get_stories(data["userId"]) + if user_stories is None: return {} + + story_list = [] + for story in user_stories: + tmp = story._asdict() + tmp.pop("id") + tmp.pop("user") + story_list.append(tmp) + + return { + "userId": data["userId"], + "length": len(story_list), + "userStoryList": story_list + } + + def handle_get_user_chapter_api_request(self, data: Dict) -> Dict: + user_chapters = self.data.item.get_chapters(data["userId"]) + if user_chapters is None: return {} + + chapter_list = [] + for chapter in user_chapters: + tmp = chapter._asdict() + tmp.pop("id") + tmp.pop("user") + chapter_list.append(tmp) + + return { + "userId": data["userId"], + "length": len(chapter_list), + "userChapterList": chapter_list + } + + def handle_get_user_training_room_by_key_api_request(self, data: Dict) -> Dict: + return { + "userId": data["userId"], + "length": 0, + "userTrainingRoomList": [], + } + + def handle_get_user_character_api_request(self, data: Dict) -> Dict: + user_characters = self.data.item.get_characters(data["userId"]) + if user_characters is None: return {} + + character_list = [] + for character in user_characters: + tmp = character._asdict() + tmp.pop("id") + tmp.pop("user") + character_list.append(tmp) + + return { + "userId": data["userId"], + "length": len(character_list), + "userCharacterList": character_list + } + + def handle_get_user_card_api_request(self, data: Dict) -> Dict: + user_cards = self.data.item.get_cards(data["userId"]) + if user_cards is None: return {} + + card_list = [] + for card in user_cards: + tmp = card._asdict() + tmp.pop("id") + tmp.pop("user") + card_list.append(tmp) + + return { + "userId": data["userId"], + "length": len(card_list), + "userCardList": card_list + } + + def handle_get_user_deck_by_key_api_request(self, data: Dict) -> Dict: + # Auth key doesn't matter, it just wants all the decks + decks = self.data.item.get_decks(data["userId"]) + if decks is None: return {} + + deck_list = [] + for deck in decks: + tmp = deck._asdict() + tmp.pop("user") + tmp.pop("id") + deck_list.append(tmp) + + return { + "userId": data["userId"], + "length": len(deck_list), + "userDeckList": deck_list, + } + + def handle_get_user_trade_item_api_request(self, data: Dict) -> Dict: + user_trade_items = self.data.item.get_trade_items(data["userId"]) + if user_trade_items is None: return {} + + trade_item_list = [] + for trade_item in user_trade_items: + tmp = trade_item._asdict() + tmp.pop("id") + tmp.pop("user") + trade_item_list.append(tmp) + + return { + "userId": data["userId"], + "length": len(trade_item_list), + "userTradeItemList": trade_item_list, + } + + def handle_get_user_scenario_api_request(self, data: Dict) -> Dict: + user_scenerio = self.data.item.get_scenerios(data["userId"]) + if user_scenerio is None: return {} + + scenerio_list = [] + for scenerio in user_scenerio: + tmp = scenerio._asdict() + tmp.pop("id") + tmp.pop("user") + scenerio_list.append(tmp) + + return { + "userId": data["userId"], + "length": len(scenerio_list), + "userScenarioList": scenerio_list, + } + + def handle_get_user_ratinglog_api_request(self, data: Dict) -> Dict: + rating_log = self.data.profile.get_profile_rating_log(data["userId"]) + if rating_log is None: return {} + + userRatinglogList = [] + for rating in rating_log: + tmp = rating._asdict() + tmp.pop("id") + tmp.pop("user") + userRatinglogList.append(tmp) + + return { + "userId": data["userId"], + "length": len(userRatinglogList), + "userRatinglogList": userRatinglogList, + } + + def handle_get_user_mission_point_api_request(self, data: Dict) -> Dict: + user_mission_point_list = self.data.item.get_mission_points(data["userId"]) + if user_mission_point_list is None: return {} + + mission_point_list = [] + for evt_music in user_mission_point_list: + tmp = evt_music._asdict() + tmp.pop("id") + tmp.pop("user") + mission_point_list.append(tmp) + + return { + "userId": data["userId"], + "length": len(mission_point_list), + "userMissionPointList": mission_point_list, + } + + def handle_get_user_event_point_api_request(self, data: Dict) -> Dict: + user_event_point_list = self.data.item.get_event_points(data["userId"]) + if user_event_point_list is None: return {} + + event_point_list = [] + for evt_music in user_event_point_list: + tmp = evt_music._asdict() + tmp.pop("id") + tmp.pop("user") + event_point_list.append(tmp) + + return { + "userId": data["userId"], + "length": len(event_point_list), + "userEventPointList": event_point_list, + } + + def handle_get_user_music_item_api_request(self, data: Dict) -> Dict: + user_music_item_list = self.data.item.get_music_items(data["userId"]) + if user_music_item_list is None: return {} + + music_item_list = [] + for evt_music in user_music_item_list: + tmp = evt_music._asdict() + tmp.pop("id") + tmp.pop("user") + music_item_list.append(tmp) + + return { + "userId": data["userId"], + "length": len(music_item_list), + "userMusicItemList": music_item_list, + } + + def handle_get_user_event_music_api_request(self, data: Dict) -> Dict: + user_evt_music_list = self.data.item.get_event_music(data["userId"]) + if user_evt_music_list is None: return {} + + evt_music_list = [] + for evt_music in user_evt_music_list: + tmp = evt_music._asdict() + tmp.pop("id") + tmp.pop("user") + evt_music_list.append(tmp) + + return { + "userId": data["userId"], + "length": len(evt_music_list), + "userEventMusicList": evt_music_list, + } + + def handle_get_user_boss_api_request(self, data: Dict) -> Dict: + p = self.data.item.get_bosses(data["userId"]) + if p is None: return {} + + boss_list = [] + for boss in p: + tmp = boss._asdict() + tmp.pop("id") + tmp.pop("user") + boss_list.append(tmp) + + return { + "userId": data["userId"], + "length": len(boss_list), + "userBossList": boss_list, + } + + def handle_upsert_user_all_api_request(self, data: Dict) -> Dict: + upsert = data["upsertUserAll"] + user_id = data["userId"] + + # The isNew fields are new as of Red and up. We just won't use them for now. + + if "userData" in upsert and len(upsert["userData"]) > 0: + self.data.profile.put_profile_data(user_id, self.version, upsert["userData"][0]) + + if "userOption" in upsert and len(upsert["userOption"]) > 0: + self.data.profile.put_profile_options(user_id, upsert["userOption"][0]) + + if "userPlaylogList" in upsert: + for playlog in upsert["userPlaylogList"]: + self.data.score.put_playlog(user_id, playlog) + + if "userActivityList" in upsert: + for act in upsert["userActivityList"]: + self.data.profile.put_profile_activity(user_id, act["kind"], act["id"], act["sortNumber"], act["param1"], + act["param2"], act["param3"], act["param4"]) + + if "userRecentRatingList" in upsert: + self.data.profile.put_profile_recent_rating(user_id, upsert["userRecentRatingList"]) + + if "userBpBaseList" in upsert: + self.data.profile.put_profile_bp_list(user_id, upsert["userBpBaseList"]) + + if "userMusicDetailList" in upsert: + for x in upsert["userMusicDetailList"]: + self.data.score.put_best_score(user_id, x) + + if "userCharacterList" in upsert: + for x in upsert["userCharacterList"]: + self.data.item.put_character(user_id, x) + + if "userCardList" in upsert: + for x in upsert["userCardList"]: + self.data.item.put_card(user_id, x) + + if "userDeckList" in upsert: + for x in upsert["userDeckList"]: + self.data.item.put_deck(user_id, x) + + if "userTrainingRoomList" in upsert: + for x in upsert["userTrainingRoomList"]: + self.data.profile.put_training_room(user_id, x) + + if "userStoryList" in upsert: + for x in upsert["userStoryList"]: + self.data.item.put_story(user_id, x) + + if "userChapterList" in upsert: + for x in upsert["userChapterList"]: + self.data.item.put_chapter(user_id, x) + + if "userItemList" in upsert: + for x in upsert["userItemList"]: + self.data.item.put_item(user_id, x) + + if "userMusicItemList" in upsert: + for x in upsert["userMusicItemList"]: + self.data.item.put_music_item(user_id, x) + + if "userLoginBonusList" in upsert: + for x in upsert["userLoginBonusList"]: + self.data.item.put_login_bonus(user_id, x) + + if "userEventPointList" in upsert: + for x in upsert["userEventPointList"]: + self.data.item.put_event_point(user_id, x) + + if "userMissionPointList" in upsert: + for x in upsert["userMissionPointList"]: + self.data.item.put_mission_point(user_id, x) + + if "userRatinglogList" in upsert: + for x in upsert["userRatinglogList"]: + self.data.profile.put_profile_rating_log(user_id, x["dataVersion"], x["highestRating"]) + + if "userBossList" in upsert: + for x in upsert["userBossList"]: + self.data.item.put_boss(user_id, x) + + if "userTechCountList" in upsert: + for x in upsert["userTechCountList"]: + self.data.score.put_tech_count(user_id, x) + + if "userScenerioList" in upsert: + for x in upsert["userScenerioList"]: + self.data.item.put_scenerio(user_id, x) + + if "userTradeItemList" in upsert: + for x in upsert["userTradeItemList"]: + self.data.item.put_trade_item(user_id, x) + + if "userEventMusicList" in upsert: + for x in upsert["userEventMusicList"]: + self.data.item.put_event_music(user_id, x) + + if "userTechEventList" in upsert: + for x in upsert["userTechEventList"]: + self.data.item.put_tech_event(user_id, x) + + if "userKopList" in upsert: + for x in upsert["userKopList"]: + self.data.profile.put_kop(user_id, x) + + return {'returnCode': 1, 'apiName': 'upsertUserAll'} + + def handle_get_user_rival_api_request(self, data: Dict) -> Dict: + """ + Added in Bright + """ + rival_list = self.data.profile.get_rivals(data["userId"]) + if rival_list is None or len(rival_list) < 1: + return { + "userId": data["userId"], + "length": 0, + "userRivalList": [], + } + + return { + "userId": data["userId"], + "length": len(rival_list), + "userRivalList": rival_list._asdict(), + } + + def handle_get_user_rival_data_api_reqiest(self, data:Dict) -> Dict: + """ + Added in Bright + """ + rivals = [] + + for rival in data["userRivalList"]: + name = self.data.profile.get_profile_name(rival["rivalUserId"], self.version) + if name is None: + continue + + rivals.append({ + "rivalUserId": rival["rival"], + "rivalUserName": name + }) + + return { + "userId": data["userId"], + "length": len(rivals), + "userRivalDataList": rivals, + } + + def handle_get_user_rival_music_api_request(self, data: Dict) -> Dict: + """ + Added in Bright + """ + rival_id = data["rivalUserId"] + next_idx = data["nextIndex"] + max_ct = data["maxCount"] + music = self.handle_get_user_music_api_request({ + "userId": rival_id, + "nextIndex": next_idx, + "maxCount": max_ct + }) + + for song in music["userMusicList"]: + song["userRivalMusicDetailList"] = song["userMusicDetailList"] + song.pop("userMusicDetailList") + + return { + "userId": data["userId"], + "rivalUserId": rival_id, + "length": music["length"], + "nextIndex": music["nextIndex"], + "userRivalMusicList": music["userMusicList"], + } + + @cached(2) + def util_generate_music_list(self, user_id: int) -> List: + music_detail = self.data.score.get_best_scores(user_id) + song_list = [] + + for md in music_detail: + found = False + tmp = md._asdict() + tmp.pop("user") + tmp.pop("id") + + for song in song_list: + if song["userMusicDetailList"][0]["musicId"] == tmp["musicId"]: + found = True + song["userMusicDetailList"].append(tmp) + song["length"] = len(song["userMusicDetailList"]) + break + + if not found: + song_list.append({ + "length": 1, + "userMusicDetailList": [tmp] + }) + + return song_list diff --git a/titles/ongeki/bright.py b/titles/ongeki/bright.py new file mode 100644 index 0000000..d92ed48 --- /dev/null +++ b/titles/ongeki/bright.py @@ -0,0 +1,21 @@ +from datetime import date, datetime, timedelta +from typing import Any, Dict +import pytz +import json + +from core.config import CoreConfig +from titles.ongeki.base import OngekiBase +from titles.ongeki.const import OngekiConstants +from titles.ongeki.config import OngekiConfig + +class OngekiBright(OngekiBase): + + def __init__(self, core_cfg: CoreConfig, game_cfg: OngekiConfig) -> None: + super().__init__(core_cfg, game_cfg) + self.version = OngekiConstants.VER_ONGEKI_BRIGHT + + def handle_get_game_setting_api_request(self, data: Dict) -> Dict: + ret = super().handle_get_game_setting_api_request(data) + ret["gameSetting"]["dataVersion"] = "1.30.00" + ret["gameSetting"]["onlineDataVersion"] = "1.30.00" + return ret diff --git a/titles/ongeki/config.py b/titles/ongeki/config.py new file mode 100644 index 0000000..722677c --- /dev/null +++ b/titles/ongeki/config.py @@ -0,0 +1,17 @@ +from core.config import CoreConfig + +class OngekiServerConfig(): + def __init__(self, parent_config: "OngekiConfig") -> None: + self.__config = parent_config + + @property + def enable(self) -> bool: + return CoreConfig.get_config_field(self.__config, 'ongeki', 'server', 'enable', default=True) + + @property + def loglevel(self) -> int: + return CoreConfig.str_to_loglevel(CoreConfig.get_config_field(self.__config, 'ongeki', 'server', 'loglevel', default="info")) + +class OngekiConfig(dict): + def __init__(self) -> None: + self.server = OngekiServerConfig(self) diff --git a/titles/ongeki/const.py b/titles/ongeki/const.py new file mode 100644 index 0000000..da9614e --- /dev/null +++ b/titles/ongeki/const.py @@ -0,0 +1,50 @@ +from typing import Final, Dict +from enum import Enum +class OngekiConstants(): + GAME_CODE = "SDDT" + + VER_ONGEKI = 0 + VER_ONGEKI_PLUS = 1 + VER_ONGEKI_SUMMER = 2 + VER_ONGEKI_SUMMER_PLUS = 3 + VER_ONGEKI_RED = 4 + VER_ONGEKI_RED_PLUS = 5 + VER_ONGEKI_BRIGHT = 6 + + EVT_TYPES: Enum = Enum('EVT_TYPES', [ + 'None', + 'Announcement', + 'Movie', + 'AddMyList', + 'UnlockChapter', + 'JewelEvent', + 'RankingEvent', + 'AcceptRankingEvent', + 'UnlockMusic', + 'UnlockCard', + 'UnlockTrophy', + 'UnlockNamePlate', + 'UnlockLimitBreakItem', + 'MissionEvent', + 'DailyBonus', + 'UnlockBossLockEarly', + 'UnlockPurchaseItem', + 'TechChallengeEvent', + 'AcceptTechChallengeEvent', + 'SilverJewelEvent', + ]) + + # The game expects the server to give Lunatic an ID of 10, while the game uses 4 internally... except in Music.xml + class DIFF_NAME(Enum): + Basic = 0 + Advanced = 1 + Expert = 2 + Master = 3 + Lunatic = 10 + + VERSION_NAMES = ("ONGEKI", "ONGEKI+", "ONGEKI Summer", "ONGEKI Summer+", "ONGEKI Red", "ONGEKI Red+", + "ONGEKI Bright") + + @classmethod + def game_ver_to_string(cls, ver: int): + return cls.VERSION_NAMES[ver] \ No newline at end of file diff --git a/titles/ongeki/database.py b/titles/ongeki/database.py new file mode 100644 index 0000000..a2168e4 --- /dev/null +++ b/titles/ongeki/database.py @@ -0,0 +1,14 @@ +from core.data import Data +from core.config import CoreConfig +from titles.ongeki.schema import OngekiItemData, OngekiProfileData, OngekiScoreData +from titles.ongeki.schema import OngekiStaticData, OngekiLogData + +class OngekiData(Data): + def __init__(self, cfg: CoreConfig) -> None: + super().__init__(cfg) + + self.item = OngekiItemData(cfg, self.session) + self.profile = OngekiProfileData(cfg, self.session) + self.score = OngekiScoreData(cfg, self.session) + self.static = OngekiStaticData(cfg, self.session) + self.log = OngekiLogData(cfg, self.session) \ No newline at end of file diff --git a/titles/ongeki/index.py b/titles/ongeki/index.py new file mode 100644 index 0000000..d3b107e --- /dev/null +++ b/titles/ongeki/index.py @@ -0,0 +1,114 @@ +from twisted.web.http import Request +import json +import inflection +import yaml +import string +import logging, coloredlogs +import zlib +from logging.handlers import TimedRotatingFileHandler + +from core.config import CoreConfig +from titles.ongeki.config import OngekiConfig +from titles.ongeki.const import OngekiConstants +from titles.ongeki.base import OngekiBase +from titles.ongeki.plus import OngekiPlus +from titles.ongeki.summer import OngekiSummer +from titles.ongeki.summerplus import OngekiSummerPlus +from titles.ongeki.red import OngekiRed +from titles.ongeki.redplus import OngekiRedPlus +from titles.ongeki.bright import OngekiBright + +class OngekiServlet(): + def __init__(self, core_cfg: CoreConfig, cfg_dir: str) -> None: + self.core_cfg = core_cfg + self.game_cfg = OngekiConfig() + self.game_cfg.update(yaml.safe_load(open(f"{cfg_dir}/ongeki.yaml"))) + + self.versions = [ + OngekiBase(core_cfg, self.game_cfg), + OngekiPlus(core_cfg, self.game_cfg), + OngekiSummer(core_cfg, self.game_cfg), + OngekiSummerPlus(core_cfg, self.game_cfg), + OngekiRed(core_cfg, self.game_cfg), + OngekiRedPlus(core_cfg, self.game_cfg), + OngekiBright(core_cfg, self.game_cfg), + ] + + self.logger = logging.getLogger("ongeki") + log_fmt_str = "[%(asctime)s] Ongeki | %(levelname)s | %(message)s" + log_fmt = logging.Formatter(log_fmt_str) + fileHandler = TimedRotatingFileHandler("{0}/{1}.log".format(self.core_cfg.server.log_dir, "ongeki"), encoding='utf8', + when="d", backupCount=10) + + fileHandler.setFormatter(log_fmt) + + consoleHandler = logging.StreamHandler() + consoleHandler.setFormatter(log_fmt) + + self.logger.addHandler(fileHandler) + self.logger.addHandler(consoleHandler) + + self.logger.setLevel(self.game_cfg.server.loglevel) + coloredlogs.install(level=self.game_cfg.server.loglevel, logger=self.logger, fmt=log_fmt_str) + + def render_POST(self, request: Request, version: int, url_path: str) -> bytes: + req_raw = request.content.getvalue() + url_split = url_path.split("/") + internal_ver = 0 + endpoint = url_split[len(url_split) - 1] + + if version < 105: # 1.0 + internal_ver = OngekiConstants.VER_ONGEKI + elif version >= 105 and version < 110: # Plus + internal_ver = OngekiConstants.VER_ONGEKI_PLUS + elif version >= 110 and version < 115: # Summer + internal_ver = OngekiConstants.VER_ONGEKI_SUMMER + elif version >= 115 and version < 120: # Summer Plus + internal_ver = OngekiConstants.VER_ONGEKI_SUMMER_PLUS + elif version >= 120 and version < 125: # Red + internal_ver = OngekiConstants.VER_ONGEKI_RED + elif version >= 125 and version < 130: # Red Plus + internal_ver = OngekiConstants.VER_ONGEKI_RED_PLUS + elif version >= 130 and version < 135: # Red Plus + internal_ver = OngekiConstants.VER_ONGEKI_BRIGHT + + if all(c in string.hexdigits for c in endpoint) and len(endpoint) == 32: + # If we get a 32 character long hex string, it's a hash and we're + # doing encrypted. The likelyhood of false positives is low but + # technically not 0 + self.logger.error("Encryption not supported at this time") + + try: + unzip = zlib.decompress(req_raw) + + except zlib.error as e: + self.logger.error(f"Failed to decompress v{version} {endpoint} request -> {e}") + return zlib.compress("{\"stat\": \"0\"}".encode("utf-8")) + + req_data = json.loads(unzip) + + self.logger.info(f"v{version} {endpoint} request - {req_data}") + + func_to_find = "handle_" + inflection.underscore(endpoint) + "_request" + + try: + handler = getattr(self.versions[internal_ver], func_to_find) + resp = handler(req_data) + + except AttributeError as e: + self.logger.warning(f"Unhandled v{version} request {endpoint} - {e}") + return zlib.compress("{\"stat\": \"0\"}".encode("utf-8")) + + except Exception as e: + self.logger.error(f"Error handling v{version} method {endpoint} - {e}") + return zlib.compress("{\"stat\": \"0\"}".encode("utf-8")) + + if resp == None: + resp = {'returnCode': 1} + + self.logger.info(f"Response {resp}") + + return zlib.compress(json.dumps(resp, ensure_ascii=False).encode("utf-8")) + + + \ No newline at end of file diff --git a/titles/ongeki/plus.py b/titles/ongeki/plus.py new file mode 100644 index 0000000..8875503 --- /dev/null +++ b/titles/ongeki/plus.py @@ -0,0 +1,17 @@ +from typing import Dict, Any + +from core.config import CoreConfig +from titles.ongeki.base import OngekiBase +from titles.ongeki.const import OngekiConstants +from titles.ongeki.config import OngekiConfig + +class OngekiPlus(OngekiBase): + def __init__(self, core_cfg: CoreConfig, game_cfg: OngekiConfig) -> None: + super().__init__(core_cfg, game_cfg) + self.version = OngekiConstants.VER_ONGEKI_PLUS + + def handle_get_game_setting_api_request(self, data: Dict) -> Dict: + ret = super().handle_get_game_setting_api_request(data) + ret["gameSetting"]["dataVersion"] = "1.05.00" + ret["gameSetting"]["onlineDataVersion"] = "1.05.00" + return ret diff --git a/titles/ongeki/read.py b/titles/ongeki/read.py new file mode 100644 index 0000000..8b1be3d --- /dev/null +++ b/titles/ongeki/read.py @@ -0,0 +1,89 @@ +from decimal import Decimal +import logging +import os +import re +import xml.etree.ElementTree as ET +from typing import Any, Dict, List, Optional + +from read import BaseReader +from core.config import CoreConfig +from titles.ongeki.database import OngekiData +from titles.ongeki.const import OngekiConstants +from titles.ongeki.config import OngekiConfig + +class OngekiReader(BaseReader): + def __init__(self, config: CoreConfig, version: int, bin_dir: Optional[str], opt_dir: Optional[str], extra: Optional[str]) -> None: + super().__init__(config, version, bin_dir, opt_dir, extra) + self.data = OngekiData(config) + + try: + self.logger.info(f"Start importer for {OngekiConstants.game_ver_to_string(version)}") + except IndexError: + self.logger.error(f"Invalid ongeki version {version}") + exit(1) + + def read(self) -> None: + data_dirs = [] + if self.bin_dir is not None: + data_dirs += self.get_data_directories(self.bin_dir) + + if self.opt_dir is not None: + data_dirs += self.get_data_directories(self.opt_dir) + + for dir in data_dirs: + self.read_events(f"{dir}/event") + self.read_music(f"{dir}/music") + + def read_events(self, base_dir: str) -> None: + self.logger.info(f"Reading events from {base_dir}...") + + for root, dirs, files in os.walk(base_dir): + for dir in dirs: + if os.path.exists(f"{root}/{dir}/Event.xml"): + with open(f"{root}/{dir}/Event.xml", "r", encoding="utf-8") as f: + troot = ET.fromstring(f.read()) + + name = troot.find('Name').find('str').text + id = int(troot.find('Name').find('id').text) + event_type = OngekiConstants.EVT_TYPES[troot.find('EventType').text].value + + + self.data.static.put_event(self.version, id, event_type, name) + self.logger.info(f"Added event {id}") + + def read_music(self, base_dir: str) -> None: + self.logger.info(f"Reading music from {base_dir}...") + + for root, dirs, files in os.walk(base_dir): + for dir in dirs: + if os.path.exists(f"{root}/{dir}/Music.xml"): + strdata = "" + + with open(f"{root}/{dir}/Music.xml", "r", encoding="utf-8") as f: + strdata = f.read() + + troot = ET.fromstring(strdata) + + if root is None: + continue + + name = troot.find('Name') + song_id = name.find('id').text + title = name.find('str').text + artist = troot.find('ArtistName').find('str').text + genre = troot.find('Genre').find('str').text + + fumens = troot.find("FumenData") + for fumens_data in fumens.findall('FumenData'): + path = fumens_data.find('FumenFile').find('path').text + if path is None or not os.path.exists(f"{root}/{dir}/{path}"): + continue + + chart_id = int(path.split(".")[0].split("_")[1]) + level = float( + f"{fumens_data.find('FumenConstIntegerPart').text}.{fumens_data.find('FumenConstFractionalPart').text}" + ) + + self.data.static.put_chart(self.version, song_id, chart_id, title, artist, genre, level) + self.logger.info(f"Added song {song_id} chart {chart_id}") + diff --git a/titles/ongeki/red.py b/titles/ongeki/red.py new file mode 100644 index 0000000..047286e --- /dev/null +++ b/titles/ongeki/red.py @@ -0,0 +1,17 @@ +from typing import Dict, Any + +from core.config import CoreConfig +from titles.ongeki.base import OngekiBase +from titles.ongeki.const import OngekiConstants +from titles.ongeki.config import OngekiConfig + +class OngekiRed(OngekiBase): + def __init__(self, core_cfg: CoreConfig, game_cfg: OngekiConfig) -> None: + super().__init__(core_cfg, game_cfg) + self.version = OngekiConstants.VER_ONGEKI_RED + + def handle_get_game_setting_api_request(self, data: Dict) -> Dict: + ret = super().handle_get_game_setting_api_request(data) + ret["gameSetting"]["dataVersion"] = "1.20.00" + ret["gameSetting"]["onlineDataVersion"] = "1.20.00" + return ret diff --git a/titles/ongeki/redplus.py b/titles/ongeki/redplus.py new file mode 100644 index 0000000..a4df205 --- /dev/null +++ b/titles/ongeki/redplus.py @@ -0,0 +1,23 @@ +from typing import Dict, Any + +from core.config import CoreConfig +from titles.ongeki.base import OngekiBase +from titles.ongeki.const import OngekiConstants +from titles.ongeki.config import OngekiConfig + +class OngekiRedPlus(OngekiBase): + def __init__(self, core_cfg: CoreConfig, game_cfg: OngekiConfig) -> None: + super().__init__(core_cfg, game_cfg) + self.version = OngekiConstants.VER_ONGEKI_RED_PLUS + + def handle_get_game_setting_api_request(self, data: Dict) -> Dict: + ret = super().handle_get_game_setting_api_request(data) + ret["gameSetting"]["dataVersion"] = "1.25.00" + ret["gameSetting"]["onlineDataVersion"] = "1.25.00" + ret["gameSetting"]["maxCountCharacter"] = 50 + ret["gameSetting"]["maxCountCard"] = 300 + ret["gameSetting"]["maxCountItem"] = 300 + ret["gameSetting"]["maxCountMusic"] = 50 + ret["gameSetting"]["maxCountMusicItem"] = 300 + ret["gameSetting"]["macCountRivalMusic"] = 300 + return ret diff --git a/titles/ongeki/schema/__init__.py b/titles/ongeki/schema/__init__.py new file mode 100644 index 0000000..9b1e1da --- /dev/null +++ b/titles/ongeki/schema/__init__.py @@ -0,0 +1,7 @@ +from titles.ongeki.schema.profile import OngekiProfileData +from titles.ongeki.schema.item import OngekiItemData +from titles.ongeki.schema.static import OngekiStaticData +from titles.ongeki.schema.score import OngekiScoreData +from titles.ongeki.schema.log import OngekiLogData + +__all__ = [OngekiProfileData, OngekiItemData, OngekiStaticData, OngekiScoreData, OngekiLogData] \ No newline at end of file diff --git a/titles/ongeki/schema/item.py b/titles/ongeki/schema/item.py new file mode 100644 index 0000000..cc09fda --- /dev/null +++ b/titles/ongeki/schema/item.py @@ -0,0 +1,526 @@ +from typing import Dict, Optional, List +from sqlalchemy import Table, Column, UniqueConstraint, PrimaryKeyConstraint, and_ +from sqlalchemy.types import Integer, String, TIMESTAMP, Boolean, JSON +from sqlalchemy.schema import ForeignKey +from sqlalchemy.sql import func, select +from sqlalchemy.dialects.mysql import insert + +from core.data.schema import BaseData, metadata + +card = Table( + "ongeki_user_card", + metadata, + Column("id", Integer, primary_key=True, nullable=False), + Column("user", ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade")), + Column("cardId", Integer), + Column("digitalStock", Integer), + Column("analogStock", Integer), + Column("level", Integer), + Column("maxLevel", Integer), + Column("exp", Integer), + Column("printCount", Integer), + Column("useCount", Integer), + Column("isNew", Boolean), + Column("kaikaDate", String(25)), + Column("choKaikaDate", String(25)), + Column("skillId", Integer), + Column("isAcquired", Boolean), + Column("created", String(25)), + UniqueConstraint("user", "cardId", name="ongeki_user_card_uk"), + mysql_charset='utf8mb4' +) + +deck = Table( + "ongeki_user_deck", + metadata, + Column("id", Integer, primary_key=True, nullable=False), + Column("user", ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade")), + Column("deckId", Integer), + Column("cardId1", Integer), + Column("cardId2", Integer), + Column("cardId3", Integer), + UniqueConstraint("user", "deckId", name="ongeki_user_deck_uk"), + mysql_charset='utf8mb4' +) + +character = Table( + "ongeki_user_character", + metadata, + Column("id", Integer, primary_key=True, nullable=False), + Column("user", ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade")), + Column("characterId", Integer), + Column("costumeId", Integer), + Column("attachmentId", Integer), + Column("playCount", Integer), + Column("intimateLevel", Integer), + Column("intimateCount", Integer), + Column("intimateCountRewarded", Integer), + Column("intimateCountDate", String(25)), + Column("isNew", Boolean), + UniqueConstraint("user", "characterId", name="ongeki_user_character_uk"), + mysql_charset='utf8mb4' +) + +boss = Table ( + "ongeki_user_boss", + metadata, + Column("id", Integer, primary_key=True, nullable=False), + Column("user", ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade")), + Column("musicId", Integer), + Column("damage", Integer), + Column("isClear", Boolean), + Column("eventId", Integer), + UniqueConstraint("user", "musicId", "eventId", name="ongeki_user_boss_uk"), + mysql_charset='utf8mb4' +) + +story = Table ( + "ongeki_user_story", + metadata, + Column("id", Integer, primary_key=True, nullable=False), + Column("user", ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade")), + Column("storyId", Integer), + Column("jewelCount", Integer), + Column("lastChapterId", Integer), + Column("lastPlayMusicId", Integer), + Column("lastPlayMusicCategory", Integer), + Column("lastPlayMusicLevel", Integer), + UniqueConstraint("user", "storyId", name="ongeki_user_story_uk"), + mysql_charset='utf8mb4' +) + +chapter = Table( + "ongeki_user_chapter", + metadata, + Column("id", Integer, primary_key=True, nullable=False), + Column("user", ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade")), + Column("chapterId", Integer), + Column("jewelCount", Integer), + Column("isStoryWatched", Boolean), + Column("isClear", Boolean), + Column("lastPlayMusicId", Integer), + Column("lastPlayMusicCategory", Integer), + Column("lastPlayMusicLevel", Integer), + Column("skipTiming1", Integer), + Column("skipTiming2", Integer), + UniqueConstraint("user", "chapterId", name="ongeki_user_chapter_uk"), + mysql_charset='utf8mb4' +) + +item = Table( + "ongeki_user_item", + metadata, + Column("id", Integer, primary_key=True, nullable=False), + Column("user", ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade")), + Column("itemKind", Integer), + Column("itemId", Integer), + Column("stock", Integer), + Column("isValid", Boolean), + UniqueConstraint("user", "itemKind", "itemId", name="ongeki_user_item_uk"), + mysql_charset='utf8mb4' +) + +music_item = Table( + "ongeki_user_music_item", + metadata, + Column("id", Integer, primary_key=True, nullable=False), + Column("user", ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade")), + Column("musicId", Integer), + Column("status", Integer), + UniqueConstraint("user", "musicId", name="ongeki_user_music_item_uk"), + mysql_charset='utf8mb4' +) + +login_bonus = Table( + "ongeki_user_login_bonus", + metadata, + Column("id", Integer, primary_key=True, nullable=False), + Column("user", ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade")), + Column("bonusId", Integer), + Column("bonusCount", Integer), + Column("lastUpdateDate", String(25)), + UniqueConstraint("user", "bonusId", name="ongeki_user_login_bonus_uk"), + mysql_charset='utf8mb4' +) + +event_point = Table( + "ongeki_user_event_point", + metadata, + Column("id", Integer, primary_key=True, nullable=False), + Column("user", ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade")), + Column("eventId", Integer), + Column("point", Integer), + Column("isRankingRewarded", Boolean), + UniqueConstraint("user", "eventId", name="ongeki_user_event_point_uk"), + mysql_charset='utf8mb4' +) + +mission_point = Table( + "ongeki_user_mission_point", + metadata, + Column("id", Integer, primary_key=True, nullable=False), + Column("user", ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade")), + Column("eventId", Integer), + Column("point", Integer), + UniqueConstraint("user", "eventId", name="ongeki_user_mission_point_uk"), + mysql_charset='utf8mb4' +) + +scenerio = Table( + "ongeki_user_scenerio", + metadata, + Column("id", Integer, primary_key=True, nullable=False), + Column("user", ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade")), + Column("scenarioId", Integer), + Column("playCount", Integer), + UniqueConstraint("user", "scenarioId", name="ongeki_user_scenerio_uk"), + mysql_charset='utf8mb4' +) + +trade_item = Table( + "ongeki_user_trade_item", + metadata, + Column("id", Integer, primary_key=True, nullable=False), + Column("user", ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade")), + Column("chapterId", Integer), + Column("tradeItemId", Integer), + Column("tradeCount", Integer), + UniqueConstraint("user", "chapterId", "tradeItemId", name="ongeki_user_trade_item_uk"), + mysql_charset='utf8mb4' +) + +event_music = Table( + "ongeki_user_event_music", + metadata, + Column("id", Integer, primary_key=True, nullable=False), + Column("user", ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade")), + Column("eventId", Integer), + Column("type", Integer), + Column("musicId", Integer), + Column("level", Integer), + Column("techScoreMax", Integer), + Column("platinumScoreMax", Integer), + Column("techRecordDate", String(25)), + Column("isTechNewRecord", Boolean), + UniqueConstraint("user", "eventId", "type", "musicId", "level", name="ongeki_user_event_music"), + mysql_charset='utf8mb4' +) + +tech_event = Table( + "ongeki_user_tech_event", + metadata, + Column("id", Integer, primary_key=True, nullable=False), + Column("user", ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade")), + Column("eventId", Integer), + Column("totalTechScore", Integer), + Column("totalPlatinumScore", Integer), + Column("techRecordDate", String(25)), + Column("isRankingRewarded", Boolean), + Column("isTotalTechNewRecord", Boolean), + UniqueConstraint("user", "eventId", name="ongeki_user_tech_event_uk"), + mysql_charset='utf8mb4' +) + + +class OngekiItemData(BaseData): + def put_card(self, aime_id: int, card_data: Dict) -> Optional[int]: + card_data["user"] = aime_id + + sql = insert(card).values(**card_data) + conflict = sql.on_duplicate_key_update(**card_data) + result = self.execute(conflict) + + if result is None: + self.logger.warn(f"put_card: Failed to update! aime_id: {aime_id}") + return None + return result.lastrowid + + def get_cards(self, aime_id: int) -> Optional[List[Dict]]: + sql = select(card).where(card.c.user == aime_id) + + result = self.execute(sql) + if result is None: return None + return result.fetchall() + + def put_character(self, aime_id: int, character_data: Dict) -> Optional[int]: + character_data["user"] = aime_id + + sql = insert(character).values(**character_data) + conflict = sql.on_duplicate_key_update(**character_data) + result = self.execute(conflict) + + if result is None: + self.logger.warn(f"put_character: Failed to update! aime_id: {aime_id}") + return None + return result.lastrowid + + def get_characters(self, aime_id: int) -> Optional[List[Dict]]: + sql = select(character).where(character.c.user == aime_id) + + result = self.execute(sql) + if result is None: return None + return result.fetchall() + + def put_deck(self, aime_id: int, deck_data: Dict) -> Optional[int]: + deck_data["user"] = aime_id + + sql = insert(deck).values(**deck_data) + conflict = sql.on_duplicate_key_update(**deck_data) + result = self.execute(conflict) + + if result is None: + self.logger.warn(f"put_deck: Failed to update! aime_id: {aime_id}") + return None + return result.lastrowid + + def get_deck(self, aime_id: int, deck_id: int) -> Optional[Dict]: + sql = select(deck).where(and_(deck.c.user == aime_id, deck.c.deckId == deck_id)) + + result = self.execute(sql) + if result is None: return None + return result.fetchone() + + def get_decks(self, aime_id: int) -> Optional[List[Dict]]: + sql = select(deck).where(deck.c.user == aime_id) + + result = self.execute(sql) + if result is None: return None + return result.fetchall() + + def put_boss(self, aime_id: int, boss_data: Dict) -> Optional[int]: + boss_data["user"] = aime_id + + sql = insert(boss).values(**boss_data) + conflict = sql.on_duplicate_key_update(**boss_data) + result = self.execute(conflict) + + if result is None: + self.logger.warn(f"put_boss: Failed to update! aime_id: {aime_id}") + return None + return result.lastrowid + + def put_story(self, aime_id: int, story_data: Dict) -> Optional[int]: + story_data["user"] = aime_id + + sql = insert(story).values(**story_data) + conflict = sql.on_duplicate_key_update(**story_data) + result = self.execute(conflict) + + if result is None: + self.logger.warn(f"put_story: Failed to update! aime_id: {aime_id}") + return None + return result.lastrowid + + def get_stories(self, aime_id: int) -> Optional[List[Dict]]: + sql = select(story).where(story.c.user == aime_id) + + result = self.execute(sql) + if result is None: return None + return result.fetchall() + + def put_chapter(self, aime_id: int, chapter_data: Dict) -> Optional[int]: + chapter_data["user"] = aime_id + + sql = insert(chapter).values(**chapter_data) + conflict = sql.on_duplicate_key_update(**chapter_data) + result = self.execute(conflict) + + if result is None: + self.logger.warn(f"put_chapter: Failed to update! aime_id: {aime_id}") + return None + return result.lastrowid + + def get_chapters(self, aime_id: int) -> Optional[List[Dict]]: + sql = select(chapter).where(chapter.c.user == aime_id) + + result = self.execute(sql) + if result is None: return None + return result.fetchall() + + def put_item(self, aime_id: int, item_data: Dict) -> Optional[int]: + item_data["user"] = aime_id + + sql = insert(item).values(**item_data) + conflict = sql.on_duplicate_key_update(**item_data) + result = self.execute(conflict) + + if result is None: + self.logger.warn(f"put_item: Failed to update! aime_id: {aime_id}") + return None + return result.lastrowid + + def get_item(self, aime_id: int, item_id: int, item_kind: int) -> Optional[Dict]: + sql = select(item).where(and_(item.c.user == aime_id, item.c.itemId == item_id)) + + result = self.execute(sql) + if result is None: return None + return result.fetchone() + + def get_items(self, aime_id: int, item_kind: int = None) -> Optional[List[Dict]]: + if item_kind is None: + sql = select(item).where(item.c.user == aime_id) + else: + sql = select(item).where(and_(item.c.user == aime_id, item.c.itemKind == item_kind)) + + result = self.execute(sql) + if result is None: return None + return result.fetchall() + + def put_music_item(self, aime_id: int, music_item_data: Dict) -> Optional[int]: + music_item_data["user"] = aime_id + + sql = insert(music_item).values(**music_item_data) + conflict = sql.on_duplicate_key_update(**music_item_data) + result = self.execute(conflict) + + if result is None: + self.logger.warn(f"put_music_item: Failed to update! aime_id: {aime_id}") + return None + return result.lastrowid + + def get_music_items(self, aime_id: int) -> Optional[List[Dict]]: + sql = select(music_item).where(music_item.c.user == aime_id) + result = self.execute(sql) + + if result is None: return None + return result.fetchall() + + def put_login_bonus(self, aime_id: int, login_bonus_data: Dict) -> Optional[int]: + login_bonus_data["user"] = aime_id + + sql = insert(login_bonus).values(**login_bonus_data) + conflict = sql.on_duplicate_key_update(**login_bonus_data) + result = self.execute(conflict) + + if result is None: + self.logger.warn(f"put_login_bonus: Failed to update! aime_id: {aime_id}") + return None + return result.lastrowid + + def get_login_bonuses(self, aime_id: int) -> Optional[List[Dict]]: + sql = select(login_bonus).where(login_bonus.c.user == aime_id) + result = self.execute(sql) + + if result is None: return None + return result.fetchall() + + def put_mission_point(self, aime_id: int, mission_point_data: Dict) -> Optional[int]: + mission_point_data["user"] = aime_id + + sql = insert(mission_point).values(**mission_point_data) + conflict = sql.on_duplicate_key_update(**mission_point_data) + result = self.execute(conflict) + + if result is None: + self.logger.warn(f"put_mission_point: Failed to update! aime_id: {aime_id}") + return None + return result.lastrowid + + def get_mission_points(self, aime_id: int) -> Optional[List[Dict]]: + sql = select(mission_point).where(mission_point.c.user == aime_id) + result = self.execute(sql) + + if result is None: return None + return result.fetchall() + + def put_event_point(self, aime_id: int, event_point_data: Dict) -> Optional[int]: + event_point_data["user"] = aime_id + + sql = insert(event_point).values(**event_point_data) + conflict = sql.on_duplicate_key_update(**event_point_data) + result = self.execute(conflict) + + if result is None: + self.logger.warn(f"put_event_point: Failed to update! aime_id: {aime_id}") + return None + return result.lastrowid + + def get_event_points(self, aime_id: int) -> Optional[List[Dict]]: + sql = select(event_point).where(event_point.c.user == aime_id) + result = self.execute(sql) + + if result is None: return None + return result.fetchall() + + def put_scenerio(self, aime_id: int, scenerio_data: Dict) -> Optional[int]: + scenerio_data["user"] = aime_id + + sql = insert(scenerio).values(**scenerio_data) + conflict = sql.on_duplicate_key_update(**scenerio_data) + result = self.execute(conflict) + + if result is None: + self.logger.warn(f"put_scenerio: Failed to update! aime_id: {aime_id}") + return None + return result.lastrowid + + def get_scenerios(self, aime_id: int) -> Optional[List[Dict]]: + sql = select(scenerio).where(scenerio.c.user == aime_id) + result = self.execute(sql) + + if result is None: return None + return result.fetchall() + + def put_trade_item(self, aime_id: int, trade_item_data: Dict) -> Optional[int]: + trade_item_data["user"] = aime_id + + sql = insert(trade_item).values(**trade_item_data) + conflict = sql.on_duplicate_key_update(**trade_item_data) + result = self.execute(conflict) + + if result is None: + self.logger.warn(f"put_trade_item: Failed to update! aime_id: {aime_id}") + return None + return result.lastrowid + + def get_trade_items(self, aime_id: int) -> Optional[List[Dict]]: + sql = select(trade_item).where(trade_item.c.user == aime_id) + result = self.execute(sql) + + if result is None: return None + return result.fetchall() + + def put_event_music(self, aime_id: int, event_music_data: Dict) -> Optional[int]: + event_music_data["user"] = aime_id + + sql = insert(event_music).values(**event_music_data) + conflict = sql.on_duplicate_key_update(**event_music_data) + result = self.execute(conflict) + + if result is None: + self.logger.warn(f"put_event_music: Failed to update! aime_id: {aime_id}") + return None + return result.lastrowid + + def get_event_music(self, aime_id: int) -> Optional[List[Dict]]: + sql = select(event_music).where(event_music.c.user == aime_id) + result = self.execute(sql) + + if result is None: return None + return result.fetchall() + + def put_tech_event(self, aime_id: int, tech_event_data: Dict) -> Optional[int]: + tech_event_data["user"] = aime_id + + sql = insert(tech_event).values(**tech_event_data) + conflict = sql.on_duplicate_key_update(**tech_event_data) + result = self.execute(conflict) + + if result is None: + self.logger.warn(f"put_tech_event: Failed to update! aime_id: {aime_id}") + return None + return result.lastrowid + + def get_tech_event(self, aime_id: int) -> Optional[List[Dict]]: + sql = select(tech_event).where(tech_event.c.user == aime_id) + result = self.execute(sql) + + if result is None: return None + return result.fetchall() + + def get_bosses(self, aime_id: int) -> Optional[List[Dict]]: + sql = select(boss).where(boss.c.user == aime_id) + result = self.execute(sql) + + if result is None: return None + return result.fetchall() \ No newline at end of file diff --git a/titles/ongeki/schema/log.py b/titles/ongeki/schema/log.py new file mode 100644 index 0000000..67ed778 --- /dev/null +++ b/titles/ongeki/schema/log.py @@ -0,0 +1,55 @@ +from typing import Dict, Optional +from sqlalchemy import Table, Column, UniqueConstraint, PrimaryKeyConstraint, and_ +from sqlalchemy.types import Integer, String, TIMESTAMP, Boolean, JSON +from sqlalchemy.schema import ForeignKey +from sqlalchemy.sql import func, select +from sqlalchemy.dialects.mysql import insert + +from core.data.schema import BaseData, metadata + +gp_log = Table( + "ongeki_gp_log", + metadata, + Column("id", Integer, primary_key=True, nullable=False), + Column("user", ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade")), + Column("usedCredit", Integer), + Column("placeName", String(255)), + Column("trxnDate", String(255)), + Column("placeId", Integer), # Making this an FK would mess with people playing with default KC + Column("kind", Integer), + Column("pattern", Integer), + Column("currentGP", Integer), + mysql_charset='utf8mb4' +) + +session_log = Table( + "ongeki_session_log", + metadata, + Column("id", Integer, primary_key=True, nullable=False), + Column("user", ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade")), + Column("sortNumber", Integer), + Column("placeId", Integer), + Column("playDate", String(10)), + Column("userPlayDate", String(25)), + Column("isPaid", Boolean), + mysql_charset='utf8mb4' +) + +class OngekiLogData(BaseData): + def put_gp_log(self, aime_id: Optional[int], used_credit: int, place_name: str, tx_date: str, place_id: int, + kind: int, pattern: int, current_gp: int) -> Optional[int]: + sql = insert(gp_log).values( + user=aime_id, + usedCredit=used_credit, + placeName=place_name, + trxnDate=tx_date, + placeId=place_id, + kind=kind, + pattern=pattern, + currentGP=current_gp, + ) + + result = self.execute(sql) + if result is None: + self.logger.warn(f"put_gp_log: Failed to insert GP log! aime_id: {aime_id} kind {kind} pattern {pattern} current_gp {current_gp}") + return result.lastrowid \ No newline at end of file diff --git a/titles/ongeki/schema/profile.py b/titles/ongeki/schema/profile.py new file mode 100644 index 0000000..bdff67d --- /dev/null +++ b/titles/ongeki/schema/profile.py @@ -0,0 +1,447 @@ +from typing import Dict, List, Optional +from sqlalchemy import Table, Column, UniqueConstraint, PrimaryKeyConstraint, and_ +from sqlalchemy.types import Integer, String, TIMESTAMP, Boolean, JSON, BigInteger +from sqlalchemy.engine.base import Connection +from sqlalchemy.schema import ForeignKey +from sqlalchemy.sql import func, select +from sqlalchemy.engine import Row +from sqlalchemy.dialects.mysql import insert + +from core.data.schema import BaseData, metadata +from core.config import CoreConfig + +# Cammel case column names technically don't follow the other games but +# it makes it way easier on me to not fuck with what the games has +profile = Table( + "ongeki_profile_data", + metadata, + Column("id", Integer, primary_key=True, nullable=False), + Column("user", ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade"), nullable=False), + Column("version", Integer, nullable=False), + Column("userName", String(8)), + Column("level", Integer), + Column("reincarnationNum", Integer), + Column("exp", Integer), + Column("point", Integer), + Column("totalPoint", Integer), + Column("playCount", Integer), + Column("jewelCount", Integer), + Column("totalJewelCount", Integer), + Column("medalCount", Integer), + Column("playerRating", Integer), + Column("highestRating", Integer), + Column("battlePoint", Integer), + Column("nameplateId", Integer), + Column("trophyId", Integer), + Column("cardId", Integer), + Column("characterId", Integer), + Column("characterVoiceNo", Integer), + Column("tabSetting", Integer), + Column("tabSortSetting", Integer), + Column("cardCategorySetting", Integer), + Column("cardSortSetting", Integer), + Column("playedTutorialBit", Integer), + Column("firstTutorialCancelNum", Integer), + Column("sumTechHighScore", BigInteger), + Column("sumTechBasicHighScore", BigInteger), + Column("sumTechAdvancedHighScore", BigInteger), + Column("sumTechExpertHighScore", BigInteger), + Column("sumTechMasterHighScore", BigInteger), + Column("sumTechLunaticHighScore", BigInteger), + Column("sumBattleHighScore", BigInteger), + Column("sumBattleBasicHighScore", BigInteger), + Column("sumBattleAdvancedHighScore", BigInteger), + Column("sumBattleExpertHighScore", BigInteger), + Column("sumBattleMasterHighScore", BigInteger), + Column("sumBattleLunaticHighScore", BigInteger), + Column("eventWatchedDate", String(255)), + Column("cmEventWatchedDate", String(255)), + Column("firstGameId", String(8)), + Column("firstRomVersion", String(8)), + Column("firstDataVersion", String(8)), + Column("firstPlayDate", String(255)), + Column("lastGameId", String(8)), + Column("lastRomVersion", String(8)), + Column("lastDataVersion", String(8)), + Column("compatibleCmVersion", String(8)), + Column("lastPlayDate", String(255)), + Column("lastPlaceId", Integer), + Column("lastPlaceName", String(255)), + Column("lastRegionId", Integer), + Column("lastRegionName", String(255)), + Column("lastAllNetId", Integer), + Column("lastClientId", String(16)), + Column("lastUsedDeckId", Integer), + Column("lastPlayMusicLevel", Integer), + Column("banStatus", Integer, server_default="0"), + Column("rivalScoreCategorySetting", Integer, server_default="0"), + Column("overDamageBattlePoint", Integer, server_default="0"), + Column("bestBattlePoint", Integer, server_default="0"), + Column("lastEmoneyBrand", Integer, server_default="0"), + UniqueConstraint("user", "version", name="ongeki_profile_profile_uk"), + mysql_charset='utf8mb4' +) + +# No point setting defaults since the game sends everything on profile creation anyway +option = Table( + "ongeki_profile_option", + metadata, + Column("id", Integer, primary_key=True, nullable=False), + Column("user", ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade"), nullable=False), + Column("optionSet", Integer), + Column("speed", Integer), + Column("mirror", Integer), + Column("judgeTiming", Integer), + Column("judgeAdjustment", Integer), + Column("abort", Integer), + Column("tapSound", Integer), + Column("volGuide", Integer), + Column("volAll", Integer), + Column("volTap", Integer), + Column("volCrTap", Integer), + Column("volHold", Integer), + Column("volSide", Integer), + Column("volFlick", Integer), + Column("volBell", Integer), + Column("volEnemy", Integer), + Column("volSkill", Integer), + Column("volDamage", Integer), + Column("colorField", Integer), + Column("colorLaneBright", Integer), + Column("colorLane", Integer), + Column("colorSide", Integer), + Column("effectDamage", Integer), + Column("effectPos", Integer), + Column("judgeDisp", Integer), + Column("judgePos", Integer), + Column("judgeBreak", Integer), + Column("judgeHit", Integer), + Column("platinumBreakDisp", Integer), + Column("judgeCriticalBreak", Integer), + Column("matching", Integer), + Column("dispPlayerLv", Integer), + Column("dispRating", Integer), + Column("dispBP", Integer), + Column("headphone", Integer), + Column("stealthField", Integer), + Column("colorWallBright", Integer), + UniqueConstraint("user", name="ongeki_profile_option_uk"), + mysql_charset='utf8mb4' +) + +activity = Table( + "ongeki_profile_activity", + metadata, + Column("id", Integer, primary_key=True, nullable=False), + Column("user", ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade"), nullable=False), + Column("kind", Integer), + Column("activityId", Integer), + Column("sortNumber", Integer), + Column("param1", Integer), + Column("param2", Integer), + Column("param3", Integer), + Column("param4", Integer), + UniqueConstraint("user", "kind", "activityId", name="ongeki_profile_activity_uk"), + mysql_charset='utf8mb4' +) + +recent_rating = Table( + "ongeki_profile_recent_rating", + metadata, + Column("id", Integer, primary_key=True, nullable=False), + Column("user", ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade"), nullable=False), + Column("recentRating", JSON), + UniqueConstraint("user", name="ongeki_profile_recent_rating_uk"), + mysql_charset='utf8mb4' +) + +rating_log = Table( + "ongeki_profile_rating_log", + metadata, + Column("id", Integer, primary_key=True, nullable=False), + Column("user", ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade"), nullable=False), + Column("highestRating", Integer), + Column("dataVersion", String(10)), + UniqueConstraint("user", "dataVersion", name="ongeki_profile_rating_log_uk"), + mysql_charset='utf8mb4' +) + +region = Table( + "ongeki_profile_region", + metadata, + Column("id", Integer, primary_key=True, nullable=False), + Column("user", ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade"), nullable=False), + Column("regionId", Integer), + Column("playCount", Integer), + Column("created", String(25)), + UniqueConstraint("user", "regionId", name="ongeki_profile_region_uk"), + mysql_charset='utf8mb4' +) + +training_room = Table ( + "ongeki_profile_training_room", + metadata, + Column("id", Integer, primary_key=True, nullable=False), + Column("user", ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade")), + Column("roomId", Integer), + Column("authKey", Integer), + Column("cardId", Integer), + Column("valueDate", String(25)), + UniqueConstraint("user", "roomId", name="ongeki_profile_training_room_uk"), + mysql_charset='utf8mb4' +) + +kop = Table ( + "ongeki_profile_kop", + metadata, + Column("id", Integer, primary_key=True, nullable=False), + Column("user", ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade")), + Column("authKey", Integer), + Column("kopId", Integer), + Column("areaId", Integer), + Column("totalTechScore", Integer), + Column("totalPlatinumScore", Integer), + Column("techRecordDate", String(25)), + Column("isTotalTechNewRecord", Boolean), + UniqueConstraint("user", "kopId", name="ongeki_profile_kop_uk"), + mysql_charset='utf8mb4' +) + +rival = Table( + "ongeki_profile_rival", + metadata, + Column("id", Integer, primary_key=True, nullable=False), + Column("user", ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade")), + Column("rivalUserId", ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade")), + UniqueConstraint("user", "rivalUserId", name="ongeki_profile_rival_uk"), + mysql_charset='utf8mb4' +) + +class OngekiProfileData(BaseData): + def __init__(self, cfg: CoreConfig, conn: Connection) -> None: + super().__init__(cfg, conn) + self.date_time_format_ext = "%Y-%m-%d %H:%M:%S.%f" # needs to be lopped off at [:-5] + self.date_time_format_short = "%Y-%m-%d" + + def get_profile_name(self, aime_id: int, version: int) -> Optional[str]: + sql = select(profile.c.userName).where(and_(profile.c.user == aime_id, profile.c.version == version)) + + result = self.execute(sql) + if result is None: return None + + row = result.fetchone() + if row is None: return None + + return row["userName"] + + def get_profile_preview(self, aime_id: int, version: int) -> Optional[Row]: + sql = select([profile, option]).join(option, profile.c.user == option.c.user).filter( + and_(profile.c.user == aime_id, profile.c.version == version) + ) + + result = self.execute(sql) + if result is None: return None + return result.fetchone() + + def get_profile_data(self, aime_id: int, version: int) -> Optional[Row]: + sql = select(profile).where(and_( + profile.c.user == aime_id, + profile.c.version == version, + )) + + result = self.execute(sql) + if result is None: return None + return result.fetchone() + + def get_profile_options(self, aime_id: int) -> Optional[Row]: + sql = select(option).where(and_( + option.c.user == aime_id, + )) + + result = self.execute(sql) + if result is None: return None + return result.fetchone() + + def get_profile_recent_rating(self, aime_id: int) -> Optional[List[Row]]: + sql = select(recent_rating).where(recent_rating.c.user == aime_id) + + result = self.execute(sql) + if result is None: return None + return result.fetchone() + + def get_profile_rating_log(self, aime_id: int) -> Optional[List[Row]]: + sql = select(rating_log).where(recent_rating.c.user == aime_id) + + result = self.execute(sql) + if result is None: return None + return result.fetchall() + + def get_profile_activity(self, aime_id: int, kind: int = None) -> Optional[List[Row]]: + sql = select(activity).where(and_( + activity.c.user == aime_id, + (activity.c.kind == kind) if kind is not None else True + )) + + result = self.execute(sql) + if result is None: return None + return result.fetchall() + + def get_kop(self, aime_id: int) -> Optional[List[Row]]: + sql = select(kop).where(kop.c.user == aime_id) + + result = self.execute(sql) + if result is None: return None + return result.fetchall() + + def get_rivals(self, aime_id: int) -> Optional[List[Row]]: + sql = select(rival.c.rivalUserId).where(rival.c.user == aime_id) + + result = self.execute(sql) + if result is None: + return None + return result.fetchall() + + def put_profile_data(self, aime_id: int, version: int, data: Dict) -> Optional[int]: + data["user"] = aime_id + data["version"] = version + data.pop("accessCode") + + sql = insert(profile).values(**data) + conflict = sql.on_duplicate_key_update(**data) + result = self.execute(conflict) + + if result is None: + self.logger.warn(f"put_profile_data: Failed to update! aime_id: {aime_id}") + return None + return result.lastrowid + + def put_profile_options(self, aime_id: int, options_data: Dict) -> Optional[int]: + options_data["user"] = aime_id + + sql = insert(option).values(**options_data) + conflict = sql.on_duplicate_key_update(**options_data) + result = self.execute(conflict) + + if result is None: + self.logger.warn(f"put_profile_options: Failed to update! aime_id: {aime_id}") + return None + return result.lastrowid + + def put_profile_recent_rating(self, aime_id: int, recent_rating_data: List[Dict]) -> Optional[int]: + sql = insert(recent_rating).values( + user=aime_id, + recentRating=recent_rating_data + ) + + conflict = sql.on_duplicate_key_update( + recentRating=recent_rating_data + ) + + result = self.execute(conflict) + if result is None: + self.logger.warn(f"put_profile_recent_rating: failed to update recent rating! aime_id {aime_id}") + return None + return result.lastrowid + + def put_profile_bp_list(self, aime_id: int, bp_base_list: List[Dict]) -> Optional[int]: + pass + + def put_profile_rating_log(self, aime_id: int, data_version: str, highest_rating: int) -> Optional[int]: + sql = insert(rating_log).values( + user=aime_id, + dataVersion=data_version, + highestRating=highest_rating + ) + + conflict = sql.on_duplicate_key_update( + highestRating=highest_rating + ) + + result = self.execute(conflict) + if result is None: + self.logger.warn(f"put_profile_rating_log: failed to update rating log! aime_id {aime_id} data_version {data_version} highest_rating {highest_rating}") + return None + return result.lastrowid + + def put_profile_activity(self, aime_id: int, kind: int, activity_id: int, sort_num: int, + p1: int, p2: int, p3: int, p4: int) -> Optional[int]: + sql = insert(activity).values( + user=aime_id, + kind=kind, + activityId=activity_id, + sortNumber=sort_num, + param1=p1, + param2=p2, + param3=p3, + param4=p4 + ) + + conflict = sql.on_duplicate_key_update( + sortNumber=sort_num, + param1=p1, + param2=p2, + param3=p3, + param4=p4 + ) + + result = self.execute(conflict) + if result is None: + self.logger.warn(f"put_profile_activity: failed to put activity! aime_id {aime_id} kind {kind} activity_id {activity_id}") + return None + return result.lastrowid + + def put_profile_region(self, aime_id: int, region: int, date: str) -> Optional[int]: + sql = insert(activity).values( + user=aime_id, + region=region, + playCount=1, + created=date + ) + + conflict = sql.on_duplicate_key_update( + playCount=activity.c.playCount + 1, + ) + + result = self.execute(conflict) + if result is None: + self.logger.warn(f"put_profile_region: failed to update! aime_id {aime_id} region {region}") + return None + return result.lastrowid + + def put_training_room(self, aime_id: int, room_detail: Dict) -> Optional[int]: + room_detail["user"] = aime_id + + sql = insert(training_room).values(**room_detail) + conflict = sql.on_duplicate_key_update(**room_detail) + result = self.execute(conflict) + + if result is None: + self.logger.warn(f"put_best_score: Failed to add score! aime_id: {aime_id}") + return None + return result.lastrowid + + def put_kop(self, aime_id: int, kop_data: Dict) -> Optional[int]: + kop_data["user"] = aime_id + + sql = insert(kop).values(**kop_data) + conflict = sql.on_duplicate_key_update(**kop_data) + result = self.execute(conflict) + + if result is None: + self.logger.warn(f"put_kop: Failed to add score! aime_id: {aime_id}") + return None + return result.lastrowid + + def put_rival(self, aime_id: int, rival_id: int) -> Optional[int]: + sql = insert(rival).values( + user = aime_id, + rivalUserId = rival_id + ) + + conflict = sql.on_duplicate_key_update(rival = rival_id) + + result = self.execute(conflict) + if result is None: + self.logger.warn(f"put_rival: failed to update! aime_id: {aime_id}, rival_id: {rival_id}") + return None + return result.lastrowid diff --git a/titles/ongeki/schema/score.py b/titles/ongeki/schema/score.py new file mode 100644 index 0000000..08a6a86 --- /dev/null +++ b/titles/ongeki/schema/score.py @@ -0,0 +1,161 @@ +from typing import Dict, List, Optional +from sqlalchemy import Table, Column, UniqueConstraint, PrimaryKeyConstraint, and_ +from sqlalchemy.types import Integer, String, TIMESTAMP, Boolean, JSON, Float +from sqlalchemy.schema import ForeignKey +from sqlalchemy.sql import func, select +from sqlalchemy.dialects.mysql import insert + +from core.data.schema import BaseData, metadata + +score_best = Table( + "ongeki_score_best", + metadata, + Column("id", Integer, primary_key=True, nullable=False), + Column("user", ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade"), nullable=False), + Column("musicId", Integer, nullable=False), + Column("level", Integer, nullable=False), + Column("playCount", Integer, nullable=False), + Column("techScoreMax", Integer, nullable=False), + Column("techScoreRank", Integer, nullable=False), + Column("battleScoreMax", Integer, nullable=False), + Column("battleScoreRank", Integer, nullable=False), + Column("maxComboCount", Integer, nullable=False), + Column("maxOverKill", Float, nullable=False), + Column("maxTeamOverKill", Float, nullable=False), + Column("isFullBell", Boolean, nullable=False), + Column("isFullCombo", Boolean, nullable=False), + Column("isAllBreake", Boolean, nullable=False), + Column("isLock", Boolean, nullable=False), + Column("clearStatus", Boolean, nullable=False), + Column("isStoryWatched", Boolean, nullable=False), + UniqueConstraint("user", "musicId", "level", name="ongeki_best_score_uk"), + mysql_charset='utf8mb4' +) + +playlog = Table( + "ongeki_score_playlog", + metadata, + Column("id", Integer, primary_key=True, nullable=False), + Column("user", ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade"), nullable=False), + Column("sortNumber", Integer), + Column("placeId", Integer), + Column("placeName", String(255)), + Column("playDate", TIMESTAMP), + Column("userPlayDate", TIMESTAMP), + Column("musicId", Integer), + Column("level", Integer), + Column("playKind", Integer), + Column("eventId", Integer), + Column("eventName", String(255)), + Column("eventPoint", Integer), + Column("playedUserId1", Integer), + Column("playedUserId2", Integer), + Column("playedUserId3", Integer), + Column("playedUserName1", String(8)), + Column("playedUserName2", String(8)), + Column("playedUserName3", String(8)), + Column("playedMusicLevel1", Integer), + Column("playedMusicLevel2", Integer), + Column("playedMusicLevel3", Integer), + Column("cardId1", Integer), + Column("cardId2", Integer), + Column("cardId3", Integer), + Column("cardLevel1", Integer), + Column("cardLevel2", Integer), + Column("cardLevel3", Integer), + Column("cardAttack1", Integer), + Column("cardAttack2", Integer), + Column("cardAttack3", Integer), + Column("bossCharaId", Integer), + Column("bossLevel", Integer), + Column("bossAttribute", Integer), + Column("clearStatus", Integer), + Column("techScore", Integer), + Column("techScoreRank", Integer), + Column("battleScore", Integer), + Column("battleScoreRank", Integer), + Column("maxCombo", Integer), + Column("judgeMiss", Integer), + Column("judgeHit", Integer), + Column("judgeBreak", Integer), + Column("judgeCriticalBreak", Integer), + Column("rateTap", Integer), + Column("rateHold", Integer), + Column("rateFlick", Integer), + Column("rateSideTap", Integer), + Column("rateSideHold", Integer), + Column("bellCount", Integer), + Column("totalBellCount", Integer), + Column("damageCount", Integer), + Column("overDamage", Integer), + Column("isTechNewRecord", Boolean), + Column("isBattleNewRecord", Boolean), + Column("isOverDamageNewRecord", Boolean), + Column("isFullCombo", Boolean), + Column("isFullBell", Boolean), + Column("isAllBreak", Boolean), + Column("playerRating", Integer), + Column("battlePoint", Integer), + mysql_charset='utf8mb4' +) + +tech_count = Table( + "ongeki_score_tech_count", + metadata, + Column("id", Integer, primary_key=True, nullable=False), + Column("user", ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade"), nullable=False), + Column("levelId", Integer, nullable=False), + Column("allBreakCount", Integer), + Column("allBreakPlusCount", Integer), + UniqueConstraint("user", "levelId", name="ongeki_tech_count_uk"), + mysql_charset='utf8mb4' +) + +class OngekiScoreData(BaseData): + def get_tech_count(self, aime_id: int) -> Optional[List[Dict]]: + return [] + + def put_tech_count(self, aime_id: int, tech_count_data: Dict) -> Optional[int]: + tech_count_data["user"] = aime_id + + sql = insert(tech_count).values(**tech_count_data) + conflict = sql.on_duplicate_key_update(**tech_count_data) + result = self.execute(conflict) + + if result is None: + self.logger.warn(f"put_tech_count: Failed to update! aime_id: {aime_id}") + return None + return result.lastrowid + + def get_best_scores(self, aime_id: int) -> Optional[List[Dict]]: + sql = select(score_best).where(score_best.c.user == aime_id) + + result = self.execute(sql) + if result is None: return None + return result.fetchall() + + def get_best_score(self, aime_id: int, song_id: int, chart_id: int = None) -> Optional[List[Dict]]: + return [] + + def put_best_score(self, aime_id: int, music_detail: Dict) -> Optional[int]: + music_detail["user"] = aime_id + + sql = insert(score_best).values(**music_detail) + conflict = sql.on_duplicate_key_update(**music_detail) + result = self.execute(conflict) + + if result is None: + self.logger.warn(f"put_best_score: Failed to add score! aime_id: {aime_id}") + return None + return result.lastrowid + + def put_playlog(self, aime_id: int, playlog_data: Dict) -> Optional[int]: + playlog_data["user"] = aime_id + + sql = insert(playlog).values(**playlog_data) + + result = self.execute(sql) + if result is None: + self.logger.warn(f"put_playlog: Failed to add playlog! aime_id: {aime_id}") + return None + return result.lastrowid \ No newline at end of file diff --git a/titles/ongeki/schema/static.py b/titles/ongeki/schema/static.py new file mode 100644 index 0000000..e98ec58 --- /dev/null +++ b/titles/ongeki/schema/static.py @@ -0,0 +1,119 @@ +from typing import Dict, List, Optional +from sqlalchemy import Table, Column, UniqueConstraint, PrimaryKeyConstraint, and_ +from sqlalchemy.types import Integer, String, TIMESTAMP, Boolean, JSON, Float +from sqlalchemy.schema import ForeignKey +from sqlalchemy.sql import func, select +from sqlalchemy.engine import Row +from sqlalchemy.dialects.mysql import insert + +from core.data.schema import BaseData, metadata + +events = Table( + "ongeki_static_events", + metadata, + Column("id", Integer, primary_key=True, nullable=False), + Column("version", Integer), + Column("eventId", Integer), + Column("type", Integer), + Column("name", String(255)), + Column("enabled", Boolean, server_default="1"), + UniqueConstraint("version", "eventId", "type", name="ongeki_static_events_uk"), + mysql_charset='utf8mb4' +) + + +music = Table( + "ongeki_static_music", + metadata, + Column("id", Integer, primary_key=True, nullable=False), + Column("version", Integer), + Column("songId", Integer), + Column("chartId", Integer), + Column("title", String(255)), + Column("artist", String(255)), + Column("genre", String(255)), + Column("level", Float), + UniqueConstraint("version", "songId", "chartId", name="ongeki_static_music_uk"), + mysql_charset='utf8mb4' +) + +class OngekiStaticData(BaseData): + def put_event(self, version: int, event_id: int, event_type: int, event_name: str) -> Optional[int]: + sql = insert(events).values( + version = version, + eventId = event_id, + type = event_type, + name = event_name, + ) + + conflict = sql.on_duplicate_key_update( + name = event_name, + ) + + result = self.execute(conflict) + if result is None: + self.logger.warn(f"Failed to insert event! event_id {event_id}") + return None + return result.lastrowid + + def get_event(self, version: int, event_id: int) -> Optional[List[Dict]]: + sql = select(events).where(and_(events.c.version == version, events.c.eventId == event_id)) + + result = self.execute(sql) + if result is None: return None + return result.fetchall() + + def get_events(self, version: int) -> Optional[List[Dict]]: + sql = select(events).where(events.c.version == version) + + result = self.execute(sql) + if result is None: return None + return result.fetchall() + + def get_enabled_events(self, version: int) -> Optional[List[Dict]]: + sql = select(events).where(and_(events.c.version == version, events.c.enabled == True)) + + result = self.execute(sql) + if result is None: return None + return result.fetchall() + + def put_chart(self, version: int, song_id: int, chart_id: int, title: str, artist: str, genre: str, level: float) -> Optional[int]: + sql = insert(music).values( + version = version, + songId = song_id, + chartId = chart_id, + title = title, + artist = artist, + genre = genre, + level = level, + ) + + conflict = sql.on_duplicate_key_update( + title = title, + artist = artist, + genre = genre, + level = level, + ) + + result = self.execute(conflict) + if result is None: + self.logger.warn(f"Failed to insert chart! song_id: {song_id}, chart_id: {chart_id}") + return None + return result.lastrowid + + def get_chart(self, version: int, song_id: int, chart_id: int = None) -> Optional[List[Dict]]: + pass + + def get_music(self, version: int) -> Optional[List[Dict]]: + pass + + def get_music_chart(self, version: int, song_id: int, chart_id: int) -> Optional[List[Row]]: + sql = select(music).where(and_( + music.c.version == version, + music.c.songId == song_id, + music.c.chartId == chart_id + )) + + result = self.execute(sql) + if result is None: return None + return result.fetchone() diff --git a/titles/ongeki/summer.py b/titles/ongeki/summer.py new file mode 100644 index 0000000..24ed290 --- /dev/null +++ b/titles/ongeki/summer.py @@ -0,0 +1,17 @@ +from typing import Dict, Any + +from core.config import CoreConfig +from titles.ongeki.base import OngekiBase +from titles.ongeki.const import OngekiConstants +from titles.ongeki.config import OngekiConfig + +class OngekiSummer(OngekiBase): + def __init__(self, core_cfg: CoreConfig, game_cfg: OngekiConfig) -> None: + super().__init__(core_cfg, game_cfg) + self.version = OngekiConstants.VER_ONGEKI_SUMMER + + def handle_get_game_setting_api_request(self, data: Dict) -> Dict: + ret = super().handle_get_game_setting_api_request(data) + ret["gameSetting"]["dataVersion"] = "1.10.00" + ret["gameSetting"]["onlineDataVersion"] = "1.10.00" + return ret diff --git a/titles/ongeki/summerplus.py b/titles/ongeki/summerplus.py new file mode 100644 index 0000000..188e618 --- /dev/null +++ b/titles/ongeki/summerplus.py @@ -0,0 +1,17 @@ +from typing import Dict, Any + +from core.config import CoreConfig +from titles.ongeki.base import OngekiBase +from titles.ongeki.const import OngekiConstants +from titles.ongeki.config import OngekiConfig + +class OngekiSummerPlus(OngekiBase): + def __init__(self, core_cfg: CoreConfig, game_cfg: OngekiConfig) -> None: + super().__init__(core_cfg, game_cfg) + self.version = OngekiConstants.VER_ONGEKI_SUMMER_PLUS + + def handle_get_game_setting_api_request(self, data: Dict) -> Dict: + ret = super().handle_get_game_setting_api_request(data) + ret["gameSetting"]["dataVersion"] = "1.15.00" + ret["gameSetting"]["onlineDataVersion"] = "1.15.00" + return ret diff --git a/titles/wacca/__init__.py b/titles/wacca/__init__.py new file mode 100644 index 0000000..c0351da --- /dev/null +++ b/titles/wacca/__init__.py @@ -0,0 +1,18 @@ +from titles.wacca.const import WaccaConstants +from titles.wacca.index import WaccaServlet +from titles.wacca.read import WaccaReader +from titles.wacca.database import WaccaData + +index = WaccaServlet +database = WaccaData +reader = WaccaReader + +use_default_title = True +include_protocol = True +title_secure = False +game_codes = [WaccaConstants.GAME_CODE] +trailing_slash = False +use_default_host = False +host = "" + +current_schema_version = 3 \ No newline at end of file diff --git a/titles/wacca/base.py b/titles/wacca/base.py new file mode 100644 index 0000000..598f1fc --- /dev/null +++ b/titles/wacca/base.py @@ -0,0 +1,941 @@ +from typing import Any, List, Dict +import logging +from math import floor + +from datetime import datetime, timedelta + +from core.config import CoreConfig +from titles.wacca.config import WaccaConfig +from titles.wacca.const import WaccaConstants +from titles.wacca.database import WaccaData + +from titles.wacca.handlers import * + +class WaccaBase(): + def __init__(self, cfg: CoreConfig, game_cfg: WaccaConfig) -> None: + self.config = cfg # Config file + self.game_config = game_cfg # Game Config file + self.game = WaccaConstants.GAME_CODE # Game code + self.version = WaccaConstants.VER_WACCA # Game version + self.data = WaccaData(cfg) # Database + self.logger = logging.getLogger("wacca") + self.srvtime = datetime.now() + self.season = 1 + + self.OPTIONS_DEFAULTS: Dict[str, Any] = { + "note_speed": 5, + "field_mask": 0, + "note_sound": 105001, + "note_color": 203001, + "bgm_volume": 10, + "bg_video": 0, + + "mirror": 0, + "judge_display_pos": 0, + "judge_detail_display": 0, + "measure_guidelines": 1, + "guideline_mask": 1, + "judge_line_timing_adjust": 10, + "note_design": 3, + "bonus_effect": 1, + "chara_voice": 1, + "score_display_method": 0, + "give_up": 0, + "guideline_spacing": 1, + "center_display": 1, + "ranking_display": 1, + "stage_up_icon_display": 1, + "rating_display": 1, + "player_level_display": 1, + "touch_effect": 1, + "guide_sound_vol": 3, + "touch_note_vol": 8, + "hold_note_vol": 8, + "slide_note_vol": 8, + "snap_note_vol": 8, + "chain_note_vol": 8, + "bonus_note_vol": 8, + "gate_skip": 0, + "key_beam_display": 1, + + "left_slide_note_color": 4, + "right_slide_note_color": 3, + "forward_slide_note_color": 1, + "back_slide_note_color": 2, + + "master_vol": 3, + "set_title_id": 104001, + "set_icon_id": 102001, + "set_nav_id": 210001, + "set_plate_id": 211001 + } + self.allowed_stages = [] + + def handle_housing_get_request(self, data: Dict) -> Dict: + req = BaseRequest(data) + housing_id = 1337 + self.logger.info(f"{req.chipId} -> {housing_id}") + resp = HousingGetResponse(housing_id) + return resp.make() + + def handle_housing_start_request(self, data: Dict) -> Dict: + req = HousingStartRequest(data) + + resp = HousingStartResponseV1( + 1, + [ # Recomended songs + 1269,1007,1270,1002,1020,1003,1008,1211,1018,1092,1056,32, + 1260,1230,1258,1251,2212,1264,1125,1037,2001,1272,1126,1119, + 1104,1070,1047,1044,1027,1004,1001,24,2068,2062,2021,1275, + 1249,1207,1203,1107,1021,1009,9,4,3,23,22,2014,13,1276,1247, + 1240,1237,1128,1114,1110,1109,1102,1045,1043,1036,1035,1030, + 1023,1015 + ] + ) + return resp.make() + + def handle_advertise_GetNews_request(self, data: Dict) -> Dict: + resp = GetNewsResponseV1() + return resp.make() + + def handle_user_status_logout_request(self, data: Dict) -> Dict: + req = UserStatusLogoutRequest(data) + self.logger.info(f"Log out user {req.userId} from {req.chipId}") + return BaseResponse().make() + + def handle_user_status_login_request(self, data: Dict) -> List[Any]: + req = UserStatusLoginRequest(data) + resp = UserStatusLoginResponseV1() + is_new_day = False + is_consec_day = False + is_consec_day = True + + if req.userId == 0: + self.logger.info(f"Guest login on {req.chipId}") + resp.lastLoginDate = 0 + + else: + profile = self.data.profile.get_profile(req.userId) + if profile is None: + self.logger.warn(f"Unknown user id {req.userId} attempted login from {req.chipId}") + return resp.make() + + self.logger.info(f"User {req.userId} login on {req.chipId}") + last_login_time = int(profile["last_login_date"].timestamp()) + resp.lastLoginDate = last_login_time + + # If somebodies login timestamp < midnight of current day, then they are logging in for the first time today + if last_login_time < int(datetime.now().replace(hour=0,minute=0,second=0,microsecond=0).timestamp()): + is_new_day = True + is_consec_day = True + + # If somebodies login timestamp > midnight of current day + 1 day, then they broke their daily login streak + elif last_login_time > int((datetime.now().replace(hour=0,minute=0,second=0,microsecond=0) + timedelta(days=1)).timestamp()): + is_consec_day = False + # else, they are simply logging in again on the same day, and we don't need to do anything for that + + self.data.profile.session_login(req.userId, is_new_day, is_consec_day) + + resp.firstLoginDaily = int(is_new_day) + + return resp.make() + + def handle_user_status_get_request(self, data: Dict) -> List[Any]: + req = UserStatusGetRequest(data) + resp = UserStatusGetV1Response() + ver_split = req.appVersion.split(".") + + profile = self.data.profile.get_profile(aime_id=req.aimeId) + if profile is None: + self.logger.info(f"No user exists for aime id {req.aimeId}") + return resp.make() + + + self.logger.info(f"User preview for {req.aimeId} from {req.chipId}") + if profile["last_game_ver"] is None: + profile_ver_split = ver_split + resp.lastGameVersion = req.appVersion + else: + profile_ver_split = profile["last_game_ver"].split(".") + resp.lastGameVersion = profile["last_game_ver"] + + resp.userStatus.userId = profile["id"] + resp.userStatus.username = profile["username"] + resp.userStatus.xp = profile["xp"] + resp.userStatus.danLevel = profile["dan_level"] + resp.userStatus.danType = profile["dan_type"] + resp.userStatus.wp = profile["wp"] + resp.userStatus.useCount = profile["login_count"] + resp.userStatus.loginDays = profile["login_count_days"] + resp.userStatus.loginConsecutiveDays = profile["login_count_days_consec"] + + set_title_id = self.data.profile.get_options(WaccaConstants.OPTIONS["set_title_id"], profile["user"]) + if set_title_id is None: + set_title_id = self.OPTIONS_DEFAULTS["set_title_id"] + resp.setTitleId = set_title_id + + set_icon_id = self.data.profile.get_options(WaccaConstants.OPTIONS["set_title_id"], profile["user"]) + if set_icon_id is None: + set_icon_id = self.OPTIONS_DEFAULTS["set_icon_id"] + resp.setIconId = set_icon_id + + if profile["last_login_date"].timestamp() < int((datetime.now().replace(hour=0,minute=0,second=0,microsecond=0) - timedelta(days=1)).timestamp()): + resp.userStatus.loginConsecutiveDays = 0 + + if int(ver_split[0]) > int(profile_ver_split[0]): + resp.versionStatus = PlayVersionStatus.VersionUpgrade + + elif int(ver_split[0]) < int(profile_ver_split[0]): + resp.versionStatus = PlayVersionStatus.VersionTooNew + + else: + if int(ver_split[1]) > int(profile_ver_split[1]): + resp.versionStatus = PlayVersionStatus.VersionUpgrade + + elif int(ver_split[1]) < int(profile_ver_split[1]): + resp.versionStatus = PlayVersionStatus.VersionTooNew + + else: + if int(ver_split[2]) > int(profile_ver_split[2]): + resp.versionStatus = PlayVersionStatus.VersionUpgrade + + + elif int(ver_split[2]) < int(profile_ver_split[2]): + resp.versionStatus = PlayVersionStatus.VersionTooNew + + if profile["always_vip"]: + resp.userStatus.vipExpireTime = int((datetime.now() + timedelta(days=30)).timestamp()) + + elif profile["vip_expire_time"] is not None: + resp.userStatus.vipExpireTime = int(profile["vip_expire_time"].timestamp()) + + return resp.make() + + def handle_user_status_login_request(self, data: Dict) -> List[Any]: + req = UserStatusLoginRequest(data) + resp = UserStatusLoginResponseV2() + is_new_day = False + is_consec_day = False + is_consec_day = True + + if req.userId == 0: + self.logger.info(f"Guest login on {req.chipId}") + resp.lastLoginDate = 0 + + else: + profile = self.data.profile.get_profile(req.userId) + if profile is None: + self.logger.warn(f"Unknown user id {req.userId} attempted login from {req.chipId}") + return resp.make() + + self.logger.info(f"User {req.userId} login on {req.chipId}") + last_login_time = int(profile["last_login_date"].timestamp()) + resp.lastLoginDate = last_login_time + + # If somebodies login timestamp < midnight of current day, then they are logging in for the first time today + if last_login_time < int(datetime.now().replace(hour=0,minute=0,second=0,microsecond=0).timestamp()): + is_new_day = True + is_consec_day = True + + # If somebodies login timestamp > midnight of current day + 1 day, then they broke their daily login streak + elif last_login_time > int((datetime.now().replace(hour=0,minute=0,second=0,microsecond=0) + timedelta(days=1)).timestamp()): + is_consec_day = False + # else, they are simply logging in again on the same day, and we don't need to do anything for that + + self.data.profile.session_login(req.userId, is_new_day, is_consec_day) + resp.vipInfo.pageYear = datetime.now().year + resp.vipInfo.pageMonth = datetime.now().month + resp.vipInfo.pageDay = datetime.now().day + resp.vipInfo.numItem = 1 + + resp.firstLoginDaily = int(is_new_day) + + return resp.make() + + def handle_user_status_create_request(self, data: Dict) -> List[Any]: + req = UserStatusCreateRequest(data) + + profileId = self.data.profile.create_profile(req.aimeId, req.username, self.version) + + if profileId is None: return BaseResponse().make() + + # Insert starting items + self.data.item.put_item(req.aimeId, WaccaConstants.ITEM_TYPES["title"], 104001) + self.data.item.put_item(req.aimeId, WaccaConstants.ITEM_TYPES["title"], 104002) + self.data.item.put_item(req.aimeId, WaccaConstants.ITEM_TYPES["title"], 104003) + self.data.item.put_item(req.aimeId, WaccaConstants.ITEM_TYPES["title"], 104005) + + self.data.item.put_item(req.aimeId, WaccaConstants.ITEM_TYPES["icon"], 102001) + self.data.item.put_item(req.aimeId, WaccaConstants.ITEM_TYPES["icon"], 102002) + + self.data.item.put_item(req.aimeId, WaccaConstants.ITEM_TYPES["note_color"], 103001) + self.data.item.put_item(req.aimeId, WaccaConstants.ITEM_TYPES["note_color"], 203001) + + self.data.item.put_item(req.aimeId, WaccaConstants.ITEM_TYPES["note_sound"], 105001) + self.data.item.put_item(req.aimeId, WaccaConstants.ITEM_TYPES["note_sound"], 205005) # Added lily + + self.data.item.put_item(req.aimeId, WaccaConstants.ITEM_TYPES["navigator"], 210001) + + self.data.item.put_item(req.aimeId, WaccaConstants.ITEM_TYPES["user_plate"], 211001) # Added lily + + self.data.item.put_item(req.aimeId, WaccaConstants.ITEM_TYPES["touch_effect"], 312000) # Added reverse + self.data.item.put_item(req.aimeId, WaccaConstants.ITEM_TYPES["touch_effect"], 312001) # Added reverse + self.data.item.put_item(req.aimeId, WaccaConstants.ITEM_TYPES["touch_effect"], 312002) # Added reverse + + return UserStatusCreateResponseV2(profileId, req.username).make() + + def handle_user_status_getDetail_request(self, data: Dict) -> List[Any]: + req = UserStatusGetDetailRequest(data) + resp = UserStatusGetDetailResponseV1() + + profile = self.data.profile.get_profile(req.userId) + if profile is None: + self.logger.warn(f"Unknown profile {req.userId}") + return resp.make() + + self.logger.info(f"Get detail for profile {req.userId}") + user_id = profile["user"] + + profile_scores = self.data.score.get_best_scores(user_id) + profile_items = self.data.item.get_items(user_id) + profile_song_unlocks = self.data.item.get_song_unlocks(user_id) + profile_options = self.data.profile.get_options(user_id) + profile_trophies = self.data.item.get_trophies(user_id) + profile_tickets = self.data.item.get_tickets(user_id) + + if profile["vip_expire_time"] is None: + resp.userStatus.vipExpireTime = 0 + + else: + resp.userStatus.vipExpireTime = int(profile["vip_expire_time"].timestamp()) + + if profile["always_vip"] or self.game_config.mods.always_vip: + resp.userStatus.vipExpireTime = int((self.srvtime + timedelta(days=31)).timestamp()) + + resp.songUpdateTime = int(profile["last_login_date"].timestamp()) + resp.songPlayStatus = [profile["last_song_id"], 1] + + resp.userStatus.userId = profile["id"] + resp.userStatus.username = profile["username"] + resp.userStatus.xp = profile["xp"] + resp.userStatus.danLevel = profile["dan_level"] + resp.userStatus.danType = profile["dan_type"] + resp.userStatus.wp = profile["wp"] + resp.userStatus.useCount = profile["login_count"] + resp.userStatus.loginDays = profile["login_count_days"] + resp.userStatus.loginConsecutiveDays = profile["login_count_days_consec"] + + if self.game_config.mods.infinite_wp: + resp.userStatus.wp = 999999 + + if profile["friend_view_1"] is not None: + pass + if profile["friend_view_2"] is not None: + pass + if profile["friend_view_3"] is not None: + pass + + resp.seasonalPlayModeCounts.append(PlayModeCounts(self.season, 1, profile["playcount_single"])) + resp.seasonalPlayModeCounts.append(PlayModeCounts(self.season, 2, profile["playcount_multi_vs"])) + resp.seasonalPlayModeCounts.append(PlayModeCounts(self.season, 3, profile["playcount_multi_coop"])) + resp.seasonalPlayModeCounts.append(PlayModeCounts(self.season, 4, profile["playcount_stageup"])) + + for opt in profile_options: + resp.options.append(UserOption(opt["opt_id"], opt["value"])) + + for unlock in profile_song_unlocks: + for x in range(1, unlock["highest_difficulty"] + 1): + resp.userItems.songUnlocks.append(SongUnlock(unlock["song_id"], x, 0, int(unlock["acquire_date"].timestamp()))) + if x > 2: + resp.scores.append(BestScoreDetailV1(unlock["song_id"], x)) + + empty_scores = len(resp.scores) + for song in profile_scores: + resp.seasonInfo.cumulativeScore += song["score"] + empty_score_idx = resp.find_score_idx(song["song_id"], song["chart_id"], 0, empty_scores) + + clear_cts = SongDetailClearCounts( + song["play_ct"], + song["clear_ct"], + song["missless_ct"], + song["fullcombo_ct"], + song["allmarv_ct"], + ) + + grade_cts = SongDetailGradeCountsV1( + song["grade_d_ct"], song["grade_c_ct"], song["grade_b_ct"], song["grade_a_ct"], song["grade_aa_ct"], + song["grade_aaa_ct"], song["grade_s_ct"], song["grade_ss_ct"], song["grade_sss_ct"], + song["grade_master_ct"] + ) + + if empty_score_idx is not None: + resp.scores[empty_score_idx].clearCounts = clear_cts + resp.scores[empty_score_idx].clearCountsSeason = clear_cts + resp.scores[empty_score_idx].gradeCounts = grade_cts + resp.scores[empty_score_idx].score = song["score"] + resp.scores[empty_score_idx].bestCombo = song["best_combo"] + resp.scores[empty_score_idx].lowestMissCtMaybe = song["lowest_miss_ct"] + resp.scores[empty_score_idx].rating = song["rating"] + + else: + deets = BestScoreDetailV1(song["song_id"], song["chart_id"]) + deets.clearCounts = clear_cts + deets.clearCountsSeason = clear_cts + deets.gradeCounts = grade_cts + deets.score = song["score"] + deets.bestCombo = song["best_combo"] + deets.lowestMissCtMaybe = song["lowest_miss_ct"] + deets.rating = song["rating"] + + for trophy in profile_trophies: + resp.userItems.trophies.append(TrophyItem(trophy["trophy_id"], trophy["season"], trophy["progress"], trophy["badge_type"])) + + if self.game_config.mods.infinite_tickets: + for x in range(5): + resp.userItems.tickets.append(TicketItem(x, 106002, 0)) + else: + for ticket in profile_tickets: + if ticket["expire_date"] is None: + expire = int((self.srvtime + timedelta(days=30)).timestamp()) + else: + expire = int(ticket["expire_date"].timestamp()) + + resp.userItems.tickets.append(TicketItem(ticket["id"], ticket["ticket_id"], expire)) + + if profile_items: + for item in profile_items: + try: + + if item["type"] == WaccaConstants.ITEM_TYPES["icon"]: + resp.userItems.icons.append(IconItem(item["item_id"], 1, item["use_count"], int(item["acquire_date"].timestamp()))) + + else: + itm_send = GenericItemSend(item["item_id"], 1, int(item["acquire_date"].timestamp())) + + if item["type"] == WaccaConstants.ITEM_TYPES["title"]: + resp.userItems.titles.append(itm_send) + + elif item["type"] == WaccaConstants.ITEM_TYPES["note_color"]: + resp.userItems.noteColors.append(itm_send) + + elif item["type"] == WaccaConstants.ITEM_TYPES["note_sound"]: + resp.userItems.noteSounds.append(itm_send) + + except: + self.logger.error(f"{__name__} Failed to load item {item['item_id']} for user {profile['user']}") + + resp.seasonInfo.level = profile["xp"] + resp.seasonInfo.wpObtained = profile["wp_total"] + resp.seasonInfo.wpSpent = profile["wp_spent"] + resp.seasonInfo.titlesObtained = len(resp.userItems.titles) + resp.seasonInfo.iconsObtained = len(resp.userItems.icons) + resp.seasonInfo.noteColorsObtained = len(resp.userItems.noteColors) + resp.seasonInfo.noteSoundsObtained = len(resp.userItems.noteSounds) + + return resp.make() + + def handle_user_trial_get_request(self, data: Dict) -> List[Any]: + req = UserTrialGetRequest(data) + resp = UserTrialGetResponse() + + user_id = self.data.profile.profile_to_aime_user(req.profileId) + if user_id is None: + self.logger.error(f"handle_user_trial_get_request: No profile with id {req.profileId}") + return resp.make() + + self.logger.info(f"Get trial info for user {req.profileId}") + + for d in self.allowed_stages: + if d[1] > 0 and d[1] < 10: + resp.stageList.append(StageInfo(d[0], d[1])) + + stages = self.data.score.get_stageup(user_id, self.version) + if stages is None: + stages = [] + + add_next = True + for d in self.allowed_stages: + stage_info = StageInfo(d[0], d[1]) + + for score in stages: + if score["stage_id"] == stage_info.danId: + stage_info.clearStatus = score["clear_status"] + stage_info.numSongCleared = score["clear_song_ct"] + stage_info.song1BestScore = score["song1_score"] + stage_info.song2BestScore = score["song2_score"] + stage_info.song3BestScore = score["song3_score"] + break + + if add_next or stage_info.danLevel < 9: + resp.stageList.append(stage_info) + + if stage_info.danLevel >= 9 and stage_info.clearStatus < 1: + add_next = False + + return resp.make() + + def handle_user_trial_update_request(self, data: Dict) -> List[Any]: + req = UserTrialUpdateRequest(data) + + total_score = 0 + for score in req.songScores: + total_score += score + + while len(req.songScores) < 3: + req.songScores.append(0) + + profile = self.data.profile.get_profile(req.profileId) + + user_id = profile["user"] + old_stage = self.data.score.get_stageup_stage(user_id, self.version, req.stageId) + + if old_stage is None: + self.data.score.put_stageup(user_id, self.version, req.stageId, req.clearType.value, req.numSongsCleared, req.songScores[0], req.songScores[1], req.songScores[2]) + + else: + # We only care about total score for best of, even if one score happens to be lower (I think) + if total_score > (old_stage["song1_score"] + old_stage["song2_score"] + old_stage["song3_score"]): + best_score1 = req.songScores[0] + best_score2 = req.songScores[2] + best_score3 = req.songScores[3] + else: + best_score1 = old_stage["song1_score"] + best_score2 = old_stage["song2_score"] + best_score3 = old_stage["song3_score"] + + self.data.score.put_stageup(user_id, self.version, req.stageId, req.clearType.value, req.numSongsCleared, + best_score1, best_score2, best_score3) + + if req.stageLevel > 0 and req.stageLevel <= 14 and req.clearType.value > 0: # For some reason, special stages send dan level 1001... + if req.stageLevel > profile["dan_level"] or (req.stageLevel == profile["dan_level"] and req.clearType.value > profile["dan_type"]): + self.data.profile.update_profile_dan(req.profileId, req.stageLevel, req.clearType.value) + + self.util_put_items(req.profileId, user_id, req.itemsObtained) + + # user/status/update isn't called after stageup so we have to do some things now + current_icon = self.data.profile.get_options(user_id, WaccaConstants.OPTIONS["set_icon_id"]) + current_nav = self.data.profile.get_options(user_id, WaccaConstants.OPTIONS["set_nav_id"]) + + if current_icon is None: + current_icon = self.OPTIONS_DEFAULTS["set_icon_id"] + else: + current_icon = current_icon["value"] + if current_nav is None: + current_nav = self.OPTIONS_DEFAULTS["set_nav_id"] + else: + current_nav = current_nav["value"] + + self.data.item.put_item(user_id, WaccaConstants.ITEM_TYPES["icon"], current_icon) + self.data.item.put_item(user_id, WaccaConstants.ITEM_TYPES["navigator"], current_nav) + self.data.profile.update_profile_playtype(req.profileId, 4, data["appVersion"][:7]) + return BaseResponse.make() + + def handle_user_sugoroku_update_request(self, data: Dict) -> List[Any]: + ver_split = data["appVersion"].split(".") + resp = BaseResponse() + + if int(ver_split[0]) <= 2 and int(ver_split[1]) < 53: + req = UserSugarokuUpdateRequestV1(data) + mission_flg = 0 + + else: + req = UserSugarokuUpdateRequestV2(data) + mission_flg = req.mission_flag + + user_id = self.data.profile.profile_to_aime_user(req.profileId) + if user_id is None: + self.logger.info(f"handle_user_sugoroku_update_request unknwon profile ID {req.profileId}") + return resp.make() + + self.util_put_items(req.profileId, user_id, req.itemsObtainted) + + self.data.profile.update_gate(user_id, req.gateId, req.page, req.progress, req.loops, mission_flg, req.totalPts) + return resp.make() + + def handle_user_info_getMyroom_request(self, data: Dict) -> List[Any]: + return UserInfogetMyroomResponse().make() + + def handle_user_music_unlock_request(self, data: Dict) -> List[Any]: + req = UserMusicUnlockRequest(data) + + profile = self.data.profile.get_profile(req.profileId) + if profile is None: return BaseResponse().make() + user_id = profile["user"] + current_wp = profile["wp"] + + tickets = self.data.item.get_tickets(user_id) + new_tickets = [] + + for ticket in tickets: + new_tickets.append([ticket["id"], ticket["ticket_id"], 9999999999]) + + for item in req.itemsUsed: + if item.itemType == WaccaConstants.ITEM_TYPES["wp"]: + if current_wp >= item.quantity: + current_wp -= item.quantity + self.data.profile.spend_wp(req.profileId, item.quantity) + else: return BaseResponse().make() + + elif item.itemType == WaccaConstants.ITEM_TYPES["ticket"]: + for x in range(len(new_tickets)): + if new_tickets[x][1] == item.itemId: + self.data.item.spend_ticket(new_tickets[x][0]) + new_tickets.pop(x) + break + + # wp, ticket info + if req.difficulty > WaccaConstants.Difficulty.HARD.value: + old_score = self.data.score.get_best_score(user_id, req.songId, req.difficulty) + if not old_score: + self.data.score.put_best_score(user_id, req.songId, req.difficulty, 0, [0] * 5, [0] * 13, 0, 0) + + self.data.item.unlock_song(user_id, req.songId, req.difficulty if req.difficulty > WaccaConstants.Difficulty.HARD.value else WaccaConstants.Difficulty.HARD.value) + + if self.game_config.mods.infinite_tickets: + new_tickets = [ + [0, 106002, 0], + [1, 106002, 0], + [2, 106002, 0], + [3, 106002, 0], + [4, 106002, 0], + ] + + if self.game_config.mods.infinite_wp: + current_wp = 999999 + + return UserMusicUnlockResponse(current_wp, new_tickets).make() + + def handle_user_info_getRanking_request(self, data: Dict) -> List[Any]: + # total score, high score by song, cumulative socre, stage up score, other score, WP ranking + # This likely requies calculating standings at regular intervals and caching the results + return UserInfogetRankingResponse().make() + + def handle_user_music_update_request(self, data: Dict) -> List[Any]: + req = UserMusicUpdateRequest(data) + ver_split = req.appVersion.split(".") + if int(ver_split[0]) >= 3: + resp = UserMusicUpdateResponseV3() + elif int(ver_split[0]) >= 2: + resp = UserMusicUpdateResponseV2() + else: + resp = UserMusicUpdateResponseV1() + + resp.songDetail.songId = req.songDetail.songId + resp.songDetail.difficulty = req.songDetail.difficulty + + profile = self.data.profile.get_profile(req.profileId) + + if profile is None: + self.logger.warn(f"handle_user_music_update_request: No profile for game_id {req.profileId}") + return BaseResponse().make() + + user_id = profile["user"] + self.util_put_items(req.profileId, user_id, req.itemsObtained) + + playlog_clear_status = req.songDetail.flagCleared + req.songDetail.flagMissless + req.songDetail.flagFullcombo + \ + req.songDetail.flagAllMarvelous + + self.data.score.put_playlog(user_id, req.songDetail.songId, req.songDetail.difficulty, req.songDetail.score, + playlog_clear_status, req.songDetail.grade.value, req.songDetail.maxCombo, req.songDetail.judgements.marvCt, + req.songDetail.judgements.greatCt, req.songDetail.judgements.goodCt, req.songDetail.judgements.missCt, + req.songDetail.fastCt, req.songDetail.slowCt, self.season) + + old_score = self.data.score.get_best_score(user_id, req.songDetail.songId, req.songDetail.difficulty) + + if not old_score: + grades = [0] * 13 + clears = [0] * 5 + + clears[0] = 1 + clears[1] = 1 if req.songDetail.flagCleared else 0 + clears[2] = 1 if req.songDetail.flagMissless else 0 + clears[3] = 1 if req.songDetail.flagFullcombo else 0 + clears[4] = 1 if req.songDetail.flagAllMarvelous else 0 + + grades[req.songDetail.grade.value - 1] = 1 + + self.data.score.put_best_score(user_id, req.songDetail.songId, req.songDetail.difficulty, req.songDetail.score, + clears, grades, req.songDetail.maxCombo, req.songDetail.judgements.missCt) + + resp.songDetail.score = req.songDetail.score + resp.songDetail.lowestMissCount = req.songDetail.judgements.missCt + + else: + grades = [ + old_score["grade_d_ct"], + old_score["grade_c_ct"], + old_score["grade_b_ct"], + old_score["grade_a_ct"], + old_score["grade_aa_ct"], + old_score["grade_aaa_ct"], + old_score["grade_s_ct"], + old_score["grade_ss_ct"], + old_score["grade_sss_ct"], + old_score["grade_master_ct"], + old_score["grade_sp_ct"], + old_score["grade_ssp_ct"], + old_score["grade_sssp_ct"], + ] + clears = [ + old_score["play_ct"], + old_score["clear_ct"], + old_score["missless_ct"], + old_score["fullcombo_ct"], + old_score["allmarv_ct"], + ] + + clears[0] += 1 + clears[1] += 1 if req.songDetail.flagCleared else 0 + clears[2] += 1 if req.songDetail.flagMissless else 0 + clears[3] += 1 if req.songDetail.flagFullcombo else 0 + clears[4] += 1 if req.songDetail.flagAllMarvelous else 0 + + grades[req.songDetail.grade.value - 1] += 1 + + best_score = max(req.songDetail.score, old_score["score"]) + best_max_combo = max(req.songDetail.maxCombo, old_score["best_combo"]) + lowest_miss_ct = min(req.songDetail.judgements.missCt, old_score["lowest_miss_ct"]) + best_rating = max(self.util_calc_song_rating(req.songDetail.score, req.songDetail.level), old_score["rating"]) + + self.data.score.put_best_score(user_id, req.songDetail.songId, req.songDetail.difficulty, best_score, clears, + grades, best_max_combo, lowest_miss_ct) + + resp.songDetail.score = best_score + resp.songDetail.lowestMissCount = lowest_miss_ct + resp.songDetail.rating = best_rating + + resp.songDetail.clearCounts = SongDetailClearCounts(counts=clears) + resp.songDetail.clearCountsSeason = SongDetailClearCounts(counts=clears) + + if int(ver_split[0]) >= 3: + resp.songDetail.grades = SongDetailGradeCountsV2(counts=grades) + else: + resp.songDetail.grades = SongDetailGradeCountsV1(counts=grades) + + return resp.make() + + #TODO: Coop and vs data + def handle_user_music_updateCoop_request(self, data: Dict) -> List[Any]: + coop_info = data["params"][4] + return self.handle_user_music_update_request(data) + + def handle_user_music_updateVersus_request(self, data: Dict) -> List[Any]: + vs_info = data["params"][4] + return self.handle_user_music_update_request(data) + + def handle_user_music_updateTrial_request(self, data: Dict) -> List[Any]: + return self.handle_user_music_update_request(data) + + def handle_user_mission_update_request(self, data: Dict) -> List[Any]: + req = UserMissionUpdateRequest(data) + page_status = req.params[1][1] + + profile = self.data.profile.get_profile(req.profileId) + if profile is None: + return BaseResponse().make() + + if len(req.itemsObtained) > 0: + self.util_put_items(req.profileId, profile["user"], req.itemsObtained) + + self.data.profile.update_bingo(profile["user"], req.bingoDetail.pageNumber, page_status) + self.data.profile.update_tutorial_flags(req.profileId, req.params[3]) + + return BaseResponse().make() + + def handle_user_goods_purchase_request(self, data: Dict) -> List[Any]: + req = UserGoodsPurchaseRequest(data) + resp = UserGoodsPurchaseResponse() + + profile = self.data.profile.get_profile(req.profileId) + if profile is None: return BaseResponse().make() + + user_id = profile["user"] + resp.currentWp = profile["wp"] + + if req.purchaseType == PurchaseType.PurchaseTypeWP: + resp.currentWp -= req.cost + self.data.profile.spend_wp(req.profileId, req.cost) + + elif req.purchaseType == PurchaseType.PurchaseTypeCredit: + self.logger.info(f"User {req.profileId} Purchased item {req.itemObtained.itemType} id {req.itemObtained.itemId} for {req.cost} credits on machine {req.chipId}") + + self.util_put_items(req.profileId ,user_id, [req.itemObtained]) + + if self.game_config.mods.infinite_tickets: + for x in range(5): + resp.tickets.append(TicketItem(x, 106002, 0)) + else: + tickets = self.data.item.get_tickets(user_id) + + for ticket in tickets: + resp.tickets.append(TicketItem(ticket["id"], ticket["ticket_id"], int((self.srvtime + timedelta(days=30)).timestamp()))) + + if self.game_config.mods.infinite_wp: + resp.currentWp = 999999 + + return resp.make() + + def handle_competition_status_login_request(self, data: Dict) -> List[Any]: + return BaseResponse().make() + + def handle_competition_status_update_request(self, data: Dict) -> List[Any]: + return BaseResponse().make() + + def handle_user_rating_update_request(self, data: Dict) -> List[Any]: + req = UserRatingUpdateRequest(data) + + user_id = self.data.profile.profile_to_aime_user(req.profileId) + + if user_id is None: + self.logger.error(f"handle_user_rating_update_request: No profild with ID {req.profileId}") + return BaseResponse().make() + + for song in req.songs: + self.data.score.update_song_rating(user_id, song.songId, song.difficulty, song.rating) + + self.data.profile.update_user_rating(req.profileId, req.totalRating) + + return BaseResponse().make() + + def handle_user_status_update_request(self, data: Dict) -> List[Any]: + req = UserStatusUpdateRequestV2(data) + + user_id = self.data.profile.profile_to_aime_user(req.profileId) + if user_id is None: + self.logger.info(f"handle_user_status_update_request: No profile with ID {req.profileId}") + return BaseResponse().make() + + self.util_put_items(req.profileId, user_id, req.itemsRecieved) + self.data.profile.update_profile_playtype(req.profileId, req.playType.value, data["appVersion"][:7]) + self.data.profile.update_profile_lastplayed(req.profileId, req.lastSongInfo.lastSongId, req.lastSongInfo.lastSongDiff, + req.lastSongInfo.lastFolderOrd, req.lastSongInfo.lastFolderId, req.lastSongInfo.lastSongOrd) + + current_icon = self.data.profile.get_options(user_id, WaccaConstants.OPTIONS["set_icon_id"]) + current_nav = self.data.profile.get_options(user_id, WaccaConstants.OPTIONS["set_nav_id"]) + + if current_icon is None: + current_icon = self.OPTIONS_DEFAULTS["set_icon_id"] + else: + current_icon = current_icon["value"] + if current_nav is None: + current_nav = self.OPTIONS_DEFAULTS["set_nav_id"] + else: + current_nav = current_nav["value"] + + self.data.item.put_item(user_id, WaccaConstants.ITEM_TYPES["icon"], current_icon) + self.data.item.put_item(user_id, WaccaConstants.ITEM_TYPES["navigator"], current_nav) + return BaseResponse().make() + + def handle_user_info_update_request(self, data: Dict) -> List[Any]: + req = UserInfoUpdateRequest(data) + + user_id = self.data.profile.profile_to_aime_user(req.profileId) + + for opt in req.optsUpdated: + self.data.profile.update_option(user_id, opt.id, opt.val) + + for update in req.datesUpdated: + pass + + for fav in req.favoritesAdded: + self.data.profile.add_favorite_song(user_id, fav) + + for unfav in req.favoritesRemoved: + self.data.profile.remove_favorite_song(user_id, unfav) + + return BaseResponse().make() + + def handle_user_vip_get_request(self, data: Dict) -> List[Any]: + req = UserVipGetRequest(data) + resp = UserVipGetResponse() + + profile = self.data.profile.get_profile(req.profileId) + if profile is None: + self.logger.warn(f"handle_user_vip_get_request no profile with ID {req.profileId}") + return BaseResponse().make() + + if "vip_expire_time" in profile and profile["vip_expire_time"] is not None and profile["vip_expire_time"].timestamp() > int(self.srvtime.timestamp()): + resp.vipDays = int((profile["vip_expire_time"].timestamp() - int(self.srvtime.timestamp())) / 86400) + + resp.vipDays += 30 + + resp.presents.append(VipLoginBonus(1,0,16,211025,1)) + resp.presents.append(VipLoginBonus(2,0,6,202086,1)) + resp.presents.append(VipLoginBonus(3,0,11,205008,1)) + resp.presents.append(VipLoginBonus(4,0,10,203009,1)) + resp.presents.append(VipLoginBonus(5,0,16,211026,1)) + resp.presents.append(VipLoginBonus(6,0,9,206001,1)) + + return resp.make() + + def handle_user_vip_start_request(self, data: Dict) -> List[Any]: + req = UserVipStartRequest(data) + + profile = self.data.profile.get_profile(req.profileId) + if profile is None: return BaseResponse().make() + + # This should never happen because wacca stops you from buying VIP + # if you have more then 10 days remaining, but this IS wacca we're dealing with... + if "always_vip" in profile and profile["always_vip"] or self.game_config.mods.always_vip: + return UserVipStartResponse(int((self.srvtime + timedelta(days=req.days)).timestamp())).make() + + profile["vip_expire_time"] = int((self.srvtime + timedelta(days=req.days)).timestamp()) + self.data.profile.update_vip_time(req.profileId, self.srvtime + timedelta(days=req.days)) + return UserVipStartResponse(profile["vip_expire_time"]).make() + + def util_put_items(self, profile_id: int, user_id: int, items_obtained: List[GenericItemRecv]) -> None: + if user_id is None or profile_id <= 0: + return None + + if items_obtained: + for item in items_obtained: + + if item.itemType == WaccaConstants.ITEM_TYPES["xp"]: + self.data.profile.add_xp(profile_id, item.quantity) + + elif item.itemType == WaccaConstants.ITEM_TYPES["wp"]: + self.data.profile.add_wp(profile_id, item.quantity) + + elif item.itemType == WaccaConstants.ITEM_TYPES["music_difficulty_unlock"] or item.itemType == WaccaConstants.ITEM_TYPES["music_unlock"]: + if item.quantity > WaccaConstants.Difficulty.HARD.value: + old_score = self.data.score.get_best_score(user_id, item.itemId, item.quantity) + if not old_score: + self.data.score.put_best_score(user_id, item.itemId, item.quantity, 0, [0] * 5, [0] * 13, 0, 0) + + if item.quantity == 0: + item.quantity = WaccaConstants.Difficulty.HARD.value + self.data.item.unlock_song(user_id, item.itemId, item.quantity) + + elif item.itemType == WaccaConstants.ITEM_TYPES["ticket"]: + self.data.item.add_ticket(user_id, item.itemId) + + elif item.itemType == WaccaConstants.ITEM_TYPES["trophy"]: + self.data.item.update_trophy(user_id, item.itemId, self.season, item.quantity, 0) + + else: + self.data.item.put_item(user_id, item.itemType, item.itemId) + + def util_calc_song_rating(self, score: int, difficulty: float) -> int: + if score >= 990000: + const = 4.00 + elif score >= 980000 and score < 990000: + const = 3.75 + elif score >= 970000 and score < 980000: + const = 3.50 + elif score >= 960000 and score < 970000: + const = 3.25 + elif score >= 950000 and score < 960000: + const = 3.00 + elif score >= 940000 and score < 950000: + const = 2.75 + elif score >= 930000 and score < 940000: + const = 2.50 + elif score >= 920000 and score < 930000: + const = 2.25 + elif score >= 910000 and score < 920000: + const = 2.00 + elif score >= 900000 and score < 910000: + const = 1.00 + else: const = 0.00 + + return floor((difficulty * const) * 10) diff --git a/titles/wacca/config.py b/titles/wacca/config.py new file mode 100644 index 0000000..f5bc235 --- /dev/null +++ b/titles/wacca/config.py @@ -0,0 +1,44 @@ +from typing import Dict, List +from core.config import CoreConfig + +class WaccaServerConfig(): + def __init__(self, parent_config: "WaccaConfig") -> None: + self.__config = parent_config + + @property + def enable(self) -> bool: + return CoreConfig.get_config_field(self.__config, 'wacca', 'server', 'enable', default=True) + + @property + def loglevel(self) -> int: + return CoreConfig.str_to_loglevel(CoreConfig.get_config_field(self.__config, 'wacca', 'server', 'loglevel', default="info")) + +class WaccaModsConfig(): + def __init__(self, parent_config: "WaccaConfig") -> None: + self.__config = parent_config + + @property + def always_vip(self) -> bool: + return CoreConfig.get_config_field(self.__config, 'wacca', 'mods', 'always_vip', default=True) + + @property + def infinite_tickets(self) -> bool: + return CoreConfig.get_config_field(self.__config, 'wacca', 'mods', 'infinite_tickets', default=True) + + @property + def infinite_wp(self) -> bool: + return CoreConfig.get_config_field(self.__config, 'wacca', 'mods', 'infinite_wp', default=True) + +class WaccaGateConfig(): + def __init__(self, parent_config: "WaccaConfig") -> None: + self.__config = parent_config + + @property + def enabled_gates(self) -> List[int]: + return CoreConfig.get_config_field(self.__config, 'wacca', 'gates', 'enabled_gates', default=[]) + +class WaccaConfig(dict): + def __init__(self) -> None: + self.server = WaccaServerConfig(self) + self.mods = WaccaModsConfig(self) + self.gates = WaccaGateConfig(self) diff --git a/titles/wacca/const.py b/titles/wacca/const.py new file mode 100644 index 0000000..910f313 --- /dev/null +++ b/titles/wacca/const.py @@ -0,0 +1,113 @@ +from enum import Enum + +class WaccaConstants(): + CONFIG_NAME = "wacca.yaml" + GAME_CODE = "SDFE" + + VER_WACCA = 0 + VER_WACCA_S = 1 + VER_WACCA_LILY = 2 + VER_WACCA_LILY_R = 3 + VER_WACCA_REVERSE = 4 + + VERSION_NAMES = ("WACCA", "WACCA S", "WACCA Lily", "WACCA Lily R", "WACCA Reverse") + + class GRADES(Enum): + D = 1 + C = 2 + B = 3 + A = 4 + AA = 5 + AAA = 6 + S = 7 + SS = 8 + SSS = 9 + MASTER = 10 + S_PLUS = 11 + SS_PLUS = 12 + SSS_PLUS = 13 + + ITEM_TYPES = { + "xp": 1, + "wp": 2, + "music_unlock": 3, + "music_difficulty_unlock": 4, + "title": 5, + "icon": 6, + "trophy": 7, + "skill": 8, + "ticket": 9, + "note_color": 10, + "note_sound": 11, + "baht_do_not_send": 12, + "boost_badge": 13, + "gate_point": 14, + "navigator": 15, + "user_plate": 16, + "touch_effect": 17, + } + + OPTIONS = { + "note_speed": 1, # 1.0 - 6.0 + "field_mask": 2, # 0-4 + "note_sound": 3, # ID + "note_color": 4, # ID + "bgm_volume": 5, # 0-100 incremements of 10 + "bg_video": 7, # ask, on, or off + + "mirror": 101, # none or left+right swap + "judge_display_pos": 102, # center, under, over, top or off + "judge_detail_display": 103, # on or off + "measure_guidelines": 105, # on or off + "guideline_mask": 106, # 0 - 5 + "judge_line_timing_adjust": 108, # -10 - 10 + "note_design": 110, # 1 - 5 + "bonus_effect": 114, # on or off + "chara_voice": 115, # "usually" or none + "score_display_method": 116, # add or subtract + "give_up": 117, # off, no touch, can't achieve s, ss, sss, pb + "guideline_spacing": 118, # none, or a-g type + "center_display": 119, # none, combo, score add, score sub, s ss sss pb boarder + "ranking_display": 120, # on or off + "stage_up_icon_display": 121, # on or off + "rating_display": 122, # on or off + "player_level_display": 123, # on or off + "touch_effect": 124, # on or off + "guide_sound_vol": 125, # 0-100 incremements of 10 + "touch_note_vol": 126, # 0-100 incremements of 10 + "hold_note_vol": 127, # 0-100 incremements of 10 + "slide_note_vol": 128, # 0-100 incremements of 10 + "snap_note_vol": 129, # 0-100 incremements of 10 + "chain_note_vol": 130, # 0-100 incremements of 10 + "bonus_note_vol": 131, # 0-100 incremements of 10 + "gate_skip": 132, # on or off + "key_beam_display": 133, # on or off + + "left_slide_note_color": 201, # red blue green or orange + "right_slide_note_color": 202, # red blue green or orange + "forward_slide_note_color": 203, # red blue green or orange + "back_slide_note_color": 204, # red blue green or orange + + "master_vol": 1001, # 0-100 incremements of 10 + "set_title_id": 1002, # ID + "set_icon_id": 1003, # ID + "set_nav_id": 1004, # ID + "set_plate_id": 1005, # ID + } + + DIFFICULTIES = { + "Normal": 1, + "Hard": 2, + "Expert": 3, + "Inferno": 4, + } + + class Difficulty(Enum): + NORMAL = 1 + HARD = 2 + EXPERT = 3 + INFERNO = 4 + + @classmethod + def game_ver_to_string(cls, ver: int): + return cls.VERSION_NAMES[ver] \ No newline at end of file diff --git a/titles/wacca/database.py b/titles/wacca/database.py new file mode 100644 index 0000000..8d4c8a5 --- /dev/null +++ b/titles/wacca/database.py @@ -0,0 +1,12 @@ +from core.data import Data +from core.config import CoreConfig +from titles.wacca.schema import * + +class WaccaData(Data): + def __init__(self, cfg: CoreConfig) -> None: + super().__init__(cfg) + + self.profile = WaccaProfileData(self.config, self.session) + self.score = WaccaScoreData(self.config, self.session) + self.item = WaccaItemData(self.config, self.session) + self.static = WaccaStaticData(self.config, self.session) \ No newline at end of file diff --git a/titles/wacca/handlers/__init__.py b/titles/wacca/handlers/__init__.py new file mode 100644 index 0000000..a59c7c1 --- /dev/null +++ b/titles/wacca/handlers/__init__.py @@ -0,0 +1,9 @@ +from titles.wacca.handlers.base import * +from titles.wacca.handlers.advertise import * +from titles.wacca.handlers.housing import * +from titles.wacca.handlers.user_info import * +from titles.wacca.handlers.user_misc import * +from titles.wacca.handlers.user_music import * +from titles.wacca.handlers.user_status import * +from titles.wacca.handlers.user_trial import * +from titles.wacca.handlers.user_vip import * \ No newline at end of file diff --git a/titles/wacca/handlers/advertise.py b/titles/wacca/handlers/advertise.py new file mode 100644 index 0000000..cf41359 --- /dev/null +++ b/titles/wacca/handlers/advertise.py @@ -0,0 +1,45 @@ +from typing import List, Dict + +from titles.wacca.handlers.base import BaseResponse +from titles.wacca.handlers.helpers import Notice + +# ---advertise/GetNews--- +class GetNewsResponseV1(BaseResponse): + def __init__(self) -> None: + super().__init__() + self.notices: list[Notice] = [] + self.copywrightListings: list[str] = [] + self.stoppedSongs: list[int] = [] + self.stoppedJackets: list[int] = [] + self.stoppedMovies: list[int] = [] + self.stoppedIcons: list[int] = [] + + def make(self) -> Dict: + note = [] + + for notice in self.notices: + note.append(notice.make()) + + self.params = [ + note, + self.copywrightListings, + self.stoppedSongs, + self.stoppedJackets, + self.stoppedMovies, + self.stoppedIcons + ] + + return super().make() + +class GetNewsResponseV2(GetNewsResponseV1): + stoppedProducts: list[int] = [] + stoppedNavs: list[int] = [] + stoppedNavVoices: list[int] = [] + + def make(self) -> Dict: + super().make() + self.params.append(self.stoppedProducts) + self.params.append(self.stoppedNavs) + self.params.append(self.stoppedNavVoices) + + return super(GetNewsResponseV1, self).make() diff --git a/titles/wacca/handlers/base.py b/titles/wacca/handlers/base.py new file mode 100644 index 0000000..1e1197b --- /dev/null +++ b/titles/wacca/handlers/base.py @@ -0,0 +1,31 @@ +from typing import Dict, List +from datetime import datetime + +class BaseRequest(): + def __init__(self, data: Dict) -> None: + self.requestNo: int = data["requestNo"] + self.appVersion: str = data["appVersion"] + self.boardId: str = data["boardId"] + self.chipId: str = data["chipId"] + self.params: List = data["params"] + +class BaseResponse(): + def __init__(self) -> None: + self.status: int = 0 + self.message: str = "" + self.serverTime: int = int(datetime.now().timestamp()) + self.maintNoticeTime: int = 0 + self.maintNotPlayableTime: int = 0 + self.maintStartTime: int = 0 + self.params: List = [] + + def make(self) -> Dict: + return { + "status": self.status, + "message": self.message, + "serverTime": self.serverTime, + "maintNoticeTime": self.maintNoticeTime, + "maintNotPlayableTime": self.maintNotPlayableTime, + "maintStartTime": self.maintStartTime, + "params": self.params + } diff --git a/titles/wacca/handlers/helpers.py b/titles/wacca/handlers/helpers.py new file mode 100644 index 0000000..19991e5 --- /dev/null +++ b/titles/wacca/handlers/helpers.py @@ -0,0 +1,786 @@ +from typing import List, Dict, Any +from enum import Enum + +from titles.wacca.const import WaccaConstants + +class HousingInfo(): + """ + 1 is lan install role, 2 is country + """ + id: int = 0 + val: str = "" + + def __init__(self, id: int = 0, val: str = "") -> None: + self.id = id + self.val = val + + def make(self) -> List: + return [ self.id, self.val ] + +class Notice(): + name: str = "" + title: str = "" + message: str = "" + unknown3: str = "" + unknown4: str = "" + showTitleScreen: bool = True + showWelcomeScreen: bool = True + startTime: int = 0 + endTime: int = 0 + voiceline: int = 0 + + def __init__(self, name: str = "", title: str = "", message: str = "", start: int = 0, end: int = 0) -> None: + self.name = name + self.title = title + self.message = message + self.startTime = start + self.endTime = end + + def make(self) -> List: + return [ self.name, self.title, self.message, self.unknown3, self.unknown4, int(self.showTitleScreen), + int(self.showWelcomeScreen), self.startTime, self.endTime, self.voiceline] + +class UserOption(): + opt_id: int + opt_val: Any + + def __init__(self, opt_id: int = 0, opt_val: Any = 0) -> None: + self.opt_id = opt_id + self.opt_val = opt_val + + def make(self) -> List: + return [self.opt_id, self.opt_val] + +class UserStatusV1(): + def __init__(self) -> None: + self.userId: int = -1 + self.username: str = "" + self.userType: int = 1 + self.xp: int = 0 + self.danLevel: int = 0 + self.danType: int = 0 + self.wp: int = 0 + self.titlePartIds: List[int] = [0, 0, 0] + self.useCount: int = 0 + self.loginDays: int = 0 + self.loginConsecutive: int = 0 + self.loginConsecutiveDays: int = 0 + self.vipExpireTime: int = 0 + + def make(self) -> List: + return [ + self.userId, + self.username, + self.userType, + self.xp, + self.danLevel, + self.danType, + self.wp, + self.titlePartIds, + self.useCount, + self.loginDays, + self.loginConsecutive, + self.loginConsecutiveDays, + self.vipExpireTime + ] + +class UserStatusV2(UserStatusV1): + def __init__(self) -> None: + super().__init__() + self.loginsToday: int = 0 + self.rating: int = 0 + + def make(self) -> List: + ret = super().make() + + ret.append(self.loginsToday) + ret.append(self.rating) + + return ret + +class ProfileStatus(Enum): + ProfileGood = 0 + ProfileRegister = 1 + ProfileInUse = 2 + ProfileWrongRegion = 3 + +class PlayVersionStatus(Enum): + VersionGood = 0 + VersionTooNew = 1 + VersionUpgrade = 2 + +class PlayModeCounts(): + seasonId: int = 0 + modeId: int = 0 + playNum: int = 0 + + def __init__(self, seasonId: int, modeId: int, playNum: int) -> None: + self.seasonId = seasonId + self.modeId = modeId + self.playNum = playNum + + def make(self) -> List: + return [ + self.seasonId, + self.modeId, + self.playNum + ] + +class SongUnlock(): + songId: int = 0 + difficulty: int = 0 + whenAppeared: int = 0 + whenUnlocked: int = 0 + + def __init__(self, song_id: int = 0, difficulty: int = 1, whenAppered: int = 0, whenUnlocked: int = 0) -> None: + self.songId = song_id + self.difficulty = difficulty + self.whenAppeared = whenAppered + self.whenUnlocked = whenUnlocked + + def make(self) -> List: + return [ + self.songId, + self.difficulty, + self.whenAppeared, + self.whenUnlocked + ] + +class GenericItemRecv(): + def __init__(self, item_type: int = 1, item_id: int = 1, quantity: int = 1) -> None: + self.itemId = item_id + self.itemType = item_type + self.quantity = quantity + + def make(self) -> List: + return [ self.itemType, self.itemId, self.quantity ] + +class GenericItemSend(): + def __init__(self, itemId: int, itemType: int, whenAcquired: int) -> None: + self.itemId = itemId + self.itemType = itemType + self.whenAcquired = whenAcquired + + def make(self) -> List: + return [ + self.itemId, + self.itemType, + self.whenAcquired + ] + +class IconItem(GenericItemSend): + uses: int = 0 + + def __init__(self, itemId: int, itemType: int, uses: int, whenAcquired: int) -> None: + super().__init__(itemId, itemType, whenAcquired) + self.uses = uses + + def make(self) -> List: + return [ + self.itemId, + self.itemType, + self.uses, + self.whenAcquired + ] + +class TrophyItem(): + trophyId: int = 0 + season: int = 1 + progress: int = 0 + badgeType: int = 0 + + def __init__(self, trophyId: int, season: int, progress: int, badgeType: int) -> None: + self.trophyId = trophyId + self.season = season + self.progress = progress + self.badgeType = badgeType + + def make(self) -> List: + return [ + self.trophyId, + self.season, + self.progress, + self.badgeType + ] + +class TicketItem(): + userTicketId: int = 0 + ticketId: int = 0 + whenExpires: int = 0 + + def __init__(self, userTicketId: int, ticketId: int, whenExpires: int) -> None: + self.userTicketId = userTicketId + self.ticketId = ticketId + self.whenExpires = whenExpires + + def make(self) -> List: + return [ + self.userTicketId, + self.ticketId, + self.whenExpires + ] + +class NavigatorItem(IconItem): + usesToday: int = 0 + + def __init__(self, itemId: int, itemType: int, whenAcquired: int, uses: int, usesToday: int) -> None: + super().__init__(itemId, itemType, uses, whenAcquired) + self.usesToday = usesToday + + def make(self) -> List: + return [ + self.itemId, + self.itemType, + self.whenAcquired, + self.uses, + self.usesToday + ] + +class SkillItem(): + skill_type: int + level: int + flag: int + badge: int + + def make(self) -> List: + return [ + self.skill_type, + self.level, + self.flag, + self.badge + ] + +class UserItemInfoV1(): + def __init__(self) -> None: + self.songUnlocks: List[SongUnlock] = [] + self.titles: List[GenericItemSend] = [] + self.icons: List[IconItem] = [] + self.trophies: List[TrophyItem] = [] + self.skills: List[SkillItem] = [] + self.tickets: List[TicketItem] = [] + self.noteColors: List[GenericItemSend] = [] + self.noteSounds: List[GenericItemSend] = [] + + def make(self) -> List: + unlocks = [] + titles = [] + icons = [] + trophies = [] + skills = [] + tickets = [] + colors = [] + sounds = [] + + for x in self.songUnlocks: + unlocks.append(x.make()) + for x in self.titles: + titles.append(x.make()) + for x in self.icons: + icons.append(x.make()) + for x in self.trophies: + trophies.append(x.make()) + for x in self.skills: + skills.append(x.make()) + for x in self.tickets: + tickets.append(x.make()) + for x in self.noteColors: + colors.append(x.make()) + for x in self.noteSounds: + sounds.append(x.make()) + + return [ + unlocks, + titles, + icons, + trophies, + skills, + tickets, + colors, + sounds, + ] + +class UserItemInfoV2(UserItemInfoV1): + def __init__(self) -> None: + super().__init__() + self.navigators: List[NavigatorItem] = [] + self.plates: List[GenericItemSend] = [] + + def make(self) -> List: + ret = super().make() + plates = [] + navs = [] + + for x in self.navigators: + navs.append(x.make()) + for x in self.plates: + plates.append(x.make()) + + ret.append(navs) + ret.append(plates) + return ret + +class UserItemInfoV3(UserItemInfoV2): + def __init__(self) -> None: + super().__init__() + self.touchEffect: List[GenericItemSend] = [] + + def make(self) -> List: + ret = super().make() + effect = [] + + for x in self.touchEffect: + effect.append(x.make()) + + ret.append(effect) + return ret + +class SongDetailClearCounts(): + def __init__(self, play_ct: int = 0, clear_ct: int = 0, ml_ct: int = 0, fc_ct: int = 0, + am_ct: int = 0, counts: List[int] = None) -> None: + if counts is None: + self.playCt = play_ct + self.clearCt = clear_ct + self.misslessCt = ml_ct + self.fullComboCt = fc_ct + self.allMarvelousCt = am_ct + + else: + self.playCt = counts[0] + self.clearCt = counts[1] + self.misslessCt = counts[2] + self.fullComboCt = counts[3] + self.allMarvelousCt = counts[4] + + def make(self) -> List: + return [self.playCt, self.clearCt, self.misslessCt, self.fullComboCt, self.allMarvelousCt] + +class SongDetailGradeCountsV1(): + dCt: int + cCt: int + bCt: int + aCt: int + aaCt: int + aaaCt: int + sCt: int + ssCt: int + sssCt: int + masterCt: int + + def __init__(self, d: int = 0, c: int = 0, b: int = 0, a: int = 0, aa: int = 0, aaa: int = 0, s: int = 0, + ss: int = 0, sss: int = 0, master: int = 0, counts: List[int] = None) -> None: + if counts is None: + self.dCt = d + self.cCt = c + self.bCt = b + self.aCt = a + self.aaCt = aa + self.aaaCt = aaa + self.sCt = s + self.ssCt = ss + self.sssCt = sss + self.masterCt = master + + else: + self.dCt = counts[0] + self.cCt = counts[1] + self.bCt = counts[2] + self.aCt = counts[3] + self.aaCt = counts[4] + self.aaaCt = counts[5] + self.sCt = counts[6] + self.ssCt = counts[7] + self.sssCt = counts[8] + self.masterCt =counts[9] + + def make(self) -> List: + return [self.dCt, self.cCt, self.bCt, self.aCt, self.aaCt, self.aaaCt, self.sCt, self.ssCt, self.sssCt, self.masterCt] + +class SongDetailGradeCountsV2(SongDetailGradeCountsV1): + spCt: int + sspCt: int + ssspCt: int + + def __init__(self, d: int = 0, c: int = 0, b: int = 0, a: int = 0, aa: int = 0, aaa: int = 0, s: int = 0, + ss: int = 0, sss: int = 0, master: int = 0, sp: int = 0, ssp: int = 0, sssp: int = 0, counts: List[int] = None, ) -> None: + super().__init__(d, c, b, a, aa, aaa, s, ss, sss, master, counts) + if counts is None: + self.spCt = sp + self.sspCt = ssp + self.ssspCt = sssp + + else: + self.spCt = counts[10] + self.sspCt = counts[11] + self.ssspCt = counts[12] + + def make(self) -> List: + return super().make() + [self.spCt, self.sspCt, self.ssspCt] + +class BestScoreDetailV1(): + songId: int = 0 + difficulty: int = 1 + clearCounts: SongDetailClearCounts = SongDetailClearCounts() + clearCountsSeason: SongDetailClearCounts = SongDetailClearCounts() + gradeCounts: SongDetailGradeCountsV1 = SongDetailGradeCountsV1() + score: int = 0 + bestCombo: int = 0 + lowestMissCtMaybe: int = 0 + isUnlock: int = 1 + rating: int = 0 + + def __init__(self, song_id: int, difficulty: int = 1) -> None: + self.songId = song_id + self.difficulty = difficulty + + def make(self) -> List: + return [ + self.songId, + self.difficulty, + self.clearCounts.make(), + self.clearCountsSeason.make(), + self.gradeCounts.make(), + self.score, + self.bestCombo, + self.lowestMissCtMaybe, + self.isUnlock, + self.rating + ] + +class BestScoreDetailV2(BestScoreDetailV1): + gradeCounts: SongDetailGradeCountsV2 = SongDetailGradeCountsV2() + +class SongUpdateJudgementCounts(): + marvCt: int + greatCt: int + goodCt: int + missCt: int + + def __init__(self, marvs: int = 0, greats: int = 0, goods: int = 0, misses: int = 0) -> None: + self.marvCt = marvs + self.greatCt = greats + self.goodCt = goods + self.missCt = misses + + def make(self) -> List: + return [self.marvCt, self.greatCt, self.goodCt, self.missCt] + +class SongUpdateDetail(): + songId: int + difficulty: int + level: float + score: int + judgements: SongUpdateJudgementCounts + maxCombo: int + grade: WaccaConstants.GRADES + flagCleared: bool + flagMissless: bool + flagFullcombo: bool + flagAllMarvelous: bool + flagGiveUp: bool + skillPt: int + fastCt: int + slowCt: int + flagNewRecord: bool + + def __init__(self, data: List = None) -> None: + if data is not None: + self.songId = data[0] + self.difficulty = data[1] + self.level = data[2] + self.score = data[3] + + self.judgements = SongUpdateJudgementCounts(data[4][0], data[4][1], data[4][2], data[4][3]) + self.maxCombo = data[5] + self.grade = WaccaConstants.GRADES(data[6]) # .value to get number, .name to get letter + + self.flagCleared = False if data[7] == 0 else True + self.flagMissless = False if data[8] == 0 else True + self.flagFullcombo = False if data[9] == 0 else True + self.flagAllMarvelous = False if data[10] == 0 else True + self.flagGiveUp = False if data[11] == 0 else True + + self.skillPt = data[12] + self.fastCt = data[13] + self.slowCt = data[14] + self.flagNewRecord = False if data[15] == 0 else True + +class SeasonalInfoV1(): + def __init__(self) -> None: + self.level: int = 0 + self.wpObtained: int = 0 + self.wpSpent: int = 0 + self.cumulativeScore: int = 0 + self.titlesObtained: int = 0 + self.iconsObtained: int = 0 + self.skillPts: int = 0 + self.noteColorsObtained: int = 0 + self.noteSoundsObtained: int = 0 + + def make(self) -> List: + return [ + self.level, + self.wpObtained, + self.wpSpent, + self.cumulativeScore, + self.titlesObtained, + self.iconsObtained, + self.skillPts, + self.noteColorsObtained, + self.noteSoundsObtained + ] + +class SeasonalInfoV2(SeasonalInfoV1): + def __init__(self) -> None: + super().__init__() + self.platesObtained: int = 0 + self.cumulativeGatePts: int = 0 + + def make(self) -> List: + return super().make() + [self.platesObtained, self.cumulativeGatePts] + +class BingoPageStatus(): + id = 0 + location = 1 + progress = 0 + + def __init__(self, id: int = 0, location: int = 1, progress: int = 0) -> None: + self.id = id + self.location = location + self.progress = progress + + def make(self) -> List: + return [self.id, self.location, self.progress] + +class BingoDetail(): + def __init__(self, pageNumber: int) -> None: + self.pageNumber = pageNumber + self.pageStatus: List[BingoPageStatus] = [] + + def make(self) -> List: + status = [] + for x in self.pageStatus: + status.append(x.make()) + + return [ + self.pageNumber, + status + ] + +class GateDetailV1(): + def __init__(self, gate_id: int = 1, page: int = 1, progress: int = 0, loops: int = 0, last_used: int = 0, mission_flg = 0) -> None: + self.id = gate_id + self.page = page + self.progress = progress + self.loops = loops + self.lastUsed = last_used + self.missionFlg = mission_flg + + def make(self) -> List: + return [self.id, 1, self.page, self.progress, self.loops, self.lastUsed] + +class GateDetailV2(GateDetailV1): + def make(self) -> List: + return super().make() + [self.missionFlg] + +class GachaInfo(): + def make() -> List: + return [] + +class LastSongDetail(): + lastSongId = 90 + lastSongDiff = 1 + lastFolderOrd = 1 + lastFolderId = 1 + lastSongOrd = 1 + + def __init__(self, last_song: int = 90, last_diff: int = 1, last_folder_ord: int = 1, + last_folder_id: int = 1, last_song_ord: int = 1) -> None: + self.lastSongId = last_song + self.lastSongDiff = last_diff + self.lastFolderOrd = last_folder_ord + self.lastFolderId = last_folder_id + self.lastSongOrd = last_song_ord + + def make(self) -> List: + return [self.lastSongId, self.lastSongDiff, self.lastFolderOrd, self.lastFolderId, + self.lastSongOrd] + +class FriendDetail(): + def make(self) -> List: + return [] + +class UserOption(): + id = 1 + val = 1 + + def __init__(self, id: int = 1, val: int = val) -> None: + self.id = id + self.val = val + + def make(self) -> List: + return [self.id, self.val] + +class LoginBonusInfo(): + def __init__(self) -> None: + self.tickets: List[TicketItem] = [] + self.items: List[GenericItemRecv] = [] + self.message: str = "" + + def make(self) -> List: + tks = [] + itms = [] + + for ticket in self.tickets: + tks.append(ticket.make()) + + for item in self.items: + itms.append(item.make()) + + return [ tks, itms, self.message ] + +class VipLoginBonus(): + id = 1 + unknown = 0 + item: GenericItemRecv + + def __init__(self, id: int = 1, unk: int = 0, item_type: int = 1, item_id: int = 1, item_qt: int = 1) -> None: + self.id = id + self.unknown = unk + self.item = GenericItemRecv(item_type, item_id, item_qt) + + def make(self) -> List: + return [ self.id, self.unknown, self.item.make() ] + +class VipInfo(): + def __init__(self, year: int = 2019, month: int = 1, day: int = 1, num_item: int = 1) -> None: + self.pageYear = year + self.pageMonth = month + self.pageDay = day + self.numItem = num_item + self.presentInfo: List[LoginBonusInfo] = [] + self.vipLoginBonus: List[VipLoginBonus] = [] + + def make(self) -> List: + pres = [] + vipBonus = [] + + for present in self.presentInfo: + pres.append(present.make()) + + for b in self.vipLoginBonus: + vipBonus.append(b.make()) + + return [ self.pageYear, self.pageMonth, self.pageDay, self.numItem, pres, vipBonus ] + +class PurchaseType(Enum): + PurchaseTypeCredit = 1 + PurchaseTypeWP = 2 + +class PlayType(Enum): + PlayTypeSingle = 1 + PlayTypeVs = 2 + PlayTypeCoop = 3 + PlayTypeStageup = 4 + +class SongRatingUpdate(): + song_id = 0 + difficulty = 0 + rating = 0 + + def __init__(self, song: int = 0, difficulty: int = 0, rating: int = 0) -> None: + self.song_id = song + self.difficulty = difficulty + self.rating = rating + + def make(self) -> List: + return [self.song_id, self.difficulty, self.rating] + +class StageInfo(): + danId: int = 0 + danLevel: int = 0 + clearStatus: int = 0 + numSongCleared: int = 0 + song1BestScore: int = 0 + song2BestScore: int = 0 + song3BestScore: int = 0 + unk5: int = 1 + + def __init__(self, dan_id: int = 0, dan_level: int = 0) -> None: + self.danId = dan_id + self.danLevel = dan_level + + def make(self) -> List: + return [ + self.danId, + self.danLevel, + self.clearStatus, + self.numSongCleared, + [ + self.song1BestScore, + self.song2BestScore, + self.song3BestScore, + ], + self.unk5 + ] + +class StageupClearType(Enum): + FAIL = 0 + CLEAR_BLUE = 1 + CLEAR_SILVER = 2 + CLEAR_GOLD = 3 + +class MusicUpdateDetailV1(): + def __init__(self) -> None: + self.songId = 0 + self.difficulty = 1 + self.clearCounts: SongDetailClearCounts = SongDetailClearCounts() + self.clearCountsSeason: SongDetailClearCounts = SongDetailClearCounts() + self.grades: SongDetailGradeCountsV1 = SongDetailGradeCountsV1() + self.score = 0 + self.lowestMissCount = 0 + self.maxSkillPts = 0 + self.locked = 0 + self.rating = 0 + + def make(self) -> List: + return [ + self.songId, + self.difficulty, + self.clearCounts.make(), + self.clearCountsSeason.make(), + self.grades.make(), + self.score, + self.lowestMissCount, + self.maxSkillPts, + self.locked, + self.rating + ] + +class MusicUpdateDetailV2(MusicUpdateDetailV1): + def __init__(self) -> None: + super().__init__() + self.grades = SongDetailGradeCountsV2() + +class SongRatingUpdate(): + def __init__(self, song_id: int = 0, difficulty: int = 1, new_rating: int = 0) -> None: + self.songId = song_id + self.difficulty = difficulty + self.rating = new_rating + + def make(self) -> List: + return [ + self.songId, + self.difficulty, + self.rating, + ] + +class GateTutorialFlag(): + def __init__(self, tutorial_id: int = 1, flg_watched: bool = False) -> None: + self.tutorialId = tutorial_id + self.flagWatched = flg_watched + + def make(self) -> List: + return [ + self.tutorialId, + int(self.flagWatched) + ] diff --git a/titles/wacca/handlers/housing.py b/titles/wacca/handlers/housing.py new file mode 100644 index 0000000..7806632 --- /dev/null +++ b/titles/wacca/handlers/housing.py @@ -0,0 +1,38 @@ +from typing import List, Dict + +from titles.wacca.handlers.base import BaseRequest, BaseResponse +from titles.wacca.handlers.helpers import HousingInfo + +# ---housing/get---- +class HousingGetResponse(BaseResponse): + def __init__(self, housingId: int) -> None: + super().__init__() + self.housingId: int = housingId + self.regionId: int = 0 + + def make(self) -> Dict: + self.params = [self.housingId, self.regionId] + return super().make() + +# ---housing/start---- +class HousingStartRequest(BaseRequest): + def __init__(self, data: Dict) -> None: + super().__init__(data) + self.unknown0: str = self.params[0] + self.errorLog: str = self.params[1] + self.unknown2: str = self.params[2] + self.info: List[HousingInfo] = [] + + for info in self.params[3]: + self.info.append(HousingInfo(info[0], info[1])) + +class HousingStartResponseV1(BaseResponse): + def __init__(self, regionId: int, songList: List[int]) -> None: + super().__init__() + self.regionId = regionId + self.songList = songList + + def make(self) -> Dict: + self.params = [self.regionId, self.songList] + + return super().make() diff --git a/titles/wacca/handlers/user_info.py b/titles/wacca/handlers/user_info.py new file mode 100644 index 0000000..c7336d7 --- /dev/null +++ b/titles/wacca/handlers/user_info.py @@ -0,0 +1,61 @@ +from typing import List, Dict + +from titles.wacca.handlers.base import BaseRequest, BaseResponse +from titles.wacca.handlers.helpers import UserOption + +# ---user/info/update--- +class UserInfoUpdateRequest(BaseRequest): + def __init__(self, data: Dict) -> None: + super().__init__(data) + self.profileId = int(self.params[0]) + self.optsUpdated: List[UserOption] = [] + self.datesUpdated: List = self.params[3] + self.favoritesAdded: List[int] = self.params[4] + self.favoritesRemoved: List[int] = self.params[5] + + for x in self.params[2]: + self.optsUpdated.append(UserOption(x[0], x[1])) + +# ---user/info/getMyroom--- TODO: Understand this better +class UserInfogetMyroomRequest(BaseRequest): + game_id = 0 + def __init__(self, data: Dict) -> None: + super().__init__(data) + self.game_id = int(self.params[0]) + +class UserInfogetMyroomResponse(BaseResponse): + def make(self) -> Dict: + self.params = [ + 0,0,0,0,0,[],0,0,0 + ] + + return super().make() + +# ---user/info/getRanking--- +class UserInfogetRankingRequest(BaseRequest): + game_id = 0 + def __init__(self, data: Dict) -> None: + super().__init__(data) + self.game_id = int(self.params[0]) + +class UserInfogetRankingResponse(BaseResponse): + def __init__(self) -> None: + super().__init__() + self.total_score_rank = 0 + self.high_score_by_song_rank = 0 + self.cumulative_score_rank = 0 + self.state_up_score_rank = 0 + self.other_score_ranking = 0 + self.wacca_points_ranking = 0 + + def make(self) -> Dict: + self.params = [ + self.total_score_rank, + self.high_score_by_song_rank, + self.cumulative_score_rank, + self.state_up_score_rank, + self.other_score_ranking, + self.wacca_points_ranking, + ] + + return super().make() \ No newline at end of file diff --git a/titles/wacca/handlers/user_misc.py b/titles/wacca/handlers/user_misc.py new file mode 100644 index 0000000..e710a8b --- /dev/null +++ b/titles/wacca/handlers/user_misc.py @@ -0,0 +1,85 @@ +from typing import List, Dict + +from titles.wacca.handlers.base import BaseRequest, BaseResponse +from titles.wacca.handlers.helpers import PurchaseType, GenericItemRecv +from titles.wacca.handlers.helpers import TicketItem, SongRatingUpdate, BingoDetail +from titles.wacca.handlers.helpers import BingoPageStatus, GateTutorialFlag + +# ---user/goods/purchase--- +class UserGoodsPurchaseRequest(BaseRequest): + def __init__(self, data: Dict) -> None: + super().__init__(data) + self.profileId = int(self.params[0]) + self.purchaseId = int(self.params[1]) + self.purchaseCount = int(self.params[2]) + self.purchaseType = PurchaseType(self.params[3]) + self.cost = int(self.params[4]) + self.itemObtained: GenericItemRecv = GenericItemRecv(self.params[5][0], self.params[5][1], self.params[5][2]) + +class UserGoodsPurchaseResponse(BaseResponse): + def __init__(self, wp: int = 0, tickets: List = []) -> None: + super().__init__() + self.currentWp = wp + self.tickets: List[TicketItem] = [] + + for ticket in tickets: + self.tickets.append(TicketItem(ticket[0], ticket[1], ticket[2])) + + def make(self) -> List: + tix = [] + for ticket in self.tickets: + tix.append(ticket.make()) + + self.params = [self.currentWp, tix] + + return super().make() + +# ---user/sugaroku/update--- +class UserSugarokuUpdateRequestV1(BaseRequest): + def __init__(self, data: Dict) -> None: + super().__init__(data) + self.profileId = int(self.params[0]) + self.gateId = int(self.params[1]) + self.page = int(self.params[2]) + self.progress = int(self.params[3]) + self.loops = int(self.params[4]) + self.boostsUsed = self.params[5] + self.totalPts = int(self.params[7]) + self.itemsObtainted: List[GenericItemRecv] = [] + + for item in self.params[6]: + self.itemsObtainted.append(GenericItemRecv(item[0], item[1], item[2])) + +class UserSugarokuUpdateRequestV2(UserSugarokuUpdateRequestV1): + def __init__(self, data: Dict) -> None: + super().__init__(data) + self.mission_flag = int(self.params[8]) + +# ---user/rating/update--- +class UserRatingUpdateRequest(BaseRequest): + def __init__(self, data: Dict) -> None: + super().__init__(data) + self.profileId = self.params[0] + self.totalRating = self.params[1] + self.songs: List[SongRatingUpdate] = [] + + for x in self.params[2]: + self.songs.append(SongRatingUpdate(x[0], x[1], x[2])) + +# ---user/mission/update--- +class UserMissionUpdateRequest(BaseRequest): + def __init__(self, data: Dict) -> None: + super().__init__(data) + self.profileId = self.params[0] + self.bingoDetail = BingoDetail(self.params[1][0]) + self.itemsObtained: List[GenericItemRecv] = [] + self.gateTutorialFlags: List[GateTutorialFlag] = [] + + for x in self.params[1][1]: + self.bingoDetail.pageStatus.append(BingoPageStatus(x[0], x[1], x[2])) + + for x in self.params[2]: + self.itemsObtained.append(GenericItemRecv(x[0], x[1], x[2])) + + for x in self.params[3]: + self.gateTutorialFlags.append(GateTutorialFlag(x[0], x[1])) diff --git a/titles/wacca/handlers/user_music.py b/titles/wacca/handlers/user_music.py new file mode 100644 index 0000000..adb11b6 --- /dev/null +++ b/titles/wacca/handlers/user_music.py @@ -0,0 +1,92 @@ +from typing import List, Dict + +from titles.wacca.handlers.base import BaseRequest, BaseResponse +from titles.wacca.handlers.helpers import GenericItemRecv, SongUpdateDetail, TicketItem +from titles.wacca.handlers.helpers import MusicUpdateDetailV1, MusicUpdateDetailV2 +from titles.wacca.handlers.helpers import SeasonalInfoV2, SeasonalInfoV1 + +# ---user/music/update--- +class UserMusicUpdateRequest(BaseRequest): + def __init__(self, data: Dict) -> None: + super().__init__(data) + self.profileId: int = self.params[0] + self.songNumber: int = self.params[1] + self.songDetail = SongUpdateDetail(self.params[2]) + self.itemsObtained: List[GenericItemRecv] = [] + + for itm in data["params"][3]: + self.itemsObtained.append(GenericItemRecv(itm[0], itm[1], itm[2])) + +class UserMusicUpdateResponseV1(BaseResponse): + def __init__(self) -> None: + super().__init__() + self.songDetail = MusicUpdateDetailV1() + self.seasonInfo = SeasonalInfoV1() + self.rankingInfo: List[List[int]] = [] + + def make(self) -> Dict: + self.params = [ + self.songDetail.make(), + [self.songDetail.songId, self.songDetail.clearCounts.playCt], + self.seasonInfo.make(), + self.rankingInfo + ] + + return super().make() + +class UserMusicUpdateResponseV2(UserMusicUpdateResponseV1): + def __init__(self) -> None: + super().__init__() + self.seasonInfo = SeasonalInfoV2() + +class UserMusicUpdateResponseV3(UserMusicUpdateResponseV2): + def __init__(self) -> None: + super().__init__() + self.songDetail = MusicUpdateDetailV2() + +# ---user/music/updateCoop--- +class UserMusicUpdateCoopRequest(UserMusicUpdateRequest): + def __init__(self, data: Dict) -> None: + super().__init__(data) + self.coopData = self.params[4] + +# ---user/music/updateVs--- +class UserMusicUpdateVsRequest(UserMusicUpdateRequest): + def __init__(self, data: Dict) -> None: + super().__init__(data) + self.vsData = self.params[4] + +# ---user/music/unlock--- +class UserMusicUnlockRequest(BaseRequest): + def __init__(self, data: Dict) -> None: + super().__init__(data) + self.profileId = self.params[0] + self.songId = self.params[1] + self.difficulty = self.params[2] + self.itemsUsed: List[GenericItemRecv] = [] + + for itm in self.params[3]: + self.itemsUsed.append(GenericItemRecv(itm[0], itm[1], itm[2])) + +class UserMusicUnlockResponse(BaseResponse): + def __init__(self, current_wp: int = 0, tickets_remaining: List = []) -> None: + super().__init__() + self.wp = current_wp + self.tickets: List[TicketItem] = [] + + for ticket in tickets_remaining: + self.tickets.append(TicketItem(ticket[0], ticket[1], ticket[2])) + + def make(self) -> List: + tickets = [] + + for ticket in self.tickets: + tickets.append(ticket.make()) + + self.params = [ + self.wp, + tickets + ] + + return super().make() + diff --git a/titles/wacca/handlers/user_status.py b/titles/wacca/handlers/user_status.py new file mode 100644 index 0000000..66d0bae --- /dev/null +++ b/titles/wacca/handlers/user_status.py @@ -0,0 +1,289 @@ +from typing import List, Dict, Optional + +from titles.wacca.handlers.base import BaseRequest, BaseResponse +from titles.wacca.handlers.helpers import * + +# ---user/status/get---- +class UserStatusGetRequest(BaseRequest): + aimeId: int = 0 + + def __init__(self, data: Dict) -> None: + super().__init__(data) + self.aimeId = int(data["params"][0]) + +class UserStatusGetV1Response(BaseResponse): + def __init__(self) -> None: + super().__init__() + self.userStatus: UserStatusV1 = UserStatusV1() + self.setTitleId: int = 0 + self.setIconId: int = 0 + self.profileStatus: ProfileStatus = ProfileStatus.ProfileGood + self.versionStatus: PlayVersionStatus = PlayVersionStatus.VersionGood + self.lastGameVersion: str = "" + + def make(self) -> Dict: + self.params = [ + self.userStatus.make(), + self.setTitleId, + self.setIconId, + self.profileStatus.value, + [ + self.versionStatus.value, + self.lastGameVersion + ] + ] + + return super().make() + +class UserStatusGetV2Response(UserStatusGetV1Response): + def __init__(self) -> None: + super().__init__() + self.userStatus: UserStatusV2 = UserStatusV2() + self.unknownArr: List = [] + + def make(self) -> Dict: + super().make() + + self.params.append(self.unknownArr) + + return super(UserStatusGetV1Response, self).make() + +# ---user/status/getDetail---- +class UserStatusGetDetailRequest(BaseRequest): + userId: int = 0 + + def __init__(self, data: Dict) -> None: + super().__init__(data) + self.userId = data["params"][0] + +class UserStatusGetDetailResponseV1(BaseResponse): + def __init__(self) -> None: + super().__init__() + self.userStatus: UserStatusV1 = UserStatusV1() + self.options: List[UserOption] = [] + self.seasonalPlayModeCounts: List[PlayModeCounts] = [] + self.userItems: UserItemInfoV1 = UserItemInfoV1() + self.scores: List[BestScoreDetailV1] = [] + self.songPlayStatus: List[int] = [0,0] + self.seasonInfo: SeasonalInfoV1 = [] + self.playAreaList: List = [ [0],[0,0,0,0,0,0],[0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0],[0,0,0,0,0],[0,0,0,0],[0,0,0,0,0,0,0],[0] ] + self.songUpdateTime: int = 0 + + def make(self) -> List: + opts = [] + play_modes = [] + scores = [] + + for x in self.seasonalPlayModeCounts: + play_modes.append(x.make()) + + for x in self.scores: + scores.append(x.make()) + + for x in self.options: + opts.append(x.make()) + + self.params = [ + self.userStatus.make(), + opts, + play_modes, + self.userItems.make(), + scores, + self.songPlayStatus, + self.seasonInfo.make(), + self.playAreaList, + self.songUpdateTime + ] + + return super().make() + + def find_score_idx(self, song_id: int, difficulty: int = 1, start_idx: int = 0, stop_idx: int = None) -> Optional[int]: + if stop_idx is None or stop_idx > len(self.scores): + stop_idx = len(self.scores) + + for x in range(start_idx, stop_idx): + if self.scores[x].songId == song_id and self.scores[x].difficulty == difficulty: + return x + + return None + +class UserStatusGetDetailResponseV2(UserStatusGetDetailResponseV1): + def __init__(self) -> None: + super().__init__() + self.userStatus: UserStatusV2 = UserStatusV2() + self.seasonInfo: SeasonalInfoV2 = SeasonalInfoV2() + self.userItems: UserItemInfoV2 = UserItemInfoV2() + self.favorites: List[int] = [] + self.stoppedSongIds: List[int] = [] + self.eventInfo: List[int] = [] + self.gateInfo: List[GateDetailV1] = [] + self.lastSongInfo: LastSongDetail = LastSongDetail() + self.gateTutorialFlags: List[GateTutorialFlag] = [] + self.gatchaInfo: List[GachaInfo] = [] + self.friendList: List[FriendDetail] = [] + + def make(self) -> List: + super().make() + gates = [] + friends = [] + tut_flg = [] + + for x in self.gateInfo: + gates.append(x.make()) + + for x in self.friendList: + friends.append(x.make()) + + for x in self.gateTutorialFlags: + tut_flg.append(x.make()) + + while len(tut_flg) < 5: + flag_id = len(tut_flg) + 1 + tut_flg.append([flag_id, 0]) + + self.params.append(self.favorites) + self.params.append(self.stoppedSongIds) + self.params.append(self.eventInfo) + self.params.append(gates) + self.params.append(self.lastSongInfo.make()) + self.params.append(tut_flg) + self.params.append(self.gatchaInfo) + self.params.append(friends) + + return super(UserStatusGetDetailResponseV1, self).make() + +class UserStatusGetDetailResponseV3(UserStatusGetDetailResponseV2): + def __init__(self) -> None: + super().__init__() + self.gateInfo: List[GateDetailV2] = [] + +class UserStatusGetDetailResponseV4(UserStatusGetDetailResponseV3): + def __init__(self) -> None: + super().__init__() + self.userItems: UserItemInfoV3 = UserItemInfoV3() + self.bingoStatus: BingoDetail = BingoDetail(0) + self.scores: List[BestScoreDetailV2] = [] + + def make(self) -> List: + super().make() + self.params.append(self.bingoStatus.make()) + + return super(UserStatusGetDetailResponseV1, self).make() + +# ---user/status/login---- +class UserStatusLoginRequest(BaseRequest): + userId: int = 0 + + def __init__(self, data: Dict) -> None: + super().__init__(data) + self.userId = data["params"][0] + +class UserStatusLoginResponseV1(BaseResponse): + def __init__(self, is_first_login_daily: bool = False, last_login_date: int = 0) -> None: + super().__init__() + self.dailyBonus: List[LoginBonusInfo] = [] + self.consecBonus: List[LoginBonusInfo] = [] + self.otherBonus: List[LoginBonusInfo] = [] + self.firstLoginDaily = is_first_login_daily + self.lastLoginDate = last_login_date + + def make(self) -> List: + daily = [] + consec = [] + other = [] + + for bonus in self.dailyBonus: + daily.append(bonus.make()) + + for bonus in self.consecBonus: + consec.append(bonus.make()) + + for bonus in self.otherBonus: + other.append(bonus.make()) + + self.params = [ daily, consec, other, int(self.firstLoginDaily)] + return super().make() + +class UserStatusLoginResponseV2(UserStatusLoginResponseV1): + vipInfo: VipInfo + lastLoginDate: int = 0 + + def __init__(self, is_first_login_daily: bool = False, last_login_date: int = 0) -> None: + super().__init__(is_first_login_daily) + self.lastLoginDate = last_login_date + + self.vipInfo = VipInfo() + + def make(self) -> List: + super().make() + self.params.append(self.vipInfo.make()) + self.params.append(self.lastLoginDate) + return super(UserStatusLoginResponseV1, self).make() + +class UserStatusLoginResponseV3(UserStatusLoginResponseV2): + unk: List = [] + + def make(self) -> List: + super().make() + self.params.append(self.unk) + return super(UserStatusLoginResponseV1, self).make() + +# ---user/status/create--- +class UserStatusCreateRequest(BaseRequest): + def __init__(self, data: Dict) -> None: + super().__init__(data) + self.aimeId = data["params"][0] + self.username = data["params"][1] + +class UserStatusCreateResponseV1(BaseResponse): + def __init__(self, userId: int, username: str) -> None: + super().__init__() + self.userStatus = UserStatusV1() + self.userStatus.userId = userId + self.userStatus.username = username + + def make(self) -> List: + self.params = [ + self.userStatus.make() + ] + return super().make() + +class UserStatusCreateResponseV2(UserStatusCreateResponseV1): + def __init__(self, userId: int, username: str) -> None: + super().__init__(userId, username) + self.userStatus: UserStatusV2 = UserStatusV2() + self.userStatus.userId = userId + self.userStatus.username = username + +# ---user/status/logout--- +class UserStatusLogoutRequest(BaseRequest): + userId: int + + def __init__(self, data: Dict) -> None: + super().__init__(data) + self.userId = data["params"][0] + +# ---user/status/update--- +class UserStatusUpdateRequestV1(BaseRequest): + def __init__(self, data: Dict) -> None: + super().__init__(data) + self.profileId: int = data["params"][0] + self.playType: PlayType = PlayType(data["params"][1]) + self.itemsRecieved: List[GenericItemRecv] = [] + + for itm in data["params"][2]: + self.itemsRecieved.append(GenericItemRecv(itm[0], itm[1], itm[2])) + +class UserStatusUpdateRequestV2(UserStatusUpdateRequestV1): + isContinue = False + isFirstPlayFree = False + itemsUsed = [] + lastSongInfo: LastSongDetail + + def __init__(self, data: Dict) -> None: + super().__init__(data) + self.isContinue = bool(data["params"][3]) + self.isFirstPlayFree = bool(data["params"][4]) + self.itemsUsed = data["params"][5] + self.lastSongInfo = LastSongDetail(data["params"][6][0], data["params"][6][1], + data["params"][6][2], data["params"][6][3], data["params"][6][4]) diff --git a/titles/wacca/handlers/user_trial.py b/titles/wacca/handlers/user_trial.py new file mode 100644 index 0000000..84bd44a --- /dev/null +++ b/titles/wacca/handlers/user_trial.py @@ -0,0 +1,48 @@ +from typing import Dict, List +from titles.wacca.handlers.base import BaseRequest, BaseResponse +from titles.wacca.handlers.helpers import StageInfo, StageupClearType + +# --user/trial/get-- +class UserTrialGetRequest(BaseRequest): + profileId: int = 0 + + def __init__(self, data: Dict) -> None: + super().__init__(data) + self.profileId = self.params[0] + +class UserTrialGetResponse(BaseResponse): + def __init__(self) -> None: + super().__init__() + + self.stageList: List[StageInfo] = [] + + def make(self) -> Dict: + dans = [] + for x in self.stageList: + dans.append(x.make()) + + self.params = [dans] + return super().make() + +# --user/trial/update-- +class UserTrialUpdateRequest(BaseRequest): + def __init__(self, data: Dict) -> None: + super().__init__(data) + self.profileId = self.params[0] + self.stageId = self.params[1] + self.stageLevel = self.params[2] + self.clearType = StageupClearType(self.params[3]) + self.songScores = self.params[4] + self.numSongsCleared = self.params[5] + self.itemsObtained = self.params[6] + self.unk7: List = [] + + if len(self.params) == 8: + self.unk7 = self.params[7] + +class UserTrialUpdateResponse(BaseResponse): + def __init__(self) -> None: + super().__init__() + + def make(self) -> Dict: + return super().make() \ No newline at end of file diff --git a/titles/wacca/handlers/user_vip.py b/titles/wacca/handlers/user_vip.py new file mode 100644 index 0000000..c48c9fa --- /dev/null +++ b/titles/wacca/handlers/user_vip.py @@ -0,0 +1,54 @@ +from typing import Dict, List +from titles.wacca.handlers.base import BaseRequest, BaseResponse +from titles.wacca.handlers.helpers import VipLoginBonus + +# --user/vip/get-- +class UserVipGetRequest(BaseRequest): + def __init__(self, data: Dict) -> None: + super().__init__(data) + self.profileId = self.params[0] + +class UserVipGetResponse(BaseResponse): + def __init__(self) -> None: + super().__init__() + self.vipDays: int = 0 + self.unknown1: int = 1 + self.unknown2: int = 1 + self.presents: List[VipLoginBonus] = [] + + def make(self) -> Dict: + pres = [] + for x in self.presents: + pres.append(x.make()) + + self.params = [ + self.vipDays, + [ + self.unknown1, + self.unknown2, + pres + ] + ] + return super().make() + +# --user/vip/start-- +class UserVipStartRequest(BaseRequest): + def __init__(self, data: Dict) -> None: + super().__init__(data) + self.profileId = self.params[0] + self.cost = self.params[1] + self.days = self.params[2] + +class UserVipStartResponse(BaseResponse): + def __init__(self, expires: int = 0) -> None: + super().__init__() + self.whenExpires: int = expires + self.presents = [] + + def make(self) -> Dict: + self.params = [ + self.whenExpires, + self.presents + ] + + return super().make() \ No newline at end of file diff --git a/titles/wacca/index.py b/titles/wacca/index.py new file mode 100644 index 0000000..963fa7a --- /dev/null +++ b/titles/wacca/index.py @@ -0,0 +1,126 @@ +import yaml +import logging, coloredlogs +from logging.handlers import TimedRotatingFileHandler +import logging +import json +from datetime import datetime +from hashlib import md5 +from twisted.web.http import Request +from typing import Dict + +from core.config import CoreConfig +from titles.wacca.config import WaccaConfig +from titles.wacca.config import WaccaConfig +from titles.wacca.const import WaccaConstants +from titles.wacca.reverse import WaccaReverse +from titles.wacca.lilyr import WaccaLilyR +from titles.wacca.lily import WaccaLily +from titles.wacca.s import WaccaS +from titles.wacca.base import WaccaBase +from titles.wacca.handlers.base import BaseResponse + +class WaccaServlet(): + def __init__(self, core_cfg: CoreConfig, cfg_dir: str) -> None: + self.core_cfg = core_cfg + self.game_cfg = WaccaConfig() + self.game_cfg.update(yaml.safe_load(open(f"{cfg_dir}/wacca.yaml"))) + + self.versions = [ + WaccaBase(core_cfg, self.game_cfg), + WaccaS(core_cfg, self.game_cfg), + WaccaLily(core_cfg, self.game_cfg), + WaccaLilyR(core_cfg, self.game_cfg), + WaccaReverse(core_cfg, self.game_cfg), + ] + + self.logger = logging.getLogger("wacca") + log_fmt_str = "[%(asctime)s] Wacca | %(levelname)s | %(message)s" + log_fmt = logging.Formatter(log_fmt_str) + fileHandler = TimedRotatingFileHandler("{0}/{1}.log".format(self.core_cfg.server.log_dir, "wacca"), encoding='utf8', + when="d", backupCount=10) + + fileHandler.setFormatter(log_fmt) + + consoleHandler = logging.StreamHandler() + consoleHandler.setFormatter(log_fmt) + + self.logger.addHandler(fileHandler) + self.logger.addHandler(consoleHandler) + + self.logger.setLevel(self.game_cfg.server.loglevel) + coloredlogs.install(level=self.game_cfg.server.loglevel, logger=self.logger, fmt=log_fmt_str) + + def render_POST(self, request: Request, version: int, url_path: str) -> bytes: + def end(resp: Dict) -> bytes: + hash = md5(json.dumps(resp, ensure_ascii=False).encode()).digest() + request.responseHeaders.addRawHeader(b"X-Wacca-Hash", hash.hex().encode()) + return json.dumps(resp).encode() + + version_full = [] + + try: + req_json = json.loads(request.content.getvalue()) + version_full = req_json["appVersion"].split(".") + except: + self.logger.error(f"Failed to parse request toi {request.uri} -> {request.content.getvalue()}") + resp = BaseResponse() + resp.status = 1 + resp.message = "不正なリクエスト エラーです" + return end(resp.make()) + + url_split = url_path.split("/") + start_req_idx = url_split.index("api") + 1 + + func_to_find = "handle_" + for x in range(len(url_split) - start_req_idx): + func_to_find += f"{url_split[x + start_req_idx]}_" + func_to_find += "request" + + ver_search = (int(version_full[0]) * 10000) + (int(version_full[1]) * 100) + int(version_full[2]) + + if ver_search < 15000: + internal_ver = WaccaConstants.VER_WACCA + + elif ver_search >= 15000 and ver_search < 20000: + internal_ver = WaccaConstants.VER_WACCA_S + + elif ver_search >= 20000 and ver_search < 25000: + internal_ver = WaccaConstants.VER_WACCA_LILY + + elif ver_search >= 25000 and ver_search < 30000: + internal_ver = WaccaConstants.VER_WACCA_LILY_R + + elif ver_search >= 30000: + internal_ver = WaccaConstants.VER_WACCA_REVERSE + + else: + self.logger.warning(f"Unsupported version ({req_json['appVersion']}) request {url_path} - {req_json}") + resp = BaseResponse() + resp.status = 1 + resp.message = "不正なアプリバージョンエラーです" + return end(resp.make()) + + self.logger.info(f"v{req_json['appVersion']} {url_path} request from {request.getClientAddress().host} with chipId {req_json['chipId']}") + self.logger.debug(req_json) + + try: + handler = getattr(self.versions[internal_ver], func_to_find) + if handler is not None: + resp = handler(req_json) + + else: + self.logger.warn(f"{req_json['appVersion']} has no handler for {func_to_find}") + resp = None + + if resp is None: + resp = BaseResponse().make() + + self.logger.debug(f"{req_json['appVersion']} response {resp}") + return end(resp) + + except Exception as e: + self.logger.error(f"{req_json['appVersion']} Error handling method {url_path} -> {e}") + if self.game_cfg.server.loglevel <= logging.DEBUG: + raise + resp = BaseResponse().make() + return end(resp) diff --git a/titles/wacca/lily.py b/titles/wacca/lily.py new file mode 100644 index 0000000..7f9580f --- /dev/null +++ b/titles/wacca/lily.py @@ -0,0 +1,351 @@ +from typing import Any, List, Dict +from datetime import datetime, timedelta +import json + +from core.config import CoreConfig +from titles.wacca.s import WaccaS +from titles.wacca.config import WaccaConfig +from titles.wacca.const import WaccaConstants + +from titles.wacca.handlers import * + +class WaccaLily(WaccaS): + def __init__(self, cfg: CoreConfig, game_cfg: WaccaConfig) -> None: + super().__init__(cfg, game_cfg) + self.version = WaccaConstants.VER_WACCA_LILY + self.season = 2 + + self.OPTIONS_DEFAULTS["set_nav_id"] = 210002 + self.allowed_stages = [ + (2001, 1), + (2002, 2), + (2003, 3), + (2004, 4), + (2005, 5), + (2006, 6), + (2007, 7), + (2008, 8), + (2009, 9), + (2010, 10), + (2011, 11), + (2012, 12), + (2013, 13), + (2014, 14), + (210001, 0), + (210002, 0), + (210003, 0), + ] + + def handle_user_status_get_request(self, data: Dict) -> List[Any]: + req = UserStatusGetRequest(data) + resp = UserStatusGetV2Response() + ver_split = req.appVersion.split(".") + + profile = self.data.profile.get_profile(aime_id=req.aimeId) + if profile is None: + self.logger.info(f"No user exists for aime id {req.aimeId}") + resp.profileStatus = ProfileStatus.ProfileRegister + return resp.make() + + self.logger.info(f"User preview for {req.aimeId} from {req.chipId}") + if profile["last_game_ver"] is None: + profile_ver_split = ver_split + resp.lastGameVersion = req.appVersion + else: + profile_ver_split = profile["last_game_ver"].split(".") + resp.lastGameVersion = profile["last_game_ver"] + + resp.userStatus.userId = profile["id"] + resp.userStatus.username = profile["username"] + resp.userStatus.xp = profile["xp"] + resp.userStatus.danLevel = profile["dan_level"] + resp.userStatus.danType = profile["dan_type"] + resp.userStatus.wp = profile["wp"] + resp.userStatus.useCount = profile["login_count"] + resp.userStatus.loginDays = profile["login_count_days"] + resp.userStatus.loginConsecutiveDays = profile["login_count_days_consec"] + resp.userStatus.loginsToday = profile["login_count_today"] + resp.userStatus.rating = profile["rating"] + + set_title_id = self.data.profile.get_options(WaccaConstants.OPTIONS["set_title_id"], profile["user"]) + if set_title_id is None: + set_title_id = self.OPTIONS_DEFAULTS["set_title_id"] + resp.setTitleId = set_title_id + + set_icon_id = self.data.profile.get_options(WaccaConstants.OPTIONS["set_title_id"], profile["user"]) + if set_icon_id is None: + set_icon_id = self.OPTIONS_DEFAULTS["set_icon_id"] + resp.setIconId = set_icon_id + + if profile["last_login_date"].timestamp() < int(datetime.now().replace(hour=0,minute=0,second=0,microsecond=0).timestamp()): + resp.userStatus.loginsToday = 0 + + if profile["last_login_date"].timestamp() < int((datetime.now().replace(hour=0,minute=0,second=0,microsecond=0) - timedelta(days=1)).timestamp()): + resp.userStatus.loginConsecutiveDays = 0 + + if int(ver_split[0]) > int(profile_ver_split[0]): + resp.versionStatus = PlayVersionStatus.VersionUpgrade + + elif int(ver_split[0]) < int(profile_ver_split[0]): + resp.versionStatus = PlayVersionStatus.VersionTooNew + + else: + if int(ver_split[1]) > int(profile_ver_split[1]): + resp.versionStatus = PlayVersionStatus.VersionUpgrade + + elif int(ver_split[1]) < int(profile_ver_split[1]): + resp.versionStatus = PlayVersionStatus.VersionTooNew + + else: + if int(ver_split[2]) > int(profile_ver_split[2]): + resp.versionStatus = PlayVersionStatus.VersionUpgrade + + + elif int(ver_split[2]) < int(profile_ver_split[2]): + resp.versionStatus = PlayVersionStatus.VersionTooNew + + if profile["vip_expire_time"] is not None: + resp.userStatus.vipExpireTime = int(profile["vip_expire_time"].timestamp()) + + if profile["always_vip"] or self.game_config.mods.always_vip: + resp.userStatus.vipExpireTime = int((datetime.now() + timedelta(days=30)).timestamp()) + + if self.game_config.mods.infinite_wp: + resp.userStatus.wp = 999999 + + return resp.make() + + def handle_user_status_login_request(self, data: Dict) -> List[Any]: + req = UserStatusLoginRequest(data) + resp = UserStatusLoginResponseV2() + is_new_day = False + is_consec_day = False + is_consec_day = True + + if req.userId == 0: + self.logger.info(f"Guest login on {req.chipId}") + resp.lastLoginDate = 0 + + else: + profile = self.data.profile.get_profile(req.userId) + if profile is None: + self.logger.warn(f"Unknown user id {req.userId} attempted login from {req.chipId}") + return resp.make() + + self.logger.info(f"User {req.userId} login on {req.chipId}") + last_login_time = int(profile["last_login_date"].timestamp()) + resp.lastLoginDate = last_login_time + + # If somebodies login timestamp < midnight of current day, then they are logging in for the first time today + if last_login_time < int(datetime.now().replace(hour=0,minute=0,second=0,microsecond=0).timestamp()): + is_new_day = True + is_consec_day = True + + # If somebodies login timestamp > midnight of current day + 1 day, then they broke their daily login streak + elif last_login_time > int((datetime.now().replace(hour=0,minute=0,second=0,microsecond=0) + timedelta(days=1)).timestamp()): + is_consec_day = False + # else, they are simply logging in again on the same day, and we don't need to do anything for that + + self.data.profile.session_login(req.userId, is_new_day, is_consec_day) + resp.vipInfo.pageYear = datetime.now().year + resp.vipInfo.pageMonth = datetime.now().month + resp.vipInfo.pageDay = datetime.now().day + resp.vipInfo.numItem = 1 + + resp.firstLoginDaily = int(is_new_day) + + return resp.make() + + def handle_user_status_getDetail_request(self, data: Dict) -> List[Any]: + req = UserStatusGetDetailRequest(data) + ver_split = req.appVersion.split(".") + if int(ver_split[1]) >= 53: + resp = UserStatusGetDetailResponseV3() + else: + resp = UserStatusGetDetailResponseV2() + + profile = self.data.profile.get_profile(req.userId) + if profile is None: + self.logger.warn(f"Unknown profile {req.userId}") + return resp.make() + + self.logger.info(f"Get detail for profile {req.userId}") + user_id = profile["user"] + + profile_scores = self.data.score.get_best_scores(user_id) + profile_items = self.data.item.get_items(user_id) + profile_song_unlocks = self.data.item.get_song_unlocks(user_id) + profile_options = self.data.profile.get_options(user_id) + profile_favorites = self.data.profile.get_favorite_songs(user_id) + profile_gates = self.data.profile.get_gates(user_id) + profile_trophies = self.data.item.get_trophies(user_id) + profile_tickets = self.data.item.get_tickets(user_id) + + if profile["vip_expire_time"] is None: + resp.userStatus.vipExpireTime = 0 + + else: + resp.userStatus.vipExpireTime = int(profile["vip_expire_time"].timestamp()) + + if profile["always_vip"] or self.game_config.mods.always_vip: + resp.userStatus.vipExpireTime = int((self.srvtime + timedelta(days=31)).timestamp()) + + resp.songUpdateTime = int(profile["last_login_date"].timestamp()) + resp.lastSongInfo = LastSongDetail(profile["last_song_id"],profile["last_song_difficulty"],profile["last_folder_order"],profile["last_folder_id"],profile["last_song_order"]) + resp.songPlayStatus = [resp.lastSongInfo.lastSongId, 1] + + resp.userStatus.userId = profile["id"] + resp.userStatus.username = profile["username"] + resp.userStatus.xp = profile["xp"] + resp.userStatus.danLevel = profile["dan_level"] + resp.userStatus.danType = profile["dan_type"] + resp.userStatus.wp = profile["wp"] + resp.userStatus.useCount = profile["login_count"] + resp.userStatus.loginDays = profile["login_count_days"] + resp.userStatus.loginConsecutiveDays = profile["login_count_days_consec"] + resp.userStatus.loginsToday = profile["login_count_today"] + resp.userStatus.rating = profile['rating'] + + if self.game_config.mods.infinite_wp: + resp.userStatus.wp = 999999 + + for fav in profile_favorites: + resp.favorites.append(fav["song_id"]) + + if profile["friend_view_1"] is not None: + pass + if profile["friend_view_2"] is not None: + pass + if profile["friend_view_3"] is not None: + pass + + resp.seasonalPlayModeCounts.append(PlayModeCounts(self.season, 1, profile["playcount_single"])) + resp.seasonalPlayModeCounts.append(PlayModeCounts(self.season, 2, profile["playcount_multi_vs"])) + resp.seasonalPlayModeCounts.append(PlayModeCounts(self.season, 3, profile["playcount_multi_coop"])) + resp.seasonalPlayModeCounts.append(PlayModeCounts(self.season, 4, profile["playcount_stageup"])) + + for opt in profile_options: + resp.options.append(UserOption(opt["opt_id"], opt["value"])) + + for gate in self.game_config.gates.enabled_gates: + added_gate = False + + for user_gate in profile_gates: + if user_gate["gate_id"] == gate: + if int(ver_split[1]) >= 53: + resp.gateInfo.append(GateDetailV2(user_gate["gate_id"],user_gate["page"],user_gate["progress"], + user_gate["loops"],int(user_gate["last_used"].timestamp()),user_gate["mission_flag"])) + + else: + resp.gateInfo.append(GateDetailV1(user_gate["gate_id"],user_gate["page"],user_gate["progress"], + user_gate["loops"],int(user_gate["last_used"].timestamp()),user_gate["mission_flag"])) + + resp.seasonInfo.cumulativeGatePts += user_gate["total_points"] + + added_gate = True + break + + if not added_gate: + if int(ver_split[1]) >= 53: + resp.gateInfo.append(GateDetailV2(gate)) + + else: + resp.gateInfo.append(GateDetailV1(gate)) + + for unlock in profile_song_unlocks: + for x in range(1, unlock["highest_difficulty"] + 1): + resp.userItems.songUnlocks.append(SongUnlock(unlock["song_id"], x, 0, int(unlock["acquire_date"].timestamp()))) + if x > 2: + resp.scores.append(BestScoreDetailV1(unlock["song_id"], x)) + + empty_scores = len(resp.scores) + for song in profile_scores: + resp.seasonInfo.cumulativeScore += song["score"] + empty_score_idx = resp.find_score_idx(song["song_id"], song["chart_id"], 0, empty_scores) + + clear_cts = SongDetailClearCounts( + song["play_ct"], + song["clear_ct"], + song["missless_ct"], + song["fullcombo_ct"], + song["allmarv_ct"], + ) + + grade_cts = SongDetailGradeCountsV1( + song["grade_d_ct"], song["grade_c_ct"], song["grade_b_ct"], song["grade_a_ct"], song["grade_aa_ct"], + song["grade_aaa_ct"], song["grade_s_ct"], song["grade_ss_ct"], song["grade_sss_ct"], + song["grade_master_ct"] + ) + + if empty_score_idx is not None: + resp.scores[empty_score_idx].clearCounts = clear_cts + resp.scores[empty_score_idx].clearCountsSeason = clear_cts + resp.scores[empty_score_idx].gradeCounts = grade_cts + resp.scores[empty_score_idx].score = song["score"] + resp.scores[empty_score_idx].bestCombo = song["best_combo"] + resp.scores[empty_score_idx].lowestMissCtMaybe = song["lowest_miss_ct"] + resp.scores[empty_score_idx].rating = song["rating"] + + else: + deets = BestScoreDetailV1(song["song_id"], song["chart_id"]) + deets.clearCounts = clear_cts + deets.clearCountsSeason = clear_cts + deets.gradeCounts = grade_cts + deets.score = song["score"] + deets.bestCombo = song["best_combo"] + deets.lowestMissCtMaybe = song["lowest_miss_ct"] + deets.rating = song["rating"] + + for trophy in profile_trophies: + resp.userItems.trophies.append(TrophyItem(trophy["trophy_id"], trophy["season"], trophy["progress"], trophy["badge_type"])) + + if self.game_config.mods.infinite_tickets: + for x in range(5): + resp.userItems.tickets.append(TicketItem(x, 106002, 0)) + else: + for ticket in profile_tickets: + if ticket["expire_date"] is None: + expire = int((self.srvtime + timedelta(days=30)).timestamp()) + else: + expire = int(ticket["expire_date"].timestamp()) + + resp.userItems.tickets.append(TicketItem(ticket["id"], ticket["ticket_id"], expire)) + + if profile_items: + for item in profile_items: + try: + + if item["type"] == WaccaConstants.ITEM_TYPES["icon"]: + resp.userItems.icons.append(IconItem(item["item_id"], 1, item["use_count"], int(item["acquire_date"].timestamp()))) + + elif item["type"] == WaccaConstants.ITEM_TYPES["navigator"]: + resp.userItems.navigators.append(NavigatorItem(item["item_id"], 1, int(item["acquire_date"].timestamp()), item["use_count"], item["use_count"])) + + else: + itm_send = GenericItemSend(item["item_id"], 1, int(item["acquire_date"].timestamp())) + + if item["type"] == WaccaConstants.ITEM_TYPES["title"]: + resp.userItems.titles.append(itm_send) + + elif item["type"] == WaccaConstants.ITEM_TYPES["user_plate"]: + resp.userItems.plates.append(itm_send) + + elif item["type"] == WaccaConstants.ITEM_TYPES["note_color"]: + resp.userItems.noteColors.append(itm_send) + + elif item["type"] == WaccaConstants.ITEM_TYPES["note_sound"]: + resp.userItems.noteSounds.append(itm_send) + + except: + self.logger.error(f"{__name__} Failed to load item {item['item_id']} for user {profile['user']}") + + resp.seasonInfo.level = profile["xp"] + resp.seasonInfo.wpObtained = profile["wp_total"] + resp.seasonInfo.wpSpent = profile["wp_spent"] + resp.seasonInfo.titlesObtained = len(resp.userItems.titles) + resp.seasonInfo.iconsObtained = len(resp.userItems.icons) + resp.seasonInfo.noteColorsObtained = len(resp.userItems.noteColors) + resp.seasonInfo.noteSoundsObtained = len(resp.userItems.noteSounds) + resp.seasonInfo.platesObtained = len(resp.userItems.plates) + + return resp.make() \ No newline at end of file diff --git a/titles/wacca/lilyr.py b/titles/wacca/lilyr.py new file mode 100644 index 0000000..a359725 --- /dev/null +++ b/titles/wacca/lilyr.py @@ -0,0 +1,54 @@ +from typing import Any, List, Dict +from datetime import datetime, timedelta +import json + +from core.config import CoreConfig +from titles.wacca.lily import WaccaLily +from titles.wacca.config import WaccaConfig +from titles.wacca.const import WaccaConstants +from titles.wacca.handlers import * + +class WaccaLilyR(WaccaLily): + def __init__(self, cfg: CoreConfig, game_cfg: WaccaConfig) -> None: + super().__init__(cfg, game_cfg) + self.version = WaccaConstants.VER_WACCA_LILY_R + self.season = 2 + + self.OPTIONS_DEFAULTS["set_nav_id"] = 210002 + self.allowed_stages = [ + (2501, 1), + (2502, 2), + (2503, 3), + (2504, 4), + (2505, 5), + (2506, 6), + (2507, 7), + (2508, 8), + (2509, 9), + (2510, 10), + (2511, 11), + (2512, 12), + (2513, 13), + (2514, 14), + (210001, 0), + (210002, 0), + (210003, 0), + ] + + def handle_user_status_create_request(self, data: Dict) -> List[Any]: + req = UserStatusCreateRequest(data) + resp = super().handle_user_status_create_request(data) + + self.data.item.put_item(req.aimeId, WaccaConstants.ITEM_TYPES["navigator"], 210054) # Added lily r + self.data.item.put_item(req.aimeId, WaccaConstants.ITEM_TYPES["navigator"], 210055) # Added lily r + self.data.item.put_item(req.aimeId, WaccaConstants.ITEM_TYPES["navigator"], 210056) # Added lily r + self.data.item.put_item(req.aimeId, WaccaConstants.ITEM_TYPES["navigator"], 210057) # Added lily r + self.data.item.put_item(req.aimeId, WaccaConstants.ITEM_TYPES["navigator"], 210058) # Added lily r + self.data.item.put_item(req.aimeId, WaccaConstants.ITEM_TYPES["navigator"], 210059) # Added lily r + self.data.item.put_item(req.aimeId, WaccaConstants.ITEM_TYPES["navigator"], 210060) # Added lily r + self.data.item.put_item(req.aimeId, WaccaConstants.ITEM_TYPES["navigator"], 210061) # Added lily r + + return resp + + def handle_user_status_logout_request(self, data: Dict) -> List[Any]: + return BaseResponse().make() diff --git a/titles/wacca/read.py b/titles/wacca/read.py new file mode 100644 index 0000000..1c8e7f8 --- /dev/null +++ b/titles/wacca/read.py @@ -0,0 +1,80 @@ +from typing import Optional +import wacky +import json +from os import walk, path + +from read import BaseReader +from core.config import CoreConfig +from titles.wacca.database import WaccaData +from titles.wacca.const import WaccaConstants + +class WaccaReader(BaseReader): + def __init__(self, config: CoreConfig, version: int, bin_dir: Optional[str], opt_dir: Optional[str], extra: Optional[str]) -> None: + super().__init__(config, version, bin_dir, opt_dir, extra) + self.data = WaccaData(config) + + try: + self.logger.info(f"Start importer for {WaccaConstants.game_ver_to_string(version)}") + except IndexError: + self.logger.error(f"Invalid wacca version {version}") + exit(1) + + def read(self) -> None: + if not (path.exists(f"{self.bin_dir}/Table") and path.exists(f"{self.bin_dir}/Message")): + self.logger.error("Could not find Table or Message folder, nothing to read") + return + + self.read_music(f"{self.bin_dir}/Table", "MusicParameterTable") + + def read_music(self, base_dir: str, table: str) -> None: + if not self.check_valid_pair(base_dir, table): + self.logger.warn(f"Cannot find {table} uasset/uexp pair at {base_dir}, music will not be read") + return + + uasset=open(f"{base_dir}/{table}.uasset", "rb") + uexp=open(f"{base_dir}/{table}.uexp", "rb") + + package = wacky.jsonify(uasset,uexp) + package_json = json.dumps(package, indent=4, sort_keys=True) + data=json.loads(package_json) + + first_elem = data[0] + wacca_data = first_elem['rows'] + + for i, key in enumerate(wacca_data): + song_id = int(key) + title = wacca_data[str(key)]["MusicMessage"] + artist = wacca_data[str(key)]["ArtistMessage"] + bpm = wacca_data[str(key)]["Bpm"] + jacket_asset_name = wacca_data[str(key)]["JacketAssetName"] + + diff = float(wacca_data[str(key)]["DifficultyNormalLv"]) + designer = wacca_data[str(key)]["NotesDesignerNormal"] + + if diff > 0: + self.data.static.put_music(self.version, song_id, 1, title, artist, bpm, diff, designer, jacket_asset_name) + self.logger.info(f"Read song {song_id} chart 1") + + diff = float(wacca_data[str(key)]["DifficultyHardLv"]) + designer = wacca_data[str(key)]["NotesDesignerHard"] + + if diff > 0: + self.data.static.put_music(self.version, song_id, 2, title, artist, bpm, diff, designer, jacket_asset_name) + self.logger.info(f"Read song {song_id} chart 2") + + diff = float(wacca_data[str(key)]["DifficultyExtremeLv"]) + designer = wacca_data[str(key)]["NotesDesignerExpert"] + + if diff > 0: + self.data.static.put_music(self.version, song_id, 3, title, artist, bpm, diff, designer, jacket_asset_name) + self.logger.info(f"Read song {song_id} chart 3") + + diff = float(wacca_data[str(key)]["DifficultyInfernoLv"]) + designer = wacca_data[str(key)]["NotesDesignerInferno"] + + if diff > 0: + self.data.static.put_music(self.version, song_id, 4, title, artist, bpm, diff, designer, jacket_asset_name) + self.logger.info(f"Read song {song_id} chart 4") + + def check_valid_pair(self, dir: str, file: str) -> bool: + return path.exists(f"{dir}/{file}.uasset") and path.exists(f"{dir}/{file}.uexp") \ No newline at end of file diff --git a/titles/wacca/reverse.py b/titles/wacca/reverse.py new file mode 100644 index 0000000..3d2b571 --- /dev/null +++ b/titles/wacca/reverse.py @@ -0,0 +1,258 @@ +from typing import Any, List, Dict +from datetime import datetime, timedelta +import json + +from core.config import CoreConfig +from titles.wacca.lilyr import WaccaLilyR +from titles.wacca.config import WaccaConfig +from titles.wacca.const import WaccaConstants + +from titles.wacca.handlers import * + +class WaccaReverse(WaccaLilyR): + def __init__(self, cfg: CoreConfig, game_cfg: WaccaConfig) -> None: + super().__init__(cfg, game_cfg) + self.version = WaccaConstants.VER_WACCA_REVERSE + + self.season = 3 + + self.OPTIONS_DEFAULTS["set_nav_id"] = 310001 + self.allowed_stages = [ + (3001, 1), + (3002, 2), + (3003, 3), + (3004, 4), + (3005, 5), + (3006, 6), + (3007, 7), + (3008, 8), + (3009, 9), + (3010, 10), + (3011, 11), + (3012, 12), + (3013, 13), + (3014, 14), + # Touhou + (210001, 0), + (210002, 0), + (210003, 0), + # Final spurt + (310001, 0), + (310002, 0), + (310003, 0), + # boss remix + (310004, 0), + (310005, 0), + (310006, 0), + ] + + def handle_user_status_login_request(self, data: Dict) -> List[Any]: + resp = super().handle_user_status_login_request(data) + resp["params"].append([]) + return resp + + def handle_user_status_getDetail_request(self, data: Dict) -> List[Any]: + req = UserStatusGetDetailRequest(data) + resp = UserStatusGetDetailResponseV4() + + profile = self.data.profile.get_profile(req.userId) + if profile is None: + self.logger.warn(f"Unknown profile {req.userId}") + return resp.make() + + self.logger.info(f"Get detail for profile {req.userId}") + user_id = profile["user"] + + profile_scores = self.data.score.get_best_scores(user_id) + profile_items = self.data.item.get_items(user_id) + profile_song_unlocks = self.data.item.get_song_unlocks(user_id) + profile_options = self.data.profile.get_options(user_id) + profile_favorites = self.data.profile.get_favorite_songs(user_id) + profile_gates = self.data.profile.get_gates(user_id) + profile_bingo = self.data.profile.get_bingo(user_id) + profile_trophies = self.data.item.get_trophies(user_id) + profile_tickets = self.data.item.get_tickets(user_id) + + if profile["gate_tutorial_flags"] is not None: + for x in profile["gate_tutorial_flags"]: + resp.gateTutorialFlags.append(GateTutorialFlag(x[0], x[1])) + + if profile["vip_expire_time"] is None: + resp.userStatus.vipExpireTime = 0 + + else: + resp.userStatus.vipExpireTime = int(profile["vip_expire_time"].timestamp()) + + if profile["always_vip"] or self.game_config.mods.always_vip: + resp.userStatus.vipExpireTime = int((self.srvtime + timedelta(days=31)).timestamp()) + + resp.songUpdateTime = int(profile["last_login_date"].timestamp()) + resp.lastSongInfo = LastSongDetail(profile["last_song_id"],profile["last_song_difficulty"],profile["last_folder_order"],profile["last_folder_id"],profile["last_song_order"]) + resp.songPlayStatus = [resp.lastSongInfo.lastSongId, 1] + + resp.userStatus.userId = profile["id"] + resp.userStatus.username = profile["username"] + resp.userStatus.xp = profile["xp"] + resp.userStatus.danLevel = profile["dan_level"] + resp.userStatus.danType = profile["dan_type"] + resp.userStatus.wp = profile["wp"] + resp.userStatus.useCount = profile["login_count"] + resp.userStatus.loginDays = profile["login_count_days"] + resp.userStatus.loginConsecutiveDays = profile["login_count_days_consec"] + resp.userStatus.loginsToday = profile["login_count_today"] + resp.userStatus.rating = profile['rating'] + + if self.game_config.mods.infinite_wp: + resp.userStatus.wp = 999999 + + for fav in profile_favorites: + resp.favorites.append(fav["song_id"]) + + if profile["friend_view_1"] is not None: + pass + if profile["friend_view_2"] is not None: + pass + if profile["friend_view_3"] is not None: + pass + + resp.seasonalPlayModeCounts.append(PlayModeCounts(self.season, 1, profile["playcount_single"])) + resp.seasonalPlayModeCounts.append(PlayModeCounts(self.season, 2, profile["playcount_multi_vs"])) + resp.seasonalPlayModeCounts.append(PlayModeCounts(self.season, 3, profile["playcount_multi_coop"])) + resp.seasonalPlayModeCounts.append(PlayModeCounts(self.season, 4, profile["playcount_stageup"])) + + for opt in profile_options: + resp.options.append(UserOption(opt["opt_id"], opt["value"])) + + if profile_bingo is not None: + resp.bingoStatus = BingoDetail(profile_bingo["page_number"]) + for x in profile_bingo["page_progress"]: + resp.bingoStatus.pageStatus.append(BingoPageStatus(x[0], x[1], x[2])) + + for gate in self.game_config.gates.enabled_gates: + added_gate = False + + for user_gate in profile_gates: + if user_gate["gate_id"] == gate: + + resp.gateInfo.append(GateDetailV2(user_gate["gate_id"],user_gate["page"],user_gate["progress"], + user_gate["loops"],int(user_gate["last_used"].timestamp()),user_gate["mission_flag"])) + + resp.seasonInfo.cumulativeGatePts += user_gate["total_points"] + + added_gate = True + break + + if not added_gate: + resp.gateInfo.append(GateDetailV2(gate)) + + for unlock in profile_song_unlocks: + for x in range(1, unlock["highest_difficulty"] + 1): + resp.userItems.songUnlocks.append(SongUnlock(unlock["song_id"], x, 0, int(unlock["acquire_date"].timestamp()))) + if x > 2: + resp.scores.append(BestScoreDetailV2(unlock["song_id"], x)) + + empty_scores = len(resp.scores) + for song in profile_scores: + resp.seasonInfo.cumulativeScore += song["score"] + empty_score_idx = resp.find_score_idx(song["song_id"], song["chart_id"], 0, empty_scores) + + clear_cts = SongDetailClearCounts( + song["play_ct"], + song["clear_ct"], + song["missless_ct"], + song["fullcombo_ct"], + song["allmarv_ct"], + ) + + grade_cts = SongDetailGradeCountsV2( + song["grade_d_ct"], song["grade_c_ct"], song["grade_b_ct"], song["grade_a_ct"], song["grade_aa_ct"], + song["grade_aaa_ct"], song["grade_s_ct"], song["grade_ss_ct"], song["grade_sss_ct"], + song["grade_master_ct"], song["grade_sp_ct"], song["grade_ssp_ct"], song["grade_sssp_ct"] + ) + + if empty_score_idx is not None: + resp.scores[empty_score_idx].clearCounts = clear_cts + resp.scores[empty_score_idx].clearCountsSeason = clear_cts + resp.scores[empty_score_idx].gradeCounts = grade_cts + resp.scores[empty_score_idx].score = song["score"] + resp.scores[empty_score_idx].bestCombo = song["best_combo"] + resp.scores[empty_score_idx].lowestMissCtMaybe = song["lowest_miss_ct"] + resp.scores[empty_score_idx].rating = song["rating"] + + else: + deets = BestScoreDetailV2(song["song_id"], song["chart_id"]) + deets.clearCounts = clear_cts + deets.clearCountsSeason = clear_cts + deets.gradeCounts = grade_cts + deets.score = song["score"] + deets.bestCombo = song["best_combo"] + deets.lowestMissCtMaybe = song["lowest_miss_ct"] + deets.rating = song["rating"] + resp.scores.append(deets) + + for trophy in profile_trophies: + resp.userItems.trophies.append(TrophyItem(trophy["trophy_id"], trophy["season"], trophy["progress"], trophy["badge_type"])) + + if self.game_config.mods.infinite_tickets: + for x in range(5): + resp.userItems.tickets.append(TicketItem(x, 106002, 0)) + else: + for ticket in profile_tickets: + if ticket["expire_date"] is None: + expire = int((self.srvtime + timedelta(days=30)).timestamp()) + else: + expire = int(ticket["expire_date"].timestamp()) + + resp.userItems.tickets.append(TicketItem(ticket["id"], ticket["ticket_id"], expire)) + + if profile_items: + for item in profile_items: + try: + + if item["type"] == WaccaConstants.ITEM_TYPES["icon"]: + resp.userItems.icons.append(IconItem(item["item_id"], 1, item["use_count"], int(item["acquire_date"].timestamp()))) + + elif item["type"] == WaccaConstants.ITEM_TYPES["navigator"]: + resp.userItems.navigators.append(NavigatorItem(item["item_id"], 1, int(item["acquire_date"].timestamp()), item["use_count"], item["use_count"])) + + else: + itm_send = GenericItemSend(item["item_id"], 1, int(item["acquire_date"].timestamp())) + + if item["type"] == WaccaConstants.ITEM_TYPES["title"]: + resp.userItems.titles.append(itm_send) + + elif item["type"] == WaccaConstants.ITEM_TYPES["user_plate"]: + resp.userItems.plates.append(itm_send) + + elif item["type"] == WaccaConstants.ITEM_TYPES["touch_effect"]: + resp.userItems.touchEffect.append(itm_send) + + elif item["type"] == WaccaConstants.ITEM_TYPES["note_color"]: + resp.userItems.noteColors.append(itm_send) + + elif item["type"] == WaccaConstants.ITEM_TYPES["note_sound"]: + resp.userItems.noteSounds.append(itm_send) + + except: + self.logger.error(f"{__name__} Failed to load item {item['item_id']} for user {profile['user']}") + + resp.seasonInfo.level = profile["xp"] + resp.seasonInfo.wpObtained = profile["wp_total"] + resp.seasonInfo.wpSpent = profile["wp_spent"] + resp.seasonInfo.titlesObtained = len(resp.userItems.titles) + resp.seasonInfo.iconsObtained = len(resp.userItems.icons) + resp.seasonInfo.noteColorsObtained = len(resp.userItems.noteColors) + resp.seasonInfo.noteSoundsObtained = len(resp.userItems.noteSounds) + resp.seasonInfo.platesObtained = len(resp.userItems.plates) + + return resp.make() + + def handle_user_status_create_request(self, data: Dict) -> List[Any]: + req = UserStatusCreateRequest(data) + resp = super().handle_user_status_create_request(data) + + self.data.item.put_item(req.aimeId, WaccaConstants.ITEM_TYPES["navigator"], 310001) # Added reverse + self.data.item.put_item(req.aimeId, WaccaConstants.ITEM_TYPES["navigator"], 310002) # Added reverse + + return resp + diff --git a/titles/wacca/s.py b/titles/wacca/s.py new file mode 100644 index 0000000..f302f44 --- /dev/null +++ b/titles/wacca/s.py @@ -0,0 +1,35 @@ +from typing import Any, List, Dict +from datetime import datetime, timedelta +import json + +from core.config import CoreConfig +from titles.wacca.base import WaccaBase +from titles.wacca.config import WaccaConfig +from titles.wacca.const import WaccaConstants + +from titles.wacca.handlers import * + +class WaccaS(WaccaBase): + allowed_stages = [ + (1501, 1), + (1502, 2), + (1503, 3), + (1504, 4), + (1505, 5), + (1506, 6), + (1507, 7), + (1508, 8), + (1509, 9), + (1510, 10), + (1511, 11), + (1512, 12), + (1513, 13), + ] + + def __init__(self, cfg: CoreConfig, game_cfg: WaccaConfig) -> None: + super().__init__(cfg, game_cfg) + self.version = WaccaConstants.VER_WACCA_S + + def handle_advertise_GetNews_request(self, data: Dict) -> List[Any]: + resp = GetNewsResponseV2() + return resp.make() diff --git a/titles/wacca/schema/__init__.py b/titles/wacca/schema/__init__.py new file mode 100644 index 0000000..1addd87 --- /dev/null +++ b/titles/wacca/schema/__init__.py @@ -0,0 +1,6 @@ +from titles.wacca.schema.profile import WaccaProfileData +from titles.wacca.schema.score import WaccaScoreData +from titles.wacca.schema.item import WaccaItemData +from titles.wacca.schema.static import WaccaStaticData + +__all__ = ["WaccaProfileData", "WaccaScoreData", "WaccaItemData", "WaccaStaticData"] \ No newline at end of file diff --git a/titles/wacca/schema/item.py b/titles/wacca/schema/item.py new file mode 100644 index 0000000..76e901f --- /dev/null +++ b/titles/wacca/schema/item.py @@ -0,0 +1,177 @@ +from typing import Optional, Dict, List +from sqlalchemy import Table, Column, UniqueConstraint, PrimaryKeyConstraint, and_, case +from sqlalchemy.types import Integer, String, TIMESTAMP, Boolean +from sqlalchemy.schema import ForeignKey +from sqlalchemy.sql import func, select, update, delete +from sqlalchemy.engine import Row +from sqlalchemy.dialects.mysql import insert + +from core.data.schema import BaseData, metadata + +item = Table( + "wacca_item", + metadata, + Column("id", Integer, primary_key=True, nullable=False), + Column("user", ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade"), nullable=False), + Column("item_id", Integer, nullable=False), + Column("type", Integer, nullable=False), + Column("acquire_date", TIMESTAMP, nullable=False, server_default=func.now()), + Column("use_count", Integer, server_default="0"), + UniqueConstraint("user", "item_id", "type", name="wacca_item_uk"), + mysql_charset='utf8mb4' +) + +ticket = Table( + "wacca_ticket", + metadata, + Column("id", Integer, primary_key=True, nullable=False), + Column("user", ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade"), nullable=False), + Column("ticket_id", Integer, nullable=False), + Column("acquire_date", TIMESTAMP, nullable=False, server_default=func.now()), + Column("expire_date", TIMESTAMP), + mysql_charset='utf8mb4' +) + +song_unlock = Table( + "wacca_song_unlock", + metadata, + Column("id", Integer, primary_key=True, nullable=False), + Column("user", ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade"), nullable=False), + Column("song_id", Integer, nullable=False), + Column("highest_difficulty", Integer, nullable=False), + Column("acquire_date", TIMESTAMP, nullable=False, server_default=func.now()), + UniqueConstraint("user", "song_id", name="wacca_song_unlock_uk"), + mysql_charset='utf8mb4' +) + +trophy = Table( + "wacca_trophy", + metadata, + Column("id", Integer, primary_key=True, nullable=False), + Column("user", ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade"), nullable=False), + Column("trophy_id", Integer, nullable=False), + Column("season", Integer, nullable=False), + Column("progress", Integer, nullable=False, server_default="0"), + Column("badge_type", Integer, nullable=False, server_default="0"), + UniqueConstraint("user", "trophy_id", "season", name="wacca_trophy_uk"), + mysql_charset='utf8mb4' +) + +class WaccaItemData(BaseData): + def get_song_unlocks(self, user_id: int) -> Optional[List[Row]]: + sql = song_unlock.select(song_unlock.c.user == user_id) + + result = self.execute(sql) + if result is None: return None + + return result.fetchall() + + def unlock_song(self, user_id: int, song_id: int, difficulty: int) -> Optional[int]: + sql = insert(song_unlock).values( + user=user_id, + song_id=song_id, + highest_difficulty=difficulty + ) + + conflict = sql.on_duplicate_key_update( + highest_difficulty=case( + (song_unlock.c.highest_difficulty >= difficulty, song_unlock.c.highest_difficulty), + (song_unlock.c.highest_difficulty < difficulty, difficulty), + ) + ) + + result = self.execute(conflict) + if result is None: + self.logger.error(f"{__name__} failed to unlock song! user: {user_id}, song_id: {song_id}, difficulty: {difficulty}") + return None + + return result.lastrowid + + def put_item(self, user_id: int, item_type: int, item_id: int) -> Optional[int]: + sql = insert(item).values( + user = user_id, + item_id = item_id, + type = item_type, + ) + + conflict = sql.on_duplicate_key_update( + use_count = item.c.use_count + 1 + ) + + result = self.execute(conflict) + if result is None: + self.logger.error(f"{__name__} failed to insert item! user: {user_id}, item_id: {item_id}, item_type: {item_type}") + return None + + return result.lastrowid + + def get_items(self, user_id: int, item_type: int = None, item_id: int = None) -> Optional[List[Row]]: + """ + A catch-all item lookup given a profile and option item type and ID specifiers + """ + sql = item.select( + and_(item.c.user == user_id, + item.c.type == item_type if item_type is not None else True, + item.c.item_id == item_id if item_id is not None else True) + ) + + result = self.execute(sql) + if result is None: return None + return result.fetchall() + + def get_tickets(self, user_id: int) -> Optional[List[Row]]: + sql = select(ticket).where(ticket.c.user == user_id) + + result = self.execute(sql) + if result is None: return None + return result.fetchall() + + def add_ticket(self, user_id: int, ticket_id: int) -> None: + sql = insert(ticket).values( + user = user_id, + ticket_id = ticket_id + ) + + result = self.execute(sql) + if result is None: + self.logger.error(f"add_ticket: Failed to insert wacca ticket! user_id: {user_id} ticket_id {ticket_id}") + return None + return result.lastrowid + + def spend_ticket(self, id: int) -> None: + sql = delete(ticket).where(ticket.c.id == id) + + result = self.execute(sql) + if result is None: + self.logger.warn(f"Failed to delete ticket id {id}") + return None + + def get_trophies(self, user_id: int, season: int = None) -> Optional[List[Row]]: + if season is None: + sql = select(trophy).where(trophy.c.user == user_id) + else: + sql = select(trophy).where(and_(trophy.c.user == user_id, trophy.c.season == season)) + + result = self.execute(sql) + if result is None: return None + return result.fetchall() + + def update_trophy(self, user_id: int, trophy_id: int, season: int, progress: int, badge_type: int) -> Optional[int]: + sql = insert(trophy).values( + user = user_id, + trophy_id = trophy_id, + season = season, + progress = progress, + badge_type = badge_type + ) + + conflict = sql.on_duplicate_key_update( + progress = progress + ) + + result = self.execute(conflict) + if result is None: + self.logger.error(f"update_trophy: Failed to insert wacca trophy! user_id: {user_id} trophy_id: {trophy_id} progress {progress}") + return None + return result.lastrowid + diff --git a/titles/wacca/schema/profile.py b/titles/wacca/schema/profile.py new file mode 100644 index 0000000..7237149 --- /dev/null +++ b/titles/wacca/schema/profile.py @@ -0,0 +1,428 @@ +from typing import Optional, Dict, List +from sqlalchemy import Table, Column, UniqueConstraint, PrimaryKeyConstraint, and_ +from sqlalchemy.types import Integer, String, TIMESTAMP, Boolean, JSON +from sqlalchemy.schema import ForeignKey +from sqlalchemy.sql import func, select +from sqlalchemy.engine import Row +from sqlalchemy.dialects.mysql import insert + +from core.data.schema import BaseData, metadata + +profile = Table( + "wacca_profile", + metadata, + Column("id", Integer, primary_key=True, nullable=False), + Column("user", ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade"), nullable=False), + Column("version", Integer), + Column("username", String(8), nullable=False), + Column("xp", Integer, server_default="0"), + Column("wp", Integer, server_default="0"), + Column("wp_total", Integer, server_default="0"), + Column("wp_spent", Integer, server_default="0"), + Column("dan_type", Integer, server_default="0"), + Column("dan_level", Integer, server_default="0"), + Column("title_0", Integer, server_default="0"), + Column("title_1", Integer, server_default="0"), + Column("title_2", Integer, server_default="0"), + Column("rating", Integer, server_default="0"), + Column("vip_expire_time", TIMESTAMP), + Column("always_vip", Boolean, server_default="0"), + Column("login_count", Integer, server_default="0"), + Column("login_count_consec", Integer, server_default="0"), + Column("login_count_days", Integer, server_default="0"), + Column("login_count_days_consec", Integer, server_default="0"), + Column("login_count_today", Integer, server_default="0"), + Column("playcount_single", Integer, server_default="0"), + Column("playcount_multi_vs", Integer, server_default="0"), + Column("playcount_multi_coop", Integer, server_default="0"), + Column("playcount_stageup", Integer, server_default="0"), + Column("friend_view_1", Integer), + Column("friend_view_2", Integer), + Column("friend_view_3", Integer), + Column("last_game_ver", String(50)), + Column("last_song_id", Integer, server_default="0"), + Column("last_song_difficulty", Integer, server_default="0"), + Column("last_folder_order", Integer, server_default="0"), + Column("last_folder_id", Integer, server_default="0"), + Column("last_song_order", Integer, server_default="0"), + Column("last_login_date", TIMESTAMP, server_default=func.now()), + Column("gate_tutorial_flags", JSON), + UniqueConstraint("user", "version", name="wacca_profile_uk"), + mysql_charset='utf8mb4' +) + +option = Table( + "wacca_option", + metadata, + Column("id", Integer, primary_key=True, nullable=False), + Column("user", ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade"), nullable=False), + Column("opt_id", Integer, nullable=False), + Column("value", Integer, nullable=False), + UniqueConstraint("user", "opt_id", name="wacca_option_uk"), +) + +bingo = Table( + "wacca_bingo", + metadata, + Column("user", ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade"), primary_key=True, nullable=False), + Column("page_number", Integer, nullable=False), + Column("page_progress", JSON, nullable=False), + UniqueConstraint("user", "page_number", name="wacca_bingo_uk"), + mysql_charset='utf8mb4' +) + +friend = Table( + "wacca_friend", + metadata, + Column("profile_sender", ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade"), nullable=False), + Column("profile_reciever", ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade"), nullable=False), + Column("is_accepted", Boolean, server_default="0"), + PrimaryKeyConstraint('profile_sender', 'profile_reciever', name='arcade_owner_pk'), + mysql_charset='utf8mb4' +) + +favorite = Table( + "wacca_favorite_song", + metadata, + Column("id", Integer, primary_key=True, nullable=False), + Column("user", ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade"), nullable=False), + Column("song_id", Integer, nullable=False), + UniqueConstraint("user", "song_id", name="wacca_favorite_song_uk"), + mysql_charset='utf8mb4' +) + +gate = Table( + "wacca_gate", + metadata, + Column("id", Integer, primary_key=True, nullable=False), + Column("user", ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade"), nullable=False), + Column("gate_id", Integer, nullable=False), + Column("page", Integer, nullable=False, server_default="0"), + Column("progress", Integer, nullable=False, server_default="0"), + Column("loops", Integer, nullable=False, server_default="0"), + Column("last_used", TIMESTAMP, nullable=False, server_default=func.now()), + Column("mission_flag", Integer, nullable=False, server_default="0"), + Column("total_points", Integer, nullable=False, server_default="0"), + UniqueConstraint("user", "gate_id", name="wacca_gate_uk"), +) + +class WaccaProfileData(BaseData): + def create_profile(self, aime_id: int, username: str, version: int) -> Optional[int]: + """ + Given a game version, aime id, and username, create a profile and return it's ID + """ + sql = insert(profile).values( + user=aime_id, + username=username, + version=version + ) + + conflict = sql.on_duplicate_key_update( + username = sql.inserted.username + ) + + result = self.execute(conflict) + if result is None: + self.logger.error(f"{__name__} Failed to insert wacca profile! aime id: {aime_id} username: {username}") + return None + return result.lastrowid + + def update_profile_playtype(self, profile_id: int, play_type: int, game_version: str) -> None: + sql = profile.update(profile.c.id == profile_id).values( + playcount_single = profile.c.playcount_single + 1 if play_type == 1 else profile.c.playcount_single, + + playcount_multi_vs = profile.c.playcount_multi_vs + 1 if play_type == 2 else profile.c.playcount_multi_vs, + + playcount_multi_coop = profile.c.playcount_multi_coop + 1 if play_type == 3 else profile.c.playcount_multi_coop, + + playcount_stageup = profile.c.playcount_stageup + 1 if play_type == 4 else profile.c.playcount_stageup, + + last_game_ver = game_version, + ) + + result = self.execute(sql) + if result is None: + self.logger.error(f"update_profile: failed to update profile! profile: {profile_id}") + return None + + def update_profile_lastplayed(self, profile_id: int, last_song_id: int, last_song_difficulty: int, last_folder_order: int, + last_folder_id: int, last_song_order: int) -> None: + sql = profile.update(profile.c.id == profile_id).values( + last_song_id = last_song_id, + last_song_difficulty = last_song_difficulty, + last_folder_order = last_folder_order, + last_folder_id = last_folder_id, + last_song_order = last_song_order + ) + result = self.execute(sql) + if result is None: + self.logger.error(f"update_profile_lastplayed: failed to update profile! profile: {profile_id}") + return None + + def update_profile_dan(self, profile_id: int, dan_level: int, dan_type: int) -> Optional[int]: + sql = profile.update(profile.c.id == profile_id).values( + dan_level = dan_level, + dan_type = dan_type + ) + + result = self.execute(sql) + if result is None: + self.logger.warn(f"update_profile_dan: Failed to update! profile {profile_id}") + return None + return result.lastrowid + + def get_profile(self, profile_id: int = 0, aime_id: int = None) -> Optional[Row]: + """ + Given a game version and either a profile or aime id, return the profile + """ + if aime_id is not None: + sql = profile.select(profile.c.user == aime_id) + elif profile_id > 0: + sql = profile.select(profile.c.id == profile_id) + else: + self.logger.error(f"get_profile: Bad arguments!! profile_id {profile_id} aime_id {aime_id}") + return None + + result = self.execute(sql) + if result is None: return None + return result.fetchone() + + def get_options(self, user_id: int, option_id: int = None) -> Optional[List[Row]]: + """ + Get a specific user option for a profile, or all of them if none specified + """ + sql = option.select( + and_(option.c.user == user_id, + option.c.opt_id == option_id if option_id is not None else True) + ) + + result = self.execute(sql) + if result is None: return None + if option_id is not None: + return result.fetchone() + else: + return result.fetchall() + + def update_option(self, user_id: int, option_id: int, value: int) -> Optional[int]: + sql = insert(option).values( + user = user_id, + opt_id = option_id, + value = value + ) + + conflict = sql.on_duplicate_key_update( + value = sql.inserted.value + ) + + result = self.execute(conflict) + if result is None: + self.logger.error(f"{__name__} failed to insert option! profile: {user_id}, option: {option_id}, value: {value}") + return None + + return result.lastrowid + + def add_favorite_song(self, user_id: int, song_id: int) -> Optional[int]: + sql = favorite.insert().values( + user=user_id, + song_id=song_id + ) + + result = self.execute(sql) + if result is None: + self.logger.error(f"{__name__} failed to insert favorite! profile: {user_id}, song_id: {song_id}") + return None + return result.lastrowid + + def remove_favorite_song(self, user_id: int, song_id: int) -> None: + sql = favorite.delete(and_(favorite.c.user == user_id, favorite.c.song_id == song_id)) + + result = self.execute(sql) + if result is None: + self.logger.error(f"{__name__} failed to remove favorite! profile: {user_id}, song_id: {song_id}") + return None + + def get_favorite_songs(self, user_id: int) -> Optional[List[Row]]: + sql = favorite.select(favorite.c.user == user_id) + + result = self.execute(sql) + if result is None: return None + return result.fetchall() + + def get_gates(self, user_id: int) -> Optional[List[Row]]: + sql = select(gate).where(gate.c.user == user_id) + + result = self.execute(sql) + if result is None: return None + return result.fetchall() + + def update_gate(self, user_id: int, gate_id: int, page: int, progress: int, loop: int, mission_flag: int, + total_points: int) -> Optional[int]: + sql = insert(gate).values( + user=user_id, + gate_id=gate_id, + page=page, + progress=progress, + loops=loop, + mission_flag=mission_flag, + total_points=total_points + ) + + conflict = sql.on_duplicate_key_update( + page=sql.inserted.page, + progress=sql.inserted.progress, + loops=sql.inserted.loops, + mission_flag=sql.inserted.mission_flag, + total_points=sql.inserted.total_points, + ) + + result = self.execute(conflict) + if result is None: + self.logger.error(f"{__name__} failed to update gate! user: {user_id}, gate_id: {gate_id}") + return None + return result.lastrowid + + def get_friends(self, user_id: int) -> Optional[List[Row]]: + sql = friend.select(friend.c.profile_sender == user_id) + + result = self.execute(sql) + if result is None: return None + return result.fetchall() + + def profile_to_aime_user(self, profile_id: int) -> Optional[int]: + sql = select(profile.c.user).where(profile.c.id == profile_id) + + result = self.execute(sql) + if result is None: + self.logger.info(f"profile_to_aime_user: No user found for profile {profile_id}") + return None + + this_profile = result.fetchone() + if this_profile is None: + self.logger.info(f"profile_to_aime_user: No user found for profile {profile_id}") + return None + + return this_profile['user'] + + def session_login(self, profile_id: int, is_new_day: bool, is_consec_day: bool) -> None: + # TODO: Reset consec days counter + sql = profile.update(profile.c.id == profile_id).values( + login_count = profile.c.login_count + 1, + login_count_consec = profile.c.login_count_consec + 1, + login_count_days = profile.c.login_count_days + 1 if is_new_day else profile.c.login_count_days, + login_count_days_consec = profile.c.login_count_days_consec + 1 if is_new_day and is_consec_day else profile.c.login_count_days_consec, + login_count_today = 1 if is_new_day else profile.c.login_count_today + 1, + last_login_date = func.now() + ) + + result = self.execute(sql) + if result is None: + self.logger.error(f"session_login: failed to update profile! profile: {profile_id}") + return None + + def session_logout(self, profile_id: int) -> None: + sql = profile.update(profile.c.id == id).values( + login_count_consec = 0 + ) + + result = self.execute(sql) + if result is None: + self.logger.error(f"{__name__} failed to update profile! profile: {profile_id}") + return None + + def add_xp(self, profile_id: int, xp: int) -> None: + sql = profile.update(profile.c.id == profile_id).values( + xp = profile.c.xp + xp + ) + + result = self.execute(sql) + if result is None: + self.logger.error(f"add_xp: Failed to update profile! profile_id {profile_id} xp {xp}") + return None + + def add_wp(self, profile_id: int, wp: int) -> None: + sql = profile.update(profile.c.id == profile_id).values( + wp = profile.c.wp + wp, + wp_total = profile.c.wp_total + wp, + ) + + result = self.execute(sql) + if result is None: + self.logger.error(f"add_wp: Failed to update profile! profile_id {profile_id} wp {wp}") + return None + + def spend_wp(self, profile_id: int, wp: int) -> None: + sql = profile.update(profile.c.id == profile_id).values( + wp = profile.c.wp - wp, + wp_spent = profile.c.wp_spent + wp, + ) + + result = self.execute(sql) + if result is None: + self.logger.error(f"spend_wp: Failed to update profile! profile_id {profile_id} wp {wp}") + return None + + def activate_vip(self, profile_id: int, expire_time) -> None: + sql = profile.update(profile.c.id == profile_id).values( + vip_expire_time = expire_time + ) + + result = self.execute(sql) + if result is None: + self.logger.error(f"activate_vip: Failed to update profile! profile_id {profile_id} expire_time {expire_time}") + return None + + def update_user_rating(self, profile_id: int, new_rating: int) -> None: + sql = profile.update(profile.c.id == profile_id).values( + rating = new_rating + ) + + result = self.execute(sql) + if result is None: + self.logger.error(f"update_user_rating: Failed to update profile! profile_id {profile_id} new_rating {new_rating}") + return None + + def update_bingo(self, aime_id: int, page: int, progress: int) -> Optional[int]: + sql = insert(bingo).values( + user=aime_id, + page_number=page, + page_progress=progress + ) + + conflict = sql.on_duplicate_key_update( + page_number=page, + page_progress=progress + ) + + result = self.execute(conflict) + if result is None: + self.logger.error(f"put_bingo: failed to update! aime_id: {aime_id}") + return None + return result.lastrowid + + def get_bingo(self, aime_id: int) -> Optional[List[Row]]: + sql = select(bingo).where(bingo.c.user==aime_id) + + result = self.execute(sql) + if result is None: return None + return result.fetchone() + + def get_bingo_page(self, aime_id: int, page: Dict) -> Optional[List[Row]]: + sql = select(bingo).where(and_(bingo.c.user==aime_id, bingo.c.page_number==page)) + + result = self.execute(sql) + if result is None: return None + return result.fetchone() + + def update_vip_time(self, profile_id: int, time_left) -> None: + sql = profile.update(profile.c.id == profile_id).values(vip_expire_time = time_left) + + result = self.execute(sql) + if result is None: + self.logger.error(f"Failed to update VIP time for profile {profile_id}") + + def update_tutorial_flags(self, profile_id: int, flags: Dict) -> None: + sql = profile.update(profile.c.id == profile_id).values(gate_tutorial_flags = flags) + + result = self.execute(sql) + if result is None: + self.logger.error(f"Failed to update tutorial flags for profile {profile_id}") \ No newline at end of file diff --git a/titles/wacca/schema/score.py b/titles/wacca/schema/score.py new file mode 100644 index 0000000..4b0c26c --- /dev/null +++ b/titles/wacca/schema/score.py @@ -0,0 +1,260 @@ +from sqlalchemy import Table, Column, UniqueConstraint, PrimaryKeyConstraint, and_ +from sqlalchemy.types import Integer, String, TIMESTAMP, JSON, Boolean +from sqlalchemy.schema import ForeignKey +from sqlalchemy.sql import func, select +from sqlalchemy.engine import Row +from sqlalchemy.dialects.mysql import insert +from typing import Optional, List, Dict, Any + +from core.data.schema import BaseData, metadata +from core.data import cached + +best_score = Table( + "wacca_score_best", + metadata, + Column("id", Integer, primary_key=True, nullable=False), + Column("user", ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade"), nullable=False), + Column("song_id", Integer), + Column("chart_id", Integer), + Column("score", Integer), + Column("play_ct", Integer), + Column("clear_ct", Integer), + Column("missless_ct", Integer), + Column("fullcombo_ct", Integer), + Column("allmarv_ct", Integer), + Column("grade_d_ct", Integer), + Column("grade_c_ct", Integer), + Column("grade_b_ct", Integer), + Column("grade_a_ct", Integer), + Column("grade_aa_ct", Integer), + Column("grade_aaa_ct", Integer), + Column("grade_s_ct", Integer), + Column("grade_ss_ct", Integer), + Column("grade_sss_ct", Integer), + Column("grade_master_ct", Integer), + Column("grade_sp_ct", Integer), + Column("grade_ssp_ct", Integer), + Column("grade_sssp_ct", Integer), + Column("best_combo", Integer), + Column("lowest_miss_ct", Integer), + Column("rating", Integer), + UniqueConstraint("user", "song_id", "chart_id", name="wacca_score_uk"), + mysql_charset='utf8mb4' +) + +playlog = Table( + "wacca_score_playlog", + metadata, + Column("id", Integer, primary_key=True, nullable=False), + Column("user", ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade"), nullable=False), + Column("song_id", Integer), + Column("chart_id", Integer), + Column("score", Integer), + Column("clear", Integer), + Column("grade", Integer), + Column("max_combo", Integer), + Column("marv_ct", Integer), + Column("great_ct", Integer), + Column("good_ct", Integer), + Column("miss_ct", Integer), + Column("fast_ct", Integer), + Column("late_ct", Integer), + Column("season", Integer), + Column("date_scored", TIMESTAMP, server_default=func.now()), + mysql_charset='utf8mb4' +) + +stageup = Table( + "wacca_score_stageup", + metadata, + Column("id", Integer, primary_key=True, nullable=False), + Column("user", ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade"), nullable=False), + Column("version", Integer), + Column("stage_id", Integer), + Column("clear_status", Integer), + Column("clear_song_ct", Integer), + Column("song1_score", Integer), + Column("song2_score", Integer), + Column("song3_score", Integer), + Column("play_ct", Integer, server_default="1"), + UniqueConstraint("user", "stage_id", name="wacca_score_stageup_uk"), + mysql_charset='utf8mb4' +) + +class WaccaScoreData(BaseData): + def put_best_score(self, user_id: int, song_id: int, chart_id: int, score: int, clear: List[int], + grade: List[int], best_combo: int, lowest_miss_ct: int) -> Optional[int]: + """ + Update the user's best score for a chart + """ + while len(grade) < 13: + grade.append(0) + + sql = insert(best_score).values( + user=user_id, + song_id=song_id, + chart_id=chart_id, + score=score, + play_ct=clear[0], + clear_ct=clear[1], + missless_ct=clear[2], + fullcombo_ct=clear[3], + allmarv_ct=clear[4], + grade_d_ct=grade[0], + grade_c_ct=grade[1], + grade_b_ct=grade[2], + grade_a_ct=grade[3], + grade_aa_ct=grade[4], + grade_aaa_ct=grade[5], + grade_s_ct=grade[6], + grade_ss_ct=grade[7], + grade_sss_ct=grade[8], + grade_master_ct=grade[9], + grade_sp_ct=grade[10], + grade_ssp_ct=grade[11], + grade_sssp_ct=grade[12], + best_combo=best_combo, + lowest_miss_ct=lowest_miss_ct, + rating=0 + ) + + conflict = sql.on_duplicate_key_update( + score=score, + play_ct=clear[0], + clear_ct=clear[1], + missless_ct=clear[2], + fullcombo_ct=clear[3], + allmarv_ct=clear[4], + grade_d_ct=grade[0], + grade_c_ct=grade[1], + grade_b_ct=grade[2], + grade_a_ct=grade[3], + grade_aa_ct=grade[4], + grade_aaa_ct=grade[5], + grade_s_ct=grade[6], + grade_ss_ct=grade[7], + grade_sss_ct=grade[8], + grade_master_ct=grade[9], + grade_sp_ct=grade[10], + grade_ssp_ct=grade[11], + grade_sssp_ct=grade[12], + best_combo=best_combo, + lowest_miss_ct=lowest_miss_ct, + ) + + result = self.execute(conflict) + if result is None: + self.logger.error(f"{__name__}: failed to insert best score! profile: {user_id}, song: {song_id}, chart: {chart_id}") + return None + + return result.lastrowid + + def put_playlog(self, user_id: int, song_id: int, chart_id: int, this_score: int, clear: int, grade: int, max_combo: int, + marv_ct: int, great_ct: int, good_ct: int, miss_ct: int, fast_ct: int, late_ct: int, season: int) -> Optional[int]: + """ + Add an entry to the user's play log + """ + sql = playlog.insert().values( + user=user_id, + song_id=song_id, + chart_id=chart_id, + score=this_score, + clear=clear, + grade=grade, + max_combo=max_combo, + marv_ct=marv_ct, + great_ct=great_ct, + good_ct=good_ct, + miss_ct=miss_ct, + fast_ct=fast_ct, + late_ct=late_ct, + season=season + ) + + result = self.execute(sql) + if result is None: + self.logger.error(f"{__name__} failed to insert playlog! profile: {user_id}, song: {song_id}, chart: {chart_id}") + return None + + return result.lastrowid + + def get_best_score(self, user_id: int, song_id: int, chart_id: int) -> Optional[Row]: + sql = best_score.select( + and_(best_score.c.user == user_id, best_score.c.song_id == song_id, best_score.c.chart_id == chart_id) + ) + + result = self.execute(sql) + if result is None: return None + return result.fetchone() + + def get_best_scores(self, user_id: int) -> Optional[List[Row]]: + sql = best_score.select( + best_score.c.user == user_id + ) + + result = self.execute(sql) + if result is None: return None + return result.fetchall() + + def update_song_rating(self, user_id: int, song_id: int, chart_id: int, new_rating: int) -> None: + sql = best_score.update( + and_( + best_score.c.user == user_id, + best_score.c.song_id == song_id, + best_score.c.chart_id == chart_id + )).values( + rating = new_rating + ) + + result = self.execute(sql) + if result is None: + self.logger.error(f"update_song_rating: failed to update rating! user_id: {user_id} song_id: {song_id} chart_id {chart_id} new_rating {new_rating}") + return None + + def put_stageup(self, user_id: int, version: int, stage_id: int, clear_status: int, clear_song_ct: int, score1: int, + score2: int, score3: int) -> Optional[int]: + sql = insert(stageup).values( + user = user_id, + version = version, + stage_id = stage_id, + clear_status = clear_status, + clear_song_ct = clear_song_ct, + song1_score = score1, + song2_score = score2, + song3_score = score3, + ) + + conflict = sql.on_duplicate_key_update( + clear_status = clear_status, + clear_song_ct = clear_song_ct, + song1_score = score1, + song2_score = score2, + song3_score = score3, + play_ct = stageup.c.play_ct + 1 + ) + + result = self.execute(conflict) + if result is None: + self.logger.warn(f"put_stageup: failed to update! user_id: {user_id} version: {version} stage_id: {stage_id}") + return None + return result.lastrowid + + def get_stageup(self, user_id: int, version: int) -> Optional[List[Row]]: + sql = select(stageup).where(and_(stageup.c.user==user_id, stageup.c.version==version)) + + result = self.execute(sql) + if result is None: return None + return result.fetchall() + + def get_stageup_stage(self, user_id: int, version: int, stage_id: int) -> Optional[Row]: + sql = select(stageup).where( + and_( + stageup.c.user == user_id, + stageup.c.version == version, + stageup.c.stage_id == stage_id, + ) + ) + + result = self.execute(sql) + if result is None: return None + return result.fetchone() diff --git a/titles/wacca/schema/static.py b/titles/wacca/schema/static.py new file mode 100644 index 0000000..a5e8b41 --- /dev/null +++ b/titles/wacca/schema/static.py @@ -0,0 +1,68 @@ +from sqlalchemy import Table, Column, UniqueConstraint, PrimaryKeyConstraint, and_ +from sqlalchemy.types import Integer, String, TIMESTAMP, JSON, Boolean, Float +from sqlalchemy.schema import ForeignKey +from sqlalchemy.sql import func, select +from sqlalchemy.engine import Row +from sqlalchemy.dialects.mysql import insert +from typing import Optional, List, Dict, Any + +from core.data.schema import BaseData, metadata +from core.data import cached + +music = Table( + "wacca_static_music", + metadata, + Column("id", Integer, primary_key=True, nullable=False), + Column("version", Integer, nullable=False), + Column("songId", Integer), + Column("chartId", Integer), + Column("title", String(255)), + Column("artist", String(255)), + Column("bpm", String(255)), + Column("difficulty", Float), + Column("chartDesigner", String(255)), + Column("jacketFile", String(255)), + UniqueConstraint("version", "songId", "chartId", name="wacca_static_music_uk"), + mysql_charset='utf8mb4' +) + +class WaccaStaticData(BaseData): + def put_music(self, version: int, song_id: int, chart_id: int, title: str, artist: str, bpm: str, + difficulty: float, chart_designer: str, jacket: str) -> Optional[int]: + sql = insert(music).values( + version = version, + songId = song_id, + chartId = chart_id, + title = title, + artist = artist, + bpm = bpm, + difficulty = difficulty, + chartDesigner = chart_designer, + jacketFile = jacket + ) + + conflict = sql.on_duplicate_key_update( + title = title, + artist = artist, + bpm = bpm, + difficulty = difficulty, + chartDesigner = chart_designer, + jacketFile = jacket + ) + + result = self.execute(conflict) + if result is None: + self.logger.warn(f"Failed to insert music {song_id} chart {chart_id}") + return None + return result.lastrowid + + def get_music_chart(self, version: int, song_id: int, chart_id: int) -> Optional[List[Row]]: + sql = select(music).where(and_( + music.c.version == version, + music.c.songId == song_id, + music.c.chartId == chart_id + )) + + result = self.execute(sql) + if result is None: return None + return result.fetchone()