|
|
@ -12,7 +12,7 @@ class GamePlayer(db.Model): |
|
|
|
game_id = db.Column(db.Integer, db.ForeignKey('game.id'), nullable=False) |
|
|
|
game_id = db.Column(db.Integer, db.ForeignKey('game.id'), nullable=False) |
|
|
|
user_id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False) |
|
|
|
user_id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False) |
|
|
|
role = db.Column(db.Enum(Role), server_default=Role(0).name, nullable=False) |
|
|
|
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='players') |
|
|
|
user = db.relationship('User', back_populates='user_games') |
|
|
|
user = db.relationship('User', back_populates='user_games') |
|
|
|
__table_args__ = (UniqueConstraint('game_id', 'user_id', name='_game_user_uc'), |
|
|
|
__table_args__ = (UniqueConstraint('game_id', 'user_id', name='_game_user_uc'), |
|
|
|
) |
|
|
|
) |
|
|
@ -33,3 +33,11 @@ class GamePlayer(db.Model): |
|
|
|
|
|
|
|
|
|
|
|
caught_by_players = association_proxy('player_caught_by_players', 'caught_player') |
|
|
|
caught_by_players = association_proxy('player_caught_by_players', 'caught_player') |
|
|
|
caught_players = association_proxy('player_caught_players', 'catching_player') |
|
|
|
caught_players = association_proxy('player_caught_players', 'catching_player') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def last_location(self): |
|
|
|
|
|
|
|
# pylint: disable=no-member |
|
|
|
|
|
|
|
self.user.last_location(self.game) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def locations_during_game(self): |
|
|
|
|
|
|
|
# pylint: disable=no-member |
|
|
|
|
|
|
|
self.user.locations_during_game(self.game) |
|
|
|