mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-06-21 09:02:47 +02:00
Added Payback tests
This commit is contained in:
parent
312884a131
commit
9bb67df9e7
@ -4073,30 +4073,6 @@ export class OpponentHighHpPowerAttr extends VariablePowerAttr {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Attribute to double this move's power if the target hasn't acted yet in the current turn.
|
||||
* Used by {@linkcode Moves.BOLT_BEAK} and {@linkcode Moves.FISHIOUS_REND}
|
||||
*/
|
||||
export class FirstAttackDoublePowerAttr extends VariablePowerAttr {
|
||||
/**
|
||||
* Double this move's power if the user is acting before the target.
|
||||
* @param user - Unused
|
||||
* @param target - The {@linkcode Pokemon} being targeted by this move
|
||||
* @param move - Unused
|
||||
* @param args `[0]` - A {@linkcode NumberHolder} containing move base power
|
||||
* @returns Whether the attribute was successfully applied
|
||||
*/
|
||||
apply(_user: Pokemon, target: Pokemon, move: Move, args: [NumberHolder]): boolean {
|
||||
if (target.turnData.acted) {
|
||||
return false;
|
||||
}
|
||||
|
||||
args[0].value *= 2;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export class TurnDamagedDoublePowerAttr extends VariablePowerAttr {
|
||||
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean {
|
||||
if (user.turnData.attacksReceived.find(r => r.damage && r.sourceId === target.id)) {
|
||||
@ -9579,7 +9555,8 @@ export function initMoves() {
|
||||
new AttackMove(MoveId.CLOSE_COMBAT, PokemonType.FIGHTING, MoveCategory.PHYSICAL, 120, 100, 5, -1, 0, 4)
|
||||
.attr(StatStageChangeAttr, [ Stat.DEF, Stat.SPDEF ], -1, true),
|
||||
new AttackMove(MoveId.PAYBACK, PokemonType.DARK, MoveCategory.PHYSICAL, 50, 100, 10, -1, 0, 4)
|
||||
.attr(MovePowerMultiplierAttr, (user, target, move) => target.getLastXMoves(1).find(m => m.turn === globalScene.currentBattle.turn) || globalScene.currentBattle.turnCommands[target.getBattlerIndex()]?.command === Command.BALL ? 2 : 1),
|
||||
// Payback boosts power on enemy item use
|
||||
.attr(MovePowerMultiplierAttr, (_user, target) => target.turnData.acted || globalScene.currentBattle.turnCommands[target.getBattlerIndex()]?.command === Command.BALL ? 2 : 1),
|
||||
new AttackMove(MoveId.ASSURANCE, PokemonType.DARK, MoveCategory.PHYSICAL, 60, 100, 10, -1, 0, 4)
|
||||
.attr(MovePowerMultiplierAttr, (user, target, move) => target.turnData.damageTaken > 0 ? 2 : 1),
|
||||
new StatusMove(MoveId.EMBARGO, PokemonType.DARK, 100, 15, -1, 0, 4)
|
||||
@ -10791,9 +10768,9 @@ export function initMoves() {
|
||||
.condition(failIfGhostTypeCondition)
|
||||
.attr(AddBattlerTagAttr, BattlerTagType.OCTOLOCK, false, true, 1),
|
||||
new AttackMove(MoveId.BOLT_BEAK, PokemonType.ELECTRIC, MoveCategory.PHYSICAL, 85, 100, 10, -1, 0, 8)
|
||||
.attr(FirstAttackDoublePowerAttr),
|
||||
.attr(MovePowerMultiplierAttr, (_user, target) => target.turnData.acted ? 1 : 2),
|
||||
new AttackMove(MoveId.FISHIOUS_REND, PokemonType.WATER, MoveCategory.PHYSICAL, 85, 100, 10, -1, 0, 8)
|
||||
.attr(FirstAttackDoublePowerAttr)
|
||||
.attr(MovePowerMultiplierAttr, (_user, target) => target.turnData.acted ? 1 : 2)
|
||||
.bitingMove(),
|
||||
new StatusMove(MoveId.COURT_CHANGE, PokemonType.NORMAL, 100, 10, -1, 0, 8)
|
||||
.attr(SwapArenaTagsAttr, [ ArenaTagType.AURORA_VEIL, ArenaTagType.LIGHT_SCREEN, ArenaTagType.MIST, ArenaTagType.REFLECT, ArenaTagType.SPIKES, ArenaTagType.STEALTH_ROCK, ArenaTagType.STICKY_WEB, ArenaTagType.TAILWIND, ArenaTagType.TOXIC_SPIKES ]),
|
||||
|
@ -32,65 +32,40 @@ describe("Abilities - Intimidate", () => {
|
||||
.enemyMoveset(MoveId.SPLASH);
|
||||
});
|
||||
|
||||
it("should lower all non-immune opponents ATK stat stage by 1 of enemy Pokemon on entry and player switch", async () => {
|
||||
it("should lower all opponents' ATK by 1 stage on entry and switch", async () => {
|
||||
await game.classicMode.startBattle([SpeciesId.MIGHTYENA, SpeciesId.POOCHYENA]);
|
||||
|
||||
const player = game.field.getPlayerPokemon()
|
||||
const enemy = game.field.getEnemyPokemon()
|
||||
|
||||
expect(player.species.speciesId).toBe(SpeciesId.MIGHTYENA);
|
||||
const enemy = game.field.getEnemyPokemon();
|
||||
expect(enemy.getStatStage(Stat.ATK)).toBe(-1);
|
||||
expect(player.getStatStage(Stat.ATK)).toBe(-1);
|
||||
|
||||
game.doSwitchPokemon(1);
|
||||
await game.toNextTurn();
|
||||
|
||||
expect(game.field.getPlayerPokemon()).toBe(player);
|
||||
expect(player.getStatStage(Stat.ATK)).toBe(0);
|
||||
expect(enemy.getStatStage(Stat.ATK)).toBe(-2);
|
||||
});
|
||||
|
||||
it("should lower ATK stat stage by 1 for every enemy Pokemon in a double battle on entry", async () => {
|
||||
it("should lower ATK of all opponents in a double battle", async () => {
|
||||
game.override.battleStyle("double");
|
||||
await game.classicMode.startBattle([SpeciesId.MIGHTYENA, SpeciesId.POOCHYENA]);
|
||||
await game.classicMode.startBattle([SpeciesId.MIGHTYENA]);
|
||||
|
||||
const playerField = game.scene.getPlayerField();
|
||||
const enemyField = game.scene.getEnemyField();
|
||||
const [enemy1, enemy2] = game.scene.getEnemyField();
|
||||
|
||||
expect(enemyField[0].getStatStage(Stat.ATK)).toBe(-2);
|
||||
expect(enemyField[1].getStatStage(Stat.ATK)).toBe(-2);
|
||||
expect(playerField[0].getStatStage(Stat.ATK)).toBe(-2);
|
||||
expect(playerField[1].getStatStage(Stat.ATK)).toBe(-2);
|
||||
});
|
||||
|
||||
it("should not activate again if there is no switch or new entry", async () => {
|
||||
await game.classicMode.startBattle([SpeciesId.MIGHTYENA, SpeciesId.POOCHYENA]);
|
||||
|
||||
const player = game.field.getPlayerPokemon()
|
||||
const enemy = game.field.getEnemyPokemon()
|
||||
|
||||
expect(player.getStatStage(Stat.ATK)).toBe(-1);
|
||||
expect(enemy.getStatStage(Stat.ATK)).toBe(-1);
|
||||
|
||||
game.move.select(MoveId.SPLASH);
|
||||
await game.toNextTurn();
|
||||
|
||||
expect(player.getStatStage(Stat.ATK)).toBe(-1);
|
||||
expect(enemy.getStatStage(Stat.ATK)).toBe(-1);
|
||||
expect(enemy1.getStatStage(Stat.ATK)).toBe(-1);
|
||||
expect(enemy2.getStatStage(Stat.ATK)).toBe(-1);
|
||||
});
|
||||
|
||||
it("should not trigger on switching moves used by wild Pokemon", async () => {
|
||||
game.override.enemyMoveset(MoveId.VOLT_SWITCH).battleType(BattleType.WILD);
|
||||
await game.classicMode.startBattle([SpeciesId.MIGHTYENA]);
|
||||
|
||||
const playerPokemon = game.field.getPlayerPokemon()
|
||||
expect(playerPokemon.getStatStage(Stat.ATK)).toBe(-1);
|
||||
const player = game.field.getPlayerPokemon();
|
||||
expect(player.getStatStage(Stat.ATK)).toBe(-1);
|
||||
|
||||
game.move.select(MoveId.SPLASH);
|
||||
await game.toNextTurn();
|
||||
|
||||
// doesn't lower attack due to not actually switching out
|
||||
expect(playerPokemon.getStatStage(Stat.ATK)).toBe(-1);
|
||||
expect(player.getStatStage(Stat.ATK)).toBe(-1);
|
||||
});
|
||||
|
||||
it("should trigger on moves that switch user/target out during trainer battles", async () => {
|
||||
|
@ -9,10 +9,7 @@ import Phaser from "phaser";
|
||||
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi, type MockInstance } from "vitest";
|
||||
import { MoveUseMode } from "#enums/move-use-mode";
|
||||
|
||||
describe.each<{ name: string; move: MoveId }>([
|
||||
{ name: "Bolt Beak", move: MoveId.BOLT_BEAK },
|
||||
{ name: "Fishious Rend", move: MoveId.FISHIOUS_REND },
|
||||
])("Moves - $name", ({ move }) => {
|
||||
describe("Moves - Fishious Rend & Bolt Beak", () => {
|
||||
let phaserGame: Phaser.Game;
|
||||
let game: GameManager;
|
||||
let powerSpy: MockInstance;
|
||||
@ -30,7 +27,6 @@ describe.each<{ name: string; move: MoveId }>([
|
||||
beforeEach(() => {
|
||||
game = new GameManager(phaserGame);
|
||||
game.override
|
||||
.moveset(move)
|
||||
.ability(AbilityId.BALL_FETCH)
|
||||
.battleStyle("single")
|
||||
.battleType(BattleType.TRAINER)
|
||||
@ -40,23 +36,27 @@ describe.each<{ name: string; move: MoveId }>([
|
||||
.enemyAbility(AbilityId.BALL_FETCH)
|
||||
.enemyMoveset(MoveId.SPLASH);
|
||||
|
||||
powerSpy = vi.spyOn(allMoves[move], "calculateBattlePower");
|
||||
powerSpy = vi.spyOn(allMoves[MoveId.BOLT_BEAK], "calculateBattlePower");
|
||||
});
|
||||
|
||||
it("should double power if the user moves before the target", async () => {
|
||||
it.each<{ name: string; move: MoveId }>([
|
||||
{ name: "Bolt Beak", move: MoveId.BOLT_BEAK },
|
||||
{ name: "Fishious Rend", move: MoveId.FISHIOUS_REND },
|
||||
])("$name should double power if the user moves before the target", async ({ move }) => {
|
||||
powerSpy = vi.spyOn(allMoves[move], "calculateBattlePower");
|
||||
await game.classicMode.startBattle([SpeciesId.FEEBAS]);
|
||||
|
||||
// turn 1: enemy, then player (no boost)
|
||||
game.move.select(move);
|
||||
game.move.use(move);
|
||||
await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]);
|
||||
await game.toNextTurn();
|
||||
|
||||
expect(powerSpy).toHaveLastReturnedWith(allMoves[move].power);
|
||||
|
||||
// turn 2: player, then enemy (boost)
|
||||
game.move.select(move);
|
||||
game.move.use(move);
|
||||
await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]);
|
||||
await game.toNextTurn();
|
||||
await game.toEndOfTurn();
|
||||
|
||||
expect(powerSpy).toHaveLastReturnedWith(allMoves[move].power * 2);
|
||||
});
|
||||
@ -66,30 +66,41 @@ describe.each<{ name: string; move: MoveId }>([
|
||||
await game.classicMode.startBattle([SpeciesId.FEEBAS, SpeciesId.MILOTIC]);
|
||||
|
||||
// Use move after everyone but P1 and enemy 1 have already moved
|
||||
game.move.use(move, BattlerIndex.PLAYER, BattlerIndex.ENEMY);
|
||||
game.move.use(MoveId.BOLT_BEAK, BattlerIndex.PLAYER, BattlerIndex.ENEMY);
|
||||
game.move.use(MoveId.SPLASH, BattlerIndex.PLAYER_2);
|
||||
await game.setTurnOrder([BattlerIndex.PLAYER_2, BattlerIndex.ENEMY_2, BattlerIndex.PLAYER, BattlerIndex.ENEMY]);
|
||||
await game.toNextTurn();
|
||||
await game.toEndOfTurn();
|
||||
|
||||
expect(powerSpy).toHaveLastReturnedWith(allMoves[move].power * 2);
|
||||
expect(powerSpy).toHaveLastReturnedWith(allMoves[MoveId.BOLT_BEAK].power * 2);
|
||||
});
|
||||
|
||||
it("should double power on the turn the target switches in", async () => {
|
||||
await game.classicMode.startBattle([SpeciesId.FEEBAS]);
|
||||
|
||||
game.move.select(move);
|
||||
game.move.select(MoveId.BOLT_BEAK);
|
||||
game.forceEnemyToSwitch();
|
||||
await game.toNextTurn();
|
||||
await game.toEndOfTurn();
|
||||
|
||||
expect(powerSpy).toHaveLastReturnedWith(allMoves[move].power * 2);
|
||||
expect(powerSpy).toHaveLastReturnedWith(allMoves[MoveId.BOLT_BEAK].power * 2);
|
||||
});
|
||||
|
||||
// TODO: Verify behavior with Instruct/Dancer
|
||||
it.todo.each<{ type: string; allyMove: MoveId }>([
|
||||
it("should double power on forced switch-induced sendouts", async () => {
|
||||
await game.classicMode.startBattle([SpeciesId.FEEBAS]);
|
||||
|
||||
game.move.select(MoveId.BOLT_BEAK);
|
||||
await game.move.forceEnemyMove(MoveId.U_TURN);
|
||||
await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]);
|
||||
await game.toEndOfTurn();
|
||||
|
||||
expect(powerSpy).toHaveLastReturnedWith(allMoves[MoveId.BOLT_BEAK].power * 2);
|
||||
});
|
||||
|
||||
it.each<{ type: string; allyMove: MoveId }>([
|
||||
{ type: "a Dancer-induced", allyMove: MoveId.FIERY_DANCE },
|
||||
{ type: "an Instructed", allyMove: MoveId.INSTRUCT },
|
||||
])("should double power if $type move is used as the target's first action that turn", async ({ allyMove }) => {
|
||||
game.override.battleStyle("double").moveset([move, allyMove]).enemyAbility(AbilityId.DANCER);
|
||||
game.override.battleStyle("double").enemyAbility(AbilityId.DANCER);
|
||||
powerSpy = vi.spyOn(allMoves[MoveId.FISHIOUS_REND], "calculateBattlePower");
|
||||
await game.classicMode.startBattle([SpeciesId.DRACOVISH, SpeciesId.ARCTOZOLT]);
|
||||
|
||||
// Simulate enemy having used splash last turn to allow Instruct to copy it
|
||||
@ -101,11 +112,11 @@ describe.each<{ name: string; move: MoveId }>([
|
||||
useMode: MoveUseMode.NORMAL,
|
||||
});
|
||||
|
||||
game.move.select(move, BattlerIndex.PLAYER, BattlerIndex.ENEMY);
|
||||
game.move.select(allyMove, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY);
|
||||
game.move.use(MoveId.FISHIOUS_REND, BattlerIndex.PLAYER, BattlerIndex.ENEMY);
|
||||
game.move.use(allyMove, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY);
|
||||
await game.setTurnOrder([BattlerIndex.PLAYER_2, BattlerIndex.PLAYER, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2]);
|
||||
await game.toNextTurn();
|
||||
await game.toEndOfTurn();
|
||||
|
||||
expect(powerSpy).toHaveLastReturnedWith(allMoves[move].power);
|
||||
expect(powerSpy).toHaveLastReturnedWith(allMoves[MoveId.FISHIOUS_REND].power);
|
||||
});
|
||||
});
|
||||
|
68
test/moves/payback.test.ts
Normal file
68
test/moves/payback.test.ts
Normal file
@ -0,0 +1,68 @@
|
||||
import { allMoves, allSpecies } from "#app/data/data-lists";
|
||||
import { AbilityId } from "#enums/ability-id";
|
||||
import { BattlerIndex } from "#enums/battler-index";
|
||||
import { MoveId } from "#enums/move-id";
|
||||
import { SpeciesId } from "#enums/species-id";
|
||||
import GameManager from "#test/testUtils/gameManager";
|
||||
import Phaser from "phaser";
|
||||
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi, type MockInstance } from "vitest";
|
||||
|
||||
describe("Move - Payback", () => {
|
||||
let phaserGame: Phaser.Game;
|
||||
let game: GameManager;
|
||||
let powerSpy: MockInstance;
|
||||
|
||||
beforeAll(() => {
|
||||
phaserGame = new Phaser.Game({
|
||||
type: Phaser.HEADLESS,
|
||||
});
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
game.phaseInterceptor.restoreOg();
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
game = new GameManager(phaserGame);
|
||||
game.override
|
||||
.ability(AbilityId.BALL_FETCH)
|
||||
.battleStyle("single")
|
||||
.criticalHits(false)
|
||||
.enemyLevel(100)
|
||||
.enemySpecies(SpeciesId.DRACOVISH)
|
||||
.enemyAbility(AbilityId.BALL_FETCH)
|
||||
.enemyMoveset(MoveId.SPLASH);
|
||||
|
||||
powerSpy = vi.spyOn(allMoves[MoveId.PAYBACK], "calculateBattlePower");
|
||||
});
|
||||
|
||||
it("should double power if the user moves after the target", async () => {
|
||||
await game.classicMode.startBattle([SpeciesId.FEEBAS]);
|
||||
|
||||
// turn 1: enemy, then player (boost)
|
||||
game.move.use(MoveId.PAYBACK);
|
||||
await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]);
|
||||
await game.toNextTurn();
|
||||
|
||||
expect(powerSpy).toHaveLastReturnedWith(allMoves[MoveId.PAYBACK].power * 2);
|
||||
|
||||
// turn 2: player, then enemy (no boost)
|
||||
game.move.use(MoveId.PAYBACK);
|
||||
await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]);
|
||||
await game.toEndOfTurn();
|
||||
|
||||
expect(powerSpy).toHaveLastReturnedWith(allMoves[MoveId.PAYBACK].power);
|
||||
});
|
||||
|
||||
it("should trigger for enemies on player failed ball catch", async () => {
|
||||
// Make dracovish uncatchable so we don't flake out
|
||||
vi.spyOn(allSpecies[SpeciesId.DRACOVISH], "catchRate", "get").mockReturnValue(0);
|
||||
await game.classicMode.startBattle([SpeciesId.FEEBAS]);
|
||||
|
||||
game.doThrowPokeball(0);
|
||||
await game.move.forceEnemyMove(MoveId.PAYBACK);
|
||||
await game.toEndOfTurn();
|
||||
|
||||
expect(powerSpy).toHaveLastReturnedWith(allMoves[MoveId.PAYBACK].power * 2);
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue
Block a user