Class: FifthedSim::Attack::DefinitionProxy

Inherits:
Object
  • Object
show all
Defined in:
lib/fifthed_sim/attack.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, &block) ⇒ DefinitionProxy

Returns a new instance of DefinitionProxy.



7
8
9
10
11
12
13
14
15
16
# File 'lib/fifthed_sim/attack.rb', line 7

def initialize(name, &block)
  @attrs = {
    name: name,
    to_hit: 0,
    damage: nil,
    crit_threshold: 20,
    crit_damage: nil
  }
  instance_eval(&block)
end

Instance Attribute Details

#attrsObject (readonly)

Returns the value of attribute attrs.



18
19
20
# File 'lib/fifthed_sim/attack.rb', line 18

def attrs
  @attrs
end

Instance Method Details

#crit_damage(arg = nil, &block) ⇒ Object



33
34
35
36
37
38
39
# File 'lib/fifthed_sim/attack.rb', line 33

def crit_damage(arg = nil, &block)
  if block_given?
    @attrs[:crit_damage] = Damage.define(&block)
  else
    damage_check(arg)
  end
end

#crit_threshold(thr) ⇒ Object



41
42
43
# File 'lib/fifthed_sim/attack.rb', line 41

def crit_threshold(thr)
  @attrs[:crit_threshold] = thr
end

#damage(arg = nil, &block) ⇒ Object



24
25
26
27
28
29
30
31
# File 'lib/fifthed_sim/attack.rb', line 24

def damage(arg = nil, &block)
  if block_given?
    @attrs[:damage] = Damage.define(&block)
  else
    damage_check(arg)
    @attrs[:damage] = arg
  end
end

#to_hit(num) ⇒ Object



20
21
22
# File 'lib/fifthed_sim/attack.rb', line 20

def to_hit(num)
  @attrs[:to_hit] = num
end