[mai2] add buddies plus support (#177)

Adds favorite music support (there's an option in the results screen to star a song), handlers for new methods and fixes upsert failures for `userFavoriteList`.
The `UserIntimateApi` has been added but didn't seem to add any data during testing, and `CreateTokenApi`/`RemoveTokenApi` have also been added but I think they're only used during guest play.

---
Tested on 1.45 with no errors/game crashes (see logs). Card Maker hasn't been tested as I don't have a setup to play with.

Reviewed-on: https://gitea.tendokyu.moe/Hay1tsme/artemis/pulls/177
Co-authored-by: ppc <albie@ppc.moe>
Co-committed-by: ppc <albie@ppc.moe>
This commit is contained in:
ppc
2024-09-23 17:21:29 +00:00
committed by Hay1tsme
parent e85728f33c
commit f47175a144
13 changed files with 246 additions and 11 deletions

View File

@@ -242,7 +242,13 @@ class Mai2DX(Mai2Base):
if "userFavoriteList" in upsert and len(upsert["userFavoriteList"]) > 0:
for fav in upsert["userFavoriteList"]:
await self.data.item.put_favorite(user_id, fav["kind"], fav["itemIdList"])
kind_id = fav.get("kind", fav.get("itemKind")) # itemKind key used in BUDDiES+
if kind_id is not None:
await self.data.item.put_favorite(user_id, kind_id, fav["itemIdList"])
if "userFavoritemusicList" in upsert and len(upsert["userFavoritemusicList"]) > 0:
for fav in upsert["userFavoritemusicList"]:
await self.data.item.add_fav_music(user_id, fav["id"], fav["orderId"])
if (
"userFriendSeasonRankingList" in upsert
@@ -259,6 +265,11 @@ class Mai2DX(Mai2Base):
if "user2pPlaylog" in upsert:
await self.data.score.put_playlog_2p(user_id, upsert["user2pPlaylog"])
# added in BUDDiES+
if "userIntimateList" in upsert and len(upsert["userIntimateList"]) > 0:
for intimate in upsert["userIntimateList"]:
await self.data.profile.put_intimacy(user_id, intimate["partnerId"], intimate["intimateLevel"], intimate["intimateCountRewarded"])
return {"returnCode": 1, "apiName": "UpsertUserAllApi"}
async def handle_get_user_data_api_request(self, data: Dict) -> Dict:
@@ -708,6 +719,24 @@ class Mai2DX(Mai2Base):
ret['loginId'] = ret.get('loginCount', 0)
return ret
# Intimate api added in BUDDiES+
async def handle_get_user_intimate_api_request(self, data: Dict) -> Dict:
intimate = await self.data.profile.get_intimacy(data["userId"])
if intimate is None:
return {}
partner_list = [{
"partnerId": i["partnerId"],
"intimateLevel": i["intimateLevel"],
"intimateCountRewarded": i["intimateCountRewarded"]
} for i in intimate]
return {
"userId": data["userId"],
"length": len(partner_list),
"userIntimateList": partner_list
}
# CardMaker support added in Universe
async def handle_cm_get_user_preview_api_request(self, data: Dict) -> Dict:
p = await self.data.profile.get_profile_detail(data["userId"], self.version)