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 +4 -4
- data/lib/gemwarrior/arena.rb +2 -1
- data/lib/gemwarrior/battle.rb +13 -11
- data/lib/gemwarrior/entities/item.rb +2 -1
- data/lib/gemwarrior/entities/items/arena_master.rb +1 -0
- data/lib/gemwarrior/entities/items/tent.rb +10 -9
- data/lib/gemwarrior/entities/player.rb +6 -6
- data/lib/gemwarrior/evaluator.rb +72 -10
- data/lib/gemwarrior/version.rb +1 -1
- data/lib/gemwarrior/world.rb +0 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 30320b17fc348bcf979a232b45e942b2760a6f7d
|
4
|
+
data.tar.gz: 33a63526a76eeb98fae273542b3a55fbfb9b0287
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9c795a7c3823054838aa6e8149a37e320124736e112abb7cfc47db8aa58684addf7830e412c6efd04d167fee7719634ce75e24548786c899c20c03ea2a33fb7a
|
7
|
+
data.tar.gz: ee7df37798af7556b855ad3c8fb639cd19514d6d1d45ed719f26c72c35543ea89efa25132cbe79f6deb44a15a09db84e52859a5c68ac58d42b7e97b571af98d0
|
data/lib/gemwarrior/arena.rb
CHANGED
@@ -24,11 +24,12 @@ module Gemwarrior
|
|
24
24
|
result = battle.start(is_arena = true)
|
25
25
|
|
26
26
|
if result.eql?('death')
|
27
|
-
return '
|
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
|
|
data/lib/gemwarrior/battle.rb
CHANGED
@@ -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
|
-
|
296
|
-
|
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
|
-
|
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
|
@@ -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
|
10
|
-
self.description
|
11
|
-
self.atk_lo
|
12
|
-
self.atk_hi
|
13
|
-
self.takeable
|
14
|
-
self.useable
|
15
|
-
self.equippable
|
16
|
-
self.equipped
|
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 => '
|
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
|
123
|
+
if tent_uses > 0
|
124
124
|
self.hp_cur = self.hp_max
|
125
125
|
|
126
|
-
return "You brandish
|
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 '
|
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 '
|
285
|
-
return '
|
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
|
data/lib/gemwarrior/evaluator.rb
CHANGED
@@ -261,7 +261,36 @@ module Gemwarrior
|
|
261
261
|
world.player.list_inventory
|
262
262
|
end
|
263
263
|
when 'rest', 'r'
|
264
|
-
|
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
|
-
|
292
|
-
|
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
|
-
|
305
|
-
|
306
|
-
|
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?('
|
347
|
-
|
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
|
data/lib/gemwarrior/version.rb
CHANGED
data/lib/gemwarrior/world.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2015-08-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: os
|