browser-go-api/models/Move.py

32 lines
957 B
Python
Raw Normal View History

2019-10-04 22:00:47 +00:00
from app import db, ma
2019-10-02 03:24:15 +00:00
import enum
2019-10-02 20:55:09 +00:00
class Move(db.Model):
__tablename__ = "moves"
__table_args__ = {'extend_existing': True}
2019-10-02 03:24:15 +00:00
2019-10-10 21:57:29 +00:00
class Players(enum.Enum):
BLACK = "The player taking black stones"
WHITE = "The player taking white stones"
2019-10-02 20:55:09 +00:00
id = db.Column(db.Integer, primary_key=True, autoincrement=True)
2019-10-02 03:24:15 +00:00
player = db.Column(db.Enum(Players))
x_point = db.Column(db.Integer)
y_point = db.Column(db.Integer)
move_number = db.Column(db.Integer)
2019-10-02 23:48:10 +00:00
is_pass = db.Column(db.Boolean, nullable=False, default=False)
is_main = db.Column(db.Boolean, nullable=False, default=True)
2019-10-02 03:24:15 +00:00
# foreign keys
2019-10-11 00:52:43 +00:00
game = db.Column(db.Integer, db.ForeignKey("games.id"), nullable=False)
preceding_move = db.Column(db.Integer, db.ForeignKey("moves.id"))
2019-10-11 00:41:49 +00:00
succeeding_moves = db.relationship(
'Move',
lazy='subquery',
backref=db.backref('moves', lazy=True)
)
2019-10-02 03:24:15 +00:00
def __init__(self):
pass