diff --git a/src/arena.ts b/src/arena.ts index 656d6f4334e..7d6e727d4d5 100644 --- a/src/arena.ts +++ b/src/arena.ts @@ -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"; diff --git a/src/battle-scene.ts b/src/battle-scene.ts index 14559a97c30..4c2c8f55686 100644 --- a/src/battle-scene.ts +++ b/src/battle-scene.ts @@ -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 diff --git a/src/data/ability.ts b/src/data/ability.ts index 13b0357fe5a..4a82044ef20 100644 --- a/src/data/ability.ts +++ b/src/data/ability.ts @@ -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"; diff --git a/src/data/arena-tag.ts b/src/data/arena-tag.ts index f611a0e9bac..bff42d4eb85 100644 --- a/src/data/arena-tag.ts +++ b/src/data/arena-tag.ts @@ -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"; diff --git a/src/data/battler-tags.ts b/src/data/battler-tags.ts index 0cd7dbf5d15..08f229b2eaf 100644 --- a/src/data/battler-tags.ts +++ b/src/data/battler-tags.ts @@ -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"; diff --git a/src/data/berry.ts b/src/data/berry.ts index 9a5c67734d6..ab686ad0211 100644 --- a/src/data/berry.ts +++ b/src/data/berry.ts @@ -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"; diff --git a/src/data/move.ts b/src/data/move.ts index 86de43fe43e..7d2a8f24f3b 100644 --- a/src/data/move.ts +++ b/src/data/move.ts @@ -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"; diff --git a/src/egg-hatch-phase.ts b/src/egg-hatch-phase.ts index 4f27a1a4065..570752ba334 100644 --- a/src/egg-hatch-phase.ts +++ b/src/egg-hatch-phase.ts @@ -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; diff --git a/src/evolution-phase.ts b/src/evolution-phase.ts index 1bc0b944190..5c476aed2f1 100644 --- a/src/evolution-phase.ts +++ b/src/evolution-phase.ts @@ -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(); diff --git a/src/form-change-phase.ts b/src/form-change-phase.ts index 185d602f88c..4ed592a9d7c 100644 --- a/src/form-change-phase.ts +++ b/src/form-change-phase.ts @@ -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 { diff --git a/src/modifier/modifier.ts b/src/modifier/modifier.ts index b6c0399cd81..8438ea012b7 100644 --- a/src/modifier/modifier.ts +++ b/src/modifier/modifier.ts @@ -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"; diff --git a/src/battle-phase.ts b/src/phase.ts similarity index 90% rename from src/battle-phase.ts rename to src/phase.ts index b9f597babbd..052a957fa4c 100644 --- a/src/battle-phase.ts +++ b/src/phase.ts @@ -1,6 +1,6 @@ import BattleScene from "./battle-scene"; -export class BattlePhase { +export class Phase { protected scene: BattleScene; constructor(scene: BattleScene) { diff --git a/src/battle-phases.ts b/src/phases.ts similarity index 98% rename from src/battle-phases.ts rename to src/phases.ts index e3b89507c45..c71882b6742 100644 --- a/src/battle-phases.ts +++ b/src/phases.ts @@ -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); } diff --git a/src/pokemon.ts b/src/pokemon.ts index c75ee93d364..496f78a7327 100644 --- a/src/pokemon.ts +++ b/src/pokemon.ts @@ -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"; diff --git a/src/system/auto-play.ts b/src/system/auto-play.ts index 9fc2616f796..05255a2c0c4 100644 --- a/src/system/auto-play.ts +++ b/src/system/auto-play.ts @@ -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"; diff --git a/src/ui/ball-ui-handler.ts b/src/ui/ball-ui-handler.ts index a102b8bd2e0..4583a0edea1 100644 --- a/src/ui/ball-ui-handler.ts +++ b/src/ui/ball-ui-handler.ts @@ -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"; diff --git a/src/ui/command-ui-handler.ts b/src/ui/command-ui-handler.ts index b08a96a7976..9831d006a82 100644 --- a/src/ui/command-ui-handler.ts +++ b/src/ui/command-ui-handler.ts @@ -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"; diff --git a/src/ui/fight-ui-handler.ts b/src/ui/fight-ui-handler.ts index a346cbf105e..8ca6ab6e3d0 100644 --- a/src/ui/fight-ui-handler.ts +++ b/src/ui/fight-ui-handler.ts @@ -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; diff --git a/src/ui/party-ui-handler.ts b/src/ui/party-ui-handler.ts index cd024512923..8598d1dd7aa 100644 --- a/src/ui/party-ui-handler.ts +++ b/src/ui/party-ui-handler.ts @@ -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"; diff --git a/src/ui/pokeball-tray.ts b/src/ui/pokeball-tray.ts index 23a168d51df..0acfcff6a4c 100644 --- a/src/ui/pokeball-tray.ts +++ b/src/ui/pokeball-tray.ts @@ -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);