class Rsrb::Item::BonusListener
Attributes
bonus_names[R]
player[R]
Public Class Methods
new(player)
click to toggle source
# File lib/rsrb/model/item.rb, line 197 def initialize(player) @player = player @bonus_names = ['Stab', 'Slash', 'Crush', 'Magic', 'Range', 'Stab', 'Slash', 'Crush', 'Magic', 'Range', 'Strength', 'Prayer'] end
Public Instance Methods
equipment_bonus(id)
click to toggle source
# File lib/rsrb/model/item.rb, line 216 def equipment_bonus(id) bonus = case id when Symbol id when Integer Rsrb::Item::ItemDefinition::PROPERTIES[id + 9] end if bonus player.equipment.items.inject(0) {|sum, item| sum + (item ? item.definition.send(bonus) : 0) } else nil end end
items_changed(container)
click to toggle source
# File lib/rsrb/model/item.rb, line 212 def items_changed(container) update_bonuses end
slot_changed(container, slot)
click to toggle source
# File lib/rsrb/model/item.rb, line 204 def slot_changed(container, slot) update_bonuses end
slots_changed(container, slots)
click to toggle source
# File lib/rsrb/model/item.rb, line 208 def slots_changed(container, slots) update_bonuses end
Private Instance Methods
update_bonuses()
click to toggle source
# File lib/rsrb/model/item.rb, line 233 def update_bonuses offset = 0 for i in 0...12 bonus = equipment_bonus(i) offset = 1 if i == 10 sign = bonus >= 0 ? "+" : "-" @player.io.send_string 1675 + i + offset, "#{bonus_names[i]}: #{sign}#{bonus}" end end