This commit is contained in:
Major-
2014-02-24 08:02:33 +00:00
parent a325cd1d09
commit a5c95015b4
3 changed files with 6 additions and 8 deletions
+1
View File
@@ -50,6 +50,7 @@ class ConsumeAction < Action
def equals(other)
return (mob == other.mob && @consumable.id == other.consumable.id)
end
end
# Intercepts the first item option event and consumes the consumable, if necessary.
+1 -2
View File
@@ -19,8 +19,7 @@ class Food < Consumable
# Restore the appropriate amount of hitpoints when consumed.
def consume(player)
hitpoints = player.skill_set.skill(HITPOINTS_SKILL_ID)
new_curr = hitpoints.current_level + @restoration
new_curr = hitpoints.maximum_level if new_curr > hitpoints.maximum_level
new_curr = [ hitpoints.current_level + @restoration, hitpoints.maximum_level ].min
player.skill_set.set_skill(HITPOINTS_SKILL_ID, Skill.new(hitpoints.experience, new_curr, hitpoints.maximum_level))
player.send_message("You eat the #{name}.", true)
+4 -6
View File
@@ -13,7 +13,7 @@ class Potion < Consumable
end
def consume(player)
index = @doses.find_index(@id)
index = @doses.find_index(id)
unless index + 1 == @doses.length
player.inventory.add(@doses[index + 1])
@@ -44,9 +44,8 @@ class BoostingPotion < Potion
def drink(player)
@skill_ids.each do |id|
skill = player.skill_set.skill(id); current = skill.current_level; max = skill.maximum_level
level = current > max ? max : current
skill = player.skill_set.skill(id); max = skill.maximum_level
level = [ skill.current_level, max ].min
new_current = @boost.call(max, level).floor
player.skill_set.set_skill(id, Skill.new(skill.experience, new_current, max))
@@ -68,10 +67,9 @@ end
# Appends a potion to the list of consumables.
def append_potion(hash)
regular_potion = (hash.size == 2)
class_name = 'Potion'; keys = [ :name, :doses ]
unless regular_potion
unless (hash.size == 2)
keys << :skills << :boost
class_name.insert(0, 'Boosting')
end