From 23d07f8badb2b2ce8139ee421157a96fb61455dc Mon Sep 17 00:00:00 2001 From: David Gay Date: Tue, 15 Jun 2021 22:30:47 -0400 Subject: Add 7 new titles, awarded for MonsterKill quantity --- CHANGELOG.md | 10 ++++++++++ app/models/monster_kill.rb | 15 +++++++++++++++ app/views/application/components/text/_title.html.erb | 14 ++++++++++++++ data/titles.yml | 14 ++++++++++++++ 4 files changed, 53 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 22ebaf8..e584534 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -36,6 +36,16 @@ All notable changes to this project will be documented in this file. ### Hearth - New amenity: binding array (level 1, level 2) +### Titles +- 7 new titles + - Slayer: Kill 1,000 monsters + - Butcher: Kill 10,000 monsters + - Slaughterer: Kill 100,000 monsters + - Massacrer: Kill 1,000,000 monsters + - Spiteful: Kill 1,000 of one particular monster + - Hateful: Kill 10,000 of one particular monster + - Vicious: Kill 100,000 of one particular monster + ### UI - Character skills were moved from the Character view to their own view, which features a new interface with XP bars. 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 @@ Aspirant <% when "sentinel" %> Sentinel + <% when "spiteful" %> + Spiteful + <% when "hateful" %> + Hateful + <% when "vicious" %> + Vicious + <% when "slayer" %> + Slayer + <% when "butcher" %> + Butcher + <% when "slaughterer" %> + Slaughterer + <% when "massacrer" %> + Massacrer <% else %> <%= title.name %> <% end %> diff --git a/data/titles.yml b/data/titles.yml index a8c228a..23ff009 100644 --- a/data/titles.yml +++ b/data/titles.yml @@ -8,3 +8,17 @@ aspirant: name: "Aspirant" sentinel: name: "Sentinel" +spiteful: + name: "Spiteful" +hateful: + name: "Hateful" +vicious: + name: "Vicious" +slayer: + name: "Slayer" +butcher: + name: "Butcher" +slaughterer: + name: "Slaughterer" +massacrer: + name: "Massacrer" -- cgit v1.2.3