diff options
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/character_skill.rb | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/app/models/character_skill.rb b/app/models/character_skill.rb index 722a371..84c538e 100644 --- a/app/models/character_skill.rb +++ b/app/models/character_skill.rb @@ -4,7 +4,7 @@ class CharacterSkill < ApplicationRecord validates :skill_id, uniqueness: { scope: :character_id } validates :xp, numericality: { greater_than_or_equal_to: 0, only_integer: true } - before_update :send_chat_message_if_leveled_up + before_update :send_chat_message_if_leveled_up, :award_titles scope :ordered_by_skill_name, -> { includes(:skill).order("skills.name") } @@ -72,4 +72,12 @@ class CharacterSkill < ApplicationRecord end end end + + def award_titles + if CharacterSkill.level_for_xp(self.xp_was) < CharacterSkill.level_for_xp(xp) + if character.character_skills.to_a.sum(&:level) >= 100 + character.award_title("aspirant") + end + end + end end |