Adding Ongeki Bright Memory support

This commit is contained in:
2023-03-03 00:00:22 -05:00
parent 937dba20ca
commit 3791b2b238
10 changed files with 148 additions and 3 deletions

View File

@ -787,6 +787,10 @@ class OngekiBase():
if "userChapterList" in upsert:
for x in upsert["userChapterList"]:
self.data.item.put_chapter(user_id, x)
if "userMemoryChapterList" in upsert:
for x in upsert["userMemoryChapterList"]:
self.data.item.put_memorychapter(user_id, x)
if "userItemList" in upsert:
for x in upsert["userItemList"]:

View File

@ -0,0 +1,58 @@
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 OngekiBrightMemory(OngekiBase):
def __init__(self, core_cfg: CoreConfig, game_cfg: OngekiConfig) -> None:
super().__init__(core_cfg, game_cfg)
self.version = OngekiConstants.VER_ONGEKI_BRIGHT_MEMORY
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"]["onlineDataVersion"] = "1.35.00"
ret["gameSetting"]["maxCountCharacter"] = 50
ret["gameSetting"]["maxCountCard"] = 300
ret["gameSetting"]["maxCountItem"] = 300
ret["gameSetting"]["maxCountMusic"] = 50
ret["gameSetting"]["maxCountMusicItem"] = 300
ret["gameSetting"]["maxCountRivalMusic"] = 300
return ret
def handle_get_user_memory_chapter_api_request(self, data: Dict) -> Dict:
memories = self.data.item.get_memorychapters(data["userId"])
if not memories:
return {"userId": data["userId"], "length":6, "userMemoryChapterList":[
{"gaugeId":0, "isClear": False, "gaugeNum": 0, "chapterId": 70001, "jewelCount": 0, "isBossWatched": False, "isStoryWatched": False, "isDialogWatched": False, "isEndingWatched": False, "lastPlayMusicId": 0, "lastPlayMusicLevel": 0, "lastPlayMusicCategory": 0},
{"gaugeId":0, "isClear": False, "gaugeNum": 0, "chapterId": 70002, "jewelCount": 0, "isBossWatched": False, "isStoryWatched": False, "isDialogWatched": False, "isEndingWatched": False, "lastPlayMusicId": 0, "lastPlayMusicLevel": 0, "lastPlayMusicCategory": 0},
{"gaugeId":0, "isClear": False, "gaugeNum": 0, "chapterId": 70003, "jewelCount": 0, "isBossWatched": False, "isStoryWatched": False, "isDialogWatched": False, "isEndingWatched": False, "lastPlayMusicId": 0, "lastPlayMusicLevel": 0, "lastPlayMusicCategory": 0},
{"gaugeId":0, "isClear": False, "gaugeNum": 0, "chapterId": 70004, "jewelCount": 0, "isBossWatched": False, "isStoryWatched": False, "isDialogWatched": False, "isEndingWatched": False, "lastPlayMusicId": 0, "lastPlayMusicLevel": 0, "lastPlayMusicCategory": 0},
{"gaugeId":0, "isClear": False, "gaugeNum": 0, "chapterId": 70005, "jewelCount": 0, "isBossWatched": False, "isStoryWatched": False, "isDialogWatched": False, "isEndingWatched": False, "lastPlayMusicId": 0, "lastPlayMusicLevel": 0, "lastPlayMusicCategory": 0},
{"gaugeId":0, "isClear": False, "gaugeNum": 0, "chapterId": 70099, "jewelCount": 0, "isBossWatched": False, "isStoryWatched": False, "isDialogWatched": False, "isEndingWatched": False, "lastPlayMusicId": 0, "lastPlayMusicLevel": 0, "lastPlayMusicCategory": 0}
]}
memory_chp = []
for chp in memories:
tmp = chp._asdict()
tmp.pop("id")
tmp.pop("user")
memory_chp.append(tmp)
return {
"userId": data["userId"],
"length": len(memory_chp),
"userMemoryChapterList": memory_chp
}
def handle_get_game_music_release_state_api_request(self, data: Dict) -> Dict:
return {
"techScore": 0,
"cardNum": 0
}

View File

