gemwarrior 0.15.5 → 0.15.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,7 +6,9 @@ require 'os'
6
6
  require 'clocker'
7
7
  require 'io/console'
8
8
  require 'gems'
9
+ require 'ap'
9
10
 
11
+ require_relative 'misc/audio'
10
12
  require_relative 'misc/timer'
11
13
  require_relative 'misc/wordlist'
12
14
  require_relative 'evaluator'
@@ -23,6 +25,7 @@ module Gemwarrior
23
25
  SPLASH_MESSAGE = 'Welcome to *Jool*, where randomized fortune is just as likely as mayhem.'
24
26
  GITHUB_NAME = 'michaelchadwick'
25
27
  GITHUB_PROJECT = 'gemwarrior'
28
+ ERROR_SOUND_NOT_ENABLED = 'Sound is disabled! Enter \'x\' to exit'
26
29
 
27
30
  attr_accessor :game, :world, :evaluator
28
31
 
@@ -58,7 +61,7 @@ module Gemwarrior
58
61
  return [screen_width, SCREEN_WIDTH_MAX].min
59
62
  end
60
63
  end
61
-
64
+
62
65
  def start(initial_command, extra_command, new_skip, resume_skip)
63
66
  setup_screen(initial_command, extra_command, new_skip, resume_skip)
64
67
 
@@ -114,6 +117,14 @@ module Gemwarrior
114
117
  Readline.readline(prompt_text, true).to_s
115
118
  end
116
119
 
120
+ def get_save_file_name
121
+ if save_file_exist?
122
+ File.open(GameOptions.data['save_file_yaml_path'], 'r') do |f|
123
+ return YAML.load(f)
124
+ end
125
+ end
126
+ end
127
+
117
128
  def puts(s = '', width = GameOptions.data['wrap_width'])
