-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathspell.go
39 lines (35 loc) · 1.31 KB
/
spell.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
package go5e
type Spell struct {
Id string `json:"_id"`
Index string `json:"index"`
Name string `json:"name"`
Desc []string `json:"desc"`
HigherLevel []string `json:"higher_level"`
Range string `json:"range"`
Components []string `json:"components"`
Material string `json:"material"`
Ritual bool `json:"ritual"`
Duration string `json:"duration"`
Concentration bool `json:"concentration"`
CastingTime string `json:"casting_time"`
Level int `json:"level"`
School NamedAPIResource `json:"school"`
Classes []NamedAPIResource `json:"classes"`
Subclasses []NamedAPIResource `json:"subclasses"`
Url string `json:"url"`
}
func GetSpell(index string) (Spell, error) {
var ret Spell
err := doRequestAndUnmarshal("spells/"+index, &ret)
return ret, err
}
func GetSpellByUrl(url string) (Spell, error) {
var ret Spell
err := doRequestRawAndUnmarshal(url, ret)
return ret, err
}
func SearchSpellByName(query string) (NamedAPIResourceList, error) {
var ret NamedAPIResourceList
err := doRequestAndUnmarshal("spells/?name="+query, &ret)
return ret, err
}