You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
1.4 KiB
28 lines
1.4 KiB
from sqlalchemy.sql import func |
|
|
|
from app import db |
|
from .game_player import GamePlayer |
|
from .review import Review |
|
|
|
class PlayerCaughtPlayer(db.Model): |
|
__tablename__ = 'player_caught_player' |
|
id = db.Column(db.Integer, primary_key=True, autoincrement=True, server_default='-1') |
|
catching_player_id = db.Column(db.Integer, db.ForeignKey('game_player.id'), nullable=False) |
|
caught_player_id = db.Column(db.Integer, db.ForeignKey('game_player.id'), nullable=False) |
|
timestamp = db.Column(db.DateTime, server_default=func.now(), nullable=False) |
|
review = db.Column(db.Enum(Review), server_default=Review(0).name, nullable=False) |
|
catching_player = db.relationship('GamePlayer', primaryjoin=(catching_player_id == GamePlayer.id), |
|
backref=db.backref('player_caught_players', cascade='save-update, merge, delete, delete-orphan')) |
|
caught_player = db.relationship('GamePlayer', primaryjoin=(caught_player_id == GamePlayer.id), |
|
backref=db.backref('player_caught_by_players', cascade='save-update, merge, delete, delete-orphan')) |
|
|
|
''' |
|
This relation doesn't work as well as the others, and must be used as folowed: |
|
g = Game.query.first() |
|
p1 = User.query[2].player_in(g) |
|
p2 = User.query[3].player_in(g) |
|
pc = PlayerCaughtPlayer(caught_player=p2, catching_player=p1) |
|
db.session.add(pc) |
|
db.session.commit() |
|
|
|
'''
|
|
|