aboutsummaryrefslogtreecommitdiff
path: root/internal/game/flagstore.go
diff options
context:
space:
mode:
authorhistoria <[not public]>2026-06-24 22:55:35 -0400
committerhistoria <[not public]>2026-06-24 22:55:35 -0400
commit15b7e221b799ef107dec44ecdb294026dfd3d059 (patch)
tree3748e464a77f0f082bea1567e9d6990052054961 /internal/game/flagstore.go
parent9d4b799db4868bcab291b83599ff088763cd4ed6 (diff)
downloadthehouseoficarus-15b7e221b799ef107dec44ecdb294026dfd3d059.tar.gz
refactor: pulled techs out to yaml files, unified numerous combat functions, broke up game object
Diffstat (limited to 'internal/game/flagstore.go')
-rw-r--r--internal/game/flagstore.go42
1 files changed, 42 insertions, 0 deletions
diff --git a/internal/game/flagstore.go b/internal/game/flagstore.go
new file mode 100644
index 0000000..2790d89
--- /dev/null
+++ b/internal/game/flagstore.go
@@ -0,0 +1,42 @@
+package game
+
+import "sync"
+
+// 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 {
+ mu sync.Mutex
+ flags map[string]any
+}
+
+func NewFlagStore() *FlagStore {
+ return &FlagStore{flags: make(map[string]any)}
+}
+
+func (f *FlagStore) 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) {
+ f.mu.Lock()
+ defer f.mu.Unlock()
+ f.flags[name] = value
+}
+
+func (f *FlagStore) SetAll(m map[string]any) {
+ f.mu.Lock()
+ defer f.mu.Unlock()
+ for k, v := range m {
+ f.flags[k] = v
+ }
+}
+
+func (f *FlagStore) Delete(name string) {
+ f.mu.Lock()
+ defer f.mu.Unlock()
+ delete(f.flags, name)
+}