gemwarrior 0.9.31 → 0.9.32

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d55fe04a8f5043e88e3190a89d1769ab83303ee0
4
- data.tar.gz: 076226766021189d922d10f5775c3ddef13dd283
3
+ metadata.gz: 5ba232be35f794bab630db0215b3eddeec211dad
4
+ data.tar.gz: a6503b7c1899de07423d637c3d1edcb01f1cda27
5
5
  SHA512:
6
- metadata.gz: 91fa430b80846bde16f61f33997cd227c80f436c4efe17ed47398477045f199c0ce47a4e9216cf02fb36fde3a74c52955790561d79a643913c1f69d13f62a4ca
7
- data.tar.gz: 9d71ed1c86feed2ac58a35345bb0c074c19924e1bef42752e53a98b4ecf34cb73649f033990d85fa606f15cbcadbdf7c3e34c5c0312902beeb67a2d01c3fd529
6
+ metadata.gz: 58f92ed5ff17659ff4778173777d13e95b6c148ee86dc04733e0031db6d01efda84b55f4008b3a931c6128f49f5a0578e1cf691880008198ebddd9338717d114
7
+ data.tar.gz: 3eab9d6b0d418c703bdd8ed9c3bff3166681291300c6d37a8682e6093ef221f290217364c57a6653bf28526e0eaee50eae03eb1d1be2bf18789c3caf3ed5c0c9
data/bin/gemwarrior CHANGED
@@ -7,7 +7,7 @@ require_relative '../lib/gemwarrior/version'
7
7
 
8
8
  GAME_NAME = 'Gem Warrior'
9
9
 
10
- def parse_options
10
+ def parse_options_cli
11
11
  options = {
12
12
  :beast_mode => false,
13
13
  :debug_mode => false,
@@ -68,8 +68,34 @@ def print_error(error)
68
68
  end
69
69
  end
70
70
 
71
+ def get_options_file_path
72
+ "#{Dir.home}/.gemwarrior_options"
73
+ end
74
+
75
+ def read_options_file
76
+ options = []
77
+ if File.exist?(get_options_file_path)
78
+ File.open(get_options_file_path).readlines.each do |line|
79
+ options << line.chomp.split(':')
80
+ end
81
+ return options
82
+ end
83
+ nil
84
+ end
85
+
71
86
  begin
72
- options = parse_options
87
+ options = parse_options_cli
88
+
89
+ options_file = read_options_file
90
+
91
+ unless options_file.nil?
92
+ sound_option = options_file[0][1].eql?('false') ? false : true
93
+ wordnik_option = options_file[1][1].eql?('false') ? false : true
94
+
95
+ options[:sound] = sound_option
96
+ options[:use_wordnik] = wordnik_option
97
+ end
98
+
73
99
  Gemwarrior::Game.new(options)
74
100
  rescue => error
75
101
  print_error(error)
@@ -82,8 +82,8 @@ module Gemwarrior
82
82
 
83
83
  def update_options_file(world)
84
84
  File.open(get_options_file_path, 'w') do |f|
85
- f.puts "sound|#{world.sound}"
86
- f.puts "use_wordnik|#{world.use_wordnik}"
85
+ f.puts "sound:#{world.sound}"
86
+ f.puts "use_wordnik:#{world.use_wordnik}"
87
87
  end
88
88
  end
89
89
  end
@@ -7,22 +7,22 @@ module Gemwarrior
7
7
  # if Windows, use superior win32-sound library
8
8
  if OS.windows?
9
9
  require 'win32/sound'
10
- threads = []
11
-
12
- Thread.start {
10
+ require_relative 'musical_notes'
11
+
12
+ Thread.start do
13
13
  sequence.each do |seq|
14
+ threads = []
14
15
  seq[:frequencies].split(',').each do |note|
15
- threads << Thread.new {
16
+ threads << Thread.new do
16
17
  Win32::Sound::play_freq(Notes::NOTE_FREQ[note], seq[:duration], 0.5)
17
- }
18
+ end
18
19
  end
19
20
  threads.each { |th| th.join }
20
21
  end
21
- }
22
+ end
22
23
  # otherwise, use inferior feep library
23
24
  else
24
25
  require 'feep'
25
- require_relative 'musical_notes'
26
26
 
27
27
  feep_defaults = {
28
28
  frequencies: '440',
@@ -32,7 +32,7 @@ module Gemwarrior
32
32
  notext: true
33
33
  }
34
34
 
35
- Thread.start {
35
+ Thread.start do
36
36
  sequence.each do |seq|
37
37
  seq = feep_defaults.merge(seq)
38
38
 
@@ -44,7 +44,7 @@ module Gemwarrior
44
44
  notext: seq[:notext]
45
45
  })
