aboutsummaryrefslogtreecommitdiff
path: root/internal
diff options
context:
space:
mode:
authorhistoria <[not public]>2026-07-01 22:39:42 -0400
committerhistoria <[not public]>2026-07-01 22:39:42 -0400
commit778157981cccb8cb4856e3ab5a72085830c59120 (patch)
tree95a69bd1586609cdc960a1e721cbde0b4cfa1b9a /internal
parentc14c2e403c75a913e1a6d962fb6fe64f013adae5 (diff)
downloadthehouseoficarus-778157981cccb8cb4856e3ab5a72085830c59120.tar.gz
feat: god <level> lets admins set all stats to level
Diffstat (limited to 'internal')
-rw-r--r--internal/game/cmd_god.go23
-rw-r--r--internal/game/game.go1
-rw-r--r--internal/player/store.go12
3 files changed, 33 insertions, 3 deletions
diff --git a/internal/game/cmd_god.go b/internal/game/cmd_god.go
index 0545c3f..56311cb 100644
--- a/internal/game/cmd_god.go
+++ b/internal/game/cmd_god.go
@@ -1,6 +1,9 @@
package game
import (
+ "fmt"
+ "strconv"
+
"thehouseoficarus/internal/net"
"thehouseoficarus/internal/player"
)
@@ -19,19 +22,29 @@ func (g *Game) executeGod(sess *net.Session, args []string, rawInput string) {
return
}
+ level := 99
+ if len(args) > 0 {
+ n, err := strconv.Atoi(args[0])
+ if err != nil || n < 1 || n > 99 {
+ sess.WriteLine("Usage: god [level] (1-99).")
+ return
+ }
+ level = n
+ }
+
p.GodBackup = make(map[player.SkillName]int, len(p.Skills))
for k, v := range p.Skills {
p.GodBackup[k] = v
}
- lvl99xp := player.XPForLevel(99)
+ lvlXP := player.XPForLevel(level)
for _, s := range player.AllSkills {
- p.Skills[s] = lvl99xp
+ p.Skills[s] = lvlXP
}
p.GodMode = true
p.HP = p.MaxHP()
- sess.WriteLine("God mode activated. All skills set to 99.")
+ sess.WriteLine(fmt.Sprintf("God mode activated. All skills set to %d.", level))
}
func (g *Game) executeUnGod(sess *net.Session, args []string, rawInput string) {
@@ -48,6 +61,7 @@ func (g *Game) executeUnGod(sess *net.Session, args []string, rawInput string) {
return
}
g.restoreGodPlayer(p)
+ g.AccountStore.SaveCharacter(p)
sess.WriteLine("God mode deactivated. Skills restored.")
}
@@ -60,4 +74,7 @@ func (g *Game) restoreGodPlayer(p *player.Player) {
}
p.GodMode = false
p.GodBackup = nil
+ if p.HP > p.MaxHP() {
+ p.HP = p.MaxHP()
+ }
}
diff --git a/internal/game/game.go b/internal/game/game.go
index 4cd3b30..bf7bdc2 100644
--- a/internal/game/game.go
+++ b/internal/game/game.go
@@ -115,6 +115,7 @@ func (g *Game) SetHub(hub *net.Hub) {
hub.OnRemove(func(sess *net.Session) {
if p := sess.Player; p != nil {
g.restoreGodPlayer(p)
+ g.AccountStore.SaveCharacter(p)
p.DeactivateAllTechs()
g.cancelEnterSeq(p.Name)
g.charsMu.Lock()
diff --git a/internal/player/store.go b/internal/player/store.go
index bcadf3b..bc5db11 100644
--- a/internal/player/store.go
+++ b/internal/player/store.go
@@ -103,6 +103,18 @@ func (s *AccountStore) LoadCharacter(name string) (*Player, error) {
func (s *AccountStore) SaveCharacter(p *Player) error {
path := s.CharPath(p.Name)
+ if p.GodMode && p.GodBackup != nil {
+ buffedSkills := p.Skills
+ buffedHP := p.HP
+ p.Skills = p.GodBackup
+ if p.HP > p.MaxHP() {
+ p.HP = p.MaxHP()
+ }
+ defer func() {
+ p.Skills = buffedSkills
+ p.HP = buffedHP
+ }()
+ }
data, err := yaml.Marshal(p)
if err != nil {
return err