|
|
@ -23,7 +23,7 @@ class GamePlayer(db.Model): |
|
|
|
__tablename__ = 'game_player' |
|
|
|
__tablename__ = 'game_player' |
|
|
|
game_id = db.Column(db.Integer, db.ForeignKey('game.id'), primary_key=True, nullable=False) |
|
|
|
game_id = db.Column(db.Integer, db.ForeignKey('game.id'), primary_key=True, nullable=False) |
|
|
|
player_id = db.Column(db.Integer, db.ForeignKey('player.id'), primary_key=True, nullable=False) |
|
|
|
player_id = db.Column(db.Integer, db.ForeignKey('player.id'), primary_key=True, nullable=False) |
|
|
|
role = db.Column(db.Enum(Role), server_default=Role(0).name) |
|
|
|
role = db.Column(db.Enum(Role), server_default=Role(0).name, nullable=False) |
|
|
|
game = db.relationship('Game', back_populates='game_players') |
|
|
|
game = db.relationship('Game', back_populates='game_players') |
|
|
|
player = db.relationship('Player', back_populates='player_games') |
|
|
|
player = db.relationship('Player', back_populates='player_games') |
|
|
|
|
|
|
|
|
|
|
@ -57,14 +57,14 @@ class Game(db.Model): |
|
|
|
__tablename__ = 'game' |
|
|
|
__tablename__ = 'game' |
|
|
|
id = db.Column(db.Integer, primary_key=True) |
|
|
|
id = db.Column(db.Integer, primary_key=True) |
|
|
|
name = db.Column(db.String(64), index=True, unique=True, nullable=False) |
|
|
|
name = db.Column(db.String(64), index=True, unique=True, nullable=False) |
|
|
|
state = db.Column(db.Enum(GameState), server_default=GameState(1).name) |
|
|
|
state = db.Column(db.Enum(GameState), server_default=GameState(1).name, nullable=False) |
|
|
|
start_time = db.Column(db.DateTime) |
|
|
|
start_time = db.Column(db.DateTime) |
|
|
|
end_time = db.Column(db.DateTime) |
|
|
|
end_time = db.Column(db.DateTime) |
|
|
|
game_players = db.relationship( |
|
|
|
game_players = db.relationship( |
|
|
|
'GamePlayer', |
|
|
|
'GamePlayer', |
|
|
|
back_populates='game', |
|
|
|
back_populates='game', |
|
|
|
cascade="save-update, merge, delete, delete-orphan") |
|
|
|
cascade="save-update, merge, delete, delete-orphan") |
|
|
|
players = association_proxy('game_players', 'player', |
|
|
|
players = association_proxy('game_players', 'player', |
|
|
|
creator=lambda player: GamePlayer(player=player)) # to enable game.players.append(player) |
|
|
|
creator=lambda player: GamePlayer(player=player)) # to enable game.players.append(player) |
|
|
|
objectives = db.relationship( |
|
|
|
objectives = db.relationship( |
|
|
|
'Objective', |
|
|
|
'Objective', |
|
|
@ -86,7 +86,7 @@ class Player(UserMixin, db.Model): |
|
|
|
'GamePlayer', |
|
|
|
'GamePlayer', |
|
|
|
back_populates='player', |
|
|
|
back_populates='player', |
|
|
|
cascade='save-update, merge, delete, delete-orphan') |
|
|
|
cascade='save-update, merge, delete, delete-orphan') |
|
|
|
games = association_proxy('player_games', 'game', |
|
|
|
games = association_proxy('player_games', 'game', |
|
|
|
creator=lambda game: GamePlayer(game=game)) |
|
|
|
creator=lambda game: GamePlayer(game=game)) |
|
|
|
|
|
|
|
|
|
|
|
player_found_objectives = db.relationship( |
|
|
|
player_found_objectives = db.relationship( |
|
|
|