From 6a41dac46cf1196f310b03ada96045bd38c032fa Mon Sep 17 00:00:00 2001 From: Dniel97 Date: Wed, 12 Jul 2023 11:25:46 +0200 Subject: [PATCH] ongeki: card maker config added, small fixes, improved credits - Changed the credits config to the default 370 instead of 360 - Added `start_date` to the events to show new events - Fixed Card Maker Gachas to only allow "Select Gacha" once - Fixed the `get_profile_rating_log` database query --- core/data/schema/versions/SDDT_4_rollback.sql | 2 ++ core/data/schema/versions/SDDT_5_upgrade.sql | 2 ++ docs/game_specific_info.md | 26 ++++++++++++------- example_config/ongeki.yaml | 6 +++++ readme.md | 2 +- titles/ongeki/__init__.py | 2 +- titles/ongeki/base.py | 18 +++++++++---- titles/ongeki/bright.py | 19 +++++++++----- titles/ongeki/brightmemory.py | 11 -------- titles/ongeki/config.py | 17 ++++++++++++ titles/ongeki/const.py | 14 +++++----- titles/ongeki/index.py | 9 +++++-- titles/ongeki/schema/profile.py | 2 +- titles/ongeki/schema/static.py | 1 + 14 files changed, 87 insertions(+), 44 deletions(-) create mode 100644 core/data/schema/versions/SDDT_4_rollback.sql create mode 100644 core/data/schema/versions/SDDT_5_upgrade.sql diff --git a/core/data/schema/versions/SDDT_4_rollback.sql b/core/data/schema/versions/SDDT_4_rollback.sql new file mode 100644 index 0000000..fdd369b --- /dev/null +++ b/core/data/schema/versions/SDDT_4_rollback.sql @@ -0,0 +1,2 @@ +ALTER TABLE ongeki_static_events +DROP COLUMN startDate; \ No newline at end of file diff --git a/core/data/schema/versions/SDDT_5_upgrade.sql b/core/data/schema/versions/SDDT_5_upgrade.sql new file mode 100644 index 0000000..6d4b421 --- /dev/null +++ b/core/data/schema/versions/SDDT_5_upgrade.sql @@ -0,0 +1,2 @@ +ALTER TABLE ongeki_static_events +ADD COLUMN startDate TIMESTAMP NOT NULL DEFAULT current_timestamp(); \ No newline at end of file diff --git a/docs/game_specific_info.md b/docs/game_specific_info.md index d5d1eff..e2a8296 100644 --- a/docs/game_specific_info.md +++ b/docs/game_specific_info.md @@ -230,12 +230,12 @@ python dbutils.py --game SBZV upgrade |------------|----------------------------| | 0 | O.N.G.E.K.I. | | 1 | O.N.G.E.K.I. + | -| 2 | O.N.G.E.K.I. Summer | -| 3 | O.N.G.E.K.I. Summer + | -| 4 | O.N.G.E.K.I. Red | -| 5 | O.N.G.E.K.I. Red + | -| 6 | O.N.G.E.K.I. Bright | -| 7 | O.N.G.E.K.I. Bright Memory | +| 2 | O.N.G.E.K.I. SUMMER | +| 3 | O.N.G.E.K.I. SUMMER + | +| 4 | O.N.G.E.K.I. R.E.D. | +| 5 | O.N.G.E.K.I. R.E.D. + | +| 6 | O.N.G.E.K.I. bright | +| 7 | O.N.G.E.K.I. bright MEMORY | ### Importer @@ -285,12 +285,12 @@ python dbutils.py --game SDDT upgrade * Card Maker 1.30: * CHUNITHM NEW!!: Yes * maimai DX UNiVERSE: Yes - * O.N.G.E.K.I. Bright: Yes + * O.N.G.E.K.I. bright: Yes * Card Maker 1.35: * CHUNITHM SUN: Yes (NEW PLUS!! up to A032) * maimai DX FESTiVAL: Yes (up to A035) (UNiVERSE PLUS up to A031) - * O.N.G.E.K.I. Bright Memory: Yes + * O.N.G.E.K.I. bright MEMORY: Yes ### Importer @@ -345,7 +345,15 @@ Now update your `config/cardmaker.yaml` with the correct version number, for exa version: 1: # Card Maker 1.35 ongeki: 1.35.03 -``` +``` + +For now you also need to update your `config/ongeki.yaml` with the correct version number, for example: + +```yaml +version: + 7: # O.N.G.E.K.I. bright MEMORY + card_maker: 1.35.03 +``` ### O.N.G.E.K.I. diff --git a/example_config/ongeki.yaml b/example_config/ongeki.yaml index 3db7098..90233b3 100644 --- a/example_config/ongeki.yaml +++ b/example_config/ongeki.yaml @@ -29,3 +29,9 @@ gachas: - 1156 - 1163 - 1164 + +version: + 6: + card_maker: 1.30.01 + 7: + card_maker: 1.35.03 diff --git a/readme.md b/readme.md index 224fa5b..2c49faa 100644 --- a/readme.md +++ b/readme.md @@ -21,7 +21,7 @@ Games listed below have been tested and confirmed working. Only game versions ol + 1.35 + O.N.G.E.K.I. - + All versions up to Bright Memory + + All versions up to bright MEMORY + WACCA + Lily R diff --git a/titles/ongeki/__init__.py b/titles/ongeki/__init__.py index 1ba901b..b887ba6 100644 --- a/titles/ongeki/__init__.py +++ b/titles/ongeki/__init__.py @@ -7,4 +7,4 @@ index = OngekiServlet database = OngekiData reader = OngekiReader game_codes = [OngekiConstants.GAME_CODE] -current_schema_version = 4 +current_schema_version = 5 diff --git a/titles/ongeki/base.py b/titles/ongeki/base.py index f10353c..ace1d12 100644 --- a/titles/ongeki/base.py +++ b/titles/ongeki/base.py @@ -142,7 +142,7 @@ class OngekiBase: def handle_get_game_point_api_request(self, data: Dict) -> Dict: """ - Sets the GP ammount for A and B sets for 1 - 3 crdits + Sets the GP amount for A and B sets for 1 - 3 credits """ return { "length": 6, @@ -155,13 +155,13 @@ class OngekiBase: }, { "type": 1, - "cost": 200, + "cost": 230, "startDate": "2000-01-01 05:00:00.0", "endDate": "2099-01-01 05:00:00.0", }, { "type": 2, - "cost": 300, + "cost": 370, "startDate": "2000-01-01 05:00:00.0", "endDate": "2099-01-01 05:00:00.0", }, @@ -256,7 +256,11 @@ class OngekiBase: { "type": event["type"], "id": event["eventId"], - "startDate": "2017-12-05 07:00:00.0", + # actually use the startDate from the import so it + # properly shows all the events when new ones are imported + "startDate": datetime.strftime( + event["startDate"], "%Y-%m-%d %H:%M:%S.0" + ), "endDate": "2099-12-31 00:00:00.0", } ) @@ -560,7 +564,11 @@ class OngekiBase: 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 {} + return { + "userId": data["userId"], + "length": 0, + "userRecentRatingList": [], + } userRecentRatingList = recent_rating["recentRating"] diff --git a/titles/ongeki/bright.py b/titles/ongeki/bright.py index 06155a1..49d6216 100644 --- a/titles/ongeki/bright.py +++ b/titles/ongeki/bright.py @@ -43,15 +43,15 @@ class OngekiBright(OngekiBase): 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"] - # hardcode Card Maker version for now - # Card Maker 1.34.00 = 1.30.01 - # Card Maker 1.36.00 = 1.35.04 - user_data["compatibleCmVersion"] = "1.30.01" + # add the compatible card maker version from config + card_maker_ver = self.game_cfg.version.version(self.version) + if card_maker_ver and card_maker_ver.get("card_maker"): + # Card Maker 1.30 = 1.30.01+ + # Card Maker 1.35 = 1.35.03+ + user_data["compatibleCmVersion"] = card_maker_ver.get("card_maker") return {"userId": data["userId"], "userData": user_data} @@ -333,6 +333,8 @@ class OngekiBright(OngekiBase): select_point = data["selectPoint"] total_gacha_count, ceiling_gacha_count = 0, 0 + # 0 = can still use Gacha Select, 1 = already used Gacha Select + use_select_point = 0 daily_gacha_cnt, five_gacha_cnt, eleven_gacha_cnt = 0, 0, 0 daily_gacha_date = datetime.strptime("2000-01-01", "%Y-%m-%d") @@ -344,6 +346,9 @@ class OngekiBright(OngekiBase): daily_gacha_cnt = user_gacha["dailyGachaCnt"] five_gacha_cnt = user_gacha["fiveGachaCnt"] eleven_gacha_cnt = user_gacha["elevenGachaCnt"] + # if the Gacha Select has been used, make sure to keep it + if user_gacha["useSelectPoint"] == 1: + use_select_point = 1 # parse just the year, month and date daily_gacha_date = user_gacha["dailyGachaDate"] @@ -359,7 +364,7 @@ class OngekiBright(OngekiBase): totalGachaCnt=total_gacha_count + gacha_count, ceilingGachaCnt=ceiling_gacha_count + gacha_count, selectPoint=select_point, - useSelectPoint=0, + useSelectPoint=use_select_point, dailyGachaCnt=daily_gacha_cnt + gacha_count, fiveGachaCnt=five_gacha_cnt + 1 if gacha_count == 5 else five_gacha_cnt, elevenGachaCnt=eleven_gacha_cnt + 1 diff --git a/titles/ongeki/brightmemory.py b/titles/ongeki/brightmemory.py index 6e2548b..d7103a3 100644 --- a/titles/ongeki/brightmemory.py +++ b/titles/ongeki/brightmemory.py @@ -136,14 +136,3 @@ class OngekiBrightMemory(OngekiBright): def handle_get_game_music_release_state_api_request(self, data: Dict) -> Dict: return {"techScore": 0, "cardNum": 0} - - def handle_cm_get_user_data_api_request(self, data: Dict) -> Dict: - # check for a bright memory profile - user_data = super().handle_cm_get_user_data_api_request(data) - - # hardcode Card Maker version for now - # Card Maker 1.34 = 1.30.01 - # Card Maker 1.35 = 1.35.03 - user_data["userData"]["compatibleCmVersion"] = "1.35.03" - - return user_data diff --git a/titles/ongeki/config.py b/titles/ongeki/config.py index 1117b39..c20b1ed 100644 --- a/titles/ongeki/config.py +++ b/titles/ongeki/config.py @@ -1,3 +1,4 @@ +from ast import Dict from typing import List from core.config import CoreConfig @@ -33,7 +34,23 @@ class OngekiGachaConfig: ) +class OngekiCardMakerVersionConfig: + def __init__(self, parent_config: "OngekiConfig") -> None: + self.__config = parent_config + + def version(self, version: int) -> Dict: + """ + in the form of: + : {"card_maker": } + 6: {"card_maker": 1.30.01} + """ + return CoreConfig.get_config_field( + self.__config, "ongeki", "version", default={} + ).get(version) + + class OngekiConfig(dict): def __init__(self) -> None: self.server = OngekiServerConfig(self) self.gachas = OngekiGachaConfig(self) + self.version = OngekiCardMakerVersionConfig(self) diff --git a/titles/ongeki/const.py b/titles/ongeki/const.py index ceef317..8d4c4ab 100644 --- a/titles/ongeki/const.py +++ b/titles/ongeki/const.py @@ -66,13 +66,13 @@ class OngekiConstants: VERSION_NAMES = ( "ONGEKI", - "ONGEKI+", - "ONGEKI Summer", - "ONGEKI Summer+", - "ONGEKI Red", - "ONGEKI Red+", - "ONGEKI Bright", - "ONGEKI Bright Memory", + "ONGEKI +", + "ONGEKI SUMMER", + "ONGEKI SUMMER +", + "ONGEKI R.E.D.", + "ONGEKI R.E.D. +", + "ONGEKI bright", + "ONGEKI bright MEMORY", ) @classmethod diff --git a/titles/ongeki/index.py b/titles/ongeki/index.py index 7927d84..af206e9 100644 --- a/titles/ongeki/index.py +++ b/titles/ongeki/index.py @@ -11,6 +11,7 @@ from os import path from typing import Tuple from core.config import CoreConfig +from core.utils import Utils from titles.ongeki.config import OngekiConfig from titles.ongeki.const import OngekiConstants from titles.ongeki.base import OngekiBase @@ -101,6 +102,7 @@ class OngekiServlet: url_split = url_path.split("/") internal_ver = 0 endpoint = url_split[len(url_split) - 1] + client_ip = Utils.get_ip_addr(request) if version < 105: # 1.0 internal_ver = OngekiConstants.VER_ONGEKI @@ -137,7 +139,10 @@ class OngekiServlet: req_data = json.loads(unzip) - self.logger.info(f"v{version} {endpoint} request - {req_data}") + self.logger.info( + f"v{version} {endpoint} request from {client_ip}" + ) + self.logger.debug(req_data) func_to_find = "handle_" + inflection.underscore(endpoint) + "_request" @@ -156,6 +161,6 @@ class OngekiServlet: if resp == None: resp = {"returnCode": 1} - self.logger.info(f"Response {resp}") + self.logger.debug(f"Response {resp}") return zlib.compress(json.dumps(resp, ensure_ascii=False).encode("utf-8")) diff --git a/titles/ongeki/schema/profile.py b/titles/ongeki/schema/profile.py index a112bf2..374503e 100644 --- a/titles/ongeki/schema/profile.py +++ b/titles/ongeki/schema/profile.py @@ -316,7 +316,7 @@ class OngekiProfileData(BaseData): 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) + sql = select(rating_log).where(rating_log.c.user == aime_id) result = self.execute(sql) if result is None: diff --git a/titles/ongeki/schema/static.py b/titles/ongeki/schema/static.py index ed81ebf..b34802d 100644 --- a/titles/ongeki/schema/static.py +++ b/titles/ongeki/schema/static.py @@ -16,6 +16,7 @@ events = Table( Column("eventId", Integer), Column("type", Integer), Column("name", String(255)), + Column("startDate", TIMESTAMP, server_default=func.now()), Column("enabled", Boolean, server_default="1"), UniqueConstraint("version", "eventId", "type", name="ongeki_static_events_uk"), mysql_charset="utf8mb4",