summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md1
-rw-r--r--app/controllers/game_controller.rb5
-rw-r--r--app/models/character_skill.rb10
-rw-r--r--app/views/application/components/text/_title.html.erb2
-rw-r--r--data/titles.yml2
5 files changed, 19 insertions, 1 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index b15c280..fa5e02f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -12,6 +12,7 @@ amenities, etc that are added unless they are special in some way.
is gained, the old one is lost. There is no limit to the number of drug conditions a character can have at once.
- New hearth amenities: spicebench level 1, spicebench level 2
- New items: bluster powder, mudtub mash, midoras spice, midoras mudtub mash
+- New title: Aspirant, gained by reaching 100 total level
## [0.1.5] - 2021-06-03
diff --git a/app/controllers/game_controller.rb b/app/controllers/game_controller.rb
index c506aa6..f8b9973 100644
--- a/app/controllers/game_controller.rb
+++ b/app/controllers/game_controller.rb
@@ -179,6 +179,11 @@ class GameController < ApplicationController
unless @results.any?
@results.push({ type: "message", body: "You come up empty." })
end
+
+ # HACK: To display any titles that were gained indirectly (not as part of the activity results).
+ current_char.title_awards.where(created_at: 5.seconds.ago..).each do |title_award|
+ @results.push({ type: "title", title: title_award.title })
+ end
end
rescue ItemQuantityError
current_char.stop_activity
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
diff --git a/app/views/application/components/text/_title.html.erb b/app/views/application/components/text/_title.html.erb
index ea00777..2576ff8 100644
--- a/app/views/application/components/text/_title.html.erb
+++ b/app/views/application/components/text/_title.html.erb
@@ -6,6 +6,8 @@
<span class="text-yellow-400">Beryly</span>
<% when "retributor" %>
<span class="text-gray-500">Retribut</span><span class="text-yellow-200">o</span><span class="text-gray-500">r</span>
+ <% when "aspirant" %>
+ <span class="text-purple-200">Aspirant</span>
<% else %>
<%= title.name %>
<% end %>
diff --git a/data/titles.yml b/data/titles.yml
index 30cb41e..a45206e 100644
--- a/data/titles.yml
+++ b/data/titles.yml
@@ -4,3 +4,5 @@ beryly:
name: "Beryly"
retributor:
name: "Retributor"
+aspirant:
+ name: "Aspirant"