[Ability][Move] Last Respects Refactor and Full Implementation (#5200)

* full implementation of supreme overlord + test

* removed unused import

* changed documentation since Battle.playerFaints is not used in supreme overlord

* Update faint-phase.ts

* changed supreme overlords power calculation function and adjusted tests

* added changes to Last Respects too

* added playerFaints to SessionSaveData to make the counter saveable

* Apply Kev's suggestions

Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>

* Reset enemy faint counter per battle

* Re-mark supreme overlord as partial

* added automated test case

* moved playerFaints reset to resetArenaEffects

* removed resetEnemyFaintCount() function since it is unused

---------

Co-authored-by: Sirz Benjie <142067137+SirzBenjie@users.noreply.github.com>
Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
This commit is contained in:
geeilhan 2025-02-11 07:53:37 +01:00 committed by GitHub
parent abf9c83607
commit 42c4ca27e6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 432 additions and 18 deletions

View File

@ -1401,8 +1401,8 @@ export default class BattleScene extends SceneBase {
return this.currentBattle;
}
newArena(biome: Biome): Arena {
this.arena = new Arena(biome, Biome[biome].toLowerCase());
newArena(biome: Biome, playerFaints?: number): Arena {
this.arena = new Arena(biome, Biome[biome].toLowerCase(), playerFaints);
this.eventTarget.dispatchEvent(new NewArenaEvent());
this.arenaBg.pipelineData = { terrainColorRatio: this.arena.getBgTerrainColorRatioForBiome() };

View File

@ -105,9 +105,11 @@ export default class Battle {
public lastEnemyInvolved: number;
public lastPlayerInvolved: number;
public lastUsedPokeball: PokeballType | null = null;
/** The number of times a Pokemon on the player's side has fainted this battle */
public playerFaints: number = 0;
/** The number of times a Pokemon on the enemy's side has fainted this battle */
/**
* Saves the number of times a Pokemon on the enemy's side has fainted during this battle.
* This is saved here since we encounter a new enemy every wave.
* {@linkcode globalScene.arena.playerFaints} is the corresponding faint counter for the player and needs to be save across waves (reset every arena encounter).
*/
public enemyFaints: number = 0;
public playerFaintsHistory: FaintLogEntry[] = [];
public enemyFaintsHistory: FaintLogEntry[] = [];
@ -118,7 +120,7 @@ export default class Battle {
private rngCounter: number = 0;
constructor(gameMode: GameMode, waveIndex: number, battleType: BattleType, trainer?: Trainer, double?: boolean) {
constructor(gameMode: GameMode, waveIndex: number, battleType: BattleType, trainer?: Trainer, double: boolean = false) {
this.gameMode = gameMode;
this.waveIndex = waveIndex;
this.battleType = battleType;
@ -127,7 +129,7 @@ export default class Battle {
this.enemyLevels = battleType !== BattleType.TRAINER
? new Array(double ? 2 : 1).fill(null).map(() => this.getLevelForWave())
: trainer?.getPartyLevels(this.waveIndex);
this.double = double ?? false;
this.double = double;
}
private initBattleSpec(): void {

View File

@ -6313,8 +6313,8 @@ export function initAbilities() {
new Ability(Abilities.SHARPNESS, 9)
.attr(MovePowerBoostAbAttr, (user, target, move) => move.hasFlag(MoveFlags.SLICING_MOVE), 1.5),
new Ability(Abilities.SUPREME_OVERLORD, 9)
.attr(VariableMovePowerBoostAbAttr, (user, target, move) => 1 + 0.1 * Math.min(user.isPlayer() ? globalScene.currentBattle.playerFaints : globalScene.currentBattle.enemyFaints, 5))
.partial(), // Counter resets every wave instead of on arena reset
.attr(VariableMovePowerBoostAbAttr, (user, target, move) => 1 + 0.1 * Math.min(user.isPlayer() ? globalScene.arena.playerFaints : globalScene.currentBattle.enemyFaints, 5))
.partial(), // Should only boost once, on summon
new Ability(Abilities.COSTAR, 9)
.attr(PostSummonCopyAllyStatsAbAttr),
new Ability(Abilities.TOXIC_DEBRIS, 9)

View File

@ -10916,8 +10916,7 @@ export function initMoves() {
.attr(ConfuseAttr)
.recklessMove(),
new AttackMove(Moves.LAST_RESPECTS, Type.GHOST, MoveCategory.PHYSICAL, 50, 100, 10, -1, 0, 9)
.partial() // Counter resets every wave instead of on arena reset
.attr(MovePowerMultiplierAttr, (user, target, move) => 1 + Math.min(user.isPlayer() ? globalScene.currentBattle.playerFaints : globalScene.currentBattle.enemyFaints, 100))
.attr(MovePowerMultiplierAttr, (user, target, move) => 1 + Math.min(user.isPlayer() ? globalScene.arena.playerFaints : globalScene.currentBattle.enemyFaints, 100))
.makesContact(false),
new AttackMove(Moves.LUMINA_CRASH, Type.PSYCHIC, MoveCategory.SPECIAL, 80, 100, 10, 100, 0, 9)
.attr(StatStageChangeAttr, [ Stat.SPDEF ], -2),

View File

@ -44,6 +44,11 @@ export class Arena {
public bgm: string;
public ignoreAbilities: boolean;
public ignoringEffectSource: BattlerIndex | null;
/**
* Saves the number of times a party pokemon faints during a arena encounter.
* {@linkcode globalScene.currentBattle.enemyFaints} is the corresponding faint counter for the enemy (this resets every wave).
*/
public playerFaints: number;
private lastTimeOfDay: TimeOfDay;
@ -52,12 +57,13 @@ export class Arena {
public readonly eventTarget: EventTarget = new EventTarget();
constructor(biome: Biome, bgm: string) {
constructor(biome: Biome, bgm: string, playerFaints: number = 0) {
this.biomeType = biome;
this.tags = [];
this.bgm = bgm;
this.trainerPool = biomeTrainerPools[biome];
this.updatePoolsForTimeOfDay();
this.playerFaints = playerFaints;
}
init() {
@ -688,6 +694,7 @@ export class Arena {
this.trySetWeather(WeatherType.NONE, false);
}
this.trySetTerrain(TerrainType.NONE, false, true);
this.resetPlayerFaintCount();
this.removeAllTags();
}
@ -773,6 +780,10 @@ export class Arena {
return 0;
}
}
resetPlayerFaintCount(): void {
this.playerFaints = 0;
}
}
export function getBiomeKey(biome: Biome): string {

View File

@ -96,10 +96,9 @@ export class FaintPhase extends PokemonPhase {
doFaint(): void {
const pokemon = this.getPokemon();
// Track total times pokemon have been KO'd for supreme overlord/last respects
// Track total times pokemon have been KO'd for Last Respects/Supreme Overlord
if (pokemon.isPlayer()) {
globalScene.currentBattle.playerFaints += 1;
globalScene.arena.playerFaints += 1;
globalScene.currentBattle.playerFaintsHistory.push({ pokemon: pokemon, turn: globalScene.currentBattle.turn });
} else {
globalScene.currentBattle.enemyFaints += 1;

View File

@ -249,7 +249,8 @@ export class GameOverPhase extends BattlePhase {
timestamp: new Date().getTime(),
challenges: globalScene.gameMode.challenges.map(c => new ChallengeData(c)),
mysteryEncounterType: globalScene.currentBattle.mysteryEncounter?.encounterType ?? -1,
mysteryEncounterSaveData: globalScene.mysteryEncounterSaveData
mysteryEncounterSaveData: globalScene.mysteryEncounterSaveData,
playerFaints: globalScene.arena.playerFaints
} as SessionSaveData;
}
}

View File

@ -141,6 +141,10 @@ export interface SessionSaveData {
challenges: ChallengeData[];
mysteryEncounterType: MysteryEncounterType | -1; // Only defined when current wave is ME,
mysteryEncounterSaveData: MysteryEncounterSaveData;
/**
* Counts the amount of pokemon fainted in your party during the current arena encounter.
*/
playerFaints: number;
}
interface Unlocks {
@ -964,7 +968,8 @@ export class GameData {
timestamp: new Date().getTime(),
challenges: globalScene.gameMode.challenges.map(c => new ChallengeData(c)),
mysteryEncounterType: globalScene.currentBattle.mysteryEncounter?.encounterType ?? -1,
mysteryEncounterSaveData: globalScene.mysteryEncounterSaveData
mysteryEncounterSaveData: globalScene.mysteryEncounterSaveData,
playerFaints: globalScene.arena.playerFaints
} as SessionSaveData;
}
@ -1056,7 +1061,7 @@ export class GameData {
globalScene.mysteryEncounterSaveData = new MysteryEncounterSaveData(sessionData.mysteryEncounterSaveData);
globalScene.newArena(sessionData.arena.biome);
globalScene.newArena(sessionData.arena.biome, sessionData.playerFaints);
const battleType = sessionData.battleType || 0;
const trainerConfig = sessionData.trainer ? trainerConfigs[sessionData.trainer.trainerType] : null;

View File

@ -0,0 +1,178 @@
import { Moves } from "#app/enums/moves";
import { Abilities } from "#enums/abilities";
import { Species } from "#enums/species";
import { BattlerIndex } from "#app/battle";
import { MoveEffectPhase } from "#app/phases/move-effect-phase";
import GameManager from "#test/utils/gameManager";
import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
import { allMoves } from "#app/data/move";
describe("Abilities - Supreme Overlord", () => {
let phaserGame: Phaser.Game;
let game: GameManager;
const move = allMoves[Moves.TACKLE];
const basePower = move.power;
beforeAll(() => {
phaserGame = new Phaser.Game({
type: Phaser.HEADLESS,
});
});
afterEach(() => {
game.phaseInterceptor.restoreOg();
});
beforeEach(() => {
game = new GameManager(phaserGame);
game.override
.battleType("single")
.enemySpecies(Species.MAGIKARP)
.enemyLevel(100)
.startingLevel(1)
.enemyAbility(Abilities.BALL_FETCH)
.ability(Abilities.SUPREME_OVERLORD)
.enemyMoveset([ Moves.SPLASH ])
.moveset([ Moves.TACKLE, Moves.EXPLOSION, Moves.LUNAR_DANCE ]);
vi.spyOn(move, "calculateBattlePower");
});
it("should increase Power by 20% if 2 Pokemon are fainted in the party", async() => {
await game.startBattle([ Species.BULBASAUR, Species.CHARMANDER, Species.SQUIRTLE ]);
game.move.select(Moves.EXPLOSION);
await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]);
game.doSelectPartyPokemon(1);
await game.toNextTurn();
game.move.select(Moves.EXPLOSION);
await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]);
game.doSelectPartyPokemon(2);
await game.toNextTurn();
game.move.select(Moves.TACKLE);
await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]);
await game.phaseInterceptor.to(MoveEffectPhase);
expect(move.calculateBattlePower).toHaveReturnedWith(basePower * 1.2);
});
it("should increase Power by 30% if an ally fainted twice and another one once", async () => {
await game.classicMode.startBattle([ Species.BULBASAUR, Species.CHARMANDER, Species.SQUIRTLE ]);
/**
* Bulbasur faints once
*/
game.move.select(Moves.EXPLOSION);
await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]);
game.doSelectPartyPokemon(1);
await game.toNextTurn();
/**
* Charmander faints once
*/
game.doRevivePokemon(1);
game.move.select(Moves.EXPLOSION);
await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]);
game.doSelectPartyPokemon(1);
await game.toNextTurn();
/**
* Bulbasur faints twice
*/
game.move.select(Moves.EXPLOSION);
await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]);
game.doSelectPartyPokemon(2);
await game.toNextTurn();
game.move.select(Moves.TACKLE);
await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]);
await game.phaseInterceptor.to(MoveEffectPhase);
expect(move.calculateBattlePower).toHaveReturnedWith(basePower * 1.3);
});
it("should maintain its power during next battle if it is within the same arena encounter", async () => {
game.override
.enemySpecies(Species.MAGIKARP)
.startingWave(1)
.enemyLevel(1)
.startingLevel(100);
await game.classicMode.startBattle([ Species.BULBASAUR, Species.CHARMANDER, Species.SQUIRTLE ]);
/**
* The first Pokemon faints and another Pokemon in the party is selected.
*/
game.move.select(Moves.LUNAR_DANCE);
await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]);
game.doSelectPartyPokemon(1);
await game.toNextTurn();
/**
* Enemy Pokemon faints and new wave is entered.
*/
game.move.select(Moves.TACKLE);
await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]);
await game.toNextWave();
game.move.select(Moves.TACKLE);
await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]);
await game.phaseInterceptor.to("TurnEndPhase");
expect(move.calculateBattlePower).toHaveLastReturnedWith(basePower * 1.1);
});
it("should reset playerFaints count if we enter new trainer battle", async () => {
game.override
.enemySpecies(Species.MAGIKARP)
.startingWave(4)
.enemyLevel(1)
.startingLevel(100);
await game.classicMode.startBattle([ Species.BULBASAUR, Species.CHARMANDER, Species.SQUIRTLE ]);
game.move.select(Moves.LUNAR_DANCE);
await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]);
game.doSelectPartyPokemon(1);
await game.toNextTurn();
game.move.select(Moves.TACKLE);
await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]);
await game.toNextWave();
game.move.select(Moves.TACKLE);
await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]);
await game.phaseInterceptor.to("BerryPhase", false);
expect(move.calculateBattlePower).toHaveLastReturnedWith(basePower);
});
it("should reset playerFaints count if we enter new biome", async () => {
game.override
.enemySpecies(Species.MAGIKARP)
.startingWave(10)
.enemyLevel(1)
.startingLevel(100);
await game.classicMode.startBattle([ Species.BULBASAUR, Species.CHARMANDER, Species.SQUIRTLE ]);
game.move.select(Moves.LUNAR_DANCE);
await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]);
game.doSelectPartyPokemon(1);
await game.toNextTurn();
game.move.select(Moves.TACKLE);
await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]);
await game.toNextWave();
game.move.select(Moves.TACKLE);
await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]);
await game.phaseInterceptor.to("BerryPhase", false);
expect(move.calculateBattlePower).toHaveLastReturnedWith(basePower);
});
});

