-
Notifications
You must be signed in to change notification settings - Fork 11
/
mechanics.go
145 lines (119 loc) · 3.59 KB
/
mechanics.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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
package gw2api
import "net/url"
// Trait overview with facts
type Trait struct {
ID int `json:"id"`
Name string `json:"icon"`
Icon string `json:"icon"`
Description string `json:"description"`
Specialization int `json:"specialization"`
Tier int `json:"tier"`
Order int `josn:"order"`
Slot string `json:"slot"`
Facts []Fact `json:"facts"`
TraitedFacts []TraitedFact `json:"traited_facts"`
Skills []Skill `json:"skills"`
}
// Skill with associated facts
type Skill struct {
ID int `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
Icon string `json:"icon"`
Facts []Fact `json:"facts"`
TraitedFacts []TraitedFact `json:"traited_facts"`
}
// FactType - One of the types a fact can be
// Set fields depend on the Type
type FactType struct {
//Common fields
Text string `json:"text"`
Type string `json:"type"`
Icon string `json:"icon"`
Description string `json:"description"`
Percent int `json:"percent"`
Target string `json:"target"`
Duration int `json:"duration"`
Status string `json:"status"`
ApplyCount int `json:"apply_count"`
Value int `json:"value"`
// AttributeAdjustFact
// BuffFact
// BuffConversionFact
Source string `json:"source"`
// ComboFieldFact
FinisherType string `json:"finisher_type"`
// DamageFact
HitCount int `json:"hit_count"`
// DistanceFact
Distance int `json:"distance"`
// NoDataFact
// PercentFact
// PrefixedBuffFact
Prefix Fact `json:"prefix"`
// RadiusFact
// RangeFact
// RechargeFact
// TimeFact
// UnblockableFact
}
// Fact associated with a trait or skill
type Fact struct {
Text string `json:"text"`
Icon string `json:"icon"`
Type string `json:"type"`
Facts []FactType `json:"facts"`
// Only as TraitedFact
RequiresTrait int `json:"requires_trait"`
Overrides int `json:"overrides"`
}
// TraitedFact has some extra attributes
type TraitedFact Fact
// Traits a list of all traits
func (gw2 *GW2Api) Traits() (res []int, err error) {
ver := "v2"
tag := "traits"
err = gw2.fetchEndpoint(ver, tag, nil, &res)
return
}
// TraitIds details on the requested traits. Localized to lang
func (gw2 *GW2Api) TraitIds(lang string, ids ...int) (traits []Trait, err error) {
ver := "v2"
tag := "traits"
params := url.Values{}
if lang != "" {
params.Add("lang", lang)
}
params.Add("ids", commaList(stringSlice(ids)))
err = gw2.fetchEndpoint(ver, tag, params, &traits)
return
}
// DetailSpecialization spec lines and their traits
type DetailSpecialization struct {
ID int `json:"id"`
Name string `json:"name"`
Elite bool `json:"elite"`
Icon string `json:"icon"`
Background string `json:"background"`
MinorTraits []int `json:"minor_traits"`
MajorTraits []int `json:"major_traits"`
}
// Specializations returns the list of all
func (gw2 *GW2Api) Specializations() (res []int, err error) {
ver := "v2"
tag := "specializations"
err = gw2.fetchEndpoint(ver, tag, nil, &res)
return
}
// SpecializationIds returns a localized detail object for the requested ids
func (gw2 *GW2Api) SpecializationIds(lang string, ids ...int) (specs []DetailSpecialization, err error) {
ver := "v2"
tag := "specializations"
params := url.Values{}
if lang != "" {
params.Add("lang", lang)
}
params.Add("ids", commaList(stringSlice(ids)))
err = gw2.fetchEndpoint(ver, tag, params, &specs)
return
}