67 lines
No EOL
1.7 KiB
TypeScript
67 lines
No EOL
1.7 KiB
TypeScript
export type GameState =
|
|
| 'LANDING'
|
|
| 'CREATING'
|
|
| 'GENERATING'
|
|
| 'LOBBY'
|
|
| 'COUNTDOWN'
|
|
| 'QUESTION'
|
|
| 'REVEAL'
|
|
| 'SCOREBOARD'
|
|
| 'PODIUM';
|
|
|
|
export type GameRole = 'HOST' | 'CLIENT';
|
|
|
|
export interface AnswerOption {
|
|
text: string;
|
|
isCorrect: boolean;
|
|
shape: 'triangle' | 'diamond' | 'circle' | 'square';
|
|
color: 'red' | 'blue' | 'yellow' | 'green';
|
|
reason?: string; // Explanation for why this answer is correct or incorrect
|
|
}
|
|
|
|
export interface Question {
|
|
id: string;
|
|
text: string;
|
|
options: AnswerOption[];
|
|
timeLimit: number; // in seconds
|
|
}
|
|
|
|
export interface Quiz {
|
|
title: string;
|
|
questions: Question[];
|
|
}
|
|
|
|
export interface Player {
|
|
id: string;
|
|
name: string;
|
|
score: number;
|
|
streak: number;
|
|
lastAnswerCorrect: boolean | null;
|
|
isBot: boolean;
|
|
avatarSeed: number;
|
|
color: string;
|
|
}
|
|
|
|
// Network Types
|
|
export type NetworkMessage =
|
|
| { type: 'JOIN'; payload: { name: string } }
|
|
| { type: 'WELCOME'; payload: { playerId: string; quizTitle: string; players: Player[] } }
|
|
| { type: 'PLAYER_JOINED'; payload: { player: Player } }
|
|
| { type: 'GAME_START'; payload: {} }
|
|
| { type: 'START_COUNTDOWN'; payload: { duration: number } }
|
|
| {
|
|
type: 'QUESTION_START';
|
|
payload: {
|
|
totalQuestions: number;
|
|
currentQuestionIndex: number;
|
|
timeLimit: number;
|
|
correctShape: string;
|
|
questionText: string;
|
|
options: AnswerOption[];
|
|
}
|
|
}
|
|
| { type: 'ANSWER'; payload: { playerId: string; isCorrect: boolean } }
|
|
| { type: 'RESULT'; payload: { isCorrect: boolean; scoreAdded: number; newScore: number } }
|
|
| { type: 'TIME_UP'; payload: {} }
|
|
| { type: 'SHOW_SCOREBOARD'; payload: { players: Player[] } }
|
|
| { type: 'GAME_OVER'; payload: { players: Player[] } }; |