Class: FifthedSim::Spell
- Inherits:
-
Object
- Object
- FifthedSim::Spell
- Defined in:
- lib/fifthed_sim/spell.rb
Overview
Spells model save-or-take-damage stuff. At some point in the future I hope to modify them so they work as other stu
Defined Under Namespace
Classes: DefinitionProxy
Instance Attribute Summary collapse
-
#save_dc ⇒ Object
readonly
Returns the value of attribute save_dc.
-
#save_type ⇒ Object
readonly
Returns the value of attribute save_type.
Class Method Summary collapse
Instance Method Summary collapse
- #against(other) ⇒ Object
-
#initialize(hash) ⇒ Spell
constructor
A new instance of Spell.
- #raw_damage ⇒ Object
- #raw_save_damage ⇒ Object
Constructor Details
#initialize(hash) ⇒ Spell
Returns a new instance of Spell.
45 46 47 48 49 50 51 |
# File 'lib/fifthed_sim/spell.rb', line 45 def initialize(hash) @name = hash[:name] @damage = hash[:damage] @save_damage = hash[:save_damage] @save_type = hash[:save_type] @save_dc = hash[:save_dc] end |
Instance Attribute Details
#save_dc ⇒ Object (readonly)
Returns the value of attribute save_dc.
53 54 55 |
# File 'lib/fifthed_sim/spell.rb', line 53 def save_dc @save_dc end |
#save_type ⇒ Object (readonly)
Returns the value of attribute save_type.
53 54 55 |
# File 'lib/fifthed_sim/spell.rb', line 53 def save_type @save_type end |
Class Method Details
.define(name, &block) ⇒ Object
40 41 42 43 |
# File 'lib/fifthed_sim/spell.rb', line 40 def self.define(name, &block) h = DefinitionProxy.new(name, &block).attrs self.new(h) end |
Instance Method Details
#against(other) ⇒ Object
56 57 58 59 60 61 62 63 64 |
# File 'lib/fifthed_sim/spell.rb', line 56 def against(other) other.saving_throw(@save_type).test_then do |res| if res >= @save_dc @save_damage.to(other) else @damage.to(other) end end end |
#raw_damage ⇒ Object
66 67 68 |
# File 'lib/fifthed_sim/spell.rb', line 66 def raw_damage @damage.raw end |
#raw_save_damage ⇒ Object
70 71 72 |
# File 'lib/fifthed_sim/spell.rb', line 70 def raw_save_damage @save_damage.raw end |