Initial commit
This commit is contained in:
commit
c87ebf0a74
22 changed files with 4973 additions and 0 deletions
65
types.ts
Normal file
65
types.ts
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
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';
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
// 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[] } };
|
||||
Loading…
Add table
Add a link
Reference in a new issue