Browse Source

implement game and player in models.py, document gamestate

feature_tests
Burathar 4 years ago
parent
commit
a019578082
  1. 32
      app/models.py
  2. 8
      documentation/gamestate.txt

32
app/models.py

@ -1,3 +1,35 @@ @@ -1,3 +1,35 @@
from app import app, db
from sqlalchemy.sql import func
game_player = db.Table('game_player',
db.Column('game_id', db.Integer, db.ForeignKey('game.id')),
db.Column('player_id', db.Integer, db.ForeignKey('player.id')),
db.Column('role', db.String(16))
)
class Game(db.Model):
__tablename__ = 'game'
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(64), index=True, unique=True, nullable=False)
password_hash = db.Column(db.String(128), nullable=False)
state = db.Column(db.Integer, default='1')
start_time = db.Column(db.DateTime)
end_time = db.Column(db.DateTime)
players = relationship(
'player',
secondary=game_player,
back_populates='games')
class Player(db.Model):
__tablename = 'player'
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(64), unique=True, nullable=False)
auth_hash = db.Column(db.String(128), unique=True, nullable=False)
password_hash = db.Column(db.String(128))
games = relationship(
'game',
secondary=game_player,
back_populates='players')
#start_time = db.Column(db.DateTime, server_default=func.now())

8
documentation/gamestate.txt

@ -0,0 +1,8 @@ @@ -0,0 +1,8 @@
Gamestate
This is an attribute of the Game class. It will be implemented as an enum containing the following values:
initiated = 1
published = 2
started = 3
interrupted = 4
finished = 5
Loading…
Cancel
Save