Extract queued player hit processing
This commit is contained in:
parent
42ebf6a763
commit
4ff7edd030
@ -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,
|
||||
});
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user