diff --git a/js/client-battle.js b/js/client-battle.js index 385e88719..36ab9d14d 100644 --- a/js/client-battle.js +++ b/js/client-battle.js @@ -141,23 +141,40 @@ // battle has ended this.$controls.html('

'); + } else if (!this.battle.mySide.initialized || !this.battle.yourSide.initialized) { + + // empty battle + + if (this.side) { + if (this.battle.kickingInactive) { + this.$controls.html('

← Your opponent has disconnected. This will give them more time to reconnect.

'); + } else { + this.$controls.html('

← Your opponent has disconnected. Click this if they don\'t reconnect.

'); + } + } else { + this.$controls.html('

Waiting for players...

'); + this.$join = $('
'); + this.$battle.append(this.$join); + } + } else if (this.side) { // player - this.controlsShown = true; - if (!controlsShown) this.updateControlsForPlayer(); - - } else if (this.battle.mySide.initialized && this.battle.yourSide.initialized) { - - // full battle - this.$controls.html('

Waiting for players...

'); + if (!this.request) { + if (this.battle.kickingInactive) { + this.$controls.html('

← Your opponent has disconnected. This will give them more time to reconnect.

'); + } else { + this.$controls.html('

← Your opponent has disconnected. Click this if they don\'t reconnect.

'); + } + } else { + this.controlsShown = true; + if (!controlsShown) this.updateControlsForPlayer(); + } } else { - // empty battle + // full battle this.$controls.html('

Waiting for players...

'); - this.$join = $('
'); - this.$battle.append(this.$join); } @@ -167,19 +184,8 @@ }, controlsShown: false, updateControlsForPlayer: function() { - if (!this.request) { - if (this.battle.kickingInactive) { - this.$controls.html('

← Your opponent has disconnected. This will give them more time to reconnect.

'); - } else { - this.$controls.html('

← Your opponent has disconnected. Click this if they don\'t reconnect.

'); - } - } - var battle = this.battle; - // TODO: investigate when to do this - this.updateSide(this.request.side); - // updated trappedness if (false && 'trapped') { var idx = parseInt(moveTarget[1], 10); // moveTarget is a poor name now... @@ -202,6 +208,9 @@ var act = ''; var switchables = []; if (this.request) { + // TODO: investigate when to do this + this.updateSide(this.request.side); + act = this.request.requestType; if (this.request.side) { switchables = this.battle.mySide.pokemon;