Game save state SQL

This commit is contained in:
Ben 2019-12-04 01:31:35 +00:00
parent b2b3d9c236
commit 23a8147762
2 changed files with 20 additions and 8 deletions

View File

@ -1011,15 +1011,15 @@ COMMENT ON COLUMN track_like.track_id IS 'Liked track ID';
COMMENT ON COLUMN track_like.penguin_id IS 'Liker penguin ID';
COMMENT ON COLUMN track_like.date IS 'Timestamp of like';
DROP TABLE IF EXISTS penguin_launch_game;
CREATE TABLE penguin_launch_game (
DROP TABLE IF EXISTS penguin_game_data;
CREATE TABLE penguin_game_data (
penguin_id INT NOT NULL,
level SMALLINT NOT NULL DEFAULT 0,
puffle_os SMALLINT NOT NULL DEFAULT 0,
best_time SMALLINT NOT NULL DEFAULT 600,
turbo BOOLEAN NOT NULL DEFAULT FALSE,
PRIMARY KEY (penguin_id, level),
CONSTRAINT penguin_launch_game_ibfk_1 FOREIGN KEY (penguin_id) REFERENCES penguin (id) ON DELETE RESTRICT ON UPDATE CASCADE
room_id INT NOT NULL,
index INT DEFAULT NULL,
data TEXT DEFAULT '',
PRIMARY KEY (penguin_id, room_id, index),
CONSTRAINT penguin_game_data_ibfk_1 FOREIGN KEY (penguin_id) REFERENCES penguin (id) ON DELETE RESTRICT ON UPDATE CASCADE,
CONSTRAINT penguin_game_data_ibfk_2 FOREIGN KEY (room_id) REFERENCES room (id) ON DELETE RESTRICT ON UPDATE CASCADE
);
DROP TABLE IF EXISTS ignore_list;

12
houdini/data/game.py Normal file
View File

@ -0,0 +1,12 @@
from houdini.data import db
class PenguinGameData(db.Model):
__tablename__ = 'penguin_game_data'
penguin_id = db.Column(db.ForeignKey('penguin.id', ondelete='RESTRICT', onupdate='CASCADE'), primary_key=True,
nullable=False)
room_id = db.Column(db.ForeignKey('room.id', ondelete='RESTRICT', onupdate='CASCADE'), primary_key=True,
nullable=False, index=True)
index = db.Column(db.Integer, primary_key=True, index=True)
data = db.Column(db.Text, nullable=False, server_default=db.text("''"))