Class: FifthedSim::Actor::DefinitionProxy
- Inherits:
-
Object
- Object
- FifthedSim::Actor::DefinitionProxy
- Defined in:
- lib/fifthed_sim/actor.rb
Instance Attribute Summary collapse
-
#attrs ⇒ Object
readonly
Returns the value of attribute attrs.
Instance Method Summary collapse
- #attack(name, &block) ⇒ Object
- #base_ac(num) ⇒ Object
-
#initialize(name, &block) ⇒ DefinitionProxy
constructor
A new instance of DefinitionProxy.
- #spell(name, &block) ⇒ Object
- #stats(n = nil, &block) ⇒ Object
Constructor Details
#initialize(name, &block) ⇒ DefinitionProxy
Returns a new instance of DefinitionProxy.
4 5 6 7 8 9 10 11 12 |
# File 'lib/fifthed_sim/actor.rb', line 4 def initialize(name, &block) @attrs = { name: name, attacks: {}, spells: {}, base_ac: 10 } instance_eval(&block) end |
Instance Attribute Details
#attrs ⇒ Object (readonly)
Returns the value of attribute attrs.
14 15 16 |
# File 'lib/fifthed_sim/actor.rb', line 14 def attrs @attrs end |
Instance Method Details
#attack(name, &block) ⇒ Object
16 17 18 19 20 21 22 23 24 |
# 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) ⇒ Object
46 47 48 |
# File 'lib/fifthed_sim/actor.rb', line 46 def base_ac(num) @attrs[:base_ac] = num end |
#spell(name, &block) ⇒ Object
26 27 28 29 30 31 32 33 34 |
# 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 |