mission_game 1.1.1 → 1.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/enemy.rb +49 -53
- data/lib/main.rb +142 -142
- data/lib/neworleans.rb +144 -149
- data/lib/player.rb +122 -121
- data/lib/story.rb +38 -42
- data/lib/ui.rb +269 -259
- data/mission_game.rb +41 -43
- metadata +7 -7
data/lib/ui.rb
CHANGED
@@ -1,259 +1,269 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
#
|
3
|
-
# Written by Webster Avosa
|
4
|
-
#
|
5
|
-
|
6
|
-
module MISSIONGAME
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
new_line
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
new_line
|
35
|
-
print "
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
new_line
|
41
|
-
print UI_ARROW.light_yellow + " " + "left, l, ".light_white +
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
new_line
|
47
|
-
print UI_ARROW.light_yellow + " " + "
|
48
|
-
new_line
|
49
|
-
print UI_ARROW.light_yellow + " " + "
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
new_line
|
55
|
-
print UI_ARROW.light_yellow + " " + "
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
new_line
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
player
|
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
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
end
|
203
|
-
|
204
|
-
def
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
end
|
215
|
-
|
216
|
-
def
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
end
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# Written by Webster Avosa
|
4
|
+
#
|
5
|
+
|
6
|
+
module MISSIONGAME
|
7
|
+
UI_FRAME_HORIZONTAL = "\u2501"
|
8
|
+
UI_FRAME_VERTICAL = "\u2503"
|
9
|
+
UI_FRAME_UPPER_LEFT = "\u250F"
|
10
|
+
UI_FRAME_LOWER_LEFT = "\u2517"
|
11
|
+
UI_FRAME_UPPER_RIGHT = "\u2513"
|
12
|
+
UI_FRAME_LOWER_RIGHT = "\u251B"
|
13
|
+
|
14
|
+
UI_COPYRIGHT = "\u00A9"
|
15
|
+
UI_EMAIL = "\u2709"
|
16
|
+
UI_ARROW = "\u2712"
|
17
|
+
|
18
|
+
class UI
|
19
|
+
# Clear the screen
|
20
|
+
def clear
|
21
|
+
print "\e[H\e[2J"
|
22
|
+
end
|
23
|
+
|
24
|
+
def display_map(args)
|
25
|
+
map = args[:map]
|
26
|
+
new_line
|
27
|
+
draw_frame({text: map})
|
28
|
+
new_line
|
29
|
+
end
|
30
|
+
|
31
|
+
def help
|
32
|
+
new_line
|
33
|
+
print "Valid Commands".light_green
|
34
|
+
new_line(2)
|
35
|
+
print UI_ARROW.light_yellow + " " + "right, r, ".light_white +
|
36
|
+
++" - Move right/east"
|
37
|
+
new_line
|
38
|
+
print UI_ARROW.light_yellow + " " + "backward, b, ".light_white +
|
39
|
+
++" - Move backward/south"
|
40
|
+
new_line
|
41
|
+
print UI_ARROW.light_yellow + " " + "left, l, ".light_white +
|
42
|
+
++" - Move left/west"
|
43
|
+
new_line
|
44
|
+
print UI_ARROW.light_yellow + " " + "forward, f, ".light_white +
|
45
|
+
++" - Move forward/north"
|
46
|
+
new_line
|
47
|
+
print UI_ARROW.light_yellow + " " + "map, m".light_white + " - Display map"
|
48
|
+
new_line
|
49
|
+
print UI_ARROW.light_yellow + " " + "where".light_white +
|
50
|
+
" - Describe current surroundings"
|
51
|
+
new_line
|
52
|
+
print UI_ARROW.light_yellow + " " + "name".light_white +
|
53
|
+
" - Reminds player their name"
|
54
|
+
new_line
|
55
|
+
print UI_ARROW.light_yellow + " " + "a, attack".light_white +
|
56
|
+
" - Attack (only in combat)"
|
57
|
+
new_line
|
58
|
+
print UI_ARROW.light_yellow + " " + "enemy".light_white +
|
59
|
+
" - Display information about your enemy"
|
60
|
+
new_line
|
61
|
+
print UI_ARROW.light_yellow + " " +
|
62
|
+
"points, score, status, info".light_white +
|
63
|
+
" - Display points (score)"
|
64
|
+
new_line
|
65
|
+
print UI_ARROW.light_yellow + " " + "clear, cls".light_white +
|
66
|
+
" - Clears the screen"
|
67
|
+
new_line
|
68
|
+
print UI_ARROW.light_yellow + " " + "q, quit, exit".light_white +
|
69
|
+
" - Quits the MISSIONGAME"
|
70
|
+
new_line
|
71
|
+
end
|
72
|
+
|
73
|
+
def points(args)
|
74
|
+
player = args[:player]
|
75
|
+
print "You currently have " + player.points.to_s.light_white + " points."
|
76
|
+
new_line
|
77
|
+
end
|
78
|
+
|
79
|
+
def enemy_info(args)
|
80
|
+
player = args[:player]
|
81
|
+
enemy = player.current_enemy
|
82
|
+
print enemy.name.light_red + " has " + enemy.str.to_s.light_white +
|
83
|
+
" strength and " + enemy.lives.to_s.light_white + " lives."
|
84
|
+
new_line
|
85
|
+
end
|
86
|
+
|
87
|
+
def player_info(args)
|
88
|
+
player = args[:player]
|
89
|
+
print "You have " + player.lives.to_s.light_white + " lives and have " +
|
90
|
+
player.points.to_s.light_white + " points."
|
91
|
+
new_line
|
92
|
+
end
|
93
|
+
|
94
|
+
# Ask user a question. A regular expression filter can be applied.
|
95
|
+
def ask(question, filter = nil)
|
96
|
+
if filter
|
97
|
+
match = false
|
98
|
+
answer = nil
|
99
|
+
while match == false
|
100
|
+
print UI_ARROW.red + question.light_white + " "
|
101
|
+
answer = gets.chomp
|
102
|
+
if answer.match(filter)
|
103
|
+
return answer
|
104
|
+
else
|
105
|
+
print "Sorry, please try again.".red
|
106
|
+
new_line
|
107
|
+
new_line
|
108
|
+
end
|
109
|
+
end
|
110
|
+
else
|
111
|
+
print "\u2712 ".red + question.light_white + " "
|
112
|
+
gets.chomp
|
113
|
+
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
# Display welcome
|
118
|
+
def welcome
|
119
|
+
text = []
|
120
|
+
text <<
|
121
|
+
"This is a text adventure game inspired by the movie series ".white +
|
122
|
+
"The Originals".light_green
|
123
|
+
text <<
|
124
|
+
"Written by: ".white +
|
125
|
+
"Webster Avosa".light_green
|
126
|
+
text <<
|
127
|
+
"Copyright " + UI_COPYRIGHT +
|
128
|
+
" Webster Avosa, All Rights Reserved.".white
|
129
|
+
text << "Licensed under MIT.".white
|
130
|
+
text <<
|
131
|
+
"Contact me ".white + UI_EMAIL.light_white +
|
132
|
+
" websterb17@gmail.com".white
|
133
|
+
draw_frame({text: text})
|
134
|
+
new_line
|
135
|
+
end
|
136
|
+
|
137
|
+
# Prints a new line. Optinally can print multiple lines.
|
138
|
+
def new_line(times = 1)
|
139
|
+
times.times { print "\n" }
|
140
|
+
end
|
141
|
+
|
142
|
+
# Draw text surrounded in a nice frame
|
143
|
+
def draw_frame(args)
|
144
|
+
# Figure out width automatically
|
145
|
+
text = args[:text]
|
146
|
+
width = get_max_size_from_array(text)
|
147
|
+
draw_top_frame(width)
|
148
|
+
text.each do |t|
|
149
|
+
t_size = get_real_size(t)
|
150
|
+
draw_vert_frame_begin
|
151
|
+
if t.is_a?(Array)
|
152
|
+
t.each { |s| print s }
|
153
|
+
else
|
154
|
+
print t
|
155
|
+
end
|
156
|
+
(width - (t_size + 4)).times { print " " }
|
157
|
+
draw_vert_frame_end
|
158
|
+
new_line
|
159
|
+
end
|
160
|
+
draw_bottom_frame(width)
|
161
|
+
end
|
162
|
+
|
163
|
+
def display_version
|
164
|
+
puts " Version " + MISSIONMISSIONGAME_VERSION.light_white
|
165
|
+
new_line
|
166
|
+
end
|
167
|
+
|
168
|
+
def not_found
|
169
|
+
print "Command not understood. Use the " + "help or h".red +
|
170
|
+
" to see available commands.".light_white
|
171
|
+
new_line
|
172
|
+
end
|
173
|
+
|
174
|
+
def show_location(args)
|
175
|
+
player = args[:player]
|
176
|
+
print "You are currently on row " + player.y.to_s.light_white +
|
177
|
+
", column " + player.x.to_s.light_white
|
178
|
+
new_line
|
179
|
+
print "Use the " + "map".light_white + " command to see the map."
|
180
|
+
new_line
|
181
|
+
end
|
182
|
+
|
183
|
+
def cannot_travel_combat
|
184
|
+
puts "You're in a war with the vampires! Fight for your life to proceed or else your're being feasted on!"
|
185
|
+
end
|
186
|
+
|
187
|
+
def not_in_combat
|
188
|
+
puts "No vampire has attacked you just yet."
|
189
|
+
end
|
190
|
+
|
191
|
+
def quit
|
192
|
+
new_line
|
193
|
+
print "You abandoned your journey to getting answers to all of your many unaswered questions."
|
194
|
+
.red
|
195
|
+
new_line(2)
|
196
|
+
end
|
197
|
+
|
198
|
+
def get_cmd
|
199
|
+
print "Type ".white + "help".light_white + " for possible commands.\n"
|
200
|
+
print "\u2712 ".red + "Your command? ".light_white
|
201
|
+
gets.chomp.downcase
|
202
|
+
end
|
203
|
+
|
204
|
+
def out_of_bounds
|
205
|
+
print "x".red + " Requested move out of bounds."
|
206
|
+
new_line
|
207
|
+
end
|
208
|
+
|
209
|
+
def display_name(args)
|
210
|
+
player = args[:player]
|
211
|
+
print "You are " + player.name.light_white +
|
212
|
+
". Have you forgotten your own name?"
|
213
|
+
new_line
|
214
|
+
end
|
215
|
+
|
216
|
+
def player_dead(args)
|
217
|
+
story = args[:story]
|
218
|
+
new_line
|
219
|
+
text = story.player_dead
|
220
|
+
draw_frame(text: text)
|
221
|
+
new_line
|
222
|
+
end
|
223
|
+
|
224
|
+
def enemy_greet(args)
|
225
|
+
enemy = args[:enemy]
|
226
|
+
print enemy.name.light_white + " attacks!"
|
227
|
+
new_line
|
228
|
+
end
|
229
|
+
|
230
|
+
private
|
231
|
+
|
232
|
+
def draw_vert_frame_begin
|
233
|
+
print UI_FRAME_VERTICAL.yellow + " "
|
234
|
+
end
|
235
|
+
|
236
|
+
def draw_vert_frame_end
|
237
|
+
print " " + UI_FRAME_VERTICAL.yellow
|
238
|
+
end
|
239
|
+
|
240
|
+
def draw_top_frame(width)
|
241
|
+
print UI_FRAME_UPPER_LEFT.yellow
|
242
|
+
(width - 2).times { print UI_FRAME_HORIZONTAL.yellow }
|
243
|
+
print UI_FRAME_UPPER_RIGHT.yellow
|
244
|
+
new_line
|
245
|
+
end
|
246
|
+
|
247
|
+
def draw_bottom_frame(width)
|
248
|
+
print UI_FRAME_LOWER_LEFT.yellow
|
249
|
+
(width - 2).times { print UI_FRAME_HORIZONTAL.yellow }
|
250
|
+
print UI_FRAME_LOWER_RIGHT.yellow
|
251
|
+
new_line
|
252
|
+
end
|
253
|
+
|
254
|
+
# Returns actual length of text accounting for UTF-8 and ANSI
|
255
|
+
def get_real_size(text)
|
256
|
+
text.is_a?(Array) ? text.size : text.uncolorize.size
|
257
|
+
end
|
258
|
+
|
259
|
+
# Returns size of longest string in array
|
260
|
+
def get_max_size_from_array(array)
|
261
|
+
max = 0
|
262
|
+
array.each do |s|
|
263
|
+
s_size = get_real_size(s)
|
264
|
+
max = s_size if s_size >= max
|
265
|
+
end
|
266
|
+
max + 4
|
267
|
+
end
|
268
|
+
end
|
269
|
+
end
|
data/mission_game.rb
CHANGED
@@ -1,43 +1,41 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
#
|
3
|
-
# Written by Webster Avosa
|
4
|
-
|
5
|
-
GAME_VERSION = "1.00"
|
6
|
-
|
7
|
-
begin
|
8
|
-
require
|
9
|
-
require
|
10
|
-
rescue LoadError
|
11
|
-
puts
|
12
|
-
puts "This game requires the 'colorize' and 'pry' gem to run."
|
13
|
-
puts
|
14
|
-
puts "Installation Instructions"
|
15
|
-
puts "-------------------------"
|
16
|
-
puts
|
17
|
-
puts "Debian/Ubuntu Linux:"
|
18
|
-
puts " sudo apt install ruby-colorize && sudo apt install pry"
|
19
|
-
puts
|
20
|
-
puts "Other Linux Distros:"
|
21
|
-
puts " gem install colorize && gem install pry"
|
22
|
-
puts
|
23
|
-
puts "Windows:"
|
24
|
-
puts " gem install colorize && gem install pry"
|
25
|
-
puts
|
26
|
-
puts "macOS:"
|
27
|
-
puts " gem install colorize && gem install pry"
|
28
|
-
puts
|
29
|
-
puts
|
30
|
-
exit
|
31
|
-
end
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
load "lib/
|
37
|
-
load "lib/
|
38
|
-
load "lib/
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
# Start
|
43
|
-
load "lib/main.rb"
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# Written by Webster Avosa
|
4
|
+
|
5
|
+
GAME_VERSION = "1.00"
|
6
|
+
|
7
|
+
begin
|
8
|
+
require "colorize"
|
9
|
+
require "pry"
|
10
|
+
rescue LoadError
|
11
|
+
puts
|
12
|
+
puts "This game requires the 'colorize' and 'pry' gem to run."
|
13
|
+
puts
|
14
|
+
puts "Installation Instructions"
|
15
|
+
puts "-------------------------"
|
16
|
+
puts
|
17
|
+
puts "Debian/Ubuntu Linux:"
|
18
|
+
puts " sudo apt install ruby-colorize && sudo apt install pry"
|
19
|
+
puts
|
20
|
+
puts "Other Linux Distros:"
|
21
|
+
puts " gem install colorize && gem install pry"
|
22
|
+
puts
|
23
|
+
puts "Windows:"
|
24
|
+
puts " gem install colorize && gem install pry"
|
25
|
+
puts
|
26
|
+
puts "macOS:"
|
27
|
+
puts " gem install colorize && gem install pry"
|
28
|
+
puts
|
29
|
+
puts
|
30
|
+
exit
|
31
|
+
end
|
32
|
+
|
33
|
+
# Require libraries
|
34
|
+
load "lib/ui.rb"
|
35
|
+
load "lib/neworleans.rb"
|
36
|
+
load "lib/player.rb"
|
37
|
+
load "lib/story.rb"
|
38
|
+
load "lib/enemy.rb"
|
39
|
+
|
40
|
+
# Start
|
41
|
+
load "lib/main.rb"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mission_game
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Webster Avosa
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-05-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colorize
|
@@ -38,7 +38,7 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
-
description:
|
41
|
+
description:
|
42
42
|
email: websterb17@gmail.com
|
43
43
|
executables:
|
44
44
|
- mission_game
|
@@ -57,7 +57,7 @@ homepage: https://github.com/avosa/mission_game
|
|
57
57
|
licenses:
|
58
58
|
- MIT
|
59
59
|
metadata: {}
|
60
|
-
post_install_message:
|
60
|
+
post_install_message:
|
61
61
|
rdoc_options: []
|
62
62
|
require_paths:
|
63
63
|
- lib
|
@@ -72,8 +72,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
72
72
|
- !ruby/object:Gem::Version
|
73
73
|
version: '0'
|
74
74
|
requirements: []
|
75
|
-
rubygems_version: 3.2.
|
76
|
-
signing_key:
|
75
|
+
rubygems_version: 3.2.3
|
76
|
+
signing_key:
|
77
77
|
specification_version: 4
|
78
78
|
summary: This is an open-source text-based adventure game written in Ruby.
|
79
79
|
test_files: []
|