aboutsummaryrefslogtreecommitdiff
path: root/internal/game/save.go
blob: 8e1af3dc0bfe773d990cb8c76426a5a38486887d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
package game

import (
	"log"

	"thehouseoficarus/internal/player"
)

// Best-effort persistence helpers. Gameplay code re-saves a character or
// account after most state changes; a save failure there is not recoverable
// by the caller, so these helpers log it once in one place instead of
// silently discarding it at ~100 call sites. Lifecycle transactions (create,
// delete, rename, migration) intentionally do NOT use these: they must
// propagate save errors to the caller.

func (g *Game) saveCharacter(p *player.Player) {
	if err := g.AccountStore.SaveCharacter(p); err != nil {
		log.Printf("save character %s: %v", p.Name, err)
	}
}

func (g *Game) saveAccount(acc *player.Account) {
	if err := g.AccountStore.SaveAccount(acc); err != nil {
		log.Printf("save account %s: %v", acc.Name, err)
	}
}