summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/models/character.rb29
1 files changed, 8 insertions, 21 deletions
diff --git a/app/models/character.rb b/app/models/character.rb
index b06220b..42f5f10 100644
--- a/app/models/character.rb
+++ b/app/models/character.rb
@@ -170,19 +170,6 @@ class Character < ApplicationRecord
self.title_awards.create(title: title)
end
- def equipment_stats
- stats = {}
- self.equipment.each do |eq|
- eq.item.whatnot[:equip_effects]&.each do |effect|
- if effect[:type] == "stat_change"
- stats[effect[:gid]] ||= 0
- stats[effect[:gid]] += effect[:modifier]
- end
- end
- end
- stats
- end
-
def effects
# TODO: Review this filter_map to see if it can be simplified
hearth_amenity_effects = self.hearth.built_hearth_amenities.filter_map { |a| a.effects if a.effects }
@@ -199,19 +186,19 @@ class Character < ApplicationRecord
end
def max_wounds
- 1 + total_stat_change("max_wounds")
+ [1 + total_stat_change("max_wounds"), 0].max
end
def max_hp
- 9 + self.beastslay_level + (equipment_stats["max_hp"] || 0)
+ [9 + self.beastslay_level + total_stat_change("max_hp"), 1].max
end
def speed
- self.beastslay_level + (equipment_stats["speed"] || 0)
+ [self.beastslay_level + total_stat_change("speed"), 0].max
end
def accuracy(with_combat_style: false)
- base = self.beastslay_level + (equipment_stats["accuracy"] || 0)
+ base = [self.beastslay_level + total_stat_change("accuracy"), 0].max
if with_combat_style && self.precise?
base = (base * 1.25).floor
elsif with_combat_style && self.brutal?
@@ -221,7 +208,7 @@ class Character < ApplicationRecord
end
def power(with_combat_style: false)
- base = self.beastslay_level + (equipment_stats["power"] || 0)
+ base = [self.beastslay_level + total_stat_change("power"), 0].max
if with_combat_style && self.precise?
base = (base * 0.75).ceil
elsif with_combat_style && self.brutal?
@@ -231,7 +218,7 @@ class Character < ApplicationRecord
end
def evasion(with_combat_style: false)
- base = self.beastslay_level + (equipment_stats["evasion"] || 0)
+ base = [self.beastslay_level + total_stat_change("evasion"), 0].max
if with_combat_style && self.elusive?
base = (base * 1.25).floor
elsif with_combat_style && self.protective?
@@ -241,7 +228,7 @@ class Character < ApplicationRecord
end
def block(with_combat_style: false)
- base = self.beastslay_level + (equipment_stats["block"] || 0)
+ base = [self.beastslay_level + total_stat_change("block"), 0].max
if with_combat_style && self.elusive?
base = (base * 0.75).ceil
elsif with_combat_style && self.protective?
@@ -251,7 +238,7 @@ class Character < ApplicationRecord
end
def block_value
- equipment_stats["block_value"] || 0
+ [total_stat_change("block_value"), 0].max
end
private