Support blank target in -item message (#2302)
Some checks failed
Node.js CI / build (14.x) (push) Has been cancelled

* Support blank target in -item message

* TS fix

* TS fix again
This commit is contained in:
Alex "Mathy 2024-11-27 14:08:49 -06:00 committed by GitHub
parent d43e960729
commit a77ed2a881
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -2231,6 +2231,20 @@ export class Battle {
let item = Dex.items.get(args[2]);
let effect = Dex.getEffect(kwArgs.from);
let ofpoke = this.getPokemon(kwArgs.of);
if (!poke) {
if (effect.id === 'frisk') {
const possibleTargets = ofpoke!.side.foe.active.filter(p => p !== null);
if (possibleTargets.length === 1) {
poke = possibleTargets[0]!;
} else {
this.activateAbility(ofpoke!, "Frisk");
this.log(args, kwArgs);
break;
}
} else {
throw new Error('No Pokemon in -item message');
}
}
poke.item = item.name;
poke.itemEffect = '';
poke.removeVolatile('airballoon' as ID);