From 8385f693d7f718e877dd86fc2b30e516753c82a1 Mon Sep 17 00:00:00 2001 From: MathyFurret <4866817+MathyFurret@users.noreply.github.com> Date: Tue, 26 Nov 2024 19:41:24 -0600 Subject: [PATCH 1/3] Support blank target in -item message --- play.pokemonshowdown.com/src/battle.ts | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/play.pokemonshowdown.com/src/battle.ts b/play.pokemonshowdown.com/src/battle.ts index 4a9b73e9af..556bf47f80 100644 --- a/play.pokemonshowdown.com/src/battle.ts +++ b/play.pokemonshowdown.com/src/battle.ts @@ -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); From 1d6a8883431258c3991d1ab69e8de907e164f327 Mon Sep 17 00:00:00 2001 From: MathyFurret <4866817+MathyFurret@users.noreply.github.com> Date: Tue, 26 Nov 2024 19:51:50 -0600 Subject: [PATCH 2/3] TS fix --- play.pokemonshowdown.com/src/battle.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/play.pokemonshowdown.com/src/battle.ts b/play.pokemonshowdown.com/src/battle.ts index 556bf47f80..1f3c699615 100644 --- a/play.pokemonshowdown.com/src/battle.ts +++ b/play.pokemonshowdown.com/src/battle.ts @@ -2225,7 +2225,7 @@ 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); From 8a433186b96a276e44eed6aa977ee8aa396a72c7 Mon Sep 17 00:00:00 2001 From: MathyFurret <4866817+MathyFurret@users.noreply.github.com> Date: Tue, 26 Nov 2024 19:55:06 -0600 Subject: [PATCH 3/3] TS fix again --- play.pokemonshowdown.com/src/battle.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/play.pokemonshowdown.com/src/battle.ts b/play.pokemonshowdown.com/src/battle.ts index 1f3c699615..763c5c34b2 100644 --- a/play.pokemonshowdown.com/src/battle.ts +++ b/play.pokemonshowdown.com/src/battle.ts @@ -2233,7 +2233,7 @@ export class Battle { if (effect.id === 'frisk') { const possibleTargets = ofpoke!.side.foe.active.filter(p => p !== null); if (possibleTargets.length === 1) { - poke = possibleTargets[0]; + poke = possibleTargets[0]!; } else { this.activateAbility(ofpoke!, "Frisk"); this.log(args, kwArgs);