gemwarrior 0.9.13 → 0.9.14

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: 2882237d0ae680196fd53ba40b980b971cb98827
4
- data.tar.gz: 8526b2c173b534c5179b6a77f7ca9f6f084240f8
3
+ metadata.gz: 93bc49273b5962d3094e927e1f2b604fcd4190b9
4
+ data.tar.gz: c7219c8675e8549d72e2df4db0e5caf860ab3b47
5
5
  SHA512:
6
- metadata.gz: df7ee21d2dea13af1bbaf0c418c83cfc789782542404950b864bc3f52d8068d7590fd7a6468dd194c8b64feeb019c8ea9965b1ee4ceb497de31800c1b0042fcf
7
- data.tar.gz: 750f4ee539610fd37cba7ae432458044fe1a76d1ef1dd37369a3b95f707565ffefa3b708371949c2efe5d16973b42332d941a9801c2349e37f6be096e43a569e
6
+ metadata.gz: 1efa9aa0504e57f90d77bcf29e1dc6677a7709ba1114016256cf280cf626f3d2e5bd6eed100c5f72eb093f8f52bb1eab16964c454f0c043ef5fb709d1271277c
7
+ data.tar.gz: 4d80c518aad9e8eff5fc8f0c916b38031b01b234e3fc13f87ff4eb73c45cc6af4a1cd6538013cb94e6ca82dae2ea727cc9982c80b64d5d7ad94657c1fb0ad165
data/bin/gemwarrior CHANGED
File without changes
@@ -56,7 +56,7 @@ module Gemwarrior
56
56
  random_monster = nil
57
57
 
58
58
  loop do
59
- random_monster = world.monsters[rand(0..world.monsters.length-1)]
59
+ random_monster = world.monsters[rand(0..world.monsters.length-1)].clone
60
60
 
61
61
  unless random_monster.is_boss
62
62
  break
@@ -95,14 +95,24 @@ module Gemwarrior
95
95
  self_text << "Current status - breathing, wearing clothing, and with a few other specific characteristics: face is #{self.face}, hands are #{self.hands}, and general mood is #{self.mood}.\n"
96
96
  end
97
97
 
98
- def rest(world, tent_uses = nil)
98
+ def rest(world, tent_uses = nil, ensure_fight = false)
99
+ if ensure_fight
100
+ battle = Battle.new({:world => world, :player => self, :monster => world.monsters[rand(0..world.monsters.length-1)].clone})
101
+ result = battle.start(is_arena = false, is_event = true)
102
+ if result.eql?('death')
103
+ return 'death'
104
+ else
105
+ return
106
+ end
107
+ end
108
+
99
109
  cur_loc = world.location_by_coords(cur_coords)
100
110
 
101
111
  if cur_loc.should_spawn_monster?
102
112
  chance_of_ambush = rand(0..100)
103
113
 
104
114
  if chance_of_ambush < 25
105
- battle = Battle.new({:world => world, :player => self, :monster => cur_loc.monsters_abounding[rand(0..cur_loc.monsters_abounding.length-1)]})
115
+ battle = Battle.new({:world => world, :player => self, :monster => cur_loc.monsters_abounding[rand(0..cur_loc.monsters_abounding.length-1)].clone})
106
116
  return battle.start(is_arena = false, is_event = true)
107
117
  end
108
118
  end
@@ -123,12 +133,12 @@ module Gemwarrior
123
133
  if tent_uses > 0
124
134
  self.hp_cur = self.hp_max
125
135
 
126
- return "You brandish the trusty magical canvas and, with a flick of the wrist, your home for the evening is set up. Approximately #{hours} #{hours_text}, #{minutes} #{mins_text}, and #{seconds} #{secs_text} later, you wake up, fully rested, ready for adventure."
136
+ puts "You brandish the trusty magical canvas and, with a flick of the wrist, your home for the evening is set up. Approximately #{hours} #{hours_text}, #{minutes} #{mins_text}, and #{seconds} #{secs_text} later, you wake up, fully rested, ready for adventure."
127
137
  else
128
138
  self.hp_cur = self.hp_cur.to_i + rand(10..15)
129
139
  self.hp_cur = self.hp_max if self.hp_cur > self.hp_max
130
140
 
