Fix animation not resuming after faint

This commit is contained in:
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.add.existing(playerPokemon);
this.scene.field.add(playerPokemon); this.scene.field.add(playerPokemon);
playerPokemon.showInfo(); playerPokemon.showInfo();
playerPokemon.playAnim();
playerPokemon.setVisible(true); playerPokemon.setVisible(true);
playerPokemon.setScale(0.5); playerPokemon.setScale(0.5);
playerPokemon.tint(getPokeballTintColor(playerPokemon.pokeball)); playerPokemon.tint(getPokeballTintColor(playerPokemon.pokeball));
@ -968,12 +969,14 @@ export class SelectModifierPhase extends BattlePhase {
if (slotIndex < 6) { if (slotIndex < 6) {
this.scene.ui.setMode(Mode.MODIFIER_SELECT); this.scene.ui.setMode(Mode.MODIFIER_SELECT);
this.scene.addModifier(types[cursor].newModifier(this.scene.getParty()[slotIndex])).then(() => super.end()); this.scene.addModifier(types[cursor].newModifier(this.scene.getParty()[slotIndex])).then(() => super.end());
this.scene.ui.clearText();
this.scene.ui.setMode(Mode.MESSAGE); this.scene.ui.setMode(Mode.MESSAGE);
} else } else
this.scene.ui.setMode(Mode.MODIFIER_SELECT); this.scene.ui.setMode(Mode.MODIFIER_SELECT);
}, pokemonModifierType.selectFilter); }, pokemonModifierType.selectFilter);
} else { } else {
this.scene.addModifier(types[cursor].newModifier()).then(() => super.end()); this.scene.addModifier(types[cursor].newModifier()).then(() => super.end());
this.scene.ui.clearText();
this.scene.ui.setMode(Mode.MESSAGE); 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 { export class PokemonLevelIncrementModifier extends ConsumablePokemonModifier {
constructor(type: ModifierType, pokemonId: integer) { constructor(type: ModifierType, pokemonId: integer) {
super(type, pokemonId); 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 { export class PokemonReviveModifierType extends PokemonHpRestoreModifierType {
constructor(name: string, restorePercent: integer, iconImage?: string) { constructor(name: string, restorePercent: integer, iconImage?: string) {
super(name, restorePercent, (_type, args) => new PokemonHpRestoreModifier(this, (args[0] as PlayerPokemon).id, this.restorePercent, true), 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 { export class PokemonBaseStatBoosterModifierType extends PokemonModifierType {
private stat: Stat; private stat: Stat;

View File

@ -173,9 +173,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
frameRate: 12, frameRate: 12,
repeat: -1 repeat: -1
}); });
this.getSprite().play(this.getSpriteKey()); this.playAnim();
this.getTintSprite().play(this.getSpriteKey());
this.getZoomSprite().play(this.getSpriteKey());
resolve(); resolve();
}); });
if (!this.scene.load.isLoading()) 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; 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() { calculateStats() {
if (!this.stats) if (!this.stats)
this.stats = [ 0, 0, 0, 0, 0, 0 ]; this.stats = [ 0, 0, 0, 0, 0, 0 ];