diff options
Diffstat (limited to 'tools/importer/ACDv2Reader.go')
-rw-r--r-- | tools/importer/ACDv2Reader.go | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/tools/importer/ACDv2Reader.go b/tools/importer/ACDv2Reader.go index 2ddca4d..974da52 100644 --- a/tools/importer/ACDv2Reader.go +++ b/tools/importer/ACDv2Reader.go | |||
@@ -9,6 +9,8 @@ import ( | |||
9 | "fagott.pw/grilist/modules/grils" | 9 | "fagott.pw/grilist/modules/grils" |
10 | ) | 10 | ) |
11 | 11 | ||
12 | const failMsg = "Offenbar war meine Annahme bzgl. der Traits nicht ganz korrekt" | ||
13 | |||
12 | type ACDv2Reader struct{} | 14 | type ACDv2Reader struct{} |
13 | 15 | ||
14 | type ACDv2NameValue struct { | 16 | type ACDv2NameValue struct { |
@@ -58,6 +60,21 @@ func (r *ACDv2Reader) Read(path string) WrappedGril { | |||
58 | for _, v := range jObj.Tags { | 60 | for _, v := range jObj.Tags { |
59 | g.Gril.Tags = append(g.Gril.Tags, v.Name) | 61 | g.Gril.Tags = append(g.Gril.Tags, v.Name) |
60 | } | 62 | } |
63 | g.Gril.Traits = make([]grils.Trait, 0) | ||
64 | if len(jObj.Traits.Official) != len(jObj.Traits.Indexed) { | ||
65 | panic(failMsg) | ||
66 | } | ||
67 | for i := 0; i < len(jObj.Traits.Official); i++ { | ||
68 | if jObj.Traits.Official[i].Name != jObj.Traits.Indexed[i].Name { | ||
69 | panic(failMsg) | ||
70 | } | ||
71 | t := grils.Trait{ | ||
72 | Name: jObj.Traits.Official[i].Name, | ||
73 | Value: jObj.Traits.Indexed[i].Value, | ||
74 | OfficialValue: jObj.Traits.Official[i].Value, | ||
75 | } | ||
76 | g.Gril.Traits = append(g.Gril.Traits, t) | ||
77 | } | ||
61 | return g | 78 | return g |
62 | } | 79 | } |
63 | 80 | ||