131
- return "You lie down somewhere quasi-flat and after a few moments, due to extreme exhaustion, you fall into a deep, yet troubled, slumber. Approximately #{hours} #{hours_text}, #{minutes} #{mins_text}, and #{seconds} #{secs_text} later, you wake up with a start. Upon getting to your feet you look around, notice you feel somewhat better, and wonder why you dreamt about #{WordList.new(world.use_wordnik, 'noun-plural').get_random_value}."
141
+ puts "You lie down somewhere quasi-flat and after a few moments, due to extreme exhaustion, you fall into a deep, yet troubled, slumber. Approximately #{hours} #{hours_text}, #{minutes} #{mins_text}, and #{seconds} #{secs_text} later, you wake up with a start. Upon getting to your feet you look around, notice you feel somewhat better, and wonder why you dreamt about #{WordList.new(world.use_wordnik, 'noun-plural').get_random_value}."
132
142
  end
133
143
  end
134
144
 
@@ -241,7 +251,7 @@ module Gemwarrior
241
251
  self.inventory.items.concat monster_items unless monster_items.empty?
242
252
  end
243
253
  when trigger[:reason].eql?(:xp)
244
- self.xp += trigger[:value].xp
254
+ self.xp += trigger[:value]
245
255
  when trigger[:reason].eql?(:level_bump)
246
256
  next_player_level = old_player_level + 1
247
257
  self.xp = PlayerLevels::get_level_stats(next_player_level)[:xp_start]
@@ -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 levelbump)
51
- self.devaliases = %w(gd bs ls v m s tp sp lb)
50
+ self.devcommands = %w(god beast list vars map stat teleport spawn levelbump restfight)
51
+ self.devaliases = %w(gd bs ls v m s tp sp lb rf)
52
52
  self.devextras = %w(st)
53
53
  self.devcmd_descriptions = [
54
54
  'Toggle god mode (i.e. invincible)',
@@ -59,7 +59,8 @@ module Gemwarrior
59
59
  'Change player stat',
60
60
  'Teleport to coordinates (5 0 0) or location name (\'Home\')',
61
61
  'Spawn random monster',
62
- 'Bump your character to the next experience level'
62
+ 'Bump your character to the next experience level',
63
+ 'Rest, but ensure battle for testing'
63
64
  ]
64
65
 
65
66
  self.commands = %w(character inventory rest look take use drop equip unequip go attack change help quit quit!)
@@ -247,6 +248,12 @@ module Gemwarrior
247
248
  end
248
249
  when 'levelbump', 'lb'
249
250
  world.player.update_stats({:reason => :level_bump, :value => 1})
251
+ when 'restfight', 'rf'
252
+ result = world.player.rest(world, nil, true)
253
+
254
+ if result.eql?('death')
255
+ player_death_resurrection
256
+ end
250
257
  end
251
258
  end
252
259
 
@@ -290,7 +297,12 @@ module Gemwarrior
290
297
  end
291
298
  end
292
299
  end
293
- world.player.rest(world, tent_uses)
300
+
301
+ result = world.player.rest(world, tent_uses)
302
+
303
+ if result.eql?('death')
304
+ player_death_resurrection
305
+ end
294
306
  when 'look', 'l'
295
307
  if param1
296
308
  world.describe_entity(world.location_by_coords(world.player.cur_coords), param1)
@@ -328,6 +340,8 @@ module Gemwarrior
328
340
  elsif i.consumable
329
341
  result = i.use(world.player)
330
342
  world.player.inventory.remove_item(i.name)
343
+ else
344
+ result = i.use(world.player)
331
345
  end
332
346
  else
333
347
  return ERROR_USE_PARAM_UNUSEABLE
@@ -349,6 +363,8 @@ module Gemwarrior
349
363
  elsif i.consumable
350
364
  result = i.use(world.player)
351
365
  world.player.inventory.remove_item(i.name)
366
+ else
367
+ result = i.use(world.player)
352
368
  end
353
369
  else
354
370
  return ERROR_USE_PARAM_UNUSEABLE
@@ -8,10 +8,9 @@ module Gemwarrior
8
8
  ERROR_ITEM_REMOVE_INVALID = 'Your inventory does not contain that item, so you cannot drop it.'
9
9
  ERROR_ITEM_ADD_UNTAKEABLE = 'That would be great if you could take that thing, wouldn\'t it? Well, it\'s not so great for you right now.'
