Browse Source

Change GameState.started to GameState.active

testing
Burathar 4 years ago
parent
commit
f53f5b948c
  1. 4
      app/main/routes.py
  2. 2
      app/models/game.py
  3. 2
      app/models/game_state.py
  4. 2
      database_dump.txt
  5. 2
      documentation/gamestate.txt
  6. 2
      migrations/versions/d87b14d6a90c_add_pcp_review.py

4
app/main/routes.py

@ -135,7 +135,7 @@ def catch_bunny(game_name):
flash('Only hunters can catch bunnies!') flash('Only hunters can catch bunnies!')
abort(403) abort(403)
if not game.is_active(): if not game.is_active():
flash("Its not possible to catch a bunny before or after a game, or if the game is not in 'started' mode.") flash("Its not possible to catch a bunny before or after a game, or if the game is not in 'active' mode.")
return redirect(url_for('main.game_dashboard', game_name=game.name)) return redirect(url_for('main.game_dashboard', game_name=game.name))
game_bunnies = game.bunnies() game_bunnies = game.bunnies()
@ -331,7 +331,7 @@ def objective(objective_hash):
objective = Objective.query.filter_by(hash=objective_hash).first_or_404() objective = Objective.query.filter_by(hash=objective_hash).first_or_404()
if current_user.role_in_game(objective.game) == Role.bunny: if current_user.role_in_game(objective.game) == Role.bunny:
if not objective.game.is_active(): if not objective.game.is_active():
flash("Its not find an objective before or after a game, or if the game is not in 'started' mode.") flash("Its not find an objective before or after a game, or if the game is not in 'active' mode.")
return redirect(url_for('main.game_dashboard', game_name=objective.game.name)) return redirect(url_for('main.game_dashboard', game_name=objective.game.name))
player = current_user.player_in(objective.game) player = current_user.player_in(objective.game)
if not objective in player.found_objectives: if not objective in player.found_objectives:

2
app/models/game.py

@ -72,4 +72,4 @@ class Game(db.Model):
now = datetime.utcnow() now = datetime.utcnow()
return now > (self.start_time or datetime.min) and \ return now > (self.start_time or datetime.min) and \
now < (self.end_time or datetime.max) and \ now < (self.end_time or datetime.max) and \
self.state == GameState.started self.state == GameState.active

2
app/models/game_state.py

@ -3,7 +3,7 @@ from enum import Enum
class GameState(Enum): class GameState(Enum):
initiated = 1 initiated = 1
published = 2 published = 2
started = 3 active = 3
interrupted = 4 interrupted = 4
finished = 5 finished = 5

2
database_dump.txt

@ -12,7 +12,7 @@ CREATE TABLE game (
start_time DATETIME, start_time DATETIME,
end_time DATETIME, end_time DATETIME,
PRIMARY KEY (id), PRIMARY KEY (id),
CONSTRAINT gamestate CHECK (state IN ('initiated', 'published', 'started', 'interrupted', 'finished')) CONSTRAINT gamestate CHECK (state IN ('initiated', 'published', 'active', 'interrupted', 'finished'))
); );
INSERT INTO game VALUES(1,'Marijns Game','initiated','2020-07-09 12:56:00.000000',NULL); INSERT INTO game VALUES(1,'Marijns Game','initiated','2020-07-09 12:56:00.000000',NULL);
INSERT INTO game VALUES(2,'Spelletje','initiated',NULL,NULL); INSERT INTO game VALUES(2,'Spelletje','initiated',NULL,NULL);

2
documentation/gamestate.txt

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

2
migrations/versions/d87b14d6a90c_add_pcp_review.py

@ -21,7 +21,7 @@ def upgrade():
op.create_table('game', op.create_table('game',
sa.Column('id', sa.Integer(), nullable=False), sa.Column('id', sa.Integer(), nullable=False),
sa.Column('name', sa.String(length=64), nullable=False), sa.Column('name', sa.String(length=64), nullable=False),
sa.Column('state', sa.Enum('initiated', 'published', 'started', 'interrupted', 'finished', name='gamestate'), server_default='initiated', nullable=False), sa.Column('state', sa.Enum('initiated', 'published', 'active', 'interrupted', 'finished', name='gamestate'), server_default='initiated', nullable=False),
sa.Column('start_time', sa.DateTime(), nullable=True), sa.Column('start_time', sa.DateTime(), nullable=True),
sa.Column('end_time', sa.DateTime(), nullable=True), sa.Column('end_time', sa.DateTime(), nullable=True),
sa.PrimaryKeyConstraint('id') sa.PrimaryKeyConstraint('id')

Loading…
Cancel
Save