View File

@ -0,0 +1,219 @@
import { Moves } from "#enums/moves";
import { BattlerIndex } from "#app/battle";
import { Species } from "#enums/species";
import { Abilities } from "#enums/abilities";
import GameManager from "#test/utils/gameManager";
import { allMoves } from "#app/data/move";
import { MoveEffectPhase } from "#app/phases/move-effect-phase";
import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
describe("Moves - Last Respects", () => {
let phaserGame: Phaser.Game;
let game: GameManager;
const move = allMoves[Moves.LAST_RESPECTS];
const basePower = move.power;
beforeAll(() => {
phaserGame = new Phaser.Game({
type: Phaser.HEADLESS,
});
});
afterEach(() => {
game.phaseInterceptor.restoreOg();
});
beforeEach(() => {
game = new GameManager(phaserGame);
game.override
.battleType("single")
.disableCrits()
.moveset([ Moves.LAST_RESPECTS, Moves.EXPLOSION, Moves.LUNAR_DANCE ])
.ability(Abilities.BALL_FETCH)
.enemyAbility(Abilities.BALL_FETCH)
.enemySpecies(Species.MAGIKARP)
.enemyMoveset(Moves.SPLASH)
.startingLevel(1)
.enemyLevel(100);
vi.spyOn(move, "calculateBattlePower");
});
it("should have 150 power if 2 allies faint before using move", async () => {
await game.classicMode.startBattle([ Species.BULBASAUR, Species.CHARMANDER, Species.SQUIRTLE ]);
/**
* Bulbasur faints once
*/
game.move.select(Moves.EXPLOSION);
await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]);
game.doSelectPartyPokemon(1);
await game.toNextTurn();
/**
* Charmander faints once
*/
game.move.select(Moves.EXPLOSION);
await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]);
game.doSelectPartyPokemon(2);
await game.toNextTurn();
game.move.select(Moves.LAST_RESPECTS);
await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]);
await game.phaseInterceptor.to(MoveEffectPhase);
expect(move.calculateBattlePower).toHaveReturnedWith(basePower + (2 * 50));
});
it("should have 200 power if an ally fainted twice and another one once", async () => {
await game.classicMode.startBattle([ Species.BULBASAUR, Species.CHARMANDER, Species.SQUIRTLE ]);
/**
* Bulbasur faints once
*/
game.move.select(Moves.EXPLOSION);
await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]);
game.doSelectPartyPokemon(1);
await game.toNextTurn();
/**
* Charmander faints once
*/
game.doRevivePokemon(1);
game.move.select(Moves.EXPLOSION);
await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]);
game.doSelectPartyPokemon(1);
await game.toNextTurn();
/**
* Bulbasur faints twice
*/
game.move.select(Moves.EXPLOSION);
await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]);
game.doSelectPartyPokemon(2);
await game.toNextTurn();
game.move.select(Moves.LAST_RESPECTS);
await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]);
await game.phaseInterceptor.to(MoveEffectPhase);
expect(move.calculateBattlePower).toHaveReturnedWith(basePower + (3 * 50));
});
it("should maintain its power for the player during the next battle if it is within the same arena encounter", async () => {
game.override
.enemySpecies(Species.MAGIKARP)
.startingWave(1)
.enemyLevel(1)
.startingLevel(100)
.enemyMoveset(Moves.SPLASH);
await game.classicMode.startBattle([ Species.BULBASAUR, Species.CHARMANDER, Species.SQUIRTLE ]);
/**
* The first Pokemon faints and another Pokemon in the party is selected.
*/
game.move.select(Moves.LUNAR_DANCE);
await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]);
game.doSelectPartyPokemon(1);
await game.toNextTurn();
/**
* Enemy Pokemon faints and new wave is entered.
*/
game.move.select(Moves.LAST_RESPECTS);
await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]);
await game.toNextWave();
expect(game.scene.arena.playerFaints).toBe(1);
game.move.select(Moves.LAST_RESPECTS);
await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]);
await game.phaseInterceptor.to("MoveEndPhase");
expect(move.calculateBattlePower).toHaveLastReturnedWith(basePower + (1 * 50));
});
it("should reset enemyFaints count on progressing to the next wave.", async () => {
game.override
.enemySpecies(Species.MAGIKARP)
.startingWave(1)
.enemyLevel(1)
.startingLevel(100)
.enemyMoveset(Moves.LAST_RESPECTS)
.moveset([ Moves.LUNAR_DANCE, Moves.LAST_RESPECTS, Moves.SPLASH ]);
await game.classicMode.startBattle([ Species.BULBASAUR, Species.CHARMANDER, Species.SQUIRTLE ]);
/**
* The first Pokemon faints and another Pokemon in the party is selected.
*/
game.move.select(Moves.LUNAR_DANCE);
await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]);
game.doSelectPartyPokemon(1);
await game.toNextTurn();
/**
* Enemy Pokemon faints and new wave is entered.
*/
game.move.select(Moves.LAST_RESPECTS);
await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]);
await game.toNextWave();
expect(game.scene.currentBattle.enemyFaints).toBe(0);
game.move.select(Moves.LAST_RESPECTS);
await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]);
await game.phaseInterceptor.to("MoveEndPhase");
expect(move.calculateBattlePower).toHaveLastReturnedWith(basePower);
});
it("should reset playerFaints count if we enter new trainer battle", async () => {
game.override
.enemySpecies(Species.MAGIKARP)
.startingWave(4)
.enemyLevel(1)
.startingLevel(100);
await game.classicMode.startBattle([ Species.BULBASAUR, Species.CHARMANDER, Species.SQUIRTLE ]);
game.move.select(Moves.LUNAR_DANCE);
await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]);
game.doSelectPartyPokemon(1);
await game.toNextTurn();
game.move.select(Moves.LAST_RESPECTS);
await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]);
await game.toNextWave();
game.move.select(Moves.LAST_RESPECTS);
await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]);
await game.phaseInterceptor.to("BerryPhase", false);
expect(move.calculateBattlePower).toHaveLastReturnedWith(basePower);
});
it("should reset playerFaints count if we enter new biome", async () => {
game.override
.enemySpecies(Species.MAGIKARP)
.startingWave(10)
.enemyLevel(1)
.startingLevel(100);
await game.classicMode.startBattle([ Species.BULBASAUR, Species.CHARMANDER, Species.SQUIRTLE ]);
game.move.select(Moves.LUNAR_DANCE);
await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]);
game.doSelectPartyPokemon(1);
await game.toNextTurn();
game.move.select(Moves.LAST_RESPECTS);
await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]);
await game.toNextWave();
game.move.select(Moves.LAST_RESPECTS);
await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]);
await game.phaseInterceptor.to("BerryPhase", false);
expect(move.calculateBattlePower).toHaveLastReturnedWith(basePower);
});
});