diff options
-rw-r--r-- | app/models/character.rb | 10 | ||||
-rw-r--r-- | app/models/equipment.rb | 4 | ||||
-rw-r--r-- | data/hearth_amenities.yml | 6 | ||||
-rw-r--r-- | data/items.yml | 14 |
4 files changed, 20 insertions, 14 deletions
diff --git a/app/models/character.rb b/app/models/character.rb index 1ff0a06..b06220b 100644 --- a/app/models/character.rb +++ b/app/models/character.rb @@ -174,7 +174,7 @@ class Character < ApplicationRecord stats = {} self.equipment.each do |eq| eq.item.whatnot[:equip_effects]&.each do |effect| - if effect[:type] == "stat" + if effect[:type] == "stat_change" stats[effect[:gid]] ||= 0 stats[effect[:gid]] += effect[:modifier] end @@ -185,11 +185,13 @@ class Character < ApplicationRecord def effects # TODO: Review this filter_map to see if it can be simplified - self.hearth.built_hearth_amenities.filter_map { |a| a.effects if a.effects }.flatten + hearth_amenity_effects = self.hearth.built_hearth_amenities.filter_map { |a| a.effects if a.effects } + equipment_effects = self.equipment.filter_map { |a| a.effects if a.effects } + (hearth_amenity_effects + equipment_effects).flatten end - def total_stat_change(stat) - effects.filter_map { |e| e[:modifier] if e[:type] == "stat_change" && e[:stat] == stat }.sum + def total_stat_change(gid) + effects.filter_map { |e| e[:modifier] if e[:type] == "stat_change" && e[:gid] == gid }.sum end def can_fight? diff --git a/app/models/equipment.rb b/app/models/equipment.rb index 11030fd..ce3822c 100644 --- a/app/models/equipment.rb +++ b/app/models/equipment.rb @@ -8,4 +8,8 @@ class Equipment < ApplicationRecord def slot self[:slot].to_sym end + + def effects + self.item.whatnot[:equip_effects] + end end diff --git a/data/hearth_amenities.yml b/data/hearth_amenities.yml index d6dca76..fd090c8 100644 --- a/data/hearth_amenities.yml +++ b/data/hearth_amenities.yml @@ -17,7 +17,7 @@ forge: effects: - type: "stat_change" level: 2 - stat: "otherforge_speed" + gid: "otherforge_speed" modifier: 4 labratory: name: "Labratory" @@ -31,7 +31,7 @@ labratory: effects: - type: "stat_change" level: 2 - stat: "fluxseethe_speed" + gid: "fluxseethe_speed" modifier: 4 listern_font: name: "Listern Font" @@ -50,5 +50,5 @@ listern_font: effects: - type: "stat_change" level: 2 - stat: "max_wounds" + gid: "max_wounds" modifier: 1 diff --git a/data/items.yml b/data/items.yml index 2c00f61..c153b57 100644 --- a/data/items.yml +++ b/data/items.yml @@ -35,10 +35,10 @@ iron_dagger: equip_slots: - "mainhand" equip_effects: - - type: "stat" + - type: "stat_change" gid: "accuracy" modifier: 2 - - type: "stat" + - type: "stat_change" gid: "power" modifier: 2 iron_short_sword: @@ -48,10 +48,10 @@ iron_short_sword: equip_slots: - "mainhand" equip_effects: - - type: "stat" + - type: "stat_change" gid: "accuracy" modifier: 3 - - type: "stat" + - type: "stat_change" gid: "power" modifier: 3 iron_longsword: @@ -65,10 +65,10 @@ iron_longsword: - gid: "beastslay" level: 3 equip_effects: - - type: "stat" + - type: "stat_change" gid: "accuracy" modifier: 4 - - type: "stat" + - type: "stat_change" gid: "power" modifier: 4 mending_salve: @@ -145,7 +145,7 @@ warm_diadem: equip_slots: - "head" equip_effects: - - type: "stat" + - type: "stat_change" gid: "max_hp" modifier: 1 warped_eyestalk: |