-
Notifications
You must be signed in to change notification settings - Fork 7
/
direction.rb
121 lines (91 loc) · 3.27 KB
/
direction.rb
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
require_relative 'coords'
class NorthEast
def right() East.new end
def left() NorthWest.new end
def reflect_diag_up() NorthEast.new end
def reflect_diag_down() West.new end
def reflect_hori() SouthEast.new end
def reflect_vert() NorthWest.new end
def reflect_branch_left(right) SouthWest.new end
def reflect_branch_right(right) East.new end
def reverse() SouthWest.new end
def vec() PointAxial.new(1,-1) end
def ==(other) other.is_a?(NorthEast) end
def coerce(other) return self, other end
def to_s() "North East" end
end
class NorthWest
def right() NorthEast.new end
def left() West.new end
def reflect_diag_up() East.new end
def reflect_diag_down() NorthWest.new end
def reflect_hori() SouthWest.new end
def reflect_vert() NorthEast.new end
def reflect_branch_left(right) West.new end
def reflect_branch_right(right) SouthEast.new end
def reverse() SouthEast.new end
def vec() PointAxial.new(0,-1) end
def ==(other) other.is_a?(NorthWest) end
def coerce(other) return self, other end
def to_s() "North West" end
end
class West
def right() NorthWest.new end
def left() SouthWest.new end
def reflect_diag_up() SouthEast.new end
def reflect_diag_down() NorthEast.new end
def reflect_hori() West.new end
def reflect_vert() East.new end
def reflect_branch_left(right) East.new end
def reflect_branch_right(right) right ? NorthWest.new : SouthWest.new end
def reverse() East.new end
def vec() PointAxial.new(-1,0) end
def ==(other) other.is_a?(West) end
def coerce(other) return self, other end
def to_s() "West" end
end
class SouthWest
def right() West.new end
def left() SouthEast.new end
def reflect_diag_up() SouthWest.new end
def reflect_diag_down() East.new end
def reflect_hori() NorthWest.new end
def reflect_vert() SouthEast.new end
def reflect_branch_left(right) West.new end
def reflect_branch_right(right) NorthEast.new end
def reverse() NorthEast.new end
def vec() PointAxial.new(-1,1) end
def ==(other) other.is_a?(SouthWest) end
def coerce(other) return self, other end
def to_s() "South West" end
end
class SouthEast
def right() SouthWest.new end
def left() East.new end
def reflect_diag_up() West.new end
def reflect_diag_down() SouthEast.new end
def reflect_hori() NorthEast.new end
def reflect_vert() SouthWest.new end
def reflect_branch_left(right) NorthWest.new end
def reflect_branch_right(right) East.new end
def reverse() NorthWest.new end
def vec() PointAxial.new(0,1) end
def ==(other) other.is_a?(SouthEast) end
def coerce(other) return self, other end
def to_s() "South East" end
end
class East
def right() SouthEast.new end
def left() NorthEast.new end
def reflect_diag_up() NorthWest.new end
def reflect_diag_down() SouthWest.new end
def reflect_hori() East.new end
def reflect_vert() West.new end
def reflect_branch_left(right) right ? SouthEast.new : NorthEast.new end
def reflect_branch_right(right) West.new end
def reverse() West.new end
def vec() PointAxial.new(1,0) end
def ==(other) other.is_a?(East) end
def coerce(other) return self, other end
def to_s() "East" end
end