Fix logic issues with item stealing
This commit is contained in:
parent
10733fd98d
commit
0ab7f1b018
|
@ -1090,20 +1090,23 @@ export default class BattleScene extends Phaser.Scene {
|
||||||
resolve(false);
|
resolve(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const newStackCount = matchingModifier.stackCount + (transferStack ? itemModifier.stackCount : 1);
|
const countTaken = transferStack ? Math.min(itemModifier.stackCount, maxStackCount - matchingModifier.stackCount) : 1;
|
||||||
if (newStackCount > maxStackCount) {
|
itemModifier.stackCount -= countTaken;
|
||||||
itemModifier.stackCount = newStackCount - maxStackCount;
|
newItemModifier.stackCount = matchingModifier.stackCount + countTaken;
|
||||||
newItemModifier.stackCount = maxStackCount;
|
|
||||||
removeOld = !itemModifier.stackCount;
|
removeOld = !itemModifier.stackCount;
|
||||||
}
|
} else if (!transferStack) {
|
||||||
} else if (!transferStack)
|
newItemModifier.stackCount = 1;
|
||||||
removeOld = !(--itemModifier.stackCount);
|
removeOld = !(--itemModifier.stackCount);
|
||||||
|
}
|
||||||
if (!removeOld || this.removeModifier(itemModifier, !source.isPlayer())) {
|
if (!removeOld || this.removeModifier(itemModifier, !source.isPlayer())) {
|
||||||
const addModifier = () => {
|
const addModifier = () => {
|
||||||
|
if (!matchingModifier || this.removeModifier(matchingModifier, !target.isPlayer())) {
|
||||||
if (target.isPlayer())
|
if (target.isPlayer())
|
||||||
this.addModifier(newItemModifier, playSound).then(() => resolve(true));
|
this.addModifier(newItemModifier, playSound).then(() => resolve(true));
|
||||||
else
|
else
|
||||||
this.addEnemyModifier(newItemModifier).then(() => resolve(true));
|
this.addEnemyModifier(newItemModifier).then(() => resolve(true));
|
||||||
|
} else
|
||||||
|
resolve(false);
|
||||||
};
|
};
|
||||||
if (source.isPlayer() !== target.isPlayer())
|
if (source.isPlayer() !== target.isPlayer())
|
||||||
this.updateModifiers(source.isPlayer()).then(() => addModifier());
|
this.updateModifiers(source.isPlayer()).then(() => addModifier());
|
||||||
|
|
|
@ -14,6 +14,7 @@ import * as Utils from "../utils";
|
||||||
import { TempBattleStat } from '../data/temp-battle-stat';
|
import { TempBattleStat } from '../data/temp-battle-stat';
|
||||||
import { BerryType, getBerryEffectFunc, getBerryPredicate } from '../data/berry';
|
import { BerryType, getBerryEffectFunc, getBerryPredicate } from '../data/berry';
|
||||||
import { Species } from '../data/species';
|
import { Species } from '../data/species';
|
||||||
|
import { BattleType } from '../battle';
|
||||||
|
|
||||||
type ModifierType = ModifierTypes.ModifierType;
|
type ModifierType = ModifierTypes.ModifierType;
|
||||||
export type ModifierPredicate = (modifier: Modifier) => boolean;
|
export type ModifierPredicate = (modifier: Modifier) => boolean;
|
||||||
|
@ -339,7 +340,7 @@ export abstract class PokemonHeldItemModifier extends PersistentModifier {
|
||||||
|
|
||||||
isIconVisible(scene: BattleScene): boolean {
|
isIconVisible(scene: BattleScene): boolean {
|
||||||
const pokemon = this.getPokemon(scene);
|
const pokemon = this.getPokemon(scene);
|
||||||
return pokemon instanceof PlayerPokemon || this.getPokemon(scene).isOnField();
|
return pokemon instanceof PlayerPokemon || (scene.currentBattle.battleType === BattleType.WILD || this.getPokemon(scene).isOnField());
|
||||||
}
|
}
|
||||||
|
|
||||||
getIcon(scene: BattleScene, forSummary?: boolean): Phaser.GameObjects.Container {
|
getIcon(scene: BattleScene, forSummary?: boolean): Phaser.GameObjects.Container {
|
||||||
|
|
Loading…
Reference in New Issue