-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstatic.go
More file actions
75 lines (66 loc) · 1.8 KB
/
static.go
File metadata and controls
75 lines (66 loc) · 1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
package main
import (
"encoding/json"
"log"
"os"
)
var WokaDB map[string]WokaPart
var WokaKV = make(map[string]string)
type WokaPart struct {
Required bool `json:"required"`
Collections []WokaCollection `json:"collections"`
}
type WokaCollection struct {
Name string `json:"name"`
Position int `json:"position"`
Textures []WokaTexture `json:"textures"`
}
type WokaTexture struct {
ID string `json:"id"`
Name string `json:"name"`
URL string `json:"url"`
Position int `json:"position"`
}
var CompanionDB []CompanionCollection
var CompanionKV = make(map[string]string)
type CompanionCollection struct {
Name string `json:"name"`
Position int `json:"position"`
Textures []CompanionTexture `json:"textures"`
}
type CompanionTexture struct {
ID string `json:"id"`
Name string `json:"name"`
Behavior string `json:"behavior"`
URL string `json:"url"`
}
func LoadFiles() {
wokaFile, err := os.Open("woka.json")
if err != nil {
log.Panic("Failed to open woka.json: ", err)
}
defer wokaFile.Close()
if err := json.NewDecoder(wokaFile).Decode(&WokaDB); err != nil {
log.Panic("Failed to decode woka.json: ", err)
}
for _, part := range WokaDB {
for _, collection := range part.Collections {
for _, texture := range collection.Textures {
WokaKV[texture.ID] = texture.URL
}
}
}
companionsFile, err := os.Open("companions.json")
if err != nil {
log.Panic("Failed to open companions.json: ", err)
}
defer companionsFile.Close()
if err := json.NewDecoder(companionsFile).Decode(&CompanionDB); err != nil {
log.Panic("Failed to decode companions.json: ", err)
}
for _, collection := range CompanionDB {
for _, texture := range collection.Textures {
CompanionKV[texture.ID] = texture.URL
}
}
}