From 085e728d22a3369bd110b77409914cfbe9ebe611 Mon Sep 17 00:00:00 2001 From: historia <[not public]> Date: Tue, 16 Jun 2026 04:17:43 -0400 Subject: feat: recipe system, combining items, cooking skill --- internal/object/item_store.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'internal/object/item_store.go') diff --git a/internal/object/item_store.go b/internal/object/item_store.go index 6d62143..9e932ba 100644 --- a/internal/object/item_store.go +++ b/internal/object/item_store.go @@ -4,6 +4,7 @@ import ( "fmt" "os" "path/filepath" + "strings" "gopkg.in/yaml.v3" ) @@ -36,3 +37,24 @@ func (s *ItemStore) Load(id string) (*ItemDef, error) { s.cache[id] = &def return &def, nil } + +func (s *ItemStore) LoadAll() ([]*ItemDef, error) { + dir := filepath.Join(s.dataDir, "items") + entries, err := os.ReadDir(dir) + if err != nil { + return nil, err + } + var defs []*ItemDef + for _, e := range entries { + if e.IsDir() || filepath.Ext(e.Name()) != ".yaml" { + continue + } + id := strings.TrimSuffix(e.Name(), ".yaml") + def, err := s.Load(id) + if err != nil { + continue + } + defs = append(defs, def) + } + return defs, nil +} -- cgit v1.2.3