diff options
Diffstat (limited to 'internal/game/cmd_god.go')
| -rw-r--r-- | internal/game/cmd_god.go | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/internal/game/cmd_god.go b/internal/game/cmd_god.go new file mode 100644 index 0000000..0545c3f --- /dev/null +++ b/internal/game/cmd_god.go @@ -0,0 +1,63 @@ +package game + +import ( + "thehouseoficarus/internal/net" + "thehouseoficarus/internal/player" +) + +func (g *Game) executeGod(sess *net.Session, args []string, rawInput string) { + if !g.checkAdmin(sess) { + sess.WriteLine("Unknown command.") + return + } + p := sess.Player + if p == nil { + return + } + if p.GodMode { + sess.WriteLine("You are already in god mode.") + return + } + + p.GodBackup = make(map[player.SkillName]int, len(p.Skills)) + for k, v := range p.Skills { + p.GodBackup[k] = v + } + + lvl99xp := player.XPForLevel(99) + for _, s := range player.AllSkills { + p.Skills[s] = lvl99xp + } + p.GodMode = true + p.HP = p.MaxHP() + + sess.WriteLine("God mode activated. All skills set to 99.") +} + +func (g *Game) executeUnGod(sess *net.Session, args []string, rawInput string) { + if !g.checkAdmin(sess) { + sess.WriteLine("Unknown command.") + return + } + p := sess.Player + if p == nil { + return + } + if !p.GodMode { + sess.WriteLine("You are not in god mode.") + return + } + g.restoreGodPlayer(p) + sess.WriteLine("God mode deactivated. Skills restored.") +} + +func (g *Game) restoreGodPlayer(p *player.Player) { + if p == nil || !p.GodMode { + return + } + if p.GodBackup != nil { + p.Skills = p.GodBackup + } + p.GodMode = false + p.GodBackup = nil +} |
