Add per-projectile player damage reducer

This commit is contained in:
Admin 2026-09-18 01:15:37 +00:00
parent cb139b839e
commit 1a99e1c362

View File

@ -111,3 +111,24 @@ export const reducePlayerVolleyHits = ({
gameOver: nextHull <= 0,
};
};
export const reducePlayerProjectileHits = ({
hull,
hits,
maxHull = PLAYER_MAX_HULL,
fallbackDamage = DEFAULT_PIRATE_SHOT_DAMAGE,
}) => {
const currentHull = Number.isFinite(hull) ? hull : maxHull;
const totalDamage = hits.reduce(
(sum, hit) => sum + normalizePlayerDamage(hit?.damage, fallbackDamage),
0,
);
const nextHull = Math.max(0, currentHull - totalDamage);
return {
hull: nextHull,
totalDamage,
appliedHits: hits.length,
gameOver: nextHull <= 0,
};
};