mirror of
https://github.com/2006-Scape/apollo.git
synced 2026-07-05 16:49:04 +00:00
@@ -6,15 +6,22 @@ CONSUMABLES = {}
|
|||||||
# The id of the food consumption animation.
|
# The id of the food consumption animation.
|
||||||
CONSUME_ANIMATION_ID = 829
|
CONSUME_ANIMATION_ID = 829
|
||||||
|
|
||||||
|
# Contains the different types of consumables
|
||||||
|
module ConsumableType
|
||||||
|
FOOD = 1
|
||||||
|
POTION = 2
|
||||||
|
end
|
||||||
|
|
||||||
# An item that can be consumed to produce a skill effect.
|
# An item that can be consumed to produce a skill effect.
|
||||||
class Consumable
|
class Consumable
|
||||||
attr_reader :name, :id, :sound, :delay
|
attr_reader :name, :id, :sound, :delay, :type
|
||||||
|
|
||||||
def initialize(name, id, sound, delay)
|
def initialize(name, id, sound, delay, type)
|
||||||
@name = name.to_s.gsub(/_/, ' ')
|
@name = name.to_s.gsub(/_/, ' ')
|
||||||
@id = id
|
@id = id
|
||||||
@sound = sound
|
@sound = sound
|
||||||
@delay = delay
|
@delay = delay
|
||||||
|
@type = type
|
||||||
end
|
end
|
||||||
|
|
||||||
def consume(_player)
|
def consume(_player)
|
||||||
@@ -55,7 +62,7 @@ class ConsumeAction < Action
|
|||||||
end
|
end
|
||||||
|
|
||||||
def equals(other)
|
def equals(other)
|
||||||
mob == other.mob
|
mob == other.mob && @consumable.type == other.consumable.type
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ EAT_FOOD_SOUND = 317
|
|||||||
class Food < Consumable
|
class Food < Consumable
|
||||||
|
|
||||||
def initialize(name, id, restoration, replace, delay)
|
def initialize(name, id, restoration, replace, delay)
|
||||||
super(name, id, EAT_FOOD_SOUND, delay)
|
super(name, id, EAT_FOOD_SOUND, delay, ConsumableType::FOOD)
|
||||||
@restoration = restoration
|
@restoration = restoration
|
||||||
@replace = replace
|
@replace = replace
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ end
|
|||||||
class Potion < Consumable
|
class Potion < Consumable
|
||||||
|
|
||||||
def initialize(id, name, doses)
|
def initialize(id, name, doses)
|
||||||
super(name, id, Constants::DRINK_POTION_SOUND, Constants::POTION_DELAY)
|
super(name, id, Constants::DRINK_POTION_SOUND, Constants::POTION_DELAY, ConsumableType::POTION)
|
||||||
@doses = doses
|
@doses = doses
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user