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) }