[Refactor][Move] Add options
param interface for MoveEffectAttr
#4710
+171
−97
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?
At the time of writing this,
MoveEffectAttr
has five optional fields:These fields help control when the attribute's effect triggers and what chance the effect has of triggering, but in general these fields are used very sparsely throughout the move code to resolve specific edge cases.
At the same time, we currently set these fields with a long sequence of constructor params:
This can cause a lot of issues in terms of readability. For example, Triple Arrows has an attribute for its chance to drop the target's Defense that requires
effectChanceOverride
to set its chance of applying to 50%. Despite only requiring one of the optional parameters, this attribute needs to be constructed like this inallMoves
:Of course, this also extends beyond the existing options. With potential additions from future implementations and the move scoring flags planned for the AI Rework, the code's readability is only going to get worse if the same structure is kept.
What are the changes from a developer perspective?
data/move
:MoveEffectOptions
andStatStageChangeAttrOptions
) to store optional parameters forMoveEffectAttrs
andStatStageChangeAttrs
, respectively.MoveEffectAttr
now stores all of these parameters in a single field:StatStageChangeAttr
.get
functions allow optional parameters to be accessed in the same way as before (albeitreadonly
) and with the same default values.SecretPowerAttr
has been changed to reflecteffectChanceOverride
now beingreadonly
. The effect chance roll is now done within attributes invoked internally within theapply
function.The End Result: Attributes e.g. Triple Arrows' Defense drop can be initialized as follows:
Screenshots/Videos
N/A
How to test the changes?
npm run test secret_power
(1 test updated)npm run test
for general coverage of attributes with changed syntaxChecklist
beta
as my base branchnpm run test
)