Files
QuizMaster/types.ts
T
Philip c5cf88491f feat: Integrate join URL and QR code for player access
Adds a dynamic join URL and QR code displayed on the spectator view and host dashboard. This allows players to easily join the quiz session by scanning the QR code or navigating to the provided URL.

The `joinUrl` is now managed within the `GameContext` and exposed to relevant components. The spectator view uses this URL to generate the QR code, while the host view displays it for easy access. This enhances the onboarding experience for new players and simplifies session management.
2026-01-28 19:01:34 -08:00

78 lines
1.5 KiB
TypeScript

export const GamePhase = {
LOBBY: 'LOBBY',
COUNTDOWN: 'COUNTDOWN',
QUESTION_DISPLAY: 'QUESTION_DISPLAY',
BUZZER_OPEN: 'BUZZER_OPEN',
ADJUDICATION: 'ADJUDICATION',
ANSWER_REVEAL: 'ANSWER_REVEAL',
LEADERBOARD: 'LEADERBOARD',
FINAL_STATS: 'FINAL_STATS'
} as const;
export type GamePhase = typeof GamePhase[keyof typeof GamePhase];
export interface PlayerStats {
correctAnswers: number;
totalBuzzes: number;
bestReactionTime: number | null; // in ms
}
export interface Player {
id: string;
name: string;
teamId?: string;
score: number;
isApproved: boolean;
buzzerTimestamp?: number; // MS timestamp of when they buzzed
stats: PlayerStats;
}
export interface Team {
id: string;
name: string;
score: number;
}
export interface Question {
id: string;
text: string;
answer: string;
points: number;
category?: string;
mediaUrl?: string;
mediaType?: 'image' | 'video';
audioUrl?: string;
audioStart?: number;
audioEnd?: number;
}
export interface Game {
id: string;
name: string;
description?: string;
createdAt: number;
questions: Question[];
}
export interface BuzzerLog {
playerId: string;
timestamp: number;
order: number;
status: 'PENDING' | 'CORRECT' | 'WRONG';
}
export interface GameState {
phase: GamePhase;
currentQuestionIndex: number;
countdownValue: number;
buzzerOpenTimestamp: number | null; // To calculate reaction time
}
// Synchronization Types
export interface PlayerIntent {
type: 'JOIN' | 'BUZZ' | 'LEAVE';
payload: any;
created_at?: string;
}