2024-08-22 06:49:33 -07:00
|
|
|
import { BattlerIndex } from "#app/battle";
|
2024-07-25 16:43:48 -07:00
|
|
|
import { applyAbAttrs, applyPostDefendAbAttrs, applyPreAttackAbAttrs, MoveEffectChanceMultiplierAbAttr, MovePowerBoostAbAttr, PostDefendTypeChangeAbAttr } from "#app/data/ability";
|
2024-09-02 22:12:34 -04:00
|
|
|
import { Stat } from "#enums/stat";
|
2024-08-22 06:49:33 -07:00
|
|
|
import { MoveEffectPhase } from "#app/phases/move-effect-phase";
|
2024-06-17 18:30:42 -06:00
|
|
|
import * as Utils from "#app/utils";
|
2024-07-25 16:43:48 -07:00
|
|
|
import { Abilities } from "#enums/abilities";
|
|
|
|
import { Moves } from "#enums/moves";
|
|
|
|
import { Species } from "#enums/species";
|
2024-08-22 06:49:33 -07:00
|
|
|
import GameManager from "#test/utils/gameManager";
|
2024-07-25 16:43:48 -07:00
|
|
|
import Phaser from "phaser";
|
|
|
|
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
|
2024-10-10 11:28:26 -04:00
|
|
|
import { allMoves } from "#app/data/move";
|
2024-06-17 18:30:42 -06:00
|
|
|
|
|
|
|
|
|
|
|
describe("Abilities - Sheer Force", () => {
|
|
|
|
let phaserGame: Phaser.Game;
|
|
|
|
let game: GameManager;
|
|
|
|
|
|
|
|
beforeAll(() => {
|
|
|
|
phaserGame = new Phaser.Game({
|
|
|
|
type: Phaser.HEADLESS,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
game.phaseInterceptor.restoreOg();
|
|
|
|
});
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
game = new GameManager(phaserGame);
|
2024-10-04 13:08:31 +08:00
|
|
|
const movesToUse = [ Moves.AIR_SLASH, Moves.BIND, Moves.CRUSH_CLAW, Moves.TACKLE ];
|
2024-07-25 14:48:48 -07:00
|
|
|
game.override.battleType("single");
|
2024-07-25 14:57:47 -07:00
|
|
|
game.override.enemySpecies(Species.ONIX);
|
2024-07-25 15:29:19 -07:00
|
|
|
game.override.startingLevel(100);
|
2024-07-25 15:51:05 -07:00
|
|
|
game.override.moveset(movesToUse);
|
2024-10-04 13:08:31 +08:00
|
|
|
game.override.enemyMoveset([ Moves.TACKLE, Moves.TACKLE, Moves.TACKLE, Moves.TACKLE ]);
|
2024-06-17 18:30:42 -06:00
|
|
|
});
|
|
|
|
|
2024-08-22 06:49:33 -07:00
|
|
|
it("Sheer Force", async () => {
|
2024-06-17 18:30:42 -06:00
|
|
|
const moveToUse = Moves.AIR_SLASH;
|
2024-07-25 15:35:20 -07:00
|
|
|
game.override.ability(Abilities.SHEER_FORCE);
|
2024-06-17 18:30:42 -06:00
|
|
|
await game.startBattle([
|
|
|
|
Species.PIDGEOT
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
|
|
game.scene.getEnemyParty()[0].stats[Stat.SPDEF] = 10000;
|
|
|
|
expect(game.scene.getParty()[0].formIndex).toBe(0);
|
|
|
|
|
2024-08-22 06:49:33 -07:00
|
|
|
game.move.select(moveToUse);
|
2024-06-17 18:30:42 -06:00
|
|
|
|
2024-10-04 13:08:31 +08:00
|
|
|
await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]);
|
2024-06-17 18:30:42 -06:00
|
|
|
await game.phaseInterceptor.to(MoveEffectPhase, false);
|
|
|
|
|
|
|
|
const phase = game.scene.getCurrentPhase() as MoveEffectPhase;
|
|
|
|
const move = phase.move.getMove();
|
|
|
|
expect(move.id).toBe(Moves.AIR_SLASH);
|
|
|
|
|
|
|
|
//Verify the move is boosted and has no chance of secondary effects
|
|
|
|
const power = new Utils.IntegerHolder(move.power);
|
|
|
|
const chance = new Utils.IntegerHolder(move.chance);
|
|
|
|
|
2024-11-02 22:55:15 -04:00
|
|
|
applyAbAttrs(MoveEffectChanceMultiplierAbAttr, phase.getUserPokemon()!, null, false, chance, move, phase.getFirstTarget(), false);
|
|
|
|
applyPreAttackAbAttrs(MovePowerBoostAbAttr, phase.getUserPokemon()!, phase.getFirstTarget()!, move, false, power);
|
2024-06-17 18:30:42 -06:00
|
|
|
|
|
|
|
expect(chance.value).toBe(0);
|
2024-08-22 06:49:33 -07:00
|
|
|
expect(power.value).toBe(move.power * 5461 / 4096);
|
2024-06-17 18:30:42 -06:00
|
|
|
|
|
|
|
|
|
|
|
}, 20000);
|
|
|
|
|
2024-08-22 06:49:33 -07:00
|
|
|
it("Sheer Force with exceptions including binding moves", async () => {
|
2024-06-17 18:30:42 -06:00
|
|
|
const moveToUse = Moves.BIND;
|
2024-07-25 15:35:20 -07:00
|
|
|
game.override.ability(Abilities.SHEER_FORCE);
|
2024-06-17 18:30:42 -06:00
|
|
|
await game.startBattle([
|
|
|
|
Species.PIDGEOT
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
|
|
game.scene.getEnemyParty()[0].stats[Stat.DEF] = 10000;
|
|
|
|
expect(game.scene.getParty()[0].formIndex).toBe(0);
|
|
|
|
|
2024-08-22 06:49:33 -07:00
|
|
|
game.move.select(moveToUse);
|
2024-06-17 18:30:42 -06:00
|
|
|
|
2024-10-04 13:08:31 +08:00
|
|
|
await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]);
|
2024-06-17 18:30:42 -06:00
|
|
|
await game.phaseInterceptor.to(MoveEffectPhase, false);
|
|
|
|
|
|
|
|
const phase = game.scene.getCurrentPhase() as MoveEffectPhase;
|
|
|
|
const move = phase.move.getMove();
|
|
|
|
expect(move.id).toBe(Moves.BIND);
|
|
|
|
|
|
|
|
//Binding moves and other exceptions are not affected by Sheer Force and have a chance.value of -1
|
|
|
|
const power = new Utils.IntegerHolder(move.power);
|
|
|
|
const chance = new Utils.IntegerHolder(move.chance);
|
|
|
|
|
2024-11-02 22:55:15 -04:00
|
|
|
applyAbAttrs(MoveEffectChanceMultiplierAbAttr, phase.getUserPokemon()!, null, false, chance, move, phase.getFirstTarget(), false);
|
|
|
|
applyPreAttackAbAttrs(MovePowerBoostAbAttr, phase.getUserPokemon()!, phase.getFirstTarget()!, move, false, power);
|
2024-06-17 18:30:42 -06:00
|
|
|
|
|
|
|
expect(chance.value).toBe(-1);
|
|
|
|
expect(power.value).toBe(move.power);
|
|
|
|
|
|
|
|
|
|
|
|
}, 20000);
|
|
|
|
|
2024-08-22 06:49:33 -07:00
|
|
|
it("Sheer Force with moves with no secondary effect", async () => {
|
2024-06-17 18:30:42 -06:00
|
|
|
const moveToUse = Moves.TACKLE;
|
2024-07-25 15:35:20 -07:00
|
|
|
game.override.ability(Abilities.SHEER_FORCE);
|
2024-06-17 18:30:42 -06:00
|
|
|
await game.startBattle([
|
|
|
|
Species.PIDGEOT
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
|
|
game.scene.getEnemyParty()[0].stats[Stat.DEF] = 10000;
|
|
|
|
expect(game.scene.getParty()[0].formIndex).toBe(0);
|
|
|
|
|
2024-08-22 06:49:33 -07:00
|
|
|
game.move.select(moveToUse);
|
2024-06-17 18:30:42 -06:00
|
|
|
|
2024-10-04 13:08:31 +08:00
|
|
|
await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]);
|
2024-06-17 18:30:42 -06:00
|
|
|
await game.phaseInterceptor.to(MoveEffectPhase, false);
|
|
|
|
|
|
|
|
const phase = game.scene.getCurrentPhase() as MoveEffectPhase;
|
|
|
|
const move = phase.move.getMove();
|
|
|
|
expect(move.id).toBe(Moves.TACKLE);
|
|
|
|
|
|
|
|
//Binding moves and other exceptions are not affected by Sheer Force and have a chance.value of -1
|
|
|
|
const power = new Utils.IntegerHolder(move.power);
|
|
|
|
const chance = new Utils.IntegerHolder(move.chance);
|
|
|
|
|
2024-11-02 22:55:15 -04:00
|
|
|
applyAbAttrs(MoveEffectChanceMultiplierAbAttr, phase.getUserPokemon()!, null, false, chance, move, phase.getFirstTarget(), false);
|
|
|
|
applyPreAttackAbAttrs(MovePowerBoostAbAttr, phase.getUserPokemon()!, phase.getFirstTarget()!, move, false, power);
|
2024-06-17 18:30:42 -06:00
|
|
|
|
|
|
|
expect(chance.value).toBe(-1);
|
|
|
|
expect(power.value).toBe(move.power);
|
|
|
|
|
|
|
|
|
|
|
|
}, 20000);
|
|
|
|
|
2024-08-22 06:49:33 -07:00
|
|
|
it("Sheer Force Disabling Specific Abilities", async () => {
|
2024-06-17 18:30:42 -06:00
|
|
|
const moveToUse = Moves.CRUSH_CLAW;
|
2024-07-25 15:05:32 -07:00
|
|
|
game.override.enemyAbility(Abilities.COLOR_CHANGE);
|
2024-08-22 06:49:33 -07:00
|
|
|
game.override.startingHeldItems([{ name: "KINGS_ROCK", count: 1 }]);
|
2024-07-25 15:35:20 -07:00
|
|
|
game.override.ability(Abilities.SHEER_FORCE);
|
2024-06-17 18:30:42 -06:00
|
|
|
await game.startBattle([
|
|
|
|
Species.PIDGEOT
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
|
|
game.scene.getEnemyParty()[0].stats[Stat.DEF] = 10000;
|
|
|
|
expect(game.scene.getParty()[0].formIndex).toBe(0);
|
|
|
|
|
2024-08-22 06:49:33 -07:00
|
|
|
game.move.select(moveToUse);
|
2024-06-17 18:30:42 -06:00
|
|
|
|
2024-10-04 13:08:31 +08:00
|
|
|
await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]);
|
2024-06-17 18:30:42 -06:00
|
|
|
await game.phaseInterceptor.to(MoveEffectPhase, false);
|
|
|
|
|
|
|
|
const phase = game.scene.getCurrentPhase() as MoveEffectPhase;
|
|
|
|
const move = phase.move.getMove();
|
|
|
|
expect(move.id).toBe(Moves.CRUSH_CLAW);
|
|
|
|
|
|
|
|
//Disable color change due to being hit by Sheer Force
|
|
|
|
const power = new Utils.IntegerHolder(move.power);
|
|
|
|
const chance = new Utils.IntegerHolder(move.chance);
|
2024-08-07 09:23:12 -07:00
|
|
|
const user = phase.getUserPokemon()!;
|
2024-11-02 22:55:15 -04:00
|
|
|
const target = phase.getFirstTarget()!;
|
2024-06-17 18:30:42 -06:00
|
|
|
const opponentType = target.getTypes()[0];
|
|
|
|
|
2024-08-21 18:29:21 -07:00
|
|
|
applyAbAttrs(MoveEffectChanceMultiplierAbAttr, user, null, false, chance, move, target, false);
|
|
|
|
applyPreAttackAbAttrs(MovePowerBoostAbAttr, user, target, move, false, power);
|
2024-06-17 18:30:42 -06:00
|
|
|
applyPostDefendAbAttrs(PostDefendTypeChangeAbAttr, target, user, move, target.apply(user, move));
|
|
|
|
|
|
|
|
expect(chance.value).toBe(0);
|
2024-08-22 06:49:33 -07:00
|
|
|
expect(power.value).toBe(move.power * 5461 / 4096);
|
2024-06-17 18:30:42 -06:00
|
|
|
expect(target.getTypes().length).toBe(2);
|
|
|
|
expect(target.getTypes()[0]).toBe(opponentType);
|
|
|
|
|
|
|
|
}, 20000);
|
|
|
|
|
2024-10-10 11:28:26 -04:00
|
|
|
it("Two Pokemon with abilities disabled by Sheer Force hitting each other should not cause a crash", async () => {
|
|
|
|
const moveToUse = Moves.CRUNCH;
|
|
|
|
game.override.enemyAbility(Abilities.COLOR_CHANGE)
|
|
|
|
.ability(Abilities.COLOR_CHANGE)
|
|
|
|
.moveset(moveToUse)
|
|
|
|
.enemyMoveset(moveToUse);
|
|
|
|
|
|
|
|
await game.classicMode.startBattle([
|
|
|
|
Species.PIDGEOT
|
|
|
|
]);
|
|
|
|
|
|
|
|
const pidgeot = game.scene.getParty()[0];
|
|
|
|
const onix = game.scene.getEnemyParty()[0];
|
|
|
|
|
|
|
|
pidgeot.stats[Stat.DEF] = 10000;
|
|
|
|
onix.stats[Stat.DEF] = 10000;
|
|
|
|
|
|
|
|
game.move.select(moveToUse);
|
|
|
|
await game.toNextTurn();
|
|
|
|
|
|
|
|
// Check that both Pokemon's Color Change activated
|
|
|
|
const expectedTypes = [ allMoves[moveToUse].type ];
|
|
|
|
expect(pidgeot.getTypes()).toStrictEqual(expectedTypes);
|
|
|
|
expect(onix.getTypes()).toStrictEqual(expectedTypes);
|
|
|
|
});
|
|
|
|
|
2024-06-17 18:30:42 -06:00
|
|
|
//TODO King's Rock Interaction Unit Test
|
|
|
|
});
|