Fix hit boolean for torpedos

This commit is contained in:
aronmal 2023-09-10 19:46:21 +02:00
parent 2991dc19f2
commit 8b179b5e65
Signed by: aronmal
GPG key ID: 816B7707426FC612

View file

@ -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[]) ?? []