-
-
Notifications
You must be signed in to change notification settings - Fork 1.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
[Move] Use BattlerTag for move-disabling effects #2051
Conversation
I've added some moves as a proof of concept to another branch. For example, here's Throat Chop and Taunt: 94cfb53 |
Rewrote OP to focus more on integrating the variety of disparate Disable effect PRs. |
Converted to draft due to significant overlap with other PRs. |
Imo it'd be best if this PR was merged and then the other PRs were updated to use the new, non-spaghetti code. |
I'm just going through this, but as the developer of #1121, I have no objection to cleaning this up. I kinda touched on it in some of my back and forth in that one, I wasn't thrilled with what it required to implement. Not only did I talk about how I was hesitant to update code on something that basically affected every move, but on my end I also was seeing exactly what you are trying to address based on your summary here. I'm all for a change that creates a better framework for my code, I'll gladly update it rather than add extra code to an "unrelated" section just for my move. I'm actually glad I had to step away for a few weeks and haven't had my code committed if it means we're getting a better framework! |
I agree with this, don't try to update my move, I'll do that gladly! |
7dc4c78
to
0ed7024
Compare
WTF did i do to make those tests fail 😭 |
One of the overrides changed how it worked (instead of |
Hi, thank you for working on this. I was wondering if this was able to be extended to multiple categories / attrs of moves. I'm currently working on Heal Block right now and was hoping to try disabling moves based on attributes. |
Are you still working on this @zacharied ? |
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.
couple nits, some docs are missing @param
and @returns
too, otherwise looks good to me
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.
lgtm
What are the changes?
This PR implements a new
BattlerTag
for move-disabling effects such as those done by Disable, Taunt, Throat Chop, etc.. It also replaces the implementation of the move Disable and the ability Cursed Body with a new implementation using this tag.Why am I doing these changes?
The current approach
Disabling is a somewhat common effect of moves, but the current implementation of disabling has a few issues:
phases.ts
to implement new disabling effects#751 is an example of a PR that attempts to solve this problem by extending the current approach, using Throat Chop as a baseline. It carries with it the same issues as the current implementation of Disable, namely in that it adds more state for the Pokemon object to deal with. Incorrect behavior can be observed in #751 if a pokemon were to learn a sound-based move after getting hit by Throat Chop; the sound-based move would execute successfully because the
disabledMoves
array does not reflect the actual disabled moves according to the rules. This would be incorrect, as all sound-based moves should be disabled regardless of if they were originally in the moveset.Related work-in-progress
Other PRs implement new Tags, which feels safer to me. #1121 implements Imprison correctly, but my concern is over tacking more conditions onto
PokemonMove.isUsable
. Every condition added to that function also means more code spread elsewhere to account for displaying the move-specific messages and other such effects. I am concerned that by the time we have all the moves implemented, the function will become incredibly long while simultaneously requiring its callers to take on the work of presenting the correct messages. With that said, a lot of work has gone into verifying the correctness of Imprison in #1121, so I don't want to overstep any boundaries of what seems to be the more mature PR.Likewise, there is #1153, which is an overall agreeable solution, but I'm unsure if a PR with that many features will get merged anytime soon. An intermediate PR that lays the groundwork for those moves, like this PR, might be necessary to get that through.
To avoid invalidating the work of these existing commits, my idea was to introduce some system-level changes that will make move-disabling effects more consistent and easier to implement. I haven't checked the exact merges myself, but I think things like #1121 and #1153 could coexist with and benefit from these changes they were to adapt this tag system. But since those commits are further along the pipeline, I'd also be happy to wait for them to go mainline and then rebase my changes onto those implementations. I'm open to all discussion!
This PR
In this PR, to implement new disable types, you only need to extend
DisablingBattlerTag
and implement itsisMoveDisabled
to match the filter applied by the move. Then, any Pokemon that has that tag will handle disabling the matching moves -- no need to editPokemonMove.isUsable
orMovePhase.canMove
or anything like that.What did change?
Add abstract class
DisablingBattlerTag
that serves as the base for all tags that disable moves. The tag lapses inPRE_MOVE
to cancel any disable move getting used. It also lapses atTURN_END
to remove the tag. Also updated menus and AI command selection to prevent players and enemies from selecting disabled moves.Add a battler tag
DisabledTag
that represents Disabling as applied by the move Disable and ability Cursed Body. Also removeDisableMoveAttr
(the old implementation of the Disable move) and replace Disable's effect with adding aDisabledTag
.Add battler tag type
DISABLED
which maps toDisabledTag
. This tag has been given the sametargetBenefit
as was previously bestowed byDisableMoveAttr
.disabledMove
anddisabledTurns
fields removed fromPokemonSummonData
. Any time those fields would be set, instead an instance of tagDisabledTag
is applied. Because this uses the tag system, all the code that had to manually manipulate/checkdisabledTurns
has been removed as well.Add new functions
Pokemon.getDisablingTag(Moves)
andPokemon.isMoveDisabled(Moves)
that find the tag that disables a given move (if it exists), and checks whether the Pokemon has a tag that disables the given move, respectively.Screenshots/Videos
How to test the changes?
I used the following overrides for testing beyond the unit tests.
Checklist
npm run test
)