mirror of
https://gitea.tendokyu.moe/Hay1tsme/artemis.git
synced 2026-02-14 11:47:28 +08:00
add rollback sql
move GP support to table in DB small fixes
This commit is contained in:
@@ -173,51 +173,28 @@ class OngekiBase:
|
||||
|
||||
|
||||
def handle_get_game_point_api_request(self, data: Dict) -> Dict:
|
||||
"""
|
||||
Sets the GP amount for A and B sets for 1 - 3 credits
|
||||
"""
|
||||
return {
|
||||
"length": 6,
|
||||
"gamePointList": [
|
||||
{
|
||||
"type": 0,
|
||||
"cost": 100,
|
||||
"startDate": "2000-01-01 05:00:00.0",
|
||||
"endDate": "2099-01-01 05:00:00.0",
|
||||
},
|
||||
{
|
||||
"type": 1,
|
||||
"cost": 230,
|
||||
"startDate": "2000-01-01 05:00:00.0",
|
||||
"endDate": "2099-01-01 05:00:00.0",
|
||||
},
|
||||
{
|
||||
"type": 2,
|
||||
"cost": 370,
|
||||
"startDate": "2000-01-01 05:00:00.0",
|
||||
"endDate": "2099-01-01 05:00:00.0",
|
||||
},
|
||||
{
|
||||
"type": 3,
|
||||
"cost": 120,
|
||||
"startDate": "2000-01-01 05:00:00.0",
|
||||
"endDate": "2099-01-01 05:00:00.0",
|
||||
},
|
||||
{
|
||||
"type": 4,
|
||||
"cost": 240,
|
||||
"startDate": "2000-01-01 05:00:00.0",
|
||||
"endDate": "2099-01-01 05:00:00.0",
|
||||
},
|
||||
{
|
||||
"type": 5,
|
||||
"cost": 360,
|
||||
"startDate": "2000-01-01 05:00:00.0",
|
||||
"endDate": "2099-01-01 05:00:00.0",
|
||||
},
|
||||
],
|
||||
}
|
||||
get_game_point = self.data.static.get_static_game_point()
|
||||
game_point = []
|
||||
|
||||
if not get_game_point:
|
||||
self.logger.info(f"GP table is empty, inserting defaults")
|
||||
self.data.static.put_static_game_point_defaults()
|
||||
get_game_point = self.data.static.get_static_game_point()
|
||||
for gp in get_game_point:
|
||||
tmp = gp._asdict()
|
||||
game_point.append(tmp)
|
||||
return {
|
||||
"length": len(game_point),
|
||||
"gamePointList": game_point,
|
||||
}
|
||||
for gp in get_game_point:
|
||||
tmp = gp._asdict()
|
||||
game_point.append(tmp)
|
||||
return {
|
||||
"length": len(game_point),
|
||||
"gamePointList": game_point,
|
||||
}
|
||||
|
||||
def handle_game_login_api_request(self, data: Dict) -> Dict:
|
||||
return {"returnCode": 1, "apiName": "gameLogin"}
|
||||
|
||||
|
||||
@@ -134,7 +134,7 @@ present = Table(
|
||||
Column("message", String(255)),
|
||||
Column("startDate", String(25), nullable=False),
|
||||
Column("endDate", String(25), nullable=False),
|
||||
UniqueConstraint("version", "presentId", "rewardId", name="ongeki_static_present_list_uk"),
|
||||
UniqueConstraint("version", "presentId", name="ongeki_static_present_list_uk"),
|
||||
mysql_charset="utf8mb4",
|
||||
)
|
||||
|
||||
@@ -174,6 +174,18 @@ client_testmode = Table(
|
||||
mysql_charset="utf8mb4",
|
||||
)
|
||||
|
||||
game_point = Table(
|
||||
"ongeki_static_game_point",
|
||||
metadata,
|
||||
Column("id", Integer, primary_key=True, nullable=False),
|
||||
Column("type", Integer, nullable=False),
|
||||
Column("cost", Integer, nullable=False),
|
||||
Column("startDate", String(25), nullable=False, server_default="2000-01-01 05:00:00.0"),
|
||||
Column("endDate", String(25), nullable=False, server_default="2099-01-01 05:00:00.0"),
|
||||
UniqueConstraint("type", name="ongeki_static_game_point_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)
|
||||
@@ -482,3 +494,19 @@ class OngekiStaticData(BaseData):
|
||||
self.logger.warning(f"clientId: {clientId} Failed to update ClientSetting data"),
|
||||
return None
|
||||
return result.lastrowid
|
||||
|
||||
def put_static_game_point_defaults(self) -> Optional[List[Dict]]:
|
||||
game_point_defaults = [{"type": 0, "cost": 100},{"type": 1, "cost": 230},{"type": 2, "cost": 370},{"type": 3, "cost": 120},{"type": 4, "cost": 240},{"type": 5, "cost": 360}]
|
||||
sql = insert(game_point).values(game_point_defaults)
|
||||
result = self.execute(sql)
|
||||
if result is None:
|
||||
self.logger.warning(f"Failed to insert default GP table!")
|
||||
return None
|
||||
return result.lastrowid
|
||||
|
||||
def get_static_game_point(self) -> Optional[List[Dict]]:
|
||||
sql = select(game_point.c.type, game_point.c.cost, game_point.c.startDate, game_point.c.endDate)
|
||||
result = self.execute(sql)
|
||||
if result is None:
|
||||
return None
|
||||
return result.fetchall()
|
||||
|
||||
Reference in New Issue
Block a user