Merge pull request #149 from thispixel/master

fixes issue #148 - add consumable delays
This commit is contained in:
Gary Tierney
2016-02-01 20:42:02 +00:00
3 changed files with 15 additions and 9 deletions
+8 -4
View File
@@ -8,12 +8,13 @@ CONSUME_ANIMATION_ID = 829
# An item that can be consumed to produce a skill effect.
class Consumable
attr_reader :name, :id, :sound
attr_reader :name, :id, :sound, :delay
def initialize(name, id, sound)
def initialize(name, id, sound, delay)
@name = name.to_s.gsub(/_/, ' ')
@id = id
@sound = sound
@delay = delay
end
def consume(_player)
@@ -44,8 +45,11 @@ class ConsumeAction < Action
@consumable.consume(mob)
mob.play_animation(Animation.new(CONSUME_ANIMATION_ID))
@executions += 1
else
end
@executions += 1
if @executions >= @consumable.delay
stop
end
end
+4 -4
View File
@@ -13,8 +13,8 @@ EAT_FOOD_SOUND = 317
# TODO: delay eating times
class Food < Consumable
def initialize(name, id, restoration, replace)
super(name, id, EAT_FOOD_SOUND)
def initialize(name, id, restoration, replace, delay)
super(name, id, EAT_FOOD_SOUND, delay)
@restoration = restoration
@replace = replace
end
@@ -48,7 +48,7 @@ def food(hash)
replace = hash[:replace] || -1
delay = hash[:delay] || DEFAULT_DELAY # TODO: ??
append_consumable(Food.new(name, id, restoration, replace))
append_consumable(Food.new(name, id, restoration, replace, delay))
end
# TODO: special effects
@@ -88,7 +88,7 @@ food name: :bass, id: 365, restoration: 13
food name: :swordfish, id: 373, restoration: 14
food name: :cooked_jubbly, id: 7568, restoration: 15
food name: :monkfish, id: 7946, restoration: 16
food name: :cooked_karambwan, id: 3144, restoration: 18
food name: :cooked_karambwan, id: 3144, restoration: 18, delay: 0
food name: :shark, id: 385, restoration: 20
food name: :sea_turtle, id: 397, restoration: 21
food name: :manta_ray, id: 391, restoration: 22
+3 -1
View File
@@ -13,13 +13,15 @@ module Constants
# The id of an empty vial.
EMPTY_VIAL_ID = 229
# The delay between drinking potions
POTION_DELAY = 2
end
# A drinkable potion.
class Potion < Consumable
def initialize(id, name, doses)
super(name, id, Constants::DRINK_POTION_SOUND)
super(name, id, Constants::DRINK_POTION_SOUND, Constants::POTION_DELAY)
@doses = doses
end