From ac02af8cbb504a19e0b22267edf908a2d4a2899c Mon Sep 17 00:00:00 2001 From: Sorrel Bri Date: Tue, 1 Oct 2019 20:09:46 -0700 Subject: [PATCH] create basic Game model --- app.py | 4 ++-- models/Branch.py | 6 ++++++ models/Game.py | 42 ++++++++++++++++++++++++++++++++++++++++++ models/GameRoom.py | 0 models/Message.py | 0 models/Move.py | 0 models/TimeSettings.py | 0 models/User.py | 0 8 files changed, 50 insertions(+), 2 deletions(-) create mode 100644 models/Branch.py create mode 100644 models/Game.py create mode 100644 models/GameRoom.py create mode 100644 models/Message.py create mode 100644 models/Move.py create mode 100644 models/TimeSettings.py create mode 100644 models/User.py diff --git a/app.py b/app.py index bada1e9..7544776 100644 --- a/app.py +++ b/app.py @@ -2,7 +2,7 @@ import os from flask import Flask from flask_sqlalchemy import SQLAlchemy -# from flask_marshmallow import Marshmallow +from flask_marshmallow import Marshmallow from flask_migrate import Migrate app = Flask(__name__) @@ -22,7 +22,7 @@ db = SQLAlchemy(app) migrate = Migrate(app, db) # init marshmallow -# ma = Marshmallow(app) +ma = Marshmallow(app) # dev server DEBUG = True diff --git a/models/Branch.py b/models/Branch.py new file mode 100644 index 0000000..72f717f --- /dev/null +++ b/models/Branch.py @@ -0,0 +1,6 @@ +from ..app import db, ma + +class Branch(db.Model): + __table_args__ = {'extend_existing': True} + + id = db.Column(db.Integer, primary_key=True) \ No newline at end of file diff --git a/models/Game.py b/models/Game.py new file mode 100644 index 0000000..65d366c --- /dev/null +++ b/models/Game.py @@ -0,0 +1,42 @@ +from ..app import db, ma +import enum + +class Players(enum.Enum): + BLACK = "The player taking black stones" + WHITE = "The player taking white stones" + +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): + __table_args__ = {'extend_existing': True} + + id = db.Column(db.Integer, primary_key=True) + date = db.Column(db.DateTime()) + komi = db.Column(db.Decimal(2,1)) + handicap = db.Column(db.Integer) + board_size = db.Column(db.Integer) + win_type = db.Column(db.Enum(WinType)) + winner = db.Column(db.Enum(Players)) + score = db.Column(db.Decimal(2,1)) + 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)) + round = db.Column(db.Integer()) + + # foreign keys + # game_room + # time_settings + # player_black + # player_white + + def __init__(self): + pass \ No newline at end of file diff --git a/models/GameRoom.py b/models/GameRoom.py new file mode 100644 index 0000000..e69de29 diff --git a/models/Message.py b/models/Message.py new file mode 100644 index 0000000..e69de29 diff --git a/models/Move.py b/models/Move.py new file mode 100644 index 0000000..e69de29 diff --git a/models/TimeSettings.py b/models/TimeSettings.py new file mode 100644 index 0000000..e69de29 diff --git a/models/User.py b/models/User.py new file mode 100644 index 0000000..e69de29