@ -10,6 +10,7 @@ class OngekiConstants():
VER_ONGEKI_RED = 4
VER_ONGEKI_RED_PLUS = 5
VER_ONGEKI_BRIGHT = 6
VER_ONGEKI_BRIGHT_MEMORY = 7
EVT_TYPES: Enum = Enum('EVT_TYPES', [
'None',
@ -43,7 +44,7 @@ class OngekiConstants():
Lunatic = 10
VERSION_NAMES = ("ONGEKI", "ONGEKI+", "ONGEKI Summer", "ONGEKI Summer+", "ONGEKI Red", "ONGEKI Red+",
"ONGEKI Bright")
"ONGEKI Bright", "ONGEKI Bright Memory")
@classmethod
def game_ver_to_string(cls, ver: int):

View File

@ -17,6 +17,7 @@ from titles.ongeki.summerplus import OngekiSummerPlus
from titles.ongeki.red import OngekiRed
from titles.ongeki.redplus import OngekiRedPlus
from titles.ongeki.bright import OngekiBright
from titles.ongeki.brightmemory import OngekiBrightMemory
class OngekiServlet():
def __init__(self, core_cfg: CoreConfig, cfg_dir: str) -> None:
@ -32,6 +33,7 @@ class OngekiServlet():
OngekiRed(core_cfg, self.game_cfg),
OngekiRedPlus(core_cfg, self.game_cfg),
OngekiBright(core_cfg, self.game_cfg),
OngekiBrightMemory(core_cfg, self.game_cfg),
]
self.logger = logging.getLogger("ongeki")
@ -69,8 +71,10 @@ class OngekiServlet():
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
elif version >= 130 and version < 135: # Bright
internal_ver = OngekiConstants.VER_ONGEKI_BRIGHT
elif version >= 135 and version < 140: # Bright Memory
internal_ver = OngekiConstants.VER_ONGEKI_BRIGHT_MEMORY
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

View File

@ -107,6 +107,27 @@ chapter = Table(
mysql_charset='utf8mb4'
)
memorychapter = Table(
"ongeki_user_memorychapter",
metadata,
Column("id", Integer, primary_key=True, nullable=False),
Column("user", ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade")),
Column("chapterId", Integer),
Column("gaugeId", Integer),
Column("gaugeNum", Integer),
Column("jewelCount", Integer),
Column("isStoryWatched", Boolean),
Column("isBossWatched", Boolean),
Column("isDialogWatched", Boolean),
Column("isEndingWatched", Boolean),
Column("isClear", Boolean),
Column("lastPlayMusicId", Integer),
Column("lastPlayMusicLevel", Integer),
Column("lastPlayMusicCategory", Integer),
UniqueConstraint("user", "chapterId", name="ongeki_user_memorychapter_uk"),
mysql_charset='utf8mb4'
)
item = Table(
"ongeki_user_item",
metadata,
@ -522,5 +543,24 @@ class OngekiItemData(BaseData):
sql = select(boss).where(boss.c.user == aime_id)
result = self.execute(sql)
if result is None: return None
return result.fetchall()
def put_memorychapter(self, aime_id: int, memorychapter_data: Dict) -> Optional[int]:
memorychapter_data["user"] = aime_id
sql = insert(memorychapter).values(**memorychapter_data)
conflict = sql.on_duplicate_key_update(**memorychapter_data)
result = self.execute(conflict)
if result is None:
self.logger.warn(f"put_memorychapter: Failed to update! aime_id: {aime_id}")
return None
return result.lastrowid
def get_memorychapters(self, aime_id: int) -> Optional[List[Dict]]:
sql = select(memorychapter).where(memorychapter.c.user == aime_id)
result = self.execute(sql)
if result is None: return None
return result.fetchall()

View File

@ -78,6 +78,7 @@ profile = Table(
Column("overDamageBattlePoint", Integer, server_default="0"),
Column("bestBattlePoint", Integer, server_default="0"),
Column("lastEmoneyBrand", Integer, server_default="0"),
Column("isDialogWatchedSuggestMemory", Boolean),
UniqueConstraint("user", "version", name="ongeki_profile_profile_uk"),
mysql_charset='utf8mb4'
)

View File

@ -28,6 +28,7 @@ score_best = Table(
Column("isLock", Boolean, nullable=False),
Column("clearStatus", Boolean, nullable=False),
Column("isStoryWatched", Boolean, nullable=False),
Column("platinumScoreMax", Integer),
UniqueConstraint("user", "musicId", "level", name="ongeki_best_score_uk"),
mysql_charset='utf8mb4'
)
@ -96,6 +97,8 @@ playlog = Table(
Column("isAllBreak", Boolean),
Column("playerRating", Integer),
Column("battlePoint", Integer),
Column("platinumScore", Integer),
Column("platinumScoreMax", Integer),
mysql_charset='utf8mb4'
)