-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtflgame.go
195 lines (162 loc) · 4.46 KB
/
tflgame.go
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
package tflgame
import (
"time"
)
type User struct {
ID string
Handle string
Numeric string
Pin *string
Score int
CreatedAt time.Time
}
type PublicUser struct {
UserID string `json:"user_id"`
Handle string `json:"handle"`
Numeric string `json:"numeric"`
Score int `json:"score"`
}
type ListEventsRequest struct {
UserID string `json:"user_id"`
Pagination *Pagination `json:"pagination"`
}
type Pagination struct {
Before *string `json:"before"`
After *string `json:"after"`
Order string `json:"order"`
Limit int `json:"limit"`
}
type CreateUserRequest struct {
Handle string `json:"handle"`
Pin *string `json:"pin"`
}
type CreateUserResponse struct {
ID string `json:"id"`
Handle string `json:"handle"`
Numeric string `json:"numeric"`
Token string `json:"token"`
}
type AuthenticateRequest struct {
Handle string `json:"handle"`
Numeric string `json:"numeric"`
Pin string `json:"pin"`
}
type AuthenticateResponse struct {
UserID string `json:"user_id"`
Token string `json:"token"`
}
type ChangeHandleRequest struct {
UserID string `json:"user_id"`
NewHandle string `json:"new_handle"`
}
type ReleaseHandleRequest struct {
UserID string `json:"user_id"`
}
type ChangePinRequest struct {
UserID string `json:"user_id"`
CurrentPin string `json:"current_pin"`
NewPin string `json:"new_pin"`
}
type GameOptions struct {
Lines []string `json:"lines"`
Zones []string `json:"zones"`
}
type TestGameOptionsResponse struct {
PossiblePrompts int `json:"possible_prompts"`
}
type GetGameOptionsResponse struct {
Lines map[string][]LineDisplay `json:"lines"`
Zones []string `json:"zones"`
}
type LineDisplay struct {
ID string `json:"id"`
Name string `json:"name"`
Color *string `json:"color"`
}
type CreateGameRequest struct {
UserID string `json:"user_id"`
DifficultyOptions DifficultyOptions `json:"difficulty_options"`
GameOptions GameOptions `json:"game_options"`
}
type DifficultyOptions struct {
Rounds int `json:"rounds"`
IncludeRandomSpaces bool `json:"include_random_spaces"`
ChangeLetterOrder bool `json:"change_letter_order"`
RevealWordLength bool `json:"reveal_word_length"`
}
type CreateGameResponse struct {
ID string `json:"id"`
Next *NextPrompt `json:"next"`
}
// TODO(gm): this has some code smells of being used for too much
type Prompt struct {
ID string `json:"id"`
UserID string `json:"_"`
GameID string `json:"_"`
Prompt string `json:"prompt"`
Answer string `json:"answer"`
Length *int `json:"length"`
AnswerGiven *string `json:"_"`
Correct bool `json:"_"`
CreatedAt time.Time `json:"_"`
AnsweredAt *time.Time `json:"_"`
HintGivenAt *time.Time `json:"_"`
}
type SubmitAnswerRequest struct {
UserID string `json:"user_id"`
PromptID string `json:"prompt_id"`
Answer string `json:"answer"`
}
type SubmitAnswerResponse struct {
UserID string `json:"user_id"`
Correct bool `json:"correct"`
Answer string `json:"answer"`
Next *NextPrompt `json:"next"`
}
type NextPrompt struct {
PromptID string `json:"prompt_id"`
Prompt string `json:"prompt"`
Length *int `json:"length"`
}
type GetCurrentGameRequest struct {
UserID string `json:"user_id"`
}
type GetCurrentGameResponse struct {
GameID string `json:"game_id"`
Next *NextPrompt `json:"next"`
}
type GetHintRequest struct {
UserID string `json:"user_id"`
PromptID string `json:"prompt_id"`
}
type GetHintResponse struct {
Prompt string `json:"prompt"`
Lines []string `json:"lines"`
}
type GetGameStateRequest struct {
UserID string `json:"user_id"`
GameID string `json:"game_id"`
}
type GetGameStateResponse struct {
InProgress bool `json:"in_progress"`
Score int `json:"score"`
GameTime string `json:"game_time"`
DifficultyOptions DifficultyOptions `json:"difficulty_options"`
GameOptions GameOptions `json:"game_options"`
}
type ExplainScoreRequest struct {
UserID string `json:"user_id"`
GameID *string `json:"game_id"`
}
type GetLeaderboardResponse struct {
Level string `json:"level"`
Color string `json:"color"`
Players []*PublicUser `json:"players"`
}
type ListGameHistoryRequest struct {
UserID string `json:"user_id"`
}
type GameLog struct {
GameID string `json:"game_id"`
Score int `json:"score"`
}