aboutsummaryrefslogtreecommitdiff
path: root/internal/cardart/store.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/cardart/store.go')
-rw-r--r--internal/cardart/store.go27
1 files changed, 27 insertions, 0 deletions
diff --git a/internal/cardart/store.go b/internal/cardart/store.go
new file mode 100644
index 0000000..0763e46
--- /dev/null
+++ b/internal/cardart/store.go
@@ -0,0 +1,27 @@
+package cardart
+
+import (
+ "os"
+
+ "gopkg.in/yaml.v3"
+)
+
+type Store struct {
+ Cards map[string]map[int][]string `yaml:"cards"`
+}
+
+func Load(path string) *Store {
+ store := &Store{Cards: make(map[string]map[int][]string)}
+ data, err := os.ReadFile(path)
+ if err != nil || yaml.Unmarshal(data, store) != nil {
+ return store
+ }
+ return store
+}
+
+func (s *Store) Art(key string, size int) []string {
+ if s == nil || s.Cards == nil {
+ return nil
+ }
+ return s.Cards[key][size]
+}