Added ModifierSelectCallback type

This commit is contained in:
Wlowscha 2025-06-08 18:22:28 +02:00
parent 315e48e901
commit 1d35c60c14
No known key found for this signature in database
GPG Key ID: 3C8F1AD330565D04

View File

@ -31,6 +31,8 @@ import Overrides from "#app/overrides";
import type { CustomModifierSettings } from "#app/modifier/modifier-type";
import { isNullOrUndefined, NumberHolder } from "#app/utils/common";
export type ModifierSelectCallback = (rowCursor: number, cursor: number) => boolean;
export class SelectModifierPhase extends BattlePhase {
public readonly phaseName = "SelectModifierPhase";
private rerollCount: number;
@ -124,7 +126,7 @@ export class SelectModifierPhase extends BattlePhase {
}
// Pick a modifier from among the rewards and apply it
private selectRewardModifierOption(cursor: number, modifierSelectCallback): boolean {
private selectRewardModifierOption(cursor: number, modifierSelectCallback: ModifierSelectCallback): boolean {
if (this.typeOptions.length === 0) {
globalScene.ui.clearText();
globalScene.ui.setMode(UiMode.MESSAGE);
@ -136,7 +138,11 @@ export class SelectModifierPhase extends BattlePhase {
}
// Pick a modifier from the shop and apply it
private selectShopModifierOption(rowCursor: number, cursor: number, modifierSelectCallback): boolean {
private selectShopModifierOption(
rowCursor: number,
cursor: number,
modifierSelectCallback: ModifierSelectCallback,
): boolean {
const shopOptions = getPlayerShopModifierTypeOptionsForWave(
globalScene.currentBattle.waveIndex,
globalScene.getWaveMoneyAmount(1),
@ -160,7 +166,11 @@ export class SelectModifierPhase extends BattlePhase {
}
// Apply a chosen modifier: do an effect or open the party menu
private applyChosenModifier(modifierType: ModifierType, cost: number, modifierSelectCallback): boolean {
private applyChosenModifier(
modifierType: ModifierType,
cost: number,
modifierSelectCallback: ModifierSelectCallback,
): boolean {
if (modifierType instanceof PokemonModifierType) {
if (modifierType instanceof FusePokemonModifierType) {
this.openFusionMenu(modifierType, cost, modifierSelectCallback);
@ -198,7 +208,7 @@ export class SelectModifierPhase extends BattlePhase {
}
// Transfer modifiers among party pokemon
private openModifierTransferScreen(modifierSelectCallback) {
private openModifierTransferScreen(modifierSelectCallback: ModifierSelectCallback) {
const party = globalScene.getPlayerParty();
globalScene.ui.setModeWithoutClear(
UiMode.PARTY,
@ -280,7 +290,11 @@ export class SelectModifierPhase extends BattlePhase {
}
// Opens the party menu specifically for fusions
private openFusionMenu(modifierType: PokemonModifierType, cost: number, modifierSelectCallback): void {
private openFusionMenu(
modifierType: PokemonModifierType,
cost: number,
modifierSelectCallback: ModifierSelectCallback,
): void {
const party = globalScene.getPlayerParty();
globalScene.ui.setModeWithoutClear(
UiMode.PARTY,
@ -306,7 +320,11 @@ export class SelectModifierPhase extends BattlePhase {
}
// Opens the party menu to apply one of various modifiers
private openModifierMenu(modifierType: PokemonModifierType, cost: number, modifierSelectCallback): void {
private openModifierMenu(
modifierType: PokemonModifierType,
cost: number,
modifierSelectCallback: ModifierSelectCallback,
): void {
const party = globalScene.getPlayerParty();
const pokemonModifierType = modifierType as PokemonModifierType;
const isMoveModifier = modifierType instanceof PokemonMoveModifierType;
@ -374,7 +392,7 @@ export class SelectModifierPhase extends BattlePhase {
// Function that resets the reward selection screen,
// e.g. after pressing cancel in the party ui or while learning a move
private resetModifierSelect(modifierSelectCallback) {
private resetModifierSelect(modifierSelectCallback: ModifierSelectCallback) {
globalScene.ui.setMode(
UiMode.MODIFIER_SELECT,
this.isPlayer(),