pokerogue/src/phases/end-card-phase.ts
Sirz Benjie 1b8082a177
[Refactor] Refactor UI text ts (#5946)
* Add destroy method to pokemon-sprite-sparkle-handler

* Move TextStyle to enums, convert into const object

* Cleanup text.ts file

* Add necessary explicit types for TextStyle let vars

* Fix locales submodule commit

* Fix merge issue

---------

Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
2025-07-27 17:46:56 +00:00

53 lines
1.4 KiB
TypeScript

import { globalScene } from "#app/global-scene";
import { Phase } from "#app/phase";
import { PlayerGender } from "#enums/player-gender";
import { TextStyle } from "#enums/text-style";
import { addTextObject } from "#ui/text";
import i18next from "i18next";
export class EndCardPhase extends Phase {
public readonly phaseName = "EndCardPhase";
public endCard: Phaser.GameObjects.Image;
public text: Phaser.GameObjects.Text;
start(): void {
super.start();
globalScene.ui.getMessageHandler().bg.setVisible(false);
globalScene.ui.getMessageHandler().nameBoxContainer.setVisible(false);
this.endCard = globalScene.add.image(
0,
0,
`end_${globalScene.gameData.gender === PlayerGender.FEMALE ? "f" : "m"}`,
);
this.endCard.setOrigin(0);
this.endCard.setScale(0.5);
globalScene.field.add(this.endCard);
this.text = addTextObject(
globalScene.game.canvas.width / 12,
globalScene.game.canvas.height / 6 - 16,
i18next.t("battle:congratulations"),
TextStyle.SUMMARY,
{ fontSize: "128px" },
);
this.text.setOrigin(0.5);
globalScene.field.add(this.text);
globalScene.ui.clearText();
globalScene.ui.fadeIn(1000).then(() => {
globalScene.ui.showText(
"",
null,
() => {
globalScene.ui.getMessageHandler().bg.setVisible(true);
this.end();
},
null,
true,
);
});
}
}