Add player actions to world core

This commit is contained in:
lpf
2026-03-16 12:04:55 +08:00
parent d9671892f3
commit 5bce2cfdef
7 changed files with 267 additions and 73 deletions

View File

@@ -44,6 +44,12 @@ func DefaultWorldState() WorldState {
LastAdvance: now,
TickDuration: 30,
},
Player: PlayerState{
PlayerID: "player",
DisplayName: "Player",
CurrentLocation: "commons",
Status: "active",
},
Locations: map[string]Location{
"commons": {
ID: "commons",
@@ -89,6 +95,12 @@ func (s *Store) LoadWorldState() (WorldState, error) {
if state.Locations == nil {
state.Locations = DefaultWorldState().Locations
}
if strings.TrimSpace(state.Player.PlayerID) == "" {
state.Player = DefaultWorldState().Player
}
if strings.TrimSpace(state.Player.CurrentLocation) == "" {
state.Player.CurrentLocation = "commons"
}
if state.GlobalFacts == nil {
state.GlobalFacts = map[string]interface{}{}
}