10
10
  ERROR_ITEM_ADD_INVALID = 'That item does not exist here.'
11
- ERROR_ITEM_DESCRIBE_INVALID = 'You do not possess that.'
12
- ERROR_ITEM_EQUIP_INVALID = 'You do not have anything called that to equip.'
11
+ ERROR_ITEM_EQUIP_INVALID = 'You do not possess anything called that to equip.'
13
12
  ERROR_ITEM_EQUIP_NONWEAPON = 'That cannot be equipped as a weapon.'
14
- ERROR_ITEM_UNEQUIP_INVALID = 'You do not have anything called that to unequip.'
13
+ ERROR_ITEM_UNEQUIP_INVALID = 'You do not possess anything called that to unequip.'
15
14
  ERROR_ITEM_UNEQUIP_NONWEAPON = 'That cannot be unequipped.'
16
15
 
17
16
  attr_accessor :items, :weapon
@@ -41,7 +40,7 @@ module Gemwarrior
41
40
  end
42
41
  end
43
42
  else
44
- ERROR_ITEM_DESCRIBE_INVALID
43
+ return false
45
44
  end
46
45
  end
47
46
 
@@ -54,7 +53,7 @@ module Gemwarrior
54
53
  self.weapon = i
55
54
  return "The #{i.name} has taken charge, and been equipped."
56
55
  else
57
- ERROR_ITEM_EQUIP_NONWEAPON
56
+ return ERROR_ITEM_EQUIP_NONWEAPON
58
57
  end
59
58
  end
60
59
  end
@@ -102,13 +101,19 @@ module Gemwarrior
102
101
 
103
102
  def remove_item(item_name)
104
103
  if contains_item?(item_name)
105
- items.delete_at(items.map(&:name).index(item_name) || items.length)
106
-
107
- unless self.weapon.nil?
108
- self.weapon = nil if self.weapon.name.eql?(item_name)
109
- end
104
+ puts "Are you sure you want to permanently throw away #{item_name}? (Y/N)"
105
+ answer = gets.downcase.chomp!
110
106
 
111
- return "The #{item_name} has been thrown on the ground, but far out of reach, and you're much too lazy to go get it now, so it's as good as gone."
107
+ if answer.eql?('y')
108
+ items.delete_at(items.map(&:name).index(item_name) || items.length)
109
+ unless self.weapon.nil?
110
+ self.weapon = nil if self.weapon.name.eql?(item_name)
111
+ end
112
+
113
+ return "The #{item_name} has been thrown on the ground, but far out of reach, and you're much too lazy to go get it now, so it's as good as gone."
114
+ else
115
+ return "You decide to keep #{item_name} for now."
116
+ end
112
117
  else
113
118
  ERROR_ITEM_REMOVE_INVALID
114
119
  end
@@ -17,7 +17,8 @@ module Gemwarrior
17
17
  ## MESSAGES
18
18
  QUIT_MESSAGE = 'Temporal flux detected. Shutting down...'.colorize(:red)
19
19
  MAIN_MENU_QUIT_MESSAGE = 'Giving up so soon? Jool will be waiting...'.colorize(:yellow)
20
- SPLASH_MESSAGE = 'Welcome to the land of *Jool*, where randomized fortune is just as likely as mayhem.'
20
+ SPLASH_MESSAGE = 'Welcome to *Jool*, where randomized fortune is just as likely as mayhem.'
21
+ WRAP_WIDTH = 80
21
22
 
22
23
  attr_accessor :world, :eval
23
24
 
@@ -91,6 +92,7 @@ module Gemwarrior
91
92
  noun3_values = WordList.new(world.use_wordnik, 'noun-plural')
92
93
 
93
94
  puts "* Remember: #{noun1_values.get_random_value} and #{noun2_values.get_random_value} are the key to #{noun3_values.get_random_value} *\n\n"
95
+ puts
94
96
  end
95
97
 
96
98
  def print_help
@@ -174,14 +176,19 @@ module Gemwarrior
174
176
  print_logo
175
177
 
176
178
  # main menu loop until new game or exit
177
- run_main_menu unless world.new_game
179
+ if world.new_game
180
+ print_splash_message
181
+ print_fortune
182
+ else
183
+ run_main_menu
184
+ end
178
185
 
