Skip to content

Commit

Permalink
Support blank target in -item message
Browse files Browse the repository at this point in the history
  • Loading branch information
MathyFurret committed Nov 27, 2024
1 parent 878464a commit 8385f69
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion play.pokemonshowdown.com/src/battle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2225,10 +2225,24 @@ export class Battle {
break;
}
case '-item': {
let poke = this.getPokemon(args[1])!;
let poke = this.getPokemon(args[1]);
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);

Check failure on line 2248 in play.pokemonshowdown.com/src/battle.ts

View workflow job for this annotation

GitHub Actions / build (14.x)

'poke' is possibly 'null'.
Expand Down

0 comments on commit 8385f69

Please sign in to comment.