gemwarrior 0.9.31 → 0.9.32
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.
- checksums.yaml +4 -4
- data/bin/gemwarrior +28 -2
- data/lib/gemwarrior/game.rb +2 -2
- data/lib/gemwarrior/misc/music.rb +9 -9
- data/lib/gemwarrior/repl.rb +9 -32
- data/lib/gemwarrior/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5ba232be35f794bab630db0215b3eddeec211dad
|
4
|
+
data.tar.gz: a6503b7c1899de07423d637c3d1edcb01f1cda27
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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 =
|
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)
|
data/lib/gemwarrior/game.rb
CHANGED
@@ -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
|
86
|
-
f.puts "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
|
-
|
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
|
data/lib/gemwarrior/repl.rb
CHANGED
@@ -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
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
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
|
-
|
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
|
data/lib/gemwarrior/version.rb
CHANGED