Class: FifthedSim::Spell

Inherits:
Object
  • Object
show all
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

Class Method Summary collapse

Instance Method Summary collapse

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_dcObject (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_typeObject (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_damageObject



66
67
68
# File 'lib/fifthed_sim/spell.rb', line 66

def raw_damage
  @damage.raw
end

#raw_save_damageObject



70
71
72
# File 'lib/fifthed_sim/spell.rb', line 70

def raw_save_damage
  @save_damage.raw
end