diff options
-rw-r--r-- | CHANGELOG.md | 15 | ||||
-rw-r--r-- | app/lib/activity_processor.rb | 3 | ||||
-rw-r--r-- | app/models/character.rb | 10 | ||||
-rw-r--r-- | app/models/equipment.rb | 12 | ||||
-rw-r--r-- | app/views/application/_results.html.erb | 2 |
5 files changed, 42 insertions, 0 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 89785c6..e5c3726 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,21 @@ # Changelog All notable changes to this project will be documented in this file. +## [Unreleased] + +### Mechanics +- Any items equipped when combat completes now have a chance to be broken, damaged beyond repair. Broken items are + effectively destroyed. + - Ring and neck slot items have a 1/5000 chance to break. + - Waist, back, and curio slot items have a 1/2500 chance to break. + - Items equipped in all other slots have a 1/1000 chance to break. + - Any item equipped during combat is at risk, even if it provides no combat benefit. This may be changed in the + future. + - Currently, non-combat activities do not put your items at risk. This will change in the future. + +### Engine +- Refactored some activity and combat code. + ## [0.1.6] - 2021-06-04 Note that from this point foward, I am not explicitly listing the addition of activities required to make the items, diff --git a/app/lib/activity_processor.rb b/app/lib/activity_processor.rb index 004f8de..d8004f6 100644 --- a/app/lib/activity_processor.rb +++ b/app/lib/activity_processor.rb @@ -251,6 +251,9 @@ class ActivityProcessor end end end + @character.do_equipment_break_checks.each do |broken_item| + @results.push({ type: "warning", message: "Your #{broken_item.name} was damaged beyond repair!" }) + end break end end diff --git a/app/models/character.rb b/app/models/character.rb index 91f0a66..f4c9bc2 100644 --- a/app/models/character.rb +++ b/app/models/character.rb @@ -115,6 +115,16 @@ class Character < ApplicationRecord end end + def do_equipment_break_checks(exclude_slots: []) + broken_items = [] + equipment.where.not(slot: exclude_slots).each do |equipment| + if equipment.break_check + broken_items.push(equipment.item) + end + end + broken_items + end + def has_item?(item, quantity = 1) item = Item.find_by_gid(item) if item.is_a? String ci = self.character_items.find_by(item: item) diff --git a/app/models/equipment.rb b/app/models/equipment.rb index ce3822c..e1dc7a3 100644 --- a/app/models/equipment.rb +++ b/app/models/equipment.rb @@ -12,4 +12,16 @@ class Equipment < ApplicationRecord def effects self.item.whatnot[:equip_effects] end + + def break_check + roll = rand + if [:neck, :left_ring, :right_ring].include?(slot) + destroy and return true if roll > 0.9998 + elsif [:back, :waist, :curio].include?(slot) + destroy and return true if roll > 0.9996 + else + destroy and return true if roll > 0.999 + end + false + end end diff --git a/app/views/application/_results.html.erb b/app/views/application/_results.html.erb index 1da0af7..31fb93e 100644 --- a/app/views/application/_results.html.erb +++ b/app/views/application/_results.html.erb @@ -23,6 +23,8 @@ <p>You earned the title <%= render "application/components/text/title", title: result[:title] %>!</p> <% when "message" %> <p><%= result[:body] %></p> + <% when "warning" %> + <p class="text-yellow-500"><%= result[:message] %></p> <% when "error" %> <p class="text-red-500"><%= result[:message] %></p> <% when "br" %> |