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
25 changes: 19 additions & 6 deletions src/data/move.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4612,15 +4612,29 @@ export class ShellSideArmCategoryAttr extends VariableMoveCategoryAttr {
const predictedPhysDmg = target.getBaseDamage(user, move, MoveCategory.PHYSICAL, true, true);
const predictedSpecDmg = target.getBaseDamage(user, move, MoveCategory.SPECIAL, true, true);

if (predictedPhysDmg > predictedSpecDmg) {
category.value = MoveCategory.PHYSICAL;
return true;
} else if (predictedPhysDmg === predictedSpecDmg && user.randSeedInt(2) === 0) {
const shouldUsePhysical =
predictedPhysDmg > predictedSpecDmg ||
(predictedPhysDmg === predictedSpecDmg && user.randSeedInt(2) === 0);

if (shouldUsePhysical) {
category.value = MoveCategory.PHYSICAL;
move.makesContact();
return true;
}
this.resetContactFlag(move);
return false;
}

/**
* MoveFlags are not reset every turn so if this flag is set it needs to be reset if the move is a special attack
* This fucntion resets the {@linkcode MoveFlags.MAKES_CONTACT}
* @param move this move should be Shell Side Arm
*/
private resetContactFlag(move: Move): void {
if (move.hasFlag(MoveFlags.MAKES_CONTACT)) {
move.makesContact(false);
}
}
}

export class VariableMoveTypeAttr extends MoveAttr {
Expand Down Expand Up @@ -10395,8 +10409,7 @@ export function initMoves() {
.ignoresVirtual(),
new AttackMove(Moves.SHELL_SIDE_ARM, Type.POISON, MoveCategory.SPECIAL, 90, 100, 10, 20, 0, 8)
.attr(ShellSideArmCategoryAttr)
.attr(StatusEffectAttr, StatusEffect.POISON)
.partial(), // Physical version of the move does not make contact
.attr(StatusEffectAttr, StatusEffect.POISON),
new AttackMove(Moves.MISTY_EXPLOSION, Type.FAIRY, MoveCategory.SPECIAL, 100, 100, 5, -1, 0, 8)
.attr(SacrificialAttr)
.target(MoveTarget.ALL_NEAR_OTHERS)
Expand Down
34 changes: 33 additions & 1 deletion src/test/moves/shell_side_arm.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ describe("Moves - Shell Side Arm", () => {
beforeEach(() => {
game = new GameManager(phaserGame);
game.override
.moveset([ Moves.SHELL_SIDE_ARM, Moves.SPLASH ])
.moveset([ Moves.SHELL_SIDE_ARM ])
.battleType("single")
.startingLevel(100)
.enemyLevel(100)
Expand All @@ -47,6 +47,21 @@ describe("Moves - Shell Side Arm", () => {
expect(shellSideArmAttr.apply).toHaveLastReturnedWith(true);
});

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

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

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

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

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

it("remains a special attack if forecasted to deal more damage as special", async () => {
game.override.enemySpecies(Species.SLOWBRO);

Expand Down Expand Up @@ -78,4 +93,21 @@ describe("Moves - Shell Side Arm", () => {

expect(shellSideArmAttr.apply).toHaveLastReturnedWith(false);
});

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

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

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

vi.spyOn(shellSideArmAttr, "apply");

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

expect(shellSideArmAttr.apply).toHaveLastReturnedWith(false);
expect(player.getMaxHp()).toBe(player.hp);
});

});
Loading