Auto-select involved unit on snap-pause events (sub-issue 22-3) #26

Closed
opened 2026-10-04 21:31:34 +00:00 by Mark · 1 comment
Owner

Parent-Issue: #22

Sub-issue 22-3 — focus-snap event doesn't show which unit the event is about

snapPause() (web/js/game.js:545) sets G.focus and writes a log line but
does not select the involved unit. After the snap-pause the player sees a
circle pulse but the SELECTED panel still shows whoever was selected
before the event.

For "squad wounded" / "unit down" / "order failed" events the involved unit
should become G.selected automatically so the SELECTED panel updates. For
hostile-contact snaps, the spotted enemy should be selected.

Fix

At each snapPause(...) call site in web/js/game.js, also set
G.selected = <involved-unit> so the SELECTED panel updates on the next
updateUI() tick. Look at every call to snapPause and confirm a unit is
in scope; for events where the involved unit is null (e.g. a phase
transition), leave G.selected unchanged.

File(s)

  • web/js/game.js — snapPause() callers

Acceptance

  • Any snap-pause caused by a squad unit's state changes selects that unit
  • Hostile-contact snaps select the spotted enemy
  • Events with no unit in scope (e.g. phase transitions) leave G.selected
    unchanged
  • make ci passes

Refs

  • Parent: #22 (battle UI contract, sub-issue F)
  • web/js/game.js:545 (snapPause)
**Parent-Issue:** #22 ## Sub-issue 22-3 — focus-snap event doesn't show which unit the event is about `snapPause()` (`web/js/game.js:545`) sets `G.focus` and writes a log line but does not select the involved unit. After the snap-pause the player sees a circle pulse but the **SELECTED** panel still shows whoever was selected before the event. For "squad wounded" / "unit down" / "order failed" events the involved unit should become `G.selected` automatically so the SELECTED panel updates. For hostile-contact snaps, the spotted enemy should be selected. ## Fix At each `snapPause(...)` call site in `web/js/game.js`, also set `G.selected = <involved-unit>` so the SELECTED panel updates on the next `updateUI()` tick. Look at every call to `snapPause` and confirm a unit is in scope; for events where the involved unit is `null` (e.g. a phase transition), leave `G.selected` unchanged. ## File(s) - `web/js/game.js` — `snapPause()` callers ## Acceptance - [ ] Any snap-pause caused by a squad unit's state changes selects that unit - [ ] Hostile-contact snaps select the spotted enemy - [ ] Events with no unit in scope (e.g. phase transitions) leave `G.selected` unchanged - [ ] `make ci` passes ## Refs - Parent: #22 (battle UI contract, sub-issue F) - `web/js/game.js:545` (`snapPause`)
Author
Owner

Closed via triage-runner on commit 7b84793 (push 18ced82..7b84793).

snapPause(x,y,msg,kind) extended with optional 5th arg sel; when set it becomes G.selected so the SELECTED panel updates on the next updateUI() tick. snapPause itself stays backwards-compatible.

Updated call sites (5):

  • failOrder(u) — squad u reports failure → select u
  • enemyAI contact — hostile u just got visual on the squad → select u (the spotted enemy)
  • damageUnit wounded — squad u critically wounded → select u
  • damageUnit down — squad u just died → select u (so player sees which one went down)
  • computeVisibility — squad spots enemy e → select e

make test: all 7 smoke scripts PASS.

Closed via triage-runner on commit 7b84793 (push 18ced82..7b84793). snapPause(x,y,msg,kind) extended with optional 5th arg `sel`; when set it becomes G.selected so the SELECTED panel updates on the next updateUI() tick. snapPause itself stays backwards-compatible. Updated call sites (5): - failOrder(u) — squad u reports failure → select u - enemyAI contact — hostile u just got visual on the squad → select u (the spotted enemy) - damageUnit wounded — squad u critically wounded → select u - damageUnit down — squad u just died → select u (so player sees which one went down) - computeVisibility — squad spots enemy e → select e make test: all 7 smoke scripts PASS.
Mark closed this issue 2026-10-05 21:08:13 +00:00
Sign in to join this conversation.
No description provided.