diff options
Diffstat (limited to 'internal/game/cmd_setflag.go')
| -rw-r--r-- | internal/game/cmd_setflag.go | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/internal/game/cmd_setflag.go b/internal/game/cmd_setflag.go new file mode 100644 index 0000000..a18c635 --- /dev/null +++ b/internal/game/cmd_setflag.go @@ -0,0 +1,38 @@ +package game + +import ( + "fmt" + "strconv" + + "thehouseoficarus/internal/net" +) + +func (g *Game) executeSetFlag(sess *net.Session, args []string, rawInput string) { + if !g.checkAdmin(sess) { + sess.WriteLine("Unknown command.") + return + } + if len(args) == 0 { + sess.WriteLine("Usage: setflag <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.Flags.Set(name, value) + sess.WriteLine(fmt.Sprintf("Flag '%s' set to %v.", name, value)) +} |
