create basic Game model
This commit is contained in:
parent
740e2b13d4
commit
ac02af8cbb
8 changed files with 50 additions and 2 deletions
4
app.py
4
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
|
||||
|
|
6
models/Branch.py
Normal file
6
models/Branch.py
Normal file
|
@ -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)
|
42
models/Game.py
Normal file
42
models/Game.py
Normal file
|
@ -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
|
0
models/GameRoom.py
Normal file
0
models/GameRoom.py
Normal file
0
models/Message.py
Normal file
0
models/Message.py
Normal file
0
models/Move.py
Normal file
0
models/Move.py
Normal file
0
models/TimeSettings.py
Normal file
0
models/TimeSettings.py
Normal file
0
models/User.py
Normal file
0
models/User.py
Normal file
Loading…
Reference in a new issue