From ad820ed0910049b9e107e6ffc29b84e0fe7d7d4c Mon Sep 17 00:00:00 2001 From: Dniel97 Date: Tue, 30 May 2023 12:14:18 +0200 Subject: [PATCH] cm: Added individual Card Maker version and maimai DX passes working --- core/data/schema/versions/SDEZ_4_rollback.sql | 3 ++ core/data/schema/versions/SDEZ_5_upgrade.sql | 3 ++ docs/game_specific_info.md | 53 +++++++++++++++---- example_config/cardmaker.yaml | 10 ++++ readme.md | 2 +- titles/cm/base.py | 38 ++++++++++--- titles/cm/cm135.py | 22 +------- titles/cm/config.py | 16 ++++++ titles/cm/const.py | 2 +- titles/cm/index.py | 4 +- titles/mai2/__init__.py | 2 +- titles/mai2/schema/item.py | 12 +++-- titles/mai2/universe.py | 34 ++++++++++-- 13 files changed, 150 insertions(+), 51 deletions(-) create mode 100644 core/data/schema/versions/SDEZ_4_rollback.sql create mode 100644 core/data/schema/versions/SDEZ_5_upgrade.sql diff --git a/core/data/schema/versions/SDEZ_4_rollback.sql b/core/data/schema/versions/SDEZ_4_rollback.sql new file mode 100644 index 0000000..b8be7b3 --- /dev/null +++ b/core/data/schema/versions/SDEZ_4_rollback.sql @@ -0,0 +1,3 @@ +ALTER TABLE mai2_item_card + CHANGE COLUMN startDate startDate TIMESTAMP DEFAULT "2018-01-01 00:00:00.0", + CHANGE COLUMN endDate endDate TIMESTAMP DEFAULT "2038-01-01 00:00:00.0"; \ No newline at end of file diff --git a/core/data/schema/versions/SDEZ_5_upgrade.sql b/core/data/schema/versions/SDEZ_5_upgrade.sql new file mode 100644 index 0000000..cc4912f --- /dev/null +++ b/core/data/schema/versions/SDEZ_5_upgrade.sql @@ -0,0 +1,3 @@ +ALTER TABLE mai2_item_card + CHANGE COLUMN startDate startDate TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, + CHANGE COLUMN endDate endDate TIMESTAMP NOT NULL; \ No newline at end of file diff --git a/docs/game_specific_info.md b/docs/game_specific_info.md index 5361ce9..aa0a39f 100644 --- a/docs/game_specific_info.md +++ b/docs/game_specific_info.md @@ -253,13 +253,13 @@ python dbutils.py --game SDDT upgrade | Version ID | Version Name | |------------|-----------------| -| 0 | Card Maker 1.34 | +| 0 | Card Maker 1.30 | | 1 | Card Maker 1.35 | ### Support status -* Card Maker 1.34: +* Card Maker 1.30: * CHUNITHM NEW!!: Yes * maimai DX UNiVERSE: Yes * O.N.G.E.K.I. Bright: Yes @@ -285,19 +285,46 @@ python read.py --series SDED --version --binfolder titles/cm/cm_dat python read.py --series SDDT --version --binfolder /path/to/game/folder --optfolder /path/to/game/option/folder ``` -Also make sure to import all maimai and Chunithm data as well: +Also make sure to import all maimai DX and CHUNITHM data as well: ```shell python read.py --series SDED --version --binfolder /path/to/cardmaker/CardMaker_Data ``` -The importer for Card Maker will import all required Gachas (Banners) and cards (for maimai/Chunithm) and the hardcoded +The importer for Card Maker will import all required Gachas (Banners) and cards (for maimai DX/CHUNITHM) and the hardcoded Cards for each Gacha (O.N.G.E.K.I. only). **NOTE: Without executing the importer Card Maker WILL NOT work!** -### O.N.G.E.K.I. Gachas +### Config setup + +Make sure to update your `config/cardmaker.yaml` with the correct version for each game. To get the current version required to run a specific game, open every opt (Axxx) folder descending until you find all three folders: + +- `MU3`: O.N.G.E.K.I. +- `MAI`: maimai DX +- `CHU`: CHUNITHM + +Inside each folder is a `DataConfig.xml` file, for example: + +`MU3/DataConfig.xml`: +```xml + + 1 + 35 + 3 + +``` + +Now update your `config/cardmaker.yaml` with the correct version number, for example: + +```yaml +version: + 1: # Card Maker 1.35 + ongeki: 1.35.03 +``` + +### O.N.G.E.K.I. Gacha "無料ガチャ" can only pull from the free cards with the following probabilities: 94%: R, 5% SR and 1% chance of getting an SSR card @@ -310,20 +337,24 @@ and 3% chance of getting an SSR card All other (limited) gachas can pull from every card added to ongeki_static_cards but with the promoted cards (click on the green button under the banner) having a 10 times higher chance to get pulled -### Chunithm Gachas +### CHUNITHM -All cards in Chunithm (basically just the characters) have the same rarity to it just pulls randomly from all cards +All cards in CHUNITHM (basically just the characters) have the same rarity to it just pulls randomly from all cards from a given gacha but made sure you cannot pull the same card twice in the same 5 times gacha roll. +### maimai DX + +Printed maimai DX cards: Freedom (`cardTypeId=6`) or Gold Pass (`cardTypeId=4`) can now be selected during the login process. You can only have ONE Freedom and ONE Gold Pass active at a given time. The cards will expire after 15 days. + +Thanks GetzeAvenue for the `selectedCardList` rarity hint! + ### Notes -Card Maker 1.34 will only load an O.N.G.E.K.I. Bright profile (1.30). Card Maker 1.35 will only load an O.N.G.E.K.I. +Card Maker 1.30-1.34 will only load an O.N.G.E.K.I. Bright profile (1.30). Card Maker 1.35+ will only load an O.N.G.E.K.I. Bright Memory profile (1.35). -The gachas inside the `ongeki.yaml` will make sure only the right gacha ids for the right CM version will be loaded. +The gachas inside the `config/ongeki.yaml` will make sure only the right gacha ids for the right CM version will be loaded. Gacha IDs up to 1140 will be loaded for CM 1.34 and all gachas will be loaded for CM 1.35. -**NOTE: There is currently no way to load/use the (printed) maimai DX cards!** - ## WACCA ### SDFE diff --git a/example_config/cardmaker.yaml b/example_config/cardmaker.yaml index a04dda5..fb17756 100644 --- a/example_config/cardmaker.yaml +++ b/example_config/cardmaker.yaml @@ -1,3 +1,13 @@ server: enable: True loglevel: "info" + +version: + 0: + ongeki: 1.30.01 + chuni: 2.00.00 + maimai: 1.20.00 + 1: + ongeki: 1.35.03 + chuni: 2.10.00 + maimai: 1.30.00 \ No newline at end of file diff --git a/readme.md b/readme.md index ee407cd..f114bb0 100644 --- a/readme.md +++ b/readme.md @@ -17,7 +17,7 @@ Games listed below have been tested and confirmed working. Only game versions ol + All versions + Card Maker - + 1.34 + + 1.30 + 1.35 + O.N.G.E.K.I. diff --git a/titles/cm/base.py b/titles/cm/base.py index ff38489..dae6ecb 100644 --- a/titles/cm/base.py +++ b/titles/cm/base.py @@ -23,19 +23,40 @@ class CardMakerBase: self.game = CardMakerConstants.GAME_CODE self.version = CardMakerConstants.VER_CARD_MAKER + @staticmethod + def _parse_int_ver(version: str) -> str: + return version.replace(".", "")[:3] + def handle_get_game_connect_api_request(self, data: Dict) -> Dict: if self.core_cfg.server.is_develop: uri = f"http://{self.core_cfg.title.hostname}:{self.core_cfg.title.port}" else: uri = f"http://{self.core_cfg.title.hostname}" - # CHUNITHM = 0, maimai = 1, ONGEKI = 2 + # grab the dict with all games version numbers from user config + games_ver = self.game_cfg.version.version(self.version) + return { "length": 3, "gameConnectList": [ - {"modelKind": 0, "type": 1, "titleUri": f"{uri}/SDHD/200/"}, - {"modelKind": 1, "type": 1, "titleUri": f"{uri}/SDEZ/120/"}, - {"modelKind": 2, "type": 1, "titleUri": f"{uri}/SDDT/130/"}, + # CHUNITHM + { + "modelKind": 0, + "type": 1, + "titleUri": f"{uri}/SDHD/{self._parse_int_ver(games_ver['chuni'])}/", + }, + # maimai DX + { + "modelKind": 1, + "type": 1, + "titleUri": f"{uri}/SDEZ/{self._parse_int_ver(games_ver['maimai'])}/", + }, + # ONGEKI + { + "modelKind": 2, + "type": 1, + "titleUri": f"{uri}/SDDT/{self._parse_int_ver(games_ver['ongeki'])}/", + }, ], } @@ -47,12 +68,15 @@ class CardMakerBase: datetime.now() + timedelta(hours=4), self.date_time_format ) + # grab the dict with all games version numbers from user config + games_ver = self.game_cfg.version.version(self.version) + return { "gameSetting": { "dataVersion": "1.30.00", - "ongekiCmVersion": "1.30.01", - "chuniCmVersion": "2.00.00", - "maimaiCmVersion": "1.20.00", + "ongekiCmVersion": games_ver["ongeki"], + "chuniCmVersion": games_ver["chuni"], + "maimaiCmVersion": games_ver["maimai"], "requestInterval": 10, "rebootStartTime": reboot_start, "rebootEndTime": reboot_end, diff --git a/titles/cm/cm135.py b/titles/cm/cm135.py index 782f07a..e134974 100644 --- a/titles/cm/cm135.py +++ b/titles/cm/cm135.py @@ -1,8 +1,4 @@ -from datetime import date, datetime, timedelta -from typing import Any, Dict, List -import json -import logging -from enum import Enum +from typing import Dict from core.config import CoreConfig from core.data.cache import cached @@ -16,23 +12,7 @@ class CardMaker135(CardMakerBase): super().__init__(core_cfg, game_cfg) self.version = CardMakerConstants.VER_CARD_MAKER_135 - def handle_get_game_connect_api_request(self, data: Dict) -> Dict: - ret = super().handle_get_game_connect_api_request(data) - if self.core_cfg.server.is_develop: - uri = f"http://{self.core_cfg.title.hostname}:{self.core_cfg.title.port}" - else: - uri = f"http://{self.core_cfg.title.hostname}" - - ret["gameConnectList"][0]["titleUri"] = f"{uri}/SDHD/205/" - ret["gameConnectList"][1]["titleUri"] = f"{uri}/SDEZ/125/" - ret["gameConnectList"][2]["titleUri"] = f"{uri}/SDDT/135/" - - return ret - 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" - ret["gameSetting"]["ongekiCmVersion"] = "1.35.03" - ret["gameSetting"]["chuniCmVersion"] = "2.05.00" - ret["gameSetting"]["maimaiCmVersion"] = "1.25.00" return ret diff --git a/titles/cm/config.py b/titles/cm/config.py index ea96ca1..8bb23ec 100644 --- a/titles/cm/config.py +++ b/titles/cm/config.py @@ -1,3 +1,4 @@ +from typing import Dict from core.config import CoreConfig @@ -20,6 +21,21 @@ class CardMakerServerConfig: ) +class CardMakerVersionConfig: + def __init__(self, parent_config: "CardMakerConfig") -> None: + self.__config = parent_config + + def version(self, version: int) -> Dict: + """ + in the form of: + 1: {"ongeki": 1.30.01, "chuni": 2.00.00, "maimai": 1.20.00} + """ + return CoreConfig.get_config_field( + self.__config, "cardmaker", "version", default={} + )[version] + + class CardMakerConfig(dict): def __init__(self) -> None: self.server = CardMakerServerConfig(self) + self.version = CardMakerVersionConfig(self) diff --git a/titles/cm/const.py b/titles/cm/const.py index 09f289e..5bb6d1f 100644 --- a/titles/cm/const.py +++ b/titles/cm/const.py @@ -6,7 +6,7 @@ class CardMakerConstants: VER_CARD_MAKER = 0 VER_CARD_MAKER_135 = 1 - VERSION_NAMES = ("Card Maker 1.34", "Card Maker 1.35") + VERSION_NAMES = ("Card Maker 1.30", "Card Maker 1.35") @classmethod def game_ver_to_string(cls, ver: int): diff --git a/titles/cm/index.py b/titles/cm/index.py index 74d3a0d..3bde49c 100644 --- a/titles/cm/index.py +++ b/titles/cm/index.py @@ -30,7 +30,7 @@ class CardMakerServlet: self.versions = [ CardMakerBase(core_cfg, self.game_cfg), - CardMaker135(core_cfg, self.game_cfg), + CardMaker135(core_cfg, self.game_cfg) ] self.logger = logging.getLogger("cardmaker") @@ -89,7 +89,7 @@ class CardMakerServlet: if version >= 130 and version < 135: # Card Maker internal_ver = CardMakerConstants.VER_CARD_MAKER - elif version >= 135 and version < 136: # Card Maker 1.35 + elif version >= 135 and version < 140: # Card Maker 1.35 internal_ver = CardMakerConstants.VER_CARD_MAKER_135 if all(c in string.hexdigits for c in endpoint) and len(endpoint) == 32: diff --git a/titles/mai2/__init__.py b/titles/mai2/__init__.py index 810eac9..c9d7db2 100644 --- a/titles/mai2/__init__.py +++ b/titles/mai2/__init__.py @@ -7,4 +7,4 @@ index = Mai2Servlet database = Mai2Data reader = Mai2Reader game_codes = [Mai2Constants.GAME_CODE] -current_schema_version = 4 +current_schema_version = 5 diff --git a/titles/mai2/schema/item.py b/titles/mai2/schema/item.py index 6280bbb..6b70ed1 100644 --- a/titles/mai2/schema/item.py +++ b/titles/mai2/schema/item.py @@ -39,8 +39,8 @@ card = Table( Column("cardTypeId", Integer, nullable=False), Column("charaId", Integer, nullable=False), Column("mapId", Integer, nullable=False), - Column("startDate", TIMESTAMP, server_default="2018-01-01 00:00:00.0"), - Column("endDate", TIMESTAMP, server_default="2038-01-01 00:00:00.0"), + Column("startDate", TIMESTAMP, nullable=False, server_default=func.now()), + Column("endDate", TIMESTAMP, nullable=False), UniqueConstraint("user", "cardId", "cardTypeId", name="mai2_item_card_uk"), mysql_charset="utf8mb4", ) @@ -444,6 +444,8 @@ class Mai2ItemData(BaseData): card_kind: int, chara_id: int, map_id: int, + start_date: datetime, + end_date: datetime, ) -> Optional[Row]: sql = insert(card).values( user=user_id, @@ -451,9 +453,13 @@ class Mai2ItemData(BaseData): cardTypeId=card_kind, charaId=chara_id, mapId=map_id, + startDate=start_date, + endDate=end_date, ) - conflict = sql.on_duplicate_key_update(charaId=chara_id, mapId=map_id) + conflict = sql.on_duplicate_key_update( + charaId=chara_id, mapId=map_id, startDate=start_date, endDate=end_date + ) result = self.execute(conflict) if result is None: diff --git a/titles/mai2/universe.py b/titles/mai2/universe.py index 56b3e8f..7cbd159 100644 --- a/titles/mai2/universe.py +++ b/titles/mai2/universe.py @@ -104,8 +104,12 @@ class Mai2Universe(Mai2Base): tmp.pop("id") tmp.pop("user") - tmp["startDate"] = datetime.strftime(tmp["startDate"], "%Y-%m-%d %H:%M:%S") - tmp["endDate"] = datetime.strftime(tmp["endDate"], "%Y-%m-%d %H:%M:%S") + tmp["startDate"] = datetime.strftime( + tmp["startDate"], Mai2Constants.DATE_TIME_FORMAT + ) + tmp["endDate"] = datetime.strftime( + tmp["endDate"], Mai2Constants.DATE_TIME_FORMAT + ) card_list.append(tmp) return { @@ -154,6 +158,10 @@ class Mai2Universe(Mai2Base): # set a random card serial number serial_id = "".join([str(randint(0, 9)) for _ in range(20)]) + # calculate start and end date of the card + start_date = datetime.utcnow() + end_date = datetime.utcnow() + timedelta(days=15) + user_card = upsert["userCard"] self.data.item.put_card( user_id, @@ -161,8 +169,26 @@ class Mai2Universe(Mai2Base): user_card["cardTypeId"], user_card["charaId"], user_card["mapId"], + # add the correct start date and also the end date in 15 days + start_date, + end_date, ) + # get the profile extend to save the new bought card + extend = self.data.profile.get_profile_extend(user_id, self.version) + if extend: + extend = extend._asdict() + # parse the selectedCardList + # 6 = Freedom Pass, 4 = Gold Pass (cardTypeId) + selected_cards: list = extend["selectedCardList"] + + # if no pass is already added, add the corresponding pass + if not user_card["cardTypeId"] in selected_cards: + selected_cards.insert(0, user_card["cardTypeId"]) + + extend["selectedCardList"] = selected_cards + self.data.profile.put_profile_extend(user_id, self.version, extend) + # properly format userPrintDetail for the database upsert.pop("userCard") upsert.pop("serialId") @@ -174,8 +200,8 @@ class Mai2Universe(Mai2Base): "returnCode": 1, "orderId": 0, "serialId": serial_id, - "startDate": "2018-01-01 00:00:00", - "endDate": "2038-01-01 00:00:00", + "startDate": datetime.strftime(start_date, Mai2Constants.DATE_TIME_FORMAT), + "endDate": datetime.strftime(end_date, Mai2Constants.DATE_TIME_FORMAT), } def handle_cm_upsert_user_printlog_api_request(self, data: Dict) -> Dict: