-
Notifications
You must be signed in to change notification settings - Fork 0
/
types.ts
72 lines (60 loc) · 1.3 KB
/
types.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
export const colors = ['rose', 'amber', 'green', 'cyan', 'indigo', 'fuchsia']
export enum Difficulty {
Easy = 'fairly easy',
Hard = 'extremely difficult',
}
export enum EventType {
AddTopic = 'add-topic',
Answer = 'answer',
ChangePlayerColor = 'change-player-color',
NextQuestion = 'next-question',
Ready = 'ready',
Start = 'start',
ViewResults = 'view-results',
}
export type Answer = {
correct: boolean
text: string
}
export type Color = (typeof colors)[number]
export type ConnectionState = { ready: boolean }
export type OpenAIGenerateQuestionsContent = {
questions: {
answers: Answer[]
text: string
topic: string
}[]
}
export type Player = {
color: Color
name: string
ready: boolean
}
export type PlayerAnswer = {
answerIndex: string
playerName: Player['name']
}
export type Question = {
answers: Answer[]
playerAnswers: Record<Player['name'], number>
text: string
topic: Topic
}
export type Quiz = {
code: string
complete: boolean
currentQuestionIndex: number
difficulty: Difficulty
players: Player[]
questions: Question[]
questionsCount: number
showQuestionResults: boolean
started: boolean
startingIn: number | null
topics: Topic[]
}
export type Topic = {
color: Color
name: string
}
export const defaultDifficulty = Difficulty.Hard