Fix animation not resuming after faint

pull/1/head
Flashfyre 2023-04-04 21:10:11 -04:00
parent a1b857fbc6
commit 2a22b31129
3 changed files with 53 additions and 10 deletions

View File

@ -235,6 +235,7 @@ export class SummonPhase extends BattlePhase {
this.scene.add.existing(playerPokemon);
this.scene.field.add(playerPokemon);
playerPokemon.showInfo();
playerPokemon.playAnim();
playerPokemon.setVisible(true);
playerPokemon.setScale(0.5);
playerPokemon.tint(getPokeballTintColor(playerPokemon.pokeball));
@ -968,12 +969,14 @@ export class SelectModifierPhase extends BattlePhase {
if (slotIndex < 6) {
this.scene.ui.setMode(Mode.MODIFIER_SELECT);
this.scene.addModifier(types[cursor].newModifier(this.scene.getParty()[slotIndex])).then(() => super.end());
this.scene.ui.clearText();
this.scene.ui.setMode(Mode.MESSAGE);
} else
this.scene.ui.setMode(Mode.MODIFIER_SELECT);
}, pokemonModifierType.selectFilter);
} else {
this.scene.addModifier(types[cursor].newModifier()).then(() => super.end());
this.scene.ui.clearText();
this.scene.ui.setMode(Mode.MESSAGE);
}
});

View File

@ -242,6 +242,29 @@ export class PokemonHpRestoreModifier extends ConsumablePokemonModifier {
}
}
export class PokemonPpRestoreModifier extends ConsumablePokemonModifier {
private restorePoints: integer;
constructor(type: ModifierType, pokemonId: integer, restorePoints: integer) {
super(type, pokemonId);
this.restorePoints = restorePoints;
}
shouldApply(args: any[]): boolean {
return super.shouldApply(args) && args.length > 1 && typeof(args[1]) === 'number';
}
apply(args: any[]): boolean {
const pokemon = args[0] as Pokemon;
const moveIndex = args[1] as integer;
const move = pokemon.moveset[moveIndex];
move.ppUsed = this.restorePoints >= 0 ? Math.max(move.ppUsed - this.restorePoints, 0) : 0;
return true;
}
}
export class PokemonLevelIncrementModifier extends ConsumablePokemonModifier {
constructor(type: ModifierType, pokemonId: integer) {
super(type, pokemonId);
@ -409,13 +432,6 @@ export class PokemonHpRestoreModifierType extends PokemonModifierType {
}
}
export class PokemonLevelIncrementModifierType extends PokemonModifierType {
constructor(name: string, iconImage?: string) {
super(name, `Increase a POKéMON\'s level by 1`, (type, args) => new PokemonLevelIncrementModifier(type, (args[0] as PlayerPokemon).id),
(_pokemon: PlayerPokemon) => null, iconImage);
}
}
export class PokemonReviveModifierType extends PokemonHpRestoreModifierType {
constructor(name: string, restorePercent: integer, iconImage?: string) {
super(name, restorePercent, (_type, args) => new PokemonHpRestoreModifier(this, (args[0] as PlayerPokemon).id, this.restorePercent, true),
@ -434,6 +450,26 @@ export class PokemonReviveModifierType extends PokemonHpRestoreModifierType {
}
}
export class PokemonLevelIncrementModifierType extends PokemonModifierType {
constructor(name: string, iconImage?: string) {
super(name, `Increase a POKéMON\'s level by 1`, (_type, args) => new PokemonLevelIncrementModifier(this, (args[0] as PlayerPokemon).id),
(_pokemon: PlayerPokemon) => null, iconImage);
}
}
export class PokemonPpRestoreModifierType extends PokemonModifierType {
protected restorePoints: integer;
constructor(name: string, restorePoints: integer, iconImage?: string) {
super(name, `Restore ${restorePoints} PP for one POKéMON's move`, (_type, args) => new PokemonPpRestoreModifier(this, (args[0] as PlayerPokemon).id, this.restorePoints),
(pokemon: PlayerPokemon) => {
return null;
}, iconImage);
this.restorePoints = this.restorePoints;
}
}
export class PokemonBaseStatBoosterModifierType extends PokemonModifierType {
private stat: Stat;

View File

@ -173,9 +173,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
frameRate: 12,
repeat: -1
});
this.getSprite().play(this.getSpriteKey());
this.getTintSprite().play(this.getSpriteKey());
this.getZoomSprite().play(this.getSpriteKey());
this.playAnim();
resolve();
});
if (!this.scene.load.isLoading())
@ -220,6 +218,12 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
return this.getAt(2) as Phaser.GameObjects.Sprite;
}
playAnim() {
this.getSprite().play(this.getSpriteKey());
this.getTintSprite().play(this.getSpriteKey());
this.getZoomSprite().play(this.getSpriteKey());
}
calculateStats() {
if (!this.stats)
this.stats = [ 0, 0, 0, 0, 0, 0 ];