diff options
| author | historia <[not public]> | 2026-07-07 16:24:27 -0400 |
|---|---|---|
| committer | historia <[not public]> | 2026-07-07 16:24:27 -0400 |
| commit | ab2597b22ccdb71116992aec78080d9858358d04 (patch) | |
| tree | 8beae4060c2831c4a68f92b682b5350cfa1d0afb /internal/game/cmd_setglobalflag.go | |
| parent | 3f30fa3eec9c2e2acf9a984ccefb9529a25e688a (diff) | |
| download | thehouseoficarus-ab2597b22ccdb71116992aec78080d9858358d04.tar.gz | |
rename flags to global_flags (differentiate from player_flags)
Diffstat (limited to 'internal/game/cmd_setglobalflag.go')
| -rw-r--r-- | internal/game/cmd_setglobalflag.go | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/internal/game/cmd_setglobalflag.go b/internal/game/cmd_setglobalflag.go new file mode 100644 index 0000000..1ac5080 --- /dev/null +++ b/internal/game/cmd_setglobalflag.go @@ -0,0 +1,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)) +} |
