gemwarrior 0.10.2 → 0.10.4
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 +11 -4
- data/lib/gemwarrior/entities/items/small_hole.rb +1 -1
- data/lib/gemwarrior/entities/items/ware_hawker.rb +1 -1
- data/lib/gemwarrior/entities/location.rb +4 -0
- data/lib/gemwarrior/entities/player.rb +8 -6
- data/lib/gemwarrior/evaluator.rb +6 -5
- data/lib/gemwarrior/game.rb +2 -0
- data/lib/gemwarrior/misc/music.rb +2 -2
- data/lib/gemwarrior/repl.rb +53 -7
- 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: db7b7b4510ab007ccec7bdfc2cae8357f3ae876d
|
4
|
+
data.tar.gz: 9100d13c3f00bfc5df68ca7e4bbdde8edaa85a7c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 803ffeedec0a850cb64c7cd5425952cdc6ce85551477c4d1005ebea92cad829a4608298179965e4d462cf4de384b141156d017442a49d9344ee7e56e7a6ff68b
|
7
|
+
data.tar.gz: b099640251fa7d4c86aaf831d5c8b35c4a278e126ae9593d5c929ad176b7a73fb525adbd9e6ce1696e20219fc9800dcf44d713836b2513809706819edc65d48c
|
data/bin/gemwarrior
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
3
|
require 'optparse'
|
4
|
+
require 'os'
|
4
5
|
|
5
6
|
require_relative '../lib/gemwarrior/game'
|
6
7
|
require_relative '../lib/gemwarrior/game_options'
|
@@ -25,6 +26,7 @@ def parse_options_cli
|
|
25
26
|
new_skip: false,
|
26
27
|
resume_skip: false,
|
27
28
|
sound_enabled: false,
|
29
|
+
sound_system: nil,
|
28
30
|
sound_volume: 0.3,
|
29
31
|
use_wordnik: false,
|
30
32
|
extra_command: nil
|
@@ -34,10 +36,12 @@ def parse_options_cli
|
|
34
36
|
|
35
37
|
unless options_file.nil?
|
36
38
|
sound_enabled_option = options_file[0][1].eql?('false') ? false : true
|
37
|
-
|
38
|
-
|
39
|
-
|
39
|
+
sound_system_selected = options_file[1][1]
|
40
|
+
sound_volume_option = options_file[2][1].to_f
|
41
|
+
use_wordnik_option = options_file[3][1].eql?('false') ? false : true
|
42
|
+
|
40
43
|
options[:sound_enabled] = sound_enabled_option
|
44
|
+
options[:sound_system] = sound_system_selected
|
41
45
|
options[:sound_volume] = sound_volume_option
|
42
46
|
options[:use_wordnik] = use_wordnik_option
|
43
47
|
end
|
@@ -110,7 +114,10 @@ end
|
|
110
114
|
def init_config
|
111
115
|
Dir.mkdir(GW_HOME) unless Dir.exist?(GW_HOME)
|
112
116
|
|
113
|
-
|
117
|
+
sound_system_default = OS.windows? ? 'win32-sound' : 'feep'
|
118
|
+
|
119
|
+
GameOptions.add 'sound_system', sound_system_default
|
120
|
+
GameOptions.add 'save_file_mode', 'Y'
|
114
121
|
GameOptions.add 'default_world_path_yaml', GW_DEFAULT_WORLD_YAML
|
115
122
|
GameOptions.add 'default_world_path_bin', GW_DEFAULT_WORLD_BIN
|
116
123
|
GameOptions.add 'save_file_yaml_path', GW_SAVE_FILE_YAML
|
@@ -102,6 +102,10 @@ module Gemwarrior
|
|
102
102
|
trigger_values = 0..max
|
103
103
|
actual_value = rand(1..100)
|
104
104
|
|
105
|
+
if GameOptions.data['debug_mode']
|
106
|
+
puts "should_spawn_monster? #{trigger_values} : #{actual_value}"
|
107
|
+
end
|
108
|
+
|
105
109
|
if trigger_values.include?(actual_value)
|
106
110
|
found = true
|
107
111
|
end
|
@@ -89,7 +89,7 @@ module Gemwarrior
|
|
89
89
|
self_text << "\n"
|
90
90
|
end
|
91
91
|
|
92
|
-
def rest(world, tent_uses =
|
92
|
+
def rest(world, tent_uses = 0, ensure_fight = false)
|
93
93
|
if ensure_fight
|
94
94
|
battle = Battle.new(world: world, player: self, monster: world.monsters[rand(0..world.monsters.length-1)].clone)
|
95
95
|
result = battle.start(is_arena = false, is_event = true)
|
@@ -99,12 +99,14 @@ module Gemwarrior
|
|
99
99
|
return
|
100
100
|
end
|
101
101
|
end
|
102
|
-
|
102
|
+
|
103
103
|
cur_loc = world.location_by_coords(cur_coords)
|
104
104
|
|
105
105
|
if cur_loc.should_spawn_monster?
|
106
106
|
chance_of_ambush = rand(0..100)
|
107
107
|
|
108
|
+
puts "chance_of_ambush: #{chance_of_ambush}" if GameOptions.data['debug_mode']
|
109
|
+
|
108
110
|
if chance_of_ambush < 25
|
109
111
|
battle = Battle.new(world: world, player: self, monster: cur_loc.monsters_abounding[rand(0..cur_loc.monsters_abounding.length-1)].clone)
|
110
112
|
return battle.start(is_arena = false, is_event = true)
|
@@ -114,13 +116,13 @@ module Gemwarrior
|
|
114
116
|
# stats
|
115
117
|
self.rests_taken += 1
|
116
118
|
|
117
|
-
hours
|
119
|
+
hours = rand(1..23)
|
118
120
|
minutes = rand(1..59)
|
119
121
|
seconds = rand(1..59)
|
120
122
|
|
121
|
-
hours_text = hours
|
122
|
-
mins_text
|
123
|
-
secs_text
|
123
|
+
hours_text = hours == 1 ? 'hour' : 'hours'
|
124
|
+
mins_text = minutes == 1 ? 'minute' : 'minutes'
|
125
|
+
secs_text = seconds == 1 ? 'second' : 'seconds'
|
124
126
|
|
125
127
|
if tent_uses > 0
|
126
128
|
if self.at_full_hp?
|
data/lib/gemwarrior/evaluator.rb
CHANGED
@@ -63,8 +63,8 @@ module Gemwarrior
|
|
63
63
|
'Rest, but ensure battle for testing'
|
64
64
|
]
|
65
65
|
|
66
|
-
self.commands = %w(character inventory rest look take use drop equip unequip go north east south west attack change version help quit quit!)
|
67
|
-
self.aliases = %w(c i r l t u d eq ue g n e s w a ch v h q qq)
|
66
|
+
self.commands = %w(character inventory rest look take use drop equip unequip go north east south west attack change version checkupdate help quit quit!)
|
67
|
+
self.aliases = %w(c i r l t u d eq ue g n e s w a ch v cu h q qq)
|
68
68
|
self.extras = %w(exit exit! x xx fight f ? ?? ???)
|
69
69
|
self.cmd_descriptions = [
|
70
70
|
'Display character information',
|
@@ -84,6 +84,7 @@ module Gemwarrior
|
|
84
84
|
'Attack a monster',
|
85
85
|
'Change something',
|
86
86
|
'Display game version',
|
87
|
+
'Check for newer game releases',
|
87
88
|
'This help menu',
|
88
89
|
'Quit w/ confirmation (also exit/x)',
|
89
90
|
'Quit w/o confirmation (also exit!/xx)'
|
@@ -256,7 +257,7 @@ module Gemwarrior
|
|
256
257
|
when 'levelbump', 'lb'
|
257
258
|
world.player.update_stats(reason: :level_bump, value: 1)
|
258
259
|
when 'restfight', 'rf'
|
259
|
-
result = world.player.rest(world,
|
260
|
+
result = world.player.rest(world, 0, true)
|
260
261
|
|
261
262
|
if result.eql?('death')
|
262
263
|
player_death_resurrection
|
@@ -414,8 +415,6 @@ module Gemwarrior
|
|
414
415
|
world.player.rest(world, result[:data])
|
415
416
|
when 'action'
|
416
417
|
case result[:data]
|
417
|
-
when 'rest'
|
418
|
-
world.player.rest(world)
|
419
418
|
when 'map'
|
420
419
|
world.print_map(world.player.cur_coords[:z])
|
421
420
|
end
|
@@ -523,6 +522,8 @@ module Gemwarrior
|
|
523
522
|
list_commands
|
524
523
|
when 'version', 'v'
|
525
524
|
Gemwarrior::VERSION
|
525
|
+
when 'checkupdate', 'cu'
|
526
|
+
'checkupdate'
|
526
527
|
when 'quit', 'exit', 'q', 'x'
|
527
528
|
print 'You sure you want to quit? (y/n) '
|
528
529
|
response = gets.chomp.downcase
|
data/lib/gemwarrior/game.rb
CHANGED
@@ -29,6 +29,7 @@ module Gemwarrior
|
|
29
29
|
GameOptions.add 'debug_mode', options.fetch(:debug_mode)
|
30
30
|
GameOptions.add 'god_mode', options.fetch(:god_mode)
|
31
31
|
GameOptions.add 'sound_enabled', options.fetch(:sound_enabled)
|
32
|
+
GameOptions.add 'sound_system', options.fetch(:sound_system)
|
32
33
|
GameOptions.add 'sound_volume', options.fetch(:sound_volume)
|
33
34
|
GameOptions.add 'use_wordnik', options.fetch(:use_wordnik)
|
34
35
|
|
@@ -63,6 +64,7 @@ module Gemwarrior
|
|
63
64
|
def update_options_file
|
64
65
|
File.open(GameOptions.data['options_file_path'], 'w') do |f|
|
65
66
|
f.puts "sound_enabled:#{GameOptions.data['sound_enabled']}"
|
67
|
+
f.puts "sound_system:#{GameOptions.data['sound_system']}"
|
66
68
|
f.puts "sound_volume:#{GameOptions.data['sound_volume']}"
|
67
69
|
f.puts "use_wordnik:#{GameOptions.data['use_wordnik']}"
|
68
70
|
end
|
@@ -8,7 +8,7 @@ module Gemwarrior
|
|
8
8
|
def self.cue(sequence)
|
9
9
|
if GameOptions.data['sound_enabled']
|
10
10
|
# if Windows, use superior win32-sound library
|
11
|
-
if
|
11
|
+
if GameOptions.data['sound_system'].eql?('win32-sound')
|
12
12
|
require 'win32/sound'
|
13
13
|
require_relative 'musical_notes'
|
14
14
|
|
@@ -24,7 +24,7 @@ module Gemwarrior
|
|
24
24
|
end
|
25
25
|
end
|
26
26
|
# otherwise, use inferior feep library
|
27
|
-
|
27
|
+
elsif GameOptions.data['sound_system'].eql?('feep')
|
28
28
|
require 'feep'
|
29
29
|
|
30
30
|
feep_defaults = {
|
data/lib/gemwarrior/repl.rb
CHANGED
@@ -52,6 +52,8 @@ module Gemwarrior
|
|
52
52
|
result = evaluator.evaluate(input)
|
53
53
|
if result.eql?('exit')
|
54
54
|
exit
|
55
|
+
elsif result.eql?('checkupdate')
|
56
|
+
check_for_new_release
|
55
57
|
else
|
56
58
|
puts result
|
57
59
|
end
|
@@ -123,16 +125,18 @@ module Gemwarrior
|
|
123
125
|
puts
|
124
126
|
puts 'Gem Warrior Options'.colorize(:yellow)
|
125
127
|
puts '======================='.colorize(:yellow)
|
126
|
-
puts '
|
128
|
+
puts 'Change whether sound is played, which sound system to use, what game volume is, or whether Wordnik is used to generate more dynamic descriptors of entities (valid WORDNIK_API_KEY environment variable must be set)'
|
127
129
|
puts
|
128
130
|
puts " (1) SOUND ENABLED : #{GameOptions.data['sound_enabled']}"
|
129
|
-
puts " (2) SOUND
|
130
|
-
puts " (3)
|
131
|
+
puts " (2) SOUND SYSTEM : #{GameOptions.data['sound_system']}"
|
132
|
+
puts " (3) SOUND VOLUME : #{GameOptions.data['sound_volume']}"
|
133
|
+
puts " (4) USE WORDNIK : #{GameOptions.data['use_wordnik']}"
|
131
134
|
puts
|
132
135
|
puts '======================='
|
133
136
|
puts
|
134
137
|
puts 'Enter option number to change value, or any other key to return to main menu.'
|
135
|
-
print '
|
138
|
+
print '[GAME_OPTIONS]> '
|
139
|
+
|
136
140
|
answer = STDIN.getch
|
137
141
|
|
138
142
|
case answer
|
@@ -141,6 +145,11 @@ module Gemwarrior
|
|
141
145
|
GameOptions.data['sound_enabled'] = !GameOptions.data['sound_enabled']
|
142
146
|
print_options
|
143
147
|
when '2'
|
148
|
+
print answer
|
149
|
+
print "\n"
|
150
|
+
print_sound_system_selection
|
151
|
+
print_options
|
152
|
+
when '3'
|
144
153
|
print answer
|
145
154
|
print "\n"
|
146
155
|
print 'Enter a volume from 0.0 to 1.0: '
|
@@ -151,7 +160,7 @@ module Gemwarrior
|
|
151
160
|
puts 'Not a valid volume.'
|
152
161
|
end
|
153
162
|
print_options
|
154
|
-
when '
|
163
|
+
when '4'
|
155
164
|
print answer
|
156
165
|
GameOptions.data['use_wordnik']= !GameOptions.data['use_wordnik']
|
157
166
|
print_options
|
@@ -161,6 +170,36 @@ module Gemwarrior
|
|
161
170
|
end
|
162
171
|
end
|
163
172
|
|
173
|
+
def print_sound_system_selection
|
174
|
+
puts
|
175
|
+
puts 'Sound System Selection'.colorize(:yellow)
|
176
|
+
puts '========================'.colorize(:yellow)
|
177
|
+
puts
|
178
|
+
print ' (1) WIN32-SOUND '
|
179
|
+
print '(SELECTED)'.colorize(:yellow) if GameOptions.data['sound_system'].eql?('win32-sound')
|
180
|
+
print "\n"
|
181
|
+
print ' (2) FEEP '
|
182
|
+
print '(SELECTED)'.colorize(:yellow) if GameOptions.data['sound_system'].eql?('feep')
|
183
|
+
print "\n"
|
184
|
+
puts
|
185
|
+
puts 'Enter option number to select sound system, or any other key to exit.'
|
186
|
+
puts 'Note: win32-sound only works on Windows and will break the game is sound is enabled on non-Windows machines. Feep is cross-platform, but very slow and buggy, so use at your discretion!'
|
187
|
+
puts
|
188
|
+
print '[SOUND_SYSTEM]> '
|
189
|
+
answer = STDIN.getch.chomp.downcase
|
190
|
+
|
191
|
+
case answer
|
192
|
+
when '1'
|
193
|
+
GameOptions.add 'sound_system', 'win32-sound'
|
194
|
+
print_sound_system_selection
|
195
|
+
when '2'
|
196
|
+
GameOptions.add 'sound_system', 'feep'
|
197
|
+
print_sound_system_selection
|
198
|
+
else
|
199
|
+
return
|
200
|
+
end
|
201
|
+
end
|
202
|
+
|
164
203
|
def display_log_of_attempts
|
165
204
|
if File.exist?(GameOptions.data['log_file_path']) and !File.zero?(GameOptions.data['log_file_path'])
|
166
205
|
File.open(GameOptions.data['log_file_path']).readlines.each do |line|
|
@@ -184,12 +223,19 @@ module Gemwarrior
|
|
184
223
|
end
|
185
224
|
|
186
225
|
def check_for_new_release
|
226
|
+
new_release_available = false
|
187
227
|
puts 'Checking releases...'
|
188
228
|
remote_release = Gems.versions('gemwarrior').first['number']
|
189
229
|
local_release = Gemwarrior::VERSION
|
190
230
|
|
191
|
-
|
192
|
-
|
231
|
+
0.upto(2) do |i|
|
232
|
+
if remote_release.split('.')[i].to_i > local_release.split('.')[i].to_i
|
233
|
+
new_release_available = true
|
234
|
+
end
|
235
|
+
end
|
236
|
+
|
237
|
+
if new_release_available
|
238
|
+
puts "GW v#{remote_release} available! Please exit and run 'gem update' before continuing."
|
193
239
|
puts
|
194
240
|
else
|
195
241
|
puts 'You have the latest version. Fantastic!'
|
data/lib/gemwarrior/version.rb
CHANGED