From 54473e0e8d2db24e4c1dd12aa309d610e62ed09d Mon Sep 17 00:00:00 2001 From: David Gay Date: Mon, 7 Jun 2021 20:16:13 -0400 Subject: Move equipment break check earlier in combat end code so it isn't skipped --- CHANGELOG.md | 2 ++ app/lib/activity_processor.rb | 12 +++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c716630..89647d1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,8 @@ All notable changes to this project will be documented in this file. - The following stats can now be negative: resistances, speed, accuracy, power, and evasion - Combat stances now increase or decrease stats by a flat amount (instead of a percentage). The amount is equal to your beastslay level divided by 5, rounded up. +- Equipment break check now occurs immediately once a combatant has been reduced to zero HP or less. Previously + the break check could be skipped under certain conditons where the combat loop ended early. ### Monsters - Stalk beast diff --git a/app/lib/activity_processor.rb b/app/lib/activity_processor.rb index bc0d058..72c7ddd 100644 --- a/app/lib/activity_processor.rb +++ b/app/lib/activity_processor.rb @@ -272,7 +272,10 @@ class ActivityProcessor elsif evasion_roll > accuracy_roll combat_message.call("#{target.name} evaded #{actor.name}'s attack.") end + if char_hp < 1 || mon_hp < 1 + break_check + if monster_spawn hp_lost = monster_spawn.remaining_hp - mon_hp if hp_lost > 0 @@ -310,11 +313,14 @@ 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 end + + def break_check + @character.do_equipment_break_checks.each do |broken_item| + @results.push({ type: "warning", message: "Your #{broken_item.name} was damaged beyond repair!" }) + end + end end -- cgit v1.2.3