-
Notifications
You must be signed in to change notification settings - Fork 3
/
characters.go
61 lines (52 loc) · 1.6 KB
/
characters.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
package genshinapi
const (
CharactersDType = "characters"
CharacterIcon = "icon"
CharacterPortrait = "portrait"
)
type Character struct {
Name string `json:"name"`
Title string `json:"title"`
Vision string `json:"vision"`
Weapon string `json:"weapon"`
Gender string `json:"gender"`
Nation string `json:"nation"`
Affiliation string `json:"affiliation"`
SpecialDish string `json:"specialDish"`
Rarity int `json:"rarity"`
Constellation string `json:"constellation"`
Birthday string `json:"birthday"`
Description string `json:"description"`
SkillTalents []Talent `json:"skillTalents"`
PassiveTalents []Talent `json:"passiveTalents"`
Constellations []Talent `json:"constellations"`
}
type Talent struct {
Name string `json:"name"`
Unlock string `json:"unlock"`
Description string `json:"description"`
Upgrades []UpgradeLevel `json:"upgrades"`
SkillType string `json:"type"`
Level int `json:"level"`
}
type UpgradeLevel struct {
Name string `json:"name"`
Value string `json:"value"`
}
func (c Character) EntryName() string {
return c.Name
}
// GetCharacters : Get list of character names.
func GetCharacters() ([]string, error) {
return GetDataTypeItemsList(CharactersDType)
}
// GetCharacter : Return a requested Character struct.
func GetCharacter(name string) (Character, error) {
reqBody := []string{
CharactersDType,
name,
}
var character Character
err := getDataAndUnmarshal(reqBody, &character)
return character, err
}