aboutsummaryrefslogtreecommitdiff
path: root/internal/game/core_flagstore.go
diff options
context:
space:
mode:
authorhistoria <[not public]>2026-07-07 16:24:27 -0400
committerhistoria <[not public]>2026-07-07 16:24:27 -0400
commitab2597b22ccdb71116992aec78080d9858358d04 (patch)
tree8beae4060c2831c4a68f92b682b5350cfa1d0afb /internal/game/core_flagstore.go
parent3f30fa3eec9c2e2acf9a984ccefb9529a25e688a (diff)
downloadthehouseoficarus-ab2597b22ccdb71116992aec78080d9858358d04.tar.gz
rename flags to global_flags (differentiate from player_flags)
Diffstat (limited to 'internal/game/core_flagstore.go')
-rw-r--r--internal/game/core_flagstore.go30
1 files changed, 15 insertions, 15 deletions
diff --git a/internal/game/core_flagstore.go b/internal/game/core_flagstore.go
index ecefccf..18578b7 100644
--- a/internal/game/core_flagstore.go
+++ b/internal/game/core_flagstore.go
@@ -2,37 +2,37 @@ package game
import "sync"
-// FlagChangeCallback is invoked when a world flag value actually changes
+// GlobalFlagChangeCallback is invoked when a global flag value actually changes
// (old value differs from new, or new flag is created with a truthy value).
-type FlagChangeCallback func(name string, value any)
+type GlobalFlagChangeCallback func(name string, value any)
-// FlagStore holds world flags — shared mutable state visible to all players
-// (e.g. opened doors, quest state). Player-specific flags live on
-// *player.Player.Flags instead. FlagStore is safe for concurrent use.
-type FlagStore struct {
+// GlobalFlagStore holds global flags — shared mutable state visible to all
+// players (e.g. opened doors, quest state). Player-specific flags live on
+// *player.Player.Flags instead. GlobalFlagStore is safe for concurrent use.
+type GlobalFlagStore struct {
mu sync.Mutex
flags map[string]any
- callbacks []FlagChangeCallback
+ callbacks []GlobalFlagChangeCallback
}
-func NewFlagStore() *FlagStore {
- return &FlagStore{flags: make(map[string]any)}
+func NewGlobalFlagStore() *GlobalFlagStore {
+ return &GlobalFlagStore{flags: make(map[string]any)}
}
-func (f *FlagStore) OnChange(cb FlagChangeCallback) {
+func (f *GlobalFlagStore) OnChange(cb GlobalFlagChangeCallback) {
f.mu.Lock()
defer f.mu.Unlock()
f.callbacks = append(f.callbacks, cb)
}
-func (f *FlagStore) Get(name string) (any, bool) {
+func (f *GlobalFlagStore) Get(name string) (any, bool) {
f.mu.Lock()
defer f.mu.Unlock()
v, ok := f.flags[name]
return v, ok
}
-func (f *FlagStore) Set(name string, value any) {
+func (f *GlobalFlagStore) Set(name string, value any) {
f.mu.Lock()
old, existed := f.flags[name]
f.flags[name] = value
@@ -46,7 +46,7 @@ func (f *FlagStore) Set(name string, value any) {
}
}
-func (f *FlagStore) SetAll(m map[string]any) {
+func (f *GlobalFlagStore) SetAll(m map[string]any) {
f.mu.Lock()
changed := make(map[string]any)
for k, v := range m {
@@ -66,13 +66,13 @@ func (f *FlagStore) SetAll(m map[string]any) {
}
}
-func (f *FlagStore) Delete(name string) {
+func (f *GlobalFlagStore) Delete(name string) {
f.mu.Lock()
defer f.mu.Unlock()
delete(f.flags, name)
}
-func (f *FlagStore) All() map[string]any {
+func (f *GlobalFlagStore) All() map[string]any {
f.mu.Lock()
defer f.mu.Unlock()
out := make(map[string]any, len(f.flags))