diff --git a/data/plugins/consumables/consumable.rb b/data/plugins/consumables/consumable.rb index ac282034..177dc15c 100644 --- a/data/plugins/consumables/consumable.rb +++ b/data/plugins/consumables/consumable.rb @@ -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. diff --git a/data/plugins/consumables/food.rb b/data/plugins/consumables/food.rb index c08711a5..2aa87a3a 100644 --- a/data/plugins/consumables/food.rb +++ b/data/plugins/consumables/food.rb @@ -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) diff --git a/data/plugins/consumables/potions.rb b/data/plugins/consumables/potions.rb index aa74a914..d12a866e 100644 --- a/data/plugins/consumables/potions.rb +++ b/data/plugins/consumables/potions.rb @@ -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