class FifthedSim::Actor::DefinitionProxy
Attributes
attrs[R]
Public Class Methods
new(name, &block)
click to toggle source
# File lib/fifthed_sim/actor.rb, line 4 def initialize(name, &block) @attrs = { name: name, attacks: {}, spells: {}, base_ac: 10 } instance_eval(&block) end
Public Instance Methods
attack(name, &block)
click to toggle source
# File lib/fifthed_sim/actor.rb, line 16 def attack(name, &block) if block_given? && name.is_a?(String) @attrs[:attacks][name] = Attack.define(name, &block) elsif name.is_a?(Attack) @attrs[:attacks][name.name] << name else raise ArgumentError, "must be an attack" end end
base_ac(num)
click to toggle source
# File lib/fifthed_sim/actor.rb, line 46 def base_ac(num) @attrs[:base_ac] = num end
spell(name, &block)
click to toggle source
# File lib/fifthed_sim/actor.rb, line 26 def spell(name, &block) if block_given? && name.is_a?(String) @attrs[:spells][name] = Spell.define(name, &block) elsif name.is_a?(Spell) @attrs[:spells][name.name] << name else raise ArgumentError, "must be a spell" end end
stats(n = nil, &block)
click to toggle source
# File lib/fifthed_sim/actor.rb, line 36 def stats(n = nil, &block) if n && n.is_a?(StatBlock) @attrs[:stats] = n elsif block @attrs[:stats] = StatBlock.define(&block) else raise ArgumentError, "Must be a statblock" end end