mirror of
https://github.com/smogon/pokemon-showdown-client.git
synced 2026-03-21 17:50:29 -05:00
Preact: Fix bug with Revival Blessing (#2487)
Some checks are pending
Node.js CI / build (22.x) (push) Waiting to run
Some checks are pending
Node.js CI / build (22.x) (push) Waiting to run
This commit is contained in:
parent
5b511e2b96
commit
95a720011b
|
|
@ -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!`);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -998,6 +998,7 @@ export interface ServerPokemon extends PokemonDetails, PokemonHealth {
|
|||
details: string;
|
||||
condition: string;
|
||||
active: boolean;
|
||||
reviving: boolean;
|
||||
/** unboosted stats */
|
||||
stats: {
|
||||
atk: number,
|
||||
|
|
|
|||
|
|
@ -718,9 +718,11 @@ class BattlePanel extends PSRoomPanel<BattleRoom> {
|
|||
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 <div class="switchmenu">
|
||||
{maybeTrapped && <em class="movewarning">
|
||||
|
|
@ -729,8 +731,12 @@ class BattlePanel extends PSRoomPanel<BattleRoom> {
|
|||
{trapped && <em class="movewarning">
|
||||
You're <strong>trapped</strong> and cannot switch!<br />
|
||||
</em>}
|
||||
{isReviving && <em class="movewarning">
|
||||
Choose a pokemon to revive!<br />
|
||||
</em>}
|
||||
{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}`,
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user