Class: FifthedSim::Actor
- Inherits:
-
Object
- Object
- FifthedSim::Actor
- Defined in:
- lib/fifthed_sim/actor.rb
Defined Under Namespace
Classes: DefinitionProxy
Constant Summary collapse
- ASSIGNABLE_ATTRS =
[:base_ac, :name, :attacks, :spells]
Instance Attribute Summary collapse
-
#attacks ⇒ Object
readonly
Returns the value of attribute attacks.
-
#base_ac ⇒ Object
readonly
Returns the value of attribute base_ac.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#spells ⇒ Object
readonly
Returns the value of attribute spells.
Class Method Summary collapse
Instance Method Summary collapse
-
#ac ⇒ Object
TODO: Implement armor.
-
#initialize(attrs) ⇒ Actor
constructor
A new instance of Actor.
- #random_attack ⇒ Object
Constructor Details
#initialize(attrs) ⇒ Actor
Returns a new instance of Actor.
60 61 62 63 |
# File 'lib/fifthed_sim/actor.rb', line 60 def initialize(attrs) attrs.to_a.keep_if{ |(k, v)| ASSIGNABLE_ATTRS.include?(v) } .each { |(k, v)| self.instance_variable_set("@#{k}", v) } end |
Instance Attribute Details
#attacks ⇒ Object (readonly)
Returns the value of attribute attacks.
75 76 77 |
# File 'lib/fifthed_sim/actor.rb', line 75 def attacks @attacks end |
#base_ac ⇒ Object (readonly)
Returns the value of attribute base_ac.
75 76 77 |
# File 'lib/fifthed_sim/actor.rb', line 75 def base_ac @base_ac end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
75 76 77 |
# File 'lib/fifthed_sim/actor.rb', line 75 def name @name end |
#spells ⇒ Object (readonly)
Returns the value of attribute spells.
75 76 77 |
# File 'lib/fifthed_sim/actor.rb', line 75 def spells @spells end |
Class Method Details
.define(name, &block) ⇒ Object
51 52 53 54 |
# File 'lib/fifthed_sim/actor.rb', line 51 def self.define(name, &block) d = DefinitionProxy.new(name, &block) return self.new(d.attrs) end |
Instance Method Details
#ac ⇒ Object
TODO: Implement armor
71 72 73 |
# File 'lib/fifthed_sim/actor.rb', line 71 def ac base_ac end |
#random_attack ⇒ Object
65 66 67 |
# File 'lib/fifthed_sim/actor.rb', line 65 def random_attack @attacks.keys.sample end |