From 8b179b5e65b4aa01fe37d034900f313ee484dfb4 Mon Sep 17 00:00:00 2001 From: aronmal Date: Sun, 10 Sep 2023 19:46:21 +0200 Subject: [PATCH] Fix hit boolean for torpedos --- leaky-ships/src/lib/utils/helpers.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/leaky-ships/src/lib/utils/helpers.ts b/leaky-ships/src/lib/utils/helpers.ts index 7445738..0cecfde 100644 --- a/leaky-ships/src/lib/utils/helpers.ts +++ b/leaky-ships/src/lib/utils/helpers.ts @@ -225,20 +225,20 @@ export function intersectingShip( export function compiledHits(i: 0 | 1) { return ( - users[i]?.moves.reduce((hits, move) => { - const list = targetList(move, move.type) - return move.type === MoveType.Enum.radar + users[i]?.moves.reduce((hits, { orientation, type, ...move }) => { + const list = targetList(move, type) + return type === MoveType.Enum.radar ? hits : [ ...hits, - ...list.map(({ x, y }) => ({ + ...list.map((pos) => ({ hit: !!intersectingShip(users[i === 0 ? 1 : 0]?.ships ?? [], { - ...move, + ...pos, + orientation, size: 1, variant: 0, }).fields.length, - x, - y, + ...pos, })), ] }, [] as Hit[]) ?? []