diff options
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/monster_spawn_combat.rb | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/app/models/monster_spawn_combat.rb b/app/models/monster_spawn_combat.rb index 5b61bb5..08fe0f2 100644 --- a/app/models/monster_spawn_combat.rb +++ b/app/models/monster_spawn_combat.rb @@ -78,6 +78,15 @@ class MonsterSpawnCombat < ApplicationRecord end end + # TODO: HACK for title for now + character_damage = {} + involved_characters.each do |character| + character_damage[character] = MonsterSpawnCombat.where(monster_spawn: monster_spawn, character: character).sum(:hp_lost) + end + title_recipient = character_damage.max_by { |_, v| v }[0] + title_recipient.award_title("sentinel") + message_body_parts[title_recipient.id].push("You earned the Sentinel title!") + message_body_parts.each do |character_id, body_parts| if body_parts.any? Message.create(recipient_id: character_id, subject: "#{monster.name} slain", body: body_parts.join(", ")) |