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:
@@ -10,6 +10,10 @@ export default function GamePickerCard({
|
||||
members = [],
|
||||
me,
|
||||
hostUserId,
|
||||
isHost = false,
|
||||
started = false,
|
||||
chipCount = 0,
|
||||
onStartGame,
|
||||
}) {
|
||||
const cur = games.find((x) => x.id === gameId);
|
||||
|
||||
@@ -85,6 +89,24 @@ export default function GamePickerCard({
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div style={{ padding: "0 12px 12px", display: "flex", alignItems: "center", justifyContent: "space-between", gap: 10, flexWrap: "wrap" }}>
|
||||
{!started ? (
|
||||
isHost ? (
|
||||
<button onClick={onStartGame} style={styles.primaryBtn} disabled={!members.length}>
|
||||
▶ Spiel starten
|
||||
</button>
|
||||
) : (
|
||||
<div style={{ fontSize: 12, color: stylesTokens.textDim }}>
|
||||
Warte auf den Host, der das Spiel startet.
|
||||
</div>
|
||||
)
|
||||
) : (
|
||||
<div style={{ fontSize: 12, color: stylesTokens.textDim }}>
|
||||
✓ Spiel läuft · {chipCount} Spieler-Chips erstellt
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Spieler */}
|
||||
{members?.length > 0 && (
|
||||
<div style={{ padding: "0 12px 12px" }}>
|
||||
|
||||
Reference in New Issue
Block a user