class Goby::Item
Can be used by an Entity
in order to trigger anything specified. Placed into the Entity's inventory.
Constants
- DEFAULT_USE_TEXT
Default text when the
Item
doesn't do anything.
Attributes
consumable[RW]
disposable[RW]
name[RW]
price[RW]
Public Class Methods
new(name: "Item", price: 0, consumable: true, disposable: true)
click to toggle source
@param [String] name the name. @param [Integer] price the cost in a shop. @param [Boolean] consumable upon use, the item is lost when true. @param [Boolean] disposable allowed to sell or drop item when true.
# File lib/goby/item/item.rb, line 14 def initialize(name: "Item", price: 0, consumable: true, disposable: true) @name = name @price = price @consumable = consumable @disposable = disposable end
Public Instance Methods
==(rhs)
click to toggle source
@param [Item] rhs the item on the right.
# File lib/goby/item/item.rb, line 30 def ==(rhs) return @name.casecmp(rhs.name).zero? end
to_s()
click to toggle source
@return [String] the name of the Item
.
# File lib/goby/item/item.rb, line 35 def to_s @name end
use(user, entity)
click to toggle source
The function that executes when one uses the item.
@param [Entity] user the one using the item. @param [Entity] entity the one on whom the item is used.
# File lib/goby/item/item.rb, line 25 def use(user, entity) print DEFAULT_USE_TEXT end