- Add ClientTestmode upsert

- Add ClientSetting upsert
- Add endDate for Events
- Add Upgrade Schema
- Small bugfixes for events
This commit is contained in:
phantomlan 2023-11-09 02:40:57 +01:00 committed by phantomlan
parent d2e2c14074
commit f81c53558e
5 changed files with 166 additions and 16 deletions

View File

@ -0,0 +1,88 @@
SET FOREIGN_KEY_CHECKS=0;
ALTER TABLE ongeki_user_event_point ADD COLUMN version INTEGER NOT NULL;
ALTER TABLE ongeki_user_event_point ADD COLUMN rank INTEGER;
ALTER TABLE ongeki_user_event_point ADD COLUMN type INTEGER NOT NULL;
ALTER TABLE ongeki_user_event_point ADD COLUMN date VARCHAR(25);
ALTER TABLE ongeki_user_tech_event ADD COLUMN version INTEGER NOT NULL;
ALTER TABLE ongeki_user_mission_point ADD COLUMN version INTEGER NOT NULL;
ALTER TABLE ongeki_static_events ADD COLUMN endDate TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP;
CREATE TABLE ongeki_tech_event_ranking (
id INT PRIMARY KEY NOT NULL AUTO_INCREMENT,
user INT NOT NULL,
version INT NOT NULL,
date VARCHAR(25),
eventId INT NOT NULL,
rank INT,
totalPlatinumScore INT NOT NULL,
totalTechScore INT NOT NULL,
UNIQUE KEY ongeki_tech_event_ranking_uk (user, eventId),
CONSTRAINT ongeki_tech_event_ranking_ibfk1 FOREIGN KEY (user) REFERENCES aime_user(id) ON DELETE CASCADE ON UPDATE CASCADE
);
CREATE TABLE ongeki_static_music_ranking_list (
id INT PRIMARY KEY NOT NULL AUTO_INCREMENT,
version INT NOT NULL,
musicId INT NOT NULL,
point INT NOT NULL,
userName VARCHAR(255),
UNIQUE KEY ongeki_static_music_ranking_list_uk (version, musicId)
);
CREATE TABLE ongeki_static_rewards (
id INT PRIMARY KEY NOT NULL AUTO_INCREMENT,
version INT NOT NULL,
rewardId INT NOT NULL,
rewardName VARCHAR(255) NOT NULL,
itemKind INT NOT NULL,
itemId INT NOT NULL,
UNIQUE KEY ongeki_tech_event_ranking_uk (version, rewardId)
);
CREATE TABLE ongeki_static_present_list (
id INT PRIMARY KEY NOT NULL AUTO_INCREMENT,
version INT NOT NULL,
presentId INT NOT NULL,
presentName VARCHAR(255) NOT NULL,
rewardId INT NOT NULL,
stock INT NOT NULL,
message VARCHAR(255),
startDate VARCHAR(25) NOT NULL,
endDate VARCHAR(25) NOT NULL,
UNIQUE KEY ongeki_static_present_list_uk (version, presentId, rewardId)
);
CREATE TABLE ongeki_static_tech_music (
id INT PRIMARY KEY NOT NULL AUTO_INCREMENT,
version INT NOT NULL,
eventId INT NOT NULL,
musicId INT NOT NULL,
level INT NOT NULL,
UNIQUE KEY ongeki_static_tech_music_uk (version, musicId, eventId)
);
CREATE TABLE ongeki_static_client_testmode (
id INT PRIMARY KEY NOT NULL AUTO_INCREMENT,
regionId INT NOT NULL,
placeId INT NOT NULL,
clientId VARCHAR(11) NOT NULL,
updateDate TIMESTAMP NOT NULL,
isDelivery BOOLEAN NOT NULL,
groupId INT NOT NULL,
groupRole INT NOT NULL,
continueMode INT NOT NULL,
selectMusicTime INT NOT NULL,
advertiseVolume INT NOT NULL,
eventMode INT NOT NULL,
eventMusicNum INT NOT NULL,
patternGp INT NOT NULL,
limitGp INT NOT NULL,
maxLeverMovable INT NOT NULL,
minLeverMovable INT NOT NULL,
UNIQUE KEY ongeki_static_client_testmode_uk (clientId)
);
SET FOREIGN_KEY_CHECKS=1;

View File

