blob: 1ac5080c6a90bdf5389db298ada50f8826e94872 (
plain)
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
|
package game
import (
"fmt"
"strconv"
"thehouseoficarus/internal/net"
)
func (g *Game) executeSetGlobalFlag(sess *net.Session, args []string, rawInput string) {
if !g.checkAdmin(sess) {
sess.WriteLine("Unknown command.")
return
}
if len(args) == 0 {
sess.WriteLine("Usage: setglobalflag <flag_name> [value]")
return
}
name := args[0]
var value any = true
if len(args) > 1 {
valStr := args[1]
switch valStr {
case "true":
value = true
case "false":
value = false
default:
if n, err := strconv.Atoi(valStr); err == nil {
value = n
} else {
value = valStr
}
}
}
g.GlobalFlags.Set(name, value)
sess.WriteLine(fmt.Sprintf("Global flag '%s' set to %v.", name, value))
}
|