From 62d86f12f0a8eefcfc91d4911a71acc5906401fe Mon Sep 17 00:00:00 2001 From: Tobias Date: Thu, 31 Aug 2023 15:48:34 +0200 Subject: [PATCH] changed calculation of effective initiative so that it never returns negative values; also added functions to module.exports --- src/js/sr2ini.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/js/sr2ini.js b/src/js/sr2ini.js index fe2ac15..5620521 100644 --- a/src/js/sr2ini.js +++ b/src/js/sr2ini.js @@ -105,9 +105,9 @@ function whoGoesFirst(a, b) { // compute a combatant's effective ini value (modified by wound penalties) function getEffectiveIni(tr) { - // return -1 if combatant is K.O. or dead + // return 0 if combatant is K.O. or dead if ($(tr).hasClass("ko-or-dead")) { - return -1; + return 0; } // otherwise compute effective ini (true ini minus wound penalties) let effectiveIni = parseInt($(tr).attr("data-true-ini")) - DAMAGE_PENALTY[parseInt($(tr).attr("data-damage-stun")) || 0] - DAMAGE_PENALTY[parseInt($(tr).attr("data-damage-physical")) || 0]; @@ -511,4 +511,4 @@ $(document).ready(function () { addTestCombatant(); }); -module.exports = { rollForInitiative, validateCombatant }; \ No newline at end of file +module.exports = { rollForInitiative, validateCombatant, whoGoesFirst, getEffectiveIni }; \ No newline at end of file