@ -343,7 +343,9 @@ Events are controlled by 2 types of enabled events:
- AcceptRankingEvent (type 7), AcceptTechChallengeEvent (type 18)
Both Ranking and Accept must be enabled for event to function properly
Event will run for the time specified in startDate and endDate
AcceptRankingEvent and AcceptTechChallengeEvent are reward period for events, which specify from what startDate until endDate you can collect the rewards for attending the event, so the reward period must start in the future, e.g. :
- RankingEvent startDate 2023-12-01 - endDate 2023-12-30 - period in which whole event is running
@ -352,11 +354,14 @@ AcceptRankingEvent and AcceptTechChallengeEvent are reward period for events, wh
If player misses the AcceptRankingEvent period - ranking will be invalidated and receive lowest reward from the event (typically 500x money)
Technical Challenge Song List:
Songs that are used for Technical Challenge are not stored anywhere in data files, so you need to fill the database table by yourself, you can gather all songs that should be in Technical Challenges from ONGEKI japanese wikis, or, you can create your own sets:
Database table : `ongeki_tech_music_list`
Database table : `ongeki_static_tech_music`
```
id: Id in table, just increment for each entry
version: version of the game you want the tech challenge to be in (from RED and up)
eventId: Id of the event in ongeki_static_events, insert the Id of the TechChallengeEvent (type 17) you want the song be assigned to
musicId: Id of the song you want to add, use songId from ongeki_static_music table
level: Difficulty of the song you want to track during the event, from 0(basic) to 3(master)

View File

@ -287,9 +287,21 @@ class OngekiBase:
}
def handle_upsert_client_setting_api_request(self, data: Dict) -> Dict:
if self.core_cfg.server.is_develop:
return {"returnCode": 1, "apiName": "UpsertClientSettingApi"}
client_id = data["clientId"]
client_setting_data = data["clientSetting"]
self.data.static.put_client_setting_data(client_id, client_setting_data)
return {"returnCode": 1, "apiName": "UpsertClientSettingApi"}
def handle_upsert_client_testmode_api_request(self, data: Dict) -> Dict:
if self.core_cfg.server.is_develop:
return {"returnCode": 1, "apiName": "UpsertClientTestmodeApi"}
region_id = data["regionId"]
client_testmode_data = data["clientTestmode"]
self.data.static.put_client_testmode_data(region_id, client_testmode_data)
return {"returnCode": 1, "apiName": "UpsertClientTestmodeApi"}
def handle_upsert_client_bookkeeping_api_request(self, data: Dict) -> Dict:
@ -333,10 +345,9 @@ class OngekiBase:
"id": event["eventId"],
# actually use the startDate from the import so it
# properly shows all the events when new ones are imported
"startDate": datetime.strftime(
event["startDate"], "%Y-%m-%d %H:%M:%S.0"
),
"endDate": "2099-12-31 00:00:00.0",
"startDate": datetime.strftime(event["startDate"], "%Y-%m-%d %H:%M:%S.0"),
#"endDate": "2099-12-31 00:00:00.0",
"endDate": datetime.strftime(event["endDate"], "%Y-%m-%d %H:%M:%S.0"),
}
)
@ -849,7 +860,7 @@ class OngekiBase:
}
def handle_get_user_mission_point_api_request(self, data: Dict) -> Dict:
user_mission_point_list = self.data.item.get_mission_points(data["userId"])
user_mission_point_list = self.data.item.get_mission_points(self.version, data["userId"])
if user_mission_point_list is None:
return {}
@ -858,6 +869,7 @@ class OngekiBase:
tmp = evt_music._asdict()
tmp.pop("id")
tmp.pop("user")
tmp.pop("version")
mission_point_list.append(tmp)
@ -1032,7 +1044,7 @@ class OngekiBase:
if "userMissionPointList" in upsert:
for x in upsert["userMissionPointList"]:
self.data.item.put_mission_point(user_id, x)
self.data.item.put_mission_point(user_id, self.version, x)
if "userRatinglogList" in upsert:
for x in upsert["userRatinglogList"]:

View File

@ -187,6 +187,7 @@ mission_point = Table(
metadata,
Column("id", Integer, primary_key=True, nullable=False),
Column("user", ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade")),
Column("version", Integer),
Column("eventId", Integer),
Column("point", Integer),
UniqueConstraint("user", "eventId", name="ongeki_user_mission_point_uk"),
@ -337,7 +338,6 @@ print_detail = Table(
mysql_charset="utf8mb4",
)
class OngekiItemData(BaseData):
def put_card(self, aime_id: int, card_data: Dict) -> Optional[int]:
card_data["user"] = aime_id
@ -532,10 +532,9 @@ class OngekiItemData(BaseData):
return None
return result.fetchall()
def put_mission_point(
self, aime_id: int, mission_point_data: Dict
) -> Optional[int]:
def put_mission_point(self, version: int, aime_id: int, mission_point_data: Dict) -> Optional[int]:
mission_point_data["user"] = aime_id
mission_point_data["version"] = version
sql = insert(mission_point).values(**mission_point_data)
conflict = sql.on_duplicate_key_update(**mission_point_data)
@ -546,8 +545,8 @@ class OngekiItemData(BaseData):
return None
return result.lastrowid
def get_mission_points(self, aime_id: int) -> Optional[List[Dict]]:
sql = select(mission_point).where(mission_point.c.user == aime_id)
def get_mission_points(self, version: int, aime_id: int) -> Optional[List[Dict]]:
sql = select(mission_point).where(and_(mission_point.c.user == aime_id, mission_point.c.version == version))
result = self.execute(sql)
if result is None:

View File

@ -17,6 +17,7 @@ events = Table(
Column("type", Integer),
Column("name", String(255)),
Column("startDate", TIMESTAMP, server_default=func.now()),
Column("endDate", TIMESTAMP, server_default=func.now()),
Column("enabled", Boolean, server_default="1"),
UniqueConstraint("version", "eventId", "type", name="ongeki_static_events_uk"),
mysql_charset="utf8mb4",
@ -104,7 +105,7 @@ music_ranking = Table(
Column("musicId", Integer, nullable=False),
Column("point", Integer, nullable=False),
Column("userName", String(255)),
UniqueConstraint("musicId", name="ongeki_static_music_ranking_uk"),
UniqueConstraint("version", "musicId", name="ongeki_static_music_ranking_uk"),
mysql_charset="utf8mb4",
)
@ -117,7 +118,7 @@ rewards = Table(
Column("rewardname", String(255), nullable=False),
Column("itemKind", Integer, nullable=False),
Column("itemId", Integer, nullable=False),
UniqueConstraint("version","itemKind","rewardId", name="ongeki_static_rewards_uk"),
UniqueConstraint("version", "rewardId", name="ongeki_static_rewards_uk"),
mysql_charset="utf8mb4",
)
@ -133,7 +134,7 @@ present = Table(
Column("message", String(255)),
Column("startDate", String(25), nullable=False),
Column("endDate", String(25), nullable=False),
UniqueConstraint("version","presentId", name="ongeki_static_present_list_uk"),
UniqueConstraint("version", "presentId", "rewardId", name="ongeki_static_present_list_uk",
mysql_charset="utf8mb4",
)
@ -149,6 +150,30 @@ tech_music = Table(
mysql_charset="utf8mb4",
)
client_testmode = Table(
"ongeki_static_client_testmode",
metadata,
Column("id", Integer, primary_key=True, nullable=False),
Column("regionId", Integer, nullable=False),
Column("placeId", Integer, nullable=False),
Column("clientId", String(11), nullable=False),
Column("updateDate", TIMESTAMP, nullable=False),
Column("isDelivery", Boolean, nullable=False),
Column("groupId", Integer, nullable=False),
Column("groupRole", Integer, nullable=False),
Column("continueMode", Integer, nullable=False),
Column("selectMusicTime", Integer, nullable=False),
Column("advertiseVolume", Integer, nullable=False),
Column("eventMode", Integer, nullable=False),
Column("eventMusicNum", Integer, nullable=False),
Column("patternGp", Integer, nullable=False),
Column("limitGp", Integer, nullable=False),
Column("maxLeverMovable", Integer, nullable=False),
Column("minLeverMovable", Integer, nullable=False),
UniqueConstraint("clientId", name="ongeki_static_client_testmode_uk"),
mysql_charset="utf8mb4",
)
class OngekiStaticData(BaseData):
def put_card(self, version: int, card_id: int, **card_data) -> Optional[int]:
sql = insert(cards).values(version=version, cardId=card_id, **card_data)
@ -287,6 +312,7 @@ class OngekiStaticData(BaseData):
eventId=event_id,
type=event_type,
name=event_name,
endDate=f"2038-01-01 00:00:00",
)
conflict = sql.on_duplicate_key_update(
@ -436,3 +462,23 @@ class OngekiStaticData(BaseData):
if result is None:
return None
return result.fetchall()
def put_client_testmode_data(self, region_id: int, client_testmode_data: Dict) -> Optional[List[Dict]]:
sql = insert(client_testmode).values(regionId=region_id, **client_testmode_data)
conflict = sql.on_duplicate_key_update(regionId=region_id, **client_testmode_data)
result = self.execute(conflict)
if result is None:
self.logger.warning(f"clientId: {clientId} Failed to update ClientTestMode data"),
return None
return result.lastrowid
def put_client_setting_data(self, client_id: str, client_setting_data: Dict) -> Optional[List[Dict]]:
sql = insert(machine).values(data=client_setting_data)
conflict = sql.on_duplicate_key_update(serial=client_id)
result = self.execute(conflict)
if result is None:
self.logger.warning(f"clientId: {clientId} Failed to update ClientSetting data"),
return None
return result.lastrowid