[Bug] Making FormChangeItems Untransferrable (#2695)

* Made FormChangeItems untransferrable. Replaced getTransferrable()

* Made isTransferrable readonly. Removed unnecessary 'm as PokemonHeldItemModifier'.
This commit is contained in:
Arxalc 2024-07-13 14:09:01 -04:00 committed by GitHub
parent cbc6005c57
commit 0c0de4103b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 31 additions and 45 deletions

View File

@ -157,7 +157,7 @@ export default class Battle {
} }
addPostBattleLoot(enemyPokemon: EnemyPokemon): void { addPostBattleLoot(enemyPokemon: EnemyPokemon): void {
this.postBattleLoot.push(...enemyPokemon.scene.findModifiers(m => m instanceof PokemonHeldItemModifier && m.pokemonId === enemyPokemon.id && m.getTransferrable(false), false).map(i => { this.postBattleLoot.push(...enemyPokemon.scene.findModifiers(m => m instanceof PokemonHeldItemModifier && m.pokemonId === enemyPokemon.id && m.isTransferrable, false).map(i => {
const ret = i as PokemonHeldItemModifier; const ret = i as PokemonHeldItemModifier;
ret.pokemonId = null; ret.pokemonId = null;
return ret; return ret;

View File

@ -1525,7 +1525,7 @@ export class PostAttackStealHeldItemAbAttr extends PostAttackAbAttr {
applyPostAttack(pokemon: Pokemon, passive: boolean, defender: Pokemon, move: Move, hitResult: HitResult, args: any[]): Promise<boolean> { applyPostAttack(pokemon: Pokemon, passive: boolean, defender: Pokemon, move: Move, hitResult: HitResult, args: any[]): Promise<boolean> {
return new Promise<boolean>(resolve => { return new Promise<boolean>(resolve => {
if (hitResult < HitResult.NO_EFFECT && (!this.condition || this.condition(pokemon, defender, move))) { if (hitResult < HitResult.NO_EFFECT && (!this.condition || this.condition(pokemon, defender, move))) {
const heldItems = this.getTargetHeldItems(defender).filter(i => i.getTransferrable(false)); const heldItems = this.getTargetHeldItems(defender).filter(i => i.isTransferrable);
if (heldItems.length) { if (heldItems.length) {
const stolenItem = heldItems[pokemon.randSeedInt(heldItems.length)]; const stolenItem = heldItems[pokemon.randSeedInt(heldItems.length)];
pokemon.scene.tryTransferHeldItemModifier(stolenItem, pokemon, false).then(success => { pokemon.scene.tryTransferHeldItemModifier(stolenItem, pokemon, false).then(success => {
@ -1543,7 +1543,7 @@ export class PostAttackStealHeldItemAbAttr extends PostAttackAbAttr {
getTargetHeldItems(target: Pokemon): PokemonHeldItemModifier[] { getTargetHeldItems(target: Pokemon): PokemonHeldItemModifier[] {
return target.scene.findModifiers(m => m instanceof PokemonHeldItemModifier return target.scene.findModifiers(m => m instanceof PokemonHeldItemModifier
&& (m as PokemonHeldItemModifier).pokemonId === target.id, target.isPlayer()) as PokemonHeldItemModifier[]; && m.pokemonId === target.id, target.isPlayer()) as PokemonHeldItemModifier[];
} }
} }
@ -1614,7 +1614,7 @@ export class PostDefendStealHeldItemAbAttr extends PostDefendAbAttr {
applyPostDefend(pokemon: Pokemon, passive: boolean, attacker: Pokemon, move: Move, hitResult: HitResult, args: any[]): Promise<boolean> { applyPostDefend(pokemon: Pokemon, passive: boolean, attacker: Pokemon, move: Move, hitResult: HitResult, args: any[]): Promise<boolean> {
return new Promise<boolean>(resolve => { return new Promise<boolean>(resolve => {
if (hitResult < HitResult.NO_EFFECT && (!this.condition || this.condition(pokemon, attacker, move))) { if (hitResult < HitResult.NO_EFFECT && (!this.condition || this.condition(pokemon, attacker, move))) {
const heldItems = this.getTargetHeldItems(attacker).filter(i => i.getTransferrable(false)); const heldItems = this.getTargetHeldItems(attacker).filter(i => i.isTransferrable);
if (heldItems.length) { if (heldItems.length) {
const stolenItem = heldItems[pokemon.randSeedInt(heldItems.length)]; const stolenItem = heldItems[pokemon.randSeedInt(heldItems.length)];
pokemon.scene.tryTransferHeldItemModifier(stolenItem, pokemon, false).then(success => { pokemon.scene.tryTransferHeldItemModifier(stolenItem, pokemon, false).then(success => {
@ -1632,7 +1632,7 @@ export class PostDefendStealHeldItemAbAttr extends PostDefendAbAttr {
getTargetHeldItems(target: Pokemon): PokemonHeldItemModifier[] { getTargetHeldItems(target: Pokemon): PokemonHeldItemModifier[] {
return target.scene.findModifiers(m => m instanceof PokemonHeldItemModifier return target.scene.findModifiers(m => m instanceof PokemonHeldItemModifier
&& (m as PokemonHeldItemModifier).pokemonId === target.id, target.isPlayer()) as PokemonHeldItemModifier[]; && m.pokemonId === target.id, target.isPlayer()) as PokemonHeldItemModifier[];
} }
} }

View File

@ -1796,7 +1796,7 @@ export class StealHeldItemChanceAttr extends MoveEffectAttr {
if (rand >= this.chance) { if (rand >= this.chance) {
return resolve(false); return resolve(false);
} }
const heldItems = this.getTargetHeldItems(target).filter(i => i.getTransferrable(false)); const heldItems = this.getTargetHeldItems(target).filter(i => i.isTransferrable);
if (heldItems.length) { if (heldItems.length) {
const poolType = target.isPlayer() ? ModifierPoolType.PLAYER : target.hasTrainer() ? ModifierPoolType.TRAINER : ModifierPoolType.WILD; const poolType = target.isPlayer() ? ModifierPoolType.PLAYER : target.hasTrainer() ? ModifierPoolType.TRAINER : ModifierPoolType.WILD;
const highestItemTier = heldItems.map(m => m.type.getOrInferTier(poolType)).reduce((highestTier, tier) => Math.max(tier, highestTier), 0); const highestItemTier = heldItems.map(m => m.type.getOrInferTier(poolType)).reduce((highestTier, tier) => Math.max(tier, highestTier), 0);
@ -1817,7 +1817,7 @@ export class StealHeldItemChanceAttr extends MoveEffectAttr {
getTargetHeldItems(target: Pokemon): PokemonHeldItemModifier[] { getTargetHeldItems(target: Pokemon): PokemonHeldItemModifier[] {
return target.scene.findModifiers(m => m instanceof PokemonHeldItemModifier return target.scene.findModifiers(m => m instanceof PokemonHeldItemModifier
&& (m as PokemonHeldItemModifier).pokemonId === target.id, target.isPlayer()) as PokemonHeldItemModifier[]; && m.pokemonId === target.id, target.isPlayer()) as PokemonHeldItemModifier[];
} }
getUserBenefitScore(user: Pokemon, target: Pokemon, move: Move): number { getUserBenefitScore(user: Pokemon, target: Pokemon, move: Move): number {
@ -1857,7 +1857,6 @@ export class RemoveHeldItemAttr extends MoveEffectAttr {
* @returns {boolean} True if an item was removed * @returns {boolean} True if an item was removed
*/ */
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean { apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean {
if (!this.berriesOnly && target.isPlayer()) { // "Wild Pokemon cannot knock off Player Pokemon's held items" (See Bulbapedia) if (!this.berriesOnly && target.isPlayer()) { // "Wild Pokemon cannot knock off Player Pokemon's held items" (See Bulbapedia)
return false; return false;
} }
@ -1870,7 +1869,8 @@ export class RemoveHeldItemAttr extends MoveEffectAttr {
} }
// Considers entire transferrable item pool by default (Knock Off). Otherwise berries only if specified (Incinerate). // Considers entire transferrable item pool by default (Knock Off). Otherwise berries only if specified (Incinerate).
let heldItems = this.getTargetHeldItems(target).filter(i => i.getTransferrable(false)); let heldItems = this.getTargetHeldItems(target).filter(i => i.isTransferrable);
if (this.berriesOnly) { if (this.berriesOnly) {
heldItems = heldItems.filter(m => m instanceof BerryModifier && m.pokemonId === target.id, target.isPlayer()); heldItems = heldItems.filter(m => m instanceof BerryModifier && m.pokemonId === target.id, target.isPlayer());
} }
@ -1894,7 +1894,7 @@ export class RemoveHeldItemAttr extends MoveEffectAttr {
getTargetHeldItems(target: Pokemon): PokemonHeldItemModifier[] { getTargetHeldItems(target: Pokemon): PokemonHeldItemModifier[] {
return target.scene.findModifiers(m => m instanceof PokemonHeldItemModifier return target.scene.findModifiers(m => m instanceof PokemonHeldItemModifier
&& (m as PokemonHeldItemModifier).pokemonId === target.id, target.isPlayer()) as PokemonHeldItemModifier[]; && m.pokemonId === target.id, target.isPlayer()) as PokemonHeldItemModifier[];
} }
getUserBenefitScore(user: Pokemon, target: Pokemon, move: Move): number { getUserBenefitScore(user: Pokemon, target: Pokemon, move: Move): number {
@ -1986,7 +1986,8 @@ export class StealEatBerryAttr extends EatBerryAttr {
if (cancelled.value === true) { if (cancelled.value === true) {
return false; return false;
} }
const heldBerries = this.getTargetHeldBerries(target).filter(i => i.getTransferrable(false));
const heldBerries = this.getTargetHeldBerries(target);
if (heldBerries.length <= 0) { if (heldBerries.length <= 0) {
return false; return false;
} }
@ -5479,7 +5480,7 @@ export class AttackedByItemAttr extends MoveAttr {
*/ */
getCondition(): MoveConditionFunc { getCondition(): MoveConditionFunc {
return (user: Pokemon, target: Pokemon, move: Move) => { return (user: Pokemon, target: Pokemon, move: Move) => {
const heldItems = target.getHeldItems().filter(i => i.getTransferrable(true)); const heldItems = target.getHeldItems().filter(i => i.isTransferrable);
if (heldItems.length === 0) { if (heldItems.length === 0) {
return false; return false;
} }
@ -6436,7 +6437,7 @@ export function initMoves() {
.attr(AddBattlerTagAttr, BattlerTagType.DROWSY, false, true) .attr(AddBattlerTagAttr, BattlerTagType.DROWSY, false, true)
.condition((user, target, move) => !target.status), .condition((user, target, move) => !target.status),
new AttackMove(Moves.KNOCK_OFF, Type.DARK, MoveCategory.PHYSICAL, 65, 100, 20, -1, 0, 3) new AttackMove(Moves.KNOCK_OFF, Type.DARK, MoveCategory.PHYSICAL, 65, 100, 20, -1, 0, 3)
.attr(MovePowerMultiplierAttr, (user, target, move) => target.getHeldItems().filter(i => i.getTransferrable(false)).length > 0 ? 1.5 : 1) .attr(MovePowerMultiplierAttr, (user, target, move) => target.getHeldItems().filter(i => i.isTransferrable).length > 0 ? 1.5 : 1)
.attr(RemoveHeldItemAttr, false), .attr(RemoveHeldItemAttr, false),
new AttackMove(Moves.ENDEAVOR, Type.NORMAL, MoveCategory.PHYSICAL, -1, 100, 5, -1, 0, 3) new AttackMove(Moves.ENDEAVOR, Type.NORMAL, MoveCategory.PHYSICAL, -1, 100, 5, -1, 0, 3)
.attr(MatchHpAttr) .attr(MatchHpAttr)
@ -7067,7 +7068,7 @@ export function initMoves() {
new StatusMove(Moves.QUASH, Type.DARK, 100, 15, -1, 0, 5) new StatusMove(Moves.QUASH, Type.DARK, 100, 15, -1, 0, 5)
.unimplemented(), .unimplemented(),
new AttackMove(Moves.ACROBATICS, Type.FLYING, MoveCategory.PHYSICAL, 55, 100, 15, -1, 0, 5) new AttackMove(Moves.ACROBATICS, Type.FLYING, MoveCategory.PHYSICAL, 55, 100, 15, -1, 0, 5)
.attr(MovePowerMultiplierAttr, (user, target, move) => Math.max(1, 2 - 0.2 * user.getHeldItems().filter(i => i.getTransferrable(true)).reduce((v, m) => v + m.stackCount, 0))), .attr(MovePowerMultiplierAttr, (user, target, move) => Math.max(1, 2 - 0.2 * user.getHeldItems().filter(i => i.isTransferrable).reduce((v, m) => v + m.stackCount, 0))),
new StatusMove(Moves.REFLECT_TYPE, Type.NORMAL, -1, 15, -1, 0, 5) new StatusMove(Moves.REFLECT_TYPE, Type.NORMAL, -1, 15, -1, 0, 5)
.attr(CopyTypeAttr), .attr(CopyTypeAttr),
new AttackMove(Moves.RETALIATE, Type.NORMAL, MoveCategory.PHYSICAL, 70, 100, 5, -1, 0, 5) new AttackMove(Moves.RETALIATE, Type.NORMAL, MoveCategory.PHYSICAL, 70, 100, 5, -1, 0, 5)

View File

@ -525,7 +525,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
if (!this.scene) { if (!this.scene) {
return []; return [];
} }
return this.scene.findModifiers(m => m instanceof PokemonHeldItemModifier && (m as PokemonHeldItemModifier).pokemonId === this.id, this.isPlayer()) as PokemonHeldItemModifier[]; return this.scene.findModifiers(m => m instanceof PokemonHeldItemModifier && m.pokemonId === this.id, this.isPlayer()) as PokemonHeldItemModifier[];
} }
updateScale(): void { updateScale(): void {
@ -3286,7 +3286,7 @@ export class PlayerPokemon extends Pokemon {
this.scene.getParty().push(newPokemon); this.scene.getParty().push(newPokemon);
newPokemon.evolve(!isFusion ? newEvolution : new FusionSpeciesFormEvolution(this.id, newEvolution)); newPokemon.evolve(!isFusion ? newEvolution : new FusionSpeciesFormEvolution(this.id, newEvolution));
const modifiers = this.scene.findModifiers(m => m instanceof PokemonHeldItemModifier const modifiers = this.scene.findModifiers(m => m instanceof PokemonHeldItemModifier
&& (m as PokemonHeldItemModifier).pokemonId === this.id, true) as PokemonHeldItemModifier[]; && m.pokemonId === this.id, true) as PokemonHeldItemModifier[];
modifiers.forEach(m => { modifiers.forEach(m => {
const clonedModifier = m.clone() as PokemonHeldItemModifier; const clonedModifier = m.clone() as PokemonHeldItemModifier;
clonedModifier.pokemonId = newPokemon.id; clonedModifier.pokemonId = newPokemon.id;
@ -3379,7 +3379,7 @@ export class PlayerPokemon extends Pokemon {
partyMemberIndex--; partyMemberIndex--;
} }
const fusedPartyMemberHeldModifiers = this.scene.findModifiers(m => m instanceof PokemonHeldItemModifier const fusedPartyMemberHeldModifiers = this.scene.findModifiers(m => m instanceof PokemonHeldItemModifier
&& (m as PokemonHeldItemModifier).pokemonId === pokemon.id, true) as PokemonHeldItemModifier[]; && m.pokemonId === pokemon.id, true) as PokemonHeldItemModifier[];
const transferModifiers: Promise<boolean>[] = []; const transferModifiers: Promise<boolean>[] = [];
for (const modifier of fusedPartyMemberHeldModifiers) { for (const modifier of fusedPartyMemberHeldModifiers) {
transferModifiers.push(this.scene.tryTransferHeldItemModifier(modifier, this, false, modifier.getStackCount(), true, true)); transferModifiers.push(this.scene.tryTransferHeldItemModifier(modifier, this, false, modifier.getStackCount(), true, true));

View File

@ -470,6 +470,7 @@ export class TerastallizeAccessModifier extends PersistentModifier {
export abstract class PokemonHeldItemModifier extends PersistentModifier { export abstract class PokemonHeldItemModifier extends PersistentModifier {
public pokemonId: integer; public pokemonId: integer;
readonly isTransferrable: boolean = true;
constructor(type: ModifierType, pokemonId: integer, stackCount: integer) { constructor(type: ModifierType, pokemonId: integer, stackCount: integer) {
super(type, stackCount); super(type, stackCount);
@ -491,10 +492,6 @@ export abstract class PokemonHeldItemModifier extends PersistentModifier {
return super.shouldApply(args) && args.length && args[0] instanceof Pokemon && (this.pokemonId === -1 || (args[0] as Pokemon).id === this.pokemonId); return super.shouldApply(args) && args.length && args[0] instanceof Pokemon && (this.pokemonId === -1 || (args[0] as Pokemon).id === this.pokemonId);
} }
getTransferrable(withinParty: boolean) {
return true;
}
isIconVisible(scene: BattleScene): boolean { isIconVisible(scene: BattleScene): boolean {
return this.getPokemon(scene).isOnField(); return this.getPokemon(scene).isOnField();
} }
@ -570,6 +567,7 @@ export abstract class PokemonHeldItemModifier extends PersistentModifier {
export abstract class LapsingPokemonHeldItemModifier extends PokemonHeldItemModifier { export abstract class LapsingPokemonHeldItemModifier extends PokemonHeldItemModifier {
protected battlesLeft: integer; protected battlesLeft: integer;
readonly isTransferrable: boolean = false;
constructor(type: ModifierTypes.ModifierType, pokemonId: integer, battlesLeft?: integer, stackCount?: integer) { constructor(type: ModifierTypes.ModifierType, pokemonId: integer, battlesLeft?: integer, stackCount?: integer) {
super(type, pokemonId, stackCount); super(type, pokemonId, stackCount);
@ -606,6 +604,7 @@ export abstract class LapsingPokemonHeldItemModifier extends PokemonHeldItemModi
export class TerastallizeModifier extends LapsingPokemonHeldItemModifier { export class TerastallizeModifier extends LapsingPokemonHeldItemModifier {
public teraType: Type; public teraType: Type;
readonly isTransferrable: boolean = false;
constructor(type: ModifierTypes.TerastallizeModifierType, pokemonId: integer, teraType: Type, battlesLeft?: integer, stackCount?: integer) { constructor(type: ModifierTypes.TerastallizeModifierType, pokemonId: integer, teraType: Type, battlesLeft?: integer, stackCount?: integer) {
super(type, pokemonId, battlesLeft || 10, stackCount); super(type, pokemonId, battlesLeft || 10, stackCount);
@ -649,10 +648,6 @@ export class TerastallizeModifier extends LapsingPokemonHeldItemModifier {
return ret; return ret;
} }
getTransferrable(withinParty: boolean): boolean {
return false;
}
getScoreMultiplier(): number { getScoreMultiplier(): number {
return 1.25; return 1.25;
} }
@ -664,6 +659,7 @@ export class TerastallizeModifier extends LapsingPokemonHeldItemModifier {
export class PokemonBaseStatModifier extends PokemonHeldItemModifier { export class PokemonBaseStatModifier extends PokemonHeldItemModifier {
protected stat: Stat; protected stat: Stat;
readonly isTransferrable: boolean = false;
constructor(type: ModifierTypes.PokemonBaseStatBoosterModifierType, pokemonId: integer, stat: Stat, stackCount?: integer) { constructor(type: ModifierTypes.PokemonBaseStatBoosterModifierType, pokemonId: integer, stat: Stat, stackCount?: integer) {
super(type, pokemonId, stackCount); super(type, pokemonId, stackCount);
@ -695,10 +691,6 @@ export class PokemonBaseStatModifier extends PokemonHeldItemModifier {
return true; return true;
} }
getTransferrable(_withinParty: boolean): boolean {
return false;
}
getScoreMultiplier(): number { getScoreMultiplier(): number {
return 1.1; return 1.1;
} }
@ -1878,6 +1870,7 @@ export class PokemonMultiHitModifier extends PokemonHeldItemModifier {
export class PokemonFormChangeItemModifier extends PokemonHeldItemModifier { export class PokemonFormChangeItemModifier extends PokemonHeldItemModifier {
public formChangeItem: FormChangeItem; public formChangeItem: FormChangeItem;
public active: boolean; public active: boolean;
readonly isTransferrable: boolean = false;
constructor(type: ModifierTypes.FormChangeItemModifierType, pokemonId: integer, formChangeItem: FormChangeItem, active: boolean, stackCount?: integer) { constructor(type: ModifierTypes.FormChangeItemModifierType, pokemonId: integer, formChangeItem: FormChangeItem, active: boolean, stackCount?: integer) {
super(type, pokemonId, stackCount); super(type, pokemonId, stackCount);
@ -1916,10 +1909,6 @@ export class PokemonFormChangeItemModifier extends PokemonHeldItemModifier {
return ret; return ret;
} }
getTransferrable(withinParty: boolean) {
return withinParty;
}
getMaxHeldItemCount(pokemon: Pokemon): integer { getMaxHeldItemCount(pokemon: Pokemon): integer {
return 1; return 1;
} }
@ -2164,12 +2153,11 @@ export abstract class HeldItemTransferModifier extends PokemonHeldItemModifier {
return false; return false;
} }
const withinParty = pokemon.isPlayer() === targetPokemon.isPlayer();
const poolType = pokemon.isPlayer() ? ModifierTypes.ModifierPoolType.PLAYER : pokemon.hasTrainer() ? ModifierTypes.ModifierPoolType.TRAINER : ModifierTypes.ModifierPoolType.WILD; const poolType = pokemon.isPlayer() ? ModifierTypes.ModifierPoolType.PLAYER : pokemon.hasTrainer() ? ModifierTypes.ModifierPoolType.TRAINER : ModifierTypes.ModifierPoolType.WILD;
const transferredModifierTypes: ModifierTypes.ModifierType[] = []; const transferredModifierTypes: ModifierTypes.ModifierType[] = [];
const itemModifiers = pokemon.scene.findModifiers(m => m instanceof PokemonHeldItemModifier const itemModifiers = pokemon.scene.findModifiers(m => m instanceof PokemonHeldItemModifier
&& (m as PokemonHeldItemModifier).pokemonId === targetPokemon.id && m.getTransferrable(withinParty), targetPokemon.isPlayer()) as PokemonHeldItemModifier[]; && m.pokemonId === targetPokemon.id && m.isTransferrable, targetPokemon.isPlayer()) as PokemonHeldItemModifier[];
let highestItemTier = itemModifiers.map(m => m.type.getOrInferTier(poolType)).reduce((highestTier, tier) => Math.max(tier, highestTier), 0); let highestItemTier = itemModifiers.map(m => m.type.getOrInferTier(poolType)).reduce((highestTier, tier) => Math.max(tier, highestTier), 0);
let tierItemModifiers = itemModifiers.filter(m => m.type.getOrInferTier(poolType) === highestItemTier); let tierItemModifiers = itemModifiers.filter(m => m.type.getOrInferTier(poolType) === highestItemTier);
@ -2214,6 +2202,7 @@ export abstract class HeldItemTransferModifier extends PokemonHeldItemModifier {
* @see {@linkcode modifierTypes[MINI_BLACK_HOLE]} * @see {@linkcode modifierTypes[MINI_BLACK_HOLE]}
*/ */
export class TurnHeldItemTransferModifier extends HeldItemTransferModifier { export class TurnHeldItemTransferModifier extends HeldItemTransferModifier {
readonly isTransferrable: boolean = false;
constructor(type: ModifierType, pokemonId: integer, stackCount?: integer) { constructor(type: ModifierType, pokemonId: integer, stackCount?: integer) {
super(type, pokemonId, stackCount); super(type, pokemonId, stackCount);
} }
@ -2226,10 +2215,6 @@ export class TurnHeldItemTransferModifier extends HeldItemTransferModifier {
return new TurnHeldItemTransferModifier(this.type, this.pokemonId, this.stackCount); return new TurnHeldItemTransferModifier(this.type, this.pokemonId, this.stackCount);
} }
getTransferrable(withinParty: boolean) {
return withinParty;
}
getTransferredItemCount(): integer { getTransferredItemCount(): integer {
return this.getStackCount(); return this.getStackCount();
} }

View File

@ -5160,7 +5160,7 @@ export class SelectModifierPhase extends BattlePhase {
this.scene.ui.setModeWithoutClear(Mode.PARTY, PartyUiMode.MODIFIER_TRANSFER, -1, (fromSlotIndex: integer, itemIndex: integer, itemQuantity: integer, toSlotIndex: integer) => { this.scene.ui.setModeWithoutClear(Mode.PARTY, PartyUiMode.MODIFIER_TRANSFER, -1, (fromSlotIndex: integer, itemIndex: integer, itemQuantity: integer, toSlotIndex: integer) => {
if (toSlotIndex !== undefined && fromSlotIndex < 6 && toSlotIndex < 6 && fromSlotIndex !== toSlotIndex && itemIndex > -1) { if (toSlotIndex !== undefined && fromSlotIndex < 6 && toSlotIndex < 6 && fromSlotIndex !== toSlotIndex && itemIndex > -1) {
const itemModifiers = this.scene.findModifiers(m => m instanceof PokemonHeldItemModifier const itemModifiers = this.scene.findModifiers(m => m instanceof PokemonHeldItemModifier
&& (m as PokemonHeldItemModifier).getTransferrable(true) && (m as PokemonHeldItemModifier).pokemonId === party[fromSlotIndex].id) as PokemonHeldItemModifier[]; && m.isTransferrable && m.pokemonId === party[fromSlotIndex].id) as PokemonHeldItemModifier[];
const itemModifier = itemModifiers[itemIndex]; const itemModifier = itemModifiers[itemIndex];
this.scene.tryTransferHeldItemModifier(itemModifier, party[toSlotIndex], true, itemQuantity); this.scene.tryTransferHeldItemModifier(itemModifier, party[toSlotIndex], true, itemQuantity);
} else { } else {

View File

@ -136,7 +136,7 @@ export default class ModifierSelectUiHandler extends AwaitableUiHandler {
this.player = args[0]; this.player = args[0];
const partyHasHeldItem = this.player && !!this.scene.findModifiers(m => m instanceof PokemonHeldItemModifier && (m as PokemonHeldItemModifier).getTransferrable(true)).length; const partyHasHeldItem = this.player && !!this.scene.findModifiers(m => m instanceof PokemonHeldItemModifier && m.isTransferrable).length;
const canLockRarities = !!this.scene.findModifier(m => m instanceof LockModifierTiersModifier); const canLockRarities = !!this.scene.findModifier(m => m instanceof LockModifierTiersModifier);
this.transferButtonContainer.setVisible(false); this.transferButtonContainer.setVisible(false);

View File

@ -306,7 +306,7 @@ export default class PartyUiHandler extends MessageUiHandler {
|| (option === PartyOption.RELEASE && this.partyUiMode === PartyUiMode.RELEASE)) { || (option === PartyOption.RELEASE && this.partyUiMode === PartyUiMode.RELEASE)) {
let filterResult: string; let filterResult: string;
const getTransferrableItemsFromPokemon = (pokemon: PlayerPokemon) => const getTransferrableItemsFromPokemon = (pokemon: PlayerPokemon) =>
this.scene.findModifiers(m => m instanceof PokemonHeldItemModifier && (m as PokemonHeldItemModifier).getTransferrable(true) && (m as PokemonHeldItemModifier).pokemonId === pokemon.id) as PokemonHeldItemModifier[]; this.scene.findModifiers(m => m instanceof PokemonHeldItemModifier && m.isTransferrable && m.pokemonId === pokemon.id) as PokemonHeldItemModifier[];
if (option !== PartyOption.TRANSFER && option !== PartyOption.SPLICE) { if (option !== PartyOption.TRANSFER && option !== PartyOption.SPLICE) {
filterResult = (this.selectFilter as PokemonSelectFilter)(pokemon); filterResult = (this.selectFilter as PokemonSelectFilter)(pokemon);
if (filterResult === null && (option === PartyOption.SEND_OUT || option === PartyOption.PASS_BATON)) { if (filterResult === null && (option === PartyOption.SEND_OUT || option === PartyOption.PASS_BATON)) {
@ -482,7 +482,7 @@ export default class PartyUiHandler extends MessageUiHandler {
if (this.partyUiMode === PartyUiMode.MODIFIER_TRANSFER && !this.transferMode) { if (this.partyUiMode === PartyUiMode.MODIFIER_TRANSFER && !this.transferMode) {
/** Initialize item quantities for the selected Pokemon */ /** Initialize item quantities for the selected Pokemon */
const itemModifiers = this.scene.findModifiers(m => m instanceof PokemonHeldItemModifier const itemModifiers = this.scene.findModifiers(m => m instanceof PokemonHeldItemModifier
&& (m as PokemonHeldItemModifier).getTransferrable(true) && (m as PokemonHeldItemModifier).pokemonId === this.scene.getParty()[this.cursor].id) as PokemonHeldItemModifier[]; && m.isTransferrable && m.pokemonId === this.scene.getParty()[this.cursor].id) as PokemonHeldItemModifier[];
this.transferQuantities = itemModifiers.map(item => item.getStackCount()); this.transferQuantities = itemModifiers.map(item => item.getStackCount());
this.transferQuantitiesMax = itemModifiers.map(item => item.getStackCount()); this.transferQuantitiesMax = itemModifiers.map(item => item.getStackCount());
} }
@ -699,7 +699,7 @@ export default class PartyUiHandler extends MessageUiHandler {
const itemModifiers = this.partyUiMode === PartyUiMode.MODIFIER_TRANSFER const itemModifiers = this.partyUiMode === PartyUiMode.MODIFIER_TRANSFER
? this.scene.findModifiers(m => m instanceof PokemonHeldItemModifier ? this.scene.findModifiers(m => m instanceof PokemonHeldItemModifier
&& (m as PokemonHeldItemModifier).getTransferrable(true) && (m as PokemonHeldItemModifier).pokemonId === pokemon.id) as PokemonHeldItemModifier[] && m.isTransferrable && m.pokemonId === pokemon.id) as PokemonHeldItemModifier[]
: null; : null;
if (this.options.length) { if (this.options.length) {

View File

@ -837,7 +837,7 @@ export default class SummaryUiHandler extends UiHandler {
}); });
const itemModifiers = (this.scene.findModifiers(m => m instanceof PokemonHeldItemModifier const itemModifiers = (this.scene.findModifiers(m => m instanceof PokemonHeldItemModifier
&& (m as PokemonHeldItemModifier).pokemonId === this.pokemon.id, true) as PokemonHeldItemModifier[]) && m.pokemonId === this.pokemon.id, true) as PokemonHeldItemModifier[])
.sort(modifierSortFunc); .sort(modifierSortFunc);
itemModifiers.forEach((item, i) => { itemModifiers.forEach((item, i) => {