forked from Dniel97/artemis
mai2: added upsert returns, fixed event reader, thanks @One3
Thanks to @One3 for helping with the events
This commit is contained in:
parent
f63dd07937
commit
28c06335b6
@ -98,16 +98,16 @@ class Mai2Base:
|
||||
return {"length": len(charge_list), "gameChargeList": charge_list}
|
||||
|
||||
def handle_upsert_client_setting_api_request(self, data: Dict) -> Dict:
|
||||
pass
|
||||
return {"returnCode": 1, "apiName": "UpsertClientSettingApi"}
|
||||
|
||||
def handle_upsert_client_upload_api_request(self, data: Dict) -> Dict:
|
||||
pass
|
||||
return {"returnCode": 1, "apiName": "UpsertClientUploadApi"}
|
||||
|
||||
def handle_upsert_client_bookkeeping_api_request(self, data: Dict) -> Dict:
|
||||
pass
|
||||
return {"returnCode": 1, "apiName": "UpsertClientBookkeepingApi"}
|
||||
|
||||
def handle_upsert_client_testmode_api_request(self, data: Dict) -> Dict:
|
||||
pass
|
||||
return {"returnCode": 1, "apiName": "UpsertClientTestmodeApi"}
|
||||
|
||||
def handle_get_user_preview_api_request(self, data: Dict) -> Dict:
|
||||
p = self.data.profile.get_profile_detail(data["userId"], self.version)
|
||||
@ -172,6 +172,8 @@ class Mai2Base:
|
||||
|
||||
self.data.score.put_playlog(user_id, playlog)
|
||||
|
||||
return {"returnCode": 1, "apiName": "UploadUserPlaylogApi"}
|
||||
|
||||
def handle_upsert_user_chargelog_api_request(self, data: Dict) -> Dict:
|
||||
user_id = data["userId"]
|
||||
charge = data["userCharge"]
|
||||
@ -186,6 +188,8 @@ class Mai2Base:
|
||||
datetime.strptime(charge["validDate"], Mai2Constants.DATE_TIME_FORMAT),
|
||||
)
|
||||
|
||||
return {"returnCode": 1, "apiName": "UpsertUserChargelogApi"}
|
||||
|
||||
def handle_upsert_user_all_api_request(self, data: Dict) -> Dict:
|
||||
user_id = data["userId"]
|
||||
upsert = data["upsertUserAll"]
|
||||
@ -300,8 +304,10 @@ class Mai2Base:
|
||||
)
|
||||
self.data.item.put_friend_season_ranking(user_id, fsr)
|
||||
|
||||
return {"returnCode": 1, "apiName": "UpsertUserAllApi"}
|
||||
|
||||
def handle_user_logout_api_request(self, data: Dict) -> Dict:
|
||||
pass
|
||||
return {"returnCode": 1}
|
||||
|
||||
def handle_get_user_data_api_request(self, data: Dict) -> Dict:
|
||||
profile = self.data.profile.get_profile_detail(data["userId"], self.version)
|
||||
|
@ -29,7 +29,7 @@ class Mai2Reader(BaseReader):
|
||||
f"Start importer for {Mai2Constants.game_ver_to_string(version)}"
|
||||
)
|
||||
except IndexError:
|
||||
self.logger.error(f"Invalid maidx version {version}")
|
||||
self.logger.error(f"Invalid maimai DX version {version}")
|
||||
exit(1)
|
||||
|
||||
def read(self) -> None:
|
||||
@ -43,6 +43,7 @@ class Mai2Reader(BaseReader):
|
||||
for dir in data_dirs:
|
||||
self.logger.info(f"Read from {dir}")
|
||||
self.get_events(f"{dir}/event")
|
||||
self.disable_events(f"{dir}/information", f"{dir}/scoreRanking")
|
||||
self.read_music(f"{dir}/music")
|
||||
self.read_tickets(f"{dir}/ticket")
|
||||
|
||||
@ -64,6 +65,64 @@ class Mai2Reader(BaseReader):
|
||||
)
|
||||
self.logger.info(f"Added event {id}...")
|
||||
|
||||
def disable_events(
|
||||
self, base_information_dir: str, base_score_ranking_dir: str
|
||||
) -> None:
|
||||
self.logger.info(f"Reading disabled events from {base_information_dir}...")
|
||||
|
||||
for root, dirs, files in os.walk(base_information_dir):
|
||||
for dir in dirs:
|
||||
if os.path.exists(f"{root}/{dir}/Information.xml"):
|
||||
with open(f"{root}/{dir}/Information.xml", encoding="utf-8") as f:
|
||||
troot = ET.fromstring(f.read())
|
||||
|
||||
event_id = int(troot.find("name").find("id").text)
|
||||
|
||||
self.data.static.toggle_game_event(
|
||||
self.version, event_id, toggle=False
|
||||
)
|
||||
self.logger.info(f"Disabled event {event_id}...")
|
||||
|
||||
for root, dirs, files in os.walk(base_score_ranking_dir):
|
||||
for dir in dirs:
|
||||
if os.path.exists(f"{root}/{dir}/ScoreRanking.xml"):
|
||||
with open(f"{root}/{dir}/ScoreRanking.xml", encoding="utf-8") as f:
|
||||
troot = ET.fromstring(f.read())
|
||||
|
||||
event_id = int(troot.find("eventName").find("id").text)
|
||||
|
||||
self.data.static.toggle_game_event(
|
||||
self.version, event_id, toggle=False
|
||||
)
|
||||
self.logger.info(f"Disabled event {event_id}...")
|
||||
|
||||
# manually disable events wich are known to be problematic
|
||||
for event_id in [
|
||||
1,
|
||||
10,
|
||||
220311,
|
||||
220312,
|
||||
220313,
|
||||
220314,
|
||||
220315,
|
||||
220316,
|
||||
220317,
|
||||
220318,
|
||||
20121821,
|
||||
21121651,
|
||||
22091511,
|
||||
22091512,
|
||||
22091513,
|
||||
22091514,
|
||||
22091515,
|
||||
22091516,
|
||||
22091517,
|
||||
22091518,
|
||||
22091519,
|
||||
]:
|
||||
self.data.static.toggle_game_event(self.version, event_id, toggle=False)
|
||||
self.logger.info(f"Disabled event {event_id}...")
|
||||
|
||||
def read_music(self, base_dir: str) -> None:
|
||||
self.logger.info(f"Reading music from {base_dir}...")
|
||||
|
||||
|
@ -246,16 +246,16 @@ class Mai2ItemData(BaseData):
|
||||
) -> None:
|
||||
sql = insert(login_bonus).values(
|
||||
user=user_id,
|
||||
bonus_id=bonus_id,
|
||||
bonusId=bonus_id,
|
||||
point=point,
|
||||
is_current=is_current,
|
||||
is_complete=is_complete,
|
||||
isCurrent=is_current,
|
||||
isComplete=is_complete,
|
||||
)
|
||||
|
||||
conflict = sql.on_duplicate_key_update(
|
||||
point=point,
|
||||
is_current=is_current,
|
||||
is_complete=is_complete,
|
||||
isCurrent=is_current,
|
||||
isComplete=is_complete,
|
||||
)
|
||||
|
||||
result = self.execute(conflict)
|
||||
|
@ -113,7 +113,7 @@ class Mai2StaticData(BaseData):
|
||||
self, version: int, event_id: int, toggle: bool
|
||||
) -> Optional[List]:
|
||||
sql = event.update(
|
||||
and_(event.c.version == version, event.c.event_id == event_id)
|
||||
and_(event.c.version == version, event.c.eventId == event_id)
|
||||
).values(enabled=int(toggle))
|
||||
|
||||
result = self.execute(sql)
|
||||
|
Loading…
Reference in New Issue
Block a user