Skip to content

Commit 9cc149d

Browse files
authored
Improve stamina calculation logic
Refactor stamina calculation to include bonuses and kit stats when pulling from forge steel
1 parent 7c3e1fb commit 9cc149d

File tree

1 file changed

+25
-6
lines changed

1 file changed

+25
-6
lines changed

Draw Steel/draw-steel.html

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4148,13 +4148,32 @@ <h5 class="panel-title" data-i18n="conditions"></h5>
41484148
const disengage = calculateCombatStat(allFeatures, 'Disengage', 1);
41494149
const stability = calculateCombatStat(allFeatures, 'Stability', 0);
41504150

4151-
const stamina_max = allFeatures
4152-
.filter(f => f.type === FEATURE_TYPES.BONUS && f.data.field === 'Stamina')
4153-
.reduce((sum, f) => sum + (f.data.value + ((level - 1) * f.data.valuePerLevel)), 0);
4154-
4151+
// --- Stamina & Recoveries (including Kit stats) ---
4152+
// 1) Base stamina from Bonus features (class, ancestry, etc.)
4153+
const staminaFromBonuses = allFeatures
4154+
.filter(f => f.type === FEATURE_TYPES.BONUS && f.data.field === 'Stamina')
4155+
.reduce((sum, f) => {
4156+
const base = Number(f.data.value) || 0;
4157+
const perLevel = Number(f.data.valuePerLevel) || 0;
4158+
return sum + base + ((level - 1) * perLevel);
4159+
}, 0);
4160+
4161+
// 2) Stamina from Kits (KitStats), using the highest equipped kit value
4162+
// This mirrors how calculateCombatStat uses KIT_STATS for Speed/Stability.
4163+
const staminaFromKits = Math.max(
4164+
0, // avoid -Infinity if no kits
4165+
...allFeatures
4166+
.filter(f => f.type === FEATURE_TYPES.KIT_STATS)
4167+
.map(f => Number(f.stamina) || 0)
4168+
);
4169+
4170+
// 3) Final maximum Stamina
4171+
const stamina_max = staminaFromBonuses + staminaFromKits;
4172+
41554173
const recoveries_max = allFeatures
4156-
.filter(f => f.type === FEATURE_TYPES.BONUS && f.data.field === 'Recoveries')
4157-
.reduce((sum, f) => sum + f.data.value, 0);
4174+
.filter(f => f.type === FEATURE_TYPES.BONUS && f.data.field === 'Recoveries')
4175+
.reduce((sum, f) => sum + (Number(f.data.value) || 0), 0);
4176+
41584177

41594178
const immunity = getDamageModifiers(allFeatures, level, 'Immunity');
41604179
const weakness = getDamageModifiers(allFeatures, level, 'Weakness');

0 commit comments

Comments
 (0)