/
ExtraDirections.jl
177 lines (127 loc) · 3.27 KB
/
ExtraDirections.jl
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
"""
MenuAdventures.ExtraDirections
A sub-module with a bunch of extra directions
```jldoctest
julia> using MenuAdventures
julia> using MenuAdventures.Testing
julia> using MenuAdventures.ExtraDirections
julia> @universe struct Universe <: AbstractUniverse
end;
julia> @noun struct Room <: AbstractRoom
already_lit::Bool = true
end;
julia> @noun struct Person <: Noun
end;
julia> cd(joinpath(pkgdir(MenuAdventures), "test", "ExtraDirections")) do
check_choices() do interface
you = Person(
"Brandon",
grammatical_person = second_person,
indefinite_article = "",
)
center_room = Room("central room")
universe = Universe(you, interface = interface)
universe[center_room, you] = Containing()
universe[center_room, Room("room")] = West()
universe[center_room, Room("room")] = NorthWest()
universe[center_room, Room("room")] = North()
universe[center_room, Room("room")] = NorthEast()
universe[center_room, Room("room")] = East()
universe[center_room, Room("room")] = SouthEast()
universe[center_room, Room("room")] = South()
universe[center_room, Room("room")] = SouthWest()
universe[center_room, Room("room")] = Up()
universe[center_room, Room("room")] = Down()
universe[center_room, Room("room")] = Inside()
universe[center_room, Room("room")] = Outside()
universe
end
end
true
```
"""
module ExtraDirections
import Base: show
using MenuAdventures: Direction
import MenuAdventures: opposite
"""
NorthWest()
A [`Direction`](@ref).
"""
struct NorthWest <: Direction end
export NorthWest
function show(io::IO, ::NorthWest)
print(io, "north-west")
end
opposite(::NorthWest) = SouthEast()
"""
SouthWest()
A [`Direction`](@ref).
"""
struct SouthWest <: Direction end
export SouthWest
function show(io::IO, ::SouthWest)
print(io, "south-west")
end
opposite(::SouthWest) = NorthEast()
"""
SouthEast()
A [`Direction`](@ref).
"""
struct SouthEast <: Direction end
export SouthEast
function show(io::IO, ::SouthEast)
print(io, "south-east")
end
opposite(::SouthEast) = NorthWest()
"""
NorthEast()
A [`Direction`](@ref).
"""
struct NorthEast <: Direction end
export NorthEast
function show(io::IO, ::NorthEast)
print(io, "north-east")
end
opposite(::NorthEast) = SouthWest()
"""
Up()
A [`Direction`](@ref).
"""
struct Up <: Direction end
export Up
function show(io::IO, ::Up)
print(io, "up")
end
opposite(::Up) = Down()
"""
Down()
A [`Direction`](@ref).
"""
struct Down <: Direction end
export Down
function show(io::IO, ::Down)
print(io, "down")
end
opposite(::Down) = Up()
"""
Inside()
A [`Direction`](@ref).
"""
struct Inside <: Direction end
export Inside
function show(io::IO, ::Inside)
print(io, "inside")
end
opposite(::Inside) = Outside()
"""
Outside()
A [`Direction`](@ref).
"""
struct Outside <: Direction end
export Outside
function show(io::IO, ::Outside)
print(io, "outside")
end
opposite(::Outside) = Inside()
end