This commit is contained in:
ryan
2026-01-18 16:22:43 -05:00
parent 96716d95b6
commit e431ba45e9
9 changed files with 235 additions and 5 deletions

View File

@@ -113,13 +113,16 @@ class Game(db.Model):
is_active = db.Column(db.Boolean, default=False) # Only one game active at a time
current_question_index = db.Column(db.Integer, default=0) # Track current question
is_template = db.Column(db.Boolean, default=False) # Mark as reusable template
current_turn_team_id = db.Column(db.Integer, db.ForeignKey('teams.id'), nullable=True) # Track whose turn it is
# Relationships
teams = db.relationship('Team', back_populates='game', cascade='all, delete-orphan')
teams = db.relationship('Team', back_populates='game', cascade='all, delete-orphan',
foreign_keys='Team.game_id')
game_questions = db.relationship('GameQuestion', back_populates='game',
cascade='all, delete-orphan',
order_by='GameQuestion.order')
scores = db.relationship('Score', back_populates='game', cascade='all, delete-orphan')
current_turn_team = db.relationship('Team', foreign_keys=[current_turn_team_id], post_update=True)
@classmethod
def get_active(cls):
@@ -141,7 +144,9 @@ class Game(db.Model):
'is_active': self.is_active,
'current_question_index': self.current_question_index,
'total_questions': len(self.game_questions),
'is_template': self.is_template
'is_template': self.is_template,
'current_turn_team_id': self.current_turn_team_id,
'current_turn_team_name': self.current_turn_team.name if self.current_turn_team else None
}
if include_questions: