Skip to content
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

[Bug] Stat Stages are now changed individually instead of all at once #4457

Merged
merged 16 commits into from
Oct 12, 2024

Conversation

PrabbyDD
Copy link
Contributor

@PrabbyDD PrabbyDD commented Sep 27, 2024

What are the changes the user will see?

Defiant and Competitive will now properly interact with moves that modify multiple stats stages.

Why am I making these changes?

Fixes #4281

What are the changes from a developer perspective?

If multiple stats are being changed in StatStageChangePhase, a new SSCPhase is created for each individual stat and then the current SSCPhase is ended.

Screenshots/Videos

defiant.fix.mp4

How to test the changes?

Override file, or the test file made

Checklist

  • I'm using beta as my base branch
  • There is no overlap with another PR?
  • The PR is self-contained and cannot be split into smaller PRs?
  • Have I provided a clear explanation of the changes?
  • Have I considered writing automated tests for the issue?
  • [ ] If I have text, did I make it translatable and add a key in the English locale file(s)?
  • Have I tested the changes (manually)?
    • Are all unit tests still passing? (npm run test)
  • Are the changes visual?
    • Have I provided screenshots/videos of the changes?

Copy link
Collaborator

@DayKev DayKev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like the reason this bug exists is because we combine stat changes into a single SSCPhase which is different from mainline where each stat change is handled individually. It speeds things up but apparently also causes bugs. It might be better to instead have the SSCPhase check if it's changing multiple stats at once, and to unshift a new SSCPhase for each stat and end the current SSCPhase after doing so.

src/phases/move-effect-phase.ts Outdated Show resolved Hide resolved
@PrabbyDD
Copy link
Contributor Author

It seems like the reason this bug exists is because we combine stat changes into a single SSCPhase which is different from mainline where each stat change is handled individually. It speeds things up but apparently also causes bugs. It might be better to instead have the SSCPhase check if it's changing multiple stats at once, and to unshift a new SSCPhase for each stat and end the current SSCPhase after doing so.

This is what I was thinking originally but I wasnt sure where to start when trying to implement this - I figured the solution I committed would be simpler and easier to understand. Where do I start when trying to add multiple SSCPhases? Also should I be hard coding it in for specifically defiant and competitive?

Copy link
Collaborator

@torranx torranx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to see Defiant test cases as well

src/phases/stat-stage-change-phase.ts Outdated Show resolved Hide resolved
src/test/abilities/competitive.test.ts Show resolved Hide resolved
@DayKev
Copy link
Collaborator

DayKev commented Sep 27, 2024

It seems like the reason this bug exists is because we combine stat changes into a single SSCPhase which is different from mainline where each stat change is handled individually. It speeds things up but apparently also causes bugs. It might be better to instead have the SSCPhase check if it's changing multiple stats at once, and to unshift a new SSCPhase for each stat and end the current SSCPhase after doing so.

This is what I was thinking originally but I wasnt sure where to start when trying to implement this - I figured the solution I committed would be simpler and easier to understand. Where do I start when trying to add multiple SSCPhases? Also should I be hard coding it in for specifically defiant and competitive?

At the beginning of the SSCPhase's start() function, check if more than one different stat is being changed, and if so make a loop that passes each stat (plus the other constructor fields) to a new SSCPhase via unshiftPhase(new SSCPhase(...)). Then after the loop completes (if it was run) the current SSCPhase is ended via return this.end();. Something like this (more might be necessary, haven't tested this):

  start() {
    if (this.stats.length > 1) {
      for (let i = 0; i < this.stats.length; i++) {
        const stat = [this.stats[i]];
        this.scene.unshiftPhase(new StatStageChangePhase(this.scene, this.battlerIndex, this.selfTarget, stat, this.stages, this.showMessage, this.ignoreAbilities, this.canBeCopied, this.onChange));
      }
      return this.end();
    }

DayKev
DayKev previously approved these changes Sep 27, 2024
@DayKev DayKev changed the title [Bug Fix] Fix for When Multiple Stats are Lowered by a Single Move, Defiant and Competitive raise ATK/SPATK Once [Bug] Stat Stages are now changed individually instead of all at once Sep 27, 2024
@DayKev DayKev added Ability Affects an ability P2 Bug Minor. Non crashing Incorrect move/ability/interaction labels Sep 27, 2024
@DayKev
Copy link
Collaborator

DayKev commented Sep 27, 2024

Updated the OP with the changes.

src/test/abilities/competitive.test.ts Outdated Show resolved Hide resolved
src/test/abilities/defiant.test.ts Outdated Show resolved Hide resolved
src/phases/stat-stage-change-phase.ts Outdated Show resolved Hide resolved
src/phases/stat-stage-change-phase.ts Outdated Show resolved Hide resolved
src/test/abilities/competitive.test.ts Outdated Show resolved Hide resolved
src/test/abilities/competitive.test.ts Outdated Show resolved Hide resolved
src/test/abilities/defiant.test.ts Outdated Show resolved Hide resolved
src/test/abilities/defiant.test.ts Outdated Show resolved Hide resolved
Co-authored-by: Adrian T. <[email protected]>
src/test/abilities/competitive.test.ts Outdated Show resolved Hide resolved
src/test/abilities/defiant.test.ts Outdated Show resolved Hide resolved
@DayKev DayKev requested a review from torranx October 4, 2024 06:33
@DayKev DayKev merged commit ebb7612 into pagefaultgames:beta Oct 12, 2024
13 checks passed
@PrabbyDD PrabbyDD deleted the prabbyd4281 branch October 15, 2024 07:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Ability Affects an ability P2 Bug Minor. Non crashing Incorrect move/ability/interaction
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug] When Multiple Stats are Lowered by a Single Move, Defiant and Competitive raise ATK/SPATK Once
4 participants