mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-08-10 17:39:31 +02:00
Remove leftover unused functions from merge; transfer/discard button
This commit is contained in:
parent
c6b4f273d0
commit
f5d08567c9
@ -65,7 +65,7 @@ import { PlayerGender } from "#enums/player-gender";
|
||||
import { PokeballType } from "#enums/pokeball";
|
||||
import type { PokemonAnimType } from "#enums/pokemon-anim-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 { SpeciesId } from "#enums/species-id";
|
||||
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 { assignEnemyHeldItemsForWave, assignItemsFromConfiguration } from "#items/held-item-pool";
|
||||
import type { MatchExact, Reward } from "#items/reward";
|
||||
import { getRewardPoolForType } from "#items/reward-pool-utils";
|
||||
import { type EnemyAttackStatusEffectChanceTrainerItem, TrainerItemEffect } from "#items/trainer-item";
|
||||
import {
|
||||
isTrainerItemPool,
|
||||
@ -1234,15 +1233,7 @@ export class BattleScene extends SceneBase {
|
||||
...allSpecies,
|
||||
...allMoves,
|
||||
...allAbilities,
|
||||
...getEnumValues(RewardPoolType)
|
||||
.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),
|
||||
),
|
||||
//TODO: do we need to add items and rewards here?
|
||||
];
|
||||
for (const item of localizable) {
|
||||
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) {
|
||||
const manager = isPlayer ? this.trainerItems : this.enemyTrainerItems;
|
||||
for (const item of saveData) {
|
||||
|
@ -60,13 +60,13 @@ export enum PartyUiMode {
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
REWARD,
|
||||
/**
|
||||
* 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,
|
||||
/**
|
||||
@ -368,7 +368,7 @@ export class PartyUiHandler extends MessageUiHandler {
|
||||
this.populatePartySlots();
|
||||
// If we are currently transferring items, set the icon to its proper state and reveal the button.
|
||||
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.setCursor(0);
|
||||
@ -552,7 +552,6 @@ export class PartyUiHandler extends MessageUiHandler {
|
||||
return true;
|
||||
}
|
||||
|
||||
// TODO: This will be largely changed with the modifier rework
|
||||
private processItemTransferModeInput(pokemon: PlayerPokemon) {
|
||||
const ui = this.getUi();
|
||||
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
|
||||
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 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 matchingItem = newPokemon.heldItemManager.hasItem(transferItem);
|
||||
|
||||
@ -578,7 +576,7 @@ export class PartyUiHandler extends MessageUiHandler {
|
||||
if (p !== this.transferCursor) {
|
||||
// this skips adding the able/not able labels on the pokemon doing the transfer
|
||||
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)) {
|
||||
// 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");
|
||||
@ -587,7 +585,7 @@ export class PartyUiHandler extends MessageUiHandler {
|
||||
ableToTransferText = i18next.t("partyUiHandler:able");
|
||||
}
|
||||
} 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");
|
||||
}
|
||||
} else {
|
||||
@ -682,17 +680,17 @@ export class PartyUiHandler extends MessageUiHandler {
|
||||
}
|
||||
|
||||
private doDiscard(option: PartyOption, pokemon: PlayerPokemon) {
|
||||
const itemModifiers = this.getTransferrableItemsFromPokemon(pokemon);
|
||||
const items = pokemon.heldItemManager.getTransferableHeldItems();
|
||||
this.clearOptions();
|
||||
|
||||
if (option === PartyOption.ALL) {
|
||||
// Discard all currently held items
|
||||
for (let i = 0; i < itemModifiers.length; i++) {
|
||||
globalScene.tryDiscardHeldItemModifier(itemModifiers[i], this.transferQuantities[i]);
|
||||
for (let i = 0; i < items.length; i++) {
|
||||
pokemon.heldItemManager.remove(items[i], this.transferQuantities[i]);
|
||||
}
|
||||
} else {
|
||||
// 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.
|
||||
*/
|
||||
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 {
|
||||
@ -1005,9 +1003,9 @@ export class PartyUiHandler extends MessageUiHandler {
|
||||
if (this.cursor === 7) {
|
||||
switch (this.partyUiMode) {
|
||||
case PartyUiMode.DISCARD:
|
||||
this.partyUiMode = PartyUiMode.MODIFIER_TRANSFER;
|
||||
this.partyUiMode = PartyUiMode.ITEM_TRANSFER;
|
||||
break;
|
||||
case PartyUiMode.MODIFIER_TRANSFER:
|
||||
case PartyUiMode.ITEM_TRANSFER:
|
||||
this.partyUiMode = PartyUiMode.DISCARD;
|
||||
break;
|
||||
default:
|
||||
@ -1415,7 +1413,7 @@ export class PartyUiHandler extends MessageUiHandler {
|
||||
}
|
||||
break;
|
||||
case PartyUiMode.DISCARD:
|
||||
this.updateOptionsWithModifierTransferMode(pokemon);
|
||||
this.updateOptionsWithItemTransferMode(pokemon);
|
||||
break;
|
||||
// TODO: This still needs to be broken up.
|
||||
// It could use a rework differentiating different kind of switches
|
||||
@ -1428,7 +1426,7 @@ export class PartyUiHandler extends MessageUiHandler {
|
||||
const isBatonPassMove = this.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
|
||||
this.options.push(PartyOption.PASS_BATON);
|
||||
}
|
||||
@ -1796,7 +1794,7 @@ class PartySlot extends Phaser.GameObjects.Container {
|
||||
? -184 +
|
||||
(globalScene.currentBattle.double ? -40 : 0) +
|
||||
(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 ? -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.
|
||||
*/
|
||||
// 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);
|
||||
switch (partyMode) {
|
||||
case PartyUiMode.MODIFIER_TRANSFER:
|
||||
case PartyUiMode.ITEM_TRANSFER:
|
||||
this.transferIcon.setVisible(true);
|
||||
this.discardIcon.setVisible(false);
|
||||
this.textBox.setVisible(true);
|
||||
|
Loading…
Reference in New Issue
Block a user