From deeac1d8dbe163e3abe090826d16b50af0809cb2 Mon Sep 17 00:00:00 2001 From: Kevin Trocolli Date: Sun, 30 Apr 2023 22:19:31 -0400 Subject: [PATCH] add finale handler, pre-dx game codes --- titles/mai2/__init__.py | 11 +++++++- titles/mai2/base.py | 3 +-- titles/mai2/const.py | 41 +++++++++++++++++++++++++++++- titles/mai2/dx.py | 15 +++++++++++ titles/mai2/{plus.py => dxplus.py} | 2 +- titles/mai2/finale.py | 15 +++++++++++ titles/mai2/index.py | 24 ++++++++++++++--- 7 files changed, 103 insertions(+), 8 deletions(-) create mode 100644 titles/mai2/dx.py rename titles/mai2/{plus.py => dxplus.py} (93%) create mode 100644 titles/mai2/finale.py diff --git a/titles/mai2/__init__.py b/titles/mai2/__init__.py index 810eac9..0a76de8 100644 --- a/titles/mai2/__init__.py +++ b/titles/mai2/__init__.py @@ -6,5 +6,14 @@ from titles.mai2.read import Mai2Reader index = Mai2Servlet database = Mai2Data reader = Mai2Reader -game_codes = [Mai2Constants.GAME_CODE] +game_codes = [ + Mai2Constants.GAME_CODE_DX, + Mai2Constants.GAME_CODE_FINALE, + Mai2Constants.GAME_CODE_MILK, + Mai2Constants.GAME_CODE_MURASAKI, + Mai2Constants.GAME_CODE_PINK, + Mai2Constants.GAME_CODE_ORANGE, + Mai2Constants.GAME_CODE_GREEN, + Mai2Constants.GAME_CODE, +] current_schema_version = 4 diff --git a/titles/mai2/base.py b/titles/mai2/base.py index 171378c..efa30a0 100644 --- a/titles/mai2/base.py +++ b/titles/mai2/base.py @@ -12,8 +12,7 @@ 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.version = Mai2Constants.VER_MAIMAI self.data = Mai2Data(cfg) self.logger = logging.getLogger("mai2") diff --git a/titles/mai2/const.py b/titles/mai2/const.py index dcc7e29..19cb867 100644 --- a/titles/mai2/const.py +++ b/titles/mai2/const.py @@ -20,10 +20,31 @@ class Mai2Constants: DATE_TIME_FORMAT = "%Y-%m-%d %H:%M:%S" - GAME_CODE = "SDEZ" + GAME_CODE = "SBXL" + GAME_CODE_GREEN = "SBZF" + GAME_CODE_ORANGE = "SDBM" + GAME_CODE_PINK = "SDCQ" + GAME_CODE_MURASAKI = "SDDK" + GAME_CODE_MILK = "SDDZ" + GAME_CODE_FINALE = "SDEY" + GAME_CODE_DX = "SDEZ" CONFIG_NAME = "mai2.yaml" + VER_MAIMAI = 1000 + VER_MAIMAI_PLUS = 1001 + VER_MAIMAI_GREEN = 1002 + VER_MAIMAI_GREEN_PLUS = 1003 + VER_MAIMAI_ORANGE = 1004 + VER_MAIMAI_ORANGE_PLUS = 1005 + VER_MAIMAI_PINK = 1006 + VER_MAIMAI_PINK_PLUS = 1007 + VER_MAIMAI_MURASAKI = 1008 + VER_MAIMAI_MURASAKI_PLUS = 1009 + VER_MAIMAI_MILK = 1010 + VER_MAIMAI_MILK_PLUS = 1011 + VER_MAIMAI_FINALE = 1012 + VER_MAIMAI_DX = 0 VER_MAIMAI_DX_PLUS = 1 VER_MAIMAI_DX_SPLASH = 2 @@ -42,6 +63,24 @@ class Mai2Constants: "maimai DX Festival", ) + VERSION_STRING_OLD = ( + "maimai", + "maimai PLUS", + "maimai GreeN", + "maimai GreeN PLUS", + "maimai ORANGE", + "maimai ORANGE PLUS", + "maimai PiNK", + "maimai PiNK PLUS", + "maimai MURASAKi", + "maimai MURASAKi PLUS", + "maimai MiLK", + "maimai MiLK PLUS", + "maimai FiNALE", + ) + @classmethod def game_ver_to_string(cls, ver: int): + if ver >= 1000: + return cls.VERSION_STRING_OLD[ver / 1000] return cls.VERSION_STRING[ver] diff --git a/titles/mai2/dx.py b/titles/mai2/dx.py new file mode 100644 index 0000000..9a9cae7 --- /dev/null +++ b/titles/mai2/dx.py @@ -0,0 +1,15 @@ +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 Mai2DX(Mai2Base): + def __init__(self, cfg: CoreConfig, game_cfg: Mai2Config) -> None: + super().__init__(cfg, game_cfg) + self.version = Mai2Constants.VER_MAIMAI_DX diff --git a/titles/mai2/plus.py b/titles/mai2/dxplus.py similarity index 93% rename from titles/mai2/plus.py rename to titles/mai2/dxplus.py index a3c9288..64c9297 100644 --- a/titles/mai2/plus.py +++ b/titles/mai2/dxplus.py @@ -9,7 +9,7 @@ from titles.mai2.config import Mai2Config from titles.mai2.const import Mai2Constants -class Mai2Plus(Mai2Base): +class Mai2DXPlus(Mai2Base): def __init__(self, cfg: CoreConfig, game_cfg: Mai2Config) -> None: super().__init__(cfg, game_cfg) self.version = Mai2Constants.VER_MAIMAI_DX_PLUS diff --git a/titles/mai2/finale.py b/titles/mai2/finale.py new file mode 100644 index 0000000..bb4b67e --- /dev/null +++ b/titles/mai2/finale.py @@ -0,0 +1,15 @@ +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 Mai2Finale(Mai2Base): + def __init__(self, cfg: CoreConfig, game_cfg: Mai2Config) -> None: + super().__init__(cfg, game_cfg) + self.version = Mai2Constants.VER_MAIMAI_FINALE diff --git a/titles/mai2/index.py b/titles/mai2/index.py index 1b92842..9eb3b52 100644 --- a/titles/mai2/index.py +++ b/titles/mai2/index.py @@ -14,7 +14,9 @@ from core.utils import Utils 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.finale import Mai2Finale +from titles.mai2.dx import Mai2DX +from titles.mai2.dxplus import Mai2DXPlus from titles.mai2.splash import Mai2Splash from titles.mai2.splashplus import Mai2SplashPlus from titles.mai2.universe import Mai2Universe @@ -32,8 +34,8 @@ class Mai2Servlet: ) self.versions = [ - Mai2Base, - Mai2Plus, + Mai2DX, + Mai2DXPlus, Mai2Splash, Mai2SplashPlus, Mai2Universe, @@ -41,6 +43,22 @@ class Mai2Servlet: Mai2Festival, ] + self.versions_old = [ + Mai2Base, + None, + None, + None, + None, + None, + None, + None, + None, + None, + None, + None, + Mai2Finale, + ] + self.logger = logging.getLogger("mai2") log_fmt_str = "[%(asctime)s] Mai2 | %(levelname)s | %(message)s" log_fmt = logging.Formatter(log_fmt_str)