diff --git a/app.js b/app.js index 4d9134ce70..6781d8b6e4 100644 --- a/app.js +++ b/app.js @@ -226,7 +226,7 @@ global.ResourceMonitor = { else if (typeof value === 'number') bytes += 8; else if (typeof value === 'object' && objectList.indexOf( value ) === -1) { objectList.push( value ); - for (i in value) stack.push( value[ i ] ); + for (var i in value) stack.push( value[ i ] ); } } diff --git a/battle-engine.js b/battle-engine.js index 47631ec633..09fe0b157e 100644 --- a/battle-engine.js +++ b/battle-engine.js @@ -1046,6 +1046,7 @@ var BattlePokemon = (function() { return this.battle.getNature(this.set.nature); }; BattlePokemon.prototype.addVolatile = function(status, source, sourceEffect) { + var result; if (!this.hp) return false; status = this.battle.getEffect(status); if (this.battle.event) { @@ -1058,7 +1059,7 @@ var BattlePokemon = (function() { return this.battle.singleEvent('Restart', status, this.volatiles[status.id], this, source, sourceEffect); } if (!this.runImmunity(status.id)) return false; - var result = this.battle.runEvent('TryAddVolatile', this, source, sourceEffect, status); + result = this.battle.runEvent('TryAddVolatile', this, source, sourceEffect, status); if (!result) { this.battle.debug('add volatile ['+status.id+'] interrupted'); return result; @@ -1078,7 +1079,7 @@ var BattlePokemon = (function() { if (status.durationCallback) { this.volatiles[status.id].duration = status.durationCallback.call(this.battle, this, source, sourceEffect); } - var result = this.battle.singleEvent('Start', status, this.volatiles[status.id], this, source, sourceEffect); + result = this.battle.singleEvent('Start', status, this.volatiles[status.id], this, source, sourceEffect); if (!result) { // cancel delete this.volatiles[status.id]; @@ -3205,6 +3206,8 @@ var Battle = (function() { return false; }; Battle.prototype.runDecision = function(decision) { + var pokemon; + // returns whether or not we ended in a callback switch (decision.choice) { case 'start': @@ -3220,11 +3223,11 @@ var Battle = (function() { this.switchIn(this.p2.pokemon[pos], pos); } for (var pos=0; pos=0; i--) { if (id === this.chatRooms[i].id) { @@ -379,7 +379,7 @@ var GlobalRoom = (function() { } }; GlobalRoom.prototype.removeChatRoom = function(id) { - var id = toId(id); + id = toId(id); var room = rooms[id]; if (!room) return false; // room doesn't exist room.destroy(); @@ -620,13 +620,14 @@ var BattleRoom = (function() { var oldacre = Math.round(data.p1rating.oldacre); var acre = Math.round(data.p1rating.acre); - var reasons = ''+(acre-oldacre)+' for '+(p1score>.99?'winning':(p1score<.01?'losing':'tying')); + var reasons = ''+(acre-oldacre)+' for '+(p1score>0.99?'winning':(p1score<0.01?'losing':'tying')); if (reasons.substr(0,1) !== '-') reasons = '+'+reasons; self.addRaw(sanitize(p1)+'\'s rating: '+oldacre+' → '+acre+'
('+reasons+')'); - var oldacre = Math.round(data.p2rating.oldacre); - var acre = Math.round(data.p2rating.acre); - var reasons = ''+(acre-oldacre)+' for '+(p1score>.99?'losing':(p1score<.01?'winning':'tying')); + oldacre = Math.round(data.p2rating.oldacre); + acre = Math.round(data.p2rating.acre); + reasons = ''+(acre-oldacre)+' for '+(p1score>0.99?'losing':(p1score<0.01?'winning':'tying')); + reasons = ''+(acre-oldacre)+' for '+(p1score>0.99?'losing':(p1score<0.01?'winning':'tying')); if (reasons.substr(0,1) !== '-') reasons = '+'+reasons; self.addRaw(sanitize(p2)+'\'s rating: '+oldacre+' → '+acre+'
('+reasons+')'); @@ -1056,7 +1057,7 @@ var BattleRoom = (function() { this.kickInactiveUpdate(); }; BattleRoom.prototype.joinBattle = function(user, team) { - var slot = undefined; + var slot; if (this.rated) { if (this.rated.p1 === user.userid) { slot = 0; diff --git a/simulator.js b/simulator.js index 9606b67c7e..b4b685b7c5 100644 --- a/simulator.js +++ b/simulator.js @@ -137,6 +137,7 @@ var Simulator = (function(){ Simulator.prototype.rqid = ''; Simulator.prototype.inactiveQueued = false; Simulator.prototype.receive = function(lines) { + var player; ResourceMonitor.activeIp = this.activeIp; switch (lines[1]) { case 'update': @@ -159,14 +160,14 @@ var Simulator = (function(){ break; case 'callback': - var player = this.getPlayer(lines[2]); + player = this.getPlayer(lines[2]); if (player) { player.sendTo(this.id, '|callback|' + lines[3]); } break; case 'request': - var player = this.getPlayer(lines[2]); + player = this.getPlayer(lines[2]); var rqid = lines[3]; if (player) { this.requests[player.userid] = lines[4]; diff --git a/team-validator.js b/team-validator.js index 9409fd6f71..e0549a223b 100644 --- a/team-validator.js +++ b/team-validator.js @@ -720,10 +720,11 @@ var Validator = (function() { if (sourcesBefore || lsetData.sourcesBefore) { // having sourcesBefore is the equivalent of having everything before that gen // in sources, so we fill the other array in preparation for intersection + var learned; if (sourcesBefore && lsetData.sources) { if (!sources) sources = []; for (var i=0, len=lsetData.sources.length; i 0) { var plusPlusPos = subformat.banlist[i].indexOf('++'); if (plusPlusPos && plusPlusPos > 0) { - var complexList = subformat.banlist[i].split('++'); + complexList = subformat.banlist[i].split('++'); for (var j=0; j