Skip to content

Commit

Permalink
Rename switchSides -> switchViewpoint
Browse files Browse the repository at this point in the history
New name is a lot clearer.
  • Loading branch information
Zarel committed Oct 29, 2023
1 parent 0dcff6c commit 7305b58
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 25 deletions.
10 changes: 5 additions & 5 deletions js/client-battle.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@
updateControls: function () {
if (this.battle.scene.customControls) return;
var controlsShown = this.controlsShown;
var switchSidesButton = '<p><button class="button" name="switchSides"><i class="fa fa-random"></i> Switch sides</button></p>';
var switchSidesButton = '<p><button class="button" name="switchViewpoint"><i class="fa fa-random"></i> Switch sides</button></p>';
this.controlsShown = false;

if (this.battle.seeking !== null) {
Expand Down Expand Up @@ -1089,14 +1089,14 @@
if (!sideData.id) return;
this.side = sideData.id;
if (this.battle.mySide.sideid !== this.side) {
this.battle.setPerspective(this.side);
this.battle.setViewpoint(this.side);
this.$chat = this.$chatFrame.find('.inner');
}
},
updateSide: function () {
var sideData = this.request.side;
this.battle.myPokemon = sideData.pokemon;
this.battle.setPerspective(sideData.id);
this.battle.setViewpoint(sideData.id);
for (var i = 0; i < sideData.pokemon.length; i++) {
var pokemonData = sideData.pokemon[i];
if (this.request.active && this.request.active[i]) pokemonData.canGmax = this.request.active[i].gigantamax || false;
Expand Down Expand Up @@ -1157,8 +1157,8 @@

e.stopPropagation();
},
switchSides: function () {
this.battle.switchSides();
switchViewpoint: function () {
this.battle.switchViewpoint();
},
pause: function () {
this.tooltips.hideTooltip();
Expand Down
8 changes: 4 additions & 4 deletions js/replay-embed.template.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,9 @@ var Replays = {

if (this.battle.paused) {
var resetDisabled = !this.battle.started ? ' disabled' : '';
this.$('.replay-controls').html('<button data-action="play"><i class="fa fa-play"></i> Play</button><button data-action="reset"' + resetDisabled + '><i class="fa fa-undo"></i> Reset</button> <button data-action="rewind"><i class="fa fa-step-backward"></i> Last turn</button><button data-action="ff"><i class="fa fa-step-forward"></i> Next turn</button> <button data-action="ffto"><i class="fa fa-fast-forward"></i> Go to turn...</button> <button data-action="switchSides"><i class="fa fa-random"></i> Switch sides</button>');
this.$('.replay-controls').html('<button data-action="play"><i class="fa fa-play"></i> Play</button><button data-action="reset"' + resetDisabled + '><i class="fa fa-undo"></i> Reset</button> <button data-action="rewind"><i class="fa fa-step-backward"></i> Last turn</button><button data-action="ff"><i class="fa fa-step-forward"></i> Next turn</button> <button data-action="ffto"><i class="fa fa-fast-forward"></i> Go to turn...</button> <button data-action="switchViewpoint"><i class="fa fa-random"></i> Switch sides</button>');
} else {
this.$('.replay-controls').html('<button data-action="pause"><i class="fa fa-pause"></i> Pause</button><button data-action="reset"><i class="fa fa-undo"></i> Reset</button> <button data-action="rewind"><i class="fa fa-step-backward"></i> Last turn</button><button data-action="ff"><i class="fa fa-step-forward"></i> Next turn</button> <button data-action="ffto"><i class="fa fa-fast-forward"></i> Go to turn...</button> <button data-action="switchSides"><i class="fa fa-random"></i> Switch sides</button>');
this.$('.replay-controls').html('<button data-action="pause"><i class="fa fa-pause"></i> Pause</button><button data-action="reset"><i class="fa fa-undo"></i> Reset</button> <button data-action="rewind"><i class="fa fa-step-backward"></i> Last turn</button><button data-action="ff"><i class="fa fa-step-forward"></i> Next turn</button> <button data-action="ffto"><i class="fa fa-fast-forward"></i> Go to turn...</button> <button data-action="switchViewpoint"><i class="fa fa-random"></i> Switch sides</button>');
}
},
pause: function () {
Expand All @@ -200,8 +200,8 @@ var Replays = {
if (isNaN(turn) || turn < 0) alert("Invalid turn");
this.battle.seekTurn(turn);
},
switchSides: function () {
this.battle.switchSides();
switchViewpoint: function () {
this.battle.switchViewpoint();
},
};

Expand Down
8 changes: 4 additions & 4 deletions replays/js/replay.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,9 @@ var ReplayPanel = Panels.StaticPanel.extend({

if (this.battle.paused) {
var resetDisabled = !this.battle.started ? ' disabled' : '';
this.$('.replay-controls').html('<button data-action="play"><i class="fa fa-play"></i> Play</button><button data-action="reset"' + resetDisabled + '><i class="fa fa-undo"></i> Reset</button> <button data-action="rewind"><i class="fa fa-step-backward"></i> Last turn</button><button data-action="ff"><i class="fa fa-step-forward"></i> Next turn</button> <button data-action="ffto"><i class="fa fa-fast-forward"></i> Go to turn...</button> <button data-action="switchSides"><i class="fa fa-random"></i> Switch sides</button>');
this.$('.replay-controls').html('<button data-action="play"><i class="fa fa-play"></i> Play</button><button data-action="reset"' + resetDisabled + '><i class="fa fa-undo"></i> Reset</button> <button data-action="rewind"><i class="fa fa-step-backward"></i> Last turn</button><button data-action="ff"><i class="fa fa-step-forward"></i> Next turn</button> <button data-action="ffto"><i class="fa fa-fast-forward"></i> Go to turn...</button> <button data-action="switchViewpoint"><i class="fa fa-random"></i> Switch sides</button>');
} else {
this.$('.replay-controls').html('<button data-action="pause"><i class="fa fa-pause"></i> Pause</button><button data-action="reset"><i class="fa fa-undo"></i> Reset</button> <button data-action="rewind"><i class="fa fa-step-backward"></i> Last turn</button><button data-action="ff"><i class="fa fa-step-forward"></i> Next turn</button> <button data-action="ffto"><i class="fa fa-fast-forward"></i> Go to turn...</button> <button data-action="switchSides"><i class="fa fa-random"></i> Switch sides</button>');
this.$('.replay-controls').html('<button data-action="pause"><i class="fa fa-pause"></i> Pause</button><button data-action="reset"><i class="fa fa-undo"></i> Reset</button> <button data-action="rewind"><i class="fa fa-step-backward"></i> Last turn</button><button data-action="ff"><i class="fa fa-step-forward"></i> Next turn</button> <button data-action="ffto"><i class="fa fa-fast-forward"></i> Go to turn...</button> <button data-action="switchViewpoint"><i class="fa fa-random"></i> Switch sides</button>');
}
},
clickReplayDownloadButton: function (e) {
Expand Down Expand Up @@ -216,8 +216,8 @@ var ReplayPanel = Panels.StaticPanel.extend({
if (isNaN(turn) || turn < 0) alert("Invalid turn");
this.battle.seekTurn(turn);
},
switchSides: function() {
this.battle.switchSides();
switchViewpoint: function() {
this.battle.switchViewpoint();
},
remove: function() {
this.battle.destroy();
Expand Down
2 changes: 1 addition & 1 deletion src/battle-animations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -792,7 +792,7 @@ export class BattleScene implements BattleSceneStub {
let newBGNum = 0;
for (let siden = 0; siden < 2 || (this.battle.gameType === 'multi' && siden < 4); siden++) {
let side = this.battle.sides[siden];
const spriteIndex = +this.battle.sidesSwitched ^ (siden % 2);
const spriteIndex = +this.battle.viewpointSwitched ^ (siden % 2);
let textBuf = '';
let buf = '';
let buf2 = '';
Expand Down
2 changes: 1 addition & 1 deletion src/battle-tooltips.ts
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ class BattleTooltips {
// mouse over active pokemon
// pokemon definitely exists, serverPokemon maybe
let sideIndex = parseInt(args[1], 10);
let side = this.battle.sides[+this.battle.sidesSwitched ^ sideIndex];
let side = this.battle.sides[+this.battle.viewpointSwitched ^ sideIndex];
let activeIndex = parseInt(args[2], 10);
let pokemonIndex = activeIndex;
if (activeIndex >= 1 && this.battle.sides.length > 2) {
Expand Down
12 changes: 6 additions & 6 deletions src/battle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1011,7 +1011,7 @@ export interface ServerPokemon extends PokemonDetails, PokemonHealth {
export class Battle {
scene: BattleSceneStub;

sidesSwitched = false;
viewpointSwitched = false;

stepQueue: string[];
/** See battle.instantAdd */
Expand Down Expand Up @@ -1303,22 +1303,22 @@ export class Battle {
resetToCurrentTurn() {
this.seekTurn(this.ended ? Infinity : this.turn, true);
}
switchSides() {
this.setPerspective(this.sidesSwitched ? 'p1' : 'p2');
switchViewpoint() {
this.setViewpoint(this.viewpointSwitched ? 'p1' : 'p2');
}
setPerspective(sideid: SideID) {
setViewpoint(sideid: SideID) {
if (this.mySide.sideid === sideid) return;
if (sideid.length !== 2 || !sideid.startsWith('p')) return;
const side = this[sideid];
if (!side) return;
this.mySide = side;

if ((side.n % 2) === this.p1.n) {
this.sidesSwitched = false;
this.viewpointSwitched = false;
this.nearSide = this.p1;
this.farSide = this.p2;
} else {
this.sidesSwitched = true;
this.viewpointSwitched = true;
this.nearSide = this.p2;
this.farSide = this.p1;
}
Expand Down
4 changes: 2 additions & 2 deletions src/panel-battle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ class BattleRoom extends ChatRoom {
this.update(null);
return true;
} case 'switchsides': {
this.battle.switchSides();
this.battle.switchViewpoint();
return true;
} case 'cancel': case 'undo': {
if (!this.choices || !this.request) {
Expand Down Expand Up @@ -304,7 +304,7 @@ class BattlePanel extends PSRoomPanel<BattleRoom> {

if (request.side) {
room.battle.myPokemon = request.side.pokemon;
room.battle.setPerspective(request.side.id);
room.battle.setViewpoint(request.side.id);
room.side = request.side;
}

Expand Down
4 changes: 2 additions & 2 deletions website/replays/src/replays.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@ class SearchPanel extends preact.Component {
this.submitForm(e);
};
url(replay: ReplayResult) {
const sidesSwitched = (toID(replay.p2) === toID(this.user));
return replay.id + (replay.password ? `-${replay.password}pw` : '') + (sidesSwitched ? '?p2' : '');
const viewpointSwitched = (toID(replay.p2) === toID(this.user));
return replay.id + (replay.password ? `-${replay.password}pw` : '') + (viewpointSwitched ? '?p2' : '');
}
formatid(replay: ReplayResult) {
let formatid = replay.format;
Expand Down

0 comments on commit 7305b58

Please sign in to comment.