mirror of
https://gitea.tendokyu.moe/Hay1tsme/artemis.git
synced 2026-02-13 03:07:29 +08:00
[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:
@@ -144,6 +144,7 @@ fav_music = Table(
|
||||
nullable=False,
|
||||
),
|
||||
Column("musicId", Integer, nullable=False),
|
||||
Column("orderId", Integer, nullable=True),
|
||||
UniqueConstraint("user", "musicId", name="mai2_item_favorite_music_uk"),
|
||||
mysql_charset="utf8mb4",
|
||||
)
|
||||
@@ -453,10 +454,10 @@ class Mai2ItemData(BaseData):
|
||||
self, user_id: int, kind: int, item_id_list: List[int]
|
||||
) -> Optional[int]:
|
||||
sql = insert(favorite).values(
|
||||
user=user_id, kind=kind, item_id_list=item_id_list
|
||||
user=user_id, itemKind=kind, itemIdList=item_id_list
|
||||
)
|
||||
|
||||
conflict = sql.on_duplicate_key_update(item_id_list=item_id_list)
|
||||
conflict = sql.on_duplicate_key_update(itemIdList=item_id_list)
|
||||
|
||||
result = await self.execute(conflict)
|
||||
if result is None:
|
||||
@@ -484,13 +485,14 @@ class Mai2ItemData(BaseData):
|
||||
if result:
|
||||
return result.fetchall()
|
||||
|
||||
async def add_fav_music(self, user_id: int, music_id: int) -> Optional[int]:
|
||||
async def add_fav_music(self, user_id: int, music_id: int, order_id: Optional[int] = None) -> Optional[int]:
|
||||
sql = insert(fav_music).values(
|
||||
user = user_id,
|
||||
musicId = music_id
|
||||
musicId = music_id,
|
||||
orderId = order_id
|
||||
)
|
||||
|
||||
conflict = sql.on_duplicate_key_update(musicId = music_id)
|
||||
conflict = sql.on_duplicate_key_update(orderId = order_id)
|
||||
|
||||
result = await self.execute(conflict)
|
||||
if result:
|
||||
|
||||
@@ -3,7 +3,7 @@ from titles.mai2.const import Mai2Constants
|
||||
|
||||
from typing import Optional, Dict, List
|
||||
from sqlalchemy import Table, Column, UniqueConstraint, PrimaryKeyConstraint, and_
|
||||
from sqlalchemy.types import Integer, String, TIMESTAMP, Boolean, JSON, BigInteger
|
||||
from sqlalchemy.types import Integer, String, TIMESTAMP, Boolean, JSON, BigInteger, SmallInteger
|
||||
from sqlalchemy.schema import ForeignKey
|
||||
from sqlalchemy.sql import func, select
|
||||
from sqlalchemy.engine import Row
|
||||
@@ -43,6 +43,8 @@ detail = Table(
|
||||
Column("currentPlayCount", Integer), # new with buddies
|
||||
Column("renameCredit", Integer), # new with buddies
|
||||
Column("mapStock", Integer), # new with fes+
|
||||
Column("point", Integer), # new with buddies+
|
||||
Column("totalPoint", Integer), # new with buddies+
|
||||
Column("eventWatchedDate", String(25)),
|
||||
Column("lastGameId", String(25)),
|
||||
Column("lastRomVersion", String(25)),
|
||||
@@ -97,6 +99,7 @@ detail = Table(
|
||||
Column("playerOldRating", BigInteger),
|
||||
Column("playerNewRating", BigInteger),
|
||||
Column("dateTime", BigInteger),
|
||||
Column("friendRegistSkip", SmallInteger), # new with buddies+
|
||||
Column("banState", Integer), # new with uni+
|
||||
UniqueConstraint("user", "version", name="mai2_profile_detail_uk"),
|
||||
mysql_charset="utf8mb4",
|
||||
@@ -510,6 +513,22 @@ rival = Table(
|
||||
mysql_charset="utf8mb4",
|
||||
)
|
||||
|
||||
intimacy = Table(
|
||||
"mai2_user_intimate",
|
||||
metadata,
|
||||
Column("id", Integer, primary_key=True, nullable=False),
|
||||
Column(
|
||||
"user",
|
||||
ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade"),
|
||||
nullable=False,
|
||||
),
|
||||
Column("partnerId", Integer, nullable=False),
|
||||
Column("intimateLevel", Integer, nullable=False),
|
||||
Column("intimateCountRewarded", Integer, nullable=False),
|
||||
UniqueConstraint("user", "partnerId", name="mai2_user_intimate_uk"),
|
||||
mysql_charset="utf8mb4",
|
||||
)
|
||||
|
||||
class Mai2ProfileData(BaseData):
|
||||
async def get_all_profile_versions(self, user_id: int) -> Optional[List[Row]]:
|
||||
result = await self.execute(detail.select(detail.c.user == user_id))
|
||||
@@ -905,6 +924,27 @@ class Mai2ProfileData(BaseData):
|
||||
if not result:
|
||||
self.logger.error(f"Failed to remove rival {rival_id} for user {user_id}!")
|
||||
|
||||
async def get_intimacy(self, user_id: int) -> Optional[List[Row]]:
|
||||
result = await self.execute(intimacy.select(intimacy.c.user == user_id))
|
||||
if result:
|
||||
return result.fetchall()
|
||||
|
||||
async def put_intimacy(self, user_id: int, partner_id: int, level: int, count_rewarded: int) -> Optional[int]:
|
||||
sql = insert(intimacy).values(
|
||||
user = user_id,
|
||||
partnerId = partner_id,
|
||||
intimateLevel = level,
|
||||
intimateCountRewarded = count_rewarded
|
||||
)
|
||||
|
||||
conflict = sql.on_duplicate_key_update(intimateLevel = level, intimateCountRewarded = count_rewarded)
|
||||
|
||||
result = await self.execute(conflict)
|
||||
if result:
|
||||
return result.lastrowid
|
||||
|
||||
self.logger.error(f"Failed to update intimacy for user {user_id} and partner {partner_id}!")
|
||||
|
||||
async def update_name(self, user_id: int, new_name: str) -> bool:
|
||||
sql = detail.update(detail.c.user == user_id).values(
|
||||
userName=new_name
|
||||
|
||||
Reference in New Issue
Block a user