-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathbnet_utils.go
More file actions
43 lines (38 loc) · 1.03 KB
/
bnet_utils.go
File metadata and controls
43 lines (38 loc) · 1.03 KB
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
package main
import (
"fmt"
"strings"
)
const corruptionR = 149
const corruptionG = 109
const corruptionB = 209
/* REALM UTILITIES */
// Given two strings, if either one is the name of a realm (case insensitive)
// returns realm, player (, error).
func distinguishRealmFromPlayer(input1, input2 string) (string, string, error) {
for _, r := range wowRealms.Realms {
// Exact match
if strings.EqualFold(strings.ToLower(input1), strings.ToLower(r.Name)) {
return r.Slug, input2, nil
}
if strings.EqualFold(strings.ToLower(input2), strings.ToLower(r.Name)) {
return r.Slug, input1, nil
}
}
return "", "", fmt.Errorf("Realm not found")
}
// Given a WowDude with stats, give back all the available stat names.
func populateWoWStats(wd wowDude) []string {
var ret []string
for _, cat := range wd.cas.Categories {
for _, sc := range cat.SubCategories {
for _, stat := range sc.Statistics {
ret = append(ret, stat.Name)
}
}
for _, stat := range cat.Statistics {
ret = append(ret, stat.Name)
}
}
return ret
}