-
Notifications
You must be signed in to change notification settings - Fork 0
/
deposit.go
66 lines (62 loc) · 1.33 KB
/
deposit.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
package main
type Deposit struct {
position Position
width int
height int
subtype int
}
func (d Deposit) Rectangle() Rectangle {
return Rectangle{
position: d.position,
width: d.width,
height: d.height,
}
}
func (d Deposit) NextToEgressPositions() []Position {
positions := make([]Position, 2*d.width+2*d.height)
for i := 0; i < d.width; i++ {
positions[i] = Position{
x: d.position.x + i,
y: d.position.y - 1,
}
positions[d.width+i] = Position{
x: d.position.x + i,
y: d.position.y + d.height,
}
}
for i := 0; i < d.height; i++ {
positions[2*d.width+i] = Position{
x: d.position.x - 1,
y: d.position.y + i,
}
positions[2*d.width+d.height+i] = Position{
x: d.position.x + d.width,
y: d.position.y + i,
}
}
return positions
}
func (d Deposit) EgressPositions() []Position {
positions := make([]Position, 0)
for i := 0; i < d.width; i++ {
positions = append(positions, Position{
x: d.position.x + i,
y: d.position.y,
})
positions = append(positions, Position{
x: d.position.x + i,
y: d.position.y + d.height - 1,
})
}
for i := 0; i < d.height; i++ {
positions = append(positions, Position{
x: d.position.x,
y: d.position.y + i,
})
positions = append(positions, Position{
x: d.position.x + d.width - 1,
y: d.position.y + i,
})
}
return positions
}