gemwarrior 0.9.22 → 0.9.23

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: b597259ded305d57bc41028e2129e454140255ba
4
- data.tar.gz: 44653fe9f3c4f48c62d1fb93a8c872375539da68
3
+ metadata.gz: f98fe21d4e8bc60fc35a70412c557c61c3b58a2c
4
+ data.tar.gz: 8f1c02ecc713082b4049b01add40eb2d5209cc80
5
5
  SHA512:
6
- metadata.gz: 335f48a60bfd59529f6aa07f3ddc1c8b014add206f872b7664ed092bda7f66de7d6e5e4e62d6638699f50270205a9a0c4650174c95cc6a060290db5f030015ba
7
- data.tar.gz: 6c1a36f12a20ee9c6af50034b3e32e5842c811ec73a3c2d30d721c3f8cdacf506b9720115485f6c29ee728ddd3b9f170d7ea6b55b3edf03e63a2dd7004947f8d
6
+ metadata.gz: 6fd750bdd5b1791f61d6cd295e682c0b66d9abcd0e22934fda3e5d580b0eee8858dc86882e07c2a910571dea52904cfdceb8a3be3280e5be5ea114e2354b047c
7
+ data.tar.gz: 3f981fef70c2c9e8444e2dc5e0e4e47a52a901d775581012ac384e2d0df16443ed6ac7980cdc75d0ff578af1094fb317b86d2f6e890be357dd531a345c34851c
data/bin/gemwarrior CHANGED
File without changes
@@ -163,8 +163,13 @@ module Gemwarrior
163
163
  0
164
164
  else
165
165
  if entity.eql?(monster)
166
+ # base attack range
167
+ atk_range = player.atk_lo..player.atk_hi
168
+
169
+ # beast mode modifier
166
170
  if player.beast_mode
167
171
  atk_range = BEAST_MODE_ATTACK..BEAST_MODE_ATTACK
172
+ # level 3 ability modifier
168
173
  elsif player.special_abilities.include?(:rock_slide)
169
174
  lo_boost = rand(0..9)
170
175
 
@@ -173,10 +178,10 @@ module Gemwarrior
173
178
  hi_boost = lo_boost + rand(0..5)
174
179
  atk_range = (player.atk_lo + lo_boost)..(player.atk_hi + hi_boost)
175
180
  end
176
- else
177
- atk_range = player.atk_lo..player.atk_hi
178
181
  end
179
- rand(atk_range)
182
+
183
+ # return attack range
184
+ return rand(atk_range)
180
185
  else
181
186
  dmg = rand(monster.atk_lo..monster.atk_hi)
182
187
  dmg = dmg - (entity.defense / 2) if player_is_defending
@@ -62,13 +62,30 @@ module Gemwarrior
62
62
  :use_wordnik => options.fetch(:use_wordnik)
63
63
  })
64
64
 
65
+ # create options file if not existing
66
+ update_options_file(world)
67
+
65
68
  # create the console
66
69
  self.eval = Evaluator.new(world)
67
- self.repl = Repl.new(world, eval)
70
+ self.repl = Repl.new(self, world, eval)
68
71
 
69
72
  # enter Jool!
70
73
  repl.start('look', world.extra_command)
71
74
  end
72
75
 
76
+ def get_log_file_path
77
+ "#{Dir.home}/.gemwarrior_log"
78
+ end
79
+
80
+ def get_options_file_path
81
+ "#{Dir.home}/.gemwarrior_options"
82
+ end
83
+
84
+ def update_options_file(world)
85
+ File.open(get_options_file_path, 'w') do |f|
86
+ f.puts "sound|#{world.sound}"
87
+ f.puts "use_wordnik|#{world.use_wordnik}"
88
+ end
89
+ end
73
90
  end
74
91
  end
@@ -23,9 +23,10 @@ module Gemwarrior
23
23
  GITHUB_NAME = 'michaelchadwick'
24
24
  GITHUB_PROJECT = 'gemwarrior'
25
25
 
26
- attr_accessor :world, :eval
26
+ attr_accessor :game, :world, :eval
27
27
 
28
- def initialize(world, evaluator)
28
+ def initialize(game, world, evaluator)
29
+ self.game = game
29
30
  self.world = world
30
31
  self.eval = evaluator
31
32
  end
@@ -38,6 +39,7 @@ module Gemwarrior
38
39
  at_exit do
39
40
  pl = world.player
40
41
  duration = clocker.stop
42
+ game.update_options_file(world)
41
43
  log_stats(duration, pl)
42
44
  end
43
45
 
@@ -68,6 +70,15 @@ module Gemwarrior
68
70
  OS.windows? ? system('cls') : system('clear')
69
71
  end
70
72
 
73
+ def read_line
74
+ prompt_text = world.debug_mode ? ' GW[D]> ' : ' GW> '
75
+ Readline.readline(prompt_text, true).to_s
76
+ end
77
+
78
+ def puts(s='', width=WRAP_WIDTH)
79
+ super s.gsub(/(.{1,#{width}})(\s+|\Z)/, "\\1\n") unless s.nil?
80
+ end
81
+
71
82
  def print_logo
72
83
  if world.sound
73
84
  Music::cue([
@@ -98,36 +109,79 @@ module Gemwarrior
98
109
  puts
99
110
  end
100
111
 
101
- def print_help
102
- puts '* Basic functions: look, go, character, inventory, attack *'
103
- puts '* Type \'help\' while in-game for complete list of commands *'
104
- puts '* Most commands can be abbreviated to their first letter *'
105
- puts
106
- end
107
-
108
112
  def print_about_text
109
113
  puts 'Gem Warrior - A Game of Fortune and Mayhem'
110
114
  puts '=========================================='
111
115
  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.'
112
116
  puts
113
117
  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.'
114
- puts
115
118
  end
116
119
 
117
- def print_main_menu
118
- puts " GW v#{Gemwarrior::VERSION}"
119
- puts '======================='
120
- puts ' (N)ew Game'
121
- puts ' (A)bout'
122
- puts ' (H)elp'
123
- puts ' (L)og'
124
- puts ' (C)heck for Updates'
125
- puts ' (E)xit'
126
- puts '======================='
120
+ def print_help_text
121
+ puts 'Gem Warrior - Some Basic Help Commands'
122
+ puts '======================================'
123
+ puts '* Basic functions: look, go, character, inventory, attack *'
124
+ puts '* Type \'help\' while in-game for complete list of commands *'
125
+ puts '* Most commands can be abbreviated to their first letter *'
126
+ end
127
+
128
+ def print_options
129
+ options = read_options_file
130
+
127
131
  puts
132
+ puts 'Gem Warrior Options'
133
+ puts '======================='
134
+ if options.nil?
135
+ puts 'No options set yet.'
136
+ else
137
+ 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'
138
+ puts
139
+ count = 1
140
+ options.each do |op|
141
+ option = op[0]
142
+ value = op[1].eql?('true') ? 'ON' : 'OFF'
143
+
144
+ print " #{count} #{option.ljust(12).upcase} : #{value}\n"
145
+ count += 1
146
+ end
147
+ end
148
+ puts '======================='
149
+ puts
150
+ puts 'Enter option number to toggle value, or any other key to return to main menu.'
151
+ print 'Option? '
152
+ answer = STDIN.getch
153
+
154
+ case answer
155
+ when '1'
156
+ print answer
157
+ world.sound = !world.sound
158
+ game.update_options_file(world)
159
+ print_options
160
+ when '2'
161
+ print answer
162
+ world.use_wordnik = !world.use_wordnik
163
+ game.update_options_file(world)
164
+ print_options
165
+ else
166
+ print answer
167
+ return
168
+ end
128
169
  end
129
-
170
+
171
+ def display_log
172
+ if File.exists?(game.get_log_file_path)
173
+ File.open(game.get_log_file_path).readlines.each do |line|
174
+ print "#{line}"
175
+ end
176
+ puts
177
+ else
178
+ puts 'No attempts made yet!'
179
+ puts
180
+ end
181
+ end
182
+
130
183
  def check_for_new_release
184
+ puts 'Checking releases...'
131
185
  github = Github.new
132
186
  gw_latest_release = github.repos.releases.list GITHUB_NAME, GITHUB_PROJECT
133
187
  local_release = Gemwarrior::VERSION
@@ -137,11 +191,26 @@ module Gemwarrior
137
191
  puts "GW v#{remote_release} available! Please (E)xit and run 'gem update' before continuing."
138
192
  puts
139
193
  else
140
- puts "You have the latest version. Fantastic!"
194
+ puts 'You have the latest version. Fantastic!'
141
195
  puts
142
196
  end
143
197
  end
144
-
198
+
199
+ def print_main_menu
200
+ puts
201
+ puts " GW v#{Gemwarrior::VERSION}"
202
+ puts '======================='
203
+ puts ' (N)ew Game'
204
+ puts ' (A)bout'
205
+ puts ' (H)elp'
206
+ puts ' (O)ptions'
207
+ puts ' (L)og'
208
+ puts ' (C)heck for Updates'
209
+ puts ' (E)xit'
210
+ puts '======================='
211
+ puts
212
+ end
213
+
145
214
  def print_main_menu_prompt
146
215
  print '> '
147
216
  end
@@ -164,7 +233,11 @@ module Gemwarrior
164
233
  run_main_menu
165
234
  when 'h'
166
235
  puts choice
167
- print_help
236
+ print_help_text
237
+ run_main_menu
238
+ when 'o'
239
+ puts choice
240
+ print_options
168
241
  run_main_menu
169
242
  when 'l'
170
243
  puts choice
@@ -183,24 +256,23 @@ module Gemwarrior
183
256
  end
184
257
  end
185
258
 
186
- def get_log_file_path
187
- "#{Dir.home}/.gemwarrior"
188
- end
189
-
190
- def display_log
191
- if File.exists?(get_log_file_path)
192
- File.open(get_log_file_path).readlines.each do |line|
193
- print "#{line}"
259
+ def read_options_file
260
+ options = []
261
+ if File.exists?(game.get_options_file_path)
262
+ File.open(game.get_options_file_path).readlines.each do |line|
263
+ options << line.chomp.split('|')
194
264
  end
265
+ return options
195
266
  else
196
- puts 'No attempts made yet!'
267
+ nil
197
268
  end
198
269
  end
199
270
 
200
271
  def log_stats(duration, pl)
201
272
  puts '######################################################################'
202
273
  print 'Gem Warrior'.colorize(:color => :white, :background => :black)
203
- print " played for #{duration[:mins].to_s.colorize(:color => :white, :background => :black)} minutes, #{duration[:secs].to_s.colorize(:color => :white, :background => :black)} seconds, and #{duration[:ms].to_s.colorize(:color => :white, :background => :black)} milliseconds\n"
274
+ print " v#{Gemwarrior::VERSION}".colorize(:yellow)
275
+ print " played for #{duration[:mins].to_s.colorize(:color => :white, :background => :black)} mins, #{duration[:secs].to_s.colorize(:color => :white, :background => :black)} secs, and #{duration[:ms].to_s.colorize(:color => :white, :background => :black)} ms\n"
204
276
  puts '----------------------------------------------------------------------'
205
277
  print "Player killed #{pl.monsters_killed.to_s.colorize(:color => :white, :background => :black)} monster(s)"
206
278
  print "\n".ljust(8)
@@ -215,8 +287,8 @@ module Gemwarrior
215
287
  puts '######################################################################'
216
288
 
217
289
  # log stats to file in home directory
218
- File.open(get_log_file_path, 'a') do |f|
219
- f.write "#{Time.now} #{pl.name.rjust(10)} - LV:#{pl.level} XP:#{pl.xp} $:#{pl.rox} KIL:#{pl.monsters_killed} ITM:#{pl.items_taken} MOV:#{pl.movements_made} RST:#{pl.rests_taken} DTH:#{pl.deaths}\n"
290
+ File.open(game.get_log_file_path, 'a') do |f|
291
+ f.write "#{Time.now} #{pl.name.rjust(10)} - V:#{Gemwarrior::VERSION} LV:#{pl.level} XP:#{pl.xp} $:#{pl.rox} KIL:#{pl.monsters_killed} ITM:#{pl.items_taken} MOV:#{pl.movements_made} RST:#{pl.rests_taken} DTH:#{pl.deaths}\n"
220
292
  end
221
293
  end
222
294
 
@@ -225,7 +297,6 @@ module Gemwarrior
225
297
  clear_screen
226
298
  print_logo
227
299
 
228
-
229
300
  # main menu loop until new game or exit
230
301
  if world.new_game
231
302
  print_splash_message
@@ -261,14 +332,5 @@ module Gemwarrior
261
332
  print (prompt_template % prompt_vars_arr).colorize(:yellow)
262
333
  print "\n"
263
334
  end
264
-
265
- def read_line
266
- prompt_text = world.debug_mode ? ' GW[D]> ' : ' GW> '
267
- Readline.readline(prompt_text, true).to_s
268
- end
269
-
270
- def puts(s='', width=WRAP_WIDTH)
271
- super s.gsub(/(.{1,#{width}})(\s+|\Z)/, "\\1\n") unless s.nil?
272
- end
273
335
  end
274
336
  end
@@ -2,5 +2,5 @@
2
2
  # Version of Gem Warrior
3
3
 
4
4
  module Gemwarrior
5
- VERSION = '0.9.22'
5
+ VERSION = '0.9.23'
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.22
4
+ version: 0.9.23
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Chadwick
@@ -308,6 +308,4 @@ rubygems_version: 2.4.8
308
308
  signing_key:
309
309
  specification_version: 4
310
310
  summary: RubyGem text adventure
311
- test_files:
312
- - spec/rubywarrior_spec.rb
313
- - spec/spec_helper.rb
311
+ test_files: []