forked from Dniel97/artemis
chuni: added teams and ticket saving, fixed last played song
This commit is contained in:
parent
b21ddb92ce
commit
2a290f2a3d
@ -2,5 +2,16 @@ server:
|
|||||||
enable: True
|
enable: True
|
||||||
loglevel: "info"
|
loglevel: "info"
|
||||||
|
|
||||||
|
team:
|
||||||
|
name: ARTEMiS
|
||||||
|
|
||||||
|
version:
|
||||||
|
"11":
|
||||||
|
rom: 2.00.00
|
||||||
|
data: 2.00.00
|
||||||
|
"12":
|
||||||
|
rom: 2.05.00
|
||||||
|
data: 2.05.00
|
||||||
|
|
||||||
crypto:
|
crypto:
|
||||||
encrypted_only: False
|
encrypted_only: False
|
@ -7,4 +7,4 @@ index = ChuniServlet
|
|||||||
database = ChuniData
|
database = ChuniData
|
||||||
reader = ChuniReader
|
reader = ChuniReader
|
||||||
game_codes = [ChuniConstants.GAME_CODE, ChuniConstants.GAME_CODE_NEW]
|
game_codes = [ChuniConstants.GAME_CODE, ChuniConstants.GAME_CODE_NEW]
|
||||||
current_schema_version = 1
|
current_schema_version = 3
|
||||||
|
@ -32,7 +32,7 @@ class ChuniBase:
|
|||||||
|
|
||||||
def handle_get_game_charge_api_request(self, data: Dict) -> Dict:
|
def handle_get_game_charge_api_request(self, data: Dict) -> Dict:
|
||||||
game_charge_list = self.data.static.get_enabled_charges(self.version)
|
game_charge_list = self.data.static.get_enabled_charges(self.version)
|
||||||
|
|
||||||
if game_charge_list is None or len(game_charge_list) == 0:
|
if game_charge_list is None or len(game_charge_list) == 0:
|
||||||
return {"length": 0, "gameChargeList": []}
|
return {"length": 0, "gameChargeList": []}
|
||||||
|
|
||||||
@ -130,7 +130,7 @@ class ChuniBase:
|
|||||||
return {
|
return {
|
||||||
"userId": data["userId"],
|
"userId": data["userId"],
|
||||||
"length": len(activity_list),
|
"length": len(activity_list),
|
||||||
"kind": data["kind"],
|
"kind": int(data["kind"]),
|
||||||
"userActivityList": activity_list,
|
"userActivityList": activity_list,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -451,13 +451,13 @@ class ChuniBase:
|
|||||||
"playerLevel": profile["playerLevel"],
|
"playerLevel": profile["playerLevel"],
|
||||||
"rating": profile["rating"],
|
"rating": profile["rating"],
|
||||||
"headphone": profile["headphone"],
|
"headphone": profile["headphone"],
|
||||||
"chargeState": "1",
|
"chargeState": 1,
|
||||||
"userNameEx": profile["userName"],
|
"userNameEx": profile["userName"],
|
||||||
}
|
}
|
||||||
|
|
||||||
def handle_get_user_recent_rating_api_request(self, data: Dict) -> Dict:
|
def handle_get_user_recent_rating_api_request(self, data: Dict) -> Dict:
|
||||||
recet_rating_list = self.data.profile.get_profile_recent_rating(data["userId"])
|
recent_rating_list = self.data.profile.get_profile_recent_rating(data["userId"])
|
||||||
if recet_rating_list is None:
|
if recent_rating_list is None:
|
||||||
return {
|
return {
|
||||||
"userId": data["userId"],
|
"userId": data["userId"],
|
||||||
"length": 0,
|
"length": 0,
|
||||||
@ -466,8 +466,8 @@ class ChuniBase:
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
"userId": data["userId"],
|
"userId": data["userId"],
|
||||||
"length": len(recet_rating_list["recentRating"]),
|
"length": len(recent_rating_list["recentRating"]),
|
||||||
"userRecentRatingList": recet_rating_list["recentRating"],
|
"userRecentRatingList": recent_rating_list["recentRating"],
|
||||||
}
|
}
|
||||||
|
|
||||||
def handle_get_user_region_api_request(self, data: Dict) -> Dict:
|
def handle_get_user_region_api_request(self, data: Dict) -> Dict:
|
||||||
@ -479,8 +479,24 @@ class ChuniBase:
|
|||||||
}
|
}
|
||||||
|
|
||||||
def handle_get_user_team_api_request(self, data: Dict) -> Dict:
|
def handle_get_user_team_api_request(self, data: Dict) -> Dict:
|
||||||
# TODO: Team
|
# TODO: use the database "chuni_profile_team" with a GUI
|
||||||
return {"userId": data["userId"], "teamId": 0}
|
team_name = self.game_cfg.team.team_name
|
||||||
|
if team_name == "":
|
||||||
|
return {"userId": data["userId"], "teamId": 0}
|
||||||
|
|
||||||
|
return {
|
||||||
|
"userId": data["userId"],
|
||||||
|
"teamId": 1,
|
||||||
|
"teamRank": 1,
|
||||||
|
"teamName": team_name,
|
||||||
|
"userTeamPoint": {
|
||||||
|
"userId": data["userId"],
|
||||||
|
"teamId": 1,
|
||||||
|
"orderId": 1,
|
||||||
|
"teamPoint": 1,
|
||||||
|
"aggrDate": data["playDate"],
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
def handle_get_team_course_setting_api_request(self, data: Dict) -> Dict:
|
def handle_get_team_course_setting_api_request(self, data: Dict) -> Dict:
|
||||||
return {
|
return {
|
||||||
@ -583,6 +599,9 @@ class ChuniBase:
|
|||||||
return {"returnCode": "1"}
|
return {"returnCode": "1"}
|
||||||
|
|
||||||
def handle_upsert_user_chargelog_api_request(self, data: Dict) -> Dict:
|
def handle_upsert_user_chargelog_api_request(self, data: Dict) -> Dict:
|
||||||
|
# add tickets after they got bought, this makes sure the tickets are
|
||||||
|
# still valid after an unsuccessful logout
|
||||||
|
self.data.profile.put_profile_charge(data["userId"], data["userCharge"])
|
||||||
return {"returnCode": "1"}
|
return {"returnCode": "1"}
|
||||||
|
|
||||||
def handle_upsert_client_bookkeeping_api_request(self, data: Dict) -> Dict:
|
def handle_upsert_client_bookkeeping_api_request(self, data: Dict) -> Dict:
|
||||||
@ -603,7 +622,5 @@ class ChuniBase:
|
|||||||
def handle_get_user_net_battle_data_api_request(self, data: Dict) -> Dict:
|
def handle_get_user_net_battle_data_api_request(self, data: Dict) -> Dict:
|
||||||
return {
|
return {
|
||||||
"userId": data["userId"],
|
"userId": data["userId"],
|
||||||
"userNetBattleData": {
|
"userNetBattleData": {"recentNBSelectMusicList": []},
|
||||||
"recentNBSelectMusicList": []
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -21,6 +21,32 @@ class ChuniServerConfig:
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class ChuniTeamConfig:
|
||||||
|
def __init__(self, parent_config: "ChuniConfig") -> None:
|
||||||
|
self.__config = parent_config
|
||||||
|
|
||||||
|
@property
|
||||||
|
def team_name(self) -> str:
|
||||||
|
return CoreConfig.get_config_field(
|
||||||
|
self.__config, "chuni", "team", "name", default=""
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class ChuniVersionConfig:
|
||||||
|
def __init__(self, parent_config: "ChuniConfig") -> None:
|
||||||
|
self.__config = parent_config
|
||||||
|
|
||||||
|
def version_rom(self, version: int) -> str:
|
||||||
|
return CoreConfig.get_config_field(
|
||||||
|
self.__config, "chuni", "version", f"{version}", "rom", default="2.00.00"
|
||||||
|
)
|
||||||
|
|
||||||
|
def version_data(self, version: int) -> str:
|
||||||
|
return CoreConfig.get_config_field(
|
||||||
|
self.__config, "chuni", "version", f"{version}", "data", default="2.00.00"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class ChuniCryptoConfig:
|
class ChuniCryptoConfig:
|
||||||
def __init__(self, parent_config: "ChuniConfig") -> None:
|
def __init__(self, parent_config: "ChuniConfig") -> None:
|
||||||
self.__config = parent_config
|
self.__config = parent_config
|
||||||
@ -46,4 +72,6 @@ class ChuniCryptoConfig:
|
|||||||
class ChuniConfig(dict):
|
class ChuniConfig(dict):
|
||||||
def __init__(self) -> None:
|
def __init__(self) -> None:
|
||||||
self.server = ChuniServerConfig(self)
|
self.server = ChuniServerConfig(self)
|
||||||
|
self.team = ChuniTeamConfig(self)
|
||||||
|
self.version = ChuniVersionConfig(self)
|
||||||
self.crypto = ChuniCryptoConfig(self)
|
self.crypto = ChuniCryptoConfig(self)
|
||||||
|
@ -49,8 +49,8 @@ class ChuniNew(ChuniBase):
|
|||||||
"matchEndTime": match_end,
|
"matchEndTime": match_end,
|
||||||
"matchTimeLimit": 99,
|
"matchTimeLimit": 99,
|
||||||
"matchErrorLimit": 9999,
|
"matchErrorLimit": 9999,
|
||||||
"romVersion": "2.00.00",
|
"romVersion": self.game_cfg.version.version_rom(self.version),
|
||||||
"dataVersion": "2.00.00",
|
"dataVersion": self.game_cfg.version.version_data(self.version),
|
||||||
"matchingUri": f"http://{self.core_cfg.title.hostname}:{self.core_cfg.title.port}/SDHD/200/ChuniServlet/",
|
"matchingUri": f"http://{self.core_cfg.title.hostname}:{self.core_cfg.title.port}/SDHD/200/ChuniServlet/",
|
||||||
"matchingUriX": f"http://{self.core_cfg.title.hostname}:{self.core_cfg.title.port}/SDHD/200/ChuniServlet/",
|
"matchingUriX": f"http://{self.core_cfg.title.hostname}:{self.core_cfg.title.port}/SDHD/200/ChuniServlet/",
|
||||||
"udpHolePunchUri": f"http://{self.core_cfg.title.hostname}:{self.core_cfg.title.port}/SDHD/200/ChuniServlet/",
|
"udpHolePunchUri": f"http://{self.core_cfg.title.hostname}:{self.core_cfg.title.port}/SDHD/200/ChuniServlet/",
|
||||||
@ -454,9 +454,7 @@ class ChuniNew(ChuniBase):
|
|||||||
|
|
||||||
# set the card print state to success and use the orderId as the key
|
# set the card print state to success and use the orderId as the key
|
||||||
self.data.item.put_user_print_state(
|
self.data.item.put_user_print_state(
|
||||||
user_id,
|
user_id, id=upsert["orderId"], hasCompleted=True
|
||||||
id=upsert["orderId"],
|
|
||||||
hasCompleted=True
|
|
||||||
)
|
)
|
||||||
|
|
||||||
return {"returnCode": "1", "apiName": "CMUpsertUserPrintSubtractApi"}
|
return {"returnCode": "1", "apiName": "CMUpsertUserPrintSubtractApi"}
|
||||||
@ -467,10 +465,6 @@ class ChuniNew(ChuniBase):
|
|||||||
|
|
||||||
# set the card print state to success and use the orderId as the key
|
# set the card print state to success and use the orderId as the key
|
||||||
for order_id in order_ids:
|
for order_id in order_ids:
|
||||||
self.data.item.put_user_print_state(
|
self.data.item.put_user_print_state(user_id, id=order_id, hasCompleted=True)
|
||||||
user_id,
|
|
||||||
id=order_id,
|
|
||||||
hasCompleted=True
|
|
||||||
)
|
|
||||||
|
|
||||||
return {"returnCode": "1", "apiName": "CMUpsertUserPrintCancelApi"}
|
return {"returnCode": "1", "apiName": "CMUpsertUserPrintCancelApi"}
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
from datetime import datetime, timedelta
|
|
||||||
from typing import Dict, Any
|
from typing import Dict, Any
|
||||||
import pytz
|
|
||||||
|
|
||||||
from core.config import CoreConfig
|
from core.config import CoreConfig
|
||||||
from titles.chuni.new import ChuniNew
|
from titles.chuni.new import ChuniNew
|
||||||
@ -15,8 +13,12 @@ class ChuniNewPlus(ChuniNew):
|
|||||||
|
|
||||||
def handle_get_game_setting_api_request(self, data: Dict) -> Dict:
|
def handle_get_game_setting_api_request(self, data: Dict) -> Dict:
|
||||||
ret = super().handle_get_game_setting_api_request(data)
|
ret = super().handle_get_game_setting_api_request(data)
|
||||||
ret["gameSetting"]["romVersion"] = "2.05.00"
|
ret["gameSetting"]["romVersion"] = self.game_cfg.version.version_rom(
|
||||||
ret["gameSetting"]["dataVersion"] = "2.05.00"
|
self.version
|
||||||
|
)
|
||||||
|
ret["gameSetting"]["dataVersion"] = self.game_cfg.version.version_data(
|
||||||
|
self.version
|
||||||
|
)
|
||||||
ret["gameSetting"][
|
ret["gameSetting"][
|
||||||
"matchingUri"
|
"matchingUri"
|
||||||
] = f"http://{self.core_cfg.title.hostname}:{self.core_cfg.title.port}/SDHD/205/ChuniServlet/"
|
] = f"http://{self.core_cfg.title.hostname}:{self.core_cfg.title.port}/SDHD/205/ChuniServlet/"
|
||||||
|
@ -558,8 +558,10 @@ class ChuniProfileData(BaseData):
|
|||||||
return result.lastrowid
|
return result.lastrowid
|
||||||
|
|
||||||
def get_profile_activity(self, aime_id: int, kind: int) -> Optional[List[Row]]:
|
def get_profile_activity(self, aime_id: int, kind: int) -> Optional[List[Row]]:
|
||||||
sql = select(activity).where(
|
sql = (
|
||||||
and_(activity.c.user == aime_id, activity.c.kind == kind)
|
select(activity)
|
||||||
|
.where(and_(activity.c.user == aime_id, activity.c.kind == kind))
|
||||||
|
.order_by(activity.c.sortNumber.desc()) # to get the last played track
|
||||||
)
|
)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = self.execute(sql)
|
||||||
|
@ -390,20 +390,17 @@ class ChuniStaticData(BaseData):
|
|||||||
return None
|
return None
|
||||||
return result.fetchall()
|
return result.fetchall()
|
||||||
|
|
||||||
def get_gacha_card_by_character(self, gacha_id: int, chara_id: int) -> Optional[Dict]:
|
def get_gacha_card_by_character(
|
||||||
|
self, gacha_id: int, chara_id: int
|
||||||
|
) -> Optional[Dict]:
|
||||||
sql_sub = (
|
sql_sub = (
|
||||||
select(cards.c.cardId)
|
select(cards.c.cardId).filter(cards.c.charaId == chara_id).scalar_subquery()
|
||||||
.filter(
|
|
||||||
cards.c.charaId == chara_id
|
|
||||||
)
|
|
||||||
.scalar_subquery()
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# Perform the main query, also rename the resulting column to ranking
|
# Perform the main query, also rename the resulting column to ranking
|
||||||
sql = gacha_cards.select(and_(
|
sql = gacha_cards.select(
|
||||||
gacha_cards.c.gachaId == gacha_id,
|
and_(gacha_cards.c.gachaId == gacha_id, gacha_cards.c.cardId == sql_sub)
|
||||||
gacha_cards.c.cardId == sql_sub
|
)
|
||||||
))
|
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
|
Loading…
Reference in New Issue
Block a user