From 15b7e221b799ef107dec44ecdb294026dfd3d059 Mon Sep 17 00:00:00 2001 From: historia <[not public]> Date: Wed, 24 Jun 2026 22:55:35 -0400 Subject: refactor: pulled techs out to yaml files, unified numerous combat functions, broke up game object --- internal/game/flagstore.go | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 internal/game/flagstore.go (limited to 'internal/game/flagstore.go') 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) +} -- cgit v1.2.3