mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-20 07:12:32 +02:00
[BUG] fixes #5472 - transform on reload
This commit is contained in:
parent
4b8f1df8cd
commit
102c0ffc37
@ -5575,7 +5575,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
|||||||
}
|
}
|
||||||
this.resetBattleSummonData();
|
this.resetBattleSummonData();
|
||||||
if (this.summonDataPrimer) {
|
if (this.summonDataPrimer) {
|
||||||
for (const k of Object.keys(this.summonData)) {
|
for (const k of Object.keys(this.summonDataPrimer)) {
|
||||||
if (this.summonDataPrimer[k]) {
|
if (this.summonDataPrimer[k]) {
|
||||||
this.summonData[k] = this.summonDataPrimer[k];
|
this.summonData[k] = this.summonDataPrimer[k];
|
||||||
}
|
}
|
||||||
|
@ -195,6 +195,10 @@ export class SummonPhase extends PartyMemberPokemonPhase {
|
|||||||
pokemon.cry(pokemon.getHpRatio() > 0.25 ? undefined : { rate: 0.85 });
|
pokemon.cry(pokemon.getHpRatio() > 0.25 ? undefined : { rate: 0.85 });
|
||||||
pokemon.getSprite().clearTint();
|
pokemon.getSprite().clearTint();
|
||||||
pokemon.resetSummonData();
|
pokemon.resetSummonData();
|
||||||
|
// necessary to stay transformed during wild waves
|
||||||
|
if (pokemon.summonData?.speciesForm) {
|
||||||
|
pokemon.loadAssets();
|
||||||
|
}
|
||||||
globalScene.time.delayedCall(1000, () => this.end());
|
globalScene.time.delayedCall(1000, () => this.end());
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
@ -170,6 +170,7 @@ export default class PokemonData {
|
|||||||
this.summonData.ability = source.summonData.ability;
|
this.summonData.ability = source.summonData.ability;
|
||||||
this.summonData.moveset = source.summonData.moveset?.map(m => PokemonMove.loadMove(m));
|
this.summonData.moveset = source.summonData.moveset?.map(m => PokemonMove.loadMove(m));
|
||||||
this.summonData.types = source.summonData.types;
|
this.summonData.types = source.summonData.types;
|
||||||
|
this.summonData.speciesForm = source.summonData.speciesForm;
|
||||||
|
|
||||||
if (source.summonData.tags) {
|
if (source.summonData.tags) {
|
||||||
this.summonData.tags = source.summonData.tags?.map(t => loadBattlerTag(t));
|
this.summonData.tags = source.summonData.tags?.map(t => loadBattlerTag(t));
|
||||||
@ -213,6 +214,11 @@ export default class PokemonData {
|
|||||||
this,
|
this,
|
||||||
);
|
);
|
||||||
if (this.summonData) {
|
if (this.summonData) {
|
||||||
|
// when loading from saved session, recover summonData.speciesFrom species object
|
||||||
|
// used to stay transformed on reload session
|
||||||
|
if (this.summonData.speciesForm) {
|
||||||
|
this.summonData.speciesForm = getPokemonSpecies(this.summonData.speciesForm.speciesId);
|
||||||
|
}
|
||||||
ret.primeSummonData(this.summonData);
|
ret.primeSummonData(this.summonData);
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -127,4 +127,37 @@ describe("Abilities - Imposter", () => {
|
|||||||
|
|
||||||
expect(game.scene.getEnemyPokemon()?.getStatStage(Stat.ATK)).toBe(-1);
|
expect(game.scene.getEnemyPokemon()?.getStatStage(Stat.ATK)).toBe(-1);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("should persist transformed attributes across reloads", async () => {
|
||||||
|
game.override.moveset([Moves.ABSORB]);
|
||||||
|
|
||||||
|
await game.classicMode.startBattle([Species.DITTO]);
|
||||||
|
|
||||||
|
const player = game.scene.getPlayerPokemon()!;
|
||||||
|
const enemy = game.scene.getEnemyPokemon()!;
|
||||||
|
|
||||||
|
game.move.select(Moves.SPLASH);
|
||||||
|
await game.doKillOpponents();
|
||||||
|
await game.toNextWave();
|
||||||
|
|
||||||
|
expect(game.scene.getCurrentPhase()?.constructor.name).toBe("CommandPhase");
|
||||||
|
expect(game.scene.currentBattle.waveIndex).toBe(2);
|
||||||
|
|
||||||
|
await game.reload.reloadSession();
|
||||||
|
|
||||||
|
const playerReloaded = game.scene.getPlayerPokemon()!;
|
||||||
|
const playerMoveset = player.getMoveset();
|
||||||
|
|
||||||
|
expect(playerReloaded.getSpeciesForm().speciesId).toBe(enemy.getSpeciesForm().speciesId);
|
||||||
|
expect(playerReloaded.getAbility()).toBe(enemy.getAbility());
|
||||||
|
expect(playerReloaded.getGender()).toBe(enemy.getGender());
|
||||||
|
|
||||||
|
expect(playerReloaded.getStat(Stat.HP, false)).not.toBe(enemy.getStat(Stat.HP));
|
||||||
|
for (const s of EFFECTIVE_STATS) {
|
||||||
|
expect(playerReloaded.getStat(s, false)).toBe(enemy.getStat(s, false));
|
||||||
|
}
|
||||||
|
|
||||||
|
expect(playerMoveset.length).toEqual(1);
|
||||||
|
expect(playerMoveset[0]?.moveId).toEqual(Moves.SPLASH);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@ -6,6 +6,7 @@ import { TurnEndPhase } from "#app/phases/turn-end-phase";
|
|||||||
import { Moves } from "#enums/moves";
|
import { Moves } from "#enums/moves";
|
||||||
import { Stat, BATTLE_STATS, EFFECTIVE_STATS } from "#enums/stat";
|
import { Stat, BATTLE_STATS, EFFECTIVE_STATS } from "#enums/stat";
|
||||||
import { Abilities } from "#enums/abilities";
|
import { Abilities } from "#enums/abilities";
|
||||||
|
import { BattlerIndex } from "#app/battle";
|
||||||
|
|
||||||
// TODO: Add more tests once Transform is fully implemented
|
// TODO: Add more tests once Transform is fully implemented
|
||||||
describe("Moves - Transform", () => {
|
describe("Moves - Transform", () => {
|
||||||
@ -58,7 +59,7 @@ describe("Moves - Transform", () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const playerMoveset = player.getMoveset();
|
const playerMoveset = player.getMoveset();
|
||||||
const enemyMoveset = player.getMoveset();
|
const enemyMoveset = enemy.getMoveset();
|
||||||
|
|
||||||
expect(playerMoveset.length).toBe(enemyMoveset.length);
|
expect(playerMoveset.length).toBe(enemyMoveset.length);
|
||||||
for (let i = 0; i < playerMoveset.length && i < enemyMoveset.length; i++) {
|
for (let i = 0; i < playerMoveset.length && i < enemyMoveset.length; i++) {
|
||||||
@ -127,4 +128,40 @@ describe("Moves - Transform", () => {
|
|||||||
|
|
||||||
expect(game.scene.getEnemyPokemon()?.getStatStage(Stat.ATK)).toBe(-1);
|
expect(game.scene.getEnemyPokemon()?.getStatStage(Stat.ATK)).toBe(-1);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("should persist transformed attributes across reloads", async () => {
|
||||||
|
game.override.enemyMoveset([]).moveset([]);
|
||||||
|
|
||||||
|
await game.classicMode.startBattle([Species.DITTO]);
|
||||||
|
|
||||||
|
const player = game.scene.getPlayerPokemon()!;
|
||||||
|
const enemy = game.scene.getEnemyPokemon()!;
|
||||||
|
|
||||||
|
game.move.changeMoveset(player, Moves.TRANSFORM);
|
||||||
|
game.move.changeMoveset(enemy, Moves.MEMENTO);
|
||||||
|
|
||||||
|
game.move.select(Moves.TRANSFORM);
|
||||||
|
await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]);
|
||||||
|
await game.toNextWave();
|
||||||
|
|
||||||
|
expect(game.scene.getCurrentPhase()?.constructor.name).toBe("CommandPhase");
|
||||||
|
expect(game.scene.currentBattle.waveIndex).toBe(2);
|
||||||
|
|
||||||
|
await game.reload.reloadSession();
|
||||||
|
|
||||||
|
const playerReloaded = game.scene.getPlayerPokemon()!;
|
||||||
|
const playerMoveset = player.getMoveset();
|
||||||
|
|
||||||
|
expect(playerReloaded.getSpeciesForm().speciesId).toBe(enemy.getSpeciesForm().speciesId);
|
||||||
|
expect(playerReloaded.getAbility()).toBe(enemy.getAbility());
|
||||||
|
expect(playerReloaded.getGender()).toBe(enemy.getGender());
|
||||||
|
|
||||||
|
expect(playerReloaded.getStat(Stat.HP, false)).not.toBe(enemy.getStat(Stat.HP));
|
||||||
|
for (const s of EFFECTIVE_STATS) {
|
||||||
|
expect(playerReloaded.getStat(s, false)).toBe(enemy.getStat(s, false));
|
||||||
|
}
|
||||||
|
|
||||||
|
expect(playerMoveset.length).toEqual(1);
|
||||||
|
expect(playerMoveset[0]?.moveId).toEqual(Moves.MEMENTO);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user