MCPcopy Create free account
hub / github.com/GoMudEngine/GoMud / zombieCommand

Method zombieCommand

modules/zombiemode/command.zombie.go:16–188  ·  view source on GitHub ↗
(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag)

Source from the content-addressed store, hash-verified

14)
15
16func (m *ZombieModule) zombieCommand(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error) {
17
18 args := util.SplitButRespectQuotes(strings.ToLower(strings.TrimSpace(rest)))
19
20 cfg, hasCfg := m.configs[user.UserId]
21 if !hasCfg {
22 cfg = ZombieConfig{Profiles: make(map[string]ZombieConfig)}
23 m.configs[user.UserId] = cfg
24 }
25
26 if len(args) == 0 {
27 m.showConfig(user, cfg)
28 return true, nil
29 }
30
31 switch args[0] {
32
33 case `status`:
34 rt, isActive := m.active[user.UserId]
35 if !isActive {
36 user.SendText(`Zombie mode is not active. Use <ansi fg="command">zombie start</ansi> to begin.`)
37 return true, nil
38 }
39 m.sendSummary(user, rt.Stats)
40 return true, nil
41
42 case `start`:
43 if enabled, ok := m.plug.Config.Get(`Enabled`).(bool); ok && !enabled {
44 user.SendText(`Zombie mode is disabled on this server.`)
45 return true, nil
46 }
47 if _, alreadyActive := m.active[user.UserId]; alreadyActive {
48 user.SendText(`Zombie mode is already active.`)
49 return true, nil
50 }
51 m.active[user.UserId] = zombieRuntime{HomeRoom: user.Character.RoomId, Stats: newZombieStats()}
52 user.Character.SetAdjective(`zombie`, true)
53 user.SendText(`<ansi fg="yellow">Zombie mode activated. Send any input to wake up.</ansi>`)
54 if cfg.RoamRadius > 0 && mapper.GetMapper(user.Character.RoomId) == nil {
55 user.SendText(`<ansi fg="yellow">Warning: no map data for this area. Roaming is disabled.</ansi>`)
56 }
57 room.SendText(fmt.Sprintf(`<ansi fg="username">%s</ansi>'s eyes glaze over...`, user.Character.Name), user.UserId)
58 return true, nil
59
60 case `set`:
61 if len(args) < 3 {
62 user.SendText(`Usage: zombie set <combat|roam|rest|loot> <value>`)
63 return true, nil
64 }
65 return m.handleSet(args[1], args[2:], user, cfg)
66
67 case `unset`:
68 if len(args) < 2 {
69 user.SendText(`Usage: zombie unset <combat|roam|rest|loot> [name]`)
70 return true, nil
71 }
72 return m.handleUnset(args[1], args[2:], user, cfg)
73

Callers

nothing calls this directly

Calls 12

showConfigMethod · 0.95
sendSummaryMethod · 0.95
handleSetMethod · 0.95
handleUnsetMethod · 0.95
handleWaypointsMethod · 0.95
SplitButRespectQuotesFunction · 0.92
GetMapperFunction · 0.92
newZombieStatsFunction · 0.85
deleteFunction · 0.85
SendTextMethod · 0.45
GetMethod · 0.45
SetAdjectiveMethod · 0.45

Tested by

no test coverage detected