2019-10-04 22:00:47 +00:00
|
|
|
from app import db, ma
|
2019-10-02 03:09:46 +00:00
|
|
|
import enum
|
|
|
|
|
|
|
|
class Players(enum.Enum):
|
|
|
|
BLACK = "The player taking black stones"
|
|
|
|
WHITE = "The player taking white stones"
|
2019-10-02 20:55:09 +00:00
|
|
|
VOID = "The game was a draw or voided"
|
2019-10-02 03:09:46 +00:00
|
|
|
|
|
|
|
class WinType(enum.Enum):
|
|
|
|
DRAW = "The game is a draw"
|
|
|
|
RESIGN = "The game ended in resignation"
|
|
|
|
SCORE = "The game ended by counting points"
|
|
|
|
TIME = "The game ended in loss by time out"
|
|
|
|
VOID = "The game was suspended"
|
|
|
|
|
|
|
|
class Game(db.Model):
|
2019-10-02 20:55:09 +00:00
|
|
|
__tablename__ = "games"
|
|
|
|
__table_args__ = {'extend_existing': True}
|
2019-10-02 03:09:46 +00:00
|
|
|
|
2019-10-02 20:55:09 +00:00
|
|
|
id = db.Column(db.Integer, primary_key=True, autoincrement=True)
|
2019-10-02 03:09:46 +00:00
|
|
|
date = db.Column(db.DateTime())
|
2019-10-02 20:55:09 +00:00
|
|
|
komi = db.Column(db.Numeric(2,1), nullable=False)
|
|
|
|
handicap = db.Column(db.Integer, nullable=False)
|
|
|
|
board_size = db.Column(db.Integer, nullable=False)
|
2019-10-02 03:09:46 +00:00
|
|
|
win_type = db.Column(db.Enum(WinType))
|
|
|
|
winner = db.Column(db.Enum(Players))
|
2019-10-02 20:55:09 +00:00
|
|
|
score = db.Column(db.Numeric(2,1))
|
2019-10-02 03:09:46 +00:00
|
|
|
white_captures = db.Column(db.Integer)
|
|
|
|
black_captures = db.Column(db.Integer)
|
|
|
|
application = db.Column(db.String(40))
|
|
|
|
application_version = db.Column(db.String(20))
|
|
|
|
event = db.Column(db.String(40))
|
|
|
|
name = db.Column(db.String(40))
|
|
|
|
description = db.Column(db.String(200))
|
2019-10-02 20:55:09 +00:00
|
|
|
round = db.Column(db.Integer)
|
2019-10-02 03:09:46 +00:00
|
|
|
|
|
|
|
# foreign keys
|
2019-10-02 20:55:09 +00:00
|
|
|
game_room = db.Column(db.Integer, db.ForeignKey("game_rooms.id"))
|
|
|
|
time_settings = db.Column(db.Integer, db.ForeignKey("time_settings.id"))
|
|
|
|
player_black = db.Column(db.Integer, db.ForeignKey("users.id"))
|
|
|
|
player_white = db.Column(db.Integer, db.ForeignKey("users.id"))
|
2019-10-02 03:09:46 +00:00
|
|
|
|
|
|
|
def __init__(self):
|
|
|
|
pass
|