Class: Smite::GodStats
Instance Attribute Summary collapse
Attributes inherited from Object
#data
Instance Method Summary
collapse
Methods inherited from Object
#attributes, #method_missing
Constructor Details
#initialize(god_name, data, params = { level: 1 }) ⇒ GodStats
Returns a new instance of GodStats.
5
6
7
8
9
10
|
# File 'lib/smite/god_stats.rb', line 5
def initialize(god_name, data, params = { level: 1 })
super(data)
@name = god_name
@items = params[:items] || []
@level = (params[:level].to_i - 1) % 20
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class Smite::Object
Instance Attribute Details
Returns the value of attribute items.
3
4
5
|
# File 'lib/smite/god_stats.rb', line 3
def items
@items
end
|
Returns the value of attribute level.
3
4
5
|
# File 'lib/smite/god_stats.rb', line 3
def level
@level
end
|
Returns the value of attribute name.
3
4
5
|
# File 'lib/smite/god_stats.rb', line 3
def name
@name
end
|
Instance Method Details
#at_level(new_level) ⇒ Object
12
13
14
|
# File 'lib/smite/god_stats.rb', line 12
def at_level(new_level)
GodStats.new(name, @data, { level: new_level, items: items })
end
|
#attack_speed ⇒ Object
59
60
61
62
63
64
65
|
# File 'lib/smite/god_stats.rb', line 59
def attack_speed
from_items = item_bonus[:attack_speed]
base = data['attack_speed']
scaling = (attack_speed_per_level * level.to_f).to_i
from_items + base + scaling
end
|
27
28
29
30
31
32
33
|
# File 'lib/smite/god_stats.rb', line 27
def health
from_items = item_bonus[:health]
base = data['health']
scaling = health_per_level * level
from_items + base + scaling
end
|
51
52
53
54
55
56
57
|
# File 'lib/smite/god_stats.rb', line 51
def hp5
from_items = item_bonus[:hp5]
base = data['hp5']
scaling = (hp5_per_level * level.to_f).to_i
from_items + base + scaling
end
|
109
110
111
|
# File 'lib/smite/god_stats.rb', line 109
def inspect
"#<Smite::GodStats '#{name}' Level #{level + 1}>"
end
|
#item_bonus ⇒ Object
91
92
93
94
95
96
97
98
99
100
101
|
# File 'lib/smite/god_stats.rb', line 91
def item_bonus
return @item_bonus unless @item_bonus.nil?
@item_bonus = default_bonus
items.map(&:effects).flatten.select do |effect|
next unless attributes.include?(effect.attribute)
@item_bonus[effect.attribute.to_sym] += effect.amount
end
@item_bonus
end
|
#magic_power ⇒ Object
67
68
69
70
71
72
73
|
# File 'lib/smite/god_stats.rb', line 67
def magic_power
from_items = item_bonus[:magic_power]
base = data['magic_power']
scaling = magic_power_per_level * level
from_items + base + scaling
end
|
#magic_protection ⇒ Object
75
76
77
78
79
80
81
|
# File 'lib/smite/god_stats.rb', line 75
def magic_protection
from_items = item_bonus[:magic_protection]
base = data['magic_protection']
scaling = (magic_protection_per_level * level.to_f).to_i
from_items + base + scaling
end
|
35
36
37
38
39
40
41
|
# File 'lib/smite/god_stats.rb', line 35
def mana
from_items = item_bonus[:mana]
base = data['mana']
scaling = mana_per_level * level
from_items + base + scaling
end
|
#movement_speed ⇒ Object
20
21
22
23
24
25
|
# File 'lib/smite/god_stats.rb', line 20
def movement_speed
from_items = item_bonus[:movement_speed]
base = data['movement_speed']
from_items + base
end
|
43
44
45
46
47
48
49
|
# File 'lib/smite/god_stats.rb', line 43
def mp5
from_items = item_bonus[:mp5]
base = data['mp5']
scaling = (mp5_per_level * level.to_f).to_i
from_items + base + scaling
end
|
#physical_protection ⇒ Object
83
84
85
86
87
88
89
|
# File 'lib/smite/god_stats.rb', line 83
def physical_protection
from_items = item_bonus[:physical_protection]
base = data['physical_protection']
scaling = (physical_protection_per_level * level.to_f).to_i
from_items + base + scaling
end
|
103
104
105
106
107
|
# File 'lib/smite/god_stats.rb', line 103
def summary
attributes.each_with_object({}) do |attr, hash|
hash[attr.to_sym] = send(attr.to_sym)
end
end
|
#with_items(new_items) ⇒ Object
16
17
18
|
# File 'lib/smite/god_stats.rb', line 16
def with_items(new_items)
GodStats.new(name, @data, { level: level, items: new_items })
end
|