Fix multi battles not working on mobile

This commit is contained in:
Guangcong Luo
2021-04-02 22:15:27 -04:00
parent f3d8f67786
commit 4b07cce615
2 changed files with 9 additions and 5 deletions

View File

@@ -640,7 +640,7 @@
if (move.id === 'Recharge') move.type = '–';
if (name.substr(0, 12) === 'Hidden Power') name = 'Hidden Power';
var moveType = this.tooltips.getMoveType(move, typeValueTracker)[0];
var tooltipArgs = 'move|' + moveData.move + '|' + activePos;
var tooltipArgs = 'move|' + moveData.move + '|' + pos;
if (moveData.disabled) {
movebuttons += '<button disabled="disabled" class="has-tooltip" data-tooltip="' + BattleLog.escapeHTML(tooltipArgs) + '">';
} else {

View File

@@ -199,10 +199,12 @@ class BattleTooltips {
$elem.on('touchstart', '.has-tooltip', e => {
e.preventDefault();
this.holdLockTooltipEvent(e);
if (e.currentTarget === BattleTooltips.parentElem && BattleTooltips.parentElem!.tagName === 'BUTTON') {
$(BattleTooltips.parentElem!).addClass('pressed');
BattleTooltips.isPressed = true;
if (!BattleTooltips.parentElem) {
// should never happen, but in case there's a bug in the tooltip handler
BattleTooltips.parentElem = e.currentTarget;
}
$(BattleTooltips.parentElem!).addClass('pressed');
BattleTooltips.isPressed = true;
});
$elem.on('touchend', '.has-tooltip', e => {
e.preventDefault();
@@ -272,7 +274,9 @@ class BattleTooltips {
case 'maxmove': { // move|MOVE|ACTIVEPOKEMON|[GMAXMOVE]
let move = this.battle.dex.getMove(args[1]);
let teamIndex = parseInt(args[2], 10);
let pokemon = this.battle.nearSide.active[teamIndex + this.battle.pokemonControlled * Math.floor(this.battle.mySide!.n / 2)];
let pokemon = this.battle.nearSide.active[
teamIndex + this.battle.pokemonControlled * Math.floor(this.battle.mySide.n / 2)
];
let gmaxMove = args[3] ? this.battle.dex.getMove(args[3]) : undefined;
if (!pokemon) return false;
let serverPokemon = this.battle.myPokemon![teamIndex];