-
Notifications
You must be signed in to change notification settings - Fork 3
/
consumables.go
89 lines (71 loc) · 1.78 KB
/
consumables.go
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
package genshinapi
import (
"encoding/json"
)
const (
ConsumablesDType = "consumables"
// Assets only available for potions.
// For asset names, get key from PotionList.
FoodConsumable = "food"
PotionConsumable = "potions"
)
type FoodList map[string]Food
type Food struct {
Name string `json:"name"`
Rarity int `json:"rarity"`
Type string `json:"type"`
Effect string `json:"effect"`
HasRecipe bool `json:"hasRecipe"`
Description string `json:"description"`
Proficiency int `json:"proficiency"`
Recipe []Ingredient `json:"recipe"`
}
func (f *Food) EntryName() string {
return f.Name
}
type PotionList map[string]Potion
type Potion struct {
Name string `json:"name"`
Effect string `json:"effect"`
Rarity int `json:"rarity"`
Crafting []Ingredient `json:"crafting"`
}
func (p *Potion) EntryName() string {
return p.Name
}
type Ingredient struct {
Item string `json:"item"`
Quantity int `json:"quantity"`
}
// GetConsumables : Get a list of consumables
func GetConsumables() ([]string, error) {
return GetDataTypeItemsList(ConsumablesDType)
}
// GetFoodList : Return a map of Food items.
func GetFoodList() (FoodList, error) {
reqBody := []string{
ConsumablesDType,
FoodConsumable,
}
bytearray, err := GetCustomBody(reqBody...)
if err != nil {
return nil, err
}
var list FoodList
err = json.Unmarshal(bytearray, &list)
return list, err
}
// GetPotionList : Get a list of potions
func GetPotionList() (PotionList, error) {
reqBody := []string{
ConsumablesDType,
PotionConsumable,
}
bytearray, err := GetCustomBody(reqBody...)
if err != nil {
return nil, err
}
var list PotionList
err = json.Unmarshal(bytearray, &list)
return list, err
}