-
Notifications
You must be signed in to change notification settings - Fork 26
/
HighscoreCategory.go
68 lines (63 loc) · 1.58 KB
/
HighscoreCategory.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
package main
import (
"errors"
"strings"
)
type HighscoreCategory int
const (
achievements HighscoreCategory = iota + 1
axefighting
charmpoints
clubfighting
distancefighting
experience
fishing
fistfighting
goshnarstaint
loyaltypoints
magiclevel
shielding
swordfighting
dromescore
)
func (hc HighscoreCategory) String() (string, error) {
seasons := [...]string{"achievements", "axefighting", "charmpoints", "clubfighting", "distancefighting", "experience", "fishing", "fistfighting", "goshnarstaint", "loyaltypoints", "magiclevel", "shielding", "swordfighting", "dromescore"}
if hc < achievements || hc > dromescore {
return "", errors.New("invalid HighscoreCategory value")
}
return seasons[hc-1], nil
}
func HighscoreCategoryFromString(input string) HighscoreCategory {
// Sanatize of category value
input = strings.ToLower(input)
switch input {
case "achievements", "achievement":
return achievements
case "axe", "axefighting":
return axefighting
case "charm", "charms", "charmpoints":
return charmpoints
case "club", "clubfighting":
return clubfighting
case "distance", "distancefighting":
return distancefighting
case "fishing":
return fishing
case "fist", "fistfighting":
return fistfighting
case "goshnar", "goshnars", "goshnarstaint":
return goshnarstaint
case "loyalty", "loyaltypoints":
return loyaltypoints
case "magic", "mlvl", "magiclevel":
return magiclevel
case "shielding", "shield":
return shielding
case "sword", "swordfighting":
return swordfighting
case "drome", "dromescore":
return dromescore
default:
return experience
}
}