Extract queued player hit processing

This commit is contained in:
Admin 2026-09-18 00:40:07 +00:00
parent 42ebf6a763
commit 4ff7edd030

View File

@ -49,3 +49,25 @@ export const reducePlayerHitQueue = ({
gameOver: nextHull <= 0,
};
};
export const processQueuedPlayerHits = ({
hull,
lastHitAt,
now,
hits,
cooldownMs = PLAYER_HIT_COOLDOWN_MS,
maxHull = PLAYER_MAX_HULL,
}) => {
for (const { shot } of hits) {
if (shot?.active && typeof shot.destroy === 'function') shot.destroy();
}
return reducePlayerHitQueue({
hull,
lastHitAt,
now,
damages: hits.map(({ damage }) => damage),
cooldownMs,
maxHull,
});
};