mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-12-22 09:39:15 +01:00
* Move phase types out of phase interceptor * Create isXPhase method and add properties to each phase * Replace instanceof phase with isXPhase * Fix missing union types for phaseName * Update doc comment in phase.ts * Fix incomplete comment in encounter-phase * Make phaseName as public and fix more uses * Move phaseName property declaration before constructor in move anim phase Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> * Rename isXPhase to is --------- Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
43 lines
1.3 KiB
TypeScript
43 lines
1.3 KiB
TypeScript
import { globalScene } from "#app/global-scene";
|
|
import type { ModifierType, ModifierTypeFunc } from "#app/modifier/modifier-type";
|
|
import { getModifierType } from "#app/modifier/modifier-type";
|
|
import i18next from "i18next";
|
|
import { BattlePhase } from "./battle-phase";
|
|
|
|
export class ModifierRewardPhase extends BattlePhase {
|
|
// RibbonModifierRewardPhase extends ModifierRewardPhase and to make typescript happy
|
|
// we need to use a union type here
|
|
public readonly phaseName: "ModifierRewardPhase" | "RibbonModifierRewardPhase" | "GameOverModifierRewardPhase" =
|
|
"ModifierRewardPhase";
|
|
protected modifierType: ModifierType;
|
|
|
|
constructor(modifierTypeFunc: ModifierTypeFunc) {
|
|
super();
|
|
|
|
this.modifierType = getModifierType(modifierTypeFunc);
|
|
}
|
|
|
|
start() {
|
|
super.start();
|
|
|
|
this.doReward().then(() => this.end());
|
|
}
|
|
|
|
doReward(): Promise<void> {
|
|
return new Promise<void>(resolve => {
|
|
const newModifier = this.modifierType.newModifier();
|
|
globalScene.addModifier(newModifier);
|
|
globalScene.playSound("item_fanfare");
|
|
globalScene.ui.showText(
|
|
i18next.t("battle:rewardGain", {
|
|
modifierName: newModifier?.type.name,
|
|
}),
|
|
null,
|
|
() => resolve(),
|
|
null,
|
|
true,
|
|
);
|
|
});
|
|
}
|
|
}
|