Skip to content

refactor: clean up and denest AttemptCapturePhase#7145

Open
Bertie690 wants to merge 1 commit intopagefaultgames:betafrom
Bertie690:attempt-capture-phase
Open

refactor: clean up and denest AttemptCapturePhase#7145
Bertie690 wants to merge 1 commit intopagefaultgames:betafrom
Bertie690:attempt-capture-phase

Conversation

@Bertie690
Copy link
Contributor

@Bertie690 Bertie690 commented Mar 9, 2026

What are the changes the user will see?

N/A

Why am I making these changes?

AttemptCapturePhase was an absolute nightmare, with 15+ nesting levels' worth of tween chain-wrapped UI-handler callback code.

Also, it was virtually untestable due to the extremely convoluted way in which the capture formula was computed. What fun!

What are the changes from a developer perspective?

Denested and Promisifyed the file, moving lots of code into private methods rather than nested callbacks.
Among other things, the shake check count is now pre-determined ahead of time instead of computed on the fly in the middle of the tween chain, greatly simplifying logic and easing the ability for subclasses to override the formula logic.

Also removed PokeballType.LUXURY_BALL for the time being until we actually get more ball types. (Once we do, we can actually add them in dex order instead of some arbitrary ordering.)

Screenshots/Videos

Before
old.mp4
After
new.mp4

NB: I was not able to actively record footage of a failed catch attempt, but verified off-camera that it indeed works.

How to test the changes?

pnpm test capture-phase.test.ts payback.test.ts.
Former has had a 7-month TODO test properly filled in, while the latter demonstrates the new capture formula being actually testable instead of

Checklist

  • The PR content is correctly formatted:
    • I'm using beta as my base branch
    • The current branch is not named beta, main or the name of another long-lived feature branch
    • I have provided a clear explanation of the changes within the PR description
    • The PR title matches the Conventional Commits format (as described in CONTRIBUTING.md)
  • The PR is self-contained and cannot be split into smaller PRs
  • There is no overlap with another open PR
  • The PR has been confirmed to work correctly:
    • I have tested the changes manually
    • The full automated test suite still passes (use pnpm test:silent to test locally)
    • I have created new automated tests (pnpm test:create) or updated existing tests related to the PR's changes if necessary
  • I have provided screenshots/videos of the changes (if applicable)

@Bertie690 Bertie690 marked this pull request as ready for review March 9, 2026 02:01
@Bertie690 Bertie690 requested a review from a team as a code owner March 9, 2026 02:01
@Bertie690 Bertie690 requested review from Xavion3, emdeann and fabske0 March 9, 2026 02:01
@Madmadness65 Madmadness65 added the Refactor Rewriting existing code related label Mar 13, 2026
@Bertie690 Bertie690 requested review from DayKev and SirzBenjie March 14, 2026 05:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Refactor Rewriting existing code related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants