Add evolution pausing and fix visual bug with evolution scene

pull/14/head
Flashfyre 2023-12-14 12:55:11 -05:00
parent fc2665b3f0
commit dad6401f67
6 changed files with 166 additions and 128 deletions

View File

@ -2642,11 +2642,13 @@ export class LevelUpPhase extends PlayerPartyMemberPokemonPhase {
for (let lm of levelMoves) for (let lm of levelMoves)
this.scene.unshiftPhase(new LearnMovePhase(this.scene, this.partyMemberIndex, lm)); this.scene.unshiftPhase(new LearnMovePhase(this.scene, this.partyMemberIndex, lm));
} }
if (!pokemon.pauseEvolutions) {
const evolution = pokemon.getEvolution(); const evolution = pokemon.getEvolution();
if (evolution) if (evolution)
this.scene.unshiftPhase(new EvolutionPhase(this.scene, this.partyMemberIndex, evolution, this.lastLevel)); this.scene.unshiftPhase(new EvolutionPhase(this.scene, this.partyMemberIndex, evolution, this.lastLevel));
} }
} }
}
export class LearnMovePhase extends PlayerPartyMemberPokemonPhase { export class LearnMovePhase extends PlayerPartyMemberPokemonPhase {
private moveId: Moves; private moveId: Moves;

View File

@ -95,9 +95,10 @@ export class EvolutionPhase extends BattlePhase {
this.scene.ui.showText(`What?\n${preName} is evolving!`, null, () => { this.scene.ui.showText(`What?\n${preName} is evolving!`, null, () => {
pokemon.cry(); pokemon.cry();
const evolvedPokemon = pokemon.getPossibleEvolution(this.evolution); pokemon.getPossibleEvolution(this.evolution).then(evolvedPokemon => {
[ this.pokemonEvoSprite, this.pokemonEvoTintSprite ].map(sprite => { [ this.pokemonEvoSprite, this.pokemonEvoTintSprite ].map(sprite => {
console.log(evolvedPokemon.getSpriteKey(true))
sprite.play(evolvedPokemon.getSpriteKey(true)); sprite.play(evolvedPokemon.getSpriteKey(true));
[ 'spriteColors', 'fusionSpriteColors' ].map(k => { [ 'spriteColors', 'fusionSpriteColors' ].map(k => {
if (evolvedPokemon.summonData?.speciesForm) if (evolvedPokemon.summonData?.speciesForm)
@ -161,10 +162,23 @@ export class EvolutionPhase extends BattlePhase {
this.scene.unshiftPhase(new EndEvolutionPhase(this.scene)); this.scene.unshiftPhase(new EndEvolutionPhase(this.scene));
this.scene.ui.showText(`${preName} stopped evolving.`, null, () => { this.scene.ui.showText(`${preName} stopped evolving.`, null, () => {
this.scene.ui.showText(`Would you like to pause evolutions for ${preName}?\nEvolutions can be re-enabled from the party screen.`, null, () => {
const end = () => {
this.scene.ui.showText(null, 0);
this.scene.playBgm(); this.scene.playBgm();
evolvedPokemon.destroy(); evolvedPokemon.destroy();
this.end(); this.end();
}, null, true, 3000); };
this.scene.ui.setOverlayMode(Mode.CONFIRM, () => {
this.scene.ui.revertMode();
pokemon.pauseEvolutions = true;
this.scene.ui.showText(`Evolutions have been paused for ${preName}.`, null, end, 3000);
}, () => {
this.scene.ui.revertMode();
this.scene.time.delayedCall(3000, end);
});
});
}, null, true);
return; return;
} }
@ -231,6 +245,7 @@ export class EvolutionPhase extends BattlePhase {
} }
}); });
}); });
});
}, 1000); }, 1000);
}); });
} }

View File

