From 02d2b6ebce34bf4d0eb7fba06669ca093467e75d Mon Sep 17 00:00:00 2001 From: ImperialSympathizer Date: Sat, 21 Sep 2024 17:11:12 -0400 Subject: [PATCH] clean up post-battle logic for Breeder ME --- .../the-expert-pokemon-breeder-encounter.ts | 61 ++++++++++++++++--- .../utils/encounter-phase-utils.ts | 2 +- .../the-expert-pokemon-breeder-dialogue.json | 2 +- src/phases/battle-end-phase.ts | 26 +++++--- 4 files changed, 75 insertions(+), 16 deletions(-) diff --git a/src/data/mystery-encounters/encounters/the-expert-pokemon-breeder-encounter.ts b/src/data/mystery-encounters/encounters/the-expert-pokemon-breeder-encounter.ts index 98ace8847ee..91aeea79111 100644 --- a/src/data/mystery-encounters/encounters/the-expert-pokemon-breeder-encounter.ts +++ b/src/data/mystery-encounters/encounters/the-expert-pokemon-breeder-encounter.ts @@ -1,4 +1,4 @@ -import { EnemyPartyConfig, handleMysteryEncounterBattleFailed, initBattleWithEnemyConfig, setEncounterRewards, } from "#app/data/mystery-encounters/utils/encounter-phase-utils"; +import { EnemyPartyConfig, generateModifierType, handleMysteryEncounterBattleFailed, initBattleWithEnemyConfig, setEncounterRewards, } from "#app/data/mystery-encounters/utils/encounter-phase-utils"; import { trainerConfigs } from "#app/data/trainer-config"; import { MysteryEncounterType } from "#enums/mystery-encounter-type"; import BattleScene from "#app/battle-scene"; @@ -21,6 +21,9 @@ import { EggTier } from "#enums/egg-type"; import { MysteryEncounterOptionBuilder } from "#app/data/mystery-encounters/mystery-encounter-option"; import { MysteryEncounterOptionMode } from "#enums/mystery-encounter-option-mode"; import { achvs } from "#app/system/achv"; +import { modifierTypes, PokemonHeldItemModifierType } from "#app/modifier/modifier-type"; +import { Type } from "#app/data/type"; +import { getPokeballTintColor } from "#app/data/pokeball"; /** the i18n namespace for the encounter */ const namespace = "mysteryEncounter:expertPokemonBreeder"; @@ -190,12 +193,6 @@ export const TheExpertPokemonBreederEncounter: MysteryEncounter = pokemon3RareEggs }; - encounter.dialogue.outro = [ - { - text: `${namespace}.outro`, - }, - ]; - return true; }) .withTitle(`${namespace}.title`) @@ -359,6 +356,7 @@ export const TheExpertPokemonBreederEncounter: MysteryEncounter = ) .withOutroDialogue([ { + speaker: trainerNameKey, text: `${namespace}.outro`, }, ]) @@ -384,6 +382,11 @@ function getPartyConfig(scene: BattleScene): EnemyPartyConfig { nature: Nature.ADAMANT, moveSet: [Moves.METEOR_MASH, Moves.FIRE_PUNCH, Moves.ICE_PUNCH, Moves.THUNDER_PUNCH], ivs: [31, 31, 31, 31, 31, 31], + modifierConfigs: [ + { + modifier: generateModifierType(scene, modifierTypes.TERA_SHARD, [Type.STEEL]) as PokemonHeldItemModifierType, + } + ] } ] }; @@ -537,6 +540,7 @@ function onGameOver(scene: BattleScene) { encounter.dialogue.outro = [ { + speaker: trainerNameKey, text: `${namespace}.outro_failed`, }, ]; @@ -552,6 +556,49 @@ function onGameOver(scene: BattleScene) { // Set flag that encounter was failed encounter.misc.encounterFailed = true; + // Revert BGM + scene.playBgm(scene.arena.bgm); + + // Return enemy Pokemon + const pokemon = scene.getEnemyPokemon(); + if (pokemon) { + scene.playSound("se/pb_rel"); + pokemon.hideInfo(); + pokemon.tint(getPokeballTintColor(pokemon.pokeball), 1, 250, "Sine.easeIn"); + scene.tweens.add({ + targets: pokemon, + duration: 250, + ease: "Sine.easeIn", + scale: 0.5, + onComplete: () => { + scene.field.remove(pokemon, true); + } + }); + } + + // Show the enemy trainer + scene.time.delayedCall(250, () => { + const sprites = scene.currentBattle.trainer?.getSprites(); + const tintSprites = scene.currentBattle.trainer?.getTintSprites(); + if (sprites && tintSprites) { + for (let i = 0; i < sprites.length; i++) { + sprites[i].setVisible(true); + tintSprites[i].setVisible(true); + sprites[i].clearTint(); + tintSprites[i].clearTint(); + } + } + scene.tweens.add({ + targets: scene.currentBattle.trainer, + x: "-=16", + y: "+=16", + alpha: 1, + ease: "Sine.easeInOut", + duration: 750 + }); + }); + + handleMysteryEncounterBattleFailed(scene, true); return false; diff --git a/src/data/mystery-encounters/utils/encounter-phase-utils.ts b/src/data/mystery-encounters/utils/encounter-phase-utils.ts index 1ba55a36fba..7eb205ce3f7 100644 --- a/src/data/mystery-encounters/utils/encounter-phase-utils.ts +++ b/src/data/mystery-encounters/utils/encounter-phase-utils.ts @@ -764,7 +764,7 @@ export function handleMysteryEncounterBattleFailed(scene: BattleScene, addHealPh if (encounter.continuousEncounter || doNotContinue) { return; } else if (encounter.encounterMode !== MysteryEncounterMode.NO_BATTLE) { - scene.pushPhase(new BattleEndPhase(scene)); + scene.pushPhase(new BattleEndPhase(scene, false)); } scene.pushPhase(new MysteryEncounterRewardsPhase(scene, addHealPhase)); diff --git a/src/locales/en/mystery-encounters/the-expert-pokemon-breeder-dialogue.json b/src/locales/en/mystery-encounters/the-expert-pokemon-breeder-dialogue.json index 1f91db7e677..3c74c7b2726 100644 --- a/src/locales/en/mystery-encounters/the-expert-pokemon-breeder-dialogue.json +++ b/src/locales/en/mystery-encounters/the-expert-pokemon-breeder-dialogue.json @@ -23,7 +23,7 @@ "selected": "Let's do this!" }, "outro": "Look how happy your {{chosenPokemon}} is now!$Here, you can have these as well.", - "outro_dialogue": "How disappointing...$It looks like you still have a long way\nto go to earn your Pokémon's trust!", + "outro_failed": "How disappointing...$It looks like you still have a long way\nto go to earn your Pokémon's trust!", "gained_eggs": "@s{item_fanfare}You received {{numEggs}}!", "eggs_tooltip": "\n(+) Earn {{eggs}}", "numEggs_one": "{{count}} {{rarity}} Egg", diff --git a/src/phases/battle-end-phase.ts b/src/phases/battle-end-phase.ts index f08e04b443a..902a85325ad 100644 --- a/src/phases/battle-end-phase.ts +++ b/src/phases/battle-end-phase.ts @@ -2,19 +2,31 @@ import { applyPostBattleAbAttrs, PostBattleAbAttr } from "#app/data/ability"; import { LapsingPersistentModifier, LapsingPokemonHeldItemModifier } from "#app/modifier/modifier"; import { BattlePhase } from "./battle-phase"; import { GameOverPhase } from "./game-over-phase"; +import BattleScene from "#app/battle-scene"; export class BattleEndPhase extends BattlePhase { + /** If true, will increment battles won */ + isVictory: boolean; + + constructor(scene: BattleScene, isVictory: boolean = true) { + super(scene); + + this.isVictory = isVictory; + } + start() { super.start(); - this.scene.currentBattle.addBattleScore(this.scene); + if (this.isVictory) { + this.scene.currentBattle.addBattleScore(this.scene); - this.scene.gameData.gameStats.battles++; - if (this.scene.currentBattle.trainer) { - this.scene.gameData.gameStats.trainersDefeated++; - } - if (this.scene.gameMode.isEndless && this.scene.currentBattle.waveIndex + 1 > this.scene.gameData.gameStats.highestEndlessWave) { - this.scene.gameData.gameStats.highestEndlessWave = this.scene.currentBattle.waveIndex + 1; + this.scene.gameData.gameStats.battles++; + if (this.scene.currentBattle.trainer) { + this.scene.gameData.gameStats.trainersDefeated++; + } + if (this.scene.gameMode.isEndless && this.scene.currentBattle.waveIndex + 1 > this.scene.gameData.gameStats.highestEndlessWave) { + this.scene.gameData.gameStats.highestEndlessWave = this.scene.currentBattle.waveIndex + 1; + } } // Endless graceful end