-
Notifications
You must be signed in to change notification settings - Fork 9
/
belt.go
44 lines (36 loc) · 879 Bytes
/
belt.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
package data
import (
"strings"
"github.com/hectorgimenez/d2go/pkg/data/item"
)
const (
HealingPotion PotionType = "HealingPotion"
ManaPotion PotionType = "ManaPotion"
RejuvenationPotion PotionType = "RejuvenationPotion"
)
type Belt struct {
Items []Item
Name item.Name
}
func (b Belt) GetFirstPotion(potionType PotionType) (Position, bool) {
for _, i := range b.Items {
// Ensure potion is in row 0 and one of the four columns
if strings.Contains(string(i.Name), string(potionType)) && i.Position.Y == 0 && (i.Position.X == 0 || i.Position.X == 1 || i.Position.X == 2 || i.Position.X == 3) {
return i.Position, true
}
}
return Position{}, false
}
func (b Belt) Rows() int {
switch b.Name {
case "":
return 1
case "Sash", "LightBelt":
return 2
case "Belt", "HeavyBelt":
return 3
default:
return 4
}
}
type PotionType string