Remove leftover unused functions from merge; transfer/discard button

This commit is contained in:
Wlowscha 2025-08-08 01:27:52 +02:00
parent c6b4f273d0
commit f5d08567c9
No known key found for this signature in database
GPG Key ID: 3C8F1AD330565D04
2 changed files with 19 additions and 98 deletions

View File

@ -65,7 +65,7 @@ import { PlayerGender } from "#enums/player-gender";
import { PokeballType } from "#enums/pokeball"; import { PokeballType } from "#enums/pokeball";
import type { PokemonAnimType } from "#enums/pokemon-anim-type"; import type { PokemonAnimType } from "#enums/pokemon-anim-type";
import { PokemonType } from "#enums/pokemon-type"; import { PokemonType } from "#enums/pokemon-type";
import { HeldItemPoolType, RewardPoolType } from "#enums/reward-pool-type"; import { HeldItemPoolType } from "#enums/reward-pool-type";
import { ShopCursorTarget } from "#enums/shop-cursor-target"; import { ShopCursorTarget } from "#enums/shop-cursor-target";
import { SpeciesId } from "#enums/species-id"; import { SpeciesId } from "#enums/species-id";
import { StatusEffect } from "#enums/status-effect"; import { StatusEffect } from "#enums/status-effect";
@ -87,7 +87,6 @@ import { type ApplyTrainerItemsParams, applyTrainerItems } from "#items/apply-tr
import type { HeldItemConfiguration } from "#items/held-item-data-types"; import type { HeldItemConfiguration } from "#items/held-item-data-types";
import { assignEnemyHeldItemsForWave, assignItemsFromConfiguration } from "#items/held-item-pool"; import { assignEnemyHeldItemsForWave, assignItemsFromConfiguration } from "#items/held-item-pool";
import type { MatchExact, Reward } from "#items/reward"; import type { MatchExact, Reward } from "#items/reward";
import { getRewardPoolForType } from "#items/reward-pool-utils";
import { type EnemyAttackStatusEffectChanceTrainerItem, TrainerItemEffect } from "#items/trainer-item"; import { type EnemyAttackStatusEffectChanceTrainerItem, TrainerItemEffect } from "#items/trainer-item";
import { import {
isTrainerItemPool, isTrainerItemPool,
@ -1234,15 +1233,7 @@ export class BattleScene extends SceneBase {
...allSpecies, ...allSpecies,
...allMoves, ...allMoves,
...allAbilities, ...allAbilities,
...getEnumValues(RewardPoolType) //TODO: do we need to add items and rewards here?
.map(mpt => getRewardPoolForType(mpt))
.flatMap(mp =>
Object.values(mp)
.flat()
.map(mt => mt.reward)
.filter(mt => "localize" in mt)
.map(lpb => lpb as unknown as Localizable),
),
]; ];
for (const item of localizable) { for (const item of localizable) {
item.localize(); item.localize();
@ -2784,74 +2775,6 @@ export class BattleScene extends SceneBase {
}); });
} }
// TODO @Wlowscha: Fix this
/**
* Attempt to discard one or more copies of a held item.
* @param itemModifier - The {@linkcode PokemonHeldItemModifier} being discarded
* @param discardQuantity - The number of copies to remove (up to the amount currently held); default `1`
* @returns Whether the item was successfully discarded.
* Removing fewer items than requested is still considered a success.
*/
tryDiscardHeldItemModifier(itemModifier: PokemonHeldItemModifier, discardQuantity = 1): boolean {
const countTaken = Math.min(discardQuantity, itemModifier.stackCount);
itemModifier.stackCount -= countTaken;
if (itemModifier.stackCount > 0) {
return true;
}
return this.removeModifier(itemModifier);
}
canTransferHeldItemModifier(itemModifier: PokemonHeldItemModifier, target: Pokemon, transferQuantity = 1): boolean {
const mod = itemModifier.clone() as PokemonHeldItemModifier;
const source = mod.pokemonId ? mod.getPokemon() : null;
const cancelled = new BooleanHolder(false);
if (source && source.isPlayer() !== target.isPlayer()) {
applyAbAttrs("BlockItemTheftAbAttr", { pokemon: source, cancelled });
}
if (cancelled.value) {
return false;
}
const matchingModifier = this.findModifier(
m => m instanceof PokemonHeldItemModifier && m.matchType(mod) && m.pokemonId === target.id,
target.isPlayer(),
) as PokemonHeldItemModifier;
if (matchingModifier) {
const maxStackCount = matchingModifier.getMaxStackCount();
if (matchingModifier.stackCount >= maxStackCount) {
return false;
}
const countTaken = Math.min(transferQuantity, mod.stackCount, maxStackCount - matchingModifier.stackCount);
mod.stackCount -= countTaken;
} else {
const countTaken = Math.min(transferQuantity, mod.stackCount);
mod.stackCount -= countTaken;
}
const removeOld = mod.stackCount === 0;
return !removeOld || !source || this.hasModifier(itemModifier, !source.isPlayer());
}
removePartyMemberModifiers(partyMemberIndex: number): Promise<void> {
return new Promise(resolve => {
const pokemonId = this.getPlayerParty()[partyMemberIndex].id;
const modifiersToRemove = this.modifiers.filter(
m => m instanceof PokemonHeldItemModifier && (m as PokemonHeldItemModifier).pokemonId === pokemonId,
);
for (const m of modifiersToRemove) {
this.modifiers.splice(this.modifiers.indexOf(m), 1);
}
this.updateModifiers();
resolve();
});
}
assignTrainerItemsFromSaveData(saveData: TrainerItemSaveData, isPlayer: boolean) { assignTrainerItemsFromSaveData(saveData: TrainerItemSaveData, isPlayer: boolean) {
const manager = isPlayer ? this.trainerItems : this.enemyTrainerItems; const manager = isPlayer ? this.trainerItems : this.enemyTrainerItems;
for (const item of saveData) { for (const item of saveData) {

View File

@ -60,13 +60,13 @@ export enum PartyUiMode {
*/ */
REVIVAL_BLESSING, REVIVAL_BLESSING,
/** /**
* Indicates that the party UI is open to select a mon to apply a modifier to. * Indicates that the party UI is open to select a mon to apply a reward to.
* This type of selection can be cancelled. * This type of selection can be cancelled.
*/ */
REWARD, REWARD,
/** /**
* Indicates that the party UI is open to select a mon to apply a move * Indicates that the party UI is open to select a mon to apply a move
* modifier to (such as an Ether or PP Up). This type of selection can be cancelled. * reward to (such as an Ether or PP Up). This type of selection can be cancelled.
*/ */
MOVE_REWARD, MOVE_REWARD,
/** /**
@ -368,7 +368,7 @@ export class PartyUiHandler extends MessageUiHandler {
this.populatePartySlots(); this.populatePartySlots();
// If we are currently transferring items, set the icon to its proper state and reveal the button. // If we are currently transferring items, set the icon to its proper state and reveal the button.
if (this.isItemManageMode()) { if (this.isItemManageMode()) {
this.partyDiscardModeButton.toggleIcon(this.partyUiMode as PartyUiMode.MODIFIER_TRANSFER | PartyUiMode.DISCARD); this.partyDiscardModeButton.toggleIcon(this.partyUiMode as PartyUiMode.ITEM_TRANSFER | PartyUiMode.DISCARD);
} }
this.showPartyText(); this.showPartyText();
this.setCursor(0); this.setCursor(0);
@ -552,7 +552,6 @@ export class PartyUiHandler extends MessageUiHandler {
return true; return true;
} }
// TODO: This will be largely changed with the modifier rework
private processItemTransferModeInput(pokemon: PlayerPokemon) { private processItemTransferModeInput(pokemon: PlayerPokemon) {
const ui = this.getUi(); const ui = this.getUi();
const option = this.options[this.optionsCursor]; const option = this.options[this.optionsCursor];
@ -570,7 +569,6 @@ export class PartyUiHandler extends MessageUiHandler {
// this for look goes through each of the party pokemon // this for look goes through each of the party pokemon
const newPokemon = globalScene.getPlayerParty()[p]; const newPokemon = globalScene.getPlayerParty()[p];
// this next bit checks to see if the the selected item from the original transfer pokemon exists on the new pokemon `p` // this next bit checks to see if the the selected item from the original transfer pokemon exists on the new pokemon `p`
// this returns `undefined` if the new pokemon doesn't have the item at all, otherwise it returns the `pokemonHeldItemModifier` for that item
const transferItem = pokemon.heldItemManager.getTransferableHeldItems()[this.transferOptionCursor]; const transferItem = pokemon.heldItemManager.getTransferableHeldItems()[this.transferOptionCursor];
const matchingItem = newPokemon.heldItemManager.hasItem(transferItem); const matchingItem = newPokemon.heldItemManager.hasItem(transferItem);
@ -578,7 +576,7 @@ export class PartyUiHandler extends MessageUiHandler {
if (p !== this.transferCursor) { if (p !== this.transferCursor) {
// this skips adding the able/not able labels on the pokemon doing the transfer // this skips adding the able/not able labels on the pokemon doing the transfer
if (matchingItem) { if (matchingItem) {
// if matchingModifier exists then the item exists on the new pokemon // if matchingItem exists then the item exists on the new pokemon
if (newPokemon.heldItemManager.isMaxStack(transferItem)) { if (newPokemon.heldItemManager.isMaxStack(transferItem)) {
// checks to see if the stack of items is at max stack; if so, set the description label to "Not able" // checks to see if the stack of items is at max stack; if so, set the description label to "Not able"
ableToTransferText = i18next.t("partyUiHandler:notAble"); ableToTransferText = i18next.t("partyUiHandler:notAble");
@ -587,7 +585,7 @@ export class PartyUiHandler extends MessageUiHandler {
ableToTransferText = i18next.t("partyUiHandler:able"); ableToTransferText = i18next.t("partyUiHandler:able");
} }
} else { } else {
// if matchingModifier doesn't exist, that means the pokemon doesn't have any of the item, and we need to show "Able" // if matchingItem doesn't exist, that means the pokemon doesn't have any of the item, and we need to show "Able"
ableToTransferText = i18next.t("partyUiHandler:able"); ableToTransferText = i18next.t("partyUiHandler:able");
} }
} else { } else {
@ -682,17 +680,17 @@ export class PartyUiHandler extends MessageUiHandler {
} }
private doDiscard(option: PartyOption, pokemon: PlayerPokemon) { private doDiscard(option: PartyOption, pokemon: PlayerPokemon) {
const itemModifiers = this.getTransferrableItemsFromPokemon(pokemon); const items = pokemon.heldItemManager.getTransferableHeldItems();
this.clearOptions(); this.clearOptions();
if (option === PartyOption.ALL) { if (option === PartyOption.ALL) {
// Discard all currently held items // Discard all currently held items
for (let i = 0; i < itemModifiers.length; i++) { for (let i = 0; i < items.length; i++) {
globalScene.tryDiscardHeldItemModifier(itemModifiers[i], this.transferQuantities[i]); pokemon.heldItemManager.remove(items[i], this.transferQuantities[i]);
} }
} else { } else {
// Discard the currently selected item // Discard the currently selected item
globalScene.tryDiscardHeldItemModifier(itemModifiers[option], this.transferQuantities[option]); pokemon.heldItemManager.remove(items[option], this.transferQuantities[option]);
} }
} }
@ -981,7 +979,7 @@ export class PartyUiHandler extends MessageUiHandler {
* @returns Whether the current handler is responsible for managing items. * @returns Whether the current handler is responsible for managing items.
*/ */
private isItemManageMode(): boolean { private isItemManageMode(): boolean {
return this.partyUiMode === PartyUiMode.MODIFIER_TRANSFER || this.partyUiMode === PartyUiMode.DISCARD; return this.partyUiMode === PartyUiMode.ITEM_TRANSFER || this.partyUiMode === PartyUiMode.DISCARD;
} }
private processPartyActionInput(): boolean { private processPartyActionInput(): boolean {
@ -1005,9 +1003,9 @@ export class PartyUiHandler extends MessageUiHandler {
if (this.cursor === 7) { if (this.cursor === 7) {
switch (this.partyUiMode) { switch (this.partyUiMode) {
case PartyUiMode.DISCARD: case PartyUiMode.DISCARD:
this.partyUiMode = PartyUiMode.MODIFIER_TRANSFER; this.partyUiMode = PartyUiMode.ITEM_TRANSFER;
break; break;
case PartyUiMode.MODIFIER_TRANSFER: case PartyUiMode.ITEM_TRANSFER:
this.partyUiMode = PartyUiMode.DISCARD; this.partyUiMode = PartyUiMode.DISCARD;
break; break;
default: default:
@ -1415,7 +1413,7 @@ export class PartyUiHandler extends MessageUiHandler {
} }
break; break;
case PartyUiMode.DISCARD: case PartyUiMode.DISCARD:
this.updateOptionsWithModifierTransferMode(pokemon); this.updateOptionsWithItemTransferMode(pokemon);
break; break;
// TODO: This still needs to be broken up. // TODO: This still needs to be broken up.
// It could use a rework differentiating different kind of switches // It could use a rework differentiating different kind of switches
@ -1428,7 +1426,7 @@ export class PartyUiHandler extends MessageUiHandler {
const isBatonPassMove = this.isBatonPassMove(); const isBatonPassMove = this.isBatonPassMove();
if (allowBatonSwitch && !isBatonPassMove) { if (allowBatonSwitch && !isBatonPassMove) {
// the BATON modifier gives an extra switch option for // the BATON item gives an extra switch option for
// pokemon-command switches, allowing buffs to be optionally passed // pokemon-command switches, allowing buffs to be optionally passed
this.options.push(PartyOption.PASS_BATON); this.options.push(PartyOption.PASS_BATON);
} }
@ -1796,7 +1794,7 @@ class PartySlot extends Phaser.GameObjects.Container {
? -184 + ? -184 +
(globalScene.currentBattle.double ? -40 : 0) + (globalScene.currentBattle.double ? -40 : 0) +
(28 + (globalScene.currentBattle.double ? 8 : 0)) * slotIndex (28 + (globalScene.currentBattle.double ? 8 : 0)) * slotIndex
: partyUiMode === PartyUiMode.MODIFIER_TRANSFER : partyUiMode === PartyUiMode.ITEM_TRANSFER
? -124 + (globalScene.currentBattle.double ? -20 : 0) + slotIndex * 55 ? -124 + (globalScene.currentBattle.double ? -20 : 0) + slotIndex * 55
: -124 + (globalScene.currentBattle.double ? -8 : 0) + slotIndex * 64, : -124 + (globalScene.currentBattle.double ? -8 : 0) + slotIndex * 64,
); );
@ -2158,10 +2156,10 @@ class PartyDiscardModeButton extends Phaser.GameObjects.Container {
* This will also reveal the button if it is currently hidden. * This will also reveal the button if it is currently hidden.
*/ */
// TODO: Reminder to fix // TODO: Reminder to fix
public toggleIcon(partyMode: PartyUiMode.MODIFIER_TRANSFER | PartyUiMode.DISCARD): void { public toggleIcon(partyMode: PartyUiMode.ITEM_TRANSFER | PartyUiMode.DISCARD): void {
this.setActive(true).setVisible(true); this.setActive(true).setVisible(true);
switch (partyMode) { switch (partyMode) {
case PartyUiMode.MODIFIER_TRANSFER: case PartyUiMode.ITEM_TRANSFER:
this.transferIcon.setVisible(true); this.transferIcon.setVisible(true);
this.discardIcon.setVisible(false); this.discardIcon.setVisible(false);
this.textBox.setVisible(true); this.textBox.setVisible(true);