cm: added support for 1.36, fixed importer

- Added support for Card Maker 1.36.xx
- Added cards importer to ONGEKI importer
- Added 4 new 1.36 gachas (requires importing them from opt files)
- Fixed version for Card Maker opt importer
This commit is contained in:
Dniel97
2023-03-05 23:54:13 +01:00
parent fe8f40c627
commit 74f3ab7c3f
16 changed files with 453 additions and 1844 deletions

View File

@@ -15,4 +15,4 @@ trailing_slash = True
use_default_host = False
host = ""
current_schema_version = 2
current_schema_version = 2

View File

@@ -22,10 +22,8 @@ class OngekiBright(OngekiBase):
return ret
def handle_cm_get_user_data_api_request(self, data: Dict) -> Dict:
# first check for a bright memory profile after that check for a
# bright profile
p = (self.data.profile.get_profile_data(data["userId"], self.version+1)
or self.data.profile.get_profile_data(data["userId"], self.version))
# check for a bright profile
p = self.data.profile.get_profile_data(data["userId"], self.version)
if p is None:
return {}
@@ -50,6 +48,8 @@ class OngekiBright(OngekiBase):
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"
return {"userId": data["userId"], "userData": user_data}
@@ -195,7 +195,9 @@ class OngekiBright(OngekiBase):
# make sure to only show gachas for the current version
# so only up to bright, 1140 is the first bright memory gacha
if tmp["gachaId"] < 1140:
if self.version == OngekiConstants.VER_ONGEKI_BRIGHT_MEMORY:
game_gacha_list.append(tmp)
elif self.version == OngekiConstants.VER_ONGEKI_BRIGHT and tmp["gachaId"] < 1140:
game_gacha_list.append(tmp)
return {
@@ -379,11 +381,11 @@ class OngekiBright(OngekiBase):
if "userData" in upsert and len(upsert["userData"]) > 0:
# check if the profile is a bright memory profile
p = self.data.profile.get_profile_data(data["userId"], self.version+1)
p = self.data.profile.get_profile_data(data["userId"], self.version)
if p is not None:
# save the bright memory profile
self.data.profile.put_profile_data(
user_id, self.version+1, upsert["userData"][0])
user_id, self.version, upsert["userData"][0])
else:
# save the bright profile
self.data.profile.put_profile_data(
@@ -413,11 +415,11 @@ class OngekiBright(OngekiBase):
if "userData" in upsert and len(upsert["userData"]) > 0:
# check if the profile is a bright memory profile
p = self.data.profile.get_profile_data(data["userId"], self.version+1)
p = self.data.profile.get_profile_data(data["userId"], self.version)
if p is not None:
# save the bright memory profile
self.data.profile.put_profile_data(
user_id, self.version+1, upsert["userData"][0])
user_id, self.version, upsert["userData"][0])
else:
# save the bright profile
self.data.profile.put_profile_data(
@@ -601,11 +603,11 @@ class OngekiBright(OngekiBase):
if "userData" in upsert and len(upsert["userData"]) > 0:
# check if the profile is a bright memory profile
p = self.data.profile.get_profile_data(data["userId"], self.version+1)
p = self.data.profile.get_profile_data(data["userId"], self.version)
if p is not None:
# save the bright memory profile
self.data.profile.put_profile_data(
user_id, self.version+1, upsert["userData"][0])
user_id, self.version, upsert["userData"][0])
else:
# save the bright profile
self.data.profile.put_profile_data(

View File

@@ -5,11 +5,12 @@ import json
from core.config import CoreConfig
from titles.ongeki.base import OngekiBase
from titles.ongeki.bright import OngekiBright
from titles.ongeki.const import OngekiConstants
from titles.ongeki.config import OngekiConfig
class OngekiBrightMemory(OngekiBase):
class OngekiBrightMemory(OngekiBright):
def __init__(self, core_cfg: CoreConfig, game_cfg: OngekiConfig) -> None:
super().__init__(core_cfg, game_cfg)
self.version = OngekiConstants.VER_ONGEKI_BRIGHT_MEMORY
@@ -28,7 +29,7 @@ class OngekiBrightMemory(OngekiBase):
def handle_get_user_memory_chapter_api_request(self, data: Dict) -> Dict:
memories = self.data.item.get_memorychapters(data["userId"])
if not memories:
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},
@@ -37,17 +38,17 @@ class OngekiBrightMemory(OngekiBase):
{"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),
"userId": data["userId"],
"length": len(memory_chp),
"userMemoryChapterList": memory_chp
}
@@ -55,4 +56,15 @@ class OngekiBrightMemory(OngekiBase):
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.00 = 1.30.01
# Card Maker 1.36.00 = 1.35.04
user_data["userData"]["compatibleCmVersion"] = "1.35.04"
return user_data

