diff options
Diffstat (limited to 'app/models/character.rb')
-rw-r--r-- | app/models/character.rb | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/app/models/character.rb b/app/models/character.rb index 8913f71..a5c871b 100644 --- a/app/models/character.rb +++ b/app/models/character.rb @@ -25,6 +25,22 @@ class Character < ApplicationRecord after_create :create_skills, :set_combat_styles after_create { Hearth.create(character: self) } + def self.sorted_by_total_xp + all.sort_by(&:total_xp).reverse + end + + def self.sorted_by_total_level + all.sort_by(&:total_level).reverse + end + + def self.top_total_xp + sorted_by_total_xp.first(5) + end + + def self.top_total_level + sorted_by_total_level.first(5) + end + def beastslay_level; skill_level("beastslay"); end def fluxseethe_level; skill_level("fluxseethe"); end def havencast_level; skill_level("havencast"); end @@ -41,6 +57,26 @@ class Character < ApplicationRecord def wildscour_level; skill_level("wildscour"); end def worldcall_level; skill_level("worldcall"); end + def total_xp + character_skills.sum(:xp).to_i + end + + def total_level + count = 0 + character_skills.each do |cs| + count += cs.level + end + count + end + + def total_xp_rank + Character.sorted_by_total_xp.map(&:id).index(self.id) + 1 + end + + def total_level_rank + Character.sorted_by_total_level.map(&:id).index(self.id) + 1 + end + def vestige vestige = self.character_items.find_by(item: Item.find_by_gid("vestige")) vestige ? vestige.quantity : 0 |