Display enemy trainer briefly when switching

pull/16/head
Flashfyre 2024-02-21 23:57:49 -05:00
parent aa13562433
commit 4e93f1e52c
20 changed files with 100 additions and 68 deletions

View File

@ -5,7 +5,7 @@ import * as Utils from "./utils";
import PokemonSpecies, { getPokemonSpecies } from "./data/pokemon-species";
import { Species } from "./data/enums/species";
import { Weather, WeatherType, getWeatherClearMessage, getWeatherStartMessage } from "./data/weather";
import { CommonAnimPhase } from "./battle-phases";
import { CommonAnimPhase } from "./phases";
import { CommonAnim } from "./data/battle-anims";
import { Type } from "./data/type";
import Move from "./data/move";

View File

@ -1,6 +1,6 @@
import Phaser from 'phaser';
import UI, { Mode } from './ui/ui';
import { EncounterPhase, SummonPhase, NextEncounterPhase, NewBiomeEncounterPhase, SelectBiomePhase, MessagePhase, CheckLoadPhase, TurnInitPhase, ReturnPhase, LevelCapPhase, TestMessagePhase, ShowTrainerPhase, TrainerMessageTestPhase, LoginPhase, ConsolidateDataPhase, SelectGenderPhase, MovePhase } from './battle-phases';
import { EncounterPhase, SummonPhase, NextEncounterPhase, NewBiomeEncounterPhase, SelectBiomePhase, MessagePhase, CheckLoadPhase, TurnInitPhase, ReturnPhase, LevelCapPhase, TestMessagePhase, ShowTrainerPhase, TrainerMessageTestPhase, LoginPhase, ConsolidateDataPhase, SelectGenderPhase, MovePhase } from './phases';
import Pokemon, { PlayerPokemon, EnemyPokemon } from './pokemon';
import PokemonSpecies, { PokemonSpeciesFilter, allSpecies, getPokemonSpecies, initSpecies, speciesStarters } from './data/pokemon-species';
import * as Utils from './utils';
@ -8,7 +8,7 @@ import { Modifier, ModifierBar, ConsumablePokemonModifier, ConsumableModifier, P
import { PokeballType } from './data/pokeball';
import { initAutoPlay } from './system/auto-play';
import { initCommonAnims, initMoveAnim, loadCommonAnimAssets, loadMoveAnimAssets, populateAnims } from './data/battle-anims';
import { BattlePhase } from './battle-phase';
import { Phase } from './phase';
import { initGameSpeed } from './system/game-speed';
import { Biome } from "./data/enums/biome";
import { Arena, ArenaBase, getBiomeHasProps, getBiomeKey } from './arena';
@ -105,11 +105,11 @@ export default class BattleScene extends Phaser.Scene {
public gameData: GameData;
private phaseQueue: BattlePhase[];
private phaseQueuePrepend: BattlePhase[];
private phaseQueue: Phase[];
private phaseQueuePrepend: Phase[];
private phaseQueuePrependSpliceIndex: integer;
private currentPhase: BattlePhase;
private standbyPhase: BattlePhase;
private currentPhase: Phase;
private standbyPhase: Phase;
public field: Phaser.GameObjects.Container;
public fieldUI: Phaser.GameObjects.Container;
public pbTray: PokeballTray;
@ -1403,19 +1403,19 @@ export default class BattleScene extends Phaser.Scene {
this.cameras.main.removePostPipeline('InvertPostFX');
}
getCurrentPhase(): BattlePhase {
getCurrentPhase(): Phase {
return this.currentPhase;
}
getStandbyPhase(): BattlePhase {
getStandbyPhase(): Phase {
return this.standbyPhase;
}
pushPhase(phase: BattlePhase): void {
pushPhase(phase: Phase): void {
this.phaseQueue.push(phase);
}
unshiftPhase(phase: BattlePhase): void {
unshiftPhase(phase: Phase): void {
if (this.phaseQueuePrependSpliceIndex === -1)
this.phaseQueuePrepend.push(phase);
else
@ -1453,7 +1453,7 @@ export default class BattleScene extends Phaser.Scene {
this.currentPhase.start();
}
overridePhase(phase: BattlePhase): boolean {
overridePhase(phase: Phase): boolean {
if (this.standbyPhase)
return false;
@ -1464,7 +1464,7 @@ export default class BattleScene extends Phaser.Scene {
return true;
}
findPhase(phaseFilter: (phase: BattlePhase) => boolean): BattlePhase {
findPhase(phaseFilter: (phase: Phase) => boolean): Phase {
return this.phaseQueue.find(phaseFilter);
}
@ -1765,7 +1765,7 @@ export default class BattleScene extends Phaser.Scene {
if (pokemonFormChanges.hasOwnProperty(pokemon.species.speciesId)) {
const matchingFormChange = pokemonFormChanges[pokemon.species.speciesId].find(fc => fc.findTrigger(formChangeTriggerType) && fc.canChange(pokemon));
if (matchingFormChange) {
let phase: BattlePhase;
let phase: Phase;
if (pokemon instanceof PlayerPokemon && !matchingFormChange.quiet)
phase = new FormChangePhase(this, pokemon, matchingFormChange, modal);
else

View File

@ -2,7 +2,7 @@ import Pokemon, { HitResult, PokemonMove } from "../pokemon";
import { Type } from "./type";
import * as Utils from "../utils";
import { BattleStat, getBattleStatName } from "./battle-stat";
import { DamagePhase, ObtainStatusEffectPhase, PokemonHealPhase, ShowAbilityPhase, StatChangePhase } from "../battle-phases";
import { DamagePhase, ObtainStatusEffectPhase, PokemonHealPhase, ShowAbilityPhase, StatChangePhase } from "../phases";
import { getPokemonMessage } from "../messages";
import { Weather, WeatherType } from "./weather";
import { BattlerTag } from "./battler-tags";

View File

@ -4,7 +4,7 @@ import * as Utils from "../utils";
import { allMoves } from "./move";
import { getPokemonMessage } from "../messages";
import Pokemon, { HitResult, PokemonMove } from "../pokemon";
import { DamagePhase, MoveEffectPhase, ObtainStatusEffectPhase } from "../battle-phases";
import { DamagePhase, MoveEffectPhase, ObtainStatusEffectPhase } from "../phases";
import { StatusEffect } from "./status-effect";
import { BattlerTagType } from "./enums/battler-tag-type";
import { BattlerIndex } from "../battle";

View File

@ -1,5 +1,5 @@
import { CommonAnim, CommonBattleAnim } from "./battle-anims";
import { CommonAnimPhase, DamagePhase, MovePhase, ObtainStatusEffectPhase, PokemonHealPhase, ShowAbilityPhase } from "../battle-phases";
import { CommonAnimPhase, DamagePhase, MovePhase, ObtainStatusEffectPhase, PokemonHealPhase, ShowAbilityPhase } from "../phases";
import { getPokemonMessage } from "../messages";
import Pokemon, { MoveResult, HitResult } from "../pokemon";
import { Stat } from "./pokemon-stat";

View File

@ -1,4 +1,4 @@
import { PokemonHealPhase, StatChangePhase } from "../battle-phases";
import { PokemonHealPhase, StatChangePhase } from "../phases";
import { getPokemonMessage } from "../messages";
import Pokemon, { HitResult } from "../pokemon";
import { getBattleStatName } from "./battle-stat";

View File

@ -1,6 +1,6 @@
import { Moves } from "./enums/moves";
import { ChargeAnim, MoveChargeAnim, initMoveAnim, loadMoveAnimAssets } from "./battle-anims";
import { BattleEndPhase, DamagePhase, MovePhase, NewBattlePhase, ObtainStatusEffectPhase, PokemonHealPhase, StatChangePhase, SwitchSummonPhase } from "../battle-phases";
import { BattleEndPhase, DamagePhase, MovePhase, NewBattlePhase, ObtainStatusEffectPhase, PokemonHealPhase, StatChangePhase, SwitchSummonPhase } from "../phases";
import { BattleStat, getBattleStatName } from "./battle-stat";
import { EncoreTag } from "./battler-tags";
import { BattlerTagType } from "./enums/battler-tag-type";

View File

@ -1,5 +1,5 @@
import SoundFade from "phaser3-rex-plugins/plugins/soundfade";
import { BattlePhase } from "./battle-phase";
import { Phase } from "./phase";
import BattleScene, { AnySound } from "./battle-scene";
import * as Utils from "./utils";
import { Mode } from "./ui/ui";
@ -16,7 +16,7 @@ import { achvs } from "./system/achv";
import { addWindow } from "./ui/window";
import { getNatureName } from "./data/nature";
export class EggHatchPhase extends BattlePhase {
export class EggHatchPhase extends Phase {
private egg: Egg;
private eggHatchContainer: Phaser.GameObjects.Container;

View File

@ -1,16 +1,16 @@
import SoundFade from "phaser3-rex-plugins/plugins/soundfade";
import { BattlePhase } from "./battle-phase";
import { Phase } from "./phase";
import BattleScene from "./battle-scene";
import { SpeciesEvolution } from "./data/pokemon-evolutions";
import EvolutionSceneHandler from "./ui/evolution-scene-handler";
import * as Utils from "./utils";
import { Mode } from "./ui/ui";
import { LearnMovePhase } from "./battle-phases";
import { LearnMovePhase } from "./phases";
import { cos, sin } from "./anims";
import { PlayerPokemon } from "./pokemon";
import { getTypeRgb } from "./data/type";
export class EvolutionPhase extends BattlePhase {
export class EvolutionPhase extends Phase {
protected pokemon: PlayerPokemon;
protected lastLevel: integer;
@ -505,7 +505,7 @@ export class EvolutionPhase extends BattlePhase {
}
}
export class EndEvolutionPhase extends BattlePhase {
export class EndEvolutionPhase extends Phase {
start() {
super.start();

View File

@ -7,9 +7,8 @@ import { EndEvolutionPhase, EvolutionPhase } from "./evolution-phase";
import Pokemon, { EnemyPokemon, PlayerPokemon } from "./pokemon";
import { Mode } from "./ui/ui";
import PartyUiHandler from "./ui/party-ui-handler";
import { BattlePhase } from "./battle-phase";
import { BattleSpec } from "./enums/battle-spec";
import { MovePhase, PokemonHealPhase } from "./battle-phases";
import { BattlePhase, MovePhase, PokemonHealPhase } from "./phases";
import { getTypeRgb } from "./data/type";
export class FormChangePhase extends EvolutionPhase {

View File

@ -1,5 +1,5 @@
import * as ModifierTypes from './modifier-type';
import { LearnMovePhase, LevelUpPhase, ObtainStatusEffectPhase, PokemonHealPhase } from "../battle-phases";
import { LearnMovePhase, LevelUpPhase, ObtainStatusEffectPhase, PokemonHealPhase } from "../phases";
import BattleScene from "../battle-scene";
import { getLevelTotalExp } from "../data/exp";
import { PokeballType } from "../data/pokeball";

View File

@ -1,6 +1,6 @@
import BattleScene from "./battle-scene";
export class BattlePhase {
export class Phase {
protected scene: BattleScene;
constructor(scene: BattleScene) {

View File

@ -14,7 +14,7 @@ import { StatusEffect, getStatusEffectActivationText, getStatusEffectCatchRateMu
import { SummaryUiMode } from "./ui/summary-ui-handler";
import EvolutionSceneHandler from "./ui/evolution-scene-handler";
import { EvolutionPhase } from "./evolution-phase";
import { BattlePhase } from "./battle-phase";
import { Phase } from "./phase";
import { BattleStat, getBattleStatLevelChangeDescription, getBattleStatName } from "./data/battle-stat";
import { biomeDepths, biomeLinks } from "./data/biomes";
import { Biome } from "./data/enums/biome";
@ -52,7 +52,7 @@ import ModifierSelectUiHandler, { SHOP_OPTIONS_ROW_LIMIT } from "./ui/modifier-s
import { Setting } from "./system/settings";
import { Tutorial, handleTutorial } from "./tutorial";
export class LoginPhase extends BattlePhase {
export class LoginPhase extends Phase {
private showText: boolean;
constructor(scene: BattleScene, showText?: boolean) {
@ -122,7 +122,7 @@ export class LoginPhase extends BattlePhase {
}
// TODO: Remove
export class ConsolidateDataPhase extends BattlePhase {
export class ConsolidateDataPhase extends Phase {
start(): void {
super.start();
@ -168,7 +168,7 @@ export class ConsolidateDataPhase extends BattlePhase {
}
}
export class CheckLoadPhase extends BattlePhase {
export class CheckLoadPhase extends Phase {
private loaded: boolean;
constructor(scene: BattleScene) {
@ -236,7 +236,7 @@ export class CheckLoadPhase extends BattlePhase {
}
}
export class SelectGenderPhase extends BattlePhase {
export class SelectGenderPhase extends Phase {
constructor(scene: BattleScene) {
super(scene);
}
@ -269,7 +269,7 @@ export class SelectGenderPhase extends BattlePhase {
}
}
export class SelectStarterPhase extends BattlePhase {
export class SelectStarterPhase extends Phase {
constructor(scene: BattleScene) {
super(scene);
}
@ -316,6 +316,34 @@ export class SelectStarterPhase extends BattlePhase {
}
}
export class BattlePhase extends Phase {
constructor(scene: BattleScene) {
super(scene);
}
showEnemyTrainer(): void {
this.scene.tweens.add({
targets: this.scene.currentBattle.trainer,
x: '-=16',
y: '+=16',
alpha: 1,
ease: 'Sine.easeInOut',
duration: 750
});
}
hideEnemyTrainer(): void {
this.scene.tweens.add({
targets: this.scene.currentBattle.trainer,
x: '+=16',
y: '-=16',
alpha: 0,
ease: 'Sine.easeInOut',
duration: 750
});
}
}
type PokemonFunc = (pokemon: Pokemon) => void;
export abstract class FieldPhase extends BattlePhase {
@ -574,14 +602,7 @@ export class EncounterPhase extends BattlePhase {
this.scene.pbTray.showPbTray(this.scene.getParty());
this.scene.pbTrayEnemy.showPbTray(this.scene.getEnemyParty());
const doTrainerSummon = () => {
this.scene.tweens.add({
targets: this.scene.currentBattle.trainer,
x: '+=16',
y: '-=16',
alpha: 0,
ease: 'Sine.easeInOut',
duration: 750
});
this.hideEnemyTrainer();
const availablePartyMembers = this.scene.getEnemyParty().filter(p => !p.isFainted()).length;
this.scene.unshiftPhase(new SummonPhase(this.scene, 0, false));
if (this.scene.currentBattle.double && availablePartyMembers > 1)
@ -1028,12 +1049,20 @@ export class SwitchSummonPhase extends SummonPhase {
}
preSummon(): void {
if (!this.player && this.slotIndex === -1)
this.slotIndex = this.scene.currentBattle.trainer.getNextSummonIndex();
if (!this.player) {
if (this.slotIndex === -1)
this.slotIndex = this.scene.currentBattle.trainer.getNextSummonIndex();
this.showEnemyTrainer();
this.scene.pbTrayEnemy.showPbTray(this.scene.getEnemyParty());
}
if (!this.doReturn || (this.slotIndex !== -1 && !(this.player ? this.scene.getParty() : this.scene.getEnemyParty())[this.slotIndex])) {
this.switchAndSummon();
return;
if (this.player)
return this.switchAndSummon();
else {
this.scene.time.delayedCall(750, () => this.switchAndSummon());
return;
}
}
const pokemon = this.getPokemon();
@ -1077,8 +1106,19 @@ export class SwitchSummonPhase extends SummonPhase {
if (switchedPokemon) {
party[this.slotIndex] = this.lastPokemon;
party[this.fieldIndex] = switchedPokemon;
this.scene.ui.showText(this.player ? `Go! ${switchedPokemon.name}!` : `${this.scene.currentBattle.trainer.getName(true)} sent out\n${this.getPokemon().name}!`);
this.summon();
const showTextAndSummon = () => {
this.scene.ui.showText(this.player ? `Go! ${switchedPokemon.name}!` : `${this.scene.currentBattle.trainer.getName(true)} sent out\n${this.getPokemon().name}!`);
this.summon();
};
if (this.player)
showTextAndSummon();
else {
this.scene.time.delayedCall(1500, () => {
this.hideEnemyTrainer();
this.scene.pbTrayEnemy.hide();
showTextAndSummon();
});
}
} else
this.end();
}
@ -2416,7 +2456,7 @@ export class PostTurnStatusEffectPhase extends PokemonPhase {
}
}
export class MessagePhase extends BattlePhase {
export class MessagePhase extends Phase {
private text: string;
private callbackDelay: integer;
private prompt: boolean;
@ -2783,14 +2823,7 @@ export class TrainerVictoryPhase extends BattlePhase {
showMessageAndEnd();
}, null, true);
this.scene.tweens.add({
targets: this.scene.currentBattle.trainer,
x: '-=16',
y: '+=16',
alpha: 1,
ease: 'Sine.easeInOut',
duration: 750
});
this.showEnemyTrainer();
}
}
@ -2883,7 +2916,7 @@ export class GameOverPhase extends BattlePhase {
}
}
export class UnlockPhase extends BattlePhase {
export class UnlockPhase extends Phase {
private unlockable: Unlockables;
constructor(scene: BattleScene, unlockable: Unlockables) {
@ -3682,7 +3715,7 @@ export class SelectModifierPhase extends BattlePhase {
}
}
export class EggLapsePhase extends BattlePhase {
export class EggLapsePhase extends Phase {
constructor(scene: BattleScene) {
super(scene);
}
@ -3707,7 +3740,7 @@ export class EggLapsePhase extends BattlePhase {
}
}
export class AddEnemyBuffModifierPhase extends BattlePhase {
export class AddEnemyBuffModifierPhase extends Phase {
constructor(scene: BattleScene) {
super(scene);
}

View File

@ -15,7 +15,7 @@ import { initMoveAnim, loadMoveAnimAssets } from './data/battle-anims';
import { Status, StatusEffect } from './data/status-effect';
import { reverseCompatibleTms, tmSpecies } from './data/tms';
import { pokemonEvolutions, pokemonPrevolutions, SpeciesEvolution, SpeciesEvolutionCondition } from './data/pokemon-evolutions';
import { DamagePhase, FaintPhase, StatChangePhase, SwitchSummonPhase } from './battle-phases';
import { DamagePhase, FaintPhase, StatChangePhase, SwitchSummonPhase } from './phases';
import { BattleStat } from './data/battle-stat';
import { BattlerTag, BattlerTagLapseType, EncoreTag, TypeBoostTag, getBattlerTag } from './data/battler-tags';
import { BattlerTagType } from "./data/enums/battler-tag-type";

View File

@ -1,4 +1,4 @@
import { SelectModifierPhase } from "../battle-phases";
import { SelectModifierPhase } from "../phases";
import BattleScene, { Button } from "../battle-scene";
import { ModifierType, ModifierTypeOption, PokemonBaseStatBoosterModifierType, PokemonHpRestoreModifierType, PokemonReviveModifierType } from "../modifier/modifier-type";
import Pokemon, { AiType, EnemyPokemon, PlayerPokemon, PokemonMove } from "../pokemon";

View File

@ -1,4 +1,4 @@
import { CommandPhase } from "../battle-phases";
import { CommandPhase } from "../phases";
import BattleScene, { Button } from "../battle-scene";
import { getPokeballName, PokeballType } from "../data/pokeball";
import { addTextObject, TextStyle } from "./text";

View File

@ -1,4 +1,4 @@
import { CommandPhase } from "../battle-phases";
import { CommandPhase } from "../phases";
import BattleScene, { Button } from "../battle-scene";
import { addTextObject, TextStyle } from "./text";
import PartyUiHandler, { PartyUiMode } from "./party-ui-handler";

View File

@ -5,7 +5,7 @@ import { Command } from "./command-ui-handler";
import { Mode } from "./ui";
import UiHandler from "./ui-handler";
import * as Utils from "../utils";
import { CommandPhase } from "../battle-phases";
import { CommandPhase } from "../phases";
export default class FightUiHandler extends UiHandler {
private movesContainer: Phaser.GameObjects.Container;

View File

@ -1,4 +1,4 @@
import { CommandPhase } from "../battle-phases";
import { CommandPhase } from "../phases";
import BattleScene, { Button } from "../battle-scene";
import { PlayerPokemon, PokemonMove } from "../pokemon";
import { addTextObject, TextStyle } from "./text";

View File

@ -49,7 +49,7 @@ export default class PokeballTray extends Phaser.GameObjects.Container {
if (b >= party.length)
ballFrame = 'empty';
else if (!party[b].hp)
ballFrame = 'fainted';
ballFrame = 'faint';
else if (party[b].status)
ballFrame = 'status';
ball.setFrame(ballFrame);