Class: GamesAndRpgParadise::DnD::DeckOfManyThings
- Inherits:
-
Base
- Object
- Base
- GamesAndRpgParadise::DnD::DeckOfManyThings
show all
- Defined in:
- lib/games_and_rpg_paradise/rpg/dnd/items/deck_of_many_things.rb
Overview
GamesAndRpgParadise::DnD::DeckOfManyThings
Constant Summary
collapse
- NAMESPACE =
inspect
- ARRAY_AVAILABLE_CHOICES_FOR_THE_FIRST_DRAW =
#
ARRAY_AVAILABLE_CHOICES_FOR_THE_FIRST_DRAW
#
%i(
bad_donjon
bad_ruin
good_flames
good_euryale
good_gem
good_jester
)
Base::Extensions::Colours::ARRAY_AVAILABLE_KONSOLE_COLOURS
CommonExtensions::CONTROL_C_CODE, CommonExtensions::N
Class Method Summary
collapse
-
.[](i = '') ⇒ Object
# === GamesAndRpgParadise::DnD::DeckOfManyThings[] ========================================================================= #.
Instance Method Summary
collapse
ecomment, #efancy, #eparse, #forestgreen, #gold, #grey, #lightblue, #mediumseagreen, #mediumslateblue, #peru, #rev, sdir, sfancy, #sfile, simp, #teal, #yellow
#commandline_arguments?, #filter_away_commandline_arguments, #first_argument?, #first_non_hyphened_argument?, #set_commandline_arguments
#cat, #cd, #cliner, #copy_file, #delete, #dirname_but_retains_the_trailing_slash, #disable_colours, #ensure_that_the_log_directory_exists, #esystem, #get_user_input, #infer_the_namespace, #is_on_roebe?, #log_dir?, #mkdir, #mkdir_then_cd_into_it, #mv, #namespace?, #opne, #opnn, #project_base_directory?, #project_image_directory?, #project_yaml_directory?, #rds, #register_sigint, #remove_this_directory, #rename_file, #reset_the_internal_hash, #return_pwd, #return_today, #touch_file, #wrap, #write_what_into
Constructor Details
#initialize(commandline_arguments = ARGV, run_already = true, &block) ⇒ DeckOfManyThings
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
|
# File 'lib/games_and_rpg_paradise/rpg/dnd/items/deck_of_many_things.rb', line 45
def initialize(
commandline_arguments = ARGV,
run_already = true,
&block
)
reset
set_commandline_arguments(
commandline_arguments
)
case run_already
when :do_not_run_yet
run_already = false
end
if block_given?
yielded = yield
case yielded
when :disable_colours
disable_colours
end
end
run if run_already
end
|
Class Method Details
.[](i = '') ⇒ Object
#
GamesAndRpgParadise::DnD::DeckOfManyThings[]
#
390
391
392
|
# File 'lib/games_and_rpg_paradise/rpg/dnd/items/deck_of_many_things.rb', line 390
def self.[](i = '')
new(i)
end
|
Instance Method Details
#first_draw ⇒ Object
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
|
# File 'lib/games_and_rpg_paradise/rpg/dnd/items/deck_of_many_things.rb', line 103
def first_draw
@array_available_choices_for_the_first_draw.shuffle!
@sample = @array_available_choices_for_the_first_draw.shift
@array_choices_made << @sample
case @sample
when :bad_donjon,
:donjon
@result << y('DONJON:')+wrap(' User Imprisonment, save vs. '\
'death at +8 penalty neg. Abjuration spell.')
when :bad_ruin, :ruin
@result << y('RUIN:')+' Lose all gold. Evocation spell.'
when :good_flames, :flames
@result << y('FLAMES:')+wrap(' Summons hostile creatures, '\
'one Balor and four Fire Elemental')
when :good_euryale, :euryale
@result << y('EURYALE:')+wrap(' User suffers a permanent +1 penalty to all '\
'saving throws, no save, no dispel, not curable. Evocation spell.')
when :good_gem, :gem
@result << y('GEM:')+wrap(" One rogue stone, king's tear, star sapphire, "\
"emerald and diamond added to inventory. Evocation spell.")
when :good_jester,
:jester
@result << y('JESTER:')+' User receives 50,000 XP. Evocation spell.'
end
return @result
end
|
#have_bad_cards_been_drawn_so_far? ⇒ Boolean
#
have_bad_cards_been_drawn_so_far?
#
253
254
255
256
257
258
259
260
261
262
|
# File 'lib/games_and_rpg_paradise/rpg/dnd/items/deck_of_many_things.rb', line 253
def have_bad_cards_been_drawn_so_far?
result = false
if @array_choices_made.first.to_s.include? 'bad_'
result = true
end
if %i( void magician).include? @array_choices_made[1]
result = true
end
return result
end
|
#reset ⇒ Object
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
# File 'lib/games_and_rpg_paradise/rpg/dnd/items/deck_of_many_things.rb', line 77
def reset
super()
@namespace = NAMESPACE
@array_available_choices_for_the_first_draw =
ARRAY_AVAILABLE_CHOICES_FOR_THE_FIRST_DRAW
@array_choices_made = []
@result = ''.dup
end
|
#result? ⇒ Boolean
373
374
375
|
# File 'lib/games_and_rpg_paradise/rpg/dnd/items/deck_of_many_things.rb', line 373
def result?
@result
end
|
#run ⇒ Object
380
381
382
383
384
385
|
# File 'lib/games_and_rpg_paradise/rpg/dnd/items/deck_of_many_things.rb', line 380
def run
first_draw
e @result second_draw
third_draw
end
|
#second_draw ⇒ Object
#
second_draw
The second draw depends on the first draw’s result.
#
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
203
204
205
206
207
208
209
210
211
212
213
214
215
216
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
246
247
248
|
# File 'lib/games_and_rpg_paradise/rpg/dnd/items/deck_of_many_things.rb', line 160
def second_draw
if was_it_a_good_draw?
possibilities = %i( VOID MAGICIAN KNIGHT ROGUE SUN VIZIER ) @sample = possibilities.shuffle.shift
case @sample
when :VOID e y(@sample.to_s+':')+wrap(" User Disintegrate, save vs. death "\
"at +8 penalty neg. Alteration spell.")
when :MAGICIAN e y(@sample.to_s+':')+wrap(" User turned into a rabbit no save, "\
"dispelable. Alteration spell.")
when :KNIGHT
e y(@sample.to_s+':')+" Summons four hostile Demon Knights."
when :ROGUE
e y(@sample.to_s+':')+wrap(" User gets dire-charmed for 500 "\
"in-game days, no save, no dispel, kill and revive "\
"the user to cure. Enchantment spell.")
when :SUN
e y(@sample.to_s+':')+" Party receives 300,000 XP."
when :VIZIER
e y(@sample.to_s+':')+wrap(" User gets Mantle for "\
"24 in-game hours. Abjuration spell.")
end
else possibilities = %i( KEY STAR ROGUE SUN VIZIER VOID )
@sample = possibilities.shuffle.shift
case @sample
when :KEY
e y('KEY:')+wrap(" The Warder's Signet added to inventory. "\
"Evocation spell.")
when :STAR
e y('STAR:')+wrap(" User gets dex +1 if has thief or bard class, "\
"if not, gets int +1 if has mage class, if not, gets wis +1 "\
"if has cleric or druid or shaman class, if not, gets str +1.")
when :ROGUE
e y('ROGUE:')+wrap(" User gets dire-charmed for 500 in-game days, "\
"no save, no dispel, kill and revive the user to cure. "\
"Enchantment spell.")
when :SUN
e y('SUN:')+" Party receives 300,000 XP. Evocation spell."
when :VIZIER
e y('VIZIER:')+" User gets Mantle for 24 in-game "\
"hours. Abjuration spell."
when :VOID
e y('VOID:')+' User Disintegrate, save vs. death at +8 penalty '\
'neg. Alteration spell.'
end
end
@array_choices_made << @sample.downcase.to_sym end
|
#third_draw ⇒ Object
#
third_draw (third tag)
#
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
|
# File 'lib/games_and_rpg_paradise/rpg/dnd/items/deck_of_many_things.rb', line 267
def third_draw
if have_bad_cards_been_drawn_so_far?
possibilities = %i( SKULL THRONE MOON FOOL COMET ERINYES )
@sample = possibilities.shuffle.shift
@array_choices_made << @sample.downcase.to_sym case @sample
when :SKULL
e y(@sample.to_s+':')+wrap(" Summons hostile Death Shade, "\
"tries to kill the user, disappears once the user is dead")
when :THRONE
e y(@sample.to_s+':')+wrap(" Party receives 1,000,000 XP.")
when :MOON
e y(@sample.to_s+':')+wrap(" User gets +10 Hit "\
"Points permanently. Necromancy spell.")
when :FOOL
e y(@sample.to_s+':')+wrap(" User wisdom set to 3, no "\
"save, Remove Curse to cure; User confusion for 1 "\
"turn, no save, dispelable, Remove Curse to cure. "\
"Necromancy spell.")
when :COMET
e y(@sample.to_s+':')+wrap(" User gains +5% fire resistance "\
"permanently. Evocation spell.")
when :ERINYES
e y(@sample.to_s+':')+wrap(" User gets all Ability Scores +1 "\
"for 24 in-game hours, no dispel. Evocation spell.")
end
else possibilities = %i( SKULL MOON TALONS FOOL COMET ERINYES )
@sample = possibilities.shuffle.shift
@array_choices_made << @sample.downcase.to_sym case @sample
when :SKULL
e y(@sample.to_s+':')+wrap(" Summons hostile Death Shade, "\
"tries to kill the user, disappears once the user is dead.")
when :MOON
e y(@sample.to_s+':')+wrap(" User gets +10 Hit Points "\
"permanently. Necromancy spell.")
when :TALONS
e y(@sample.to_s+':')+wrap(" User blinded, no save, "\
"Remove Curse to cure. Conjuration spell.")
when :FOOL
e y(@sample.to_s+':')+wrap(" User wisdom set to 3, no "\
"save, Remove Curse to cure; User confusion for 1 "\
"turn, no save, dispelable, Remove Curse to cure. "\
"Necromancy spell.")
when :COMET
e y(@sample.to_s+':')+wrap(" User gains +5% fire "\
"resistance permanently. Evocation spell.")
when :ERINYES
e y(@sample.to_s+':')+wrap(" User gets all Ability "\
"Scores +1 for 24 in-game hours, no dispel. "\
"Evocation spell.")
end
end
end
|
#was_it_a_good_draw? ⇒ Boolean
151
152
153
|
# File 'lib/games_and_rpg_paradise/rpg/dnd/items/deck_of_many_things.rb', line 151
def was_it_a_good_draw?
@sample.to_s.start_with? 'good'
end
|
#y(i) ⇒ Object
365
366
367
368
|
# File 'lib/games_and_rpg_paradise/rpg/dnd/items/deck_of_many_things.rb', line 365
def y(i)
return ::Colours.yellow(i) if @use_colours
return i
end
|