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 fusionGender: Gender;
private summonDataPrimer: PokemonSummonData;
public summonData: PokemonSummonData;
public battleData: PokemonBattleData;
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 {
if (this.summonData?.speciesForm) {
this.summonData.speciesForm = null;
@ -1668,6 +1674,13 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
if (!this.battleData)
this.resetBattleData();
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 {

View File

@ -107,8 +107,11 @@ export default class PokemonData {
toPokemon(scene: BattleScene, battleType?: BattleType, partyMemberIndex: integer = 0, double: boolean = false): Pokemon {
const species = getPokemonSpecies(this.species);
if (this.player)
return 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);
const ret: Pokemon = this.player
? scene.addPlayerPokemon(species, this.level, this.abilityIndex, this.formIndex, this.gender, this.shiny, this.ivs, this.nature, 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;
}
}