diff options
Diffstat (limited to 'internal/player')
| -rw-r--r-- | internal/player/store.go | 12 |
1 files changed, 12 insertions, 0 deletions
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 |
