pokerogue/src/phases/evolution-phase.ts

551 lines
18 KiB
TypeScript
Raw Normal View History

2023-04-10 13:54:06 -04:00
import SoundFade from "phaser3-rex-plugins/plugins/soundfade";
import { Phase } from "#app/phase";
import BattleScene, { AnySound } from "#app/battle-scene";
import { SpeciesFormEvolution } from "#app/data/balance/pokemon-evolutions";
import EvolutionSceneHandler from "#app/ui/evolution-scene-handler";
import * as Utils from "#app/utils";
import { Mode } from "#app/ui/ui";
import { cos, sin } from "#app/field/anims";
import Pokemon, { PlayerPokemon } from "#app/field/pokemon";
import { getTypeRgb } from "#app/data/type";
import i18next from "i18next";
import { getPokemonNameWithAffix } from "#app/messages";
import { LearnMovePhase } from "#app/phases/learn-move-phase";
import { EndEvolutionPhase } from "#app/phases/end-evolution-phase";
2023-04-10 13:54:06 -04:00
export class EvolutionPhase extends Phase {
2024-01-09 23:34:43 -05:00
protected pokemon: PlayerPokemon;
protected lastLevel: integer;
2024-05-24 01:45:04 +02:00
private preEvolvedPokemonName: string;
[Refactor] use typescript `strict-null` (#3259) * TS: enable strict-null * fix battle-scene.ts * fix voucher.ts * adapt more files to strict-null * adapt more files to strict-null ( 2) * adapt ability.ts to strict-null * adapt `arena.ts` to strict-null * adapt TagAddedEvent constructor to strict-null * adapt phases.ts.to strict-null * adapt status-effect.ts to strict-null * adapt `account.ts` to strict-null * adapt `configHandler.ts` to strict-null * adapt `ability.ts` to strict-null * adapt `biomes.ts` to strict-null * adapt `challenge.ts` to strict-null * adapt `daily-run.ts` to strict-null * adapt `nature.ts` to strict-null * adapt `pokemon-forms.ts` to strict-null * adapt `tainer-names.ts` to strict-null * adapt `types.ts` to strict-null * adapt `weather.ts` to strict-null * adapt `egg-hatch-phase.ts` to strict-null * adapt `evolution-phase.ts` to strict-null * adapt `pokemon-sprite-sparkle-handler.ts` to strict-null * adapt `evolution-phase.ts` to strict-null * adapt `game-mode.ts` to strict-null * adapt `utils.ts` to strict-null * adapt `voucher-ui-handler.ts` to strict-null * adapt `src/ui/unavailable-modal-ui-handler.ts` to strict-null * adapt `src/ui/ui.ts` to strict-null * adapt `src/ui/ui-theme.ts` to strict-null * adapt `src/ui/title-ui-handler.ts` to strict-null * adapt `src/ui/time-of-day-widget.ts` to strict-null * adapt `src/ui/text.ts` to strict-null * adapt `src/ui/target-select-ui-handler.ts` to strict-null * adapt `src/ui/settings/settings-keyboard-ui-handler.ts` to strict-null * adapt more files to strict-null (3) * adapt more files to strict-null (4) * adapt more files (mostly tests) to strict-null (5) * adapt more files to strict-null (6) * adapt more files to strict-null (7) * Update `src/data/pokemon-evolutions.ts` for strict-null Partial update `src/data/pokemon-species.ts` for strict-null * adapt more files to strict-null (8) * adapt more files to strict-null (9) * Strict some more nulls (still a few errors remaining) * adapt rest of the files to strict-null (9) * fix tests (check for null instead of undefined) * repalce a lot of `??` with bangs And added TODO notice as usual * fix more tests * all tests pass now * fix broken game-loop after trainer battle add some console.warn for missing cases and falling back to default * remove guessed fallback from utils.rgbHexToRgba * add TODO for this.currentBattle = null * adjust getPokemonById() return to include `null` * fix compilation errors * add test for pokemon.trySetStatus * `chanceMultiplier` shouldn't be optional * allow `null` for currentPhase * adjust hasExpSprite logic for no keymatch found * reduce bang usage in account.updateUserInfo() * fix new strict-null issues after merge * fix `strict-null` issues in dropdown.ts and sand_spit.test.ts * fix egg-gacha * adapt gul_missile.test.ts to strict-null * fix move.ts strict-null * fix i18n.ts strict-null * fix strict-null issues * fix baton_pass test after accidentially breaking it * chore: fix compiler errors * revert accidential changes in baton_pass.test.ts --------- Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
2024-08-07 09:23:12 -07:00
private evolution: SpeciesFormEvolution | null;
private evolutionBgm: AnySound;
private evolutionHandler: EvolutionSceneHandler;
2024-01-09 23:34:43 -05:00
protected evolutionContainer: Phaser.GameObjects.Container;
protected evolutionBaseBg: Phaser.GameObjects.Image;
protected evolutionBg: Phaser.GameObjects.Video;
protected evolutionBgOverlay: Phaser.GameObjects.Rectangle;
protected evolutionOverlay: Phaser.GameObjects.Rectangle;
protected pokemonSprite: Phaser.GameObjects.Sprite;
protected pokemonTintSprite: Phaser.GameObjects.Sprite;
protected pokemonEvoSprite: Phaser.GameObjects.Sprite;
protected pokemonEvoTintSprite: Phaser.GameObjects.Sprite;
[Refactor] use typescript `strict-null` (#3259) * TS: enable strict-null * fix battle-scene.ts * fix voucher.ts * adapt more files to strict-null * adapt more files to strict-null ( 2) * adapt ability.ts to strict-null * adapt `arena.ts` to strict-null * adapt TagAddedEvent constructor to strict-null * adapt phases.ts.to strict-null * adapt status-effect.ts to strict-null * adapt `account.ts` to strict-null * adapt `configHandler.ts` to strict-null * adapt `ability.ts` to strict-null * adapt `biomes.ts` to strict-null * adapt `challenge.ts` to strict-null * adapt `daily-run.ts` to strict-null * adapt `nature.ts` to strict-null * adapt `pokemon-forms.ts` to strict-null * adapt `tainer-names.ts` to strict-null * adapt `types.ts` to strict-null * adapt `weather.ts` to strict-null * adapt `egg-hatch-phase.ts` to strict-null * adapt `evolution-phase.ts` to strict-null * adapt `pokemon-sprite-sparkle-handler.ts` to strict-null * adapt `evolution-phase.ts` to strict-null * adapt `game-mode.ts` to strict-null * adapt `utils.ts` to strict-null * adapt `voucher-ui-handler.ts` to strict-null * adapt `src/ui/unavailable-modal-ui-handler.ts` to strict-null * adapt `src/ui/ui.ts` to strict-null * adapt `src/ui/ui-theme.ts` to strict-null * adapt `src/ui/title-ui-handler.ts` to strict-null * adapt `src/ui/time-of-day-widget.ts` to strict-null * adapt `src/ui/text.ts` to strict-null * adapt `src/ui/target-select-ui-handler.ts` to strict-null * adapt `src/ui/settings/settings-keyboard-ui-handler.ts` to strict-null * adapt more files to strict-null (3) * adapt more files to strict-null (4) * adapt more files (mostly tests) to strict-null (5) * adapt more files to strict-null (6) * adapt more files to strict-null (7) * Update `src/data/pokemon-evolutions.ts` for strict-null Partial update `src/data/pokemon-species.ts` for strict-null * adapt more files to strict-null (8) * adapt more files to strict-null (9) * Strict some more nulls (still a few errors remaining) * adapt rest of the files to strict-null (9) * fix tests (check for null instead of undefined) * repalce a lot of `??` with bangs And added TODO notice as usual * fix more tests * all tests pass now * fix broken game-loop after trainer battle add some console.warn for missing cases and falling back to default * remove guessed fallback from utils.rgbHexToRgba * add TODO for this.currentBattle = null * adjust getPokemonById() return to include `null` * fix compilation errors * add test for pokemon.trySetStatus * `chanceMultiplier` shouldn't be optional * allow `null` for currentPhase * adjust hasExpSprite logic for no keymatch found * reduce bang usage in account.updateUserInfo() * fix new strict-null issues after merge * fix `strict-null` issues in dropdown.ts and sand_spit.test.ts * fix egg-gacha * adapt gul_missile.test.ts to strict-null * fix move.ts strict-null * fix i18n.ts strict-null * fix strict-null issues * fix baton_pass test after accidentially breaking it * chore: fix compiler errors * revert accidential changes in baton_pass.test.ts --------- Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
2024-08-07 09:23:12 -07:00
constructor(scene: BattleScene, pokemon: PlayerPokemon, evolution: SpeciesFormEvolution | null, lastLevel: integer) {
2023-04-10 13:54:06 -04:00
super(scene);
2024-01-09 23:34:43 -05:00
this.pokemon = pokemon;
2023-04-10 13:54:06 -04:00
this.evolution = evolution;
this.lastLevel = lastLevel;
}
2024-01-09 23:34:43 -05:00
validate(): boolean {
return !!this.evolution;
}
setMode(): Promise<void> {
return this.scene.ui.setModeForceTransition(Mode.EVOLUTION_SCENE);
}
2023-04-10 13:54:06 -04:00
start() {
super.start();
2024-01-09 23:34:43 -05:00
this.setMode().then(() => {
2023-04-10 13:54:06 -04:00
if (!this.validate()) {
2023-12-07 17:43:56 -05:00
return this.end();
}
2023-04-10 13:54:06 -04:00
[Refactor] use typescript `strict-null` (#3259) * TS: enable strict-null * fix battle-scene.ts * fix voucher.ts * adapt more files to strict-null * adapt more files to strict-null ( 2) * adapt ability.ts to strict-null * adapt `arena.ts` to strict-null * adapt TagAddedEvent constructor to strict-null * adapt phases.ts.to strict-null * adapt status-effect.ts to strict-null * adapt `account.ts` to strict-null * adapt `configHandler.ts` to strict-null * adapt `ability.ts` to strict-null * adapt `biomes.ts` to strict-null * adapt `challenge.ts` to strict-null * adapt `daily-run.ts` to strict-null * adapt `nature.ts` to strict-null * adapt `pokemon-forms.ts` to strict-null * adapt `tainer-names.ts` to strict-null * adapt `types.ts` to strict-null * adapt `weather.ts` to strict-null * adapt `egg-hatch-phase.ts` to strict-null * adapt `evolution-phase.ts` to strict-null * adapt `pokemon-sprite-sparkle-handler.ts` to strict-null * adapt `evolution-phase.ts` to strict-null * adapt `game-mode.ts` to strict-null * adapt `utils.ts` to strict-null * adapt `voucher-ui-handler.ts` to strict-null * adapt `src/ui/unavailable-modal-ui-handler.ts` to strict-null * adapt `src/ui/ui.ts` to strict-null * adapt `src/ui/ui-theme.ts` to strict-null * adapt `src/ui/title-ui-handler.ts` to strict-null * adapt `src/ui/time-of-day-widget.ts` to strict-null * adapt `src/ui/text.ts` to strict-null * adapt `src/ui/target-select-ui-handler.ts` to strict-null * adapt `src/ui/settings/settings-keyboard-ui-handler.ts` to strict-null * adapt more files to strict-null (3) * adapt more files to strict-null (4) * adapt more files (mostly tests) to strict-null (5) * adapt more files to strict-null (6) * adapt more files to strict-null (7) * Update `src/data/pokemon-evolutions.ts` for strict-null Partial update `src/data/pokemon-species.ts` for strict-null * adapt more files to strict-null (8) * adapt more files to strict-null (9) * Strict some more nulls (still a few errors remaining) * adapt rest of the files to strict-null (9) * fix tests (check for null instead of undefined) * repalce a lot of `??` with bangs And added TODO notice as usual * fix more tests * all tests pass now * fix broken game-loop after trainer battle add some console.warn for missing cases and falling back to default * remove guessed fallback from utils.rgbHexToRgba * add TODO for this.currentBattle = null * adjust getPokemonById() return to include `null` * fix compilation errors * add test for pokemon.trySetStatus * `chanceMultiplier` shouldn't be optional * allow `null` for currentPhase * adjust hasExpSprite logic for no keymatch found * reduce bang usage in account.updateUserInfo() * fix new strict-null issues after merge * fix `strict-null` issues in dropdown.ts and sand_spit.test.ts * fix egg-gacha * adapt gul_missile.test.ts to strict-null * fix move.ts strict-null * fix i18n.ts strict-null * fix strict-null issues * fix baton_pass test after accidentially breaking it * chore: fix compiler errors * revert accidential changes in baton_pass.test.ts --------- Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
2024-08-07 09:23:12 -07:00
this.scene.fadeOutBgm(undefined, false);
2023-04-10 13:54:06 -04:00
this.evolutionHandler = this.scene.ui.getHandler() as EvolutionSceneHandler;
2023-12-14 11:54:56 -05:00
this.evolutionContainer = this.evolutionHandler.evolutionContainer;
2023-04-10 13:54:06 -04:00
this.evolutionBaseBg = this.scene.add.image(0, 0, "default_bg");
2023-04-10 13:54:06 -04:00
this.evolutionBaseBg.setOrigin(0, 0);
this.evolutionContainer.add(this.evolutionBaseBg);
this.evolutionBg = this.scene.add.video(0, 0, "evo_bg").stop();
2023-04-10 13:54:06 -04:00
this.evolutionBg.setOrigin(0, 0);
this.evolutionBg.setScale(0.4359673025);
this.evolutionBg.setVisible(false);
this.evolutionContainer.add(this.evolutionBg);
this.evolutionBgOverlay = this.scene.add.rectangle(0, 0, this.scene.game.canvas.width / 6, this.scene.game.canvas.height / 6, 0x262626);
this.evolutionBgOverlay.setOrigin(0, 0);
this.evolutionBgOverlay.setAlpha(0);
this.evolutionContainer.add(this.evolutionBgOverlay);
const getPokemonSprite = () => {
const ret = this.scene.addPokemonSprite(this.pokemon, this.evolutionBaseBg.displayWidth / 2, this.evolutionBaseBg.displayHeight / 2, "pkmn__sub");
ret.setPipeline(this.scene.spritePipeline, { tone: [ 0.0, 0.0, 0.0, 0.0 ], ignoreTimeTint: true });
return ret;
};
2023-04-10 13:54:06 -04:00
this.evolutionContainer.add((this.pokemonSprite = getPokemonSprite()));
this.evolutionContainer.add((this.pokemonTintSprite = getPokemonSprite()));
this.evolutionContainer.add((this.pokemonEvoSprite = getPokemonSprite()));
this.evolutionContainer.add((this.pokemonEvoTintSprite = getPokemonSprite()));
this.pokemonTintSprite.setAlpha(0);
this.pokemonTintSprite.setTintFill(0xFFFFFF);
this.pokemonEvoSprite.setVisible(false);
this.pokemonEvoTintSprite.setVisible(false);
this.pokemonEvoTintSprite.setTintFill(0xFFFFFF);
2024-01-09 23:34:43 -05:00
this.evolutionOverlay = this.scene.add.rectangle(0, -this.scene.game.canvas.height / 6, this.scene.game.canvas.width / 6, (this.scene.game.canvas.height / 6) - 48, 0xFFFFFF);
2023-04-10 13:54:06 -04:00
this.evolutionOverlay.setOrigin(0, 0);
this.evolutionOverlay.setAlpha(0);
2024-01-09 23:34:43 -05:00
this.scene.ui.add(this.evolutionOverlay);
2023-04-10 13:54:06 -04:00
[ this.pokemonSprite, this.pokemonTintSprite, this.pokemonEvoSprite, this.pokemonEvoTintSprite ].map(sprite => {
2024-01-09 23:34:43 -05:00
sprite.play(this.pokemon.getSpriteKey(true));
sprite.setPipeline(this.scene.spritePipeline, { tone: [ 0.0, 0.0, 0.0, 0.0 ], hasShadow: false, teraColor: getTypeRgb(this.pokemon.getTeraType()) });
sprite.setPipelineData("ignoreTimeTint", true);
sprite.setPipelineData("spriteKey", this.pokemon.getSpriteKey());
sprite.setPipelineData("shiny", this.pokemon.shiny);
sprite.setPipelineData("variant", this.pokemon.variant);
[ "spriteColors", "fusionSpriteColors" ].map(k => {
if (this.pokemon.summonData?.speciesForm) {
k += "Base";
}
2024-01-09 23:34:43 -05:00
sprite.pipelineData[k] = this.pokemon.getSprite().pipelineData[k];
});
});
this.preEvolvedPokemonName = getPokemonNameWithAffix(this.pokemon);
2024-01-09 23:34:43 -05:00
this.doEvolution();
});
}
2024-01-09 23:34:43 -05:00
doEvolution(): void {
this.scene.ui.showText(i18next.t("menu:evolving", { pokemonName: this.preEvolvedPokemonName }), null, () => {
2024-01-09 23:34:43 -05:00
this.pokemon.cry();
this.pokemon.getPossibleEvolution(this.evolution).then(evolvedPokemon => {
[ this.pokemonEvoSprite, this.pokemonEvoTintSprite ].map(sprite => {
sprite.play(evolvedPokemon.getSpriteKey(true));
sprite.setPipelineData("ignoreTimeTint", true);
sprite.setPipelineData("spriteKey", evolvedPokemon.getSpriteKey());
sprite.setPipelineData("shiny", evolvedPokemon.shiny);
sprite.setPipelineData("variant", evolvedPokemon.variant);
[ "spriteColors", "fusionSpriteColors" ].map(k => {
if (evolvedPokemon.summonData?.speciesForm) {
k += "Base";
}
2024-01-09 23:34:43 -05:00
sprite.pipelineData[k] = evolvedPokemon.getSprite().pipelineData[k];
});
2024-01-09 23:34:43 -05:00
});
2023-04-10 13:54:06 -04:00
2024-01-09 23:34:43 -05:00
this.scene.time.delayedCall(1000, () => {
this.evolutionBgm = this.scene.playSoundWithoutBgm("evolution");
2024-01-09 23:34:43 -05:00
this.scene.tweens.add({
targets: this.evolutionBgOverlay,
alpha: 1,
delay: 500,
duration: 1500,
ease: "Sine.easeOut",
2024-01-09 23:34:43 -05:00
onComplete: () => {
this.scene.time.delayedCall(1000, () => {
this.scene.tweens.add({
targets: this.evolutionBgOverlay,
alpha: 0,
duration: 250
2023-04-10 13:54:06 -04:00
});
2024-01-09 23:34:43 -05:00
this.evolutionBg.setVisible(true);
this.evolutionBg.play();
});
[Refactor][QoL] Game Audio + New Settings (#3527) * Changed how non-BGM are loaded into the game + moved into directories * some leftovers * Apply suggestions from code review Co-authored-by: flx-sta <50131232+flx-sta@users.noreply.github.com> * Added setting for Field Volume + rewrote playSound() and updateSoundVolume() functions to reflect the new settings. * Main -> Beta (#3635) * Fixed issue with falsy issue within condition to get a stat for IV scanner * add fix setting code to prevent form/variant bug when default form/variant setting is wrong. in addition, that fix code include gender fix, so i revert old gender fix. update wrong log message. * [Hotfix] Fix Memory Mushroom not showing relearner moves (#3619) * Fix Memory Mushroom not showing relearner moves * Fix rollout test * Rewrite player faint logic in FaintPhase (#3614) * 867 runerigus sprite (#3629) cropped static frames, fixed cropped sprite set runerigus exp to use the shiny exp's animation verified all hex colors are unchanged - fixed ultra necrozma exp front variant swapped arrays. - xatu female eye color fix * [Bug] Preventing the MBH from being stolen in Endless (#3630) * Endless MBH Fix * add import * Revert "add import" This reverts commit 814a4059c2830e972c348d698259535e117850bf. * Revert "Endless MBH Fix" This reverts commit 8eb448130132ff9eed614a2ec576926814008df0. * removed newline --------- Co-authored-by: Frederico Santos <frederico.f.santos@tecnico.ulisboa.pt> Co-authored-by: frutescens <info@laptop> * [Bug] Fix type-hints for immunity (#3620) * enable mock containers to be found by name * enable mock text to be found by name * add test coverage for type-hints Only for "immunity" and "status moves" * fix wrong message key of curse(ghost type) (#3631) Co-authored-by: Frederico Santos <frederico.f.santos@tecnico.ulisboa.pt> * [Hotfix] Steal-able Mini Black Hole Pt 2 (#3632) * Still have no idea where Eternatus is given the MBH.... * typedocs --------- Co-authored-by: frutescens <info@laptop> * [Hotfix] Abilities that prevent ATK drops no longer stop other stat drops (#3624) * Abilities that prevent ATK drops no longer stop other stat drops * Apply suggestions from code review Co-authored-by: Mumble <kimjoanne@protonmail.com> * Add `isNullOrUndefined()` utility function --------- * Grip Claw now shows the proper pokemon nickname (#3634) Co-authored-by: frutescens <info@laptop> --------- Co-authored-by: Opaque02 <66582645+Opaque02@users.noreply.github.com> Co-authored-by: KimJeongSun <leo@atlaslabs.ai> Co-authored-by: Frederico Santos <frederico.f.santos@tecnico.ulisboa.pt> Co-authored-by: innerthunder <168692175+innerthunder@users.noreply.github.com> Co-authored-by: cam <lrlrliwoo@gmail.com> Co-authored-by: Mumble <kimjoanne@protonmail.com> Co-authored-by: frutescens <info@laptop> Co-authored-by: flx-sta <50131232+flx-sta@users.noreply.github.com> Co-authored-by: Enoch <enoch.jwsong@gmail.com> Co-authored-by: Mumble <171087428+frutescens@users.noreply.github.com> * [Bug] Preventing the MBH from being stolen in Endless (#3630) * Endless MBH Fix * add import * Revert "add import" This reverts commit 814a4059c2830e972c348d698259535e117850bf. * Revert "Endless MBH Fix" This reverts commit 8eb448130132ff9eed614a2ec576926814008df0. * removed newline --------- Co-authored-by: Frederico Santos <frederico.f.santos@tecnico.ulisboa.pt> Co-authored-by: frutescens <info@laptop> * [Hotfix] Steal-able Mini Black Hole Pt 2 (#3632) * Still have no idea where Eternatus is given the MBH.... * typedocs --------- Co-authored-by: frutescens <info@laptop> * Deleted phases.ts (#3618) * Updated sound terms * Added space for localization * Update src/locales/ko/settings.ts Co-authored-by: Enoch <enoch.jwsong@gmail.com> * Update src/locales/zh_TW/settings.ts Co-authored-by: mercurius-00 <80205689+mercurius-00@users.noreply.github.com> * Update src/locales/pt_BR/settings.ts Co-authored-by: José Ricardo Fleury Oliveira <josefleury@discente.ufg.br> * Update src/locales/zh_CN/settings.ts Co-authored-by: mercurius-00 <80205689+mercurius-00@users.noreply.github.com> * Update src/locales/de/settings.ts Co-authored-by: Jannik Tappert <38758606+CodeTappert@users.noreply.github.com> * Update src/locales/ko/settings.ts Co-authored-by: returntoice <dieandbecome@gmail.com> * Update src/locales/fr/settings.ts Co-authored-by: Lugiad' <adrien.grivel@hotmail.fr> * Update src/locales/it/settings.ts Co-authored-by: Niccolò <123510358+NicusPulcis@users.noreply.github.com> * Include sound effects that were loaded in as BGM. * Removed stray placeholder localization --------- Co-authored-by: Frutescens <info@laptop> Co-authored-by: flx-sta <50131232+flx-sta@users.noreply.github.com> Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> Co-authored-by: Opaque02 <66582645+Opaque02@users.noreply.github.com> Co-authored-by: KimJeongSun <leo@atlaslabs.ai> Co-authored-by: Frederico Santos <frederico.f.santos@tecnico.ulisboa.pt> Co-authored-by: innerthunder <168692175+innerthunder@users.noreply.github.com> Co-authored-by: cam <lrlrliwoo@gmail.com> Co-authored-by: Enoch <enoch.jwsong@gmail.com> Co-authored-by: mercurius-00 <80205689+mercurius-00@users.noreply.github.com> Co-authored-by: José Ricardo Fleury Oliveira <josefleury@discente.ufg.br> Co-authored-by: Jannik Tappert <38758606+CodeTappert@users.noreply.github.com> Co-authored-by: returntoice <dieandbecome@gmail.com> Co-authored-by: Lugiad' <adrien.grivel@hotmail.fr> Co-authored-by: Niccolò <123510358+NicusPulcis@users.noreply.github.com>
2024-08-25 09:40:14 -07:00
this.scene.playSound("se/charge");
2024-01-09 23:34:43 -05:00
this.doSpiralUpward();
this.scene.tweens.addCounter({
from: 0,
to: 1,
duration: 2000,
onUpdate: t => {
this.pokemonTintSprite.setAlpha(t.getValue());
},
onComplete: () => {
this.pokemonSprite.setVisible(false);
this.scene.time.delayedCall(1100, () => {
[Refactor][QoL] Game Audio + New Settings (#3527) * Changed how non-BGM are loaded into the game + moved into directories * some leftovers * Apply suggestions from code review Co-authored-by: flx-sta <50131232+flx-sta@users.noreply.github.com> * Added setting for Field Volume + rewrote playSound() and updateSoundVolume() functions to reflect the new settings. * Main -> Beta (#3635) * Fixed issue with falsy issue within condition to get a stat for IV scanner * add fix setting code to prevent form/variant bug when default form/variant setting is wrong. in addition, that fix code include gender fix, so i revert old gender fix. update wrong log message. * [Hotfix] Fix Memory Mushroom not showing relearner moves (#3619) * Fix Memory Mushroom not showing relearner moves * Fix rollout test * Rewrite player faint logic in FaintPhase (#3614) * 867 runerigus sprite (#3629) cropped static frames, fixed cropped sprite set runerigus exp to use the shiny exp's animation verified all hex colors are unchanged - fixed ultra necrozma exp front variant swapped arrays. - xatu female eye color fix * [Bug] Preventing the MBH from being stolen in Endless (#3630) * Endless MBH Fix * add import * Revert "add import" This reverts commit 814a4059c2830e972c348d698259535e117850bf. * Revert "Endless MBH Fix" This reverts commit 8eb448130132ff9eed614a2ec576926814008df0. * removed newline --------- Co-authored-by: Frederico Santos <frederico.f.santos@tecnico.ulisboa.pt> Co-authored-by: frutescens <info@laptop> * [Bug] Fix type-hints for immunity (#3620) * enable mock containers to be found by name * enable mock text to be found by name * add test coverage for type-hints Only for "immunity" and "status moves" * fix wrong message key of curse(ghost type) (#3631) Co-authored-by: Frederico Santos <frederico.f.santos@tecnico.ulisboa.pt> * [Hotfix] Steal-able Mini Black Hole Pt 2 (#3632) * Still have no idea where Eternatus is given the MBH.... * typedocs --------- Co-authored-by: frutescens <info@laptop> * [Hotfix] Abilities that prevent ATK drops no longer stop other stat drops (#3624) * Abilities that prevent ATK drops no longer stop other stat drops * Apply suggestions from code review Co-authored-by: Mumble <kimjoanne@protonmail.com> * Add `isNullOrUndefined()` utility function --------- * Grip Claw now shows the proper pokemon nickname (#3634) Co-authored-by: frutescens <info@laptop> --------- Co-authored-by: Opaque02 <66582645+Opaque02@users.noreply.github.com> Co-authored-by: KimJeongSun <leo@atlaslabs.ai> Co-authored-by: Frederico Santos <frederico.f.santos@tecnico.ulisboa.pt> Co-authored-by: innerthunder <168692175+innerthunder@users.noreply.github.com> Co-authored-by: cam <lrlrliwoo@gmail.com> Co-authored-by: Mumble <kimjoanne@protonmail.com> Co-authored-by: frutescens <info@laptop> Co-authored-by: flx-sta <50131232+flx-sta@users.noreply.github.com> Co-authored-by: Enoch <enoch.jwsong@gmail.com> Co-authored-by: Mumble <171087428+frutescens@users.noreply.github.com> * [Bug] Preventing the MBH from being stolen in Endless (#3630) * Endless MBH Fix * add import * Revert "add import" This reverts commit 814a4059c2830e972c348d698259535e117850bf. * Revert "Endless MBH Fix" This reverts commit 8eb448130132ff9eed614a2ec576926814008df0. * removed newline --------- Co-authored-by: Frederico Santos <frederico.f.santos@tecnico.ulisboa.pt> Co-authored-by: frutescens <info@laptop> * [Hotfix] Steal-able Mini Black Hole Pt 2 (#3632) * Still have no idea where Eternatus is given the MBH.... * typedocs --------- Co-authored-by: frutescens <info@laptop> * Deleted phases.ts (#3618) * Updated sound terms * Added space for localization * Update src/locales/ko/settings.ts Co-authored-by: Enoch <enoch.jwsong@gmail.com> * Update src/locales/zh_TW/settings.ts Co-authored-by: mercurius-00 <80205689+mercurius-00@users.noreply.github.com> * Update src/locales/pt_BR/settings.ts Co-authored-by: José Ricardo Fleury Oliveira <josefleury@discente.ufg.br> * Update src/locales/zh_CN/settings.ts Co-authored-by: mercurius-00 <80205689+mercurius-00@users.noreply.github.com> * Update src/locales/de/settings.ts Co-authored-by: Jannik Tappert <38758606+CodeTappert@users.noreply.github.com> * Update src/locales/ko/settings.ts Co-authored-by: returntoice <dieandbecome@gmail.com> * Update src/locales/fr/settings.ts Co-authored-by: Lugiad' <adrien.grivel@hotmail.fr> * Update src/locales/it/settings.ts Co-authored-by: Niccolò <123510358+NicusPulcis@users.noreply.github.com> * Include sound effects that were loaded in as BGM. * Removed stray placeholder localization --------- Co-authored-by: Frutescens <info@laptop> Co-authored-by: flx-sta <50131232+flx-sta@users.noreply.github.com> Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> Co-authored-by: Opaque02 <66582645+Opaque02@users.noreply.github.com> Co-authored-by: KimJeongSun <leo@atlaslabs.ai> Co-authored-by: Frederico Santos <frederico.f.santos@tecnico.ulisboa.pt> Co-authored-by: innerthunder <168692175+innerthunder@users.noreply.github.com> Co-authored-by: cam <lrlrliwoo@gmail.com> Co-authored-by: Enoch <enoch.jwsong@gmail.com> Co-authored-by: mercurius-00 <80205689+mercurius-00@users.noreply.github.com> Co-authored-by: José Ricardo Fleury Oliveira <josefleury@discente.ufg.br> Co-authored-by: Jannik Tappert <38758606+CodeTappert@users.noreply.github.com> Co-authored-by: returntoice <dieandbecome@gmail.com> Co-authored-by: Lugiad' <adrien.grivel@hotmail.fr> Co-authored-by: Niccolò <123510358+NicusPulcis@users.noreply.github.com>
2024-08-25 09:40:14 -07:00
this.scene.playSound("se/beam");
2024-01-09 23:34:43 -05:00
this.doArcDownward();
this.scene.time.delayedCall(1500, () => {
this.pokemonEvoTintSprite.setScale(0.25);
this.pokemonEvoTintSprite.setVisible(true);
this.evolutionHandler.canCancel = true;
2024-01-09 23:34:43 -05:00
this.doCycle(1).then(success => {
if (success) {
this.handleSuccessEvolution(evolvedPokemon);
} else {
this.handleFailedEvolution(evolvedPokemon);
2024-01-09 23:34:43 -05:00
}
2023-04-10 13:54:06 -04:00
});
});
2024-01-09 23:34:43 -05:00
});
}
});
2024-01-09 23:34:43 -05:00
}
2023-04-10 13:54:06 -04:00
});
});
2024-01-09 23:34:43 -05:00
});
}, 1000);
2023-04-10 13:54:06 -04:00
}
/**
* Handles a failed/stopped evolution
* @param evolvedPokemon - The evolved Pokemon
*/
private handleFailedEvolution(evolvedPokemon: Pokemon): void {
this.pokemonSprite.setVisible(true);
this.pokemonTintSprite.setScale(1);
this.scene.tweens.add({
targets: [ this.evolutionBg, this.pokemonTintSprite, this.pokemonEvoSprite, this.pokemonEvoTintSprite ],
alpha: 0,
duration: 250,
onComplete: () => {
this.evolutionBg.setVisible(false);
}
});
SoundFade.fadeOut(this.scene, this.evolutionBgm, 100);
this.scene.unshiftPhase(new EndEvolutionPhase(this.scene));
this.scene.ui.showText(i18next.t("menu:stoppedEvolving", { pokemonName: this.preEvolvedPokemonName }), null, () => {
this.scene.ui.showText(i18next.t("menu:pauseEvolutionsQuestion", { pokemonName: this.preEvolvedPokemonName }), null, () => {
const end = () => {
this.scene.ui.showText("", 0);
this.scene.playBgm();
evolvedPokemon.destroy();
this.end();
};
this.scene.ui.setOverlayMode(Mode.CONFIRM, () => {
this.scene.ui.revertMode();
this.pokemon.pauseEvolutions = true;
this.scene.ui.showText(i18next.t("menu:evolutionsPaused", { pokemonName: this.preEvolvedPokemonName }), null, end, 3000);
}, () => {
this.scene.ui.revertMode();
this.scene.time.delayedCall(3000, end);
});
});
}, null, true);
}
/**
* Handles a successful evolution
* @param evolvedPokemon - The evolved Pokemon
*/
private handleSuccessEvolution(evolvedPokemon: Pokemon): void {
this.scene.playSound("se/sparkle");
this.pokemonEvoSprite.setVisible(true);
this.doCircleInward();
const onEvolutionComplete = () => {
SoundFade.fadeOut(this.scene, this.evolutionBgm, 100);
this.scene.time.delayedCall(250, () => {
this.pokemon.cry();
this.scene.time.delayedCall(1250, () => {
this.scene.playSoundWithoutBgm("evolution_fanfare");
evolvedPokemon.destroy();
this.scene.ui.showText(i18next.t("menu:evolutionDone", { pokemonName: this.preEvolvedPokemonName, evolvedPokemonName: this.pokemon.name }), null, () => this.end(), null, true, Utils.fixedInt(4000));
this.scene.time.delayedCall(Utils.fixedInt(4250), () => this.scene.playBgm());
});
});
};
this.scene.time.delayedCall(900, () => {
this.evolutionHandler.canCancel = false;
this.pokemon.evolve(this.evolution, this.pokemon.species).then(() => {
const levelMoves = this.pokemon.getLevelMoves(this.lastLevel + 1, true);
for (const lm of levelMoves) {
this.scene.unshiftPhase(new LearnMovePhase(this.scene, this.scene.getPlayerParty().indexOf(this.pokemon), lm[1]));
}
this.scene.unshiftPhase(new EndEvolutionPhase(this.scene));
this.scene.playSound("se/shine");
this.doSpray();
this.scene.tweens.add({
targets: this.evolutionOverlay,
alpha: 1,
duration: 250,
easing: "Sine.easeIn",
onComplete: () => {
this.evolutionBgOverlay.setAlpha(1);
this.evolutionBg.setVisible(false);
this.scene.tweens.add({
targets: [ this.evolutionOverlay, this.pokemonEvoTintSprite ],
alpha: 0,
duration: 2000,
delay: 150,
easing: "Sine.easeIn",
onComplete: () => {
this.scene.tweens.add({
targets: this.evolutionBgOverlay,
alpha: 0,
duration: 250,
onComplete: onEvolutionComplete
});
}
});
}
});
});
});
}
2023-04-10 13:54:06 -04:00
doSpiralUpward() {
let f = 0;
2024-05-24 01:45:04 +02:00
2023-04-10 13:54:06 -04:00
this.scene.tweens.addCounter({
repeat: 64,
2023-06-04 21:47:43 -04:00
duration: Utils.getFrameMs(1),
2023-04-10 13:54:06 -04:00
onRepeat: () => {
if (f < 64) {
if (!(f & 7)) {
for (let i = 0; i < 4; i++) {
2023-04-10 13:54:06 -04:00
this.doSpiralUpwardParticle((f & 120) * 2 + i * 64);
}
2023-04-10 13:54:06 -04:00
}
f++;
}
}
});
}
doArcDownward() {
let f = 0;
2024-05-24 01:45:04 +02:00
2023-04-10 13:54:06 -04:00
this.scene.tweens.addCounter({
repeat: 96,
2023-06-04 21:47:43 -04:00
duration: Utils.getFrameMs(1),
2023-04-10 13:54:06 -04:00
onRepeat: () => {
if (f < 96) {
if (f < 6) {
for (let i = 0; i < 9; i++) {
2023-04-10 13:54:06 -04:00
this.doArcDownParticle(i * 16);
}
2023-04-10 13:54:06 -04:00
}
f++;
}
}
});
}
2024-01-09 23:34:43 -05:00
doCycle(l: number, lastCycle: integer = 15): Promise<boolean> {
2023-04-10 13:54:06 -04:00
return new Promise(resolve => {
2024-01-09 23:34:43 -05:00
const isLastCycle = l === lastCycle;
2023-04-10 13:54:06 -04:00
this.scene.tweens.add({
targets: this.pokemonTintSprite,
scale: 0.25,
ease: "Cubic.easeInOut",
2023-04-10 13:54:06 -04:00
duration: 500 / l,
yoyo: !isLastCycle
});
this.scene.tweens.add({
targets: this.pokemonEvoTintSprite,
scale: 1,
ease: "Cubic.easeInOut",
2023-04-10 13:54:06 -04:00
duration: 500 / l,
yoyo: !isLastCycle,
onComplete: () => {
if (this.evolutionHandler.cancelled) {
2023-12-14 11:54:56 -05:00
return resolve(false);
}
if (l < lastCycle) {
2024-01-09 23:34:43 -05:00
this.doCycle(l + 0.5, lastCycle).then(success => resolve(success));
} else {
2023-04-10 13:54:06 -04:00
this.pokemonTintSprite.setVisible(false);
2023-12-14 11:54:56 -05:00
resolve(true);
2023-04-10 13:54:06 -04:00
}
}
});
});
}
doCircleInward() {
let f = 0;
2024-05-24 01:45:04 +02:00
2023-04-10 13:54:06 -04:00
this.scene.tweens.addCounter({
repeat: 48,
2023-06-04 21:47:43 -04:00
duration: Utils.getFrameMs(1),
2023-04-10 13:54:06 -04:00
onRepeat: () => {
if (!f) {
for (let i = 0; i < 16; i++) {
2023-04-10 13:54:06 -04:00
this.doCircleInwardParticle(i * 16, 4);
}
2023-04-10 13:54:06 -04:00
} else if (f === 32) {
for (let i = 0; i < 16; i++) {
2023-04-10 13:54:06 -04:00
this.doCircleInwardParticle(i * 16, 8);
}
2023-04-10 13:54:06 -04:00
}
f++;
}
});
}
doSpray() {
let f = 0;
2024-05-24 01:45:04 +02:00
2023-04-10 13:54:06 -04:00
this.scene.tweens.addCounter({
repeat: 48,
2023-06-04 21:47:43 -04:00
duration: Utils.getFrameMs(1),
2023-04-10 13:54:06 -04:00
onRepeat: () => {
if (!f) {
for (let i = 0; i < 8; i++) {
2023-04-10 13:54:06 -04:00
this.doSprayParticle(i);
}
} else if (f < 50) {
2023-04-10 13:54:06 -04:00
this.doSprayParticle(Utils.randInt(8));
}
2023-04-10 13:54:06 -04:00
f++;
}
});
}
doSpiralUpwardParticle(trigIndex: integer) {
const initialX = this.evolutionBaseBg.displayWidth / 2;
const particle = this.scene.add.image(initialX, 0, "evo_sparkle");
2023-04-10 13:54:06 -04:00
this.evolutionContainer.add(particle);
let f = 0;
let amp = 48;
const particleTimer = this.scene.tweens.addCounter({
repeat: -1,
2023-06-04 21:47:43 -04:00
duration: Utils.getFrameMs(1),
2023-04-10 13:54:06 -04:00
onRepeat: () => {
updateParticle();
}
});
const updateParticle = () => {
if (!f || particle.y > 8) {
particle.setPosition(initialX, 88 - (f * f) / 80);
particle.y += sin(trigIndex, amp) / 4;
particle.x += cos(trigIndex, amp);
2023-04-10 13:54:06 -04:00
particle.setScale(1 - (f / 80));
trigIndex += 4;
if (f & 1) {
2023-04-10 13:54:06 -04:00
amp--;
}
2023-04-10 13:54:06 -04:00
f++;
} else {
particle.destroy();
particleTimer.remove();
}
};
updateParticle();
}
doArcDownParticle(trigIndex: integer) {
const initialX = this.evolutionBaseBg.displayWidth / 2;
const particle = this.scene.add.image(initialX, 0, "evo_sparkle");
2023-04-10 13:54:06 -04:00
particle.setScale(0.5);
this.evolutionContainer.add(particle);
let f = 0;
let amp = 8;
const particleTimer = this.scene.tweens.addCounter({
repeat: -1,
2023-06-04 21:47:43 -04:00
duration: Utils.getFrameMs(1),
2023-04-10 13:54:06 -04:00
onRepeat: () => {
updateParticle();
}
});
const updateParticle = () => {
if (!f || particle.y < 88) {
particle.setPosition(initialX, 8 + (f * f) / 5);
particle.y += sin(trigIndex, amp) / 4;
particle.x += cos(trigIndex, amp);
amp = 8 + sin(f * 4, 40);
2023-04-10 13:54:06 -04:00
f++;
} else {
particle.destroy();
particleTimer.remove();
}
};
updateParticle();
}
doCircleInwardParticle(trigIndex: integer, speed: integer) {
const initialX = this.evolutionBaseBg.displayWidth / 2;
const initialY = this.evolutionBaseBg.displayHeight / 2;
const particle = this.scene.add.image(initialX, initialY, "evo_sparkle");
2023-04-10 13:54:06 -04:00
this.evolutionContainer.add(particle);
let amp = 120;
const particleTimer = this.scene.tweens.addCounter({
repeat: -1,
2023-06-04 21:47:43 -04:00
duration: Utils.getFrameMs(1),
2023-04-10 13:54:06 -04:00
onRepeat: () => {
updateParticle();
}
});
const updateParticle = () => {
if (amp > 8) {
particle.setPosition(initialX, initialY);
particle.y += sin(trigIndex, amp);
particle.x += cos(trigIndex, amp);
2023-04-10 13:54:06 -04:00
amp -= speed;
trigIndex += 4;
} else {
particle.destroy();
particleTimer.remove();
}
};
updateParticle();
}
doSprayParticle(trigIndex: integer) {
const initialX = this.evolutionBaseBg.displayWidth / 2;
const initialY = this.evolutionBaseBg.displayHeight / 2;
const particle = this.scene.add.image(initialX, initialY, "evo_sparkle");
2023-04-10 13:54:06 -04:00
this.evolutionContainer.add(particle);
let f = 0;
let yOffset = 0;
const speed = 3 - Utils.randInt(8);
const amp = 48 + Utils.randInt(64);
2023-04-10 13:54:06 -04:00
const particleTimer = this.scene.tweens.addCounter({
repeat: -1,
2023-06-04 21:47:43 -04:00
duration: Utils.getFrameMs(1),
2023-04-10 13:54:06 -04:00
onRepeat: () => {
updateParticle();
}
});
const updateParticle = () => {
if (!(f & 3)) {
2023-04-10 13:54:06 -04:00
yOffset++;
}
2023-04-10 13:54:06 -04:00
if (trigIndex < 128) {
particle.setPosition(initialX + (speed * f) / 3, initialY + yOffset);
particle.y += -sin(trigIndex, amp);
if (f > 108) {
2023-04-10 13:54:06 -04:00
particle.setScale((1 - (f - 108) / 20));
}
2023-04-10 13:54:06 -04:00
trigIndex++;
f++;
} else {
particle.destroy();
particleTimer.remove();
}
};
updateParticle();
}
}