-
Notifications
You must be signed in to change notification settings - Fork 1
/
farmside.go
52 lines (44 loc) · 1.42 KB
/
farmside.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
package go_carcassonne
// Farm notch which is a piece of a farm side
const (
FarmNotchA = "A"
FarmNotchB = "B"
)
/*
Farm sides of a tile
TopA TopB
—— ——
LeftB | | RightA
LeftA | | RightB
—— ——
BottomB BottomA
*/
const (
FarmSideTopA = SideTop + FarmNotchA
FarmSideTopB = SideTop + FarmNotchB
FarmSideRightA = SideRight + FarmNotchA
FarmSideRightB = SideRight + FarmNotchB
FarmSideBottomA = SideBottom + FarmNotchA
FarmSideBottomB = SideBottom + FarmNotchB
FarmSideLeftA = SideLeft + FarmNotchA
FarmSideLeftB = SideLeft + FarmNotchB
)
var (
FarmSides = []string{FarmSideTopA, FarmSideTopB, FarmSideRightA, FarmSideRightB, FarmSideBottomA, FarmSideBottomB, FarmSideLeftA, FarmSideLeftB}
AcrossFarmSide = map[string]string{FarmSideTopA: FarmSideBottomB, FarmSideTopB: FarmSideBottomA, FarmSideRightA: FarmSideLeftB, FarmSideRightB: FarmSideLeftA, FarmSideBottomA: FarmSideTopB, FarmSideBottomB: FarmSideTopA, FarmSideLeftA: FarmSideRightB, FarmSideLeftB: FarmSideRightA}
)
func farmSideToSide(farmSide string) string {
return farmSide[:len(farmSide)-1]
}
func farmSideToAB(farmSide string) string {
return string(farmSide[len(farmSide)-1])
}
func sideToFarmSide(side, ab string) string {
return side + ab
}
func inverseAB(ab string) string {
if ab == FarmNotchA {
return FarmNotchB
}
return FarmNotchA
}