Skip to content

Commit

Permalink
Support blank target in -item message (#2302)
Browse files Browse the repository at this point in the history
* Support blank target in -item message

* TS fix

* TS fix again
  • Loading branch information
MathyFurret authored Nov 27, 2024
1 parent d43e960 commit a77ed2a
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions play.pokemonshowdown.com/src/battle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit a77ed2a

Please sign in to comment.