Add game start functionality with automatic player chip generation
Implemented host-controlled game start mechanism that generates unique player chips from user names. Added `started_at` timestamp to games and new `game_chips` table to store player identifiers. Chips are created using first name initial plus first two surname letters (e.g., SNE for Sascha Nesterovic) with automatic conflict resolution. Updated frontend to display start button for hosts, show game status, and populate chip selection modal
This commit is contained in:
+12
-1
@@ -54,6 +54,17 @@ class Game(Base):
|
||||
code: Mapped[str] = mapped_column(String, unique=True, index=True)
|
||||
|
||||
winner_user_id: Mapped[str | None] = mapped_column(String, ForeignKey("users.id"), nullable=True)
|
||||
started_at: Mapped[str | None] = mapped_column(DateTime(timezone=True), nullable=True)
|
||||
|
||||
|
||||
class GameChip(Base):
|
||||
__tablename__ = "game_chips"
|
||||
__table_args__ = (UniqueConstraint("game_id", "user_id", name="uq_game_chip_user"),)
|
||||
|
||||
id: Mapped[str] = mapped_column(String, primary_key=True, default=lambda: str(uuid.uuid4()))
|
||||
game_id: Mapped[str] = mapped_column(String, ForeignKey("games.id"), index=True)
|
||||
user_id: Mapped[str] = mapped_column(String, ForeignKey("users.id"), index=True)
|
||||
chip: Mapped[str] = mapped_column(String)
|
||||
|
||||
|
||||
class GameMember(Base):
|
||||
@@ -86,4 +97,4 @@ class SheetState(Base):
|
||||
note_tag: Mapped[str | None] = mapped_column(String, nullable=True)
|
||||
|
||||
chip: Mapped[str | None] = mapped_column(String, nullable=True)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user