@ -515,7 +515,7 @@ class EvolutionItemModifierTypeGenerator extends ModifierTypeGenerator {
if (pregenArgs) if (pregenArgs)
return new EvolutionItemModifierType(pregenArgs[0] as EvolutionItem); return new EvolutionItemModifierType(pregenArgs[0] as EvolutionItem);
const evolutionItemPool = party.filter(p => pokemonEvolutions.hasOwnProperty(p.species.speciesId)).map(p => { const evolutionItemPool = party.filter(p => !p.pauseEvolutions && pokemonEvolutions.hasOwnProperty(p.species.speciesId)).map(p => {
const evolutions = pokemonEvolutions[p.species.speciesId]; const evolutions = pokemonEvolutions[p.species.speciesId];
return evolutions.filter(e => e.item !== EvolutionItem.NONE && (e.evoFormKey === null || (e.preFormKey || '') === p.getFormKey()) && (!e.condition || e.condition.predicate(p))); return evolutions.filter(e => e.item !== EvolutionItem.NONE && (e.evoFormKey === null || (e.preFormKey || '') === p.getFormKey()) && (!e.condition || e.condition.predicate(p)));
}).flat().filter(e => (e.item >= 100) === mega).flatMap(e => e.item); }).flat().filter(e => (e.item >= 100) === mega).flatMap(e => e.item);

View File

@ -65,6 +65,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
public moveset: PokemonMove[]; public moveset: PokemonMove[];
public status: Status; public status: Status;
public winCount: integer; public winCount: integer;
public pauseEvolutions: boolean;
public pokerus: boolean; public pokerus: boolean;
public fusionSpecies: PokemonSpecies; public fusionSpecies: PokemonSpecies;
@ -120,6 +121,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
this.moveset = dataSource.moveset; this.moveset = dataSource.moveset;
this.status = dataSource.status; this.status = dataSource.status;
this.winCount = dataSource.winCount; this.winCount = dataSource.winCount;
this.pauseEvolutions = dataSource.pauseEvolutions;
this.pokerus = !!dataSource.pokerus; this.pokerus = !!dataSource.pokerus;
this.fusionSpecies = dataSource.fusionSpecies instanceof PokemonSpecies ? dataSource.fusionSpecies : getPokemonSpecies(dataSource.fusionSpecies); this.fusionSpecies = dataSource.fusionSpecies instanceof PokemonSpecies ? dataSource.fusionSpecies : getPokemonSpecies(dataSource.fusionSpecies);
this.fusionFormIndex = dataSource.fusionFormIndex; this.fusionFormIndex = dataSource.fusionFormIndex;
@ -1716,14 +1718,18 @@ export class PlayerPokemon extends Pokemon {
}); });
} }
getPossibleEvolution(evolution: SpeciesEvolution): Pokemon { getPossibleEvolution(evolution: SpeciesEvolution): Promise<Pokemon> {
return new Promise(resolve => {
const species = getPokemonSpecies(evolution.speciesId); const species = getPokemonSpecies(evolution.speciesId);
const formIndex = Math.max(this.species.forms.findIndex(f => f.formKey === evolution.evoFormKey), 0); const formIndex = Math.max(this.species.forms.findIndex(f => f.formKey === evolution.evoFormKey), 0);
return new PlayerPokemon(this.scene, species, this.level, this.abilityIndex, formIndex, this.gender, this.shiny, this.ivs, this); const ret = new PlayerPokemon(this.scene, species, this.level, this.abilityIndex, formIndex, this.gender, this.shiny, this.ivs, this);
ret.loadAssets().then(() => resolve(ret));
});
} }
evolve(evolution: SpeciesEvolution): Promise<void> { evolve(evolution: SpeciesEvolution): Promise<void> {
return new Promise(resolve => { return new Promise(resolve => {
this.pauseEvolutions = false;
this.handleSpecialEvolutions(evolution); this.handleSpecialEvolutions(evolution);
this.species = getPokemonSpecies(evolution.speciesId); this.species = getPokemonSpecies(evolution.speciesId);
if (evolution.preFormKey !== null) if (evolution.preFormKey !== null)

View File

@ -25,6 +25,7 @@ export default class PokemonData {
public moveset: PokemonMove[]; public moveset: PokemonMove[];
public status: Status; public status: Status;
public winCount: integer; public winCount: integer;
public pauseEvolutions: boolean;
public pokerus: boolean; public pokerus: boolean;
public fusionSpecies: Species; public fusionSpecies: Species;
@ -52,6 +53,7 @@ export default class PokemonData {
this.stats = source.stats; this.stats = source.stats;
this.ivs = source.ivs; this.ivs = source.ivs;
this.winCount = source.winCount; this.winCount = source.winCount;
this.pauseEvolutions = !!source.pauseEvolutions;
this.pokerus = !!source.pokerus; this.pokerus = !!source.pokerus;
this.fusionSpecies = sourcePokemon ? sourcePokemon.fusionSpecies?.speciesId : source.fusionSpecies; this.fusionSpecies = sourcePokemon ? sourcePokemon.fusionSpecies?.speciesId : source.fusionSpecies;

View File

@ -11,6 +11,7 @@ import { Moves, allMoves } from "../data/move";
import { getGenderColor, getGenderSymbol } from "../data/gender"; import { getGenderColor, getGenderSymbol } from "../data/gender";
import { StatusEffect } from "../data/status-effect"; import { StatusEffect } from "../data/status-effect";
import PokemonIconAnimHandler, { PokemonIconAnimMode } from "./pokemon-icon-anim-handler"; import PokemonIconAnimHandler, { PokemonIconAnimMode } from "./pokemon-icon-anim-handler";
import { pokemonEvolutions } from "../data/pokemon-evolutions";
const defaultMessage = 'Choose a Pokémon.'; const defaultMessage = 'Choose a Pokémon.';
@ -36,6 +37,7 @@ export enum PartyOption {
TRANSFER, TRANSFER,
SPLICE, SPLICE,
SUMMARY, SUMMARY,
UNPAUSE_EVO,
RELEASE, RELEASE,
SCROLL_UP = 1000, SCROLL_UP = 1000,
SCROLL_DOWN = 1001, SCROLL_DOWN = 1001,
@ -223,7 +225,7 @@ export default class PartyUiHandler extends MessageUiHandler {
} }
ui.playSelect(); ui.playSelect();
return true; return true;
} else if ((option !== PartyOption.SUMMARY && option !== PartyOption.RELEASE && option !== PartyOption.CANCEL) } else if ((option !== PartyOption.SUMMARY && option !== PartyOption.UNPAUSE_EVO && option !== PartyOption.RELEASE && option !== PartyOption.CANCEL)
|| (option === PartyOption.RELEASE && this.partyUiMode === PartyUiMode.RELEASE)) { || (option === PartyOption.RELEASE && this.partyUiMode === PartyUiMode.RELEASE)) {
let filterResult: string; let filterResult: string;
if (option !== PartyOption.TRANSFER && option !== PartyOption.SPLICE) { if (option !== PartyOption.TRANSFER && option !== PartyOption.SPLICE) {
@ -270,6 +272,11 @@ export default class PartyUiHandler extends MessageUiHandler {
ui.playSelect(); ui.playSelect();
ui.setModeWithoutClear(Mode.SUMMARY, pokemon).then(() => this.clearOptions()); ui.setModeWithoutClear(Mode.SUMMARY, pokemon).then(() => this.clearOptions());
return true; return true;
} else if (option === PartyOption.UNPAUSE_EVO) {
this.clearOptions();
ui.playSelect();
pokemon.pauseEvolutions = false;
this.showText(`Evolutions have been unpaused for ${pokemon.name}.`, null, () => this.showText(null, 0), null, true);
} else if (option === PartyOption.RELEASE) { } else if (option === PartyOption.RELEASE) {
this.clearOptions(); this.clearOptions();
ui.playSelect(); ui.playSelect();
@ -538,6 +545,9 @@ export default class PartyUiHandler extends MessageUiHandler {
this.options.push(PartyOption.SUMMARY); this.options.push(PartyOption.SUMMARY);
if (pokemon.pauseEvolutions && pokemonEvolutions.hasOwnProperty(pokemon.species.speciesId))
this.options.push(PartyOption.UNPAUSE_EVO);
if (this.partyUiMode === PartyUiMode.SWITCH) if (this.partyUiMode === PartyUiMode.SWITCH)
this.options.push(PartyOption.RELEASE); this.options.push(PartyOption.RELEASE);
} else if (this.partyUiMode === PartyUiMode.MOVE_MODIFIER) { } else if (this.partyUiMode === PartyUiMode.MOVE_MODIFIER) {
@ -589,6 +599,9 @@ export default class PartyUiHandler extends MessageUiHandler {
case PartyOption.MOVE_4: case PartyOption.MOVE_4:
optionName = pokemon.moveset[option - PartyOption.MOVE_1].getName(); optionName = pokemon.moveset[option - PartyOption.MOVE_1].getName();
break; break;
case PartyOption.UNPAUSE_EVO:
optionName = 'Unpause Evo.';
break;
default: default:
optionName = Utils.toReadableString(PartyOption[option]); optionName = Utils.toReadableString(PartyOption[option]);
break; break;