mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-10-20 20:15:50 +02:00
* Implement Shed Tail * Fix leftover batonPass reference in docs * Fix ChillyReceptionAttr * oops * Remove unneeded default arg in ReturnPhase * Fix imports per Kev's suggestions Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> * Docs and Shed Tail on-add message * Remove mixin attribute * Update battler-tags.json * Update battler-tags.json * Update battler-tags.json * Update battler-tags.json * Update battler-tags.json * Update battler-tags.json * Update battler-tags.json * Update battler-tags.json * Update battler-tags.json * Update battler-tags.json * Fix indents * More nit fixes * Make Switch[Summon]Phase params readonly --------- Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> Co-authored-by: Lugiad <adrien.grivel@hotmail.fr> Co-authored-by: flx-sta <50131232+flx-sta@users.noreply.github.com>
63 lines
2.0 KiB
TypeScript
63 lines
2.0 KiB
TypeScript
import BattleScene from "#app/battle-scene";
|
|
import { BattleStyle } from "#app/enums/battle-style";
|
|
import { BattlerTagType } from "#app/enums/battler-tag-type";
|
|
import { getPokemonNameWithAffix } from "#app/messages";
|
|
import { Mode } from "#app/ui/ui";
|
|
import i18next from "i18next";
|
|
import { BattlePhase } from "./battle-phase";
|
|
import { PostSummonPhase } from "./post-summon-phase";
|
|
import { SummonMissingPhase } from "./summon-missing-phase";
|
|
import { SwitchPhase } from "./switch-phase";
|
|
import { SwitchType } from "#enums/switch-type";
|
|
|
|
export class CheckSwitchPhase extends BattlePhase {
|
|
protected fieldIndex: integer;
|
|
protected useName: boolean;
|
|
|
|
constructor(scene: BattleScene, fieldIndex: integer, useName: boolean) {
|
|
super(scene);
|
|
|
|
this.fieldIndex = fieldIndex;
|
|
this.useName = useName;
|
|
}
|
|
|
|
start() {
|
|
super.start();
|
|
|
|
const pokemon = this.scene.getPlayerField()[this.fieldIndex];
|
|
|
|
if (this.scene.battleStyle === BattleStyle.SET) {
|
|
super.end();
|
|
return;
|
|
}
|
|
|
|
if (this.scene.field.getAll().indexOf(pokemon) === -1) {
|
|
this.scene.unshiftPhase(new SummonMissingPhase(this.scene, this.fieldIndex));
|
|
super.end();
|
|
return;
|
|
}
|
|
|
|
if (!this.scene.getParty().slice(1).filter(p => p.isActive()).length) {
|
|
super.end();
|
|
return;
|
|
}
|
|
|
|
if (pokemon.getTag(BattlerTagType.FRENZY)) {
|
|
super.end();
|
|
return;
|
|
}
|
|
|
|
this.scene.ui.showText(i18next.t("battle:switchQuestion", { pokemonName: this.useName ? getPokemonNameWithAffix(pokemon) : i18next.t("battle:pokemon") }), null, () => {
|
|
this.scene.ui.setMode(Mode.CONFIRM, () => {
|
|
this.scene.ui.setMode(Mode.MESSAGE);
|
|
this.scene.tryRemovePhase(p => p instanceof PostSummonPhase && p.player && p.fieldIndex === this.fieldIndex);
|
|
this.scene.unshiftPhase(new SwitchPhase(this.scene, SwitchType.SWITCH, this.fieldIndex, false, true));
|
|
this.end();
|
|
}, () => {
|
|
this.scene.ui.setMode(Mode.MESSAGE);
|
|
this.end();
|
|
});
|
|
});
|
|
}
|
|
}
|