class FifthedSim::Damage
Public Class Methods
define(&block)
click to toggle source
# File lib/fifthed_sim/damage.rb, line 22 def self.define(&block) h = DefinitionProxy.new(&block).attrs self.new(h) end
new(hash)
click to toggle source
# File lib/fifthed_sim/damage.rb, line 27 def initialize(hash) @hash = hash end
Public Instance Methods
raw()
click to toggle source
# File lib/fifthed_sim/damage.rb, line 50 def raw @hash.values.inject{|s, k| s + k} end
to(enemy)
click to toggle source
Obtain a dice roll of how much damage we're doing to a particular enemy
# File lib/fifthed_sim/damage.rb, line 33 def to(enemy) mapped = @hash.map do |k, v| if enemy.immune_to?(k) 0.to_dice_expression elsif enemy.resistant_to?(k) (v / 2) else v end end if mapped.empty? 0.to_dice_expression else mapped.inject{|memo, x| memo + x} end end