diff --git a/.eslintrc.js b/.eslintrc.js index f36320e75..46806b19b 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,7 +1,5 @@ 'use strict'; -const os = require('os'); - module.exports = { "root": true, "parserOptions": { diff --git a/js/client-battle-tooltips.js b/js/client-battle-tooltips.js index 3ee2c8e5a..ec909145c 100644 --- a/js/client-battle-tooltips.js +++ b/js/client-battle-tooltips.js @@ -441,8 +441,8 @@ var BattleTooltips = (function () { } text += '
'; } else if (pokemonData.item) { - item = Tools.getItem(pokemonData.item).name; - text += 'Item: ' + item + '
'; + var itemName = Tools.getItem(pokemonData.item).name; + text += 'Item: ' + itemName + '
'; } text += '' + pokemonData.stats['atk'] + ' Atk / ' + pokemonData.stats['def'] + ' Def / ' + pokemonData.stats['spa']; if (this.battle.gen === 1) { @@ -868,28 +868,20 @@ var BattleTooltips = (function () { } // Weather and pseudo-weather type changes. if (move.id === 'weatherball' && this.battle.weather) { - var noWeatherAbility = false; - // Check if your side has an anti weather ability to skip this. - if (!noWeatherAbility) { - for (var i = 0; i < this.battle.mySide.active.length; i++) { - if (this.battle.mySide.active[i] && this.battle.mySide.active[i].ability in {'Air Lock': 1, 'Cloud Nine': 1}) { - noWeatherAbility = true; - break; - } - } - } - // If you don't, check if the opponent has it afterwards. - if (!noWeatherAbility) { - for (var i = 0; i < this.battle.yourSide.active.length; i++) { - if (this.battle.yourSide.active[i] && this.battle.yourSide.active[i].ability in {'Air Lock': 1, 'Cloud Nine': 1}) { - noWeatherAbility = true; - break; + var antiWeatherAbility = false; + // Check if there's an anti weather ability to skip this. + abilitySearch: for (var i = 0; i < this.battle.sides.length; i++) { + var side = this.battle.sides[i]; + for (var j = 0; j < side.active.length; j++) { + if (side.active[j] && ['Air Lock', 'Cloud Nine'].includes(side.active[j].ability)) { + antiWeatherAbility = true; + break abilitySearch; } } } // If the weather is indeed active, check it to see what move type weatherball gets. - if (!noWeatherAbility) { + if (!antiWeatherAbility) { if (this.battle.weather === 'sunnyday' || this.battle.weather === 'desolateland') moveType = 'Fire'; if (this.battle.weather === 'raindance' || this.battle.weather === 'primordialsea') moveType = 'Water'; if (this.battle.weather === 'sandstorm') moveType = 'Rock'; @@ -989,26 +981,18 @@ var BattleTooltips = (function () { if (move.id in table.overrideBP) basePower = table.overrideBP[move.id]; } var basePowerComment = ''; - var noWeatherAbility = false; - // Check if your side has an anti weather ability to skip this. - if (!noWeatherAbility) { - for (var i = 0; i < this.battle.mySide.active.length; i++) { - if (this.battle.mySide.active[i] && this.battle.mySide.active[i].ability in {'Air Lock': 1, 'Cloud Nine': 1}) { - noWeatherAbility = true; - break; + var antiWeatherAbility = false; + // Check if there's an anti weather ability to skip this. + abilitySearch2: for (var i = 0; i < this.battle.sides.length; i++) { + var side = this.battle.sides[i]; + for (var j = 0; j < side.active.length; j++) { + if (side.active[j] && ['Air Lock', 'Cloud Nine'].includes(side.active[j].ability)) { + antiWeatherAbility = true; + break abilitySearch2; } } } - // If you don't, check if the opponent has it afterwards. - if (!noWeatherAbility) { - for (var i = 0; i < this.battle.yourSide.active.length; i++) { - if (this.battle.yourSide.active[i] && this.battle.yourSide.active[i].ability in {'Air Lock': 1, 'Cloud Nine': 1}) { - noWeatherAbility = true; - break; - } - } - } - var thereIsWeather = !!this.battle.weather && !noWeatherAbility; + var thereIsWeather = !!this.battle.weather && !antiWeatherAbility; if (move.id === 'acrobatics') { if (!pokemonData.item) { basePower *= 2; diff --git a/js/client-battle.js b/js/client-battle.js index 6662fde76..7e63640f9 100644 --- a/js/client-battle.js +++ b/js/client-battle.js @@ -323,11 +323,7 @@ }, controlsShown: false, updateControlsForPlayer: function () { - var battle = this.battle; - this.callbackWaiting = true; - var active = this.battle.mySide.active[0]; - if (!active) active = {}; var act = ''; var switchables = []; @@ -904,7 +900,6 @@ return; } request.requestType = 'move'; - var notifyObject = null; if (request.forceSwitch) { request.requestType = 'switch'; } else if (request.teamPreview) { @@ -998,7 +993,6 @@ e.stopPropagation(); }, switchSides: function () { - var paused = this.battle.paused; this.battle.switchSides(); }, pause: function () { @@ -1060,10 +1054,8 @@ var isZMove = !!(this.$('input[name=zmove]')[0] || '').checked; var isUltraBurst = !!(this.$('input[name=ultraburst]')[0] || '').checked; - var move = e.getAttribute('data-move'); var target = e.getAttribute('data-target'); var choosableTargets = {normal: 1, any: 1, adjacentAlly: 1, adjacentAllyOrSelf: 1, adjacentFoe: 1}; - var spreadTargets = {allAdjacentFoes: 1, allAdjacent: 1}; this.choice.choices.push('move ' + pos + (isMega ? ' mega' : '') + (isZMove ? ' zmove' : '') + (isUltraBurst ? ' ultra' : '')); if (myActive.length > 1 && target in choosableTargets) { diff --git a/js/client-chat-tournament.js b/js/client-chat-tournament.js index e85cebf66..384987607 100644 --- a/js/client-chat-tournament.js +++ b/js/client-chat-tournament.js @@ -804,7 +804,7 @@ initialize: function (data) { this.$el.html('
'); }, selectUser: function (user) { diff --git a/js/client-chat.js b/js/client-chat.js index 5f28a439e..b9155ed27 100644 --- a/js/client-chat.js +++ b/js/client-chat.js @@ -860,14 +860,13 @@ case 'join': case 'j': if (noSpace) return text; - var room = toRoomid(target); if (app.rooms[target]) { app.focusRoom(target); return false; } - room = toId(target); - if (app.rooms[room]) { - app.focusRoom(room); + var roomid = toId(target); + if (app.rooms[roomid]) { + app.focusRoom(roomid); return false; } return text; // Send the /join command through to the server. @@ -1182,7 +1181,7 @@ } }, addRow: function (line) { - var name, name2, room, action, silent, oldid; + var name, name2, silent; if (line && typeof line === 'string') { if (line.charAt(0) !== '|') line = '||' + line; var row = line.substr(1).split('|'); @@ -1229,7 +1228,7 @@ if (!matches) { return; // bogus room ID could be used to inject JavaScript } - var format = Tools.escapeFormat(matches ? matches[1] : ''); + var format = Tools.escapeFormat(matches[1]); if (silent && !Tools.prefs('showbattles')) return; @@ -1621,7 +1620,7 @@ return self.comparator(a, b); }); } - for (var i = 0, len = users.length; i < users.length; i++) { + for (var i = 0; i < users.length; i++) { var userid = users[i]; buf += this.constructItem(userid); } diff --git a/js/client-ladder.js b/js/client-ladder.js index 769d66241..5cd7d4ec3 100644 --- a/js/client-ladder.js +++ b/js/client-ladder.js @@ -27,7 +27,6 @@ app.send('/leave ' + this.id); }, addRow: function (line) { - var name, name2, room, action, silent, oldid; if (!line || typeof line !== 'string') return; if (line.charAt(0) !== '|') line = '||' + line; var pipeIndex = line.indexOf('|', 1); diff --git a/js/client-mainmenu.js b/js/client-mainmenu.js index 1736e82cd..cf80f4057 100644 --- a/js/client-mainmenu.js +++ b/js/client-mainmenu.js @@ -657,7 +657,6 @@ if (atLeastOneGen5 && !Tools.loadedSpriteData['bw']) Tools.loadSpriteData('bw'); }, openChallenge: function (name, $pmWindow) { - var userid = toId(name); if (!$pmWindow) $pmWindow = this.openPM(name, true); var $challenge = $pmWindow.find('.challenge'); if (!$challenge.length) { @@ -693,7 +692,6 @@ }, updateTeams: function () { if (!window.BattleFormats) return; - var teams = Storage.teams; var self = this; this.$('button[name=team]').each(function (i, el) { @@ -942,7 +940,6 @@ var curSection = ''; for (var i in BattleFormats) { var format = BattleFormats[i]; - var selected = false; if (selectType === 'teambuilder') { if (!format.isTeambuilderFormat) continue; } else { diff --git a/js/client-teambuilder.js b/js/client-teambuilder.js index b3c819e57..e0ae11207 100644 --- a/js/client-teambuilder.js +++ b/js/client-teambuilder.js @@ -283,6 +283,7 @@ buf += 'Will be ' + Tools.escapeHTML(template.abilities['0']) + ' after Mega Evolving.
']); - template = Tools.getTemplate(template.baseSpecies); + // template is unused after this, so no need to replace } for (var i in BattleAbilities) { if (BattleAbilities[i].isNonstandard) continue; diff --git a/js/storage.js b/js/storage.js index d2018b60c..70ed04aee 100644 --- a/js/storage.js +++ b/js/storage.js @@ -176,7 +176,6 @@ Storage.bg = { var s; var l = (max + min) / 2; if (max === min) { - h = s = 0; return '0, 0%'; } else { var d = max - min; @@ -1260,7 +1259,7 @@ Storage.exportTeam = function (team) { } if (defaultIvs && !hpType) { for (var stat in BattleStatNames) { - if (curSet.ivs[stat] !== 31 && typeof curSet.ivs[stat] !== undefined) { + if (curSet.ivs[stat] !== 31 && curSet.ivs[stat] !== undefined) { defaultIvs = false; break; } @@ -1282,7 +1281,7 @@ Storage.exportTeam = function (team) { if (!first) { text += " \n"; } - if (curSet.moves && curSet.moves) for (var j = 0; j < curSet.moves.length; j++) { + if (curSet.moves) for (var j = 0; j < curSet.moves.length; j++) { var move = curSet.moves[j]; if (move.substr(0, 13) === 'Hidden Power ') { move = move.substr(0, 13) + '[' + move.substr(13) + ']'; @@ -1506,19 +1505,16 @@ Storage.nwDeleteAllTeams = function (callback) { }; Storage.nwDeleteTeamFile = function (filename, callback) { - var self = this; - var line = filename; - if (line.substr(line.length - 4).toLowerCase() === '.txt') { - line = line.substr(0, line.length - 4); - } else { + if (filename.slice(-4).toLowerCase() !== '.txt') { // not a team file - self.nwTeamsLeft--; - if (!self.nwTeamsLeft) { + this.nwTeamsLeft--; + if (!this.nwTeamsLeft) { if (callback) callback(); Storage.fsReady.load(); } return; } + var self = this; fs.unlink(this.dir + 'Teams/' + filename, function (err) { var directory = filename.split('/').slice(0, -1).join('/'); fs.rmdir(directory, function () {}); @@ -1627,7 +1623,6 @@ Storage.nwStopLoggingChat = function () { }; Storage.nwLogChat = function (roomid, line) { roomid = toRoomid(roomid); - var self = this; if (!this.loggingChat) return; var chatLogFdMonth = this.getLogMonth(); if (chatLogFdMonth !== this.chatLogFdMonth) { diff --git a/lib/validate-token.js b/lib/validate-token.js index ed350bef1..c14ad1993 100644 --- a/lib/validate-token.js +++ b/lib/validate-token.js @@ -6,7 +6,6 @@ const CLIENT_ID = '912270888098-jjnre816lsuhc5clj3vbcn4o2q7p4qvk.apps.googleuser const token = process.argv[2]; -var auth = new gal.GoogleAuth(); var client = new gal.OAuth2Client(CLIENT_ID, '', ''); client.verifyIdToken({ idToken: token, @@ -17,7 +16,7 @@ client.verifyIdToken({ function(e, login) { if (e) return console.log(e); var payload = login.getPayload(); - var userid = payload['sub']; + // var userid = payload['sub']; console.log(JSON.stringify(payload)); // If request specified a G Suite domain: //var domain = payload['hd']; diff --git a/src/battle-animations.ts b/src/battle-animations.ts index 46f816559..ac8a09799 100644 --- a/src/battle-animations.ts +++ b/src/battle-animations.ts @@ -320,7 +320,6 @@ class BattleScene { left = 210; top = 245; - scale = 1; scale = 1.5 - 0.5 * ((loc.z!) / 200); if (scale < .1) scale = .1; diff --git a/src/battle-dex.ts b/src/battle-dex.ts index 1809de586..dc79e548e 100644 --- a/src/battle-dex.ts +++ b/src/battle-dex.ts @@ -415,7 +415,7 @@ const Tools = { escapeHTML(str: string, jsEscapeToo?: boolean) { str = getString(str).replace(/&/g, '&').replace(//g, '>').replace(/"/g, '"'); - if (jsEscapeToo) str = str.replace(/'/g, '\\\''); + if (jsEscapeToo) str = str.replace(/\\/g, '\\\\').replace(/'/g, '\\\''); return str; }, @@ -428,12 +428,6 @@ const Tools = { return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&"); }, - escapeQuotes(str: string) { - str = (str ? '' + str : ''); - str = str.replace(/'/g, '\\\''); - return str; - }, - sanitizeHTML: (function () { if (!('html4' in window)) { return function () { diff --git a/src/battle.ts b/src/battle.ts index 23975dcc7..df9d910a3 100644 --- a/src/battle.ts +++ b/src/battle.ts @@ -250,7 +250,6 @@ class Pokemon { delete this.volatiles[volatile]; } addVolatile(volatile: ID, ...args: any[]) { - let battle = this.side.battle; if (this.hasVolatile(volatile) && !args.length) return; this.volatiles[volatile] = [volatile, ...args] as EffectState; this.sprite.addEffect(volatile); @@ -265,7 +264,6 @@ class Pokemon { } addTurnstatus(volatile: ID) { volatile = toId(volatile); - let battle = this.side.battle; this.sprite.addEffect(volatile); if (this.hasTurnstatus(volatile)) return; this.turnstatuses[volatile] = [volatile]; @@ -633,7 +631,7 @@ class Side { this.spriteid = spriteid; } setName(name: string, spriteid?: string | number) { - if (name) this.name = (name || ''); + if (name) this.name = name; this.id = toId(this.name); if (spriteid) { this.spriteid = spriteid; @@ -652,7 +650,6 @@ class Side { return "the opposing team"; } addSideCondition(effect: Effect) { - let elem, curelem; let condition = effect.id; if (this.sideConditions[condition]) { if (condition === 'spikes' || condition === 'toxicspikes') { @@ -709,7 +706,6 @@ class Side { this.battle.scene.removeSideCondition(this.n, id); } newPokemon(data: any, replaceSlot = -1) { - let pokeobj; let poke = new Pokemon(data, this); if (!poke.ability && poke.baseAbility) poke.ability = poke.baseAbility; poke.reset(); @@ -1306,7 +1302,9 @@ class Battle { if (!this.fastForward) { this.scene.upkeepWeather(); } - if (newWeather && newWeather.upkeepMessage) this.message('