summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorDavid Gay <david@davidgay.org>2021-06-15 22:30:47 -0400
committerDavid Gay <david@davidgay.org>2021-06-15 22:30:54 -0400
commit23d07f8badb2b2ce8139ee421157a96fb61455dc (patch)
tree7e518d66f8dd0ed512a64fdc6e19c2116bd79c8e /app
parent637adf2963f174c3e3e3d6cf9efbff314e306f3e (diff)
Add 7 new titles, awarded for MonsterKill quantity
Diffstat (limited to 'app')
-rw-r--r--app/models/monster_kill.rb15
-rw-r--r--app/views/application/components/text/_title.html.erb14
2 files changed, 29 insertions, 0 deletions
diff --git a/app/models/monster_kill.rb b/app/models/monster_kill.rb
index 4096e8e..24519b1 100644
--- a/app/models/monster_kill.rb
+++ b/app/models/monster_kill.rb
@@ -4,4 +4,19 @@ class MonsterKill < ApplicationRecord
validates :quantity, numericality: { greater_than_or_equal_to: 0, only_integer: true }
scope :ordered_by_monster_name, -> { includes(:monster).order("monsters.name") }
+
+ after_save :award_titles
+
+ private
+ def award_titles
+ character.award_title("spiteful") if quantity >= 1000
+ character.award_title("hateful") if quantity >= 10_000
+ character.award_title("vicious") if quantity >= 100_000
+
+ all_kills_quantity = character.monster_kills.sum(:quantity)
+ character.award_title("slayer") if all_kills_quantity >= 1_000
+ character.award_title("butcher") if all_kills_quantity >= 10_000
+ character.award_title("slaughterer") if all_kills_quantity >= 100_000
+ character.award_title("massacrer") if all_kills_quantity >= 1_000_000
+ end
end
diff --git a/app/views/application/components/text/_title.html.erb b/app/views/application/components/text/_title.html.erb
index a7c2a7e..5e1d5a2 100644
--- a/app/views/application/components/text/_title.html.erb
+++ b/app/views/application/components/text/_title.html.erb
@@ -10,6 +10,20 @@
<span class="text-purple-200">Aspirant</span>
<% when "sentinel" %>
<span class="text-gray-500">S</span><span class="text-gray-400">e</span><span class="text-gray-300">n</span><span class="text-gray-200">ti</span><span class="text-gray-300">n</span><span class="text-gray-400">e</span><span class="text-gray-500">l</span>
+ <% when "spiteful" %>
+ <span class="text-transparent bg-clip-text bg-gradient-to-b from-gray-500 to-red-900">Spiteful</span>
+ <% when "hateful" %>
+ <span class="text-transparent bg-clip-text bg-gradient-to-b from-gray-600 to-red-800">Hateful</span>
+ <% when "vicious" %>
+ <span class="text-transparent bg-clip-text bg-gradient-to-b from-gray-700 to-red-700">Vicious</span>
+ <% when "slayer" %>
+ <span class="text-red-400">Slayer</span>
+ <% when "butcher" %>
+ <span class="text-red-500">Butcher</span>
+ <% when "slaughterer" %>
+ <span class="text-red-600">Slaughterer</span>
+ <% when "massacrer" %>
+ <span class="text-red-700">Massacrer</span>
<% else %>
<%= title.name %>
<% end %>