class FifthedSim::Attack::DefinitionProxy
Attributes
attrs[R]
Public Class Methods
new(name, &block)
click to toggle source
# File lib/fifthed_sim/attack.rb, line 7 def initialize(name, &block) @attrs = { name: name, to_hit: 0, damage: nil, crit_threshold: 20, crit_damage: nil } instance_eval(&block) end
Public Instance Methods
crit_damage(arg = nil, &block)
click to toggle source
# File lib/fifthed_sim/attack.rb, line 33 def crit_damage(arg = nil, &block) if block_given? @attrs[:crit_damage] = Damage.define(&block) else damage_check(arg) end end
crit_threshold(thr)
click to toggle source
# File lib/fifthed_sim/attack.rb, line 41 def crit_threshold(thr) @attrs[:crit_threshold] = thr end
damage(arg = nil, &block)
click to toggle source
# File lib/fifthed_sim/attack.rb, line 24 def damage(arg = nil, &block) if block_given? @attrs[:damage] = Damage.define(&block) else damage_check(arg) @attrs[:damage] = arg end end
to_hit(num)
click to toggle source
# File lib/fifthed_sim/attack.rb, line 20 def to_hit(num) @attrs[:to_hit] = num end
Protected Instance Methods
damage_check(arg)
click to toggle source
# File lib/fifthed_sim/attack.rb, line 46 def damage_check(arg) unless arg.is_a? Damage raise TypeError, "#{arg.inspect} is not Damage" end end