mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-20 23:32:19 +02:00
Move revival blessing function to move.ts
This commit is contained in:
parent
a5c9b29495
commit
210ea5c36a
@ -46,6 +46,10 @@ import { applyChallenges, ChallengeType } from "./challenge";
|
||||
import { SwitchType } from "#enums/switch-type";
|
||||
import { StatusEffect } from "enums/status-effect";
|
||||
import { globalScene } from "#app/global-scene";
|
||||
import { Mode } from "#app/ui/ui";
|
||||
import type { PartyOption } from "#app/ui/party-ui-handler";
|
||||
import PartyUiHandler, { PartyUiMode } from "#app/ui/party-ui-handler";
|
||||
import { ToggleDoublePositionPhase } from "#app/phases/toggle-double-position-phase";
|
||||
|
||||
export enum MoveCategory {
|
||||
PHYSICAL,
|
||||
@ -5927,11 +5931,40 @@ export class RevivalBlessingAttr extends MoveEffectAttr {
|
||||
* @returns Promise, true if function succeeds.
|
||||
*/
|
||||
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): Promise<boolean> {
|
||||
const revivePlayer = (): Promise<void> => {
|
||||
return new Promise(resolve => {
|
||||
globalScene.ui.setMode(Mode.PARTY, PartyUiMode.REVIVAL_BLESSING, user.getFieldIndex(), (slotIndex:integer, option: PartyOption) => {
|
||||
if (slotIndex >= 0 && slotIndex < 6) {
|
||||
const pokemon = globalScene.getPlayerParty()[slotIndex];
|
||||
if (!pokemon || !pokemon.isFainted()) {
|
||||
resolve();
|
||||
}
|
||||
|
||||
pokemon.resetTurnData();
|
||||
pokemon.resetStatus();
|
||||
pokemon.heal(Math.min(Utils.toDmgValue(0.5 * pokemon.getMaxHp()), pokemon.getMaxHp()));
|
||||
globalScene.queueMessage(i18next.t("moveTriggers:revivalBlessing", { pokemonName: pokemon.name }), 0, true);
|
||||
|
||||
if (globalScene.currentBattle.double && globalScene.getPlayerParty().length > 1) {
|
||||
const allyPokemon = user.getAlly();
|
||||
if (allyPokemon.isFainted() || allyPokemon === pokemon) {
|
||||
globalScene.findPhase((phase: MovePhase) => phase.pokemon === pokemon)?.cancel();
|
||||
globalScene.unshiftPhase(new SwitchSummonPhase(SwitchType.SWITCH, allyPokemon.getFieldIndex(), slotIndex, false, true));
|
||||
globalScene.unshiftPhase(new ToggleDoublePositionPhase(true));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
globalScene.ui.setMode(Mode.MESSAGE).then(() => resolve());
|
||||
}, PartyUiHandler.FilterFainted);
|
||||
});
|
||||
};
|
||||
|
||||
return new Promise(resolve => {
|
||||
// If user is player, checks if the user has fainted pokemon
|
||||
if (user instanceof PlayerPokemon
|
||||
&& globalScene.getPlayerParty().findIndex(p => p.isFainted()) > -1) {
|
||||
(user as PlayerPokemon).revivalBlessing().then(() => {
|
||||
revivePlayer().then(() => {
|
||||
resolve(true);
|
||||
});
|
||||
// If user is enemy, checks that it is a trainer, and it has fainted non-boss pokemon in party
|
||||
|
@ -72,7 +72,6 @@ import { MoveEndPhase } from "#app/phases/move-end-phase";
|
||||
import { ObtainStatusEffectPhase } from "#app/phases/obtain-status-effect-phase";
|
||||
import { StatStageChangePhase } from "#app/phases/stat-stage-change-phase";
|
||||
import { SwitchSummonPhase } from "#app/phases/switch-summon-phase";
|
||||
import { ToggleDoublePositionPhase } from "#app/phases/toggle-double-position-phase";
|
||||
import { Challenges } from "#enums/challenges";
|
||||
import { PokemonAnimType } from "#enums/pokemon-anim-type";
|
||||
import { PLAYER_PARTY_MAX_SIZE } from "#app/constants";
|
||||
@ -83,7 +82,6 @@ import { BASE_HIDDEN_ABILITY_CHANCE, BASE_SHINY_CHANCE, SHINY_EPIC_CHANCE, SHINY
|
||||
import { Nature } from "#enums/nature";
|
||||
import { StatusEffect } from "#enums/status-effect";
|
||||
import { doShinySparkleAnim } from "#app/field/anims";
|
||||
import type { MovePhase } from "#app/phases/move-phase";
|
||||
|
||||
export enum LearnMoveSituation {
|
||||
MISC,
|
||||
@ -4346,39 +4344,6 @@ export class PlayerPokemon extends Pokemon {
|
||||
this.friendship = Math.max(this.friendship + friendship, 0);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Handles Revival Blessing when used by player.
|
||||
* @returns Promise to revive a pokemon.
|
||||
* @see {@linkcode RevivalBlessingAttr}
|
||||
*/
|
||||
revivalBlessing(): Promise<void> {
|
||||
return new Promise(resolve => {
|
||||
globalScene.ui.setMode(Mode.PARTY, PartyUiMode.REVIVAL_BLESSING, this.getFieldIndex(), (slotIndex:integer, option: PartyOption) => {
|
||||
if (slotIndex >= 0 && slotIndex < 6) {
|
||||
const pokemon = globalScene.getPlayerParty()[slotIndex];
|
||||
if (!pokemon || !pokemon.isFainted()) {
|
||||
resolve();
|
||||
}
|
||||
|
||||
pokemon.resetTurnData();
|
||||
pokemon.resetStatus();
|
||||
pokemon.heal(Math.min(Utils.toDmgValue(0.5 * pokemon.getMaxHp()), pokemon.getMaxHp()));
|
||||
globalScene.queueMessage(i18next.t("moveTriggers:revivalBlessing", { pokemonName: pokemon.name }), 0, true);
|
||||
|
||||
if (globalScene.currentBattle.double && globalScene.getPlayerParty().length > 1) {
|
||||
const allyPokemon = this.getAlly();
|
||||
if (allyPokemon.isFainted() || allyPokemon === pokemon) {
|
||||
globalScene.findPhase((phase: MovePhase) => phase.pokemon === pokemon)?.cancel();
|
||||
globalScene.unshiftPhase(new SwitchSummonPhase(SwitchType.SWITCH, allyPokemon.getFieldIndex(), slotIndex, false, true));
|
||||
globalScene.unshiftPhase(new ToggleDoublePositionPhase(true));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
globalScene.ui.setMode(Mode.MESSAGE).then(() => resolve());
|
||||
}, PartyUiHandler.FilterFainted);
|
||||
});
|
||||
}
|
||||
|
||||
getPossibleEvolution(evolution: SpeciesFormEvolution | null): Promise<Pokemon> {
|
||||
if (!evolution) {
|
||||
|
Loading…
Reference in New Issue
Block a user