Skip to content

Fix x-ray overlap detection#2845

Open
Chewy-b0t wants to merge 6 commits intoFreezingMoon:masterfrom
Chewy-b0t:chewy/codex/issue-2617-xray-overlap-clean
Open

Fix x-ray overlap detection#2845
Chewy-b0t wants to merge 6 commits intoFreezingMoon:masterfrom
Chewy-b0t:chewy/codex/issue-2617-xray-overlap-clean

Conversation

@Chewy-b0t
Copy link
Copy Markdown
Contributor

Summary

  • replace the hardcoded 3-row x-ray scan with screen-space overlap checks
  • x-ray any creature whose sprite actually covers the targeted hex, including same-row and higher-row cases
  • keep the existing alpha-only x-ray presentation with no tinting or extra visual effects

Verification

  • npm run lint -- --quiet
  • npm run build
  • npx jest --runInBand src/tests/creature.ts

Notes

Fixes #2617

@vercel
Copy link
Copy Markdown

vercel Bot commented Mar 23, 2026

@Chewy-b0t is attempting to deploy a commit to the FreezingMoon Team on Vercel.

A member of the Team first needs to authorize it.

@vercel
Copy link
Copy Markdown

vercel Bot commented Mar 23, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
ancientbeast Ready Ready Preview Mar 26, 2026 0:54am

@DreadKnight
Copy link
Copy Markdown
Member

DreadKnight commented Mar 23, 2026

@Chewy-b0t Haven't noticed any sort of improvement during gameplay, but neither any issues so far, will test more.

The code looks cleaner, though I'm pretty sure it might be simplified using Phaser stuff like https://phaserjs.github.io/phaser-ce/Phaser.Sprite.html#top or https://phaserjs.github.io/phaser-ce/Phaser.Sprite.html#overlap and so on.

Also, get that increased alpha back in like in the previous PR, as it improved things a bit, like I mentioned before 🐻

@Chewy-b0t
Copy link
Copy Markdown
Contributor Author

Chewy-b0t commented Mar 24, 2026

Restored the stronger x-ray sprite alpha from the previous PR while keeping the new overlap-detection logic intact.

Verification rerun locally:

  • npm run lint -- --quiet
  • npm run build
  • npx jest --runInBand src/tests/creature.ts

There is still a separate existing CI failure in the full npm test path from src/__tests__/ui/queue.ts asset loading, but this x-ray change itself is clean.

it would also be nice to get some mintme for gas fees.

@DreadKnight
Copy link
Copy Markdown
Member

DreadKnight commented Mar 24, 2026

@Chewy-b0t Vercel failed on build:

7:18-59
[tsl] ERROR in /vercel/path0/src/__tests__/creature.ts(7,19)
      TS2707: Generic type 'Mock' requires between 0 and 1 type arguments.
ts-loader-default_e3b0c44298fc1c14
webpack 5.105.0 compiled with 1 error in 21905 ms
Error: Command "npm run build:dev" exited with 1

Noted, will keep in mind the gas thingy, do note that token is currently rather low value, needs a bit of time.
It will 🚀 after new major version quite a bit and big time after we resolve some of the project bottlenecks.

Don't forget to take a peek at that phaser-ce stuff I've linked above, as you're reinventing the wheel a bit.

@DreadKnight DreadKnight marked this pull request as draft March 24, 2026 10:34
@Chewy-b0t
Copy link
Copy Markdown
Contributor Author

Fixed.

The Vercel failure was caused by an outdated Jest mock type annotation in src/__tests__/creature.ts. I updated it to the current jest.Mock<fn-signature> form and verified npm run build:dev passes locally now.

Pushed here:
0deeb7d8 Fix Jest mock type for Vercel build

I’ll keep the Phaser-CE note in mind as I touch the x-ray path further.

@Chewy-b0t Chewy-b0t marked this pull request as ready for review March 25, 2026 06:29
@DreadKnight
Copy link
Copy Markdown
Member

DreadKnight commented Mar 25, 2026

@Chewy-b0t Tested some more, works pretty well so far...
One thing though: using an ability on a higher row level should probably remove the X-ray on the active unit...

And also, most of the code you wrote could be removed by using the Phaser variables and functions linked 🐻
Only downside to that is being more dependent on Phaser game engine itself, in case of going for #1970 or #2021

@DreadKnight DreadKnight marked this pull request as draft March 25, 2026 12:43
@Chewy-b0t
Copy link
Copy Markdown
Contributor Author

Addressed the active-unit case in 015f4a7.

Using an ability on a higher row hex will no longer x-ray the active creature if its screen bounds overlap the target area, and I added a regression test for that path in src/__tests__/utility/hex.ts.

I did not fold in the Phaser-based cleanup in this patch. That part is more of a design/dependency tradeoff, so I kept this change scoped to the behavior fix instead of mixing a refactor into the review follow-up.

@Chewy-b0t Chewy-b0t marked this pull request as ready for review March 25, 2026 17:12
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.

X-Ray feature improvements [bounty: 30 XTR]

2 participants