You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: new/client/templates/wrappers/game.go.tmpl
+127-9Lines changed: 127 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -1,24 +1,119 @@
1
1
package {{.PackageName}}
2
2
3
+
/*
4
+
This code was generated by codegame-cli-go.
5
+
6
+
CHANGES TO THIS FILE MAY CAUSE INCORRECT BEHAVIOR AND WILL BE LOST IF
7
+
THE CODE IS REGENERATED.
8
+
*/
9
+
3
10
import (
11
+
"errors"
4
12
"fmt"
13
+
"os"
14
+
"strings"
5
15
6
-
"{{.LibraryURL}}"
16
+
"github.com/code-game-project/go-client/cg"
17
+
"github.com/spf13/pflag"
7
18
)
8
19
20
+
var URL string
21
+
22
+
{{.InitFunc}}
23
+
9
24
type Game struct {
10
-
Id string
11
-
socket *cg.Socket
25
+
Id string
26
+
socket *cg.Socket
27
+
spectating bool
28
+
}
29
+
30
+
// If IsSpectating returns true, the session of this game will be empty and no events can be sent.
31
+
func (g *Game) IsSpectating() bool {
32
+
return g.spectating
12
33
}
13
34
14
35
type Player struct {
15
36
Id string
16
37
Username string
17
38
}
18
39
40
+
// Init parses command line arguments with pflag and calls either CreateAndJoinGame, CreateAndSpectateGame, JoinGame, SpectateGame or ReconnectGame depending on the provided commands:
41
+
//
42
+
// Operations:\n")
43
+
// create <username> Create a new game.
44
+
// join <game_id> <username> Join an existing game.
45
+
// reconnect <username> Reconnect to a previous session.
46
+
// Flags:
47
+
// --public Make the created game public.
48
+
// --spectate Spectate the created/joined game. The username is not neccessary if this flag is set.
49
+
//
50
+
// This function calls pflag.Parse() internally. If you want to add your own flags, you will need to register them with pflag *before* calling this function.
0 commit comments