diff --git a/play.pokemonshowdown.com/src/battle-choices.ts b/play.pokemonshowdown.com/src/battle-choices.ts index 1c69f6758..e32155648 100644 --- a/play.pokemonshowdown.com/src/battle-choices.ts +++ b/play.pokemonshowdown.com/src/battle-choices.ts @@ -486,9 +486,14 @@ export class BattleChoiceBuilder { throw new Error(`That Pokémon is already in battle!`); } const target = request.side.pokemon[current.targetPokemon - 1]; + const isReviving = this.request.side?.pokemon!.some(p => p.reviving); if (!target) { throw new Error(`Couldn't find Pokémon "${choice}" to switch to!`); } + if (isReviving && target.fainted) return current; + if (isReviving && !target.fainted) { + throw new Error(`${target.name} still has energy to battle!`); + } if (target.fainted) { throw new Error(`${target.name} is fainted and cannot battle!`); } diff --git a/play.pokemonshowdown.com/src/battle.ts b/play.pokemonshowdown.com/src/battle.ts index 91154fa6c..9da46ac8c 100644 --- a/play.pokemonshowdown.com/src/battle.ts +++ b/play.pokemonshowdown.com/src/battle.ts @@ -998,6 +998,7 @@ export interface ServerPokemon extends PokemonDetails, PokemonHealth { details: string; condition: string; active: boolean; + reviving: boolean; /** unboosted stats */ stats: { atk: number, diff --git a/play.pokemonshowdown.com/src/panel-battle.tsx b/play.pokemonshowdown.com/src/panel-battle.tsx index 65aec7959..c2bb76f08 100644 --- a/play.pokemonshowdown.com/src/panel-battle.tsx +++ b/play.pokemonshowdown.com/src/panel-battle.tsx @@ -718,9 +718,11 @@ class BattlePanel extends PSRoomPanel { renderSwitchMenu( request: BattleMoveRequest | BattleSwitchRequest, choices: BattleChoiceBuilder, ignoreTrapping?: boolean ) { + const battle = this.props.room.battle; const numActive = choices.requestLength(); const maybeTrapped = !ignoreTrapping && choices.currentMoveRequest()?.maybeTrapped; const trapped = !ignoreTrapping && !maybeTrapped && choices.currentMoveRequest()?.trapped; + const isReviving = battle.myPokemon!.some(p => p.reviving); return
{maybeTrapped && @@ -729,8 +731,12 @@ class BattlePanel extends PSRoomPanel { {trapped && You're trapped and cannot switch!
} + {isReviving && + Choose a pokemon to revive!
+
} {request.side.pokemon.map((serverPokemon, i) => { - const cantSwitch = trapped || i < numActive || choices.alreadySwitchingIn.includes(i + 1) || serverPokemon.fainted; + let cantSwitch = trapped || i < numActive || choices.alreadySwitchingIn.includes(i + 1) || serverPokemon.fainted; + if (isReviving) cantSwitch = !serverPokemon.fainted; return this.renderPokemonButton({ pokemon: serverPokemon, cmd: `/switch ${i + 1}`,