From e97deb8d6fdc6011b47c8df5dbf76d6c6cc0f765 Mon Sep 17 00:00:00 2001 From: Eric Wagoner Date: Thu, 24 Sep 2026 21:37:13 -0400 Subject: [PATCH] A commanded troll lights only the walls and doors beside it, and so does a punching wizard Every interior line lit whenever an edge was wanted; the troll can strike only the four sides of its own square, so only those light now. Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_01Jm2auWk6RP71CjaAb4FMoG --- packages/web/src/App.svelte | 2 ++ packages/web/src/Board.svelte | 19 +++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 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