diff --git a/packages/web/src/App.svelte b/packages/web/src/App.svelte index 4901408..a35d3d7 100644 --- a/packages/web/src/App.svelte +++ b/packages/web/src/App.svelte @@ -3171,6 +3171,8 @@ c.id === selectedCreature)?.position ?? null) + : punchWallMode ? (me?.position ?? null) : null} selectedCreatureId={selectedCreature} onCellClick={clickCell} onEdgeClick={clickEdge} diff --git a/packages/web/src/Board.svelte b/packages/web/src/Board.svelte index 6043c7b..32b923d 100644 --- a/packages/web/src/Board.svelte +++ b/packages/web/src/Board.svelte @@ -2,7 +2,7 @@ import type { Component } from "svelte"; import type { GameView, SightTrace } from "@wizwar/engine"; import type { Side } from "@wizwar/engine"; - import { fearCells } from "@wizwar/engine"; + import { edgeKey, fearCells } from "@wizwar/engine"; import type { BoardFx } from "./fx"; import { colorIndexOf as sharedColorIndex, wizardColor } from "./colors"; import { CREATURE_ART, objectArt, TERRAIN_ART, tokenArt } from "./art"; @@ -20,6 +20,7 @@ let { view, edgeSelectMode = false, + punchFrom = null, selectedCreatureId = null, onCellClick, onEdgeClick, @@ -43,6 +44,9 @@ }: { view: GameView; edgeSelectMode?: boolean; + /** A puncher's square, wizard or troll: only the walls and doors on its + * four sides can be struck, so only those lines light. */ + punchFrom?: { x: number; y: number } | null; selectedCreatureId?: string | null; onCellClick?: (cell: { x: number; y: number }) => void; onEdgeClick?: (cell: { x: number; y: number }, side: Side) => void; @@ -209,7 +213,18 @@ if (side === "S") boxes.push({ cell: c, side, x: c.x * CELL + 4, y: (c.y + 1) * CELL - 6, w: CELL - 8, h: 12 }); if (side === "N") boxes.push({ cell: c, side, x: c.x * CELL + 4, y: c.y * CELL - 6, w: CELL - 8, h: 12 }); } - return boxes; + if (!punchFrom) return boxes; + const beside = (b: { cell: { x: number; y: number }; side: Side }) => { + const far = b.side === "E" ? { x: b.cell.x + 1, y: b.cell.y } : b.side === "W" ? { x: b.cell.x - 1, y: b.cell.y } + : b.side === "S" ? { x: b.cell.x, y: b.cell.y + 1 } : { x: b.cell.x, y: b.cell.y - 1 }; + const at = (c: { x: number; y: number }) => c.x === punchFrom!.x && c.y === punchFrom!.y; + return at(b.cell) || at(far); + }; + const solid = (b: { cell: { x: number; y: number }; side: Side }) => { + const state = view.board.edges[edgeKey(b.cell, b.side)]; + return state === "wall" || state === "door"; + }; + return boxes.filter((b) => beside(b) && solid(b)); }); // FEAR's dread: three spaces in every direction, straight through walls