class Goby::Weapon
Can be worn in the Player's outfit.
Attributes
attack[RW]
An instance of Attack
.
stat_change[R]
type[R]
Public Class Methods
new(name: "Weapon", price: 0, consumable: false, disposable: true, stat_change: {}, attack: nil)
click to toggle source
@param [String] name the name. @param [Integer] price the cost in a shop. @param [Boolean] consumable determines whether the item is lost when used. @param [Boolean] disposable allowed to sell or drop item when true. @param [Hash] stat_change
the change in stats for when the item is equipped. @param [Attack] attack the attack which is added to the entity's battle commands.
Calls superclass method
Goby::Item::new
# File lib/goby/item/weapon.rb, line 15 def initialize(name: "Weapon", price: 0, consumable: false, disposable: true, stat_change: {}, attack: nil) super(name: name, price: price, consumable: consumable, disposable: disposable) @attack = attack @type = :weapon @stat_change = stat_change end
Public Instance Methods
equip(entity)
click to toggle source
Equips onto the entity and changes the entity's attributes accordingly.
@param [Entity] entity the entity who is equipping the equippable.
Calls superclass method
Goby::Equippable#equip
# File lib/goby/item/weapon.rb, line 25 def equip(entity) prev_weapon = nil if entity.outfit[@type] prev_weapon = entity.outfit[@type] end super(entity) if (prev_weapon && prev_weapon.attack) entity.remove_battle_command(prev_weapon.attack) end if @attack entity.add_battle_command(@attack) end end
unequip(entity)
click to toggle source
Unequips from the entity and changes the entity's attributes accordingly.
@param [Entity] entity the entity who is unequipping the equippable.
Calls superclass method
Goby::Equippable#unequip
# File lib/goby/item/weapon.rb, line 46 def unequip(entity) super(entity) if @attack entity.remove_battle_command(@attack) end end