View File

@@ -11,29 +11,99 @@ 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:
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)}")
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")
self.read_card(f"{dir}/card")
def read_card(self, base_dir: str) -> None:
self.logger.info(f"Reading cards from {base_dir}...")
version_ids = {
'1000': OngekiConstants.VER_ONGEKI,
'1005': OngekiConstants.VER_ONGEKI_PLUS,
'1010': OngekiConstants.VER_ONGEKI_SUMMER,
'1015': OngekiConstants.VER_ONGEKI_SUMMER_PLUS,
'1020': OngekiConstants.VER_ONGEKI_RED,
'1025': OngekiConstants.VER_ONGEKI_RED_PLUS,
'1030': OngekiConstants.VER_ONGEKI_BRIGHT,
'1035': OngekiConstants.VER_ONGEKI_BRIGHT_MEMORY
}
for root, dirs, files in os.walk(base_dir):
for dir in dirs:
if os.path.exists(f"{root}/{dir}/Card.xml"):
with open(f"{root}/{dir}/Card.xml", "r", encoding="utf-8") as f:
troot = ET.fromstring(f.read())
card_id = int(troot.find('Name').find('id').text)
# skip already existing cards
if self.data.static.get_card(
OngekiConstants.VER_ONGEKI_BRIGHT_MEMORY, card_id) is not None:
self.logger.info(f"Card {card_id} already added, skipping")
continue
name = troot.find('Name').find('str').text
chara_id = int(troot.find('CharaID').find('id').text)
nick_name = troot.find('NickName').text
school = troot.find('School').find('str').text
attribute = troot.find('Attribute').text
gakunen = troot.find('Gakunen').find('str').text
rarity = OngekiConstants.RARITY_TYPES[
troot.find('Rarity').text].value
level_param = []
for lvl in troot.find('LevelParam').findall('int'):
level_param.append(lvl.text)
skill_id = int(troot.find('SkillID').find('id').text)
cho_kai_ka_skill_id = int(troot.find('ChoKaikaSkillID').find('id').text)
version = version_ids[
troot.find('VersionID').find('id').text]
card_number = troot.find('CardNumberString').text
self.data.static.put_card(
version,
card_id,
name=name,
charaId=chara_id,
nickName=nick_name,
school=school,
attribute=attribute,
gakunen=gakunen,
rarity=rarity,
levelParam=','.join(level_param),
skillId=skill_id,
choKaikaSkillId=cho_kai_ka_skill_id,
cardNumber=card_number
)
self.logger.info(f"Added card {card_id}")
def read_events(self, base_dir: str) -> None:
self.logger.info(f"Reading events from {base_dir}...")
@@ -45,12 +115,13 @@ class OngekiReader(BaseReader):
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
event_type = OngekiConstants.EVT_TYPES[troot.find(
'EventType').text].value
self.data.static.put_event(self.version, id, event_type, name)
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}...")
@@ -72,9 +143,9 @@ class OngekiReader(BaseReader):
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'):
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
@@ -82,8 +153,9 @@ class OngekiReader(BaseReader):
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}")
)
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}")

View File

@@ -180,7 +180,7 @@ region = Table(
mysql_charset='utf8mb4'
)
training_room = Table (
training_room = Table(
"ongeki_profile_training_room",
metadata,
Column("id", Integer, primary_key=True, nullable=False),
@@ -193,7 +193,7 @@ training_room = Table (
mysql_charset='utf8mb4'
)
kop = Table (
kop = Table(
"ongeki_profile_kop",
metadata,
Column("id", Integer, primary_key=True, nullable=False),
@@ -219,6 +219,7 @@ rival = Table(
mysql_charset='utf8mb4'
)
class OngekiProfileData(BaseData):
def __init__(self, cfg: CoreConfig, conn: Connection) -> None:
super().__init__(cfg, conn)
@@ -287,14 +288,14 @@ class OngekiProfileData(BaseData):
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)

View File

@@ -192,7 +192,7 @@ class OngekiStaticData(BaseData):
def get_gacha(self, version: int, gacha_id: int) -> Optional[Dict]:
sql = gachas.select(and_(
gachas.c.version == version,
gachas.c.version <= version,
gachas.c.gachaId == gacha_id
))