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

[Move] Add makeContact To Physical Part Of Shell Side Arm #4982

Open
wants to merge 8 commits into
base: beta
Choose a base branch
from

Conversation

geeilhan
Copy link
Contributor

@geeilhan geeilhan commented Dec 10, 2024

What are the changes the user will see?

The user now makes physical contact if Shell Side Arm does physical damage.

What are the changes from a developer perspective?

Now calls makesContact() if move turns physical.

Removed .partial()

Added test that checks for contact

Screenshots/Videos

Before changes vs Rough Skin:

shell-side-arm-implementation-before.webm

After changes vs Rough Skin:

shell-side-arm-implementation-after.webm

How to test the changes?

Give enemy Pokemon Rough Skin (Ability) and use Side Shell Arm. Make sure the enemy Pokemon has more SPDEF than DEF.

const overrides = {
  OPP_SPECIES_OVERRIDE: Species.SNORLAX,
  OPP_MOVESET_OVERRIDE: [ Moves.SPLASH ],
  OPP_ABILITY_OVERRIDE: Abilities.ROUGH_SKIN,
  OPP_LEVEL_OVERRIDE: 20,
  MOVESET_OVERRIDE: [ Moves.SHELL_SIDE_ARM ],
} satisfies Partial<InstanceType<typeof DefaultOverrides>>;

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 tested the changes manually?
  • Are all unit tests still passing? (npm run test)
    • Have I created new automated tests (npm run create-test) or updated existing tests related to the PR's changes?
  • Have I provided screenshots/videos of the changes (if applicable)?
    • Have I made sure that any UI change works for both UI themes (default and legacy)?

@geeilhan geeilhan requested a review from a team as a code owner December 10, 2024 09:05
@Tempo-anon
Copy link
Collaborator

Tempo-anon commented Dec 10, 2024

Hey geeilhan, are you on the discord server? I have some questions that I think may be easier discussed there

Copy link
Collaborator

@Tempo-anon Tempo-anon left a comment

Choose a reason for hiding this comment

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

I don't think this works as it's making contact even when special. Can you add the following test?

  it("should not make contact if the move becomes special", async () => {
    game.override.enemySpecies(Species.SLOWBRO).enemyAbility(Abilities.ROUGH_SKIN);

    await game.classicMode.startBattle([Species.XURKITREE]);

    const player = game.scene.getPlayerPokemon()!;

    game.move.select(Moves.SHELL_SIDE_ARM);
    await game.toNextTurn();

    expect(player.getMaxHp()).toBe(player.hp);
  });

@geeilhan
Copy link
Contributor Author

geeilhan commented Dec 11, 2024

I don't think this works as it's making contact even when special. Can you add the following test?

  it("should not make contact if the move becomes special", async () => {
    game.override.enemySpecies(Species.SLOWBRO).enemyAbility(Abilities.ROUGH_SKIN);

    await game.classicMode.startBattle([Species.XURKITREE]);

    const player = game.scene.getPlayerPokemon()!;

    game.move.select(Moves.SHELL_SIDE_ARM);
    await game.toNextTurn();

    expect(player.getMaxHp()).toBe(player.hp);
  });

Thanks for the feedback. Will implement this too

EDIT: That is weird because in my manual tests is works properly (no contact)

Screencast.from.2024-12-11.01-32-47.webm

I used this to manually test it:

const overrides = {
  OPP_MOVESET_OVERRIDE: [ Moves.SPLASH ],
  OPP_ABILITY_OVERRIDE: Abilities.ROUGH_SKIN,
  OPP_LEVEL_OVERRIDE: 15,
  MOVESET_OVERRIDE: [ Moves.SHELL_SIDE_ARM ],
  OPP_SPECIES_OVERRIDE: Species.SLOWBRO,
  STARTER_SPECIES_OVERRIDE: Species.XURKITREE,
} satisfies Partial<InstanceType<typeof DefaultOverrides>>;

I also tried to add makesContact(false) to the move if the move stays special but makesContact Flag is still set during the tests. During the tests I noticed that the moves stays special as it should but somehow the MoveFlags.MAKES_CONTACT is set but I can't figure out where (setFlag(MoveFlags.MAKES_CONTACT) and makesContact() are never improperly called)

@Tempo-anon
Copy link
Collaborator

That is weird. For reference I was testing out something like

override apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean {
    const category = args[0] as NumberHolder;

    const predictedPhysDmg = target.getBaseDamage(user, move, MoveCategory.PHYSICAL, true, true);
    const predictedSpecDmg = target.getBaseDamage(user, move, MoveCategory.SPECIAL, true, true);

    // Random chance of being physical or special if predicted damage is tied
    if (predictedPhysDmg > predictedSpecDmg || (predictedPhysDmg === predictedSpecDmg && user.randSeedInt(2) === 0)) {
      category.value = MoveCategory.PHYSICAL;
      move.makesContact();
      console.log("CONTACT");
      return true;
    }
    move.makesContact(false);
    console.log("NO CONTACT");
    return false;
  }

and when I npm run test shell_side_arm I get the following output

stdout | src/test/moves/shell_side_arm.test.ts > Moves - Shell Side Arm > should not make contact if the move becomes special
[ { targets: [ 2 ], multiple: false }, 'Xurkitree' ]
[ 'setMode', 'MESSAGE (=0)', [] ]
[ '%cStart Phase EnemyCommandPhase', 'color:green;' ]

stdout | src/test/moves/shell_side_arm.test.ts > Moves - Shell Side Arm > should not make contact if the move becomes special
[ '%cStart Phase TurnStartPhase', 'color:green;' ]

stdout | src/test/moves/shell_side_arm.test.ts > Moves - Shell Side Arm > should not make contact if the move becomes special
[ '%cStart Phase MovePhase', 'color:green;' ]

stdout | src/test/moves/shell_side_arm.test.ts > Moves - Shell Side Arm > should not make contact if the move becomes special
[ 'SHELL_SIDE_ARM' ]
[ '%cStart Phase MessagePhase', 'color:green;' ]

stdout | src/test/moves/shell_side_arm.test.ts > Moves - Shell Side Arm > should not make contact if the move becomes special
[ 'Xurkitree used Shell Side Arm!' ]
[ '%cStart Phase MoveEffectPhase', 'color:green;' ]

stdout | src/test/moves/shell_side_arm.test.ts > Moves - Shell Side Arm > should not make contact if the move becomes special
[ 'NO CONTACT' ]
[ 'crit stage: +0' ]
[ 'NO CONTACT' ]
[ 'base damage', 161.8754098360656, 'Shell Side Arm', 90, 387, 183 ]
[ 'damage', 161, 'Shell Side Arm' ]
[ '%cStart Phase DamageAnimPhase', 'color:green;' ]

stdout | src/test/moves/shell_side_arm.test.ts > Moves - Shell Side Arm > should not make contact if the move becomes special
[ '%cStart Phase DamageAnimPhase', 'color:green;' ]

stdout | src/test/moves/shell_side_arm.test.ts > Moves - Shell Side Arm > should not make contact if the move becomes special
[ '%cStart Phase ShowAbilityPhase', 'color:green;' ]

stdout | src/test/moves/shell_side_arm.test.ts > Moves - Shell Side Arm > should not make contact if the move becomes special
[ '%cStart Phase MessagePhase', 'color:green;' ]

stdout | src/test/moves/shell_side_arm.test.ts > Moves - Shell Side Arm > should not make contact if the move becomes special
[ "Wild Slowbro's Rough Skin\nhurt its attacker!" ]
[ '%cStart Phase MoveEndPhase', 'color:green;' ]

AssertionError: expected 276 to be 242 // Object.is equality

So it's definitely reaching the line where it's logging NO CONTACT but it's still having contact.

@geeilhan
Copy link
Contributor Author

That is weird.
So it's definitely reaching the line where it's logging NO CONTACT but it's still having contact.

Yes I found the same issue so I thought that maybe MAKES_CONTACT is set when the constructor is called or somewhere else at the beginning but it not set anywhere

@geeilhan
Copy link
Contributor Author

geeilhan commented Dec 11, 2024

That is weird.
So it's definitely reaching the line where it's logging NO CONTACT but it's still having contact.

Yes I found the same issue so I thought that maybe MAKES_CONTACT is set when the constructor is called or somewhere else at the beginning but it not set anywhere

So the solution for the tests to work was to move the no-contact-test to the top of the automated tests...

I think the Flags from when it made contact stays since they don't get reset.

Edit: Added changes where apply() checks if MAKES_CONTACT is set (probably from some previous round) and removes it if Shell Side Arm stays special.

Copy link
Contributor Author

@geeilhan geeilhan left a comment

Choose a reason for hiding this comment

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

Tests should work now

@Tempo-anon
Copy link
Collaborator

Yep looks like tests pass with that. Strangely, replacing the code block

    if (move.hasFlag(MoveFlags.MAKES_CONTACT)) {
      move.makesContact(false);
    }

with just move.makesContact(False); results in the test failing 🤔

Tempo-anon
Tempo-anon previously approved these changes Dec 11, 2024
src/data/move.ts Outdated Show resolved Hide resolved
@geeilhan
Copy link
Contributor Author

Yep looks like tests pass with that. Strangely, replacing the code block

    if (move.hasFlag(MoveFlags.MAKES_CONTACT)) {
      move.makesContact(false);
    }

with just move.makesContact(False); results in the test failing 🤔

This does seem weird

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Move Affects a move
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants