refactor: clean up and denest AttemptCapturePhase#7145
Open
Bertie690 wants to merge 1 commit intopagefaultgames:betafrom
Open
refactor: clean up and denest AttemptCapturePhase#7145Bertie690 wants to merge 1 commit intopagefaultgames:betafrom
AttemptCapturePhase#7145Bertie690 wants to merge 1 commit intopagefaultgames:betafrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What are the changes the user will see?
N/A
Why am I making these changes?
AttemptCapturePhasewas 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_BALLfor 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
betaas my base branchbeta,mainor the name of another long-lived feature branchpnpm test:silentto test locally)pnpm test:create) or updated existing tests related to the PR's changes if necessary