Fix hit boolean for torpedos
This commit is contained in:
parent
2991dc19f2
commit
8b179b5e65
1 changed files with 7 additions and 7 deletions
|
@ -225,20 +225,20 @@ export function intersectingShip(
|
||||||
|
|
||||||
export function compiledHits(i: 0 | 1) {
|
export function compiledHits(i: 0 | 1) {
|
||||||
return (
|
return (
|
||||||
users[i]?.moves.reduce((hits, move) => {
|
users[i]?.moves.reduce((hits, { orientation, type, ...move }) => {
|
||||||
const list = targetList(move, move.type)
|
const list = targetList(move, type)
|
||||||
return move.type === MoveType.Enum.radar
|
return type === MoveType.Enum.radar
|
||||||
? hits
|
? hits
|
||||||
: [
|
: [
|
||||||
...hits,
|
...hits,
|
||||||
...list.map(({ x, y }) => ({
|
...list.map((pos) => ({
|
||||||
hit: !!intersectingShip(users[i === 0 ? 1 : 0]?.ships ?? [], {
|
hit: !!intersectingShip(users[i === 0 ? 1 : 0]?.ships ?? [], {
|
||||||
...move,
|
...pos,
|
||||||
|
orientation,
|
||||||
size: 1,
|
size: 1,
|
||||||
variant: 0,
|
variant: 0,
|
||||||
}).fields.length,
|
}).fields.length,
|
||||||
x,
|
...pos,
|
||||||
y,
|
|
||||||
})),
|
})),
|
||||||
]
|
]
|
||||||
}, [] as Hit[]) ?? []
|
}, [] as Hit[]) ?? []
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue