gemwarrior 0.9.10 → 0.9.12

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: 2aaefc1728156bed990a2587cb84951231135d8a
4
- data.tar.gz: 5060bd8a701f90534ce639095be3cd4dfc659e66
3
+ metadata.gz: 30320b17fc348bcf979a232b45e942b2760a6f7d
4
+ data.tar.gz: 33a63526a76eeb98fae273542b3a55fbfb9b0287
5
5
  SHA512:
6
- metadata.gz: 03d906c73ca04bff1be05b0931414014782e0e64847fe974627d81e5cdd5817f784f06909b89eac925dc6f91ecd3a8b0a8d7ef772573da5960ad713bb7d56f80
7
- data.tar.gz: 2db84ce081bad9796998db63ae4a389015229b15de8b7853522f5fc3b6b35c5f5c4bcc3d96ad60fd620a9189290310e2ecd87ee4aa43d4ce59932f8f131d08c8
6
+ metadata.gz: 9c795a7c3823054838aa6e8149a37e320124736e112abb7cfc47db8aa58684addf7830e412c6efd04d167fee7719634ce75e24548786c899c20c03ea2a33fb7a
7
+ data.tar.gz: ee7df37798af7556b855ad3c8fb639cd19514d6d1d45ed719f26c72c35543ea89efa25132cbe79f6deb44a15a09db84e52859a5c68ac58d42b7e97b571af98d0
@@ -24,11 +24,12 @@ module Gemwarrior
24
24
  result = battle.start(is_arena = true)
25
25
 
26
26
  if result.eql?('death')
27
- return 'exit'
27
+ return 'death'
28
28
  end
29
29
 
30
30
  arena_monsters_vanquished += 1
31
31
 
32
+ puts
32
33
  puts 'Do you wish to continue fighting in the Arena? (Y/N)'
33
34
  answer = gets.chomp.downcase
34
35
 
@@ -136,11 +136,11 @@ module Gemwarrior
136
136
  next
137
137
  end
138
138
  when 'run', 'r'
139
- if player_escape?
139
+ if player_escape?(is_arena)
140
140
  monster.hp_cur = monster.hp_max
141
141
  puts "You successfully elude #{monster.name}!".colorize(:green)
142
142
  print_escape_text
143
- return
143
+ return 'escaped'
144
144
  else
145
145
  puts "You were not able to run away! :-(".colorize(:yellow)
146
146
  end
@@ -287,22 +287,24 @@ module Gemwarrior
287
287
 
288
288
  def player_death
289
289
  puts "You are dead, slain by the #{monster.name}!".colorize(:red)
290
- puts 'Your adventure ends here. Try again next time!'.colorize(:red)
291
290
  print_battle_line
292
291
  end
293
292
 
294
- def player_escape?
295
- if (player.dexterity > monster.dexterity)
296
- return true
297
- else
298
- dex_diff = monster.dexterity - player.dexterity
299
- rand_dex = rand(0..dex_diff)
300
- if rand_dex % 2 > 0
293
+ def player_escape?(is_arena)
294
+ unless is_arena
295
+ if (player.dexterity > monster.dexterity)
301
296
  return true
302
297
  else
303
- return false
298
+ dex_diff = monster.dexterity - player.dexterity
299
+ rand_dex = rand(0..dex_diff)
300
+ if rand_dex % 2 > 0
301
+ return true
302
+ else
303
+ return false
304
+ end
304
305
  end
305
306
  end
307
+ return false
306
308
  end
307
309
 
308
310
  # STATUS TEXT
@@ -13,7 +13,8 @@ module Gemwarrior
13
13
  :equipped,
14
14
  :consumable,
15
15
  :use,
16
- :used
16
+ :used,
17
+ :number_of_uses
17
18
 
18
19
  def use(inventory = nil)
19
20
  'That item does not do anything...yet.'
@@ -29,6 +29,7 @@ module Gemwarrior
29
29
  answer = gets.chomp.downcase
30
30
  case answer
31
31
  when 'y', 'yes'
32
+ player.rox -= 50
32
33
  puts 'She pockets the money and motions toward the center of the arena. She reminds you that you will be facing an ever-worsening onslaught of monsters. Each one you dispatch nets you a bonus cache of rox in addition to whatever the monster gives you. You will also become more experienced the longer you last. Finally, you can give up at any time between battles.'
33
34
  puts
34
35
  puts 'She finishes by wishing you good luck!'
@@ -6,18 +6,19 @@ require_relative '../item'
6
6
  module Gemwarrior
