-
Notifications
You must be signed in to change notification settings - Fork 11
/
maps.go
128 lines (115 loc) · 4.15 KB
/
maps.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
package gw2api
import (
"fmt"
"net/url"
)
// Map holds specific map details. ContinentID and RegionID can be used with the
// API to find higher orders of association
type Map struct {
ID int `json:"id"`
Name string `json:"name"`
MinLevel int `json:"min_level"`
MaxLevel int `json:"max_level"`
DefaultFloor int `json:"default_floor"`
Floors []int `json:"floors"`
RegionID int `json:"region_id"`
RegionName string `json:"region_name"`
ContinentID int `json:"continent_id"`
ContinentName string `json:"continent_name"`
MapRect [2][2]int `json:"map_rect"`
ContinentRect [2][2]int `json:"continent_rect"`
}
// Maps returns a list of all map ids
func (gw2 *GW2Api) Maps() (res []int, err error) {
ver := "v2"
tag := "skins"
err = gw2.fetchEndpoint(ver, tag, nil, &res)
return
}
// MapIds returns the map information localized to lang for requested ids
func (gw2 *GW2Api) MapIds(lang string, ids ...int) (maps []Map, err error) {
ver := "v2"
tag := "maps"
params := url.Values{}
if lang != "" {
params.Add("lang", lang)
}
params.Add("ids", commaList(stringSlice(ids)))
err = gw2.fetchEndpoint(ver, tag, params, &maps)
return
}
// Continents reutns a list of continent ids. Only 1 = Tyria and 2 = Mists for
// now
func (gw2 *GW2Api) Continents() (res []int, err error) {
ver := "v2"
tag := "continents"
err = gw2.fetchEndpoint(ver, tag, nil, &res)
return
}
// Continent information
type Continent struct {
ID int `json:"id"`
Name string `json:"name"`
ContinentDims []int `json:"continent_dims"`
MinZoom int `json:"min_zoom"`
MaxZoom int `json:"max_zoom"`
Floors []int `json:"floors"`
}
// ContinentIds returns continent information localized to lang for requested
// ids
func (gw2 *GW2Api) ContinentIds(lang string, ids ...int) (conts []Continent, err error) {
ver := "v2"
tag := "continents"
params := url.Values{}
if lang != "" {
params.Add("lang", lang)
}
params.Add("ids", commaList(stringSlice(ids)))
err = gw2.fetchEndpoint(ver, tag, params, &conts)
return
}
// ContinentFloors returns all floor ids on the continent
func (gw2 *GW2Api) ContinentFloors(continent int) (floors []int, err error) {
ver := "v2"
tag := fmt.Sprintf("continents/%d/floors", continent)
err = gw2.fetchEndpoint(ver, tag, nil, &floors)
return
}
// ContinentFloorRegions returns all regions on the continent and floor
func (gw2 *GW2Api) ContinentFloorRegions(continent, floor int) (regions []int, err error) {
ver := "v2"
tag := fmt.Sprintf("continents/%d/floors/%d/regions", continent, floor)
err = gw2.fetchEndpoint(ver, tag, nil, ®ions)
return
}
// ContinentFloorRegionMaps returns all maps ont he continent, floor and region
func (gw2 *GW2Api) ContinentFloorRegionMaps(continent, floor, region int) (maps []int, err error) {
ver := "v2"
tag := fmt.Sprintf("continents/%d/floors/%d/regions/%d/maps", continent, floor, region)
err = gw2.fetchEndpoint(ver, tag, nil, &maps)
return
}
// ContinentFloorRegionMapSectors returns all sectors on the continent,
// floor, region and map
func (gw2 *GW2Api) ContinentFloorRegionMapSectors(continent, floor, region, mapID int) (sectors []int, err error) {
ver := "v2"
tag := fmt.Sprintf("continents/%d/floors/%d/regions/%d/maps/%d/sectors", continent, floor, region, mapID)
err = gw2.fetchEndpoint(ver, tag, nil, §ors)
return
}
// ContinentFloorRegionMapPois returns all points of interest on the continent,
// floor, region and map
func (gw2 *GW2Api) ContinentFloorRegionMapPois(continent, floor, region, mapID int) (pois []int, err error) {
ver := "v2"
tag := fmt.Sprintf("continents/%d/floors/%d/regions/%d/maps/%d/pois", continent, floor, region, mapID)
err = gw2.fetchEndpoint(ver, tag, nil, &pois)
return
}
// ContinentFloorRegionMapTasks returns all taskson the continent, floor, region
// and map
func (gw2 *GW2Api) ContinentFloorRegionMapTasks(continent, floor, region, mapID int) (tasks []int, err error) {
ver := "v2"
tag := fmt.Sprintf("continents/%d/floors/%d/regions/%d/maps/%d/tasks", continent, floor, region, mapID)
err = gw2.fetchEndpoint(ver, tag, nil, &tasks)
return
}