@@ -13,7 +13,7 @@ import (
13
13
"os"
14
14
"strings"
15
15
16
- "github.com/code-game-project/go-client/cg "
16
+ "{{.LibraryURL}} "
17
17
"github.com/spf13/pflag"
18
18
)
19
19
@@ -28,6 +28,7 @@ func init() {
28
28
29
29
type Game struct {
30
30
Id string
31
+ Config GameConfig
31
32
socket *cg.Socket
32
33
spectating bool
33
34
}
@@ -147,6 +148,7 @@ func CreateAndJoinGame(public, protected bool, username string, config GameConfi
147
148
148
149
return &Game{
149
150
Id: gameId,
151
+ Config: config,
150
152
socket: socket,
151
153
}, joinSecret, nil
152
154
}
@@ -170,6 +172,7 @@ func CreateAndSpectateGame(public, protected bool, config GameConfig) (*Game, st
170
172
171
173
return &Game{
172
174
Id: gameId,
175
+ Config: config,
173
176
socket: socket,
174
177
}, joinSecret, nil
175
178
}
@@ -187,8 +190,14 @@ func JoinGame(gameId, username, joinSecret string) (*Game, error) {
187
190
return nil, fmt.Errorf("failed to join game: %s", err)
188
191
}
189
192
193
+ config, err := cg.FetchGameConfig[GameConfig](socket, gameId)
194
+ if err != nil {
195
+ return nil, err
196
+ }
197
+
190
198
return &Game{
191
199
Id: gameId,
200
+ Config: config,
192
201
socket: socket,
193
202
}, nil
194
203
}
@@ -205,8 +214,14 @@ func ReconnectGame(username string) (*Game, error) {
205
214
return nil, fmt.Errorf("failed to reconnect: %s", err)
206
215
}
207
216
217
+ config, err := cg.FetchGameConfig[GameConfig](socket, socket.Session().GameId)
218
+ if err != nil {
219
+ return nil, err
220
+ }
221
+
208
222
return &Game{
209
223
Id: socket.Session().GameId,
224
+ Config: config,
210
225
socket: socket,
211
226
}, nil
212
227
}
@@ -222,9 +237,15 @@ func SpectateGame(gameId string) (*Game, error) {
222
237
if err != nil {
223
238
return nil, fmt.Errorf("failed to spectate game: %s", err)
224
239
}
240
+
241
+ config, err := cg.FetchGameConfig[GameConfig](socket, gameId)
242
+ if err != nil {
243
+ return nil, err
244
+ }
225
245
226
246
return &Game{
227
247
Id: socket.Session().GameId,
248
+ Config: config,
228
249
socket: socket,
229
250
}, nil
230
251
}
0 commit comments