-
Notifications
You must be signed in to change notification settings - Fork 2
/
action_button.go
56 lines (47 loc) · 1.01 KB
/
action_button.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
package models
import "fmt"
type ActionType uint8
const (
ActionSpell ActionType = iota
ActionMacro
ActionItem
)
func (at ActionType) String() string {
if str, err := at.EncodeWord(); err == nil {
return str
}
return fmt.Sprintf("ActionType(%d)", at)
}
func (at *ActionType) EncodeWord() (string, error) {
switch *at {
case ActionSpell:
return "Spell", nil
case ActionMacro:
return "Macro", nil
case ActionItem:
return "Item", nil
default:
return "", fmt.Errorf("spell: invalid ActionType in EncodeWord %d", *at)
}
}
func (at *ActionType) DecodeWord(data string) error {
switch data {
case "Spell":
*at = ActionSpell
case "Macro":
*at = ActionMacro
case "Item":
*at = ActionItem
default:
return fmt.Errorf("spell: invalid string in ActionType.DecodeWord %s", data)
}
return nil
}
// ActionButton stores all the buttons a player has in their action bars.
type ActionButton struct {
Player uint64 `xorm:"'player' index"`
Button uint8
Action uint32
Type ActionType
Misc uint8
}