Skip to content

feat(s7/d1): spider priority right-click input + visual indicator#153

Merged
LightAxe merged 8 commits into
mainfrom
feat/s7-deferred-ux
May 27, 2026
Merged

feat(s7/d1): spider priority right-click input + visual indicator#153
LightAxe merged 8 commits into
mainfrom
feat/s7-deferred-ux

Conversation

@LightAxe
Copy link
Copy Markdown
Owner

Summary

  • Right-click on spider (anywhere in the 3×3 tile footprint) dispatches MarkSpiderPriority, toggling the sim-side priority flag that routes fighters toward the spider. Suppresses entrance-preview and rally-clear on that click.
  • White priority border drawn 2px outside the spider's 48×48 bounding box when priority is active, keeping it visible alongside the hunger ring (which occupies the same sprite edge pixels).
  • Clears stale entrance preview when priority toggle fires, so a pre-existing right-click preview can't be confirmed by a subsequent left-click.
  • Uses >> FP_SHIFT for tile conversion, consistent with spider.ts and the rest of the sim.
  • All sim-side plumbing (spiderPriorityColonyId, MarkSpiderPriority command, tick handler) was already in place from S3.

Known limitation

The priority border is drawn on the sprite and is invisible when the spider is off-screen (panned away). The stage doc explicitly defers visual polish ("programmer-art; iterate at ship time") — adding persistent off-screen HUD feedback is out of scope for D1.

Test plan

  • 7 new unit tests: toggle-on, toggle-off, box-corner hit, rally-clear suppression, stale-entrance-preview clearing, outside-box fallthrough, no-spider fallthrough
  • All 2256 tests pass
  • TypeScript clean
  • Manual smoke: fighters route toward spider when priority set; revert to rally when cleared; white border appears/disappears on toggle

🤖 Generated with Claude Code

LightAxe and others added 2 commits May 27, 2026 08:06
Right-clicking within the spider's 3×3 tile footprint now dispatches
MarkSpiderPriority (toggle), suppressing entrance preview and rally-clear.
White border drawn around spider sprite when priority is active.
6 new unit tests covering toggle, box edges, suppression, and no-spider fallthrough.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Use FP_SHIFT (>>) instead of Math.floor(/FP_ONE) for tile conversion,
  consistent with spider.ts and the rest of the sim codebase
- Clear pendingEntranceTileX/Y when spider priority toggle fires, preventing
  a stale entrance preview from being confirmed by a subsequent left-click
- Offset priority indicator 2px outward from the sprite bounding box so it
  remains visible alongside the hunger ring (which occupies the same pixels)
- Add test covering stale-entrance-preview clearing behavior

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@LightAxe
Copy link
Copy Markdown
Owner Author

@codex review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5decad2937

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/input/surface-input.ts Outdated
The 48px sprite is centered at the tile's left-edge pixel (Phaser default
origin 0.5,0.5 + posX*TILE_SIZE_PX/FP_ONE = tile left edge). This puts the
sprite 24px (1.5 tiles) left of the tile anchor, covering tiles [t-2, t+1]
in each axis. The previous [t-1, t+1] box missed the leftmost 8px of the
sprite. Expand hit range and add two tests documenting the corrected bounds.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@LightAxe
Copy link
Copy Markdown
Owner Author

@codex review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: dee2697220

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/input/surface-input.ts Outdated
…ent lag

SPIDER_SPEED = FP_ONE (1 tile/tick). During the first half of any movement
tick the renderer shows the sprite at the previous tile position (alpha < 0.5),
putting the trailing edge 1 tile beyond what a [t-2, t+1] box covers. Expand
to [t-3, t+2] to reliably hit all visible sprite pixels in any movement state.
Two existing corner tests updated to the new bounds; descriptions clarified.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@LightAxe
Copy link
Copy Markdown
Owner Author

@codex review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 582a59ebd8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/input/surface-input.ts Outdated
…wn limit

The [t-3, t+2] expansion to cover render interpolation lag made the hit box
intercept empty-tile clicks 2 tiles outside the visible sprite, breaking
rally-clear and entrance-preview for tiles near the spider (Codex P2).

Keep [t-2, t+1] which correctly covers the static 48px sprite (anchor at
tile left-edge pixel). The trailing-edge mismatch during movement is accepted
as a programmer-art limitation at SPIDER_SPEED=FP_ONE; noted in comment.
Replace the t-3 dispatch test with one verifying t-3 falls through correctly.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@LightAxe
Copy link
Copy Markdown
Owner Author

@codex review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b1ab02f3e2

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/input/surface-input.ts Outdated
Replace tile-boundary hit detection with exact pixel-space bounds check:
screenX/Y is compared against the 48×48px sprite centered at
(posX >> FP_SHIFT) * TILE_SIZE_PX offset by the camera's left/top tile,
matching drawSurfaceEntities exactly. Eliminates the outer half-tile
dead zone at the sprite edges that the tile-range approach allowed.

Tests updated to use precomputed SPIDER_SCR_X/Y constants with HALF_W/H
offsets and verify the inclusive left edge, last inside pixel, and one
pixel outside both edges.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@LightAxe
Copy link
Copy Markdown
Owner Author

@codex review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4ea9a96000

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/input/surface-input.ts Outdated
… P5)

The spider moves 1 tile/tick and the renderer interpolates its visual
position between prev and curr. Without compensation the hit-test anchor
(current-tick integer tile) can be up to one tile ahead of what the
player sees. Expand the hit box by TILE_SIZE_PX (16px) symmetrically so
clicks on the trailing edge after a tick still register.

Test suite extended with X/Y boundary cases for both inner and outer
edges of the expanded 80×80px hit region.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@LightAxe
Copy link
Copy Markdown
Owner Author

@codex review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e93b1f1a6c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/input/surface-input.ts Outdated
Replace the symmetric +TILE_SIZE_PX expansion (which caused false
positives when the spider was stationary or moving away from the click)
with a union of the current-tick and previous-tick bounding boxes.

- When prevWorld is null (stationary), the hit box is exactly the
  48×48px sprite — no false positives.
- When the spider moved, the box expands by one tile only in the
  movement direction — covering the trailing visual edge precisely.

Thread prevWorld into handleSurfaceRightClick via a new optional 7th
parameter (PLAYER_COLONY_ID stays 6th so existing callers are unchanged).
registerSurfaceInput gains an optional getPrevWorld callback; game-scene
supplies it from this.prevState (already maintained for render interp).

Tests extended with two moving-spider union-box cases.

Note: >> FP_SHIFT is equivalent to / FP_ONE here because the spider
always moves exactly FP_ONE per tick and spawns at lairTileX << FP_SHIFT,
so posX is always a multiple of FP_ONE.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@LightAxe
Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Chef's kiss.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@LightAxe LightAxe merged commit ad64440 into main May 27, 2026
1 check passed
@LightAxe LightAxe deleted the feat/s7-deferred-ux branch May 27, 2026 18:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant