-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Overhaul 'SwitchIn' event for more accurate effect resolution order #10766
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some minor notes on the tests.
Some notes about this refactor: the The Handler resolution order has been reworked to automatically sort effects so their handlers activate in the same order they do in-game. This preserves hazard activation timing within the The events
*I rethought this and made EffectState an interface again. Its initialization is handled by a |
Several tests have been unskipped, as the mechanics they check for now work correctly. The two tests currently failing are both related to Commander, and before I can fix them I need confirmation on some mechanics questions. The eject pack one was written when Commander activated instantly instead of waiting for its turn in the switch-in event order, and now Intimidate correctly activates first, so I'm not sure if the test's assertions are accurate to the games. If they are, then this test is failing because Eject Pack is bugged in a way that I didn't fix as part of this refactor because I didn't have the relevant information on its activation timings. As for the other test, the issue is that the Tatsugiri already has Commander, so when it transforms into another Pokemon with Commander, its ability isn't restarted. However, Commander's |
95409ab
to
d54b495
Compare
I forgot I did this. It doesn't need to cover seeds and Room Service because they are properly negated by Magic Room on switch-in, so your suggested change is fine. |
* Remove unnused choices * Remove redundant isStarted * Override runSwitch * Complete comment * Reset abilityState.started * Update data/mods/gen7letsgo/scripts.ts --------- Co-authored-by: pyuk-bot
onSwitchInPriority review:
|
I'd like to see some more tests for our new switch-in behavior. Things like:
Everything else looks really solid from my review. Very good job. |
I vvould say that is outside the scope of this PR. I vvas already considering making that change after this before #10832 vvas made, and I brought up the idea of moving all the Booster Energy code there. |
#10832 I've moved the Booster Energy logic to the |
Won't the new |
If there are residual event handlers that don't have a suborder set that are running in the same order as handlers that do have a suborder set, that's already a bug. After combing through all of our residuals, I could only find one residual order vvith multiple handlers in it vvhere one had a suborder set and others didn't: leftovers, berry, and gold berry in gen 2. I've asked Marty vvhat the correct order there should be. |
I’m not sure if you understood what I meant. If I'm understanding this correctly: Currently, all effects without an explicit residual subOrder default to zero. With this PR, they will instead default to the subOrder for their effect type. For instance, Power Construct doesn’t have a defined onResidualSubOrder, so it currently defaults to zero, which causes it to run before Leftovers, which has a subOrder of 1. With this PR, Power Construct will have a subOrder of 7 (abilities), causing it to run after Leftovers. The current subOrder values are unrelated to the new subOrder values assigned to each effect type, so basically, we have "two different metrics" for subOrder. This is only a problem for residuals, as they are the only events that currently use it. Let me know if I'm mistaken. |
Residuals use both |
I think pyuk answered correctly here, but I'll also mention that in an ideal case, we would never need to hardcode suborders in the first place in modern generations. The suborders should just work out of the box based on the event the various effects are tied to. To put it another way, Abilities should always go before items, no matter if that's when calculating base power, calculating Speed, running effects that happen on switchin, end-of-turn effects, whatever the event. That would of course require having implemented every single event the game uses accurately, so it's not easy or anything. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to go as far as I'm concerned. Since it is a large refactor, I'd like to merge at a convenient time for pyuk to be able to react to any oversights that snuck through.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is very cool, nice work pyuk! I scrolled through and couldn't think of anything missing or out of place, seems good to ship whenever*. 👍
*Since SPL is ongoing for the next two months or so, ideally this is merged soon after the tours server updates and restarts on any given Monday, allowing the most possible time for the main server to catch any issues before the following week.
This doesn't include a fix that lets it copy multiple Intrepid Swords, unfortunately. That still needs a larger refactor to how events trigger after simultaneous switches in.
Edit: now it does. Sorry, I got a little carried away.