/
combat_actor.rb
64 lines (54 loc) · 1.32 KB
/
combat_actor.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
module Eretheal
module CombatActor
attr_reader :action
attr_accessor :formula
def set_up
@formula = Eretheal::Formula.new
end
def max_hp
formula.max_hp self
end
def max_mp
formula.max_mp self
end
def attack_speed_with_weapon
speed = 0
if self.class.to_s.downcase.to_sym.in?([:character]) && self.equip.weapon
speed += self.equip.weapon.item.speed
end
self.speed + speed
end
def attack_speed_with_magic
formula.speed self.total_int
end
def speed
formula.speed self.total_agi
end
def weapon_item_type
if self.respond_to? :equip
if self.equip.weapon
return self.equip.weapon.item.weapon_type.key
end
return 'fist'
end
end
def action=(action)
raise unless action.is_a? Action
@action = action
end
[:total_dex, :total_agi, :total_int, :total_vit, :total_str, :total_mnd].each do |key|
status = key.to_s.slice(6,3)
define_method(key) do
bonus = 0
if self.respond_to? :equip
self.equip.each do |key, b|
if b.item.status_adjustment
bonus += b.item.status_adjustment.send(status)
end
end
end
self.send(status) + bonus
end
end
end
end