46
46
  end
47
- }
47
+ end
48
48
  end
49
49
  end
50
50
  end
@@ -120,25 +120,14 @@ module Gemwarrior
120
120
  end
121
121
 
122
122
  def print_options
123
- options = read_options_file
124
-
125
123
  puts
126
124
  puts 'Gem Warrior Options'.colorize(:yellow)
127
125
  puts '======================='.colorize(:yellow)
128
- if options.nil?
129
- puts 'No options set yet.'
130
- else
131
- puts 'Toggle whether sound is played, or Wordnik (system must have a working WORDNIK_API_KEY environment variable) is used to generate more dynamic descriptors of entities'
132
- puts
133
- count = 1
134
- options.each do |op|
135
- option = op[0]
136
- value = op[1].eql?('true') ? 'ON' : 'OFF'
137
-
138
- print " #{count} #{option.ljust(12).upcase} : #{value}\n"
139
- count += 1
140
- end
141
- end
126
+ puts 'Toggle whether sound is played, or Wordnik (system must have a working WORDNIK_API_KEY environment variable) is used to generate more dynamic descriptors of entities'
127
+ puts
128
+ puts " (1) SOUND ENABLED: #{world.sound}"
129
+ puts " (2) USE WORDNIK : #{world.use_wordnik}"
130
+ puts
142
131
  puts '======================='
143
132
  puts
144
133
  puts 'Enter option number to toggle value, or any other key to return to main menu.'
@@ -149,12 +138,10 @@ module Gemwarrior
149
138
  when '1'
150
139
  print answer
151
140
  world.sound = !world.sound
152
- game.update_options_file(world)
153
141
  print_options
154
142
  when '2'
155
143
  print answer
156
144
  world.use_wordnik = !world.use_wordnik
157
- game.update_options_file(world)
158
145
  print_options
159
146
  else
160
147
  print answer
@@ -245,23 +232,13 @@ module Gemwarrior
245
232
  when 'e', 'x'
246
233
  puts choice
247
234
  puts MAIN_MENU_QUIT_MESSAGE
248
- exit(0)
235
+ game.update_options_file(world)
236
+ exit
249
237
  else
250
238
  run_main_menu(show_choices = false)
251
239
  end
252
240
  end
253
241
 
254
- def read_options_file
255
- options = []
256
- if File.exists?(game.get_options_file_path)
257
- File.open(game.get_options_file_path).readlines.each do |line|
258
- options << line.chomp.split('|')
259
- end
260
- return options
261
- end
262
- nil
263
- end
264
-
265
242
  def log_stats(duration, pl)
266
243
  puts '######################################################################'
267
244
  print 'Gem Warrior'.colorize(color: :white, background: :black)
@@ -289,8 +266,8 @@ module Gemwarrior
289
266
  def play_intro_tune
290
267
  if world.sound
291
268
  Music::cue([
292
- { frequencies: 'A3,E4,C#5,E5', duration: 300},
293
- { frequencies: 'A3,E4,C#5,F#5', duration: 600}
269
+ { frequencies: 'A3,E4,C#5,E5', duration: 300 },
270
+ { frequencies: 'A3,E4,C#5,F#5', duration: 600 }
294
271
  ])
295
272
  end
296
273
  end
@@ -2,5 +2,5 @@
2
2
  # Version of Gem Warrior
3
3
 
4
4
  module Gemwarrior
5
- VERSION = '0.9.31'
5
+ VERSION = '0.9.32'
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gemwarrior
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.31
4
+ version: 0.9.32
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Chadwick