Revised logic in tryTransferHeldItemModifier

This commit is contained in:
frutescens 2024-11-13 12:23:38 -08:00
parent b8f9bb0d8f
commit 3e94a3aa65

View File

@ -105,7 +105,7 @@ export const bypassLogin = import.meta.env.VITE_BYPASS_LOGIN === "1";
const DEBUG_RNG = false;
const OPP_IVS_OVERRIDE_VALIDATED : integer[] = (
const OPP_IVS_OVERRIDE_VALIDATED: integer[] = (
Array.isArray(Overrides.OPP_IVS_OVERRIDE) ?
Overrides.OPP_IVS_OVERRIDE :
new Array(6).fill(Overrides.OPP_IVS_OVERRIDE)
@ -1649,7 +1649,7 @@ export default class BattleScene extends SceneBase {
const isBoss = !(this.currentBattle.waveIndex % 10);
const biomeString: string = getBiomeName(this.arena.biomeType);
this.fieldUI.moveAbove(this.biomeWaveText, this.luckText);
this.biomeWaveText.setText( biomeString + " - " + this.currentBattle.waveIndex.toString());
this.biomeWaveText.setText(biomeString + " - " + this.currentBattle.waveIndex.toString());
this.biomeWaveText.setColor(!isBoss ? "#ffffff" : "#f89890");
this.biomeWaveText.setShadowColor(!isBoss ? "#636363" : "#984038");
this.biomeWaveText.setVisible(true);
@ -2584,12 +2584,18 @@ export default class BattleScene extends SceneBase {
return new Promise(resolve => {
const source = itemModifier.pokemonId ? itemModifier.getPokemon(target.scene) : null;
const cancelled = new Utils.BooleanHolder(false);
Utils.executeIf(!!source && source.isPlayer() !== target.isPlayer(), () => applyAbAttrs(BlockItemTheftAbAttr, source! /* checked in condition*/, cancelled)).then(() => {
// Prevents transfer of Mini Black Hole from opponent to player / player to opponent
cancelled.value = itemModifier instanceof TurnHeldItemTransferModifier ? true : false;
if (source && source.isPlayer() !== target.isPlayer()) {
//Check for abilities like Sticky Hold that prevent item transfer between player and opponent
applyAbAttrs(BlockItemTheftAbAttr, source, cancelled).then(() => {
// Check to prevent player-to-opponent/opponent-to-player MBH transfer
if (!cancelled.value) {
cancelled.value = itemModifier instanceof TurnHeldItemTransferModifier;
}
if (cancelled.value) {
return resolve(false);
}
});
}
const newItemModifier = itemModifier.clone() as PokemonHeldItemModifier;
newItemModifier.pokemonId = target.id;
const matchingModifier = target.scene.findModifier(m => m instanceof PokemonHeldItemModifier
@ -2641,7 +2647,6 @@ export default class BattleScene extends SceneBase {
}
resolve(false);
});
});
}
removePartyMemberModifiers(partyMemberIndex: integer): Promise<void> {