From 3604dd88dd9db79d0e2cf98d4c6bac5f0442628d Mon Sep 17 00:00:00 2001 From: Leonard Craft III Date: Mon, 5 Apr 2021 22:50:09 -0500 Subject: [PATCH] Fix display of move choices (#1743) Co-authored-by: Guangcong Luo --- js/client-battle.js | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/js/client-battle.js b/js/client-battle.js index 1d40d539b..486365d96 100644 --- a/js/client-battle.js +++ b/js/client-battle.js @@ -901,21 +901,20 @@ leads.push(myPokemon[this.choice.teamPreview[i] - 1].speciesForme); } buf += leads.join(', ') + ' will be sent out first.
'; - } else if (this.choice.choices && this.request) { - var myActive = this.battle.myPokemon; - for (var i = 0; i < (this.battle.myPokemon || this.choice.choices.length); i++) { + } else if (this.choice.choices && this.request && this.battle.myPokemon) { + var myPokemon = this.battle.myPokemon; + for (var i = 0; i < this.choice.choices.length; i++) { var parts = this.choice.choices[i].split(' '); switch (parts[0]) { case 'move': var move; - myActive = this.battle.nearSide.active; if (this.request.active[i].maxMoves && !this.request.active[i].canDynamax) { // it's a max move move = this.request.active[i].maxMoves.maxMoves[parseInt(parts[1], 10) - 1].move; } else { // it's a normal move move = this.request.active[i].moves[parseInt(parts[1], 10) - 1].move; } var target = ''; - buf += myActive[i].speciesForme + ' will '; + buf += myPokemon[i].speciesForme + ' will '; if (parts.length > 2) { var targetPos = parts[2]; if (targetPos === 'mega') { @@ -933,30 +932,30 @@ } if (targetPos) { var targetActive = this.battle.farSide.active; - // Targeting your own side in doubles / triples if (targetPos < 0) { - targetActive = myActive; + // Targeting your own side in doubles / triples + targetActive = this.battle.nearSide.active; targetPos = -targetPos; target += 'your '; } if (targetActive[targetPos - 1]) { target += targetActive[targetPos - 1].speciesForme; } else { - target = ''; // targeting an empty slot + target += 'slot ' + targetPos; // targeting an empty slot } } } - buf += 'use ' + Dex.getMove(move).name + (target ? ' against ' + target : '') + '.
'; + buf += 'use ' + Dex.getMove(move).name + (target ? ' at ' + target : '') + '.
'; break; case 'switch': - buf += '' + this.battle.myPokemon[parts[1] - 1].speciesForme + ' will switch in'; - if (myActive[i]) { - buf += ', replacing ' + myActive[i].speciesForme; + buf += '' + myPokemon[parts[1] - 1].speciesForme + ' will switch in'; + if (myPokemon[i]) { + buf += ', replacing ' + myPokemon[i].speciesForme; } buf += '.
'; break; case 'shift': - buf += myActive[i].speciesForme + ' will shift position.
'; + buf += myPokemon[i].speciesForme + ' will shift position.
'; break; } }