From 3446cb7656768b40dfd0afce9c8384676bf27135 Mon Sep 17 00:00:00 2001 From: David Gay Date: Sun, 6 Jun 2021 20:22:14 -0400 Subject: Add and award Sentinel title, and add leviathan info to changelog --- app/models/monster_spawn_combat.rb | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'app/models') 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(", ")) -- cgit v1.2.3