mirror of
https://github.com/smogon/pokemon-showdown-client.git
synced 2026-05-09 04:23:01 -05:00
Allow spectators to switch sides
This commit is contained in:
parent
294efc0f4b
commit
660d4e1619
|
|
@ -2647,6 +2647,7 @@ var Battle = (function () {
|
|||
if (this.turnCallback) this.turnCallback(this);
|
||||
if (this.fastForward > -1 && turnnum >= this.fastForward) {
|
||||
this.fastForwardOff();
|
||||
if (this.endCallback) this.endCallback(this);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -189,7 +189,12 @@
|
|||
} else if (this.battle.playbackState === 2 || this.battle.playbackState === 3) {
|
||||
|
||||
// battle is playing or paused
|
||||
this.$controls.html('<p><button name="skipTurn">Skip turn <i class="fa fa-step-forward"></i></button><button name="goToEnd">Go to last turn <i class="fa fa-fast-forward"></i></button></p>');
|
||||
if (this.side) {
|
||||
// is a player
|
||||
this.$controls.html('<p><button name="skipTurn">Skip turn <i class="fa fa-step-forward"></i></button><button name="goToEnd">Go to last turn <i class="fa fa-fast-forward"></i></button></p>');
|
||||
} else {
|
||||
this.$controls.html('<p><button name="switchSides">Switch sides <i class="fa fa-random"></i></button> <button name="skipTurn">Skip turn <i class="fa fa-step-forward"></i></button> <button name="goToEnd">Go to last turn <i class="fa fa-fast-forward"></i></button></p>');
|
||||
}
|
||||
return;
|
||||
|
||||
}
|
||||
|
|
@ -225,7 +230,7 @@
|
|||
// was a player
|
||||
this.$controls.html('<div class="controls"><p><em><button name="instantReplay"><i class="fa fa-undo"></i> Instant Replay</button> <button name="saveReplay"><i class="fa fa-upload"></i> Share replay</button></p><p><button name="closeAndMainMenu"><strong>Main menu</strong><br /><small>(closes this battle)</small></button> <button name="closeAndRematch"><strong>Rematch</strong><br /><small>(closes this battle)</small></button></p></div>');
|
||||
} else {
|
||||
this.$controls.html('<div class="controls"><p><em><button name="instantReplay"><i class="fa fa-undo"></i> Instant Replay</button> <button name="saveReplay"><i class="fa fa-upload"></i> Share replay</button></p></div>');
|
||||
this.$controls.html('<div class="controls"><p><em><button name="switchSides">Switch sides <i class="fa fa-random"></i></button> <button name="instantReplay"><i class="fa fa-undo"></i> Instant Replay</button> <button name="saveReplay"><i class="fa fa-upload"></i> Share replay</button></p></div>');
|
||||
}
|
||||
|
||||
} else if (!this.battle.mySide.initialized || !this.battle.yourSide.initialized) {
|
||||
|
|
@ -264,7 +269,7 @@
|
|||
} else {
|
||||
|
||||
// full battle
|
||||
this.$controls.html('<p><em>Waiting for players...</em></p>');
|
||||
this.$controls.html('<p><em><button name="switchSides">Switch sides <i class="fa fa-random"></i></button> Waiting for players...</em></p>');
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -704,6 +709,19 @@
|
|||
saveReplay: function () {
|
||||
this.send('/savereplay');
|
||||
},
|
||||
switchSides: function () {
|
||||
if (this.battle.done) {
|
||||
this.battle.reset(true);
|
||||
this.battle.switchSides();
|
||||
this.battle.fastForwardTo(-1);
|
||||
} else {
|
||||
var turn = this.battle.turn;
|
||||
this.battle.reset();
|
||||
this.battle.switchSides();
|
||||
if (turn) this.battle.fastForwardTo(turn);
|
||||
this.battle.play();
|
||||
}
|
||||
},
|
||||
instantReplay: function () {
|
||||
this.hideTooltip();
|
||||
this.request = null;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user