From 7305b5892b671dea06ad828e2c4c7cf946f5ca6e Mon Sep 17 00:00:00 2001 From: Guangcong Luo Date: Sun, 29 Oct 2023 04:44:30 +0000 Subject: [PATCH] Rename switchSides -> switchViewpoint New name is a lot clearer. --- js/client-battle.js | 10 +++++----- js/replay-embed.template.js | 8 ++++---- replays/js/replay.js | 8 ++++---- src/battle-animations.ts | 2 +- src/battle-tooltips.ts | 2 +- src/battle.ts | 12 ++++++------ src/panel-battle.tsx | 4 ++-- website/replays/src/replays.tsx | 4 ++-- 8 files changed, 25 insertions(+), 25 deletions(-) diff --git a/js/client-battle.js b/js/client-battle.js index a5b09a7bbc..29887a22c1 100644 --- a/js/client-battle.js +++ b/js/client-battle.js @@ -260,7 +260,7 @@ updateControls: function () { if (this.battle.scene.customControls) return; var controlsShown = this.controlsShown; - var switchSidesButton = '

'; + var switchSidesButton = '

'; this.controlsShown = false; if (this.battle.seeking !== null) { @@ -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; @@ -1157,8 +1157,8 @@ e.stopPropagation(); }, - switchSides: function () { - this.battle.switchSides(); + switchViewpoint: function () { + this.battle.switchViewpoint(); }, pause: function () { this.tooltips.hideTooltip(); diff --git a/js/replay-embed.template.js b/js/replay-embed.template.js index 97b88b574c..6b372e5ed7 100644 --- a/js/replay-embed.template.js +++ b/js/replay-embed.template.js @@ -172,9 +172,9 @@ var Replays = { if (this.battle.paused) { var resetDisabled = !this.battle.started ? ' disabled' : ''; - this.$('.replay-controls').html(' '); + this.$('.replay-controls').html(' '); } else { - this.$('.replay-controls').html(' '); + this.$('.replay-controls').html(' '); } }, pause: function () { @@ -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(); }, }; diff --git a/replays/js/replay.js b/replays/js/replay.js index e4613e2643..6c9da9a3bd 100644 --- a/replays/js/replay.js +++ b/replays/js/replay.js @@ -170,9 +170,9 @@ var ReplayPanel = Panels.StaticPanel.extend({ if (this.battle.paused) { var resetDisabled = !this.battle.started ? ' disabled' : ''; - this.$('.replay-controls').html(' '); + this.$('.replay-controls').html(' '); } else { - this.$('.replay-controls').html(' '); + this.$('.replay-controls').html(' '); } }, clickReplayDownloadButton: function (e) { @@ -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(); diff --git a/src/battle-animations.ts b/src/battle-animations.ts index 83e610d8f4..a6b5197979 100644 --- a/src/battle-animations.ts +++ b/src/battle-animations.ts @@ -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 = ''; diff --git a/src/battle-tooltips.ts b/src/battle-tooltips.ts index 7fac90c13e..88c8a2512c 100644 --- a/src/battle-tooltips.ts +++ b/src/battle-tooltips.ts @@ -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) { diff --git a/src/battle.ts b/src/battle.ts index 5217a3520a..b570615e8c 100644 --- a/src/battle.ts +++ b/src/battle.ts @@ -1011,7 +1011,7 @@ export interface ServerPokemon extends PokemonDetails, PokemonHealth { export class Battle { scene: BattleSceneStub; - sidesSwitched = false; + viewpointSwitched = false; stepQueue: string[]; /** See battle.instantAdd */ @@ -1303,10 +1303,10 @@ 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]; @@ -1314,11 +1314,11 @@ export class Battle { 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; } diff --git a/src/panel-battle.tsx b/src/panel-battle.tsx index 431f057f85..3c9c0d8783 100644 --- a/src/panel-battle.tsx +++ b/src/panel-battle.tsx @@ -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) { @@ -304,7 +304,7 @@ class BattlePanel extends PSRoomPanel { 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; } diff --git a/website/replays/src/replays.tsx b/website/replays/src/replays.tsx index 77de7f8570..97d0e1a831 100644 --- a/website/replays/src/replays.tsx +++ b/website/replays/src/replays.tsx @@ -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;