118
129
  super s.gsub(/(.{1,#{width}})(\s+|\Z)/, "\\1\n") unless s.nil?
119
130
  end
@@ -138,14 +149,14 @@ module Gemwarrior
138
149
  noun2_values = WordList.new('noun-plural')
139
150
  noun3_values = WordList.new('noun-plural')
140
151
 
141
- puts "* Remember: #{noun1_values.get_random_value} and #{noun2_values.get_random_value} are the key to #{noun3_values.get_random_value} *\n\n"
152
+ puts "* Remember: #{noun1_values.get_random_value.colorize(:yellow)} and #{noun2_values.get_random_value.colorize(:yellow)} are the key to #{noun3_values.get_random_value.colorize(:yellow)} *\n\n"
142
153
  puts
143
154
  end
144
155
 
145
156
  def print_about_text
146
157
  puts 'Gem Warrior - A Game of Fortune and Mayhem'.colorize(:yellow)
147
158
  puts '=========================================='.colorize(:yellow)
148
- puts 'Gem Warrior is a text adventure roguelike-lite as a RubyGem created by Michael Chadwick (mike@codana.me) and released as open-source on Github. Take on the task set by Queen Ruby to defeat the evil Emerald and get back the ShinyThing(tm) he stole for terrible, dastardly reasons.'
159
+ puts 'Gem Warrior is a text adventure roguelike-lite as a RubyGem created by Michael Chadwick (mike@neb.host) and released as open-source on Github. Take on the task set by Queen Ruby to defeat the evil Emerald and get back the ShinyThing(tm) he stole for terrible, dastardly reasons.'
149
160
  puts
150
161
  puts 'Explore the land of Jool with the power of text, fighting enemies to improve your station, grabbing curious items that may or may not come in handy, and finally defeating Mr. Emerald himself to win the game.'
151
162
  end
@@ -209,7 +220,8 @@ module Gemwarrior
209
220
  puts 'Sound System Selection'.colorize(:yellow)
210
221
  puts '================================='.colorize(:yellow)
211
222
  puts
212
- print ' (1) WIN32-SOUND '
223
+ win32 = ' (1) WIN32-SOUND '
224
+ OS.windows? ? (print win32) : (print win32.colorize(:light_black))
213
225
  print '(SELECTED)'.colorize(:yellow) if GameOptions.data['sound_system'].eql?('win32-sound')
214
226
  print "\n"
215
227
  print ' (2) FEEP '
@@ -218,6 +230,9 @@ module Gemwarrior
218
230
  print ' (3) BLOOPS '
219
231
  print '(SELECTED)'.colorize(:yellow) if GameOptions.data['sound_system'].eql?('bloops')
220
232
  print "\n"
233
+ print "\n"
234
+ print ' (T) TEST SOUND '
235
+ print "\n"
221
236
  puts
222
237
  puts ' WIN32-SOUND : good quality; Windows-only'
223
238
  puts ' FEEP : cross-platform; VERY SLOW and BUGGY'
@@ -232,19 +247,34 @@ module Gemwarrior
232
247
  puts 'Enter option number to select sound system, or any other key to exit.'
233
248
  puts
234
249
  print '[GW_OPTS]-[SOUND_SYSTEM]> '
250
+
235
251
  answer = STDIN.getch.chomp.downcase
236
252
 
237
253
  case answer
238
254
  when '1'
239
- GameOptions.add 'sound_system', 'win32-sound'
255
+ if OS.windows?
256
+ puts answer
257
+ GameOptions.add 'sound_system', 'win32-sound'
258
+ else
259
+ puts
260
+ end
240
261
  print_options_sound_sytem
241
262
  when '2'
263
+ puts answer
242
264
  GameOptions.add 'sound_system', 'feep'
243
265
  print_options_sound_sytem
244
266
  when '3'
267
+ puts answer
245
268
  GameOptions.add 'sound_system', 'bloops'
246
269
  print_options_sound_sytem
270
+ when 't'
271
+ puts answer
272
+ Audio.init
273
+ play_test_tune
274
+ print_errors
275
+ print_options_sound_sytem
247
276
  else
277
+ puts
248
278
  return
249
279
  end
250
280
  end
@@ -305,16 +335,62 @@ module Gemwarrior
305
335
  end
306
336
  end
307
337
 
338
+ def print_sound_test
339
+ puts
340
+ puts 'Gem Warrior Sound Test'.colorize(:yellow)
341
+ puts '================================='.colorize(:yellow)
342
+
343
+ if GameOptions.data['sound_enabled']
344
+ puts
345
+ puts 'Play all the sounds in Gemwarrior.'
346
+ puts
347
+
348
+ cues = Audio.get_cues
349
+ for cue in cues do
350
+ pp cue[0].to_s
351
+ end
352
+
353
+ puts
354
+ puts '================================='.colorize(:yellow)
355
+ puts
356
+ puts 'Enter sound id to play it, or enter "x" to return to the main menu.'
357
+ else
358
+ GameOptions.data['errors'] = ERROR_SOUND_NOT_ENABLED
359
+ end
360
+
361
+ print_errors
362
+
363
+ puts
364
+ print '[GW_SOUND_TEST]> '
365
+
366
+ answer = gets.chomp.downcase
367
+
368
+ # print answer
369
+ if answer.eql?('x')
370
+ return
371
+ else
372
+ Audio.play_synth(answer.to_sym)
373
+ print_sound_test
374
+ end
375
+ end
376
+
308
377
  def print_main_menu
309
378
  puts
310
379
  puts " GW v#{Gemwarrior::VERSION}"
311
380
  puts '======================='
312
- puts ' (R)esume Game'.colorize(:green) if save_file_exist?
381
+
382
+ save_file = get_save_file_name
383
+ if not save_file.nil?
384
+ recent_name = save_file.instance_variable_get(:@player).name
385
+ puts " #{'(R)esume Game'.colorize(:green)} as #{recent_name.colorize(:yellow)}"
386
+ end
387
+
313
388
  puts ' (N)ew Game'
314
389
  puts ' (A)bout'
315
390
  puts ' (H)elp'
316
391
  puts ' (O)ptions'
317
392
  puts ' (L)og of Attempts'
393
+ puts ' (S)ound Test'
318
394
  puts ' (C)heck for Updates'
319
395
  puts ' (E)xit'.colorize(:red)
320
396
  puts '======================='
@@ -349,6 +425,7 @@ module Gemwarrior
349
425
  run_main_menu
350
426
  else
351
427
  print_errors
428
+ play_resume_tune
352
429
  load_saved_world(result)
353
430
  return
354
431
  end
@@ -369,6 +446,10 @@ module Gemwarrior
369
446
  puts choice
370
447
  display_log_of_attempts
371
448
  run_main_menu
449
+ when 's'
450
+ puts choice
451
+ print_sound_test
452
+ run_main_menu
372
453
  when 'c'
373
454
  puts choice
374
455
  check_for_new_release
@@ -378,31 +459,52 @@ module Gemwarrior
378
459
  puts MAIN_MENU_QUIT_MESSAGE
379
460
  game.update_options_file
380
461
  exit
381
- else
382
- run_main_menu(show_choices: false)
462
+ when "\c?" # Backspace/Delete
463
+ refresh_menu
464
+ when "\e" # ANSI escape sequence
465
+ case STDIN.getch
466
+ when '[' # CSI
467
+ choice = STDIN.getch
468
+ puts choice
469
+ case choice
470
+ when 'A', 'B', 'C', 'D' # arrow keys
471
+ refresh_menu
472
+ end
473
+ end
474
+ else # All other invalid options
475
+ refresh_menu
383
476
  end
384
477
  end
385
478
 
479
+ # need this to handle any non-valid input at the main menu
480
+ def refresh_menu
481
+ clear_screen
482
+ print_logo
483
+ run_main_menu
484
+ end
485
+
386
486
  def log_stats(duration, pl)
387
487
  # display stats upon exit
388
488
  Hr.print('#')
389
489
  print 'Gem Warrior'.colorize(color: :white, background: :black)
390
490
  print " v#{Gemwarrior::VERSION}".colorize(:yellow)
391
- print " played for #{duration[:mins].to_s.colorize(color: :white, background: :black)} min(s),"
392
- print " #{duration[:secs].to_s.colorize(color: :white, background: :black)} sec(s),"
393
- print " and #{duration[:ms].to_s.colorize(color: :white, background: :black)} ms\n"
491
+ print " played for #{duration[:mins].to_s.colorize(color: :white, background: :black)} min(s)"
492
+ print ", #{duration[:secs].to_s.colorize(color: :white, background: :black)} sec(s)"
493
+ # print ", and #{duration[:ms].to_s.colorize(color: :white, background: :black)} ms"
494
+ print "\n"
394
495
  Hr.print('-')
395
- print "#{pl.name.ljust(10)} killed #{pl.monsters_killed.to_s.colorize(color: :yellow, background: :black)} monster(s)"
496
+ print "#{pl.name.ljust(10).colorize(:green)} "
497
+ print "destroyed #{pl.monsters_killed.to_s.colorize(color: :yellow, background: :black)} monster(s)"
396
498
  print "\n".ljust(12)
397
- print "killed #{pl.bosses_killed.to_s.colorize(color: :yellow, background: :black)} boss(es)"
499
+ print "destroyed #{pl.bosses_killed.to_s.colorize(color: :yellow, background: :black)} boss(es)"
398
500
  print "\n".ljust(12)
399
501
  print "picked up #{pl.items_taken.to_s.colorize(color: :yellow, background: :black)} item(s)"
400
502
  print "\n".ljust(12)
401
- print "traveled #{pl.movements_made.to_s.colorize(color: :yellow, background: :black)} time(s)"
503
+ print "traveled #{pl.movements_made.to_s.colorize(color: :yellow, background: :black)} time(s)"
402
504
  print "\n".ljust(12)
403
- print "rested #{pl.rests_taken.to_s.colorize(color: :yellow, background: :black)} time(s)"
505
+ print "rested #{pl.rests_taken.to_s.colorize(color: :yellow, background: :black)} time(s)"
404
506
  print "\n".ljust(12)
405
- print "died #{pl.deaths.to_s.colorize(color: :yellow, background: :black)} time(s)"
507
+ print "died #{pl.deaths.to_s.colorize(color: :yellow, background: :black)} time(s)"
406
508
  print "\n"
407
509
  Hr.print('#')
408
510
 
@@ -549,7 +651,9 @@ module Gemwarrior
549
651
 
550
652
  def print_errors
551
653
  if GameOptions.data['errors']
552
- puts GameOptions.data['errors'].colorize(:red)
654
+ puts "\n\n"
655
+ puts "Errors: #{GameOptions.data['errors'].colorize(:red)}"
656
+ GameOptions.data['errors'] = nil
553
657
  end
554
658
  end
555
659
 
@@ -557,6 +661,14 @@ module Gemwarrior
557
661
  Audio.play_synth(:intro)
558
662
  end
559
663
 
664
+ def play_resume_tune
665
+ Audio.play_synth(:resume_game)
666
+ end
667
+
668
+ def play_test_tune
669
+ Audio.play_synth(:test)
670
+ end
671
+
560
672
  def prompt
561
673
  prompt_template = "\n"
562
674
  prompt_template += "[LV:%2s][XP:%3s][ROX:%3s][HP:%3s/%-3s] [".colorize(:yellow)
@@ -565,6 +677,8 @@ module Gemwarrior
565
677
  prompt_template += "%s".colorize(:cyan)
566
678
  prompt_template += "]".colorize(:yellow)
567
679
  prompt_template += "[%s, %s, %s]".colorize(:yellow) if GameOptions.data['debug_mode']
680
+ prompt_template += "\n"
681
+ prompt_template += '[c:character][i:inventory][l:look][u:use][t:take]'
568
682
 
569
683
  prompt_vars_arr = [
570
684
  world.player.level,
@@ -2,5 +2,5 @@
2
2
  # Version of Gem Warrior
3
3
 
4
4
  module Gemwarrior
5
- VERSION = '0.15.5'
5
+ VERSION = '0.15.10'
6
6
  end
@@ -1,2 +1,2 @@
1
- name:mike
2
- age:34
1
+ name:mike
2
+ age:34
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gemwarrior
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.15.5
4
+ version: 0.15.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Chadwick
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-07-17 00:00:00.000000000 Z
11
+ date: 2020-09-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: os
@@ -50,42 +50,42 @@ dependencies:
50
50
  requirements:
51
51
  - - "~>"
52
52
  - !ruby/object:Gem::Version
53
- version: 1.8.2
53
+ version: 2.3.0
54
54
  type: :runtime
55
55
  prerelease: false
56
56
  version_requirements: !ruby/object:Gem::Requirement
57
57
  requirements:
58
58
  - - "~>"
59
59
  - !ruby/object:Gem::Version
60
- version: 1.8.2
60
+ version: 2.3.0
61
61
  - !ruby/object:Gem::Dependency
62
62
  name: colorize
63
63
  requirement: !ruby/object:Gem::Requirement
64
64
  requirements:
65
65
  - - "~>"
66
66
  - !ruby/object:Gem::Version
67
- version: 0.7.7
67
+ version: '0.8'
68
68
  type: :runtime
69
69
  prerelease: false
70
70
  version_requirements: !ruby/object:Gem::Requirement
71
71
  requirements:
72
72
  - - "~>"
73
73
  - !ruby/object:Gem::Version
74
- version: 0.7.7
74
+ version: '0.8'
75
75
  - !ruby/object:Gem::Dependency
76
76
  name: matrext
77
77
  requirement: !ruby/object:Gem::Requirement
78
78
  requirements:
79
79
  - - "~>"
80
80
  - !ruby/object:Gem::Version
81
- version: 0.4.10
81
+ version: '1'
82
82
  type: :runtime
83
83
  prerelease: false
84
84
  version_requirements: !ruby/object:Gem::Requirement
85
85
  requirements:
86
86
  - - "~>"
87
87
  - !ruby/object:Gem::Version
88
- version: 0.4.10
88
+ version: '1'
89
89
  - !ruby/object:Gem::Dependency
90
90
  name: clocker
91
91
  requirement: !ruby/object:Gem::Requirement
@@ -226,6 +226,20 @@ dependencies:
226
226
  - - "~>"
227
227
  - !ruby/object:Gem::Version
228
228
  version: '3.9'
229
+ - !ruby/object:Gem::Dependency
230
+ name: awesome_print
231
+ requirement: !ruby/object:Gem::Requirement
232
+ requirements:
233
+ - - "~>"
234
+ - !ruby/object:Gem::Version
235
+ version: '1.8'
236
+ type: :development
237
+ prerelease: false
238
+ version_requirements: !ruby/object:Gem::Requirement
239
+ requirements:
240
+ - - "~>"
241
+ - !ruby/object:Gem::Version
242
+ version: '1.8'
229
243
  description: A fun text adventure in the form of a RubyGem!
230
244
  email: mike@codana.me
231
245
  executables: