gemwarrior 0.9.9 → 0.9.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2dac84cb6be6c2deb411b2e3cb3753c725e50409
4
- data.tar.gz: 24015aa5dccb120764bcc0be8703042701b18c93
3
+ metadata.gz: 2aaefc1728156bed990a2587cb84951231135d8a
4
+ data.tar.gz: 5060bd8a701f90534ce639095be3cd4dfc659e66
5
5
  SHA512:
6
- metadata.gz: 0bbbb321bdb5c182bd65b357e98f3709f2915efddb4d77538d6259eba00a790e2669985732e4685f892e334e47d2605554ff7a5f0534dc8eae33f1cfc6249ef1
7
- data.tar.gz: a94bb989a038f982b24edb879b27a68678a99b49fd452ea54e567224a0d45981ffa2b0080bdab61cf7d1dcca150ff6d8ca729ef2b861ef0b3ffc4aa6d9b4ee9c
6
+ metadata.gz: 03d906c73ca04bff1be05b0931414014782e0e64847fe974627d81e5cdd5817f784f06909b89eac925dc6f91ecd3a8b0a8d7ef772573da5960ad713bb7d56f80
7
+ data.tar.gz: 2db84ce081bad9796998db63ae4a389015229b15de8b7853522f5fc3b6b35c5f5c4bcc3d96ad60fd620a9189290310e2ecd87ee4aa43d4ce59932f8f131d08c8
data/bin/gemwarrior CHANGED
@@ -13,7 +13,8 @@ def parse_options
13
13
  :god_mode => false,
14
14
  :beast_mode => false,
15
15
  :use_wordnik => false,
16
- :sound => false
16
+ :sound => false,
17
+ :new_game => false
17
18
  }
18
19
 
19
20
  optparse = OptionParser.new do |opts|
@@ -41,6 +42,10 @@ def parse_options
41
42
  opts.on('-s', '--sound', 'Turn sound on') do
42
43
  options[:sound] = true
43
44
  end
45
+
46
+ opts.on('-n', '--new', 'Immediately start a new game, skipping main menu') do
47
+ options[:new_game] = true
48
+ end
44
49
  end
45
50
 
46
51
  optparse.parse!()
@@ -165,6 +165,14 @@ module Gemwarrior
165
165
  if entity.eql?(monster)
166
166
  if player.beast_mode
167
167
  atk_range = BEAST_MODE_ATTACK..BEAST_MODE_ATTACK
168
+ elsif player.special_abilities.include?(:rock_slide)
169
+ lo_boost = rand(0..9)
170
+
171
+ if lo_boost >= 7
172
+ puts "#{player.name} uses Rock Slide for added damage!"
173
+ hi_boost = lo_boost + rand(0..5)
174
+ atk_range = (player.atk_lo + lo_boost)..(player.atk_hi + hi_boost)
175
+ end
168
176
  else
169
177
  atk_range = player.atk_lo..player.atk_hi
170
178
  end
@@ -252,7 +260,7 @@ module Gemwarrior
252
260
  puts " XP : #{monster.xp}".colorize(:green)
253
261
  puts " ROX: #{monster.rox}".colorize(:green)
254
262
  print_battle_line
255
- player.update_stats(monster)
263
+ player.update_stats({:reason => :monster, :value => monster})
256
264
  world.location_by_coords(player.cur_coords).remove_monster(monster.name)
257
265
  end
258
266
  else
@@ -263,7 +271,7 @@ module Gemwarrior
263
271
  puts " ITEMS: #{monster.inventory.list_contents}".colorize(:green) unless monster.inventory.items.empty?
264
272
  end
265
273
  print_battle_line
266
- player.update_stats(monster)
274
+ player.update_stats({:reason => :monster, :value => monster})
267
275
  world.location_by_coords(player.cur_coords).remove_monster(monster.name)
268
276
  end
269
277
  end
@@ -3,6 +3,7 @@
3
3
 
4
4
  require_relative 'creature'
5
5
  require_relative '../battle'
6
+ require_relative '../misc/formatting'
6
7
  require_relative '../misc/name_generator'
7
8
  require_relative '../misc/player_levels'
8
9
  require_relative '../misc/wordlist'
@@ -10,6 +11,7 @@ require_relative '../misc/wordlist'
10
11
  module Gemwarrior
11
12
  class Player < Creature
12
13
  include PlayerLevels
14
+ include Formatting
13
15
 
14
16
  attr_accessor :stam_cur, :stam_max, :cur_coords,
15
17
  :god_mode, :beast_mode, :use_wordnik, :special_abilities,
@@ -46,10 +48,10 @@ module Gemwarrior
46
48
 
47
49
  self.special_abilities = []
48
50
 
49
- self.monsters_killed = 0
50
- self.items_taken = 0
51
- self.movements_made = 0
52
- self.rests_taken = 0
51
+ self.monsters_killed = 0
52
+ self.items_taken = 0
53
+ self.movements_made = 0
54
+ self.rests_taken = 0
53
55
  end
54
56
 
55
57
  def check_self(debug_mode = false, show_pic = true)
@@ -68,10 +70,10 @@ module Gemwarrior
68
70
 
69
71
  abilities = ''
70
72
  if special_abilities.empty?
71
- abilities = 'none'
73
+ abilities = 'none...yet(?)'
72
74
  else
73
- abilities = special_abilities.join(', ')
74
- end
75
+ abilities = Formatting::upstyle(special_abilities.collect { |x| x.to_s }).join(', ')
76
+ end
75
77
 
76
78
  self_text = "NAME : #{self.name}\n"
77
79
  self_text << "POSITION : #{self.cur_coords.values.to_a}\n"
@@ -144,10 +146,7 @@ module Gemwarrior
144
146
  elsif new_name.length < 3 || new_name.length > 10
145
147
  return "'#{new_name}' is an invalid length. Make it between 3 and 10 characters, please."
146
148
  else
147
- name_to_add = ""
148
- name_to_add << new_name[0].upcase
149
- name_to_add << new_name[1..new_name.length-1].downcase
150
- self.name = name_to_add
149
+ self.name = Formatting::upstyle(new_name)
151
150
  return "New name, '#{name}', accepted."
152
151
  end
153
152
  end
@@ -227,16 +226,25 @@ module Gemwarrior
227
226
  self.hp_cur = self.hp_max
228
227
  end
229
228
  end
230
-
231
- def update_stats(monster)
229
+
230
+ def update_stats(trigger)
232
231
  old_player_level = PlayerLevels::check_level(self.xp)
233
232
 
234
- self.xp = self.xp + monster.xp
235
- self.rox = self.rox + monster.rox
233
+ case
234
+ when trigger[:reason].eql?(:monster)
235
+ monster = trigger[:value]
236
+ self.xp += monster.xp
237
+ self.rox += monster.rox
236
238
 
237
- monster_items = monster.inventory.items
238
- unless monster_items.nil?
239
- self.inventory.items.concat monster_items unless monster_items.empty?
239
+ monster_items = monster.inventory.items
240
+ unless monster_items.nil?
241
+ self.inventory.items.concat monster_items unless monster_items.empty?
242
+ end
243
+ when trigger[:reason].eql?(:xp)
244
+ self.xp += trigger[:value].xp
245
+ when trigger[:reason].eql?(:level_bump)
246
+ next_player_level = old_player_level + 1
247
+ self.xp = PlayerLevels::get_level_stats(next_player_level)[:xp_start]
240
248
  end
241
249
 
242
250
  new_player_level = PlayerLevels::check_level(self.xp)
@@ -263,7 +271,7 @@ module Gemwarrior
263
271
  unless new_stats[:special_abilities].nil?
264
272
  unless self.special_abilities.include?(new_stats[:special_abilities])
265
273
  self.special_abilities.push(new_stats[:special_abilities])
266
- puts "You learned a new ability: #{new_stats[:special_abilities]}!"
274
+ puts "You learned a new ability: #{Formatting::upstyle(new_stats[:special_abilities])}!"
267
275
  end
268
276
  end
269
277
  end
@@ -47,8 +47,8 @@ module Gemwarrior
47
47
  def initialize(world)
48
48
  self.world = world
49
49
 
50
- self.devcommands = %w(god beast list vars map stat teleport spawn)
51
- self.devaliases = %w(gd bs ls v m s tp sp)
50
+ self.devcommands = %w(god beast list vars map stat teleport spawn levelbump)
51
+ self.devaliases = %w(gd bs ls v m s tp sp lb)
52
52
  self.devextras = %w(st)
53
53
  self.devcmd_descriptions = [
54
54
  'Toggle god mode (i.e. invincible)',
@@ -58,12 +58,13 @@ module Gemwarrior
58
58
  'Show a map of the world',
59
59
  'Change player stat',
60
60
  'Teleport to coordinates (5 0 0) or location name (\'Home\')',
61
- 'Spawn random monster'
61
+ 'Spawn random monster',
62
+ 'Bump your character to the next experience level'
62
63
  ]
63
64
 
64
65
  self.commands = %w(character inventory rest look take use drop equip unequip go attack change help quit quit!)
65
66
  self.aliases = %w(c i r l t u d e ue g a ch h q qq)
66
- self.extras = %w(exit exit! x x fight f)
67
+ self.extras = %w(exit exit! x xx fight f)
67
68
  self.cmd_descriptions = [
68
69
  'Display character information',
69
70
  'Look in your inventory',
@@ -244,6 +245,8 @@ module Gemwarrior
244
245
  Animation::run({:phrase => '** TELEPORT! **', :speed => :insane})
245
246
  return world.describe(world.location_by_coords(world.player.cur_coords))
246
247
  end
248
+ when 'levelbump', 'lb'
249
+ world.player.update_stats({:reason => :level_bump, :value => 1})
247
250
  end
248
251
  end
249
252
 
@@ -327,14 +330,14 @@ module Gemwarrior
327
330
  world.player.heal_damage(result[:data])
328
331
  return
329
332
  when 'xp'
330
- world.player.xp += result[:data]
333
+ world.player.update_stats({:reason => :xp, :value => result[:data]})
331
334
  return
332
335
  when 'action'
333
336
  case result[:data]
334
337
  when 'rest'
335
338
  world.player.rest(world)
336
339
  when 'map'
337
- world.print_map
340
+ world.print_map(world.player.cur_coords[:z])
338
341
  end
339
342
  when 'arena'
340
343
  arena = Arena.new({:world => world, :player => world.player})
@@ -38,6 +38,7 @@ module Gemwarrior
38
38
  world.debug_mode = options.fetch(:debug_mode)
39
39
  world.use_wordnik = options.fetch(:use_wordnik)
40
40
  world.sound = options.fetch(:sound)
41
+ world.new_game = options.fetch(:new_game)
41
42
 
42
43
  world.player = Player.new({
43
44
  :description => PLAYER_DESC_DEFAULT,
@@ -0,0 +1,42 @@
1
+ # lib/gemwarrior/misc/formatting.rb
2
+ # Formatting methods for text
3
+
4
+ module Gemwarrior
5
+ module Formatting
6
+ def self.upstyle(str_arr)
7
+ if str_arr.is_a? Array
8
+ str_arr_upstyled = []
9
+
10
+ str_arr.each do |str_arr_item|
11
+ str_arr_item_upstyled = []
12
+
13
+ str_arr_item.split(' ').each do |s|
14
+ str_arr_item_upstyled << upstyle_string(s)
15
+ end
16
+
17
+ str_arr_upstyled << str_arr_item_upstyled.join(' ')
18
+ end
19
+
20
+ return str_arr_upstyled
21
+ else
22
+ return upstyle_string(str_arr)
23
+ end
24
+ end
25
+
26
+ private
27
+
28
+ def self.upstyle_string(s)
29
+ s_upstyle = ''
30
+ s_upstyle << s[0].upcase
31
+ 1.upto(s.length-1) do |i|
32
+ if s[i-1].eql?('_')
33
+ s_upstyle[i-1] = ' '
34
+ s_upstyle << s[i].upcase
35
+ else
36
+ s_upstyle << s[i].downcase
37
+ end
38
+ end
39
+ return s_upstyle
40
+ end
41
+ end
42
+ end
@@ -172,7 +172,7 @@ module Gemwarrior
172
172
  print_logo
173
173
 
174
174
  # main menu loop until new game or exit
175
- run_main_menu
175
+ run_main_menu unless world.new_game
176
176
 
177
177
  # hook to do something right off the bat
178
178
  puts eval.evaluate(initialCommand) unless initialCommand.nil?
@@ -2,5 +2,5 @@
2
2
  # Version of Gem Warrior
3
3
 
4
4
  module Gemwarrior
5
- VERSION = '0.9.9'
5
+ VERSION = '0.9.10'
6
6
  end
@@ -18,7 +18,7 @@ module Gemwarrior
18
18
  ERROR_LIST_PARAM_INVALID = 'That is not something that can be listed.'
19
19
  ERROR_LOCATION_DESCRIBE_ENTITY_INVALID = 'You do not see that here.'
20
20
 
21
- attr_accessor :monsters, :locations, :player, :debug_mode, :use_wordnik, :sound
21
+ attr_accessor :monsters, :locations, :player, :debug_mode, :use_wordnik, :sound, :new_game
22
22
 
23
23
  def initialize
24
24
  self.monsters = init_monsters
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.9.9
4
+ version: 0.9.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: 2015-07-17 00:00:00.000000000 Z
11
+ date: 2015-07-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: os
@@ -259,6 +259,7 @@ files:
259
259
  - lib/gemwarrior/game.rb
260
260
  - lib/gemwarrior/inventory.rb
261
261
  - lib/gemwarrior/misc/animation.rb
262
+ - lib/gemwarrior/misc/formatting.rb
262
263
  - lib/gemwarrior/misc/music.rb
263
264
  - lib/gemwarrior/misc/name_generator.rb
264
265
  - lib/gemwarrior/misc/player_levels.rb
@@ -293,6 +294,4 @@ rubygems_version: 2.4.8
293
294
  signing_key:
294
295
  specification_version: 4
295
296
  summary: RubyGem text adventure
296
- test_files:
297
- - spec/rubywarrior_spec.rb
298
- - spec/spec_helper.rb
297
+ test_files: []