diff --git a/js/client-battle.js b/js/client-battle.js index b6be21108..25a99232e 100644 --- a/js/client-battle.js +++ b/js/client-battle.js @@ -777,7 +777,17 @@ updateSwitchControls: function (type) { var pos = this.choice.choices.length; - if (type !== 'switchposition' && this.request.forceSwitch !== true && !this.choice.freedomDegrees) { + // Needed so it client does not freak out when only 1 mon left wants to switch out + var atLeast1Reviving = false; + for (var i = 0; i < this.battle.pokemonControlled; i++) { + var pokemon = this.battle.myPokemon[i]; + if (pokemon.reviving) { + atLeast1Reviving = true; + break; + } + } + + if (type !== 'switchposition' && this.request.forceSwitch !== true && (!this.choice.freedomDegrees || atLeast1Reviving)) { while (!this.request.forceSwitch[pos] && pos < 6) { pos = this.choice.choices.push('pass'); } @@ -785,6 +795,7 @@ var switchables = this.request && this.request.side ? this.battle.myPokemon : []; var nearActive = this.battle.nearSide.active; + var isReviving = !!switchables[pos].reviving; var requestTitle = ''; if (type === 'switch2' || type === 'switchposition') { @@ -815,7 +826,9 @@ '' ); } else { - if (this.choice.freedomDegrees >= 1) { + if (isReviving) { + requestTitle += "Choose a fainted Pokémon to revive!"; + } else if (this.choice.freedomDegrees >= 1) { requestTitle += "Choose a Pokémon to send to battle!"; } else { requestTitle += "Switch " + BattleLog.escapeHTML(switchables[pos].name) + " to:"; @@ -825,17 +838,25 @@ for (var i = 0; i < switchables.length; i++) { var pokemon = switchables[i]; var tooltipArgs = 'switchpokemon|' + i; - if (pokemon.fainted || i < this.battle.pokemonControlled || this.choice.switchFlags[i]) { - switchMenu += ' '; } var controls = ( '
' + - '
' + + '
' + '
' + switchMenu + '
' + '
' ); @@ -1221,6 +1242,12 @@ if (!this.choice) return; this.tooltips.hideTooltip(); + if (this.battle.myPokemon[this.choice.choices.length].reviving) { + this.choice.choices.push('switch ' + (parseInt(pos, 10) + 1)); + this.endChoice(); + return; + } + if (pos !== undefined) { // pos === undefined if called by chooseSwitchTarget() this.choice.switchFlags[pos] = true; if (this.choice.freedomDegrees >= 1) { @@ -1292,6 +1319,8 @@ app.addPopupMessage("You are trapped and cannot select " + data[0] + "!"); } else if (data[1] === 'active') { app.addPopupMessage("" + data[0] + " is already in battle!"); + } else if (data[1] === 'notfainted') { + app.addPopupMessage("" + data[0] + " still has energy to battle!"); } else { app.addPopupMessage("" + data[0] + " is already selected!"); } diff --git a/src/battle.ts b/src/battle.ts index a94f6b044..61a3fe41b 100644 --- a/src/battle.ts +++ b/src/battle.ts @@ -1719,6 +1719,18 @@ export class Battle { case 'wish': this.scene.runResidualAnim('wish' as ID, poke); break; + case 'revivalblessing': + this.scene.runResidualAnim('wish' as ID, poke); + const {siden} = this.parsePokemonId(args[1]); + const side = this.sides[siden]; + poke.fainted = false; + poke.status = ''; + this.scene.updateSidebar(side); + // Revived while still on the field + if (!side.active[poke.slot]) { + poke.side.replace(poke); + } + break; } } this.scene.runOtherAnim('heal' as ID, [poke]);