7
7
  class Tent < Item
8
8
  def initialize
9
- self.name = 'tent'
10
- self.description = 'A magical, two-room suite pops up when you flick this otherwise folded piece of canvas just right, perfect for a night\'s rest.'
11
- self.atk_lo = nil
12
- self.atk_hi = nil
13
- self.takeable = true
14
- self.useable = true
15
- self.equippable = false
16
- self.equipped = false
9
+ self.name = 'tent'
10
+ self.description = 'A magical, two-room suite pops up when you flick this otherwise folded piece of canvas just right, perfect for a night\'s rest.'
11
+ self.atk_lo = nil
12
+ self.atk_hi = nil
13
+ self.takeable = true
14
+ self.useable = true
15
+ self.equippable = false
16
+ self.equipped = false
17
+ self.number_of_uses = 5
17
18
  end
18
19
 
19
20
  def use(player = nil)
20
- {:type => 'action', :data => 'rest'}
21
+ {:type => 'tent', :data => self.number_of_uses}
21
22
  end
22
23
  end
23
24
  end
@@ -95,7 +95,7 @@ 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)
98
+ def rest(world, tent_uses = nil)
99
99
  cur_loc = world.location_by_coords(cur_coords)
100
100
 
101
101
  if cur_loc.should_spawn_monster?
@@ -120,10 +120,10 @@ module Gemwarrior
120
120
 
121
121
  Animation::run({:phrase => '** Zzzzz **'})
122
122
 
123
- if self.inventory.contains_item?('tent') || world.location_by_coords(cur_coords).has_item?('tent')
123
+ if tent_uses > 0
124
124
  self.hp_cur = self.hp_max
125
125
 
126
- return "You brandish your 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."
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."
127
127
  else
128
128
  self.hp_cur = self.hp_cur.to_i + rand(10..15)
129
129
  self.hp_cur = self.hp_max if self.hp_cur > self.hp_max
@@ -196,7 +196,7 @@ module Gemwarrior
196
196
  battle = Battle.new({:world => world, :player => self, :monster => monster})
197
197
  result = battle.start
198
198
  if result.eql?('death')
199
- return 'exit'
199
+ return 'death'
200
200
  end
201
201
  end
202
202
 
@@ -281,8 +281,8 @@ module Gemwarrior
281
281
 
282
282
  def player_death
283
283
  puts 'Your actions have reduced you to death.'.colorize(:red)
284
- puts 'Your adventure ends here. Try again next time!'.colorize(:red)
285
- return 'exit'
284
+ puts 'Somehow, however, your adventure does not end here. Instead, you are whisked back home via some magical force, a bit worse for the weary and somewhat poorer, but ALIVE!'.colorize(:yellow)
285
+ return 'death'
286
286
  end
287
287
 
288
288
  # TRAVEL
@@ -261,7 +261,36 @@ module Gemwarrior
261
261
  world.player.list_inventory
262
262
  end
263
263
  when 'rest', 'r'
264
- world.player.rest(world)
264
+ tent_uses = 0
265
+ player_inventory = world.player.inventory.items
266
+ location_inventory = world.location_by_coords(world.player.cur_coords).items
267
+
268
+ if player_inventory.map(&:name).include?('tent')
269
+ player_inventory.each do |i|
270
+ if i.name.eql?('tent')
271
+ if i.number_of_uses > 0
272
+ result = i.use(world.player)
273
+ tent_uses = i.number_of_uses
274
+ i.number_of_uses -= 1
275
+
276
+ puts "The tent can be used when resting #{i.number_of_uses} more time(s)."
277
+ end
278
+ end
279
+ end
280
+ elsif location_inventory.map(&:name).include?('tent')
281
+ location_inventory.each do |i|
282
+ if i.name.eql?('tent')
283
+ if i.number_of_uses > 0
284
+ result = i.use(world.player)
285
+ tent_uses = i.number_of_uses
286
+ i.number_of_uses -= 1
287
+
288
+ puts "The tent can be used when resting #{i.number_of_uses} more time(s)."
289
+ end
290
+ end
291
+ end
292
+ end
293
+ world.player.rest(world, tent_uses)
265
294
  when 'look', 'l'
266
295
  if param1
267
296
  world.describe_entity(world.location_by_coords(world.player.cur_coords), param1)
@@ -283,13 +312,21 @@ module Gemwarrior
283
312
 
284
313
  player_inventory = world.player.inventory.items
