gemwarrior 0.9.18 → 0.9.19

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: 53393163dfd7c1df6f5b427327a787d89aacf1a3
4
- data.tar.gz: a24431d39a3de934548a6e8ab96f05f306dfbeaf
3
+ metadata.gz: 6fa970470b56b3fca1a179770c50bad1f38a1f57
4
+ data.tar.gz: 96e1f509bf41a79603c9347503bf7241b32f78e0
5
5
  SHA512:
6
- metadata.gz: d99e795c05edae152924acc563331b553dc0019ddde046b8bf59bc75ec4cbbf6d81c92e186a9134223e00424d4304ec820693c9197d69529a7cbff36fdafc5c6
7
- data.tar.gz: cf565870e51de63d5a7d0799800c02a04bed8b65f569fb6565cc8cc7e89685da2279b6252e26ba4ce600bda92f341d0cb9124e86f889317986c6377b91673a20
6
+ metadata.gz: 682e6ea04e48e876382c1a6c20853dbc6aa574aa8c06129b27f9fff075507f11e062e60a4cce06a0ee896cc6d0b055572d1c8842c5dcc69abc6f85acd61c3d77
7
+ data.tar.gz: 6ff0815d861be3ad5fee9e1671e9906956637564ebc8ed8b7215f967ac3a68ae886e8069f4da561c87cf04920bd6729864bdf3f6f3523582241c41533a98bbb8
@@ -3,6 +3,9 @@
3
3
 
4
4
  module Gemwarrior
5
5
  class Entity
6
+ # CONSTANTS
7
+ WRAP_WIDTH = 80
8
+
6
9
  attr_accessor :name,
7
10
  :description
8
11
 
@@ -10,5 +13,9 @@ module Gemwarrior
10
13
  status_text = name.ljust(26).upcase.colorize(:green)
11
14
  status_text << "#{description}\n".colorize(:white)
12
15
  end
16
+
17
+ def puts(s='', width=WRAP_WIDTH)
18
+ super s.gsub(/(.{1,#{width}})(\s+|\Z)/, "\\1\n") unless s.nil?
19
+ end
13
20
  end
14
21
  end
@@ -17,10 +17,15 @@ module Gemwarrior
17
17
  end
18
18
 
19
19
  def use(player = nil)
20
- Animation::run({:phrase => '** ZZZZZ **'})
21
- puts 'You unmake the bed, get under the covers, close your eyes, and begin to think about all the things you need to do today. You realize sleep is not one of them and quickly get back up, remake the bed, and get on about your day.'
22
- puts '>> You regain a few hit points.'
23
- {:type => 'rest', :data => 5}
20
+ if player.at_full_hp?
21
+ puts 'You feel perfectly healthy and decide not to actually use the bed. Besides, the trail of fire ants currently leading up to and around the furniture seem somehow uninviting.'
22
+ {:type => nil, :data => nil}
23
+ else
24
+ Animation::run({:phrase => '** ZZZZZ **'})
25
+ puts 'You unmake the bed, get under the covers, close your eyes, and begin to think about all the things you need to do today. You realize sleep is not one of them and quickly get back up, remake the bed, and get on about your day.'
26
+ puts '>> You regain a few hit points.'
27
+ {:type => 'rest', :data => 5}
28
+ end
24
29
  end
25
30
  end
26
31
  end
@@ -18,9 +18,14 @@ module Gemwarrior
18
18
  end
19
19
 
20
20
  def use(player = nil)
21
- puts 'You place the herb in your mouth, testing its texture. The mysterious herb is easily chewable, and you are able to swallow it without much effort. Slight tingles travel up and down your spine.'
22
- puts '>> You regain a few hit points.'
23
- {:type => 'health', :data => rand(3..5)}
21
+ puts 'You place the entire, smallish plant in your mouth, testing its texture. The mysterious herb is easily chewable, and you are able to swallow it without much effort. Slight tingles travel up and down your spine.'
22
+ if player.at_full_hp?
23
+ puts '>> The herb has no medicinal effect, as you already feel perfectly healthy, but it was kind of tasty.'
24
+ {:type => nil, :data => nil}
25
+ else
26
+ puts '>> You regain a few hit points.'
27
+ {:type => 'health', :data => rand(3..5)}
28
+ end
24
29
  end
25
30
  end
26
31
  end
@@ -129,17 +129,25 @@ module Gemwarrior
129
129
  mins_text = minutes == 1 ? 'minute' : 'minutes'
130
130
  secs_text = seconds == 1 ? 'second' : 'seconds'
131
131
 
132
- Animation::run({:phrase => '** Zzzzz **'})
133
-
134
132
  if tent_uses > 0
135
- self.hp_cur = self.hp_max
136
-
137
- 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."
133
+ if self.at_full_hp?
134
+ puts 'Despite feeling just fine, health-wise, you decide to set up camp for the ni--well, actually, after a few minutes you realize you don\'t need to sleep and pack things up again, ready to go.'
135
+ else
136
+ Animation::run({:phrase => '** Zzzzz **'})
137
+ 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."
138
+ self.hp_cur = self.hp_max
139
+ end
138
140
  else
139
- self.hp_cur = self.hp_cur.to_i + rand(10..15)
140
- self.hp_cur = self.hp_max if self.hp_cur > self.hp_max
141
-
142
- 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}."
141
+ if self.at_full_hp?
142
+ Animation::run({:phrase => '** Hmmmm **'})
143
+ puts 'You sit down on the ground, make some notes on the back of your hand, test the air, and then return to standing, back at it all again.'
144
+ else
145
+ Animation::run({:phrase => '** Zzzzz **'})
146
+ 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}."
147
+
148
+ self.hp_cur = self.hp_cur.to_i + rand(10..15)
149
+ self.hp_cur = self.hp_max if self.hp_cur > self.hp_max
150
+ end
143
151
  end
144
152
  end
145
153
 
@@ -202,6 +210,10 @@ module Gemwarrior
202
210
  # stats
203
211
  self.movements_made += 1
204
212
  end
213
+
214
+ def at_full_hp?
215
+ self.hp_cur == self.hp_max
216
+ end
205
217
 
206
218
  def attack(world, monster)
207
219
  battle = Battle.new({:world => world, :player => self, :monster => monster})
@@ -433,7 +433,7 @@ module Gemwarrior
433
433
  if param1.nil?
434
434
  ERROR_DROP_PARAM_MISSING
435
435
  else
436
- world.player.inventory.remove_item(param1)
436
+ world.player.inventory.drop_item(param1)
437
437
  end
438
438
  when 'equip', 'e'
439
439
  if param1.nil?
@@ -520,6 +520,7 @@ module Gemwarrior
520
520
  world.player.cur_coords = world.location_coords_by_name('Home')
521
521
  world.describe(world.location_by_coords(world.player.cur_coords))
522
522
  world.player.deaths += 1
523
+ return
523
524
  end
524
525
 
525
526
  def print_separator
@@ -100,15 +100,19 @@ module Gemwarrior
100
100
  end
101
101
 
102
102
  def remove_item(item_name)
103
+ items.delete_at(items.map(&:name).index(item_name) || items.length)
104
+ unless self.weapon.nil?
105
+ self.weapon = nil if self.weapon.name.eql?(item_name)
106
+ end
107
+ end
108
+
109
+ def drop_item(item_name)
103
110
  if contains_item?(item_name)
104
111
  puts "Are you sure you want to permanently throw away #{item_name}? (Y/N)"
105
112
  answer = gets.downcase.chomp!
106
113
 
107
114
  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
115
+ remove_item(item_name)
112
116
 
113
117
  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
118
  else
@@ -2,5 +2,5 @@
2
2
  # Version of Gem Warrior
3
3
 
4
4
  module Gemwarrior
5
- VERSION = '0.9.18'
5
+ VERSION = '0.9.19'
6
6
  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.18
4
+ version: 0.9.19
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-07 00:00:00.000000000 Z
11
+ date: 2015-08-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: os