Fix summon data not being loaded in on session load

pull/16/head
Flashfyre 2024-03-25 10:16:29 -04:00
parent 93a7af853b
commit efa8d4f3fc
2 changed files with 19 additions and 3 deletions

View File

@ -84,6 +84,8 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
public fusionShiny: boolean; public fusionShiny: boolean;
public fusionGender: Gender; public fusionGender: Gender;
private summonDataPrimer: PokemonSummonData;
public summonData: PokemonSummonData; public summonData: PokemonSummonData;
public battleData: PokemonBattleData; public battleData: PokemonBattleData;
public battleSummonData: PokemonBattleSummonData; public battleSummonData: PokemonBattleSummonData;
@ -1659,6 +1661,10 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
} }
} }
primeSummonData(summonDataPrimer: PokemonSummonData): void {
this.summonDataPrimer = summonDataPrimer;
}
resetSummonData(): void { resetSummonData(): void {
if (this.summonData?.speciesForm) { if (this.summonData?.speciesForm) {
this.summonData.speciesForm = null; this.summonData.speciesForm = null;
@ -1668,6 +1674,13 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
if (!this.battleData) if (!this.battleData)
this.resetBattleData(); this.resetBattleData();
this.resetBattleSummonData(); this.resetBattleSummonData();
if (this.summonDataPrimer) {
for (let k of Object.keys(this.summonData)) {
if (this.summonDataPrimer[k])
this.summonData[k] = this.summonDataPrimer[k];
}
this.summonDataPrimer = null;
}
} }
resetBattleData(): void { resetBattleData(): void {

View File

@ -107,8 +107,11 @@ export default class PokemonData {
toPokemon(scene: BattleScene, battleType?: BattleType, partyMemberIndex: integer = 0, double: boolean = false): Pokemon { toPokemon(scene: BattleScene, battleType?: BattleType, partyMemberIndex: integer = 0, double: boolean = false): Pokemon {
const species = getPokemonSpecies(this.species); const species = getPokemonSpecies(this.species);
if (this.player) const ret: Pokemon = this.player
return scene.addPlayerPokemon(species, this.level, this.abilityIndex, this.formIndex, this.gender, this.shiny, this.ivs, this.nature, this); ? scene.addPlayerPokemon(species, this.level, this.abilityIndex, this.formIndex, this.gender, this.shiny, this.ivs, this.nature, this)
return scene.addEnemyPokemon(species, this.level, battleType === BattleType.TRAINER ? !double || !(partyMemberIndex % 2) ? TrainerSlot.TRAINER : TrainerSlot.TRAINER_PARTNER : TrainerSlot.NONE, this.boss, this); : scene.addEnemyPokemon(species, this.level, battleType === BattleType.TRAINER ? !double || !(partyMemberIndex % 2) ? TrainerSlot.TRAINER : TrainerSlot.TRAINER_PARTNER : TrainerSlot.NONE, this.boss, this);
if (this.summonData)
ret.primeSummonData(this.summonData);
return ret;
} }
} }