285
314
  location_inventory = world.location_by_coords(world.player.cur_coords).items
286
-
315
+
287
316
  if player_inventory.map(&:name).include?(item_name)
288
317
  player_inventory.each do |i|
289
318
  if i.name.eql?(item_name)
290
319
  if i.useable
291
- result = i.use(world.player)
292
- if i.consumable
320
+ if !i.number_of_uses.nil?
321
+ if i.number_of_uses > 0
322
+ result = i.use(world.player)
323
+ i.number_of_uses -= 1
324
+ puts "#{i.name} can be used #{i.number_of_uses} more time(s)."
325
+ else
326
+ return "#{i.name} cannot be used anymore."
327
+ end
328
+ elsif i.consumable
329
+ result = i.use(world.player)
293
330
  world.player.inventory.remove_item(i.name)
294
331
  end
295
332
  else
@@ -301,9 +338,17 @@ module Gemwarrior
301
338
  location_inventory.each do |i|
302
339
  if i.name.eql?(item_name)
303
340
  if i.useable
304
- result = i.use(world.player)
305
- if i.consumable
306
- world.location_by_coords(world.player.cur_coords).remove_item(i)
341
+ if !i.number_of_uses.nil?
342
+ if i.number_of_uses > 0
343
+ result = i.use(world.player)
344
+ i.number_of_uses -= 1
345
+ puts "#{i.name} can be used #{i.number_of_uses} more time(s)."
346
+ else
347
+ return "#{i.name} cannot be used anymore."
348
+ end
349
+ elsif i.consumable
350
+ result = i.use(world.player)
351
+ world.player.inventory.remove_item(i.name)
307
352
  end
308
353
  else
309
354
  return ERROR_USE_PARAM_UNUSEABLE
@@ -332,6 +377,8 @@ module Gemwarrior
332
377
  when 'xp'
333
378
  world.player.update_stats({:reason => :xp, :value => result[:data]})
334
379
  return
380
+ when 'tent'
381
+ world.player.rest(world, result[:data])
335
382
  when 'action'
336
383
  case result[:data]
337
384
  when 'rest'
@@ -343,8 +390,8 @@ module Gemwarrior
343
390
  arena = Arena.new({:world => world, :player => world.player})
344
391
  result = arena.start
345
392
 
346
- if result.eql?('exit')
347
- return 'exit'
393
+ if result.eql?('death')
394
+ player_death_resurrection
348
395
  end
349
396
  when 'item'
350
397
  world.location_by_coords(world.player.cur_coords).add_item(result[:data])
@@ -397,7 +444,11 @@ module Gemwarrior
397
444
  monster_name = param1
398
445
  if world.has_monster_to_attack?(monster_name)
399
446
  monster = world.location_by_coords(world.player.cur_coords).monster_by_name(monster_name)
400
- world.player.attack(world, monster)
447
+ result = world.player.attack(world, monster)
448
+
449
+ if result.eql?('death')
450
+ player_death_resurrection
451
+ end
401
452
  else
402
453
  ERROR_ATTACK_PARAM_INVALID
403
454
  end
@@ -435,6 +486,17 @@ module Gemwarrior
435
486
 
436
487
  private
437
488
 
489
+ def player_death_resurrection
490
+ puts 'Somehow, though, your adventure does not end here. Instead, you are whisked back home via some magical force, a bit worse for the weary and somewhat poorer, but ALIVE!'.colorize(:yellow)
491
+ world.player.hp_cur = 1
492
+ world.player.rox -= (world.player.rox * 0.1).to_i
493
+ if world.player.rox < 0
494
+ world.player.rox = 0
495
+ end
496
+ world.player.cur_coords = world.location_coords_by_name('Home')
497
+ world.describe(world.location_by_coords(world.player.cur_coords))
498
+ end
499
+
438
500
  def print_separator
439
501
  puts "========================================================="
440
502
  end
@@ -2,5 +2,5 @@
2
2
  # Version of Gem Warrior
3
3
 
4
4
  module Gemwarrior
5
- VERSION = '0.9.10'
5
+ VERSION = '0.9.12'
6
6
  end
@@ -2,7 +2,6 @@
2
2
  # World where the locations, monsters, items, etc. exist
3
3
 
4
4
  require 'yaml'
5
- require 'pry'
6
5
 
7
6
  require_relative 'entities/item'
8
7
  require_relative 'entities/location'
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.10
4
+ version: 0.9.12
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-20 00:00:00.000000000 Z
11
+ date: 2015-08-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: os