179
186
  # hook to do something right off the bat
180
187
  puts eval.evaluate(initialCommand) unless initialCommand.nil?
181
188
  end
182
189
 
183
190
  def prompt
184
- prompt_template = "\n[LV:%3s][XP:%3s][ROX:%3s] -- [HP:%3s/%-3s][STM:%2s/%-2s] -- [%s @ %s]"
191
+ prompt_template = "\n[LV:%2s][XP:%3s][ROX:%3s] [HP:%3s/%-3s][STM:%2s/%-2s] [%s @ %s]"
185
192
  if world.debug_mode
186
193
  prompt_template += "[%s, %s, %s]"
187
194
  end
@@ -199,12 +206,17 @@ module Gemwarrior
199
206
  if world.debug_mode
200
207
  prompt_vars_arr.push(world.player.cur_coords[:x], world.player.cur_coords[:y], world.player.cur_coords[:z])
201
208
  end
202
- puts (prompt_template % prompt_vars_arr).colorize(:yellow)
209
+ print (prompt_template % prompt_vars_arr).colorize(:yellow)
210
+ print "\n"
203
211
  end
204
212
 
205
213
  def read_line
206
214
  prompt_text = world.debug_mode ? ' GW[D]> ' : ' GW> '
207
215
  Readline.readline(prompt_text, true).to_s
208
216
  end
217
+
218
+ def puts(s='', width=WRAP_WIDTH)
219
+ super s.gsub(/(.{1,#{width}})(\s+|\Z)/, "\\1\n") unless s.nil?
220
+ end
209
221
  end
210
222
  end
@@ -2,5 +2,5 @@
2
2
  # Version of Gem Warrior
3
3
 
4
4
  module Gemwarrior
5
- VERSION = '0.9.13'
5
+ VERSION = '0.9.14'
6
6
  end
@@ -170,9 +170,11 @@ module Gemwarrior
170
170
  end
171
171
 
172
172
  def describe_entity(point, entity_name)
173
+ entity_name.downcase!
174
+
173
175
  if point.has_item?(entity_name)
174
176
  point.items.each do |i|
175
- if i.name.downcase.eql?(entity_name.downcase)
177
+ if i.name.downcase.eql?(entity_name)
176
178
  if debug_mode
177
179
  return i.describe
178
180
  else
@@ -180,30 +182,28 @@ module Gemwarrior
180
182
  end
181
183
  end
182
184
  end
183
- elsif
184
- if point.has_monster?(entity_name)
185
- point.monsters_abounding.each do |m|
186
- if m.name.downcase.eql?(entity_name.downcase)
187
- if debug_mode
188
- return m.describe
189
- else
190
- return m.description
191
- end
185
+ elsif point.has_monster?(entity_name)
186
+ point.monsters_abounding.each do |m|
187
+ if m.name.downcase.eql?(entity_name)
188
+ if debug_mode
189
+ return m.describe
190
+ else
191
+ return m.description
192
192
  end
193
193
  end
194
194
  end
195
- elsif
196
- if point.has_boss?(entity_name)
197
- point.bosses_abounding.each do |b|
198
- if b.name.downcase.eql?(entity_name.downcase)
199
- if debug_mode
200
- return b.describe
201
- else
202
- return b.description
203
- end
195
+ elsif point.has_boss?(entity_name)
196
+ point.bosses_abounding.each do |b|
197
+ if b.name.downcase.eql?(entity_name)
198
+ if debug_mode
199
+ return b.describe
200
+ else
201
+ return b.description
204
202
  end
205
203
  end
206
204
  end
205
+ elsif player.inventory.contains_item?(entity_name)
206
+ player.inventory.describe_item(entity_name)
207
207
  else
208
208
  ERROR_LOCATION_DESCRIBE_ENTITY_INVALID
209
209
  end
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.13
4
+ version: 0.9.14
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-08-05 00:00:00.000000000 Z
11
+ date: 2015-08-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: os
@@ -294,4 +294,6 @@ rubygems_version: 2.4.8
294
294
  signing_key:
295
295
  specification_version: 4
296
296
  summary: RubyGem text adventure
297
- test_files: []
297
+ test_files:
298
+ - spec/rubywarrior_spec.rb
299
+ - spec/spec_helper.rb