diff --git a/app.js b/app.js
index 1521d0fa82..3b53beb884 100644
--- a/app.js
+++ b/app.js
@@ -134,18 +134,18 @@ global.ResourceMonitor = {
*/
log: function(text) {
console.log(text);
- if (Rooms.rooms.staff) Rooms.rooms.staff.add('||'+text);
+ if (Rooms.rooms.staff) Rooms.rooms.staff.add('||' + text);
},
countConnection: function(ip, name) {
var now = Date.now();
var duration = now - this.connectionTimes[ip];
- name = (name ? ': '+name : '');
- if (ip in this.connections && duration < 30*60*1000) {
+ name = (name ? ': ' + name : '');
+ if (ip in this.connections && duration < 30 * 60 * 1000) {
this.connections[ip]++;
- if (duration < 5*60*1000 && this.connections[ip] % 20 === 0) {
- this.log('[ResourceMonitor] IP '+ip+' has connected '+this.connections[ip]+' times in the last '+duration.duration()+name);
- } else if (this.connections[ip] % 60 == 0) {
- this.log('[ResourceMonitor] IP '+ip+' has connected '+this.connections[ip]+' times in the last '+duration.duration()+name);
+ if (duration < 5 * 60 * 1000 && this.connections[ip] % 20 === 0) {
+ this.log('[ResourceMonitor] IP ' + ip + ' has connected ' + this.connections[ip] + ' times in the last ' + duration.duration() + name);
+ } else if (this.connections[ip] % 60 === 0) {
+ this.log('[ResourceMonitor] IP ' + ip + ' has connected ' + this.connections[ip] + ' times in the last ' + duration.duration() + name);
}
} else {
this.connections[ip] = 1;
@@ -158,13 +158,13 @@ global.ResourceMonitor = {
countBattle: function(ip, name) {
var now = Date.now();
var duration = now - this.battleTimes[ip];
- name = (name ? ': '+name : '');
- if (ip in this.battles && duration < 30*60*1000) {
+ name = (name ? ': ' + name : '');
+ if (ip in this.battles && duration < 30 * 60 * 1000) {
this.battles[ip]++;
- if (duration < 5*60*1000 && this.battles[ip] % 15 == 0) {
- this.log('[ResourceMonitor] IP '+ip+' has battled '+this.battles[ip]+' times in the last '+duration.duration()+name);
- } else if (this.battles[ip] % 75 == 0) {
- this.log('[ResourceMonitor] IP '+ip+' has battled '+this.battles[ip]+' times in the last '+duration.duration()+name);
+ if (duration < 5 * 60 * 1000 && this.battles[ip] % 15 === 0) {
+ this.log('[ResourceMonitor] IP ' + ip + ' has battled ' + this.battles[ip] + ' times in the last ' + duration.duration() + name);
+ } else if (this.battles[ip] % 75 === 0) {
+ this.log('[ResourceMonitor] IP ' + ip + ' has battled ' + this.battles[ip] + ' times in the last ' + duration.duration() + name);
}
} else {
this.battles[ip] = 1;
@@ -177,7 +177,7 @@ global.ResourceMonitor = {
countPrepBattle: function(ip) {
var now = Date.now();
var duration = now - this.battlePrepTimes[ip];
- if (ip in this.battlePreps && duration < 3*60*1000) {
+ if (ip in this.battlePreps && duration < 3 * 60 * 1000) {
this.battlePreps[ip]++;
if (this.battlePreps[ip] > 6) {
return true;
@@ -202,7 +202,7 @@ global.ResourceMonitor = {
writeNetworkUse: function() {
var buf = '';
for (var i in this.networkUse) {
- buf += ''+this.networkUse[i]+'\t'+this.networkCount[i]+'\t'+i+'\n';
+ buf += '' + this.networkUse[i] + '\t' + this.networkCount[i] + '\t' + i + '\n';
}
fs.writeFile('logs/networkuse.tsv', buf);
},
@@ -237,28 +237,28 @@ global.ResourceMonitor = {
countCmd: function(ip, name) {
var now = Date.now();
var duration = now - this.cmdsTimes[ip];
- name = (name ? ': '+name : '');
+ name = (name ? ': ' + name : '');
if (!this.cmdsTotal) this.cmdsTotal = {lastCleanup: 0, count: 0};
- if (now - this.cmdsTotal.lastCleanup > 60*1000) {
+ if (now - this.cmdsTotal.lastCleanup > 60 * 1000) {
this.cmdsTotal.count = 0;
this.cmdsTotal.lastCleanup = now;
}
this.cmdsTotal.count++;
- if (ip in this.cmds && duration < 60*1000) {
+ if (ip in this.cmds && duration < 60 * 1000) {
this.cmds[ip]++;
- if (duration < 60*1000 && this.cmds[ip] % 5 === 0) {
+ if (duration < 60 * 1000 && this.cmds[ip] % 5 === 0) {
if (this.cmds[ip] >= 3) {
- if (this.cmds[ip] % 30 === 0) this.log('CMD command from '+ip+' blocked for '+this.cmds[ip]+'th use in the last '+duration.duration()+name);
+ if (this.cmds[ip] % 30 === 0) this.log('CMD command from ' + ip + ' blocked for ' + this.cmds[ip] + 'th use in the last ' + duration.duration() + name);
return true;
}
- this.log('[ResourceMonitor] IP '+ip+' has used CMD command '+this.cmds[ip]+' times in the last '+duration.duration()+name);
+ this.log('[ResourceMonitor] IP ' + ip + ' has used CMD command ' + this.cmds[ip] + ' times in the last ' + duration.duration() + name);
} else if (this.cmds[ip] % 15 === 0) {
- this.log('CMD command from '+ip+' blocked for '+this.cmds[ip]+'th use in the last '+duration.duration()+name);
+ this.log('CMD command from ' + ip + ' blocked for ' + this.cmds[ip] + 'th use in the last ' + duration.duration() + name);
return true;
}
} else if (this.cmdsTotal.count > 8000) {
// One CMD check per user per minute on average (to-do: make this better)
- this.log('CMD command for '+ip+' blocked because CMD has been used '+this.cmdsTotal.count+' times in the last minute.');
+ this.log('CMD command for ' + ip + ' blocked because CMD has been used ' + this.cmdsTotal.count + ' times in the last minute.');
return true;
} else {
this.cmds[ip] = 1;
@@ -308,7 +308,7 @@ global.toId = function(text) {
global.toName = function(name) {
name = string(name);
name = name.replace(/[\|\s\[\]\,]+/g, ' ').trim();
- if (name.length > 18) name = name.substr(0,18).trim();
+ if (name.length > 18) name = name.substr(0, 18).trim();
return name;
};
@@ -317,7 +317,7 @@ global.toName = function(name) {
* If strEscape is true, escapes it for JavaScript, too
*/
global.sanitize = function(str, strEscape) {
- str = (''+(str||''));
+ str = ('' + (str || ''));
str = str.escapeHTML();
if (strEscape) str = str.replace(/'/g, '\\\'');
return str;
@@ -325,12 +325,12 @@ global.sanitize = function(str, strEscape) {
/**
* Safely ensures the passed variable is a string
- * Simply doing ''+str can crash if str.toString crashes or isn't a function
+ * Simply doing '' + str can crash if str.toString crashes or isn't a function
* If we're expecting a string and being given anything that isn't a string
* or a number, it's safe to assume it's an error, and return ''
*/
global.string = function(str) {
- if (typeof str === 'string' || typeof str === 'number') return ''+str;
+ if (typeof str === 'string' || typeof str === 'number') return '' + str;
return '';
};
@@ -371,9 +371,9 @@ if (Config.crashguard) {
quietCrash = quietCrash || ((dateNow - lastCrash) <= 1000 * 60 * 5);
lastCrash = Date.now();
if (quietCrash) return;
- var stack = (""+err.stack).split("\n").slice(0,2).join("
");
+ var stack = ("" + err.stack).split("\n").slice(0, 2).join("
");
if (Rooms.lobby) {
- Rooms.lobby.addRaw('
THE SERVER HAS CRASHED: '+stack+'
Please restart the server.
');
+ Rooms.lobby.addRaw('THE SERVER HAS CRASHED: ' + stack + '
Please restart the server.
');
Rooms.lobby.addRaw('You will not be able to talk in the lobby or start new battles until the server restarts.
');
}
Config.modchat = 'crash';
@@ -405,9 +405,9 @@ global.TeamValidator = require('./team-validator.js');
// load ipbans at our leisure
fs.readFile('./config/ipbans.txt', function (err, data) {
if (err) return;
- data = (''+data).split("\n");
+ data = ('' + data).split("\n");
var rangebans = [];
- for (var i=0; i= 0) {
diff --git a/battle-engine.js b/battle-engine.js
index a99e76d6f1..492ea82348 100644
--- a/battle-engine.js
+++ b/battle-engine.js
@@ -18,9 +18,9 @@ if (Config.crashguard) {
// graceful crash - allow current battles to finish before restarting
process.on('uncaughtException', function (err) {
require('./crashlogger.js')(err, 'A simulator process');
- /* var stack = (""+err.stack).split("\n").slice(0,2).join("
");
+ /* var stack = ("" + err.stack).split("\n").slice(0, 2).join("
");
if (Rooms.lobby) {
- Rooms.lobby.addRaw('THE SERVER HAS CRASHED: '+stack+'
Please restart the server.
');
+ Rooms.lobby.addRaw('THE SERVER HAS CRASHED: ' + stack + '
Please restart the server.
');
Rooms.lobby.addRaw('You will not be able to talk in the lobby or start new battles until the server restarts.
');
}
Config.modchat = 'crash';
@@ -49,7 +49,7 @@ global.toId = function(text) {
global.toName = function(name) {
name = string(name);
name = name.replace(/[\|\s\[\]\,]+/g, ' ').trim();
- if (name.length > 18) name = name.substr(0,18).trim();
+ if (name.length > 18) name = name.substr(0, 18).trim();
return name;
};
@@ -58,7 +58,7 @@ global.toName = function(name) {
* If strEscape is true, escapes it for JavaScript, too
*/
global.sanitize = function(str, strEscape) {
- str = (''+(str||''));
+ str = ('' + (str || ''));
str = str.escapeHTML();
if (strEscape) str = str.replace(/'/g, '\\\'');
return str;
@@ -66,12 +66,12 @@ global.sanitize = function(str, strEscape) {
/**
* Safely ensures the passed variable is a string
- * Simply doing ''+str can crash if str.toString crashes or isn't a function
+ * Simply doing '' + str can crash if str.toString crashes or isn't a function
* If we're expecting a string and being given anything that isn't a string
* or a number, it's safe to assume it's an error, and return ''
*/
global.string = function(str) {
- if (typeof str === 'string' || typeof str === 'number') return ''+str;
+ if (typeof str === 'string' || typeof str === 'number') return '' + str;
return '';
};
@@ -82,11 +82,11 @@ var Battles = {};
// Receive and process a message sent using Simulator.prototype.send in
// another process.
process.on('message', function(message) {
- //console.log('CHILD MESSAGE RECV: "'+message+'"');
+ //console.log('CHILD MESSAGE RECV: "' + message + '"');
var nlIndex = message.indexOf("\n");
var more = '';
if (nlIndex > 0) {
- more = message.substr(nlIndex+1);
+ more = message.substr(nlIndex + 1);
message = message.substr(0, nlIndex);
}
var data = message.split('|');
@@ -101,10 +101,10 @@ process.on('message', function(message) {
var fakeErr = {stack: stack};
if (!require('./crashlogger.js')(fakeErr, 'A battle')) {
- var ministack = (""+err.stack).split("\n").slice(0,2).join("
");
- process.send(data[0]+'\nupdate\n|html|A BATTLE PROCESS HAS CRASHED: '+ministack+'
');
+ var ministack = ("" + err.stack).split("\n").slice(0, 2).join("
");
+ process.send(data[0] + '\nupdate\n|html|A BATTLE PROCESS HAS CRASHED: ' + ministack + '
');
} else {
- process.send(data[0]+'\nupdate\n|html|The battle crashed!
Don\'t worry, we\'re working on fixing it.
');
+ process.send(data[0] + '\nupdate\n|html|The battle crashed!
Don\'t worry, we\'re working on fixing it.
');
}
}
}
@@ -161,14 +161,14 @@ var BattlePokemon = (function() {
this.baseTemplate = this.battle.getTemplate(set.species || set.name);
if (!this.baseTemplate.exists) {
- this.battle.debug('Unidentified species: '+this.species);
+ this.battle.debug('Unidentified species: ' + this.species);
this.baseTemplate = this.battle.getTemplate('Unown');
}
this.species = this.baseTemplate.species;
if (set.name === set.species || !set.name || !set.species) {
set.name = this.species;
}
- this.name = (set.name || set.species || 'Bulbasaur').substr(0,20);
+ this.name = (set.name || set.species || 'Bulbasaur').substr(0, 20);
this.speciesid = toId(this.species);
this.template = this.baseTemplate;
this.moves = [];
@@ -179,14 +179,14 @@ var BattlePokemon = (function() {
this.level = this.battle.clampIntRange(set.forcedLevel || set.level || 100, 1, 1000);
- var genders = {M:'M',F:'F'};
- this.gender = this.template.gender || genders[set.gender] || (Math.random()*2<1?'M':'F');
+ var genders = {M:'M', F:'F'};
+ this.gender = this.template.gender || genders[set.gender] || (Math.random() * 2 < 1 ? 'M' : 'F');
if (this.gender === 'N') this.gender = '';
this.happiness = typeof set.happiness === 'number' ? this.battle.clampIntRange(set.happiness, 0, 255) : 255;
this.pokeball = this.set.pokeball || 'pokeball';
this.fullname = this.side.id + ': ' + this.name;
- this.details = this.species + (this.level==100?'':', L'+this.level) + (this.gender===''?'':', '+this.gender) + (this.set.shiny?', shiny':'');
+ this.details = this.species + (this.level === 100 ? '' : ', L' + this.level) + (this.gender === '' ? '' : ', ' + this.gender) + (this.set.shiny ? ', shiny' : '');
this.id = this.fullname; // shouldn't really be used anywhere
@@ -212,7 +212,7 @@ var BattlePokemon = (function() {
this.types = this.baseTemplate.types;
this.typesData = [];
- for (var i=0, l=this.types.length; i> 3) + (2 * (speDV >> 3)) + (4 * (defDV >> 3)) + (8 * (atkDV >> 3))) + (spcDV>2?3:spcDV)) / 2 + 31);
+ this.hpPower = Math.floor((5 * ((spcDV >> 3) + (2 * (speDV >> 3)) + (4 * (defDV >> 3)) + (8 * (atkDV >> 3))) + (spcDV > 2 ? 3 : spcDV)) / 2 + 31);
} else {
// Hidden Power check for gen 3 onwards
var hpTypeX = 0, hpPowerX = 0;
@@ -296,14 +296,14 @@ var BattlePokemon = (function() {
this.baseStats = {atk:10, def:10, spa:10, spd:10, spe:10};
for (var statName in this.baseStats) {
var stat = this.template.baseStats[statName];
- stat = Math.floor(Math.floor(2*stat+this.set.ivs[statName]+Math.floor(this.set.evs[statName]/4))*this.level / 100 + 5);
+ stat = Math.floor(Math.floor(2 * stat + this.set.ivs[statName] + Math.floor(this.set.evs[statName] / 4)) * this.level / 100 + 5);
var nature = this.battle.getNature(this.set.nature);
if (statName === nature.plus) stat *= 1.1;
if (statName === nature.minus) stat *= 0.9;
this.baseStats[statName] = Math.floor(stat);
}
- this.maxhp = Math.floor(Math.floor(2*this.template.baseStats['hp']+this.set.ivs['hp']+Math.floor(this.set.evs['hp']/4)+100)*this.level / 100 + 10);
+ this.maxhp = Math.floor(Math.floor(2 * this.template.baseStats['hp'] + this.set.ivs['hp'] + Math.floor(this.set.evs['hp'] / 4) + 100) * this.level / 100 + 10);
if (this.template.baseStats['hp'] === 1) this.maxhp = 1; // shedinja
this.hp = this.hp || this.maxhp;
@@ -345,8 +345,8 @@ var BattlePokemon = (function() {
var fullname = this.fullname;
if (this.illusion) fullname = this.illusion.fullname;
- var positionList = ['a','b','c','d','e','f'];
- if (this.isActive) return fullname.substr(0,2) + positionList[this.position] + fullname.substr(2);
+ var positionList = 'abcdef';
+ if (this.isActive) return fullname.substr(0, 2) + positionList[this.position] + fullname.substr(2);
return fullname;
};
// "static" function
@@ -409,7 +409,7 @@ var BattlePokemon = (function() {
// stat boosts
// boost = this.boosts[statName];
- var boostTable = [1,1.5,2,2.5,3,3.5,4];
+ var boostTable = [1, 1.5, 2, 2.5, 3, 3.5, 4];
if (boost > 6) boost = 6;
if (boost < -6) boost = -6;
if (boost >= 0) {
@@ -438,7 +438,7 @@ var BattlePokemon = (function() {
// stat boosts
if (!unboosted) {
var boost = this.boosts[statName];
- var boostTable = [1,1.5,2,2.5,3,3.5,4];
+ var boostTable = [1, 1.5, 2, 2.5, 3, 3.5, 4];
if (boost > 6) boost = 6;
if (boost < -6) boost = -6;
if (boost >= 0) {
@@ -452,7 +452,7 @@ var BattlePokemon = (function() {
if (!unmodified) {
var statTable = {atk:'Atk', def:'Def', spa:'SpA', spd:'SpD', spe:'Spe'};
var statMod = 1;
- statMod = this.battle.runEvent('Modify'+statTable[statName], this, null, null, statMod);
+ statMod = this.battle.runEvent('Modify' + statTable[statName], this, null, null, statMod);
stat = this.battle.modify(stat, statMod);
}
if (this.battle.getStatCallback) {
@@ -462,7 +462,7 @@ var BattlePokemon = (function() {
};
BattlePokemon.prototype.getMoveData = function(move) {
move = this.battle.getMove(move);
- for (var i=0; i= 5 ? this.set.ivs : pokemon.set.ivs);
this.hpType = (this.battle.gen >= 5 ? this.hpType : pokemon.hpType);
this.hpPower = (this.battle.gen >= 5 ? this.hpPower : pokemon.hpPower);
- for (var i=0; i this.maxhp) {
d -= this.hp - this.maxhp;
@@ -867,7 +867,7 @@ var BattlePokemon = (function() {
if (!ignoreImmunities && status.id) {
// the game currently never ignores immunities
- if (!this.runImmunity(status.id==='tox'?'psn':status.id)) {
+ if (!this.runImmunity(status.id === 'tox' ? 'psn' : status.id)) {
this.battle.debug('immune to status');
return false;
}
@@ -877,7 +877,7 @@ var BattlePokemon = (function() {
var prevStatus = this.status;
var prevStatusData = this.statusData;
if (status.id && !this.battle.runEvent('SetStatus', this, source, sourceEffect, status)) {
- this.battle.debug('set status ['+status.id+'] interrupted');
+ this.battle.debug('set status [' + status.id + '] interrupted');
return false;
}
@@ -892,7 +892,7 @@ var BattlePokemon = (function() {
}
if (status.id && !this.battle.singleEvent('Start', status, this.statusData, this, source, sourceEffect)) {
- this.battle.debug('status start ['+status.id+'] interrupted');
+ this.battle.debug('status start [' + status.id + '] interrupted');
// cancel the setstatus
this.status = prevStatus;
this.statusData = prevStatusData;
@@ -949,7 +949,7 @@ var BattlePokemon = (function() {
if (this.battle.runEvent('UseItem', this, null, null, item)) {
switch (item.id) {
case 'redcard':
- this.battle.add('-enditem', this, item, '[of] '+source);
+ this.battle.add('-enditem', this, item, '[of] ' + source);
break;
default:
if (!item.isGem) {
@@ -1056,7 +1056,7 @@ var BattlePokemon = (function() {
if (!this.runImmunity(status.id)) return false;
result = this.battle.runEvent('TryAddVolatile', this, source, sourceEffect, status);
if (!result) {
- this.battle.debug('add volatile ['+status.id+'] interrupted');
+ this.battle.debug('add volatile [' + status.id + '] interrupted');
return result;
}
this.volatiles[status.id] = {id: status.id};
@@ -1102,7 +1102,7 @@ var BattlePokemon = (function() {
if (!this.hp) return '0 fnt';
var hpstring;
if ((side === true) || (this.side === side) || this.battle.getFormat().debug) {
- hpstring = ''+this.hp+'/'+this.maxhp;
+ hpstring = '' + this.hp + '/' + this.maxhp;
} else {
var ratio = this.hp / this.maxhp;
if (this.battle.reportPercentages) {
@@ -1153,7 +1153,7 @@ var BattlePokemon = (function() {
};
BattlePokemon.prototype.getTypes = function(getAll) {
var types = [];
- for (var i=0, l=this.typesData.length; i>> 16; // the first 16 bits of the seed are the random value
m = Math.floor(m);
n = Math.floor(n);
- return (m ? (n ? (result%(n-m))+m : result%m) : result/0x10000);
+ return (m ? (n ? (result % (n - m)) + m : result % m) : result / 0x10000);
};
*/
// This function is designed to emulate the on-cartridge PRNG for Gen 5 and uses a 64-bit initial seed
// This function has three different results, depending on arguments:
- // - random() returns a real number in [0,1), just like Math.random()
- // - random(n) returns an integer in [0,n)
- // - random(m,n) returns an integer in [m,n)
+ // - random() returns a real number in [0, 1), just like Math.random()
+ // - random(n) returns an integer in [0, n)
+ // - random(m, n) returns an integer in [m, n)
// m and n are converted to integers via Math.floor. If the result is NaN, they are ignored.
@@ -1472,8 +1472,8 @@ var Battle = (function() {
var result = (this.seed[0] << 16 >>> 0) + this.seed[1]; // Use the upper 32 bits
m = Math.floor(m);
n = Math.floor(n);
- result = (m ? (n ? Math.floor(result*(n-m) / 0x100000000)+m : Math.floor(result*m / 0x100000000)) : result/0x100000000);
- this.debug('randBW(' + (m ? (n ? m + ',' + n : m) : '') + ') = ' + result);
+ result = (m ? (n ? Math.floor(result * (n - m) / 0x100000000) + m : Math.floor(result * m / 0x100000000)) : result / 0x100000000);
+ this.debug('randBW(' + (m ? (n ? m + ', ' + n : m) : '') + ') = ' + result);
return result;
};
@@ -1481,13 +1481,13 @@ var Battle = (function() {
var seed = this.seed;
n = n || 1;
for (var frame = 0; frame < n; ++frame) {
- // The RNG is a Linear Congruential Generator (LCG) in the form: x_n+1 = (a x_n + c) % m
+ // The RNG is a Linear Congruential Generator (LCG) in the form: x_{n + 1} = (a x_n + c) % m
// Where: x_0 is the seed, x_n is the random number after n iterations,
// a = 0x5D588B656C078965, c = 0x00269EC3 and m = 2^64
// Javascript doesnt handle such large numbers properly, so this function does it in 16-bit parts.
- // x_n+1 = (x_n * a) + c
+ // x_{n + 1} = (x_n * a) + c
// Let any 64 bit number n = (n[0] << 48) + (n[1] << 32) + (n[2] << 16) + n[3]
- // Then x_n+1 =
+ // Then x_{n + 1} =
// ((a[3] x_n[0] + a[2] x_n[1] + a[1] x_n[2] + a[0] x_n[3] + c[0]) << 48) +
// ((a[3] x_n[1] + a[2] x_n[2] + a[1] x_n[3] + c[1]) << 32) +
// ((a[3] x_n[2] + a[2] x_n[3] + c[2]) << 16) +
@@ -1504,7 +1504,7 @@ var Battle = (function() {
// ((a[b-1] x_n[0] + a[b-2] x_n[1] + ... + a[1] x_n[b-2] + a[0] + x_n[b-1] + c[0]) << (16 * (b-1)))
// Which produces this equation: \sum_{l=0}^{b-1}\left(\sum_{m=b-l-1}^{b-1}\left\{a[2b-m-l-2] x_n[m]\right\}+c[b-l-1]\ll16l\right)
// This is all ignoring overflow/carry because that cannot be shown in a pseudo-mathematical equation.
- // The below code implements a simplified version of that equation while also checking for overflow/carry.
+ // The below code implements a optimised version of that equation while also checking for overflow/carry.
var a = [0x5D58, 0x8B65, 0x6C07, 0x8965];
var c = [0, 0, 0x26, 0x9EC3];
@@ -1706,11 +1706,11 @@ var Battle = (function() {
Battle.prototype.update = function() {
var actives = this.p1.active;
- for (var i=0; i= 8) {
// oh fuck
this.add('message', 'STACK LIMIT EXCEEDED');
this.add('message', 'PLEASE REPORT IN BUG THREAD');
- this.add('message', 'Event: '+eventid);
- this.add('message', 'Parent event: '+this.event.id);
+ this.add('message', 'Event: ' + eventid);
+ this.add('message', 'Parent event: ' + this.event.id);
throw new Error("Stack overflow");
return false;
}
- //this.add('Event: '+eventid+' (depth '+this.eventDepth+')');
+ //this.add('Event: ' + eventid + ' (depth ' + this.eventDepth + ')');
effect = this.getEffect(effect);
var hasRelayVar = true;
if (relayVar === undefined) {
@@ -1814,15 +1814,15 @@ var Battle = (function() {
return relayVar;
}
if (target.ignore && target.ignore[effect.effectType]) {
- this.debug(eventid+' handler suppressed by Gastro Acid, Klutz or Magic Room');
+ this.debug(eventid + ' handler suppressed by Gastro Acid, Klutz or Magic Room');
return relayVar;
}
- if (target.ignore && target.ignore[effect.effectType+'Target']) {
- this.debug(eventid+' handler suppressed by Air Lock');
+ if (target.ignore && target.ignore[effect.effectType + 'Target']) {
+ this.debug(eventid + ' handler suppressed by Air Lock');
return relayVar;
}
- if (effect['on'+eventid] === undefined) return relayVar;
+ if (effect['on' + eventid] === undefined) return relayVar;
var parentEffect = this.effect;
var parentEffectData = this.effectData;
var parentEvent = this.event;
@@ -1833,10 +1833,10 @@ var Battle = (function() {
var args = [target, source, sourceEffect];
if (hasRelayVar) args.unshift(relayVar);
var returnVal;
- if (typeof effect['on'+eventid] === 'function') {
- returnVal = effect['on'+eventid].apply(this, args);
+ if (typeof effect['on' + eventid] === 'function') {
+ returnVal = effect['on' + eventid].apply(this, args);
} else {
- returnVal = effect['on'+eventid];
+ returnVal = effect['on' + eventid];
}
this.eventDepth--;
this.effect = parentEffect;
@@ -1954,17 +1954,17 @@ var Battle = (function() {
// oh fuck
this.add('message', 'STACK LIMIT EXCEEDED');
this.add('message', 'PLEASE REPORT IN BUG THREAD');
- this.add('message', 'Event: '+eventid);
- this.add('message', 'Parent event: '+this.event.id);
+ this.add('message', 'Event: ' + eventid);
+ this.add('message', 'Parent event: ' + this.event.id);
throw new Error("Stack overflow");
return false;
}
if (!target) target = this;
- var statuses = this.getRelevantEffects(target, 'on'+eventid, 'onSource'+eventid, source);
+ var statuses = this.getRelevantEffects(target, 'on' + eventid, 'onSource' + eventid, source);
var hasRelayVar = true;
effect = this.getEffect(effect);
var args = [target, source, effect];
- //console.log('Event: '+eventid+' (depth '+this.eventDepth+') t:'+target.id+' s:'+(!source||source.id)+' e:'+effect.id);
+ //console.log('Event: ' + eventid + ' (depth ' + this.eventDepth + ') t:' + target.id + ' s:' + (!source || source.id) + ' e:' + effect.id);
if (relayVar === undefined || relayVar === null) {
relayVar = true;
hasRelayVar = false;
@@ -1976,13 +1976,13 @@ var Battle = (function() {
this.event = {id: eventid, target: target, source: source, effect: effect, modifier: 1};
this.eventDepth++;
- if (onEffect && 'on'+eventid in effect) {
- statuses.unshift({status: effect, callback: effect['on'+eventid], statusData: {}, end: null, thing: target});
+ if (onEffect && 'on' + eventid in effect) {
+ statuses.unshift({status: effect, callback: effect['on' + eventid], statusData: {}, end: null, thing: target});
}
- for (var i=0; i> 12) / 4096;
@@ -2753,7 +2753,7 @@ var Battle = (function() {
denominator = numerator[1];
numerator = numerator[0];
}
- var modifier = Math.floor(numerator*4096/denominator);
+ var modifier = Math.floor(numerator * 4096 / denominator);
return Math.floor((value * modifier + 2048 - 1) / 4096);
};
Battle.prototype.getCategory = function(move) {
@@ -2886,11 +2886,11 @@ var Battle = (function() {
else defense = defender.calculateStat(defenseStat, defBoosts);
// Apply Stat Modifiers
- attack = this.runEvent('Modify'+statTable[attackStat], attacker, defender, move, attack);
- defense = this.runEvent('Modify'+statTable[defenseStat], defender, attacker, move, defense);
+ attack = this.runEvent('Modify' + statTable[attackStat], attacker, defender, move, attack);
+ defense = this.runEvent('Modify' + statTable[defenseStat], defender, attacker, move, defense);
- //int(int(int(2*L/5+2)*A*P/D)/50);
- var baseDamage = Math.floor(Math.floor(Math.floor(2*level/5+2) * basePower * attack/defense)/50) + 2;
+ //int(int(int(2 * L / 5 + 2) * A * P / D) / 50);
+ var baseDamage = Math.floor(Math.floor(Math.floor(2 * level / 5 + 2) * basePower * attack / defense) / 50) + 2;
// multi-target modifier (doubles only)
if (move.spreadHit) {
@@ -2909,7 +2909,7 @@ var Battle = (function() {
// randomizer
// this is not a modifier
// gen 1-2
- //var randFactor = Math.floor(Math.random()*39)+217;
+ //var randFactor = Math.floor(Math.random() * 39) + 217;
//baseDamage *= Math.floor(randFactor * 100 / 255) / 100;
baseDamage = Math.floor(baseDamage * (100 - this.random(16)) / 100);
@@ -2932,15 +2932,15 @@ var Battle = (function() {
if (totalTypeMod > 0) {
if (!suppressMessages) this.add('-supereffective', target);
- for (var i=0; itotalTypeMod; i--) {
- baseDamage = Math.floor(baseDamage/2);
+ for (var i = 0; i > totalTypeMod; i--) {
+ baseDamage = Math.floor(baseDamage / 2);
}
}
@@ -2960,9 +2960,9 @@ var Battle = (function() {
var numSlots = source.side.active.length;
if (!Math.abs(targetLoc) && Math.abs(targetLoc) > numSlots) return false;
- var sourceLoc = -(source.position+1);
+ var sourceLoc = -(source.position + 1);
var isFoe = (targetLoc > 0);
- var isAdjacent = (isFoe ? Math.abs(-(numSlots+1-targetLoc)-sourceLoc)<=1 : Math.abs(targetLoc-sourceLoc)<=1);
+ var isAdjacent = (isFoe ? Math.abs(-(numSlots + 1 - targetLoc) - sourceLoc) <= 1 : Math.abs(targetLoc - sourceLoc) <= 1);
var isSelf = (sourceLoc === targetLoc);
switch (targetType) {
@@ -2981,10 +2981,10 @@ var Battle = (function() {
return false;
};
Battle.prototype.getTargetLoc = function(target, source) {
- if (target.side == source.side) {
- return -(target.position+1);
+ if (target.side === source.side) {
+ return -(target.position + 1);
} else {
- return target.position+1;
+ return target.position + 1;
}
};
Battle.prototype.validTarget = function(target, source, targetType) {
@@ -2996,9 +2996,9 @@ var Battle = (function() {
if ((move.target !== 'randomNormal') &&
this.validTargetLoc(decision.targetLoc, decision.pokemon, move.target)) {
if (decision.targetLoc > 0) {
- target = decision.pokemon.side.foe.active[decision.targetLoc-1];
+ target = decision.pokemon.side.foe.active[decision.targetLoc - 1];
} else {
- target = decision.pokemon.side.active[(-decision.targetLoc)-1];
+ target = decision.pokemon.side.active[-decision.targetLoc - 1];
}
if (target) {
if (!target.fainted) {
@@ -3031,11 +3031,11 @@ var Battle = (function() {
move = this.getMove(move);
if (move.target === 'adjacentAlly' && pokemon.side.active.length > 1) {
- if (pokemon.side.active[pokemon.position-1]) {
- return pokemon.side.active[pokemon.position-1];
+ if (pokemon.side.active[pokemon.position - 1]) {
+ return pokemon.side.active[pokemon.position - 1];
}
- else if (pokemon.side.active[pokemon.position+1]) {
- return pokemon.side.active[pokemon.position+1];
+ else if (pokemon.side.active[pokemon.position + 1]) {
+ return pokemon.side.active[pokemon.position + 1];
}
}
if (move.target === 'self' || move.target === 'all' || move.target === 'allySide' || move.target === 'allyTeam' || move.target === 'adjacentAlly' || move.target === 'adjacentAllyOrSelf') {
@@ -3086,7 +3086,7 @@ var Battle = (function() {
Battle.prototype.addQueue = function(decision, noSort, side) {
if (decision) {
if (Array.isArray(decision)) {
- for (var i=0; i= 6 || i < 0) return;
if (decision.team[1]) {
// validate the choice
var len = decision.side.pokemon.length;
- var newPokemon = [null,null,null,null,null,null].slice(0, len);
- for (var j=0; j= 0) {
- data = choice.substr(firstSpaceIndex+1).trim();
+ data = choice.substr(firstSpaceIndex + 1).trim();
choice = choice.substr(0, firstSpaceIndex).trim();
}
@@ -3589,15 +3589,15 @@ var Battle = (function() {
}
}
- data = parseInt(data, 10)-1;
+ data = parseInt(data, 10) - 1;
if (data < 0) data = 0;
- if (data > side.pokemon.length-1) data = side.pokemon.length-1;
+ if (data > side.pokemon.length - 1) data = side.pokemon.length - 1;
if (!side.pokemon[data]) {
this.debug("Can't switch: You can't switch to a pokemon that doesn't exist");
return false;
}
- if (data == i) {
+ if (data === i) {
this.debug("Can't switch: You can't switch to yourself");
return false;
}
@@ -3630,25 +3630,25 @@ var Battle = (function() {
var validMoves = pokemon.getValidMoves(lockedMove);
var moveid = '';
- if (data.substr(data.length-2) === ' 1') targetLoc = 1;
- if (data.substr(data.length-2) === ' 2') targetLoc = 2;
- if (data.substr(data.length-2) === ' 3') targetLoc = 3;
- if (data.substr(data.length-3) === ' -1') targetLoc = -1;
- if (data.substr(data.length-3) === ' -2') targetLoc = -2;
- if (data.substr(data.length-3) === ' -3') targetLoc = -3;
+ if (data.substr(data.length - 2) === ' 1') targetLoc = 1;
+ if (data.substr(data.length - 2) === ' 2') targetLoc = 2;
+ if (data.substr(data.length - 2) === ' 3') targetLoc = 3;
+ if (data.substr(data.length - 3) === ' -1') targetLoc = -1;
+ if (data.substr(data.length - 3) === ' -2') targetLoc = -2;
+ if (data.substr(data.length - 3) === ' -3') targetLoc = -3;
if (targetLoc) data = data.substr(0, data.lastIndexOf(' '));
if (lockedMove) targetLoc = (this.runEvent('LockMoveTarget', pokemon) || 0);
- if (data.substr(data.length-5) === ' mega') {
+ if (data.substr(data.length - 5) === ' mega') {
if (!lockedMove) {
decisions.push({
choice: 'megaEvo',
pokemon: pokemon
});
}
- data = data.substr(0, data.length-5);
+ data = data.substr(0, data.length - 5);
}
if (data.search(/^[0-9]+$/) >= 0) {
@@ -3683,7 +3683,7 @@ var Battle = (function() {
return typeof part === 'function';
});
if (functions.indexOf(true) < 0) {
- this.log.push('|'+parts.join('|'));
+ this.log.push('|' + parts.join('|'));
} else {
this.log.push('|split');
var sides = this.sides.concat(null, true);
@@ -3703,10 +3703,10 @@ var Battle = (function() {
};
Battle.prototype.addMove = function() {
this.lastMoveLine = this.log.length;
- this.log.push('|'+Array.prototype.slice.call(arguments).join('|'));
+ this.log.push('|' + Array.prototype.slice.call(arguments).join('|'));
};
Battle.prototype.attrLastMove = function() {
- this.log[this.lastMoveLine] += '|'+Array.prototype.slice.call(arguments).join('|');
+ this.log[this.lastMoveLine] += '|' + Array.prototype.slice.call(arguments).join('|');
};
Battle.prototype.debug = function(activity) {
if (this.getFormat().debug) {
@@ -3726,7 +3726,7 @@ var Battle = (function() {
if (this.started) {
this.p2.name = name;
} else {
- //console.log("NEW SIDE: "+name);
+ //console.log("NEW SIDE: " + name);
this.p2 = new BattleSide(name, this, 1, team);
this.sides[1] = this.p2;
}
@@ -3737,7 +3737,7 @@ var Battle = (function() {
if (this.started) {
this.p1.name = name;
} else {
- //console.log("NEW SIDE: "+name);
+ //console.log("NEW SIDE: " + name);
this.p1 = new BattleSide(name, this, 0, team);
this.sides[0] = this.p1;
}
@@ -3760,8 +3760,8 @@ var Battle = (function() {
if (slot === 'p1' || slot === 'p2') {
var side = this[slot];
if (!side) {
- console.log('**** '+slot+' tried to leave before it was possible in '+this.id);
- require('./crashlogger.js')({stack: '**** '+slot+' tried to leave before it was possible in '+this.id}, 'A simulator process');
+ console.log('**** ' + slot + ' tried to leave before it was possible in ' + this.id);
+ require('./crashlogger.js')({stack: '**** ' + slot + ' tried to leave before it was possible in ' + this.id}, 'A simulator process');
return;
}
@@ -3779,7 +3779,7 @@ var Battle = (function() {
// Simulator.prototype.receive in simulator.js (in another process).
Battle.prototype.send = function(type, data) {
if (Array.isArray(data)) data = data.join("\n");
- process.send(this.id+"\n"+type+"\n"+data);
+ process.send(this.id + "\n" + type + "\n" + data);
};
// This function is called by this process's 'message' event.
Battle.prototype.receive = function(data, more) {
@@ -3792,7 +3792,7 @@ var Battle = (function() {
try {
if (more) team = Tools.fastUnpackTeam(more);
} catch (e) {
- console.log('TEAM PARSE ERROR: '+more);
+ console.log('TEAM PARSE ERROR: ' + more);
team = null;
}
this.join(data[2], data[3], data[4], team);
@@ -3827,14 +3827,14 @@ var Battle = (function() {
var battle = this;
var p1 = this.p1;
var p2 = this.p2;
- var p1active = p1?p1.active[0]:null;
- var p2active = p2?p2.active[0]:null;
+ var p1active = p1 ? p1.active[0] : null;
+ var p2active = p2 ? p2.active[0] : null;
data[2] = data[2].replace(/\f/g, '\n');
- this.add('', '>>> '+data[2]);
+ this.add('', '>>> ' + data[2]);
try {
- this.add('', '<<< '+eval(data[2]));
+ this.add('', '<<< ' + eval(data[2]));
} catch (e) {
- this.add('', '<<< error: '+e.message);
+ this.add('', '<<< error: ' + e.message);
}
break;
}
@@ -3884,13 +3884,13 @@ var Battle = (function() {
// deallocate ourself
// deallocate children and get rid of references to them
- for (var i=0; i 0) {
var subnet = ipToLong(cidr.substr(0, index));
- var bits = parseInt(cidr.substr(index+1), 10);
+ var bits = parseInt(cidr.substr(index + 1), 10);
var mask = -1 << (32 - bits);
return [subnet & mask, mask];
}
diff --git a/command-parser.js b/command-parser.js
index eafa5029bf..b9a8f6b40c 100644
--- a/command-parser.js
+++ b/command-parser.js
@@ -24,9 +24,9 @@ To reload chat commands:
const MAX_MESSAGE_LENGTH = 300;
-const BROADCAST_COOLDOWN = 20*1000;
+const BROADCAST_COOLDOWN = 20 * 1000;
-const MESSAGE_COOLDOWN = 5*60*1000;
+const MESSAGE_COOLDOWN = 5 * 60 * 1000;
const MAX_PARSE_RECURSION = 10;
@@ -63,21 +63,21 @@ var parse = exports.parse = function(message, room, user, connection, levelsDeep
if (!message || !message.trim().length) return;
if (!levelsDeep) {
levelsDeep = 0;
- // if (Config.emergencylog && (connection.ip === '62.195.195.62' || connection.ip === '86.141.154.222' || connection.ip === '189.134.175.221' || message.length > 2048 || message.length > 256 && message.substr(0,5) !== '/utm ' && message.substr(0,5) !== '/trn ')) {
+ // if (Config.emergencylog && (connection.ip === '62.195.195.62' || connection.ip === '86.141.154.222' || connection.ip === '189.134.175.221' || message.length > 2048 || message.length > 256 && message.substr(0, 5) !== '/utm ' && message.substr(0, 5) !== '/trn ')) {
if (Config.emergencylog && (user.userid === 'pindapinda' || connection.ip === '62.195.195.62' || connection.ip === '86.141.154.222' || connection.ip === '189.134.175.221')) {
Config.emergencylog.write('<' + user.name + '@' + connection.ip + '> ' + message + '\n');
}
}
- if (message.substr(0,3) === '>> ') {
+ if (message.substr(0, 3) === '>> ') {
// multiline eval
message = '/eval ' + message.substr(3);
- } else if (message.substr(0,4) === '>>> ') {
+ } else if (message.substr(0, 4) === '>>> ') {
// multiline eval
message = '/evalbattle ' + message.substr(4);
}
- if (message.substr(0,2) !== '//' && message.substr(0,1) === '/') {
+ if (message.substr(0, 2) !== '//' && message.substr(0, 1) === '/') {
var spaceIndex = message.indexOf(' ');
if (spaceIndex > 0) {
cmd = message.substr(1, spaceIndex - 1);
@@ -86,7 +86,7 @@ var parse = exports.parse = function(message, room, user, connection, levelsDeep
cmd = message.substr(1);
target = '';
}
- } else if (message.substr(0,1) === '!') {
+ } else if (message.substr(0, 1) === '!') {
var spaceIndex = message.indexOf(' ');
if (spaceIndex > 0) {
cmd = message.substr(0, spaceIndex);
@@ -217,17 +217,17 @@ var parse = exports.parse = function(message, room, user, connection, levelsDeep
for (var g in Config.groups) {
var groupid = Config.groups[g].id;
if (cmd === groupid) {
- return parse('/promote ' + toId(target) + ',' + g, room, user, connection);
+ return parse('/promote ' + toId(target) + ', ' + g, room, user, connection);
} else if (cmd === 'de' + groupid || cmd === 'un' + groupid) {
return parse('/demote ' + toId(target), room, user, connection);
} else if (cmd === 'room' + groupid) {
- return parse('/roompromote ' + toId(target) + ',' + g, room, user, connection);
+ return parse('/roompromote ' + toId(target) + ', ' + g, room, user, connection);
} else if (cmd === 'roomde' + groupid || cmd === 'deroom' + groupid || cmd === 'roomun' + groupid) {
return parse('/roomdemote ' + toId(target), room, user, connection);
}
}
- if (message.substr(0,1) === '/' && cmd) {
+ if (message.substr(0, 1) === '/' && cmd) {
// To guard against command typos, we now emit an error message
return connection.sendTo(room.id, "The command '/" + cmd + "' was unrecognized. To send a message starting with '" + cmd + "', type '//" + cmd + "'.");
}
@@ -244,7 +244,7 @@ function splitTarget(target, exactName) {
if (commaIndex < 0) {
targetUser = Users.get(target, exactName);
this.targetUser = targetUser;
- this.targetUsername = (targetUser?targetUser.name:target);
+ this.targetUsername = targetUser ? targetUser.name : target;
return '';
}
var targetUser = Users.get(target.substr(0, commaIndex), exactName);
@@ -252,7 +252,7 @@ function splitTarget(target, exactName) {
targetUser = null;
}
this.targetUser = targetUser;
- this.targetUsername = (targetUser?targetUser.name:target.substr(0, commaIndex));
+ this.targetUsername = targetUser ? targetUser.name : target.substr(0, commaIndex);
return target.substr(commaIndex + 1).trim();
}
@@ -318,7 +318,7 @@ function canTalk(user, room, connection, message) {
if (/\bnimp\.org\b/i.test(message)) return false;
// remove zalgo
- message = message.replace(/[\u0300-\u036f\u0E31\u0E34-\u0E3A\u0E47-\u0E4E]{3,}/g,'');
+ message = message.replace(/[\u0300-\u036f\u0E31\u0E34-\u0E3A\u0E47-\u0E4E]{3,}/g, '');
if (room && room.id === 'lobby') {
var normalized = message.trim();
diff --git a/commands.js b/commands.js
index 8d4f6457eb..862656438c 100644
--- a/commands.js
+++ b/commands.js
@@ -67,7 +67,7 @@ var commands = exports.commands = {
if (!user.lastPM) {
return this.sendReply("No one has PMed you yet.");
}
- return this.parse('/msg ' + (user.lastPM||'') + ', ' + target);
+ return this.parse('/msg ' + (user.lastPM || '') + ', ' + target);
},
pm: 'msg',
@@ -544,7 +544,7 @@ var commands = exports.commands = {
if (alts.length) this.addModCommand(targetUser.name + "'s alts were also muted: " + alts.join(", "));
this.add('|unlink|' + targetUser.userid);
- targetUser.mute(room.id, 7*60*1000);
+ targetUser.mute(room.id, 7 * 60 * 1000);
},
hm: 'hourmute',
@@ -561,7 +561,7 @@ var commands = exports.commands = {
}
if (!this.can('mute', targetUser, room)) return false;
- if (((targetUser.mutedRooms[room.id] && (targetUser.muteDuration[room.id]||0) >= 50*60*1000) || targetUser.locked) && !target) {
+ if (((targetUser.mutedRooms[room.id] && (targetUser.muteDuration[room.id] || 0) >= 50 * 60 * 1000) || targetUser.locked) && !target) {
var problem = " but was already " + (!targetUser.connected ? "offline" : targetUser.locked ? "locked" : "muted");
return this.privateModCommand("(" + targetUser.name + " would be muted by " + user.name + problem + ".)");
}
@@ -572,7 +572,7 @@ var commands = exports.commands = {
if (alts.length) this.addModCommand(targetUser.name + "'s alts were also muted: " + alts.join(", "));
this.add('|unlink|' + targetUser.userid);
- targetUser.mute(room.id, 60*60*1000, true);
+ targetUser.mute(room.id, 60 * 60 * 1000, true);
},
um: 'unmute',
@@ -829,7 +829,7 @@ var commands = exports.commands = {
room.modchat = target;
break;
}
- if (currentModchat == room.modchat) {
+ if (currentModchat === room.modchat) {
return this.sendReply("Modchat is already set to " + currentModchat + ".");
}
if (!room.modchat) {
@@ -950,7 +950,7 @@ var commands = exports.commands = {
roomNames = 'all rooms';
// Get a list of all the rooms
var fileList = fs.readdirSync('logs/modlog');
- for (var i=0; i= 0) {
@@ -1389,7 +1389,7 @@ var commands = exports.commands = {
this.sendReply('||<< ' + eval(target));
} catch (e) {
this.sendReply('||<< error: ' + e.message);
- var stack = '||' + ('' + e.stack).replace(/\n/g,'\n||');
+ var stack = '||' + ('' + e.stack).replace(/\n/g, '\n||');
connection.sendTo(room, stack);
}
},
@@ -1430,7 +1430,7 @@ var commands = exports.commands = {
logidx = 3;
}
var data = room.getLog(logidx).join("\n");
- var datahash = crypto.createHash('md5').update(data.replace(/[^(\x20-\x7F)]+/g,'')).digest('hex');
+ var datahash = crypto.createHash('md5').update(data.replace(/[^(\x20-\x7F)]+/g, '')).digest('hex');
LoginServer.request('prepreplay', {
id: room.id.substr(7),
@@ -1462,7 +1462,7 @@ var commands = exports.commands = {
switch: function(target, room, user) {
if (!room.decision) return this.sendReply("You can only do this in battle rooms.");
- room.decision(user, 'choose', 'switch ' + parseInt(target,10));
+ room.decision(user, 'choose', 'switch ' + parseInt(target, 10));
},
choose: function(target, room, user) {
@@ -1543,10 +1543,10 @@ var commands = exports.commands = {
if (!this.can('autotimer')) return;
if (target === 'off' || target === 'false' || target === 'stop') {
Config.forcetimer = false;
- this.addModCommand("Forcetimer is now OFF: The timer is now opt-in. (set by "+user.name+")");
+ this.addModCommand("Forcetimer is now OFF: The timer is now opt-in. (set by " + user.name + ")");
} else if (target === 'on' || target === 'true' || !target) {
Config.forcetimer = true;
- this.addModCommand("Forcetimer is now ON: All battles will be timed. (set by "+user.name+")");
+ this.addModCommand("Forcetimer is now ON: All battles will be timed. (set by " + user.name + ")");
} else {
this.sendReply("'" + target + "' is not a recognized forcetimer setting.");
}
@@ -1739,12 +1739,12 @@ var commands = exports.commands = {
var targetAuth = false;
var targetToken = '';
if (commaIndex >= 0) {
- targetName = target.substr(0,commaIndex);
+ targetName = target.substr(0, commaIndex);
target = target.substr(commaIndex + 1);
commaIndex = target.indexOf(',');
targetAuth = target;
if (commaIndex >= 0) {
- targetAuth = !!parseInt(target.substr(0,commaIndex),10);
+ targetAuth = !!parseInt(target.substr(0, commaIndex), 10);
targetToken = target.substr(commaIndex + 1);
}
}
diff --git a/config/commands.js b/config/commands.js
index 1d271e3ecf..febcfca086 100644
--- a/config/commands.js
+++ b/config/commands.js
@@ -206,7 +206,7 @@ var commands = exports.commands = {
for (var userid in Users.users) {
var user = Users.users[userid];
if (user.latestIp === target) {
- this.sendReply((user.connected?" + ":"-") + " " + user.name);
+ this.sendReply((user.connected ? " + " : "-") + " " + user.name);
atLeastOne = true;
}
}
@@ -264,8 +264,8 @@ var commands = exports.commands = {
if (!target) return this.parse('/help dexsearch');
var targets = target.split(',');
var searches = {};
- var allTiers = {'uber':1,'ou':1,'uu':1,'lc':1,'cap':1,'bl':1};
- var allColours = {'green':1,'red':1,'blue':1,'white':1,'brown':1,'yellow':1,'purple':1,'pink':1,'gray':1,'black':1};
+ var allTiers = {'uber':1, 'ou':1, 'uu':1, 'lc':1, 'cap':1, 'bl':1};
+ var allColours = {'green':1, 'red':1, 'blue':1, 'white':1, 'brown':1, 'yellow':1, 'purple':1, 'pink':1, 'gray':1, 'black':1};
var showAll = false;
var megaSearch = null;
var output = 10;
@@ -273,7 +273,7 @@ var commands = exports.commands = {
for (var i in targets) {
var isNotSearch = false;
target = targets[i].trim().toLowerCase();
- if (target.slice(0,1) === '!') {
+ if (target.slice(0, 1) === '!') {
isNotSearch = true;
target = target.slice(1);
}
@@ -357,7 +357,7 @@ var commands = exports.commands = {
}
}
- for (var search in {'moves':1,'types':1,'ability':1,'tier':1,'gen':1,'color':1}) {
+ for (var search in {'moves':1, 'types':1, 'ability':1, 'tier':1, 'gen':1, 'color':1}) {
if (!searches[search]) continue;
switch (search) {
case 'types':
@@ -421,7 +421,7 @@ var commands = exports.commands = {
while (prevoTemp.prevo && prevoTemp.learnset && !(prevoTemp.learnset[move.id])) {
prevoTemp = Tools.getTemplate(prevoTemp.prevo);
}
- var canLearn = (prevoTemp.learnset.sketch && !(move.id in {'chatter':1,'struggle':1,'magikarpsrevenge':1})) || prevoTemp.learnset[move.id];
+ var canLearn = (prevoTemp.learnset.sketch && !(move.id in {'chatter':1, 'struggle':1, 'magikarpsrevenge':1})) || prevoTemp.learnset[move.id];
if ((!canLearn && searches[search][i]) || (searches[search][i] === false && canLearn)) delete dex[mon];
}
}
@@ -484,7 +484,7 @@ var commands = exports.commands = {
}
var buffer = template.name + (problem ? " can't learn " : " can learn ") + (targets.length > 2 ? "these moves" : move.name);
if (!problem) {
- var sourceNames = {E:"egg",S:"event",D:"dream world"};
+ var sourceNames = {E:"egg", S:"event", D:"dream world"};
if (lsetData.sources || lsetData.sourcesBefore) buffer += " only when obtained from:";
if (lsetData.sources) {
var sources = lsetData.sources.sort();
@@ -492,16 +492,16 @@ var commands = exports.commands = {
var prevSourceType;
for (var i = 0, len = sources.length; i < len; ++i) {
var source = sources[i];
- if (source.substr(0,2) === prevSourceType) {
+ if (source.substr(0, 2) === prevSourceType) {
if (prevSourceCount < 0) buffer += ": " + source.substr(2);
else if (all || prevSourceCount < 3) buffer += ", " + source.substr(2);
- else if (prevSourceCount == 3) buffer += ", ...";
+ else if (prevSourceCount === 3) buffer += ", ...";
++prevSourceCount;
continue;
}
- prevSourceType = source.substr(0,2);
- prevSourceCount = source.substr(2)?0:-1;
- buffer += "- gen " + source.substr(0,1) + " " + sourceNames[source.substr(1,1)];
+ prevSourceType = source.substr(0, 2);
+ prevSourceCount = source.substr(2) ? 0 : -1;
+ buffer += "
- gen " + source.substr(0, 1) + " " + sourceNames[source.substr(1, 1)];
if (prevSourceType === '5E' && template.maleOnlyHidden) buffer += " (cannot have hidden ability)";
if (source.substr(2)) buffer += ": " + source.substr(2);
}
@@ -538,8 +538,8 @@ var commands = exports.commands = {
var notImmune = Tools.getImmunity(type, pokemon);
if (notImmune) {
var typeMod = Tools.getEffectiveness(type, pokemon);
- if (typeMod == 1) weaknesses.push(type);
- if (typeMod == 2) weaknesses.push("" + type + "");
+ if (typeMod === 1) weaknesses.push(type);
+ if (typeMod === 2) weaknesses.push("" + type + "");
}
});
@@ -791,7 +791,7 @@ var commands = exports.commands = {
"
" +
"Room owners (#) can also use:
" +
"- /roomdesc description: set the room description on the room join page
" +
- "- /rules rules link: set the room rules link seen when using /rules
" +
+ "- /rules rules link < /em>: set the room rules link seen when using /rules
" +
"- /roommod, /roomdriver username: appoint a room moderator/driver
" +
"- /roomdemod, /roomdedriver username: remove a room moderator/driver
" +
"- /modchat [%/@/#]: set modchat level
" +
@@ -935,7 +935,7 @@ var commands = exports.commands = {
var atLeastOne = false;
var generation = (targets[1] || 'bw').trim().toLowerCase();
var genNumber = 5;
- var doublesFormats = {'vgc2012':1,'vgc2013':1,'doubles':1};
+ var doublesFormats = {'vgc2012':1, 'vgc2013':1, 'doubles':1};
var doublesFormat = (!targets[2] && generation in doublesFormats)? generation : (targets[2] || '').trim().toLowerCase();
var doublesText = '';
if (generation === 'bw' || generation === 'bw2' || generation === '5' || generation === 'five') {
@@ -957,10 +957,10 @@ var commands = exports.commands = {
}
if (doublesFormat !== '') {
// Smogon only has doubles formats analysis from gen 5 onwards.
- if (!(generation in {'bw':1,'xy':1}) || !(doublesFormat in doublesFormats)) {
+ if (!(generation in {'bw':1, 'xy':1}) || !(doublesFormat in doublesFormats)) {
doublesFormat = '';
} else {
- doublesText = {'vgc2012':"VGC 2012",'vgc2013':"VGC 2013",'doubles':"Doubles"}[doublesFormat];
+ doublesText = {'vgc2012':"VGC 2012", 'vgc2013':"VGC 2013", 'doubles':"Doubles"}[doublesFormat];
doublesFormat = '/' + doublesFormat;
}
}
@@ -981,13 +981,13 @@ var commands = exports.commands = {
if (poke === 'farfetch\'d') poke = 'farfetchd';
if (poke === 'mr. mime') poke = 'mr_mime';
if (poke === 'mime jr.') poke = 'mime_jr';
- if (poke === 'deoxys-attack' || poke === 'deoxys-defense' || poke === 'deoxys-speed' || poke === 'kyurem-black' || poke === 'kyurem-white') poke = poke.substr(0,8);
+ if (poke === 'deoxys-attack' || poke === 'deoxys-defense' || poke === 'deoxys-speed' || poke === 'kyurem-black' || poke === 'kyurem-white') poke = poke.substr(0, 8);
if (poke === 'wormadam-trash') poke = 'wormadam-s';
if (poke === 'wormadam-sandy') poke = 'wormadam-g';
- if (poke === 'rotom-wash' || poke === 'rotom-frost' || poke === 'rotom-heat') poke = poke.substr(0,7);
+ if (poke === 'rotom-wash' || poke === 'rotom-frost' || poke === 'rotom-heat') poke = poke.substr(0, 7);
if (poke === 'rotom-mow') poke = 'rotom-c';
if (poke === 'rotom-fan') poke = 'rotom-s';
- if (poke === 'giratina-origin' || poke === 'tornadus-therian' || poke === 'landorus-therian') poke = poke.substr(0,10);
+ if (poke === 'giratina-origin' || poke === 'tornadus-therian' || poke === 'landorus-therian') poke = poke.substr(0, 10);
if (poke === 'shaymin-sky') poke = 'shaymin-s';
if (poke === 'arceus') poke = 'arceus-normal';
if (poke === 'thundurus-therian') poke = 'thundurus-t';
@@ -1044,7 +1044,7 @@ var commands = exports.commands = {
if (!this.canBroadcast()) return;
var d = target.indexOf("d");
if (d != -1) {
- var num = parseInt(target.substring(0,d));
+ var num = parseInt(target.substring(0, d));
var faces;
if (target.length > d) faces = parseInt(target.substring(d + 1));
if (isNaN(num)) num = 1;
@@ -1088,7 +1088,7 @@ var commands = exports.commands = {
if (!this.can('declare', null, room)) return false;
if (!this.canBroadcast()) return;
- targets = target.split(', ');
+ targets = target.split(',');
if (targets.length != 3) {
return this.parse('/help showimage');
}
diff --git a/config/config-example.js b/config/config-example.js
index 8f56dfb684..71530bb0cd 100644
--- a/config/config-example.js
+++ b/config/config-example.js
@@ -113,7 +113,7 @@ exports.logchat = false;
// loguserstats - how often (in milliseconds) to write user stats to the
// lobby log. This has no effect if `logchat` is disabled.
-exports.loguserstats = 1000*60*10; // 10 minutes
+exports.loguserstats = 1000 * 60 * 10; // 10 minutes
// validatorprocesses - the number of processes to use for validating teams
// simulatorprocesses - the number of processes to use for handling battles
@@ -124,7 +124,7 @@ exports.simulatorprocesses = 1;
// inactiveuserthreshold - how long a user must be inactive before being pruned
// from the `users` array. The default is 1 hour.
-exports.inactiveuserthreshold = 1000*60*60;
+exports.inactiveuserthreshold = 1000 * 60 * 60;
// Set this to true if you are using Pokemon Showdown on Heroku.
exports.herokuhack = false;
diff --git a/config/formats.js b/config/formats.js
index 023a954c03..0f69a7e2d6 100644
--- a/config/formats.js
+++ b/config/formats.js
@@ -64,9 +64,9 @@ exports.Formats = [
onBegin: function() {
this.debug('cutting down to 3');
- this.p1.pokemon = this.p1.pokemon.slice(0,3);
+ this.p1.pokemon = this.p1.pokemon.slice(0, 3);
this.p1.pokemonLeft = this.p1.pokemon.length;
- this.p2.pokemon = this.p2.pokemon.slice(0,3);
+ this.p2.pokemon = this.p2.pokemon.slice(0, 3);
this.p2.pokemonLeft = this.p2.pokemon.length;
},
maxForcedLevel: 50,
@@ -82,9 +82,9 @@ exports.Formats = [
onBegin: function() {
this.debug('cutting down to 3');
- this.p1.pokemon = this.p1.pokemon.slice(0,3);
+ this.p1.pokemon = this.p1.pokemon.slice(0, 3);
this.p1.pokemonLeft = this.p1.pokemon.length;
- this.p2.pokemon = this.p2.pokemon.slice(0,3);
+ this.p2.pokemon = this.p2.pokemon.slice(0, 3);
this.p2.pokemonLeft = this.p2.pokemon.length;
},
maxForcedLevel: 50,
@@ -211,9 +211,9 @@ exports.Formats = [
gameType: 'doubles',
onBegin: function() {
this.debug('cutting down to 4');
- this.p1.pokemon = this.p1.pokemon.slice(0,4);
+ this.p1.pokemon = this.p1.pokemon.slice(0, 4);
this.p1.pokemonLeft = this.p1.pokemon.length;
- this.p2.pokemon = this.p2.pokemon.slice(0,4);
+ this.p2.pokemon = this.p2.pokemon.slice(0, 4);
this.p2.pokemonLeft = this.p2.pokemon.length;
},
maxForcedLevel: 50,
@@ -229,9 +229,9 @@ exports.Formats = [
gameType: 'doubles',
onBegin: function() {
this.debug('cutting down to 4');
- this.p1.pokemon = this.p1.pokemon.slice(0,4);
+ this.p1.pokemon = this.p1.pokemon.slice(0, 4);
this.p1.pokemonLeft = this.p1.pokemon.length;
- this.p2.pokemon = this.p2.pokemon.slice(0,4);
+ this.p2.pokemon = this.p2.pokemon.slice(0, 4);
this.p2.pokemonLeft = this.p2.pokemon.length;
},
maxForcedLevel: 50,
@@ -276,7 +276,7 @@ exports.Formats = [
banlist: [
"Arceus", "Arceus-Bug", "Arceus-Dark", "Arceus-Dragon", "Arceus-Electric", "Arceus-Fairy", "Arceus-Fighting", "Arceus-Fire",
"Arceus-Flying", "Arceus-Ghost", "Arceus-Grass", "Arceus-Ground", "Arceus-Ice", "Arceus-Poison", "Arceus-Psychic", "Arceus-Rock", "Arceus-Steel",
- "Arceus-Water", "Darkrai", "Deoxys", "Deoxys-Attack", "Dialga", "Giratina", "Giratina-Origin"," Groudon", "Ho-Oh", "Kyurem-White", "Lugia",
+ "Arceus-Water", "Darkrai", "Deoxys", "Deoxys-Attack", "Dialga", "Giratina", "Giratina-Origin", "Groudon", "Ho-Oh", "Kyurem-White", "Lugia",
"Mewtwo", "Mewtwo-Mega-X", "Mewtwo-Mega-Y", "Palkia", "Rayquaza", "Reshiram", "Xerneas", "Zekrom", "Regigigas", "Slaking", "Ampharosite", "Gyaradosite",
"Meloetta"
]
@@ -393,7 +393,7 @@ exports.Formats = [
validateSet: function(set) {
var template = this.getTemplate(set.species || set.name);
if (template.types.indexOf('Flying') === -1 && set.ability !== 'Levitate') {
- return [set.species+" is not a Flying type and does not have the ability Levitate."];
+ return [set.species + " is not a Flying type and does not have the ability Levitate."];
}
},
ruleset: ['Pokemon', 'Standard', 'Evasion Abilities Clause', 'Team Preview'],
@@ -453,9 +453,9 @@ exports.Formats = [
section: 'Other Metagames',
onBegin: function() {
- this.p1.pokemon = this.p1.pokemon.slice(0,1);
+ this.p1.pokemon = this.p1.pokemon.slice(0, 1);
this.p1.pokemonLeft = this.p1.pokemon.length;
- this.p2.pokemon = this.p2.pokemon.slice(0,1);
+ this.p2.pokemon = this.p2.pokemon.slice(0, 1);
this.p2.pokemonLeft = this.p2.pokemon.length;
},
ruleset: ['Pokemon', 'Standard'],
@@ -528,7 +528,7 @@ exports.Formats = [
var letters = {};
var letter = '';
for (var i = 0; i < team.length; i++) {
- letter = Tools.getTemplate(team[i]).species.slice(0,1).toUpperCase();
+ letter = Tools.getTemplate(team[i]).species.slice(0, 1).toUpperCase();
if (letter in letters) return ['Your team cannot have more that one Pokémon starting with the letter "' + letter + '".'];
letters[letter] = 1;
}
@@ -604,7 +604,7 @@ exports.Formats = [
mod: 'gen5',
ruleset: ['[Gen 5] RU'],
- banlist: ['RU','BL3', 'Prankster + Assist']
+ banlist: ['RU', 'BL3', 'Prankster + Assist']
},
{
name: "[Gen 5] LC",
@@ -626,9 +626,9 @@ exports.Formats = [
},
onBegin: function() {
this.debug('cutting down to 3');
- this.p1.pokemon = this.p1.pokemon.slice(0,3);
+ this.p1.pokemon = this.p1.pokemon.slice(0, 3);
this.p1.pokemonLeft = this.p1.pokemon.length;
- this.p2.pokemon = this.p2.pokemon.slice(0,3);
+ this.p2.pokemon = this.p2.pokemon.slice(0, 3);
this.p2.pokemonLeft = this.p2.pokemon.length;
},
ruleset: ['Pokemon', 'Standard GBU', 'Team Preview GBU'],
@@ -683,9 +683,9 @@ exports.Formats = [
gameType: 'doubles',
onBegin: function() {
this.debug('cutting down to 4');
- this.p1.pokemon = this.p1.pokemon.slice(0,4);
+ this.p1.pokemon = this.p1.pokemon.slice(0, 4);
this.p1.pokemonLeft = this.p1.pokemon.length;
- this.p2.pokemon = this.p2.pokemon.slice(0,4);
+ this.p2.pokemon = this.p2.pokemon.slice(0, 4);
this.p2.pokemonLeft = this.p2.pokemon.length;
},
maxForcedLevel: 50,
diff --git a/crashlogger.js b/crashlogger.js
index e798139d29..74918cc205 100644
--- a/crashlogger.js
+++ b/crashlogger.js
@@ -11,12 +11,12 @@
module.exports = (function() {
var lastCrashLog = 0;
return function(err, description) {
- console.log("\nCRASH: "+err.stack+"\n");
+ console.log("\nCRASH: " + err.stack + "\n");
require('fs').createWriteStream('logs/errors.txt', {'flags': 'a'}).on("open", function(fd) {
- this.write("\n"+err.stack+"\n");
+ this.write("\n" + err.stack + "\n");
this.end();
}).on("error", function (err) {
- console.log("\nSUBCRASH: "+err.stack+"\n");
+ console.log("\nSUBCRASH: " + err.stack + "\n");
});
var datenow = Date.now();
if (Config.crashguardemail && ((datenow - lastCrashLog) > 1000 * 60 * 5)) {
diff --git a/data/abilities.js b/data/abilities.js
index 8bc7ae751d..f70ca88ad9 100644
--- a/data/abilities.js
+++ b/data/abilities.js
@@ -58,7 +58,7 @@ exports.BattleAbilities = {
name: "Aftermath",
onFaint: function(target, source, effect) {
if (effect && effect.effectType === 'Move' && effect.isContact && source) {
- this.damage(source.maxhp/4, source, target);
+ this.damage(source.maxhp / 4, source, target);
}
},
rating: 3,
@@ -122,7 +122,7 @@ exports.BattleAbilities = {
onCriticalHit: function(target) {
if (!target.volatiles['substitute']) {
target.setBoost({atk: 6});
- this.add('-setboost',target,'atk',12,'[from] ability: Anger Point');
+ this.add('-setboost', target, 'atk', 12, '[from] ability: Anger Point');
}
},
id: "angerpoint",
@@ -135,12 +135,12 @@ exports.BattleAbilities = {
shortDesc: "On switch-in, this Pokemon shudders if any foe has a super effective or OHKO move.",
onStart: function(pokemon) {
var targets = pokemon.side.foe.active;
- for (var i=0; i 0 || move.ohko)) {
- this.add('-message', pokemon.name+' shuddered! (placeholder)');
+ this.add('-message', pokemon.name + ' shuddered! (placeholder)');
return;
}
}
@@ -202,11 +202,11 @@ exports.BattleAbilities = {
onResidualSubOrder: 1,
onResidual: function(pokemon) {
if (!pokemon.hp) return;
- for (var i=0; i warnBp) {
warnMoves = [[move, targets[i]]];
warnBp = bp;
- } else if (bp == warnBp) {
+ } else if (bp === warnBp) {
warnMoves.push([move, targets[i]]);
}
}
@@ -885,10 +885,10 @@ exports.BattleAbilities = {
shortDesc: "On switch-in, this Pokemon identifies the foe's held items.",
onStart: function(pokemon) {
var foeactive = pokemon.side.foe.active;
- for (var i=0; ipokemon.position; i--) {
+ for (var i = pokemon.side.pokemon.length - 1; i > pokemon.position; i--) {
if (!pokemon.side.pokemon[i]) continue;
if (!pokemon.side.pokemon[i].fainted) break;
}
@@ -1170,7 +1170,7 @@ exports.BattleAbilities = {
desc: "As soon as the user comes into battle, it Transforms into its opponent, copying the opponent's stats exactly, with the exception of HP. Imposter copies all stat changes on the target originating from moves and abilities such as Swords Dance and Intimidate, but not from items such as Choice Specs. Imposter will not Transform the user if the opponent is an Illusion or if the opponent is behind a Substitute.",
shortDesc: "On switch-in, this Pokemon copies the foe it's facing; stats, moves, types, Ability.",
onStart: function(pokemon) {
- var target = pokemon.side.foe.active[pokemon.side.foe.active.length-1-pokemon.position];
+ var target = pokemon.side.foe.active[pokemon.side.foe.active.length - 1 - pokemon.position];
if (target) {
pokemon.transformInto(target, pokemon);
}
@@ -1222,13 +1222,13 @@ exports.BattleAbilities = {
shortDesc: "On switch-in, this Pokemon lowers adjacent foes' Attack by 1.",
onStart: function(pokemon) {
var foeactive = pokemon.side.foe.active;
- for (var i=0; i= target.hp && effect && effect.effectType === 'Move') {
- this.add('-activate',target,'Sturdy');
+ this.add('-activate', target, 'Sturdy');
return target.hp - 1;
}
},
@@ -2695,14 +2695,14 @@ exports.BattleAbilities = {
shortDesc: "When this Pokemon has 1/3 or less of its max HP, its Bug attacks do 1.5x damage.",
onModifyAtkPriority: 5,
onModifyAtk: function(atk, attacker, defender, move) {
- if (move.type === 'Bug' && attacker.hp <= attacker.maxhp/3) {
+ if (move.type === 'Bug' && attacker.hp <= attacker.maxhp / 3) {
this.debug('Swarm boost');
return this.chainModify(1.5);
}
},
onModifySpAPriority: 5,
onModifySpA: function(atk, attacker, defender, move) {
- if (move.type === 'Bug' && attacker.hp <= attacker.maxhp/3) {
+ if (move.type === 'Bug' && attacker.hp <= attacker.maxhp / 3) {
this.debug('Swarm boost');
return this.chainModify(1.5);
}
@@ -2755,7 +2755,7 @@ exports.BattleAbilities = {
return;
}
if (pokemon.setItem(sourceItem)) {
- this.add('-activate', pokemon, 'ability: Symbiosis', sourceItem, '[of] '+this.effectData.target);
+ this.add('-activate', pokemon, 'ability: Symbiosis', sourceItem, '[of] ' + this.effectData.target);
}
},
id: "symbiosis",
@@ -2883,14 +2883,14 @@ exports.BattleAbilities = {
shortDesc: "When this Pokemon has 1/3 or less of its max HP, its Water attacks do 1.5x damage.",
onModifyAtkPriority: 5,
onModifyAtk: function(atk, attacker, defender, move) {
- if (move.type === 'Water' && attacker.hp <= attacker.maxhp/3) {
+ if (move.type === 'Water' && attacker.hp <= attacker.maxhp / 3) {
this.debug('Torrent boost');
return this.chainModify(1.5);
}
},
onModifySpAPriority: 5,
onModifySpA: function(atk, attacker, defender, move) {
- if (move.type === 'Water' && attacker.hp <= attacker.maxhp/3) {
+ if (move.type === 'Water' && attacker.hp <= attacker.maxhp / 3) {
this.debug('Torrent boost');
return this.chainModify(1.5);
}
@@ -2940,7 +2940,7 @@ exports.BattleAbilities = {
if (bannedAbilities[target.ability]) {
return;
}
- this.add('-ability',pokemon, ability,'[from] ability: Trace','[of] '+target);
+ this.add('-ability', pokemon, ability, '[from] ability: Trace', '[of] ' + target);
pokemon.setAbility(ability);
},
id: "trace",
@@ -2953,7 +2953,7 @@ exports.BattleAbilities = {
shortDesc: "This Pokemon skips every other turn instead of using a move.",
onBeforeMove: function(pokemon, target, move) {
if (pokemon.removeVolatile('truant')) {
- this.add('cant',pokemon,'ability: Truant', move);
+ this.add('cant', pokemon, 'ability: Truant', move);
return false;
}
pokemon.addVolatile('truant');
@@ -3034,7 +3034,7 @@ exports.BattleAbilities = {
desc: "While this Pokemon is active, prevents opposing Pokemon from using their Berries.",
shortDesc: "While this Pokemon is active, prevents opposing Pokemon from using their Berries.",
onStart: function(pokemon) {
- this.add('-ability',pokemon,'Unnerve',pokemon.side.foe);
+ this.add('-ability', pokemon, 'Unnerve', pokemon.side.foe);
},
onFoeEatItem: false,
id: "unnerve",
@@ -3076,7 +3076,7 @@ exports.BattleAbilities = {
shortDesc: "This Pokemon heals 1/4 of its max HP when hit by Electric moves; Electric immunity.",
onTryHit: function(target, source, move) {
if (target !== source && move.type === 'Electric') {
- if (!this.heal(target.maxhp/4)) {
+ if (!this.heal(target.maxhp / 4)) {
this.add('-immune', target, '[msg]');
}
return null;
@@ -3092,7 +3092,7 @@ exports.BattleAbilities = {
shortDesc: "This Pokemon heals 1/4 of its max HP when hit by Water moves; Water immunity.",
onTryHit: function(target, source, move) {
if (target !== source && move.type === 'Water') {
- if (!this.heal(target.maxhp/4)) {
+ if (!this.heal(target.maxhp / 4)) {
this.add('-immune', target, '[msg]');
}
return null;
@@ -3144,7 +3144,7 @@ exports.BattleAbilities = {
showMsg = true;
}
}
- if (showMsg && !effect.secondaries) this.add("-fail", target, "unboost", "[from] ability: White Smoke", "[of] "+target);
+ if (showMsg && !effect.secondaries) this.add("-fail", target, "unboost", "[from] ability: White Smoke", "[of] " + target);
},
id: "whitesmoke",
name: "White Smoke",
@@ -3156,7 +3156,7 @@ exports.BattleAbilities = {
shortDesc: "This Pokemon can only be damaged by super effective moves and indirect damage.",
onTryHit: function(target, source, move) {
if (target === source || move.category === 'Status' || move.type === '???' || move.id === 'struggle') return;
- this.debug('Wonder Guard immunity: '+move.id);
+ this.debug('Wonder Guard immunity: ' + move.id);
if (this.getEffectiveness(move, target) <= 0) {
this.add('-activate', target, 'ability: Wonder Guard');
return null;
@@ -3190,9 +3190,9 @@ exports.BattleAbilities = {
if (pokemon.baseTemplate.species !== 'Darmanitan') {
return;
}
- if (pokemon.hp <= pokemon.maxhp/2 && pokemon.template.speciesid==='darmanitan'){
+ if (pokemon.hp <= pokemon.maxhp / 2 && pokemon.template.speciesid === 'darmanitan'){
pokemon.addVolatile('zenmode');
- } else if (pokemon.hp > pokemon.maxhp/2 && pokemon.template.speciesid==='darmanitanzen') {
+ } else if (pokemon.hp > pokemon.maxhp / 2 && pokemon.template.speciesid === 'darmanitanzen') {
pokemon.removeVolatile('zenmode');
}
},
diff --git a/data/items.js b/data/items.js
index 019bcba5c5..47fb9c10e2 100644
--- a/data/items.js
+++ b/data/items.js
@@ -98,12 +98,12 @@ exports.BattleItems = {
type: "Dragon"
},
onUpdate: function(pokemon) {
- if (pokemon.hp <= pokemon.maxhp/2) {
+ if (pokemon.hp <= pokemon.maxhp / 2) {
pokemon.eatItem();
}
},
onEat: function(pokemon) {
- this.heal(pokemon.maxhp/8);
+ this.heal(pokemon.maxhp / 8);
if (pokemon.getNature().minus === 'spd') {
pokemon.addVolatile('confusion');
}
@@ -126,14 +126,14 @@ exports.BattleItems = {
if (type === 'Ground') return false;
},
onAfterDamage: function(damage, target, source, effect) {
- this.debug('effect: '+effect.id);
+ this.debug('effect: ' + effect.id);
if (effect.effectType === 'Move') {
this.add('-enditem', target, 'Air Balloon');
target.setItem('');
}
},
onAfterSubDamage: function(damage, target, source, effect) {
- this.debug('effect: '+effect.id);
+ this.debug('effect: ' + effect.id);
if (effect.effectType === 'Move') {
this.add('-enditem', target, 'Air Balloon');
target.setItem('');
@@ -181,7 +181,7 @@ exports.BattleItems = {
type: "Ground"
},
onUpdate: function(pokemon) {
- if (pokemon.hp <= pokemon.maxhp/4|| (pokemon.hp <= pokemon.maxhp/2 && pokemon.hasAbility('gluttony'))) {
+ if (pokemon.hp <= pokemon.maxhp / 4|| (pokemon.hp <= pokemon.maxhp / 2 && pokemon.hasAbility('gluttony'))) {
pokemon.eatItem();
}
},
@@ -239,7 +239,7 @@ exports.BattleItems = {
},
onModifyPokemon: function(pokemon) {
var moves = pokemon.moveset;
- for (var i=0; i= target.hp && effect && effect.effectType === 'Move') {
- this.add("-message",target.name+" held on using its Focus Band! (placeholder)");
+ this.add("-message", target.name + " held on using its Focus Band! (placeholder)");
return target.hp - 1;
}
},
@@ -1455,7 +1455,7 @@ exports.BattleItems = {
type: "Ice"
},
onUpdate: function(pokemon) {
- if (pokemon.hp <= pokemon.maxhp/4 || (pokemon.hp <= pokemon.maxhp/2 && pokemon.hasAbility('gluttony'))) {
+ if (pokemon.hp <= pokemon.maxhp / 4 || (pokemon.hp <= pokemon.maxhp / 2 && pokemon.hasAbility('gluttony'))) {
pokemon.eatItem();
}
},
@@ -1518,7 +1518,7 @@ exports.BattleItems = {
if (target === source || move.category === 'Status') return;
if (move.type === 'Ghost') {
if (source.useItem()) {
- this.add('-enditem', source, 'Ghost Gem', '[from] gem', '[move] '+move.name);
+ this.add('-enditem', source, 'Ghost Gem', '[from] gem', '[move] ' + move.name);
source.addVolatile('gem');
}
}
@@ -1537,7 +1537,7 @@ exports.BattleItems = {
if (target === source || move.category === 'Status') return;
if (move.type === 'Grass') {
if (source.useItem()) {
- this.add('-enditem', source, 'Grass Gem', '[from] gem', '[move] '+move.name);
+ this.add('-enditem', source, 'Grass Gem', '[from] gem', '[move] ' + move.name);
source.addVolatile('gem');
}
}
@@ -1612,7 +1612,7 @@ exports.BattleItems = {
if (target === source || move.category === 'Status') return;
if (move.type === 'Ground') {
if (source.useItem()) {
- this.add('-enditem', source, 'Ground Gem', '[from] gem', '[move] '+move.name);
+ this.add('-enditem', source, 'Ground Gem', '[from] gem', '[move] ' + move.name);
source.addVolatile('gem');
}
}
@@ -1763,12 +1763,12 @@ exports.BattleItems = {
type: "Dark"
},
onUpdate: function(pokemon) {
- if (pokemon.hp <= pokemon.maxhp/2) {
+ if (pokemon.hp <= pokemon.maxhp / 2) {
pokemon.eatItem();
}
},
onEat: function(pokemon) {
- this.heal(pokemon.maxhp/8);
+ this.heal(pokemon.maxhp / 8);
if (pokemon.getNature().minus === 'def') {
pokemon.addVolatile('confusion');
}
@@ -1787,7 +1787,7 @@ exports.BattleItems = {
if (target === source || move.category === 'Status') return;
if (move.type === 'Ice') {
if (source.useItem()) {
- this.add('-enditem', source, 'Ice Gem', '[from] gem', '[move] '+move.name);
+ this.add('-enditem', source, 'Ice Gem', '[from] gem', '[move] ' + move.name);
source.addVolatile('gem');
}
}
@@ -1891,7 +1891,7 @@ exports.BattleItems = {
onAfterMoveSecondary: function(target, source, move) {
if (source && source !== target && move && move.category === 'Physical') {
if (target.eatItem()) {
- this.damage(source.maxhp/8, source, target);
+ this.damage(source.maxhp / 8, source, target);
}
}
},
@@ -2003,7 +2003,7 @@ exports.BattleItems = {
onModifyMove: function(move) {
if (move.category !== "Status") {
if (!move.secondaries) move.secondaries = [];
- for (var i=0; i move.maxpp) move.pp = move.maxpp;
- this.add("-message",pokemon.name+" restored "+move.move+"'s PP using its Leppa Berry! (placeholder)");
+ this.add("-message", pokemon.name + " restored " + move.move + "'s PP using its Leppa Berry! (placeholder)");
},
num: 154,
gen: 3,
@@ -2172,7 +2172,7 @@ exports.BattleItems = {
type: "Grass"
},
onUpdate: function(pokemon) {
- if (pokemon.hp <= pokemon.maxhp/4 || (pokemon.hp <= pokemon.maxhp/2 && pokemon.hasAbility('gluttony'))) {
+ if (pokemon.hp <= pokemon.maxhp / 4 || (pokemon.hp <= pokemon.maxhp / 2 && pokemon.hasAbility('gluttony'))) {
pokemon.eatItem();
}
},
@@ -2200,7 +2200,7 @@ exports.BattleItems = {
duration: 1,
onAfterMoveSecondarySelf: function(source, target, move) {
if (move && move.effectType === 'Move' && source && source.volatiles['lifeorb']) {
- this.damage(source.maxhp/10, source, source, this.getItem('lifeorb'));
+ this.damage(source.maxhp / 10, source, source, this.getItem('lifeorb'));
source.removeVolatile('lifeorb');
}
}
@@ -2395,12 +2395,12 @@ exports.BattleItems = {
type: "Ghost"
},
onUpdate: function(pokemon) {
- if (pokemon.hp <= pokemon.maxhp/2) {
+ if (pokemon.hp <= pokemon.maxhp / 2) {
pokemon.eatItem();
}
},
onEat: function(pokemon) {
- this.heal(pokemon.maxhp/8);
+ this.heal(pokemon.maxhp / 8);
if (pokemon.getNature().minus === 'spe') {
pokemon.addVolatile('confusion');
}
@@ -2527,10 +2527,10 @@ exports.BattleItems = {
fling: {
basePower: 10,
effect: function(pokemon) {
- var conditions = ['attract','taunt','encore','torment','disable'];
- for (var i=0; i 0) {
- this.heal(source.lastDamage/8, source);
+ this.heal(source.lastDamage / 8, source);
}
},
num: 253,
@@ -3752,12 +3752,12 @@ exports.BattleItems = {
type: "Psychic"
},
onUpdate: function(pokemon) {
- if (pokemon.hp <= pokemon.maxhp/2) {
+ if (pokemon.hp <= pokemon.maxhp / 2) {
pokemon.eatItem();
}
},
onEat: function(pokemon) {
- this.heal(pokemon.maxhp/4);
+ this.heal(pokemon.maxhp / 4);
},
num: 158,
gen: 3,
@@ -3944,7 +3944,7 @@ exports.BattleItems = {
type: "Psychic"
},
onUpdate: function(pokemon) {
- if (pokemon.hp <= pokemon.maxhp/4 || (pokemon.hp <= pokemon.maxhp/2 && pokemon.hasAbility('gluttony'))) {
+ if (pokemon.hp <= pokemon.maxhp / 4 || (pokemon.hp <= pokemon.maxhp / 2 && pokemon.hasAbility('gluttony'))) {
pokemon.eatItem();
}
},
@@ -3976,7 +3976,7 @@ exports.BattleItems = {
if (target === source || move.category === 'Status') return;
if (move.type === 'Steel') {
if (source.useItem()) {
- this.add('-enditem', source, 'Steel Gem', '[from] gem', '[move] '+move.name);
+ this.add('-enditem', source, 'Steel Gem', '[from] gem', '[move] ' + move.name);
source.addVolatile('gem');
}
}
@@ -4011,7 +4011,7 @@ exports.BattleItems = {
onResidualOrder: 26,
onResidualSubOrder: 2,
onResidual: function(pokemon) {
- this.damage(pokemon.maxhp/8);
+ this.damage(pokemon.maxhp / 8);
},
onHit: function(target, source, move) {
if (source && source !== target && !source.item && move && move.isContact) {
@@ -4222,7 +4222,7 @@ exports.BattleItems = {
if (target === source || move.category === 'Status') return;
if (move.type === 'Water') {
if (source.useItem()) {
- this.add('-enditem', source, 'Water Gem', '[from] gem', '[move] '+move.name);
+ this.add('-enditem', source, 'Water Gem', '[from] gem', '[move] ' + move.name);
source.addVolatile('gem');
}
}
@@ -4354,12 +4354,12 @@ exports.BattleItems = {
type: "Rock"
},
onUpdate: function(pokemon) {
- if (pokemon.hp <= pokemon.maxhp/2) {
+ if (pokemon.hp <= pokemon.maxhp / 2) {
pokemon.eatItem();
}
},
onEat: function(pokemon) {
- this.heal(pokemon.maxhp/8);
+ this.heal(pokemon.maxhp / 8);
if (pokemon.getNature().minus === 'spa') {
pokemon.addVolatile('confusion');
}
diff --git a/data/moves.js b/data/moves.js
index 124755a121..921b11b2c1 100644
--- a/data/moves.js
+++ b/data/moves.js
@@ -10,7 +10,7 @@ exports.BattleMovedex = {
name: "Absorb",
pp: 25,
priority: 0,
- drain: [1,2],
+ drain: [1, 2],
secondary: false,
target: "normal",
type: "Grass"
@@ -356,7 +356,7 @@ exports.BattleMovedex = {
},
onResidualOrder: 6,
onResidual: function(pokemon) {
- this.heal(pokemon.maxhp/16);
+ this.heal(pokemon.maxhp / 16);
}
},
secondary: false,
@@ -392,7 +392,7 @@ exports.BattleMovedex = {
pp: 20,
priority: 0,
isContact: true,
- multihit: [2,5],
+ multihit: [2, 5],
secondary: false,
target: "normal",
type: "Fighting"
@@ -412,10 +412,10 @@ exports.BattleMovedex = {
isSnatchable: true,
onHit: function(pokemon, source) {
var side = pokemon.side;
- for (var i=0; i 0 && pokemon.lastAttackedBy && pokemon.lastAttackedBy.thisTurn) {
- this.debug('Boosted for getting hit by '+pokemon.lastAttackedBy.move);
+ this.debug('Boosted for getting hit by ' + pokemon.lastAttackedBy.move);
return 120;
}
return 60;
@@ -739,7 +739,7 @@ exports.BattleMovedex = {
pp: 20,
priority: 0,
isBullet: true,
- multihit: [2,5],
+ multihit: [2, 5],
secondary: false,
target: "normal",
type: "Normal"
@@ -791,7 +791,7 @@ exports.BattleMovedex = {
return 5 + Math.floor(pokemon.side.pokemon[pokemon.volatiles.beatup.index].template.baseStats.atk / 10);
},
category: "Physical",
- desc: "Deals damage to one adjacent target and hits one time for the user and one time for each unfainted Pokemon without a major status problem in the user's party. The power of each hit is equal to 5+(X/10), where X is each participating Pokemon's base Attack; each hit is considered to come from the user.",
+ desc: "Deals damage to one adjacent target and hits one time for the user and one time for each unfainted Pokemon without a major status problem in the user's party. The power of each hit is equal to 5 + (X/10), where X is each participating Pokemon's base Attack; each hit is considered to come from the user.",
shortDesc: "All healthy allies aid in damaging the target.",
id: "beatup",
name: "Beat Up",
@@ -856,10 +856,10 @@ exports.BattleMovedex = {
priority: 0,
isSnatchable: true,
onHit: function(target) {
- if (target.hp <= target.maxhp/2 || target.boosts.atk >= 6 || target.maxhp === 1) { // Shedinja clause
+ if (target.hp <= target.maxhp / 2 || target.boosts.atk >= 6 || target.maxhp === 1) { // Shedinja clause
return false;
}
- this.directDamage(target.maxhp/2);
+ this.directDamage(target.maxhp / 2);
target.setBoost({atk: 6});
this.add('-setboost', target, 'atk', '6', '[from] move: Belly Drum');
},
@@ -890,7 +890,7 @@ exports.BattleMovedex = {
source.item = yourItem;
return false;
}
- this.add('-item', target, yourItem.name, '[from] move: Bestow', '[of] '+source);
+ this.add('-item', target, yourItem.name, '[from] move: Bestow', '[of] ' + source);
},
secondary: false,
target: "normal",
@@ -943,7 +943,7 @@ exports.BattleMovedex = {
this.add('-immune', target, '[msg]');
return false;
}
- this.moveHit(target, pokemon, 'bide', {damage: this.effectData.totalDamage*2});
+ this.moveHit(target, pokemon, 'bide', {damage: this.effectData.totalDamage * 2});
return false;
}
this.add('-activate', pokemon, 'Bide');
@@ -1163,7 +1163,7 @@ exports.BattleMovedex = {
name: "Bone Rush",
pp: 10,
priority: 0,
- multihit: [2,5],
+ multihit: [2, 5],
secondary: false,
target: "normal",
type: "Ground"
@@ -1267,7 +1267,7 @@ exports.BattleMovedex = {
pp: 15,
priority: 0,
isContact: true,
- recoil: [33,100],
+ recoil: [33, 100],
secondary: false,
target: "any",
type: "Flying"
@@ -1372,7 +1372,7 @@ exports.BattleMovedex = {
onHit: function(target, source) {
var item = target.getItem();
if (source.hp && item.isBerry && target.takeItem(source)) {
- this.add('-enditem', target, item.name, '[from] stealeat', '[move] Bug Bite', '[of] '+source);
+ this.add('-enditem', target, item.name, '[from] stealeat', '[move] Bug Bite', '[of] ' + source);
this.singleEvent('Eat', item, null, source, null, null);
source.ateBerry = true;
}
@@ -1475,7 +1475,7 @@ exports.BattleMovedex = {
pp: 30,
priority: 0,
isBullet: true,
- multihit: [2,5],
+ multihit: [2, 5],
secondary: false,
target: "normal",
type: "Grass"
@@ -1734,7 +1734,7 @@ exports.BattleMovedex = {
priority: 0,
onHit: function(target) {
target.clearBoosts();
- this.add('-clearboost',target);
+ this.add('-clearboost', target);
},
secondary: false,
target: "normal",
@@ -1798,7 +1798,7 @@ exports.BattleMovedex = {
priority: 0,
isContact: true,
isPunchAttack: true,
- multihit: [2,5],
+ multihit: [2, 5],
secondary: false,
target: "normal",
type: "Normal"
@@ -2079,7 +2079,7 @@ exports.BattleMovedex = {
target.item = yourItem.id; // bypass setItem so we don't break choicelock or anything
return;
}
- this.add('-item', source, yourItem, '[from] move: Covet', '[of] '+target);
+ this.add('-item', source, yourItem, '[from] move: Covet', '[of] ' + target);
},
secondary: false,
target: "normal",
@@ -2263,7 +2263,7 @@ exports.BattleMovedex = {
if (!source.hasType('Ghost')) {
delete move.volatileStatus;
delete move.onHit;
- move.self = { boosts: {atk:1,def:1,spe:-1}};
+ move.self = { boosts: {atk:1, def:1, spe:-1}};
move.target = move.nonGhostTarget;
}
},
@@ -2271,15 +2271,15 @@ exports.BattleMovedex = {
if (move.volatileStatus && target.volatiles.curse) return false;
},
onHit: function(target, source) {
- this.directDamage(source.maxhp/2, source, source);
+ this.directDamage(source.maxhp / 2, source, source);
},
effect: {
onStart: function(pokemon, source) {
- this.add('-start', pokemon, 'Curse', '[of] '+source);
+ this.add('-start', pokemon, 'Curse', '[of] ' + source);
},
onResidualOrder: 10,
onResidual: function(pokemon) {
- this.damage(pokemon.maxhp/4);
+ this.damage(pokemon.maxhp / 4);
}
},
secondary: false,
@@ -2414,13 +2414,13 @@ exports.BattleMovedex = {
var sideConditions = {reflect:1, lightscreen:1, safeguard:1, mist:1, spikes:1, toxicspikes:1, stealthrock:1, stickyweb:1};
for (var i in sideConditions) {
if (target.side.removeSideCondition(i)) {
- this.add('-sideend', target.side, this.getEffect(i).name, '[from] move: Defog', '[of] '+target);
+ this.add('-sideend', target.side, this.getEffect(i).name, '[from] move: Defog', '[of] ' + target);
}
}
for (var i in sideConditions) {
if (i === 'reflect' || i === 'lightscreen') continue;
if (source.side.removeSideCondition(i)) {
- this.add('-sideend', source.side, this.getEffect(i).name, '[from] move: Defog', '[of] '+source);
+ this.add('-sideend', source.side, this.getEffect(i).name, '[from] move: Defog', '[of] ' + source);
}
}
},
@@ -2582,7 +2582,7 @@ exports.BattleMovedex = {
return false;
}
var moves = pokemon.moveset;
- for (var i=0; i pokemon.hp) {
return target.hp - pokemon.hp;
}
@@ -3510,12 +3510,12 @@ exports.BattleMovedex = {
effect: {
duration: 1,
onStart: function(target) {
- this.add('-singleturn',target,'move: Endure');
+ this.add('-singleturn', target, 'move: Endure');
},
onDamagePriority: -10,
onDamage: function(damage, target, source, effect) {
if (effect && effect.effectType === 'Move' && damage >= target.hp) {
- return target.hp-1;
+ return target.hp - 1;
}
}
},
@@ -3581,7 +3581,7 @@ exports.BattleMovedex = {
accuracy: 100,
basePower: 150,
basePowerCallback: function(pokemon) {
- return 150*pokemon.hp/pokemon.maxhp;
+ return 150 * pokemon.hp / pokemon.maxhp;
},
category: "Special",
desc: "Deals damage to all adjacent foes. Power is equal to (user's current HP * 150 / user's maximum HP), rounded down, but not less than 1.",
@@ -3963,7 +3963,7 @@ exports.BattleMovedex = {
pp: 10,
priority: 0,
onTryHit: function(target, source, move) {
- for (var i=0; i 150) power = 150;
- this.debug(''+power+' bp');
+ this.debug('' + power + ' bp');
return power;
},
category: "Physical",
@@ -5591,8 +5591,8 @@ exports.BattleMovedex = {
priority: 0,
onHitField: function() {
this.add('-clearallboost');
- for (var i=0; i=0; i--) {
+ for (var i = this.queue.length - 1; i >= 0; i--) {
if (this.queue[i].choice === 'residual') {
- this.queue.splice(i,0,decision);
+ this.queue.splice(i, 0, decision);
break;
}
}
@@ -10242,16 +10242,16 @@ exports.BattleMovedex = {
self: {
onHit: function(pokemon) {
if (pokemon.hp && pokemon.removeVolatile('leechseed')) {
- this.add('-end', pokemon, 'Leech Seed', '[from] move: Rapid Spin', '[of] '+pokemon);
+ this.add('-end', pokemon, 'Leech Seed', '[from] move: Rapid Spin', '[of] ' + pokemon);
}
var sideConditions = {spikes:1, toxicspikes:1, stealthrock:1, stickyweb:1};
for (var i in sideConditions) {
if (pokemon.hp && pokemon.side.removeSideCondition(i)) {
- this.add('-sideend', pokemon.side, this.getEffect(i).name, '[from] move: Rapid Spin', '[of] '+pokemon);
+ this.add('-sideend', pokemon.side, this.getEffect(i).name, '[from] move: Rapid Spin', '[of] ' + pokemon);
}
}
if (pokemon.hp && pokemon.volatiles['partiallytrapped']) {
- this.add('-remove', pokemon, pokemon.volatiles['partiallytrapped'].sourceEffect.name, '[from] move: Rapid Spin', '[of] '+pokemon, '[partiallytrapped]');
+ this.add('-remove', pokemon, pokemon.volatiles['partiallytrapped'].sourceEffect.name, '[from] move: Rapid Spin', '[of] ' + pokemon, '[partiallytrapped]');
delete pokemon.volatiles['partiallytrapped'];
}
}
@@ -10340,7 +10340,7 @@ exports.BattleMovedex = {
pp: 10,
priority: 0,
isSnatchable: true,
- heal: [1,2],
+ heal: [1, 2],
secondary: false,
target: "self",
type: "Normal"
@@ -10399,11 +10399,11 @@ exports.BattleMovedex = {
}
},
onStart: function(side) {
- this.add('-sidestart',side,'Reflect');
+ this.add('-sidestart', side, 'Reflect');
},
onResidualOrder: 21,
onEnd: function(side) {
- this.add('-sideend',side,'Reflect');
+ this.add('-sideend', side, 'Reflect');
}
},
secondary: false,
@@ -10423,9 +10423,9 @@ exports.BattleMovedex = {
priority: 0,
onHit: function(target, source) {
if (source.num === 493) return false;
- this.add('-start', source, 'typechange', target.getTypes(true).join('/'), '[from] move: Reflect Type', '[of] '+target);
+ this.add('-start', source, 'typechange', target.getTypes(true).join('/'), '[from] move: Reflect Type', '[of] ' + target);
source.typesData = [];
- for (var i=0, l=target.typesData.length; i 0 && pokemon.lastAttackedBy && pokemon.lastAttackedBy.thisTurn) {
- this.debug('Boosted for getting hit by '+pokemon.lastAttackedBy.move);
+ this.debug('Boosted for getting hit by ' + pokemon.lastAttackedBy.move);
return 120;
}
return 60;
@@ -10670,7 +10670,7 @@ exports.BattleMovedex = {
name: "Rock Blast",
pp: 10,
priority: 0,
- multihit: [2,5],
+ multihit: [2, 5],
secondary: false,
target: "normal",
type: "Rock"
@@ -10827,7 +10827,7 @@ exports.BattleMovedex = {
},
onHit: function(target, source) {
if (source.setAbility(target.ability)) {
- this.add('-ability', source, source.ability, '[from] move: Role Play', '[of] '+target);
+ this.add('-ability', source, source.ability, '[from] move: Role Play', '[of] ' + target);
return;
}
return false;
@@ -10869,7 +10869,7 @@ exports.BattleMovedex = {
if (pokemon.volatiles.defensecurl) {
bp *= 2;
}
- this.debug("Rollout bp: "+bp);
+ this.debug("Rollout bp: " + bp);
return bp;
},
category: "Physical",
@@ -10916,14 +10916,14 @@ exports.BattleMovedex = {
pp: 10,
priority: 0,
isSnatchable: true,
- heal: [1,2],
+ heal: [1, 2],
self: {
volatileStatus: 'roost',
},
effect: {
duration: 1,
onStart: function(pokemon) {
- for (var i=0, l=pokemon.typesData.length; i= 2) factor = 2;
- if (typeMod == -1) factor = 16;
+ if (typeMod === -1) factor = 16;
if (typeMod <= -2) factor = 32;
- var damage = this.damage(pokemon.maxhp/factor);
+ var damage = this.damage(pokemon.maxhp / factor);
}
},
secondary: false,
@@ -12703,13 +12703,13 @@ exports.BattleMovedex = {
effect: {
onStart: function(target) {
this.effectData.layers = 1;
- this.add('-start', target, 'stockpile'+this.effectData.layers);
+ this.add('-start', target, 'stockpile' + this.effectData.layers);
this.boost({def:1, spd:1}, target, target, this.getMove('stockpile'));
},
onRestart: function(target) {
if (this.effectData.layers >= 3) return false;
this.effectData.layers++;
- this.add('-start', target, 'stockpile'+this.effectData.layers);
+ this.add('-start', target, 'stockpile' + this.effectData.layers);
this.boost({def:1, spd:1}, target, target, this.getMove('stockpile'));
},
onEnd: function(target) {
@@ -12767,8 +12767,8 @@ exports.BattleMovedex = {
return 20 + 20 * pokemon.positiveBoosts();
},
category: "Special",
- desc: "Deals damage to one adjacent target. Power is equal to 20+(X*20), where X is the user's total stat stage changes that are greater than 0.",
- shortDesc: "+20 power for each of the user's stat boosts.",
+ desc: "Deals damage to one adjacent target. Power is equal to 20 + (X * 20), where X is the user's total stat stage changes that are greater than 0.",
+ shortDesc: " + 20 power for each of the user's stat boosts.",
id: "storedpower",
isViable: true,
name: "Stored Power",
@@ -12870,7 +12870,7 @@ exports.BattleMovedex = {
},
self: {
onHit: function(source) {
- this.directDamage(source.maxhp/4, source, source, 'strugglerecoil');
+ this.directDamage(source.maxhp / 4, source, source, 'strugglerecoil');
}
},
secondary: false,
@@ -12930,7 +12930,7 @@ exports.BattleMovedex = {
pp: 25,
priority: 0,
isContact: true,
- recoil: [1,4],
+ recoil: [1, 4],
secondary: false,
target: "normal",
type: "Fighting"
@@ -12954,18 +12954,18 @@ exports.BattleMovedex = {
this.add('-fail', target, 'move: Substitute');
return null;
}
- if (target.hp <= target.maxhp/4 || target.maxhp === 1) { // Shedinja clause
+ if (target.hp <= target.maxhp / 4 || target.maxhp === 1) { // Shedinja clause
this.add('-fail', target, 'move: Substitute', '[weak]');
return null;
}
},
onHit: function(target) {
- this.directDamage(target.maxhp/4);
+ this.directDamage(target.maxhp / 4);
},
effect: {
onStart: function(target) {
this.add('-start', target, 'Substitute');
- this.effectData.hp = Math.floor(target.maxhp/4);
+ this.effectData.hp = Math.floor(target.maxhp / 4);
delete target.volatiles['partiallytrapped'];
},
onTryPrimaryHitPriority: -1,
@@ -13067,7 +13067,7 @@ exports.BattleMovedex = {
accuracy: 90,
basePower: 0,
damageCallback: function(pokemon, target) {
- return target.hp/2;
+ return target.hp / 2;
},
category: "Physical",
desc: "Deals damage to one adjacent target equal to half of its current HP, rounded down, but not less than 1HP. Makes contact.",
@@ -13173,7 +13173,7 @@ exports.BattleMovedex = {
if (!pokemon.volatiles['stockpile'] || !pokemon.volatiles['stockpile'].layers) return false;
},
onHit: function(pokemon) {
- var healAmount = [0.25,0.5,1];
+ var healAmount = [0.25, 0.5, 1];
this.heal(this.modify(pokemon.maxhp, healAmount[(pokemon.volatiles['stockpile'].layers - 1)]));
pokemon.removeVolatile('stockpile');
},
@@ -13250,7 +13250,7 @@ exports.BattleMovedex = {
if (myItem) source.item = myItem;
return false;
}
- this.add('-activate', source, 'move: Trick', '[of] '+target);
+ this.add('-activate', source, 'move: Trick', '[of] ' + target);
if (myItem) {
target.setItem(myItem);
this.add('-item', target, myItem, '[from] Trick');
@@ -13317,7 +13317,7 @@ exports.BattleMovedex = {
isSnatchable: true,
onHit: function(pokemon) {
if (this.isWeather('sunnyday')) this.heal(this.modify(pokemon.maxhp, 0.667));
- else if (this.isWeather(['raindance','sandstorm','hail'])) this.heal(this.modify(pokemon.maxhp, 0.25));
+ else if (this.isWeather(['raindance', 'sandstorm', 'hail'])) this.heal(this.modify(pokemon.maxhp, 0.25));
else this.heal(this.modify(pokemon.maxhp, 0.5));
},
secondary: false,
@@ -13373,7 +13373,7 @@ exports.BattleMovedex = {
pp: 10,
priority: 0,
isContact: true,
- multihit: [2,5],
+ multihit: [2, 5],
secondary: false,
target: "normal",
type: "Normal"
@@ -13446,7 +13446,7 @@ exports.BattleMovedex = {
pp: 20,
priority: 0,
isContact: true,
- recoil: [1,4],
+ recoil: [1, 4],
secondary: false,
target: "normal",
type: "Normal"
@@ -13479,7 +13479,7 @@ exports.BattleMovedex = {
},
onModifyPokemon: function(pokemon) {
var moves = pokemon.moveset;
- for (var i=0; i= 2) {
pokemon.trySetStatus('tox');
@@ -13968,9 +13968,9 @@ exports.BattleMovedex = {
chance: 20,
onHit: function(target, source) {
var result = this.random(3);
- if (result===0) {
+ if (result === 0) {
target.trySetStatus('brn', source);
- } else if (result===1) {
+ } else if (result === 1) {
target.trySetStatus('par', source);
} else {
target.trySetStatus('frz', source);
@@ -14000,7 +14000,7 @@ exports.BattleMovedex = {
if (myItem) source.item = myItem;
return false;
}
- this.add('-activate', source, 'move: Trick', '[of] '+target);
+ this.add('-activate', source, 'move: Trick', '[of] ' + target);
if (myItem) {
target.setItem(myItem);
this.add('-item', target, myItem, '[from] move: Trick');
@@ -14049,9 +14049,9 @@ exports.BattleMovedex = {
priority: -7,
onHitField: function(target, source, effect) {
if (this.pseudoWeather['trickroom']) {
- this.removePseudoWeather('trickroom', source, effect, '[of] '+source);
+ this.removePseudoWeather('trickroom', source, effect, '[of] ' + source);
} else {
- this.addPseudoWeather('trickroom', source, effect, '[of] '+source);
+ this.addPseudoWeather('trickroom', source, effect, '[of] ' + source);
}
},
effect: {
@@ -14063,7 +14063,7 @@ exports.BattleMovedex = {
return 5;
},
onStart: function(target, source) {
- this.add('-fieldstart', 'move: Trick Room', '[of] '+source);
+ this.add('-fieldstart', 'move: Trick Room', '[of] ' + source);
this.getStatCallback = function(stat, statName) {
// If stat is speed and does not overflow (Trick Room Glitch) return negative speed.
if (statName === 'spe' && stat <= 1809) return -stat;
@@ -14096,7 +14096,7 @@ exports.BattleMovedex = {
pp: 10,
priority: 0,
isContact: true,
- multihit: [3,3],
+ multihit: [3, 3],
effect: {
duration: 1,
onStart: function() {
@@ -14153,7 +14153,7 @@ exports.BattleMovedex = {
name: "Twineedle",
pp: 20,
priority: 0,
- multihit: [2,2],
+ multihit: [2, 2],
secondary: {
chance: 20,
status: 'psn'
@@ -14213,7 +14213,7 @@ exports.BattleMovedex = {
volatileStatus: 'uproar'
},
onTryHit: function(target) {
- for (var i=0; i this.gen) {
- problems.push(set.species+' does not exist in gen '+this.gen+'.');
+ problems.push(set.species + ' does not exist in gen ' + this.gen + '.');
}
var ability = {};
if (set.ability) {
ability = this.getAbility(set.ability);
if (ability.gen > this.gen) {
- problems.push(ability.name+' does not exist in gen '+this.gen+'.');
+ problems.push(ability.name + ' does not exist in gen ' + this.gen + '.');
}
}
- if (set.moves) for (var i=0; i this.gen) {
- problems.push(move.name+' does not exist in gen '+this.gen+'.');
+ problems.push(move.name + ' does not exist in gen ' + this.gen + '.');
} else if (!isNonstandard && move.isNonstandard) {
- problems.push(move.name+' is not a real move.');
+ problems.push(move.name + ' is not a real move.');
}
}
if (item.gen > this.gen) {
- problems.push(item.name+' does not exist in gen '+this.gen+'.');
+ problems.push(item.name + ' does not exist in gen ' + this.gen + '.');
}
if (set.moves && set.moves.length > 4) {
- problems.push((set.name||set.species) + ' has more than four moves.');
+ problems.push((set.name || set.species) + ' has more than four moves.');
}
if (set.level && set.level > 100) {
- problems.push((set.name||set.species) + ' is higher than level 100.');
+ problems.push((set.name || set.species) + ' is higher than level 100.');
}
if (!isNonstandard) {
if (template.isNonstandard) {
- problems.push(set.species+' is not a real Pokemon.');
+ problems.push(set.species + ' is not a real Pokemon.');
}
if (ability.isNonstandard) {
- problems.push(ability.name+' is not a real ability.');
+ problems.push(ability.name + ' is not a real ability.');
}
if (item.isNonstandard) {
problems.push(item.name + ' is not a real item.');
@@ -116,7 +116,7 @@ exports.BattleFormats = {
var moves = [];
if (set.moves) {
var hasMove = {};
- for (var i=0; i= 2) {
- return ["You are limited to two of each ability by the Ability Clause.","(You have more than two " + this.getAbility(ability).name + ")"];
+ return ["You are limited to two of each ability by the Ability Clause.", "(You have more than two " + this.getAbility(ability).name + ")"];
}
abilityTable[ability]++;
} else {
@@ -392,7 +392,7 @@ exports.BattleFormats = {
if (set.moves) {
for (var i in set.moves) {
var move = this.getMove(set.moves[i]);
- if (move.ohko) problems.push(move.name+' is banned by OHKO Clause.');
+ if (move.ohko) problems.push(move.name + ' is banned by OHKO Clause.');
}
}
return problems;
@@ -448,7 +448,7 @@ exports.BattleFormats = {
return;
}
if (status.id === 'slp') {
- for (var i=0; i= team.length) {
diff --git a/data/scripts.js b/data/scripts.js
index f19143d201..c978fc7efa 100644
--- a/data/scripts.js
+++ b/data/scripts.js
@@ -17,7 +17,7 @@ exports.BattleScripts = {
// THIS IS PURELY A SANITY CHECK
// DO NOT TAKE ADVANTAGE OF THIS TO PREVENT A POKEMON FROM MOVING;
// USE this.cancelMove INSTEAD
- this.debug(''+pokemon.id+' INCONSISTENT STATE, ALREADY MOVED: '+pokemon.moveThisTurn);
+ this.debug('' + pokemon.id + ' INCONSISTENT STATE, ALREADY MOVED: ' + pokemon.moveThisTurn);
this.clearActiveMove(true);
return;
}
@@ -85,8 +85,8 @@ exports.BattleScripts = {
var movename = move.name;
if (move.id === 'hiddenpower') movename = 'Hidden Power';
- if (sourceEffect) attrs += '|[from]'+this.getEffect(sourceEffect);
- this.addMove('move', pokemon, movename, target+attrs);
+ if (sourceEffect) attrs += '|[from]' + this.getEffect(sourceEffect);
+ this.addMove('move', pokemon, movename, target + attrs);
if (target === false) {
this.attrLastMove('[notarget]');
@@ -121,16 +121,16 @@ exports.BattleScripts = {
var targets = [];
if (move.target === 'allAdjacent') {
var allyActive = pokemon.side.active;
- for (var i=0; i 1) move.spreadHit = true;
damage = 0;
- for (var i=0; i= mbstmin)
break;
@@ -654,12 +654,12 @@ exports.BattleScripts = {
//random IVs
var ivs = {
- hp: Math.floor(Math.random()*32),
- atk: Math.floor(Math.random()*32),
- def: Math.floor(Math.random()*32),
- spa: Math.floor(Math.random()*32),
- spd: Math.floor(Math.random()*32),
- spe: Math.floor(Math.random()*32)
+ hp: Math.floor(Math.random() * 32),
+ atk: Math.floor(Math.random() * 32),
+ def: Math.floor(Math.random() * 32),
+ spa: Math.floor(Math.random() * 32),
+ spd: Math.floor(Math.random() * 32),
+ spe: Math.floor(Math.random() * 32)
};
//random EVs
@@ -671,21 +671,21 @@ exports.BattleScripts = {
spd: 0,
spe: 0
};
- var s = ["hp","atk","def","spa","spd","spe"];
+ var s = ["hp", "atk", "def", "spa", "spd", "spe"];
var evpool = 510;
do
{
var x = s.sample();
- var y = Math.floor(Math.random()*Math.min(256-evs[x],evpool+1));
- evs[x]+=y;
- evpool-=y;
+ var y = Math.floor(Math.random() * Math.min(256 - evs[x], evpool + 1));
+ evs[x] += y;
+ evpool -= y;
} while (evpool > 0);
//random happiness--useless, since return/frustration is currently a "cheat"
- var happiness = Math.floor(Math.random()*256);
+ var happiness = Math.floor(Math.random() * 256);
//random shininess?
- var shiny = (Math.random()*1024<=1);
+ var shiny = (Math.random() * 1024 <= 1);
//four random unique moves from movepool. don't worry about "attacking" or "viable"
var moves;
@@ -698,7 +698,7 @@ exports.BattleScripts = {
if (pool.length <= 4) {
moves = pool;
} else {
- moves=pool.sample(4);
+ moves = pool.sample(4);
}
team.push({
@@ -727,7 +727,7 @@ exports.BattleScripts = {
// GET IT? UNOWN? BECAUSE WE CAN'T TELL WHAT THE POKEMON IS
template = this.getTemplate('unown');
- var stack = 'Template incompatible with random battles: '+name;
+ var stack = 'Template incompatible with random battles: ' + name;
var fakeErr = {stack: stack};
require('../crashlogger.js')(fakeErr, 'The randbat set generator');
}
@@ -767,13 +767,13 @@ exports.BattleScripts = {
var counter = {};
var setupType = '';
- var j=0;
+ var j = 0;
do {
// Choose next 4 moves from learnset/viable moves and add them to moves list:
- while (moves.length<4 && j 1) rejected = true;
isSetup = true;
break;
@@ -1150,8 +1150,8 @@ exports.BattleScripts = {
}
// Remove rejected moves from the move list.
- if (rejected && j1) replace = true;
+ if (!hasMove['encore'] && Math.random() * 2 > 1) replace = true;
} else if (damagingid === 'focuspunch') {
// Focus Punch is a bad idea without a sub:
if (!hasMove['substitute']) replace = true;
- } else if (damagingid.substr(0,11) === 'hiddenpower' && damagingType === 'Ice') {
+ } else if (damagingid.substr(0, 11) === 'hiddenpower' && damagingType === 'Ice') {
// Mono-HP-Ice is never acceptable.
replace = true;
} else {
@@ -1196,9 +1196,9 @@ exports.BattleScripts = {
}
}
}
- if (replace) moves.splice(damagingMoveIndex[damagingid],1);
+ if (replace) moves.splice(damagingMoveIndex[damagingid], 1);
}
- } else if (damagingMoves.length===2) {
+ } else if (damagingMoves.length === 2) {
// If you have two attacks, neither is STAB, and the combo isn't Ice/Electric, Ghost/Fighting, or Dark/Fighting, reject one of them at random.
var type1 = damagingMoves[0].type, type2 = damagingMoves[1].type;
var typeCombo = [type1, type2].sort().join('/');
@@ -1208,20 +1208,20 @@ exports.BattleScripts = {
} else {
rejectCombo = false;
}
- if (rejectCombo) moves.splice(Math.floor(Math.random()*moves.length),1);
+ if (rejectCombo) moves.splice(Math.floor(Math.random() * moves.length), 1);
} else {
// If you have three or more attacks, and none of them are STAB, reject one of them at random.
var isStab = false;
- for (var l=0; l= 3 && (template.baseStats.spe >= 95 || randomNum>1)) {
+ var randomNum = Math.random() * 2;
+ if (counter.Physical >= 3 && (template.baseStats.spe >= 95 || randomNum > 1)) {
item = 'Choice Band';
- } else if (counter.Special >= 3 && (template.baseStats.spe >= 95 || randomNum>1)) {
+ } else if (counter.Special >= 3 && (template.baseStats.spe >= 95 || randomNum > 1)) {
item = 'Choice Specs';
} else {
item = 'Choice Scarf';
@@ -1463,7 +1463,7 @@ exports.BattleScripts = {
}
if ((hasMove['return'] || hasMove['hyperfang']) && !hasMove['facade']) {
// lol no
- for (var j=0; j= 4 && !hasMove['fakeout'] && !hasMove['suckerpunch'] && !hasMove['flamecharge'] && !hasMove['rapidspin']) {
- if (Math.random()*3 > 1) {
+ if (Math.random() * 3 > 1) {
item = 'Choice Band';
} else {
item = 'Expert Belt';
}
} else if (counter.Special >= 4) {
- if (Math.random()*3 > 1) {
+ if (Math.random() * 3 > 1) {
item = 'Choice Specs';
} else {
item = 'Expert Belt';
@@ -1497,7 +1497,7 @@ exports.BattleScripts = {
item = 'Focus Sash';
} else if (ability === 'Iron Barbs' || ability === 'Rough Skin') {
item = 'Rocky Helmet';
- } else if ((template.baseStats.hp+75)*(template.baseStats.def+template.baseStats.spd+175) > 60000 || template.species === 'Skarmory' || template.species === 'Forretress') {
+ } else if ((template.baseStats.hp + 75) * (template.baseStats.def + template.baseStats.spd + 175) > 60000 || template.species === 'Skarmory' || template.species === 'Forretress') {
// skarmory and forretress get exceptions for their typing
item = 'Leftovers';
} else if ((counter.Physical + counter.Special >= 3 || counter.Special >= 3) && setupType && ability !== 'Sturdy') {
@@ -1506,7 +1506,7 @@ exports.BattleScripts = {
item = 'Assault Vest';
} else if (counter.Physical + counter.Special >= 4) {
item = 'Expert Belt';
- } else if (i===0 && ability !== 'Sturdy' && !counter['recoil'] && template.baseStats.def + template.baseStats.spd + template.baseStats.hp < 300) {
+ } else if (i === 0 && ability !== 'Sturdy' && !counter['recoil'] && template.baseStats.def + template.baseStats.spd + template.baseStats.hp < 300) {
item = 'Focus Sash';
} else if (hasMove['outrage']) {
item = 'Lum Berry';
@@ -1593,7 +1593,7 @@ exports.BattleScripts = {
ivs: ivs,
item: item,
level: level,
- shiny: (Math.random()*1024<=1)
+ shiny: (Math.random() * 1024 <= 1)
};
},
randomTeam: function(side) {
@@ -1620,7 +1620,7 @@ exports.BattleScripts = {
var nuCount = 0;
var megaCount = 0;
- for (var i=0; i 1) continue;
- if ((tier === 'NFE' || tier === 'NU') && nuCount > 1 && Math.random()*5>1) continue;
- if (tier === 'Uber' && uberCount > 1 && Math.random()*5>1) continue;
+ if ((tier === 'NFE' || tier === 'NU') && nuCount > 1 && Math.random() * 5 > 1) continue;
+ if (tier === 'Uber' && uberCount > 1 && Math.random() * 5 > 1) continue;
// CAPs have 20% the normal rate
- if (tier === 'CAP' && Math.random()*5>1) continue;
+ if (tier === 'CAP' && Math.random() * 5 > 1) continue;
// Arceus formes have 1/18 the normal rate each (so Arceus as a whole has a normal rate)
- if (keys[i].substr(0,6) === 'arceus' && Math.random()*18>1) continue;
+ if (keys[i].substr(0, 6) === 'arceus' && Math.random() * 18 > 1) continue;
// Basculin formes have 1/2 the normal rate each (so Basculin as a whole has a normal rate)
- if (keys[i].substr(0,8) === 'basculin' && Math.random()*2>1) continue;
+ if (keys[i].substr(0, 8) === 'basculin' && Math.random() * 2 > 1) continue;
// Genesect formes have 1/5 the normal rate each (so Genesect as a whole has a normal rate)
- if (keys[i].substr(0,8) === 'genesect' && Math.random()*5>1) continue;
+ if (keys[i].substr(0, 8) === 'genesect' && Math.random() * 5 > 1) continue;
// Gourgeist formes have 1/4 the normal rate each (so Gourgeist as a whole has a normal rate)
- if (keys[i].substr(0,9) === 'gourgeist' && Math.random()*4>1) continue;
+ if (keys[i].substr(0, 9) === 'gourgeist' && Math.random() * 4 > 1) continue;
// Not available on XY
if (template.species === 'Pichu-Spiky-eared') continue;
// Limit 2 of any type
var types = template.types;
var skip = false;
- for (var t=0; t 1 && Math.random()*5>1) {
+ for (var t = 0; t < types.length; t++) {
+ if (typeCount[types[t]] > 1 && Math.random() * 5 > 1) {
skip = true;
break;
}
@@ -1657,7 +1657,7 @@ exports.BattleScripts = {
if (potd && potd.name && potd.types) {
// The Pokemon of the Day belongs in slot 2
- if (i===1) {
+ if (i === 1) {
template = potd;
if (template.species === 'Magikarp') {
template.viableMoves = {magikarpsrevenge:1, splash:1, bounce:1};
@@ -1694,7 +1694,7 @@ exports.BattleScripts = {
pokemonLeft++;
// Now that our Pokemon has passed all checks, we can increment the type counter
- for (var t=0; t 1) continue;
- if ((tier === 'NFE' || tier === 'NU') && nuCount > 1 && Math.random()*5>1) continue;
- if (tier === 'Uber' && uberCount > 1 && Math.random()*5>1) continue;
+ if ((tier === 'NFE' || tier === 'NU') && nuCount > 1 && Math.random() * 5 > 1) continue;
+ if (tier === 'Uber' && uberCount > 1 && Math.random() * 5 > 1) continue;
// Arceus formes have 1/18 the normal rate each (so Arceus as a whole has a normal rate)
- if (keys[i].substr(0,6) === 'arceus' && Math.random()*18>1) continue;
+ if (keys[i].substr(0, 6) === 'arceus' && Math.random() * 18 > 1) continue;
// Basculin formes have 1/2 the normal rate each (so Basculin as a whole has a normal rate)
- if (keys[i].substr(0,8) === 'basculin' && Math.random()*2>1) continue;
+ if (keys[i].substr(0, 8) === 'basculin' && Math.random() * 2 > 1) continue;
// Genesect formes have 1/5 the normal rate each (so Genesect as a whole has a normal rate)
- if (keys[i].substr(0,8) === 'genesect' && Math.random()*5>1) continue;
+ if (keys[i].substr(0, 8) === 'genesect' && Math.random() * 5 > 1) continue;
// Gourgeist formes have 1/4 the normal rate each (so Gourgeist as a whole has a normal rate)
- if (keys[i].substr(0,9) === 'gourgeist' && Math.random()*4>1) continue;
+ if (keys[i].substr(0, 9) === 'gourgeist' && Math.random() * 4 > 1) continue;
// Not available on XY
if (template.species === 'Pichu-Spiky-eared') continue;
// Limit 2 of any type
var types = template.types;
var skip = false;
- for (var t=0; t 1 && Math.random()*5>1) {
+ for (var t = 0; t < types.length; t++) {
+ if (typeCount[types[t]] > 1 && Math.random() * 5 > 1) {
skip = true;
break;
}
@@ -1774,7 +1774,7 @@ exports.BattleScripts = {
if (potd && potd.name && potd.types) {
// The Pokemon of the Day belongs in slot 2
- if (i===1) {
+ if (i === 1) {
template = potd;
if (template.species === 'Magikarp') {
template.viableMoves = {magikarpsrevenge:1, splash:1, bounce:1};
@@ -1808,7 +1808,7 @@ exports.BattleScripts = {
pokemonLeft++;
// Now that our Pokemon has passed all checks, we can increment the type counter
- for (var t=0; t1) continue;
+ if (keys[i].substr(0, 6) === 'arceus' && Math.random() * 18 > 1) continue;
// Basculin formes have 1/2 the normal rate each (so Basculin as a whole has a normal rate)
- if (keys[i].substr(0,8) === 'basculin' && Math.random()*2>1) continue;
+ if (keys[i].substr(0, 8) === 'basculin' && Math.random() * 2 > 1) continue;
// Genesect formes have 1/5 the normal rate each (so Genesect as a whole has a normal rate)
- if (keys[i].substr(0,8) === 'genesect' && Math.random()*5>1) continue;
+ if (keys[i].substr(0, 8) === 'genesect' && Math.random() * 5 > 1) continue;
// Not available on XY
if (template.species === 'Pichu-Spiky-eared') continue;
// Limit 2 of any type
var types = template.types;
var skip = false;
- for (var t=0; t 1 && Math.random()*5>1) {
+ for (var t = 0; t < types.length; t++) {
+ if (typeCount[types[t]] > 1 && Math.random() * 5 > 1) {
skip = true;
break;
}
@@ -1877,7 +1877,7 @@ exports.BattleScripts = {
// More potd stuff
if (potd && potd.name && potd.types) {
// The Pokemon of the Day belongs in slot 2
- if (i===1) {
+ if (i === 1) {
template = potd;
if (template.species === 'Magikarp') {
template.viableMoves = {magikarpsrevenge:1, splash:1, bounce:1};
@@ -1911,7 +1911,7 @@ exports.BattleScripts = {
pokemonLeft++;
// Now that our Pokemon has passed all checks, we can increment the type counter
- for (var t=0; t 1) rejected = true;
isSetup = true;
break;
@@ -2346,8 +2346,8 @@ exports.BattleScripts = {
}
// Remove rejected moves from the move list.
- if (rejected && j1) replace = true;
+ if (!hasMove['encore'] && Math.random() * 2 > 1) replace = true;
} else if (damagingid === 'focuspunch') {
// Focus Punch is a bad idea without a sub:
if (!hasMove['substitute']) replace = true;
- } else if (damagingid.substr(0,11) === 'hiddenpower' && damagingType === 'Ice') {
+ } else if (damagingid.substr(0, 11) === 'hiddenpower' && damagingType === 'Ice') {
// Mono-HP-Ice is never acceptable.
replace = true;
} else {
@@ -2392,9 +2392,9 @@ exports.BattleScripts = {
}
}
}
- if (replace) moves.splice(damagingMoveIndex[damagingid],1);
+ if (replace) moves.splice(damagingMoveIndex[damagingid], 1);
}
- } else if (damagingMoves.length===2) {
+ } else if (damagingMoves.length === 2) {
// If you have two attacks, neither is STAB, and the combo isn't Ice/Electric, Ghost/Fighting, or Dark/Fighting, reject one of them at random.
var type1 = damagingMoves[0].type, type2 = damagingMoves[1].type;
var typeCombo = [type1, type2].sort().join('/');
@@ -2404,20 +2404,20 @@ exports.BattleScripts = {
} else {
rejectCombo = false;
}
- if (rejectCombo) moves.splice(Math.floor(Math.random()*moves.length),1);
+ if (rejectCombo) moves.splice(Math.floor(Math.random() * moves.length), 1);
} else {
// If you have three or more attacks, and none of them are STAB, reject one of them at random.
var isStab = false;
- for (var l=0; l= 3 && (template.baseStats.spe >= 95 || randomNum>1)) {
+ var randomNum = Math.random() * 2;
+ if (counter.Physical >= 3 && (template.baseStats.spe >= 95 || randomNum > 1)) {
item = 'Choice Band';
- } else if (counter.Special >= 3 && (template.baseStats.spe >= 95 || randomNum>1)) {
+ } else if (counter.Special >= 3 && (template.baseStats.spe >= 95 || randomNum > 1)) {
item = 'Choice Specs';
} else {
item = 'Choice Scarf';
@@ -2657,7 +2657,7 @@ exports.BattleScripts = {
}
if ((hasMove['return'] || hasMove['hyperfang']) && !hasMove['facade']) {
// lol no
- for (var j=0; j 60000 || template.species === 'Skarmory' || template.species === 'Forretress') {
+ } else if ((template.baseStats.hp + 75) * (template.baseStats.def + template.baseStats.spd + 175) > 60000 || template.species === 'Skarmory' || template.species === 'Forretress') {
// skarmory and forretress get exceptions for their typing
item = 'Sitrus Berry';
} else if (counter.Physical + counter.Special >= 3 && setupType) {
diff --git a/data/statuses.js b/data/statuses.js
index f00bf93575..6fc16b53b2 100644
--- a/data/statuses.js
+++ b/data/statuses.js
@@ -15,7 +15,7 @@ exports.BattleStatuses = {
},
onResidualOrder: 9,
onResidual: function(pokemon) {
- this.damage(pokemon.maxhp/8);
+ this.damage(pokemon.maxhp / 8);
}
},
par: {
@@ -41,7 +41,7 @@ exports.BattleStatuses = {
onStart: function(target) {
this.add('-status', target, 'slp');
// 1-3 turns
- this.effectData.startTime = this.random(2,5);
+ this.effectData.startTime = this.random(2, 5);
this.effectData.time = this.effectData.startTime;
},
onBeforeMovePriority: 2,
@@ -88,7 +88,7 @@ exports.BattleStatuses = {
},
onResidualOrder: 9,
onResidual: function(pokemon) {
- this.damage(pokemon.maxhp/8);
+ this.damage(pokemon.maxhp / 8);
}
},
tox: {
@@ -109,7 +109,7 @@ exports.BattleStatuses = {
if (this.effectData.stage < 15) {
this.effectData.stage++;
}
- this.damage(this.clampIntRange(pokemon.maxhp/16, 1)*this.effectData.stage);
+ this.damage(this.clampIntRange(pokemon.maxhp / 16, 1) * this.effectData.stage);
}
},
confusion: {
@@ -118,7 +118,7 @@ exports.BattleStatuses = {
var result = this.runEvent('TryConfusion', target, source, sourceEffect);
if (!result) return result;
this.add('-start', target, 'confusion');
- this.effectData.time = this.random(2,6);
+ this.effectData.time = this.random(2, 6);
},
onEnd: function(target) {
this.add('-end', target, 'confusion');
@@ -133,7 +133,7 @@ exports.BattleStatuses = {
if (this.random(2) === 0) {
return;
}
- this.directDamage(this.getDamage(pokemon,pokemon,40));
+ this.directDamage(this.getDamage(pokemon, pokemon, 40));
return false;
}
},
@@ -165,10 +165,10 @@ exports.BattleStatuses = {
duration: 5,
durationCallback: function(target, source) {
if (source.item === 'gripclaw') return 8;
- return this.random(5,7);
+ return this.random(5, 7);
},
onStart: function(pokemon, source) {
- this.add('-activate', pokemon, 'move: ' +this.effectData.sourceEffect, '[of] '+source);
+ this.add('-activate', pokemon, 'move: ' +this.effectData.sourceEffect, '[of] ' + source);
},
onResidualOrder: 11,
onResidual: function(pokemon) {
@@ -177,9 +177,9 @@ exports.BattleStatuses = {
return;
}
if (this.effectData.source.item === 'bindingband') {
- this.damage(pokemon.maxhp/6);
+ this.damage(pokemon.maxhp / 6);
} else {
- this.damage(pokemon.maxhp/8);
+ this.damage(pokemon.maxhp / 8);
}
},
onEnd: function(pokemon) {
@@ -200,7 +200,7 @@ exports.BattleStatuses = {
this.effectData.trueDuration--;
},
onStart: function(target, source, effect) {
- this.effectData.trueDuration = this.random(2,4);
+ this.effectData.trueDuration = this.random(2, 4);
this.effectData.move = effect.id;
},
onRestart: function() {
@@ -251,7 +251,7 @@ exports.BattleStatuses = {
return;
}
var moves = pokemon.moveset;
- for (var i=0; i this.gen) {
- problems.push(set.species+' does not exist in gen '+this.gen+'.');
+ problems.push(set.species + ' does not exist in gen ' + this.gen + '.');
} else if (template.isNonstandard) {
- problems.push(set.species+' is not a real Pokemon.');
+ problems.push(set.species + ' is not a real Pokemon.');
}
- if (set.moves) for (var i=0; i this.gen) {
- problems.push(move.name+' does not exist in gen '+this.gen+'.');
+ problems.push(move.name + ' does not exist in gen ' + this.gen + '.');
} else if (move.isNonstandard) {
- problems.push(move.name+' is not a real move.');
+ problems.push(move.name + ' is not a real move.');
}
}
if (set.moves && set.moves.length > 4) {
- problems.push((set.name||set.species) + ' has more than four moves.');
+ problems.push((set.name || set.species) + ' has more than four moves.');
}
// Let's manually delete items.
diff --git a/mods/gen1/scripts.js b/mods/gen1/scripts.js
index f4f520ca89..68c95265d1 100644
--- a/mods/gen1/scripts.js
+++ b/mods/gen1/scripts.js
@@ -54,7 +54,7 @@ exports.BattleScripts = {
this.setActiveMove(move, pokemon, target);
if (pokemon.movedThisTurn || !this.runEvent('BeforeMove', pokemon, target, move)) {
- this.debug(''+pokemon.id+' move interrupted; movedThisTurn: '+pokemon.movedThisTurn);
+ this.debug('' + pokemon.id + ' move interrupted; movedThisTurn: ' + pokemon.movedThisTurn);
this.clearActiveMove(true);
// This is only run for sleep
this.runEvent('AfterMoveSelf', pokemon, target, move);
@@ -97,7 +97,7 @@ exports.BattleScripts = {
if (pokemon.volatiles['partialtrappinglock'].locked !== target && target !== pokemon) {
// The target switched, therefor, we must re-roll the duration
var roll = this.random(6);
- var duration = [2,2,3,3,4,5][roll];
+ var duration = [2, 2, 3, 3, 4, 5][roll];
pokemon.volatiles['partialtrappinglock'].duration = duration;
pokemon.volatiles['partialtrappinglock'].locked = target;
// Duration reset thus partially trapped at 2 always
@@ -160,8 +160,8 @@ exports.BattleScripts = {
var movename = move.name;
if (move.id === 'hiddenpower') movename = 'Hidden Power';
- if (sourceEffect) attrs += '|[from]'+this.getEffect(sourceEffect);
- this.addMove('move', pokemon, movename, target+attrs);
+ if (sourceEffect) attrs += '|[from]' + this.getEffect(sourceEffect);
+ this.addMove('move', pokemon, movename, target + attrs);
if (!this.singleEvent('Try', move, null, pokemon, target, move)) {
return true;
@@ -198,14 +198,14 @@ exports.BattleScripts = {
return true;
},
rollMoveHit: function(target, pokemon, move, spreadHit) {
- var boostTable = [1, 4/3, 5/3, 2, 7/3, 8/3, 3];
+ var boostTable = [1, 4 / 3, 5 / 3, 2, 7 / 3, 8 / 3, 3];
var doSelfDestruct = true;
var damage = 0;
// Calculate true accuracy
var accuracy = move.accuracy;
if (accuracy !== true) {
- accuracy = Math.floor(accuracy*255/100);
+ accuracy = Math.floor(accuracy * 255 / 100);
}
// Partial trapping moves: true accuracy while it lasts
@@ -255,13 +255,13 @@ exports.BattleScripts = {
var roll = this.random(6);
hits = [2, 2, 3, 3, 4, 5][roll];
} else {
- hits = this.random(hits[0], hits[1]+1);
+ hits = this.random(hits[0], hits[1] + 1);
}
}
hits = Math.floor(hits);
// In gen 1, all the hits have the same damage for multihits move
var moveDamage = 0;
- for (var i=0; i= mbstmin)
break;
@@ -897,12 +897,12 @@ exports.BattleScripts = {
// Random IVs
var ivs = {
- hp: Math.floor(Math.random()*31),
- atk: Math.floor(Math.random()*31),
- def: Math.floor(Math.random()*31),
- spa: Math.floor(Math.random()*31),
- spd: Math.floor(Math.random()*31),
- spe: Math.floor(Math.random()*31)
+ hp: Math.floor(Math.random() * 31),
+ atk: Math.floor(Math.random() * 31),
+ def: Math.floor(Math.random() * 31),
+ spa: Math.floor(Math.random() * 31),
+ spd: Math.floor(Math.random() * 31),
+ spe: Math.floor(Math.random() * 31)
};
// ALl EVs
@@ -954,7 +954,7 @@ exports.BattleScripts = {
var ruleset = this.getFormat().ruleset;
- for (var i=0; i= 256) {
// 2^32 - special-cased because Battle.random(n) can't handle n > 2^16 - 1
- return (this.random()*4294967296 < 1);
+ return (this.random() * 4294967296 < 1);
}
- this.debug("Success chance: "+Math.round(100/counter)+"%");
+ this.debug("Success chance: " + Math.round(100 / counter) + "%");
return (this.random(counter) === 0);
},
onRestart: function() {
diff --git a/mods/gen2/README.md b/mods/gen2/README.md
index ede47730ff..ed03149aa3 100644
--- a/mods/gen2/README.md
+++ b/mods/gen2/README.md
@@ -19,7 +19,7 @@ The type was decided with the following operation:
4 * (atkDV % 4) + (defDV % 4)
Which gives as a number from 0 to 16, giving us the index in the type table to use.
The Hidden Power base power was decided with the following formula:
-Math.floor((5 * ((spcDV >> 3) + (2 * (speDV >> 3)) + (4 * (defDV >> 3)) + (8 * (atkDV >> 3))) + (spcDV>2?3:spcDV)) / 2 + 31);
+Math.floor((5 * ((spcDV >> 3) + (2 * (speDV >> 3)) + (4 * (defDV >> 3)) + (8 * (atkDV >> 3))) + (spcDV > 2 ? 3 : spcDV)) / 2 + 31);
The DVs are shifted 3 positions, taking thus the most important byte, thus having no value under 8 DVs and a value on 8 and higher.
The most important DV was attack and special.
@@ -29,4 +29,4 @@ Critical hits ignore defensive boosts but not defensive drops.
Status
------
-Sleep lasts 1-5 turns and you the counter is not reset upon switch.
\ No newline at end of file
+Sleep lasts 1-5 turns and you the counter is not reset upon switch.
diff --git a/mods/gen2/items.js b/mods/gen2/items.js
index cf214d77f3..9956ebb5a8 100644
--- a/mods/gen2/items.js
+++ b/mods/gen2/items.js
@@ -67,7 +67,7 @@ exports.BattleItems = {
}
move.pp += 5;
if (move.pp > move.maxpp) move.pp = move.maxpp;
- this.add("-message",pokemon.name+" restored "+move.move+"'s PP using its Leppa Berry! (placeholder)");
+ this.add("-message", pokemon.name + " restored " + move.move + "'s PP using its Leppa Berry! (placeholder)");
},
gen: 2,
desc: "Restores 5PP to the first of the holder's moves to reach 0PP. Single use."
diff --git a/mods/gen2/moves.js b/mods/gen2/moves.js
index 6e58c42acf..58130a9408 100644
--- a/mods/gen2/moves.js
+++ b/mods/gen2/moves.js
@@ -8,11 +8,11 @@ exports.BattleMovedex = {
if (target.boosts.atk >= 6) {
return false;
}
- if (target.hp <= target.maxhp/2) {
+ if (target.hp <= target.maxhp / 2) {
this.boost({atk: 2});
return false;
}
- this.directDamage(target.maxhp/2);
+ this.directDamage(target.maxhp / 2);
target.setBoost({atk: 6});
this.add('-setboost', target, 'atk', '6', '[from] move: Belly Drum');
}
@@ -26,7 +26,7 @@ exports.BattleMovedex = {
return;
}
if (target.newlySwitched && target.speed <= source.speed) {
- var toLeech = this.clampIntRange(target.maxhp/8, 1);
+ var toLeech = this.clampIntRange(target.maxhp / 8, 1);
var damage = this.damage(toLeech, target, source, 'move: Leech Seed');
if (damage) {
this.heal(damage, source, target);
@@ -43,7 +43,7 @@ exports.BattleMovedex = {
this.debug('Nothing to leech into');
return;
}
- var toLeech = this.clampIntRange(pokemon.maxhp/8, 1);
+ var toLeech = this.clampIntRange(pokemon.maxhp / 8, 1);
var damage = this.damage(toLeech, pokemon, target);
if (damage) {
this.heal(damage, target, pokemon);
@@ -59,11 +59,11 @@ exports.BattleMovedex = {
return spd * 2;
},
onStart: function(side) {
- this.add('-sidestart',side,'move: Light Screen');
+ this.add('-sidestart', side, 'move: Light Screen');
},
onResidualOrder: 21,
onEnd: function(side) {
- this.add('-sideend',side,'move: Light Screen');
+ this.add('-sideend', side, 'move: Light Screen');
}
}
},
@@ -102,11 +102,11 @@ exports.BattleMovedex = {
return def * 2;
},
onStart: function(side) {
- this.add('-sidestart',side,'Reflect');
+ this.add('-sidestart', side, 'Reflect');
},
onResidualOrder: 21,
onEnd: function(side) {
- this.add('-sideend',side,'Reflect');
+ this.add('-sideend', side, 'Reflect');
}
}
},
@@ -130,7 +130,7 @@ exports.BattleMovedex = {
inherit: true,
onHit: function(pokemon) {
var moves = [];
- for (var i=0; i this.gen) {
- problems.push(set.species+' does not exist in gen '+this.gen+'.');
+ problems.push(set.species + ' does not exist in gen ' + this.gen + '.');
} else if (template.isNonstandard) {
- problems.push(set.species+' is not a real Pokemon.');
+ problems.push(set.species + ' is not a real Pokemon.');
}
var hasHP = false;
if (set.item) {
var item = this.getItem(set.item);
if (item.gen > this.gen) {
- problems.push(item.name+' does not exist in gen '+this.gen+'.');
+ problems.push(item.name + ' does not exist in gen ' + this.gen + '.');
} else if (item.isNonstandard) {
problems.push(item.name + ' is not a real item.');
}
}
- if (set.moves) for (var i=0; i this.gen) {
- problems.push(move.name+' does not exist in gen '+this.gen+'.');
+ problems.push(move.name + ' does not exist in gen ' + this.gen + '.');
} else if (move.isNonstandard) {
- problems.push(move.name+' is not a real move.');
+ problems.push(move.name + ' is not a real move.');
}
if (move.id === 'hiddenpower') hasHP = true;
}
if (set.moves && set.moves.length > 4) {
- problems.push((set.name||set.species) + ' has more than four moves.');
+ problems.push((set.name || set.species) + ' has more than four moves.');
}
// Automatically set ability to None
@@ -111,7 +111,7 @@ exports.BattleFormats = {
var moves = [];
if (set.moves) {
var hasMove = {};
- for (var i=0; i target.getStat(move.defensiveCategory==='Physical'?'def':'spd', true, true)) {
+ if (move.ignorePositiveDefensive && defense > target.getStat(move.defensiveCategory === 'Physical' ? 'def' : 'spd', true, true)) {
move.ignoreDefensive = true;
}
if (move.ignoreDefensive) {
this.debug('Negating (sp)def boost/penalty.');
- defense = target.getStat(move.defensiveCategory==='Physical'?'def':'spd', true, true);
+ defense = target.getStat(move.defensiveCategory === 'Physical' ? 'def' : 'spd', true, true);
}
// Gen 2 damage formula
@@ -173,7 +173,7 @@ exports.BattleScripts = {
}
// Randomizer, it's a number between 217 and 255
- var randFactor = Math.floor(Math.random()*39)+217;
+ var randFactor = Math.floor(Math.random() * 39) + 217;
baseDamage *= Math.floor(randFactor * 100 / 255) / 100;
// If damage is less than 1, we return 1
@@ -197,10 +197,10 @@ exports.BattleScripts = {
b.speed = b.speed || 0;
if ((typeof a.order === 'number' || typeof b.order === 'number') && a.order !== b.order) {
if (typeof a.order !== 'number') {
- return -(1);
+ return -1;
}
if (typeof b.order !== 'number') {
- return -(-1);
+ return 1;
}
if (b.order - a.order) {
return -(b.order - a.order);
@@ -216,16 +216,16 @@ exports.BattleScripts = {
if (b.subOrder - a.subOrder) {
return -(b.subOrder - a.subOrder);
}
- return Math.random()-0.5;
+ return Math.random() - 0.5;
},
getResidualStatuses: function(thing, callbackType) {
var statuses = this.getRelevantEffectsInner(thing || this, callbackType || 'residualCallback', null, null, false, true, 'duration');
statuses.sort(this.comparePriority);
- //if (statuses[0]) this.debug('match '+(callbackType||'residualCallback')+': '+statuses[0].status.id);
+ //if (statuses[0]) this.debug('match ' + (callbackType || 'residualCallback') + ': ' + statuses[0].status.id);
return statuses;
},
residualEvent: function(eventid, relayVar) {
- var statuses = this.getRelevantEffectsInner(this, 'on'+eventid, null, null, false, true, 'duration');
+ var statuses = this.getRelevantEffectsInner(this, 'on' + eventid, null, null, false, true, 'duration');
statuses.sort(this.comparePriority);
while (statuses.length) {
var statusObj = statuses.shift();
@@ -244,13 +244,13 @@ exports.BattleScripts = {
getRelevantEffects: function(thing, callbackType, foeCallbackType, foeThing, checkChildren) {
var statuses = this.getRelevantEffectsInner(thing, callbackType, foeCallbackType, foeThing, true, false);
statuses.sort(this.comparePriority);
- //if (statuses[0]) this.debug('match '+callbackType+': '+statuses[0].status.id);
+ //if (statuses[0]) this.debug('match ' + callbackType + ': ' + statuses[0].status.id);
return statuses;
},
addQueue: function(decision, noSort, side) {
if (decision) {
if (Array.isArray(decision)) {
- for (var i=0; i pokemon.hp) {
return target.hp - pokemon.hp;
}
@@ -465,7 +465,7 @@ exports.BattleMovedex = {
effect: {
duration: 2,
onStart: function(side) {
- this.debug('Healing Wish started on '+side.name);
+ this.debug('Healing Wish started on ' + side.name);
},
onSwitchInPriority: -6,
// Accounting for the offchance that 5 remaining pokemon are KO'd by entry hazards
@@ -477,7 +477,7 @@ exports.BattleMovedex = {
var source = this.effectData.source;
var damage = target.heal(target.maxhp);
target.setStatus('');
- this.add('-heal',target,target.getHealth,'[from] move: Healing Wish');
+ this.add('-heal', target, target.getHealth, '[from] move: Healing Wish');
target.side.removeSideCondition('healingwish');
}
}
@@ -564,7 +564,7 @@ exports.BattleMovedex = {
pp: 20,
onMoveFail: function(target, source, move) {
var damage = this.getDamage(source, target, move, true);
- this.damage(this.clampIntRange(damage/2, 1, Math.floor(target.maxhp/2)), source);
+ this.damage(this.clampIntRange(damage / 2, 1, Math.floor(target.maxhp / 2)), source);
}
},
iciclespear: {
@@ -576,9 +576,9 @@ exports.BattleMovedex = {
isSnatchable: false,
onTryHit: function(pokemon) {
var targets = pokemon.side.foe.active;
- for (var i=0; i= 0) return;
}
}
@@ -593,7 +593,7 @@ exports.BattleMovedex = {
pp: 25,
onMoveFail: function(target, source, move) {
var damage = this.getDamage(source, target, move, true);
- this.damage(this.clampIntRange(damage/2, 1, Math.floor(target.maxhp/2)), source);
+ this.damage(this.clampIntRange(damage / 2, 1, Math.floor(target.maxhp / 2)), source);
}
},
lastresort: {
@@ -703,12 +703,12 @@ exports.BattleMovedex = {
move: move.name,
id: move.id,
pp: 5,
- maxpp: move.pp * 8/5,
+ maxpp: move.pp * 8 / 5,
disabled: false,
used: false
};
source.moves[moveslot] = toId(move.name);
- this.add('-message', source.name+' learned '+move.name+'! (placeholder)');
+ this.add('-message', source.name + ' learned ' + move.name + '! (placeholder)');
}
},
minimize: {
@@ -831,7 +831,7 @@ exports.BattleMovedex = {
source.moveset[moveslot] = sketchedMove;
source.baseMoveset[moveslot] = sketchedMove;
source.moves[moveslot] = toId(move.name);
- this.add('-message', source.name+' learned '+move.name+'! (placeholder)');
+ this.add('-message', source.name + ' learned ' + move.name + '! (placeholder)');
}
},
skillswap: {
@@ -941,7 +941,7 @@ exports.BattleMovedex = {
if (!pokemon.runImmunity('Ground')) return;
if (!pokemon.runImmunity('Poison')) return;
if (pokemon.hasType('Poison')) {
- this.add('-sideend', pokemon.side, 'move: Toxic Spikes', '[of] '+pokemon);
+ this.add('-sideend', pokemon.side, 'move: Toxic Spikes', '[of] ' + pokemon);
pokemon.side.removeSideCondition('toxicspikes');
}
if (pokemon.volatiles['substitute']) {
@@ -980,8 +980,8 @@ exports.BattleMovedex = {
var target = side.active[this.effectData.sourcePosition];
if (!target.fainted) {
var source = this.effectData.source;
- var damage = this.heal(target.maxhp/2, target, target);
- if (damage) this.add('-heal', target, target.getHealth, '[from] move: Wish', '[wisher] '+source.name);
+ var damage = this.heal(target.maxhp / 2, target, target);
+ if (damage) this.add('-heal', target, target.getHealth, '[from] move: Wish', '[wisher] ' + source.name);
}
}
}
@@ -1003,7 +1003,7 @@ exports.BattleMovedex = {
wringout: {
inherit: true,
basePowerCallback: function(pokemon) {
- return Math.floor(pokemon.hp*120/pokemon.maxhp) + 1;
+ return Math.floor(pokemon.hp * 120 / pokemon.maxhp) + 1;
}
},
magikarpsrevenge: null
diff --git a/mods/gen4/statuses.js b/mods/gen4/statuses.js
index 8bdf3db000..973200db6e 100644
--- a/mods/gen4/statuses.js
+++ b/mods/gen4/statuses.js
@@ -14,7 +14,7 @@ exports.BattleStatuses = {
onStart: function(target) {
this.add('-status', target, 'slp');
// 1-4 turns
- this.effectData.time = this.random(2,6);
+ this.effectData.time = this.random(2, 6);
},
onBeforeMovePriority: 2,
onBeforeMove: function(pokemon, target, move) {
@@ -41,7 +41,7 @@ exports.BattleStatuses = {
inherit: true,
durationCallback: function(target, source) {
if (source.item === 'gripclaw') return 6;
- return this.random(3,7);
+ return this.random(3, 7);
}
},
stall: {
diff --git a/mods/gen5/abilities.js b/mods/gen5/abilities.js
index fc23b5ecf1..5dbf1eb54f 100644
--- a/mods/gen5/abilities.js
+++ b/mods/gen5/abilities.js
@@ -6,7 +6,7 @@ exports.BattleAbilities = {
onStart: function(pokemon) {
var target = pokemon.side.foe.randomActive();
if (target && target.item) {
- this.add('-item', target, target.getItem().name, '[from] ability: Frisk', '[of] '+pokemon);
+ this.add('-item', target, target.getItem().name, '[from] ability: Frisk', '[of] ' + pokemon);
}
}
},
@@ -27,7 +27,7 @@ exports.BattleAbilities = {
onUpdate: function(pokemon) {
if (pokemon.volatiles['attract']) {
pokemon.removeVolatile('attract');
- this.add("-message", pokemon.name+" got over its infatuation. (placeholder)");
+ this.add("-message", pokemon.name + " got over its infatuation. (placeholder)");
}
},
onTryHit: function(pokemon, target, move) {
diff --git a/mods/gen5/moves.js b/mods/gen5/moves.js
index 865cd8c279..c3ba63eaa6 100644
--- a/mods/gen5/moves.js
+++ b/mods/gen5/moves.js
@@ -16,10 +16,10 @@ exports.BattleMovedex = {
desc: "A random move among those known by the user's party members is selected for use. Does not select Assist, Bestow, Chatter, Circle Throw, Copycat, Counter, Covet, Destiny Bond, Detect, Dragon Tail, Endure, Feint, Focus Punch, Follow Me, Helping Hand, Me First, Metronome, Mimic, Mirror Coat, Mirror Move, Nature Power, Protect, Rage Powder, Sketch, Sleep Talk, Snatch, Struggle, Switcheroo, Thief, Transform, or Trick.",
onHit: function(target) {
var moves = [];
- for (var j=0; j 1) rejected = true;
isSetup = true;
break;
@@ -404,8 +404,8 @@ exports.BattleScripts = {
}
// Remove rejected moves from the move list.
- if (rejected && j1) replace = true;
+ if (!hasMove['encore'] && Math.random() * 2 > 1) replace = true;
} else if (damagingid === 'focuspunch') {
// Focus Punch is a bad idea without a sub:
if (!hasMove['substitute']) replace = true;
- } else if (damagingid.substr(0,11) === 'hiddenpower' && damagingType === 'Ice') {
+ } else if (damagingid.substr(0, 11) === 'hiddenpower' && damagingType === 'Ice') {
// Mono-HP-Ice is never acceptable.
replace = true;
} else {
@@ -450,9 +450,9 @@ exports.BattleScripts = {
}
}
}
- if (replace) moves.splice(damagingMoveIndex[damagingid],1);
+ if (replace) moves.splice(damagingMoveIndex[damagingid], 1);
}
- } else if (damagingMoves.length===2) {
+ } else if (damagingMoves.length === 2) {
// If you have two attacks, neither is STAB, and the combo isn't Ice/Electric, Ghost/Fighting, or Dark/Fighting, reject one of them at random.
var type1 = damagingMoves[0].type, type2 = damagingMoves[1].type;
var typeCombo = [type1, type2].sort().join('/');
@@ -462,20 +462,20 @@ exports.BattleScripts = {
} else {
rejectCombo = false;
}
- if (rejectCombo) moves.splice(Math.floor(Math.random()*moves.length),1);
+ if (rejectCombo) moves.splice(Math.floor(Math.random() * moves.length), 1);
} else {
// If you have three or more attacks, and none of them are STAB, reject one of them at random.
var isStab = false;
- for (var l=0; l 1) {
+ } else if ((template.species === 'Wynaut' || template.species === 'Wobbuffet') && hasMove['destinybond'] && Math.random() * 2 > 1) {
item = 'Custap Berry';
} else if (hasMove['trick'] && hasMove['gyroball'] && (ability === 'Levitate' || hasType['Flying'])) {
item = 'Macho Brace';
} else if (hasMove['trick'] && hasMove['gyroball']) {
item = 'Iron Ball';
} else if (hasMove['trick'] || hasMove['switcheroo']) {
- var randomNum = Math.random()*2;
- if (counter.Physical >= 3 && (template.baseStats.spe >= 95 || randomNum>1)) {
+ var randomNum = Math.random() * 2;
+ if (counter.Physical >= 3 && (template.baseStats.spe >= 95 || randomNum > 1)) {
item = 'Choice Band';
- } else if (counter.Special >= 3 && (template.baseStats.spe >= 95 || randomNum>1)) {
+ } else if (counter.Special >= 3 && (template.baseStats.spe >= 95 || randomNum > 1)) {
item = 'Choice Specs';
} else {
item = 'Choice Scarf';
@@ -685,7 +685,7 @@ exports.BattleScripts = {
}
if ((hasMove['return'] || hasMove['hyperfang']) && !hasMove['facade']) {
// lol no
- for (var j=0; j= 4 && !hasMove['fakeout'] && !hasMove['suckerpunch'] && !hasMove['flamecharge'] && !hasMove['rapidspin']) {
- if (Math.random()*3 > 1) {
+ if (Math.random() * 3 > 1) {
item = 'Choice Band';
} else {
item = 'Expert Belt';
}
} else if (counter.Special >= 4) {
- if (Math.random()*3 > 1) {
+ if (Math.random() * 3 > 1) {
item = 'Choice Specs';
} else {
item = 'Expert Belt';
@@ -729,7 +729,7 @@ exports.BattleScripts = {
} else if (ability === 'Iron Barbs') {
// only Iron Barbs for now
item = 'Rocky Helmet';
- } else if ((template.baseStats.hp+75)*(template.baseStats.def+template.baseStats.spd+175) > 60000 || template.species === 'Skarmory' || template.species === 'Forretress') {
+ } else if ((template.baseStats.hp + 75) * (template.baseStats.def + template.baseStats.spd + 175) > 60000 || template.species === 'Skarmory' || template.species === 'Forretress') {
// skarmory and forretress get exceptions for their typing
item = 'Leftovers';
} else if (counter.Physical + counter.Special >= 3 && setupType) {
@@ -738,7 +738,7 @@ exports.BattleScripts = {
item = 'Life Orb';
} else if (counter.Physical + counter.Special >= 4) {
item = 'Expert Belt';
- } else if (i===0 && ability !== 'Sturdy' && !counter['recoil']) {
+ } else if (i === 0 && ability !== 'Sturdy' && !counter['recoil']) {
item = 'Focus Sash';
} else if (hasMove['outrage']) {
item = 'Lum Berry';
@@ -814,7 +814,7 @@ exports.BattleScripts = {
ivs: ivs,
item: item,
level: level,
- shiny: (Math.random()*1024<=1)
+ shiny: (Math.random() * 1024 <= 1)
};
},
randomTeam: function(side) {
@@ -839,7 +839,7 @@ exports.BattleScripts = {
var uberCount = 0;
var nuCount = 0;
- for (var i=0; i 1) continue;
- if ((tier === 'NFE' || tier === 'NU') && nuCount > 1 && Math.random()*5>1) continue;
- if (tier === 'Uber' && uberCount > 1 && Math.random()*5>1) continue;
+ if ((tier === 'NFE' || tier === 'NU') && nuCount > 1 && Math.random() * 5 > 1) continue;
+ if (tier === 'Uber' && uberCount > 1 && Math.random() * 5 > 1) continue;
// CAPs have 20% the normal rate
- if (tier === 'CAP' && Math.random()*5>1) continue;
+ if (tier === 'CAP' && Math.random() * 5 > 1) continue;
// Arceus formes have 1/17 the normal rate each (so Arceus as a whole has a normal rate)
- if (keys[i].substr(0,6) === 'arceus' && Math.random()*17>1) continue;
+ if (keys[i].substr(0, 6) === 'arceus' && Math.random() * 17 > 1) continue;
// Basculin formes have 1/2 the normal rate each (so Basculin as a whole has a normal rate)
- if (keys[i].substr(0,8) === 'basculin' && Math.random()*2>1) continue;
+ if (keys[i].substr(0, 8) === 'basculin' && Math.random() * 2 > 1) continue;
// Not available on BW
if (template.species === 'Pichu-Spiky-eared') continue;
// Limit 2 of any type
var types = template.types;
var skip = false;
- for (var t=0; t 1 && Math.random()*5>1) {
+ for (var t = 0; t < types.length; t++) {
+ if (typeCount[types[t]] > 1 && Math.random() * 5 > 1) {
skip = true;
break;
}
@@ -872,7 +872,7 @@ exports.BattleScripts = {
if (potd && potd.name && potd.types) {
// The Pokemon of the Day belongs in slot 2
- if (i===1) {
+ if (i === 1) {
template = potd;
if (template.species === 'Magikarp') {
template.viableMoves = {magikarpsrevenge:1, splash:1, bounce:1};
@@ -899,7 +899,7 @@ exports.BattleScripts = {
pokemonLeft++;
// Now that our Pokemon has passed all checks, we can increment the type counter
- for (var t=0; t= 256) {
// 2^32 - special-cased because Battle.random(n) can't handle n > 2^16 - 1
- return (this.random()*4294967296 < 1);
+ return (this.random() * 4294967296 < 1);
}
- this.debug("Success chance: "+Math.round(100/counter)+"%");
+ this.debug("Success chance: " + Math.round(100 / counter) + "%");
return (this.random(counter) === 0);
},
onRestart: function() {
diff --git a/mods/gennext/abilities.js b/mods/gennext/abilities.js
index 07ea86762c..5bfff89963 100644
--- a/mods/gennext/abilities.js
+++ b/mods/gennext/abilities.js
@@ -62,9 +62,9 @@ exports.BattleAbilities = {
},
onSourceBasePower: function(basePower) {
if (this.isWeather('hail')) {
- return basePower * 3/4;
+ return basePower * 3 / 4;
}
- return basePower * 7/8;
+ return basePower * 7 / 8;
},
onAccuracy: function() {}
},
@@ -75,7 +75,7 @@ exports.BattleAbilities = {
},
onSourceBasePower: function(basePower) {
if (this.isWeather('sandstorm')) {
- return basePower * 4/5;
+ return basePower * 4 / 5;
}
},
onAccuracy: function() {}
@@ -84,9 +84,9 @@ exports.BattleAbilities = {
inherit: true,
onSourceBasePower: function(basePower) {
if (this.isWeather('raindance')) {
- return basePower * 3/4;
+ return basePower * 3 / 4;
}
- return basePower * 7/8;
+ return basePower * 7 / 8;
}
},
"icebody": {
@@ -95,7 +95,7 @@ exports.BattleAbilities = {
if (type === 'hail') return false;
},
onResidual: function(target, source, effect) {
- this.heal(target.maxhp/16);
+ this.heal(target.maxhp / 16);
},
onAfterDamage: function(damage, target, source, move) {
if (move && move.isContact && this.isWeather('hail')) {
@@ -147,13 +147,13 @@ exports.BattleAbilities = {
if (pokemon.isActive && pokemon.speciesid === 'cherrim' && this.effectData.forme !== 'Sunshine') {
this.effectData.forme = 'Sunshine';
this.add('-formechange', pokemon, 'Cherrim-Sunshine');
- this.add('-message', pokemon.name+' transformed!');
+ this.add('-message', pokemon.name + ' transformed!');
this.boost({spd:1});
}
} else if (pokemon.isActive && pokemon.speciesid === 'cherrim' && this.effectData.forme) {
delete this.effectData.forme;
this.add('-formechange', pokemon, 'Cherrim');
- this.add('-message', pokemon.name+' transformed!');
+ this.add('-message', pokemon.name + ' transformed!');
}
},
effect: {
@@ -223,7 +223,7 @@ exports.BattleAbilities = {
onFoeBasePower: function(basePower, attacker, defender, move) {
if (this.getEffectiveness(move.type, defender) > 0) {
this.add('-message', "The attack was weakened by Solid Rock!");
- return basePower * 1/2;
+ return basePower * 1 / 2;
}
}
},
@@ -232,7 +232,7 @@ exports.BattleAbilities = {
onFoeBasePower: function(basePower, attacker, defender, move) {
if (this.getEffectiveness(move.type, defender) > 0) {
this.add('-message', "The attack was weakened by Filter!");
- return basePower * 1/2;
+ return basePower * 1 / 2;
}
}
},
@@ -250,7 +250,7 @@ exports.BattleAbilities = {
onBasePower: function(basePower, attacker, defender, move) {
if (move.recoil || move.hasCustomRecoil || attacker.item === 'lifeorb') {
this.debug('Reckless boost');
- return basePower * 12/10;
+ return basePower * 12 / 10;
}
}
},
@@ -260,7 +260,7 @@ exports.BattleAbilities = {
for (var i in boost) {
if (boost[i] < 0) {
delete boost[i];
- this.add("-message", target.name+"'s stats were not lowered! (placeholder)");
+ this.add("-message", target.name + "'s stats were not lowered! (placeholder)");
}
}
}
@@ -283,7 +283,7 @@ exports.BattleAbilities = {
var foeactive = pokemon.side.foe.active;
var totaldef = 0;
var totalspd = 0;
- for (var i=0; i= target.maxhp) {
this.add('-message', "The attack was slightly weakened by Multiscale!");
- return this.chainModify(2/3);
+ return this.chainModify(2 / 3);
}
}
},
@@ -387,7 +387,7 @@ exports.BattleAbilities = {
if (move.category !== "Status") {
this.debug('Adding Stench flinch');
if (!move.secondaries) move.secondaries = [];
- for (var i=0; i 0) {
- this.heal(source.lastDamage/8, source);
+ this.heal(source.lastDamage / 8, source);
}
}
},
@@ -109,7 +109,7 @@ exports.BattleItems = {
onResidualSubOrder: 2,
onResidual: function(pokemon) {
if (pokemon.hasType('Grass')) {
- this.heal(pokemon.maxhp/16);
+ this.heal(pokemon.maxhp / 16);
}
}
},
@@ -119,9 +119,9 @@ exports.BattleItems = {
onResidualSubOrder: 2,
onResidual: function(pokemon) {
if (pokemon.hasType('Poison')) {
- this.heal(pokemon.maxhp/(pokemon.getTypes().length===1 ? 8 : 16));
+ this.heal(pokemon.maxhp / (pokemon.getTypes().length === 1 ? 8 : 16));
} else {
- this.damage(pokemon.maxhp/8);
+ this.damage(pokemon.maxhp / 8);
}
}
},
@@ -138,10 +138,10 @@ exports.BattleItems = {
effect && effect.effectType === 'Move' &&
target.useItem()) {
if (damage >= target.hp) {
- this.add("-message",target.name+" held on using its Focus Band!");
+ this.add("-message", target.name + " held on using its Focus Band!");
return target.hp - 1;
} else {
- this.add("-message",target.name+"'s Focus Band broke!");
+ this.add("-message", target.name + "'s Focus Band broke!");
}
}
},
@@ -189,25 +189,25 @@ exports.BattleItems = {
},
onModifyDef: function(def, pokemon) {
if (pokemon.template.species === 'Shuckle') {
- return def*1.5;
+ return def * 1.5;
}
},
onModifySpA: function(spa, pokemon) {
if (pokemon.template.species === 'Unown') {
- return spa*2;
+ return spa * 2;
}
},
onModifySpD: function(spd, pokemon) {
if (pokemon.template.species === 'Unown') {
- return spd*2;
+ return spd * 2;
}
if (pokemon.template.species === 'Shuckle') {
- return spd*1.5;
+ return spd * 1.5;
}
},
onModifySpe: function(spe, pokemon) {
if (pokemon.template.species === 'Unown') {
- return spe*2;
+ return spe * 2;
}
},
onFoeBasePower: function(basePower, attacker, defender, move) {
@@ -229,7 +229,7 @@ exports.BattleItems = {
},
// onResidual: function(pokemon) {
// if (pokemon.template.species === 'Shuckle') {
- // this.heal(this.clampIntRange(pokemon.maxhp/16, 1));
+ // this.heal(this.clampIntRange(pokemon.maxhp / 16, 1));
// }
// },
desc: "Raises Farfetch'd's critical hit rate two stages."
diff --git a/mods/gennext/moves.js b/mods/gennext/moves.js
index 0eb4da14da..3e49a69faa 100644
--- a/mods/gennext/moves.js
+++ b/mods/gennext/moves.js
@@ -130,7 +130,7 @@ exports.BattleMovedex = {
effect: {
onStart: function(target) {
this.add('-start', target, 'Substitute');
- this.effectData.hp = Math.floor(target.maxhp/4);
+ this.effectData.hp = Math.floor(target.maxhp / 4);
delete target.volatiles['partiallytrapped'];
},
onAccuracyPriority: -100,
@@ -226,12 +226,12 @@ exports.BattleMovedex = {
if (target.boosts.evasion >= 6) {
return false;
}
- if (target.hp <= target.maxhp/4 || target.maxhp === 1) { // Shedinja clause
+ if (target.hp <= target.maxhp / 4 || target.maxhp === 1) { // Shedinja clause
return false;
}
},
onHit: function(target) {
- this.directDamage(target.maxhp/4);
+ this.directDamage(target.maxhp / 4);
},
boosts: {
evasion: 1
@@ -260,7 +260,7 @@ exports.BattleMovedex = {
duration: 2,
onLockMove: 'solarbeam',
onStart: function(pokemon) {
- this.heal(pokemon.maxhp/2);
+ this.heal(pokemon.maxhp / 2);
}
},
breaksProtect: true
@@ -293,7 +293,7 @@ exports.BattleMovedex = {
duration: 2,
onLockMove: 'skullbash',
onStart: function(pokemon) {
- this.boost({def:1,spd:1,accuracy:1}, pokemon, pokemon, this.getMove('skullbash'));
+ this.boost({def:1, spd:1, accuracy:1}, pokemon, pokemon, this.getMove('skullbash'));
}
},
breaksProtect: true
@@ -539,7 +539,7 @@ exports.BattleMovedex = {
if (!effect || effect.effectType !== 'Move') return;
if (!source || source.side === target.side) return;
if (effect && effect.effectType === 'Move' && damage >= target.hp) {
- damage = target.hp-1;
+ damage = target.hp - 1;
}
this.effectData.totalDamage += damage;
this.effectData.sourcePosition = source.position;
@@ -561,7 +561,7 @@ exports.BattleMovedex = {
}
this.add('-end', pokemon, 'Bide');
var target = this.effectData.sourceSide.active[this.effectData.sourcePosition];
- this.moveHit(target, pokemon, 'bide', {damage: this.effectData.totalDamage*2});
+ this.moveHit(target, pokemon, 'bide', {damage: this.effectData.totalDamage * 2});
return false;
}
this.add('-activate', pokemon, 'Bide');
@@ -648,13 +648,13 @@ exports.BattleMovedex = {
'Timid': 'Jolly',
'Jolly': 'Timid'
};
- if (pokemon.template.speciesid==='meloettapirouette' && pokemon.formeChange('Meloetta')) {
+ if (pokemon.template.speciesid === 'meloettapirouette' && pokemon.formeChange('Meloetta')) {
this.add('-formechange', pokemon, 'Meloetta');
var tmpAtkEVs = pokemon.set.evs.atk;
pokemon.set.evs.atk = pokemon.set.evs.spa;
pokemon.set.evs.spa = tmpAtkEVs;
if (natureChange[pokemon.set.nature]) pokemon.set.nature = natureChange[pokemon.set.nature];
- var Atk2SpA = (pokemon.boosts.spa||0) - (pokemon.boosts.atk||0);
+ var Atk2SpA = (pokemon.boosts.spa || 0) - (pokemon.boosts.atk || 0);
this.boost({
atk: Atk2SpA,
spa: -Atk2SpA
@@ -665,7 +665,7 @@ exports.BattleMovedex = {
pokemon.set.evs.atk = pokemon.set.evs.spa;
pokemon.set.evs.spa = tmpAtkEVs;
if (natureChange[pokemon.set.nature]) pokemon.set.nature = natureChange[pokemon.set.nature];
- var Atk2SpA = (pokemon.boosts.spa||0) - (pokemon.boosts.atk||0);
+ var Atk2SpA = (pokemon.boosts.spa || 0) - (pokemon.boosts.atk || 0);
this.boost({
atk: Atk2SpA,
spa: -Atk2SpA
@@ -697,12 +697,12 @@ exports.BattleMovedex = {
effect: {
// this is a side condition
onStart: function(side) {
- this.add('-sidestart',side,'move: Stealth Rock');
+ this.add('-sidestart', side, 'move: Stealth Rock');
},
onSwitchIn: function(pokemon) {
var factor = 2;
if (pokemon.hasType('Flying')) factor = 4;
- var damage = this.damage(pokemon.maxhp*factor/16);
+ var damage = this.damage(pokemon.maxhp * factor / 16);
}
}
},
@@ -756,7 +756,7 @@ exports.BattleMovedex = {
onHit: function(target, source) {
var stats = [];
for (var i in target.boosts) {
- if (i!=='accuracy' && i!=='evasion' && i!=='atk' && target.boosts[i] < 6) {
+ if (i !== 'accuracy' && i !== 'evasion' && i !== 'atk' && target.boosts[i] < 6) {
stats.push(i);
}
}
@@ -786,7 +786,7 @@ exports.BattleMovedex = {
onHit: function(target, source) {
var stats = [];
for (var i in target.boosts) {
- if (i!=='accuracy' && i!=='evasion' && i!=='atk' && target.boosts[i] < 6) {
+ if (i !== 'accuracy' && i !== 'evasion' && i !== 'atk' && target.boosts[i] < 6) {
stats.push(i);
}
}
@@ -810,7 +810,7 @@ exports.BattleMovedex = {
onHit: function(target, source) {
var stats = [];
for (var i in target.boosts) {
- if (i!=='accuracy' && i!=='evasion' && i!=='atk' && target.boosts[i] < 6) {
+ if (i !== 'accuracy' && i !== 'evasion' && i !== 'atk' && target.boosts[i] < 6) {
stats.push(i);
}
}
@@ -837,10 +837,10 @@ exports.BattleMovedex = {
inherit: true,
basePowerCallback: function(pokemon, source) {
if ((source.lastDamage > 0 && pokemon.lastAttackedBy && pokemon.lastAttackedBy.thisTurn)) {
- this.debug('Boosted for getting hit by '+pokemon.lastAttackedBy.move);
- return this.isWeather('hail')?180:120;
+ this.debug('Boosted for getting hit by ' + pokemon.lastAttackedBy.move);
+ return this.isWeather('hail') ? 180 : 120;
}
- return this.isWeather('hail')?90:60;
+ return this.isWeather('hail') ? 90 : 60;
}
},
/******************************************************************
@@ -981,7 +981,7 @@ exports.BattleMovedex = {
inherit: true,
basePower: 40,
accuracy: true,
- multihit: [2,2]
+ multihit: [2, 2]
},
/******************************************************************
Moves with not enough drawbacks:
@@ -1143,18 +1143,18 @@ exports.BattleMovedex = {
onBasePower: function(power, user) {
var doubled = false;
if (user.removeVolatile('leechseed')) {
- this.add('-end', user, 'Leech Seed', '[from] move: Rapid Spin', '[of] '+user);
+ this.add('-end', user, 'Leech Seed', '[from] move: Rapid Spin', '[of] ' + user);
doubled = true;
}
var sideConditions = {spikes:1, toxicspikes:1, stealthrock:1};
for (var i in sideConditions) {
if (user.side.removeSideCondition(i)) {
- this.add('-sideend', user.side, this.getEffect(i).name, '[from] move: Rapid Spin', '[of] '+user);
+ this.add('-sideend', user.side, this.getEffect(i).name, '[from] move: Rapid Spin', '[of] ' + user);
doubled = true;
}
}
if (user.volatiles['partiallytrapped']) {
- this.add('-remove', user, user.volatiles['partiallytrapped'].sourceEffect.name, '[from] move: Rapid Spin', '[of] '+user, '[partiallytrapped]');
+ this.add('-remove', user, user.volatiles['partiallytrapped'].sourceEffect.name, '[from] move: Rapid Spin', '[of] ' + user, '[partiallytrapped]');
doubled = true;
delete user.volatiles['partiallytrapped'];
}
@@ -1167,7 +1167,7 @@ exports.BattleMovedex = {
accuracy: 100,
onBasePower: function(power, user) {
if (user.side.removeSideCondition('stealthrock')) {
- this.add('-sideend', user.side, "Stealth Rock", '[from] move: Rapid Spin', '[of] '+user);
+ this.add('-sideend', user.side, "Stealth Rock", '[from] move: Rapid Spin', '[of] ' + user);
return power * 2;
}
}
@@ -1680,7 +1680,7 @@ exports.BattleMovedex = {
inherit: true,
basePower: 40,
accuracy: true,
- multihit: [2,2]
+ multihit: [2, 2]
},
acid: {
inherit: true,
@@ -1712,14 +1712,14 @@ exports.BattleMovedex = {
pp: 10,
isViable: true,
priority: 0,
- multihit: [3,3],
+ multihit: [3, 3],
secondary: {
chance: 10,
onHit: function(target, source) {
var result = this.random(3);
- if (result===0) {
+ if (result === 0) {
target.trySetStatus('brn', source);
- } else if (result===1) {
+ } else if (result === 1) {
target.trySetStatus('par', source);
} else {
target.trySetStatus('frz', source);
diff --git a/mods/gennext/statuses.js b/mods/gennext/statuses.js
index d790abf8c2..5e8e0cf135 100644
--- a/mods/gennext/statuses.js
+++ b/mods/gennext/statuses.js
@@ -26,7 +26,7 @@ exports.BattleStatuses = {
lockedmove: {
// Outrage, Thrash, Petal Dance...
durationCallback: function() {
- return this.random(2,4);
+ return this.random(2, 4);
},
onResidual: function(target) {
var move = this.getMove(target.lastMove);
@@ -52,7 +52,7 @@ exports.BattleStatuses = {
var result = this.runEvent('TryConfusion', target, source, sourceEffect);
if (!result) return result;
this.add('-start', target, 'confusion');
- this.effectData.time = this.random(3,4);
+ this.effectData.time = this.random(3, 4);
},
onEnd: function(target) {
this.add('-end', target, 'confusion');
@@ -63,7 +63,7 @@ exports.BattleStatuses = {
pokemon.removeVolatile('confusion');
return;
}
- this.directDamage(this.getDamage(pokemon,pokemon,30));
+ this.directDamage(this.getDamage(pokemon, pokemon, 30));
}
},
diff --git a/mods/inverse/moves.js b/mods/inverse/moves.js
index c671d7e30a..4165a0571d 100644
--- a/mods/inverse/moves.js
+++ b/mods/inverse/moves.js
@@ -16,8 +16,8 @@ exports.BattleMovedex = {
var side = pokemon.side;
if (!pokemon.runImmunity('Ground')) return;
if (pokemon.hasType('Flying') && pokemon.item !== 'ironball' && !this.pseudoWeather.gravity && !pokemon.volatiles['ingrain']) return;
- var damageAmounts = [0,3,4,6]; // 1/8, 1/6, 1/4
- var damage = this.damage(damageAmounts[this.effectData.layers]*pokemon.maxhp/24);
+ var damageAmounts = [0, 3, 4, 6]; // 1/8, 1/6, 1/4
+ var damage = this.damage(damageAmounts[this.effectData.layers] * pokemon.maxhp / 24);
}
}
},
@@ -52,7 +52,7 @@ exports.BattleMovedex = {
if (!pokemon.runImmunity('Poison')) return;
if (pokemon.hasType('Flying') && pokemon.item !== 'ironball' && !this.pseudoWeather.gravity && !pokemon.volatiles['ingrain']) return;
if (pokemon.hasType('Poison')) {
- this.add('-sideend', pokemon.side, 'move: Toxic Spikes', '[of] '+pokemon);
+ this.add('-sideend', pokemon.side, 'move: Toxic Spikes', '[of] ' + pokemon);
pokemon.side.removeSideCondition('toxicspikes');
} else if (this.effectData.layers >= 2) {
pokemon.trySetStatus('tox');
diff --git a/rooms.js b/rooms.js
index 88da1c6d70..83d0302382 100644
--- a/rooms.js
+++ b/rooms.js
@@ -9,9 +9,9 @@
* @license MIT license
*/
-const TIMEOUT_EMPTY_DEALLOCATE = 10*60*1000;
-const TIMEOUT_INACTIVE_DEALLOCATE = 40*60*1000;
-const REPORT_USER_STATS_INTERVAL = 1000*60*10;
+const TIMEOUT_EMPTY_DEALLOCATE = 10 * 60 * 1000;
+const TIMEOUT_INACTIVE_DEALLOCATE = 40 * 60 * 1000;
+const REPORT_USER_STATS_INTERVAL = 1000 * 60 * 10;
var fs = require('fs');
@@ -54,13 +54,13 @@ var GlobalRoom = (function() {
this.autojoin = []; // rooms that users autojoin upon connecting
this.staffAutojoin = []; // rooms that staff autojoin upon connecting
- for (var i=0; i=0; i--) {
+ for (var i = this.rooms.length - 1; i >= 0; i--) {
var room = this.rooms[i];
if (!room || !room.active) continue;
if (filter && filter !== room.format && filter !== true) continue;
@@ -204,7 +204,7 @@ var GlobalRoom = (function() {
};
GlobalRoom.prototype.getRooms = function() {
var rooms = {official:[], chat:[], userCount: this.userCount, battleCount: this.battleCount};
- for (var i=0; i 300) searchRange = 300;
if (Math.abs(search1.rating - search2.rating) > searchRange) return false;
@@ -293,11 +293,11 @@ var GlobalRoom = (function() {
};
GlobalRoom.prototype.addSearch = function(newSearch, user) {
if (!user.connected) return;
- for (var i=0; i=0; i--) {
+ for (var i = this.chatRoomData.length - 1; i >= 0; i--) {
if (id === toId(this.chatRoomData[i].title)) {
this.chatRoomData.splice(i, 1);
this.writeChatRoomData();
@@ -371,7 +371,7 @@ var GlobalRoom = (function() {
GlobalRoom.prototype.delistChatRoom = function(id) {
id = toId(id);
if (!rooms[id]) return false; // room doesn't exist
- for (var i=this.chatRooms.length-1; i>=0; i--) {
+ for (var i = this.chatRooms.length - 1; i >= 0; i--) {
if (id === this.chatRooms[i].id) {
this.chatRooms.splice(i, 1);
break;
@@ -388,20 +388,20 @@ var GlobalRoom = (function() {
GlobalRoom.prototype.autojoinRooms = function(user, connection) {
// we only autojoin regular rooms if the client requests it with /autojoin
// note that this restriction doesn't apply to staffAutojoin
- for (var i=0; i 2) connection.send('|queryresponse|rooms|null'); // should display room list
};
GlobalRoom.prototype.onJoin = function(user, connection, merging) {
@@ -415,8 +415,8 @@ var GlobalRoom = (function() {
}
if (!merging) {
- var initdata = '|updateuser|'+user.name+'|'+(user.named?'1':'0')+'|'+user.avatar+'\n';
- connection.send(initdata+this.formatListText);
+ var initdata = '|updateuser|' + user.name + '|' + (user.named ? '1' : '0') + '|' + user.avatar + '\n';
+ connection.send(initdata + this.formatListText);
if (this.chatRooms.length > 2) connection.send('|queryresponse|rooms|null'); // should display room list
}
@@ -460,15 +460,15 @@ var GlobalRoom = (function() {
return;
}
- //console.log('BATTLE START BETWEEN: '+p1.userid+' '+p2.userid);
- var i = this.lastBattle+1;
- var formaturlid = format.toLowerCase().replace(/[^a-z0-9]+/g,'');
- while(rooms['battle-'+formaturlid+i]) {
+ //console.log('BATTLE START BETWEEN: ' + p1.userid + ' ' + p2.userid);
+ var i = this.lastBattle + 1;
+ var formaturlid = format.toLowerCase().replace(/[^a-z0-9] + /g, '');
+ while(rooms['battle-' + formaturlid + i]) {
i++;
}
this.lastBattle = i;
rooms.global.writeNumRooms();
- newRoom = this.addRoom('battle-'+formaturlid+'-'+i, format, p1, p2, this.id, rated);
+ newRoom = this.addRoom('battle-' + formaturlid + '-' + i, format, p1, p2, this.id, rated);
p1.joinRoom(newRoom);
p2.joinRoom(newRoom);
newRoom.joinBattle(p1, p1team);
@@ -476,7 +476,7 @@ var GlobalRoom = (function() {
this.cancelSearch(p1, true);
this.cancelSearch(p2, true);
if (Config.reportbattles && rooms.lobby) {
- rooms.lobby.add('|b|'+newRoom.id+'|'+p1.getIdentity()+'|'+p2.getIdentity());
+ rooms.lobby.add('|b|' + newRoom.id + '|' + p1.getIdentity() + '|' + p2.getIdentity());
}
return newRoom;
};
@@ -491,9 +491,9 @@ var GlobalRoom = (function() {
room = getRoom(room);
if (!room) return;
if (this.id in room.i) {
- this.rooms.splice(room.i[this.id],1);
+ this.rooms.splice(room.i[this.id], 1);
delete room.i[this.id];
- for (var i=0; i0.99?'winning':(p1score<0.01?'losing':'tying'));
- if (reasons.substr(0,1) !== '-') reasons = '+'+reasons;
- self.addRaw(sanitize(p1)+'\'s rating: '+oldacre+' → '+acre+'
('+reasons+')');
+ 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 + ')');
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'));
- if (reasons.substr(0,1) !== '-') reasons = '+'+reasons;
- self.addRaw(sanitize(p2)+'\'s rating: '+oldacre+' → '+acre+'
('+reasons+')');
+ 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 + ')');
Users.get(p1).cacheMMR(rated.format, data.p1rating);
Users.get(p2).cacheMMR(rated.format, data.p2rating);
@@ -651,7 +651,7 @@ var BattleRoom = (function() {
});
}
}
- rooms.global.battleCount += 0 - (this.active?1:0);
+ rooms.global.battleCount += 0 - (this.active ? 1 : 0);
this.active = false;
this.update();
};
@@ -730,15 +730,15 @@ var BattleRoom = (function() {
var date = new Date();
var logfolder = date.format('{yyyy}-{MM}');
var logsubfolder = date.format('{yyyy}-{MM}-{dd}');
- var curpath = 'logs/'+logfolder;
+ var curpath = 'logs/' + logfolder;
var self = this;
fs.mkdir(curpath, '0755', function() {
- var tier = self.format.toLowerCase().replace(/[^a-z0-9]+/g,'');
- curpath += '/'+tier;
+ var tier = self.format.toLowerCase().replace(/[^a-z0-9]+/g, '');
+ curpath += '/' + tier;
fs.mkdir(curpath, '0755', function() {
- curpath += '/'+logsubfolder;
+ curpath += '/' + logsubfolder;
fs.mkdir(curpath, '0755', function() {
- fs.writeFile(curpath+'/'+self.id+'.log.json', JSON.stringify(logData));
+ fs.writeFile(curpath + '/' + self.id + '.log.json', JSON.stringify(logData));
});
});
}); // asychronicity
@@ -748,7 +748,7 @@ var BattleRoom = (function() {
if (user) {
user.sendTo(this, message);
} else {
- Sockets.channelBroadcast(this.id, '>'+this.id+'\n'+message);
+ Sockets.channelBroadcast(this.id, '>' + this.id + '\n' + message);
}
};
BattleRoom.prototype.tryExpire = function() {
@@ -767,7 +767,7 @@ var BattleRoom = (function() {
this.add('RESET');
this.update();
- rooms.global.battleCount += 0 - (this.active?1:0);
+ rooms.global.battleCount += 0 - (this.active ? 1 : 0);
this.active = false;
if (this.parentid) {
getRoom(this.parentid).updateRooms();
@@ -792,17 +792,17 @@ var BattleRoom = (function() {
var ids = ['p1', 'p2'];
var otherids = ['p2', 'p1'];
- var name = 'Player '+(side+1);
+ var name = 'Player ' + (side + 1);
if (user) {
name = user.name;
} else if (this.rated) {
name = this.rated[ids[side]];
}
- this.addCmd('-message', name+message);
+ this.addCmd('-message', name + message);
this.battle.endType = 'forfeit';
this.battle.send('win', otherids[side]);
- rooms.global.battleCount += (this.battle.active?1:0) - (this.active?1:0);
+ rooms.global.battleCount += (this.battle.active ? 1 : 0) - (this.active ? 1 : 0);
this.active = this.battle.active;
this.update();
return true;
@@ -830,26 +830,26 @@ var BattleRoom = (function() {
ticksLeft[1] = Math.min(this.sideTurnTicks[1], this.sideTicksLeft[1]);
if (ticksLeft[0] && ticksLeft[1]) {
- if (inactiveSide == 0 || inactiveSide == 1) {
+ if (inactiveSide === 0 || inactiveSide === 1) {
// one side is inactive
var inactiveTicksLeft = ticksLeft[inactiveSide];
var inactiveUser = this.battle.getPlayer(inactiveSide);
- if (inactiveTicksLeft % 3 == 0 || inactiveTicksLeft <= 4) {
- this.send('|inactive|'+(inactiveUser?inactiveUser.name:'Player '+(inactiveSide+1))+' has '+(inactiveTicksLeft*10)+' seconds left.');
+ if (inactiveTicksLeft % 3 === 0 || inactiveTicksLeft <= 4) {
+ this.send('|inactive|' + (inactiveUser ? inactiveUser.name : 'Player ' + (inactiveSide + 1)) + ' has ' + (inactiveTicksLeft * 10) + ' seconds left.');
}
} else {
// both sides are inactive
var inactiveUser0 = this.battle.getPlayer(0);
- if (ticksLeft[0] % 3 == 0 || ticksLeft[0] <= 4) {
- this.send('|inactive|'+(inactiveUser0?inactiveUser0.name:'Player 1')+' has '+(ticksLeft[0]*10)+' seconds left.', inactiveUser0);
+ if (ticksLeft[0] % 3 === 0 || ticksLeft[0] <= 4) {
+ this.send('|inactive|' + (inactiveUser0 ? inactiveUser0.name : 'Player 1') + ' has ' + (ticksLeft[0] * 10) + ' seconds left.', inactiveUser0);
}
var inactiveUser1 = this.battle.getPlayer(1);
- if (ticksLeft[1] % 3 == 0 || ticksLeft[1] <= 4) {
- this.send('|inactive|'+(inactiveUser1?inactiveUser1.name:'Player 2')+' has '+(ticksLeft[1]*10)+' seconds left.', inactiveUser1);
+ if (ticksLeft[1] % 3 === 0 || ticksLeft[1] <= 4) {
+ this.send('|inactive|' + (inactiveUser1 ? inactiveUser1.name : 'Player 2') + ' has ' + (ticksLeft[1] * 10) + ' seconds left.', inactiveUser1);
}
}
- this.resetTimer = setTimeout(this.kickInactive.bind(this), 10*1000);
+ this.resetTimer = setTimeout(this.kickInactive.bind(this), 10 * 1000);
return;
}
@@ -858,7 +858,7 @@ var BattleRoom = (function() {
else if (ticksLeft[1]) inactiveSide = 0;
}
- this.forfeit(this.battle.getPlayer(inactiveSide),' lost due to inactivity.', inactiveSide);
+ this.forfeit(this.battle.getPlayer(inactiveSide), ' lost due to inactivity.', inactiveSide);
this.resetUser = '';
if (this.parentid) {
@@ -873,7 +873,7 @@ var BattleRoom = (function() {
if (user) {
if (!force && this.battle.getSlot(user) < 0) return false;
this.resetUser = user.userid;
- this.send('|inactive|Battle timer is now ON: inactive players will automatically lose when time\'s up. (requested by '+user.name+')');
+ this.send('|inactive|Battle timer is now ON: inactive players will automatically lose when time\'s up. (requested by ' + user.name + ')');
} else if (user === false) {
this.resetUser = '~';
this.add('|inactive|Battle timer is ON: inactive players will automatically lose when time\'s up.');
@@ -901,15 +901,15 @@ var BattleRoom = (function() {
if (inactiveSide != 1) {
// side 0 is inactive
var ticksLeft0 = Math.min(this.sideTicksLeft[0] + 1, maxTicksLeft);
- this.send('|inactive|You have '+(ticksLeft0*10)+' seconds to make your decision.', this.battle.getPlayer(0));
+ this.send('|inactive|You have ' + (ticksLeft0 * 10) + ' seconds to make your decision.', this.battle.getPlayer(0));
}
if (inactiveSide != 0) {
// side 1 is inactive
var ticksLeft1 = Math.min(this.sideTicksLeft[1] + 1, maxTicksLeft);
- this.send('|inactive|You have '+(ticksLeft1*10)+' seconds to make your decision.', this.battle.getPlayer(1));
+ this.send('|inactive|You have ' + (ticksLeft1 * 10) + ' seconds to make your decision.', this.battle.getPlayer(1));
}
- this.resetTimer = setTimeout(this.kickInactive.bind(this), 10*1000);
+ this.resetTimer = setTimeout(this.kickInactive.bind(this), 10 * 1000);
return true;
};
BattleRoom.prototype.nextInactive = function() {
@@ -983,7 +983,7 @@ var BattleRoom = (function() {
BattleRoom.prototype.decision = function(user, choice, data) {
this.battle.sendFor(user, choice, data);
if (this.active !== this.battle.active) {
- rooms.global.battleCount += (this.battle.active?1:0) - (this.active?1:0);
+ rooms.global.battleCount += (this.battle.active ? 1 : 0) - (this.active ? 1 : 0);
this.active = this.battle.active;
if (this.parentid) {
getRoom(this.parentid).updateRooms();
@@ -994,7 +994,7 @@ var BattleRoom = (function() {
// This function is only called when the room is not empty.
// Joining an empty room calls this.join() below instead.
BattleRoom.prototype.onJoinConnection = function(user, connection) {
- this.send('|init|battle\n|title|'+this.title+'\n'+this.getLogForUser(user).join('\n'), connection);
+ this.send('|init|battle\n|title|' + this.title + '\n' + this.getLogForUser(user).join('\n'), connection);
// this handles joining a battle in which a user is a participant,
// where the user has already identified before attempting to join
// the battle
@@ -1011,7 +1011,7 @@ var BattleRoom = (function() {
this.update(user);
}
- this.send('|init|battle\n|title|'+this.title+'\n'+this.getLogForUser(user).join('\n'), connection);
+ this.send('|init|battle\n|title|' + this.title + '\n' + this.getLogForUser(user).join('\n'), connection);
return user;
};
BattleRoom.prototype.onRename = function(user, oldid, joining) {
@@ -1021,7 +1021,7 @@ var BattleRoom = (function() {
var resend = joining || !this.battle.playerTable[oldid];
if (this.battle.playerTable[oldid]) {
if (this.rated) {
- this.add('|message|'+user.name+' forfeited by changing their name.');
+ this.add('|message|' + user.name + ' forfeited by changing their name.');
this.battle.lose(oldid);
this.battle.leave(oldid);
resend = false;
@@ -1044,7 +1044,7 @@ var BattleRoom = (function() {
if (!user) return; // ...
if (user.battles[this.id]) {
this.battle.leave(user);
- rooms.global.battleCount += (this.battle.active?1:0) - (this.active?1:0);
+ rooms.global.battleCount += (this.battle.active ? 1 : 0) - (this.active ? 1 : 0);
this.active = this.battle.active;
if (this.parentid) {
getRoom(this.parentid).updateRooms();
@@ -1057,7 +1057,7 @@ var BattleRoom = (function() {
this.addCmd('leave', user.name);
if (Object.isEmpty(this.users)) {
- rooms.global.battleCount += 0 - (this.active?1:0);
+ rooms.global.battleCount += 0 - (this.active ? 1 : 0);
this.active = false;
}
@@ -1072,18 +1072,18 @@ var BattleRoom = (function() {
} else if (this.rated.p2 === user.userid) {
slot = 1;
} else {
- user.popup("This is a rated battle; your username must be "+this.rated.p1+" or "+this.rated.p2+" to join.");
+ user.popup("This is a rated battle; your username must be " + this.rated.p1 + " or " + this.rated.p2 + " to join.");
return false;
}
}
this.auth[user.userid] = '\u2605';
this.battle.join(user, slot, team);
- rooms.global.battleCount += (this.battle.active?1:0) - (this.active?1:0);
+ rooms.global.battleCount += (this.battle.active ? 1 : 0) - (this.active ? 1 : 0);
this.active = this.battle.active;
if (this.active) {
- this.title = ""+this.battle.p1+" vs. "+this.battle.p2;
- this.send('|title|'+this.title);
+ this.title = "" + this.battle.p1 + " vs. " + this.battle.p2;
+ this.send('|title|' + this.title);
}
this.update();
this.kickInactiveUpdate();
@@ -1100,7 +1100,7 @@ var BattleRoom = (function() {
return false;
}
this.auth[user.userid] = '+';
- rooms.global.battleCount += (this.battle.active?1:0) - (this.active?1:0);
+ rooms.global.battleCount += (this.battle.active ? 1 : 0) - (this.active ? 1 : 0);
this.active = this.battle.active;
this.update();
this.kickInactiveUpdate();
@@ -1111,7 +1111,7 @@ var BattleRoom = (function() {
return true;
};
BattleRoom.prototype.addCmd = function() {
- this.log.push('|'+Array.prototype.slice.call(arguments).join('|'));
+ this.log.push('|' + Array.prototype.slice.call(arguments).join('|'));
};
BattleRoom.prototype.add = function(message) {
if (message.rawMessage) {
@@ -1179,7 +1179,7 @@ var ChatRoom = (function() {
Object.merge(this, options);
}
this.id = roomid;
- this.title = title||roomid;
+ this.title = title || roomid;
this.i = {};
this.log = [];
@@ -1308,9 +1308,9 @@ var ChatRoom = (function() {
continue;
}
counter++;
- buffer += ','+this.users[i].getIdentity(this.id);
+ buffer += ',' + this.users[i].getIdentity(this.id);
}
- var msg = '|users|'+counter+buffer;
+ var msg = '|users|' + counter + buffer;
return msg;
};
ChatRoom.prototype.update = function() {
@@ -1329,7 +1329,7 @@ var ChatRoom = (function() {
if (user) {
user.sendTo(this, message);
} else {
- if (this.id !== 'lobby') message = '>'+this.id+'\n'+message;
+ if (this.id !== 'lobby') message = '>' + this.id + '\n' + message;
Sockets.channelBroadcast(this.id, message);
}
};
@@ -1350,7 +1350,7 @@ var ChatRoom = (function() {
}
};
ChatRoom.prototype.addRaw = function(message) {
- this.add('|raw|'+message);
+ this.add('|raw|' + message);
};
ChatRoom.prototype.logGetLast = function (amount, noTime) {
if (!amount) {
@@ -1402,7 +1402,7 @@ var ChatRoom = (function() {
ChatRoom.prototype.onJoinConnection = function(user, connection) {
var userList = this.userList ? this.userList : this.getUserList();
var modchat = this.getModchatNote();
- this.send('|init|chat\n|title|'+this.title+'\n'+userList+'\n'+this.logGetLast(25).join('\n')+modchat, connection);
+ this.send('|init|chat\n|title|' + this.title + '\n' + userList + '\n' + this.logGetLast(25).join('\n') + modchat, connection);
if (global.Tournaments && Tournaments.get(this.id))
Tournaments.get(this.id).update(user);
};
@@ -1412,10 +1412,10 @@ var ChatRoom = (function() {
this.users[user.userid] = user;
if (user.named && Config.reportjoins) {
- this.add('|j|'+user.getIdentity(this.id), true);
+ this.add('|j|' + user.getIdentity(this.id), true);
this.update(user);
} else if (user.named) {
- var entry = '|J|'+user.getIdentity(this.id);
+ var entry = '|J|' + user.getIdentity(this.id);
if (Config.reportjoinsperiod) {
this.reportJoinsQueue.push(entry);
} else {
@@ -1427,7 +1427,7 @@ var ChatRoom = (function() {
if (!merging) {
var userList = this.userList ? this.userList : this.getUserList();
var modchat = this.getModchatNote();
- this.send('|init|chat\n|title|'+this.title+'\n'+userList+'\n'+this.logGetLast(100).join('\n')+modchat, connection);
+ this.send('|init|chat\n|title|' + this.title + '\n' + userList + '\n' + this.logGetLast(100).join('\n') + modchat, connection);
}
if (global.Tournaments && Tournaments.get(this.id))
Tournaments.get(this.id).update(user);
@@ -1480,7 +1480,7 @@ var ChatRoom = (function() {
if (!user) return; // ...
delete this.users[user.userid];
if (user.named && Config.reportjoins) {
- this.add('|l|'+user.getIdentity(this.id));
+ this.add('|l|' + user.getIdentity(this.id));
} else if (user.named) {
var entry = '|L|' + user.getIdentity(this.id);
if (Config.reportjoinsperiod) {
@@ -1495,7 +1495,7 @@ var ChatRoom = (function() {
message = CommandParser.parse(message, this, user, connection);
if (message) {
- this.add('|c|'+user.getIdentity(this.id)+'|'+message, true);
+ this.add('|c|' + user.getIdentity(this.id) + '|' + message, true);
}
this.update();
};
@@ -1533,7 +1533,7 @@ var newRoom = function(roomid, format, p1, p2, parent, rated) {
if (!p1 || !p2) return false;
if (!roomid) roomid = 'default';
if (!rooms[roomid]) {
- // console.log("NEW BATTLE ROOM: "+roomid);
+ // console.log("NEW BATTLE ROOM: " + roomid);
ResourceMonitor.countBattle(p1.latestIp, p1.name);
ResourceMonitor.countBattle(p2.latestIp, p2.name);
rooms[roomid] = new BattleRoom(roomid, format, p1, p2, parent, rated);
diff --git a/simulator.js b/simulator.js
index e058bdf6c0..64ec037ff6 100644
--- a/simulator.js
+++ b/simulator.js
@@ -89,7 +89,7 @@ var Simulator = (function(){
simulators[id] = this;
- this.send('init', this.format, rated?'1':'');
+ this.send('init', this.format, rated ? '1' : '');
}
Simulator.prototype.id = '';
@@ -115,12 +115,12 @@ var Simulator = (function(){
Simulator.prototype.lastIp = null;
Simulator.prototype.send = function() {
this.activeIp = ResourceMonitor.activeIp;
- this.process.send(''+this.id+'|'+slice.call(arguments).join('|'));
+ this.process.send('' + this.id + '|' + slice.call(arguments).join('|'));
};
Simulator.prototype.sendFor = function(user, action) {
var player = this.playerTable[toId(user)];
if (!player) {
- console.log('SENDFOR FAILED: Player doesn\'t exist: '+user.name);
+ console.log('SENDFOR FAILED: Player doesn\'t exist: ' + user.name);
return;
}
@@ -171,7 +171,7 @@ var Simulator = (function(){
var rqid = lines[3];
if (player) {
this.requests[player.userid] = lines[4];
- player.sendTo(this.id, '|request|'+lines[4]);
+ player.sendTo(this.id, '|request|' + lines[4]);
}
if (rqid !== this.rqid) {
this.rqid = rqid;
@@ -196,7 +196,7 @@ var Simulator = (function(){
Simulator.prototype.resendRequest = function(user) {
if (this.requests[user.userid]) {
- user.sendTo(this.id, '|request|'+this.requests[user.userid]);
+ user.sendTo(this.id, '|request|' + this.requests[user.userid]);
}
};
Simulator.prototype.win = function(user) {
@@ -213,7 +213,7 @@ var Simulator = (function(){
this.send('tie');
};
Simulator.prototype.chat = function(user, message) {
- this.send('chat', user.name+"\n"+message);
+ this.send('chat', user.name + "\n" + message);
};
Simulator.prototype.isEmpty = function() {
@@ -245,20 +245,20 @@ var Simulator = (function(){
this.playerids[slot] = (user ? user.userid : null);
this.playerTable = {};
this.active = !this.ended;
- for (var i=0, len=this.players.length; i= this.players.length) return false;
this.setPlayer(user, slot);
- var message = ''+user.avatar;
+ var message = '' + user.avatar;
if (!this.started) {
- message += "\n"+team;
+ message += "\n" + team;
}
if (this.p1 && this.p2) this.started = true;
this.sendFor(user, 'join', user.name, message);
@@ -289,7 +289,7 @@ var Simulator = (function(){
};
Simulator.prototype.rename = function() {
- for (var i=0, len=this.players.length; i'+socketid+'\n'+message);
+ worker.send('>' + socketid + '\n' + message);
};
exports.socketDisconnect = function(worker, socketid) {
- worker.send('!'+socketid);
+ worker.send('!' + socketid);
};
exports.channelBroadcast = function(channelid, message) {
for (var workerid in workers) {
- workers[workerid].send('#'+channelid+'\n'+message);
+ workers[workerid].send('#' + channelid + '\n' + message);
}
};
exports.channelSend = function(worker, channelid, message) {
- worker.send('#'+channelid+'\n'+message);
+ worker.send('#' + channelid + '\n' + message);
};
exports.channelAdd = function(worker, channelid, socketid) {
- worker.send('+'+channelid+'\n'+socketid);
+ worker.send('+'+channelid + '\n' + socketid);
};
exports.channelRemove = function(worker, channelid, socketid) {
- worker.send('-'+channelid+'\n'+socketid);
+ worker.send('-' + channelid + '\n' + socketid);
};
} else {
@@ -127,7 +127,7 @@ if (cluster.isMaster) {
if (Config.crashguard) {
// graceful crash
process.on('uncaughtException', function(err) {
- require('./crashlogger.js')(err, 'Socket process '+cluster.worker.id+' ('+process.pid+')');
+ require('./crashlogger.js')(err, 'Socket process ' + cluster.worker.id + ' (' + process.pid + ')');
});
}
@@ -187,7 +187,7 @@ if (cluster.isMaster) {
var server = sockjs.createServer({
sockjs_url: "//play.pokemonshowdown.com/js/lib/sockjs-0.3.min.js",
log: function(severity, message) {
- if (severity === 'error') console.log('ERROR: '+message);
+ if (severity === 'error') console.log('ERROR: ' + message);
},
prefix: '/showdown',
websocket: !Config.disablewebsocket
@@ -220,11 +220,11 @@ if (cluster.isMaster) {
};
var interval;
if (!Config.herokuhack) {
- interval = setInterval(sweepClosedSockets, 1000*60*10);
+ interval = setInterval(sweepClosedSockets, 1000 * 60 * 10);
}
process.on('message', function(data) {
- // console.log('worker received: '+data);
+ // console.log('worker received: ' + data);
var socket = null;
var socketid = null;
var channelid = null;
@@ -246,16 +246,16 @@ if (cluster.isMaster) {
case '>': // >socketid, message
// message
var nlLoc = data.indexOf('\n');
- socket = sockets[data.substr(1, nlLoc-1)];
+ socket = sockets[data.substr(1, nlLoc - 1)];
if (!socket) return;
- socket.write(data.substr(nlLoc+1));
+ socket.write(data.substr(nlLoc + 1));
break;
case '#': // #channelid, message
// message to channel
var nlLoc = data.indexOf('\n');
- channel = channels[data.substr(1, nlLoc-1)];
- var message = data.substr(nlLoc+1);
+ channel = channels[data.substr(1, nlLoc - 1)];
+ var message = data.substr(nlLoc + 1);
for (socketid in channel) {
channel[socketid].write(message);
}
@@ -264,10 +264,10 @@ if (cluster.isMaster) {
case '+': // +channelid, socketid
// add to channel
var nlLoc = data.indexOf('\n');
- socketid = data.substr(nlLoc+1);
+ socketid = data.substr(nlLoc + 1);
socket = sockets[socketid];
if (!socket) return;
- channelid = data.substr(1, nlLoc-1);
+ channelid = data.substr(1, nlLoc - 1);
var channel = channels[channelid];
if (!channel) channel = channels[channelid] = {};
channel[socketid] = socket;
@@ -276,10 +276,10 @@ if (cluster.isMaster) {
case '-': // -channelid, socketid
// remove from channel
var nlLoc = data.indexOf('\n');
- var channelid = data.substr(1, nlLoc-1);
+ var channelid = data.substr(1, nlLoc - 1);
var channel = channels[channelid];
if (!channel) return;
- delete channel[data.substr(nlLoc+1)];
+ delete channel[data.substr(nlLoc + 1)];
var isEmpty = true;
for (var socketid in channel) {
isEmpty = false;
@@ -321,9 +321,9 @@ if (cluster.isMaster) {
}
}
- process.send('*'+socketid+'\n'+socket.remoteAddress);
+ process.send('*' + socketid + '\n' + socket.remoteAddress);
- // console.log('CONNECT: '+socket.remoteAddress+' ['+socket.id+']');
+ // console.log('CONNECT: ' + socket.remoteAddress + ' [' + socket.id + ']');
var interval;
if (Config.herokuhack) {
// see https://github.com/sockjs/sockjs-node/issues/57#issuecomment-5242187
@@ -339,17 +339,17 @@ if (cluster.isMaster) {
if (!message) return;
// drop blank messages (DDoS?)
var pipeIndex = message.indexOf('|');
- if (pipeIndex < 0 || pipeIndex === message.length-1) return;
+ if (pipeIndex < 0 || pipeIndex === message.length - 1) return;
// drop legacy JSON messages
if (message.charAt(0) === '{') return;
- process.send('<'+socketid+'\n'+message);
+ process.send('<' + socketid + '\n' + message);
});
socket.on('close', function() {
if (interval) {
clearInterval(interval);
}
- process.send('!'+socketid);
+ process.send('!' + socketid);
delete sockets[socketid];
for (var channelid in channels) {
@@ -359,12 +359,12 @@ if (cluster.isMaster) {
});
server.installHandlers(app, {});
app.listen(Config.port);
- console.log('Worker '+cluster.worker.id+' now listening on port ' + Config.port);
+ console.log('Worker ' + cluster.worker.id + ' now listening on port ' + Config.port);
if (appssl) {
server.installHandlers(appssl, {});
appssl.listen(Config.ssl.port);
- console.log('Worker '+cluster.worker.id+' now listening for SSL on port ' + Config.ssl.port);
+ console.log('Worker ' + cluster.worker.id + ' now listening for SSL on port ' + Config.ssl.port);
}
console.log('Test your server at http://localhost:' + Config.port);
diff --git a/team-validator.js b/team-validator.js
index f9f800d916..b602b7b2f2 100644
--- a/team-validator.js
+++ b/team-validator.js
@@ -20,12 +20,12 @@ if (!process.send) {
// success: "[id]|1[details]"
// failure: "[id]|0[details]"
var pipeIndex = message.indexOf('|');
- var id = message.substr(0,pipeIndex);
- var success = (message.charAt(pipeIndex+1) === '1');
+ var id = message.substr(0, pipeIndex);
+ var success = (message.charAt(pipeIndex + 1) === '1');
if (pendingValidations[id]) {
ValidatorProcess.release(self);
- pendingValidations[id](success, message.substr(pipeIndex+2));
+ pendingValidations[id](success, message.substr(pipeIndex + 2));
delete pendingValidations[id];
}
});
@@ -66,7 +66,7 @@ if (!process.send) {
var process = this.acquire();
pendingValidations[validationCount] = callback;
try {
- process.process.send(''+validationCount+'|'+format+'|'+team);
+ process.process.send('' + validationCount + '|' + format + '|' + team);
} catch (e) {}
++validationCount;
};
@@ -131,7 +131,7 @@ if (!process.send) {
while (bannedNameStartChars[name.charAt(0)]) {
name = name.substr(1);
}
- if (name.length > 18) name = name.substr(0,18);
+ if (name.length > 18) name = name.substr(0, 18);
if (Config.namefilter) {
name = Config.namefilter(name);
}
@@ -140,12 +140,12 @@ if (!process.send) {
/**
* Safely ensures the passed variable is a string
- * Simply doing ''+str can crash if str.toString crashes or isn't a function
+ * Simply doing '' + str can crash if str.toString crashes or isn't a function
* If we're expecting a string and being given anything that isn't a string
* or a number, it's safe to assume it's an error, and return ''
*/
global.string = function(str) {
- if (typeof str === 'string' || typeof str === 'number') return ''+str;
+ if (typeof str === 'string' || typeof str === 'number') return '' + str;
return '';
};
@@ -154,7 +154,7 @@ if (!process.send) {
var validators = {};
function respond(id, success, details) {
- process.send(id+(success?'|1':'|0')+details);
+ process.send(id + (success ? '|1' : '|0') + details);
}
process.on('message', function(message) {
@@ -174,8 +174,8 @@ if (!process.send) {
} else {
var packedTeam = Tools.packTeam(parsedTeam);
if (packedTeam === message.substr(pipeIndex2 + 1)) packedTeam = '';
- // console.log('FROM: '+message.substr(pipeIndex2 + 1));
- // console.log('TO: '+packedTeam);
+ // console.log('FROM: ' + message.substr(pipeIndex2 + 1));
+ // console.log('TO: ' + packedTeam);
respond(id, true, packedTeam);
}
});
@@ -205,11 +205,11 @@ var Validator = (function() {
if (!team.length) {
return ["Your team has no pokemon."];
}
- if (team.length>6) {
+ if (team.length > 6) {
return ["Your team has more than 6 pokemon."];
}
var teamHas = {};
- for (var i=0; i= maxForcedLevel) {
set.forcedLevel = maxForcedLevel;
}
- if (set.level > maxLevel || set.level == set.forcedLevel || set.level == set.maxForcedLevel) {
+ if (set.level > maxLevel || set.level === set.forcedLevel || set.level === set.maxForcedLevel) {
set.level = maxLevel;
}
@@ -288,7 +288,7 @@ var Validator = (function() {
set.species = set.species;
set.name = set.name || set.species;
var name = set.species;
- if (set.species !== set.name) name = set.name + " ("+set.species+")";
+ if (set.species !== set.name) name = set.name + " (" + set.species + ")";
var isHidden = false;
var lsetData = {set:set, format:format};
@@ -300,17 +300,17 @@ var Validator = (function() {
}
if (format.ruleset) {
- for (var i=0; i= 3 && totalEV > 510) {
- problems.push(name+" has more than 510 total EVs.");
+ problems.push(name + " has more than 510 total EVs.");
}
// Don't check abilities for metagames with All Abilities
@@ -369,19 +369,19 @@ var Validator = (function() {
set.ability = 'None';
} else if (!banlistTable['ignoreillegalabilities']) {
if (!ability.name) {
- problems.push(name+" needs to have an ability.");
+ problems.push(name + " needs to have an ability.");
} else if (ability.name !== template.abilities['0'] &&
ability.name !== template.abilities['1'] &&
ability.name !== template.abilities['H']) {
- problems.push(name+" can't have "+set.ability+".");
+ problems.push(name + " can't have " + set.ability + ".");
}
if (ability.name === template.abilities['H']) {
isHidden = true;
if (template.unreleasedHidden && banlistTable['illegal']) {
- problems.push(name+"'s hidden ability is unreleased.");
+ problems.push(name + "'s hidden ability is unreleased.");
} else if (tools.gen === 5 && set.level < 10 && (template.maleOnlyHidden || template.gender === 'N')) {
- problems.push(name+" must be at least level 10 with its hidden ability.");
+ problems.push(name + " must be at least level 10 with its hidden ability.");
}
if (template.maleOnlyHidden) {
set.gender = 'M';
@@ -394,16 +394,16 @@ var Validator = (function() {
set.moves = set.moves.filter(function(val){ return val; });
}
if (!set.moves || !set.moves.length) {
- problems.push(name+" has no moves.");
+ problems.push(name + " has no moves.");
} else {
// A limit is imposed here to prevent too much engine strain or
// too much layout deformation - to be exact, this is the Debug
// Mode limitation.
// The usual limit of 4 moves is handled elsewhere - currently
// in the cartridge-compliant set validator: rulesets.js:pokemon
- set.moves = set.moves.slice(0,24);
+ set.moves = set.moves.slice(0, 24);
- for (var i=0; i1?"s":"")+".");
+ problemString = problemString.concat(" because it can only sketch " + problem.maxSketches + " move" + (problem.maxSketches > 1 ? "s" : "") + ".");
} else if (problem.type === 'pokebank') {
problemString = problemString.concat(" because it's only obtainable from a previous generation.");
} else {
@@ -439,31 +439,31 @@ var Validator = (function() {
if (lsetData.sources && lsetData.sources.length === 1 && !lsetData.sourcesBefore) {
// we're restricted to a single source
var source = lsetData.sources[0];
- if (source.substr(1,1) === 'S') {
+ if (source.substr(1, 1) === 'S') {
// it's an event
var eventData = null;
var splitSource = source.substr(2).split(' ');
var eventTemplate = tools.getTemplate(splitSource[1]);
- if (eventTemplate.eventPokemon) eventData = eventTemplate.eventPokemon[parseInt(splitSource[0],10)];
+ if (eventTemplate.eventPokemon) eventData = eventTemplate.eventPokemon[parseInt(splitSource[0], 10)];
if (eventData) {
if (eventData.nature && eventData.nature !== set.nature) {
- problems.push(name+" must have a "+eventData.nature+" nature because it comes from a specific event.");
+ problems.push(name + " must have a " + eventData.nature + " nature because it comes from a specific event.");
}
if (eventData.shiny) {
set.shiny = true;
}
if (eventData.generation < 5) eventData.isHidden = false;
if (eventData.isHidden !== undefined && eventData.isHidden !== isHidden) {
- problems.push(name+(isHidden?" can't have":" must have")+" its hidden ability because it comes from a specific event.");
+ problems.push(name + (isHidden ? " can't have" : " must have") + " its hidden ability because it comes from a specific event.");
}
if (tools.gen <= 5 && eventData.abilities && eventData.abilities.indexOf(ability.id) < 0) {
- problems.push(name+" must have "+eventData.abilities.join(" or ")+" because it comes from a specific event.");
+ problems.push(name + " must have " + eventData.abilities.join(" or ") + " because it comes from a specific event.");
}
if (eventData.gender) {
set.gender = eventData.gender;
}
if (eventData.level && set.level < eventData.level) {
- problems.push(name+" must be at least level "+eventData.level+" because it comes from a specific event.");
+ problems.push(name + " must be at least level " + eventData.level + " because it comes from a specific event.");
}
}
isHidden = false;
@@ -471,37 +471,37 @@ var Validator = (function() {
}
if (isHidden && lsetData.sourcesBefore < 5) {
if (!lsetData.sources) {
- problems.push(name+" has a hidden ability - it can't have moves only learned before gen 5.");
+ problems.push(name + " has a hidden ability - it can't have moves only learned before gen 5.");
} else if (template.gender) {
var compatibleSource = false;
- for (var i=0,len=lsetData.sources.length; i= 10)) {
+ for (var i = 0, len = lsetData.sources.length; i < len; i++) {
+ if (lsetData.sources[i].charAt(1) === 'E' || (lsetData.sources[i].substr(0, 2) === '5D' && set.level >= 10)) {
compatibleSource = true;
break;
}
}
if (!compatibleSource) {
- problems.push(name+" has moves incompatible with its hidden ability.");
+ problems.push(name + " has moves incompatible with its hidden ability.");
}
}
}
if (banlistTable['illegal'] && set.level < template.evoLevel) {
// FIXME: Event pokemon given at a level under what it normally can be attained at gives a false positive
- problems.push(name+" must be at least level "+template.evoLevel+".");
+ problems.push(name + " must be at least level " + template.evoLevel + ".");
}
if (!lsetData.sources && lsetData.sourcesBefore <= 3 && tools.getAbility(set.ability).gen === 4 && !template.prevo && tools.gen <= 5) {
- problems.push(name+" has a gen 4 ability and isn't evolved - it can't use anything from gen 3.");
+ problems.push(name + " has a gen 4 ability and isn't evolved - it can't use anything from gen 3.");
}
if (!lsetData.sources && lsetData.sourcesBefore >= 3 && (isHidden || tools.gen <= 5) && template.gen <= lsetData.sourcesBefore) {
- var oldAbilities = tools.mod('gen'+lsetData.sourcesBefore).getTemplate(set.species).abilities;
+ var oldAbilities = tools.mod('gen' + lsetData.sourcesBefore).getTemplate(set.species).abilities;
if (ability.name !== oldAbilities['0'] && ability.name !== oldAbilities['1'] && !oldAbilities['H']) {
- problems.push(name+" has moves incompatible with its ability.");
+ problems.push(name + " has moves incompatible with its ability.");
}
}
}
setHas[toId(template.tier)] = true;
if (banlistTable[template.tier]) {
- problems.push(name+" is in "+template.tier+", which is banned.");
+ problems.push(name + " is in " + template.tier + ", which is banned.");
}
if (teamHas) {
@@ -509,22 +509,22 @@ var Validator = (function() {
teamHas[i] = true;
}
}
- for (var i=0; i -1) return false;
// Alphabet Cup hack to do the same
- if (alphabetCupLetter && alphabetCupLetter === Tools.getMove(move).id.slice(0,1) && Tools.getMove(move).id !== 'sketch') return false;
+ if (alphabetCupLetter && alphabetCupLetter === Tools.getMove(move).id.slice(0, 1) && Tools.getMove(move).id !== 'sketch') return false;
if (template.learnset) {
if (template.learnset[move] || template.learnset['sketch']) {
sometimesPossible = true;
@@ -594,11 +594,11 @@ var Validator = (function() {
}
if (typeof lset === 'string') lset = [lset];
- for (var i=0, len=lset.length; i tools.gen) continue;
- if (isHidden && !tools.mod('gen'+learned.charAt(0)).getTemplate(template.species).abilities['H']) {
+ if (parseInt(learned.charAt(0), 10) > tools.gen) continue;
+ if (isHidden && !tools.mod('gen' + learned.charAt(0)).getTemplate(template.species).abilities['H']) {
// check if the Pokemon's hidden ability was available
incompatibleHidden = true;
continue;
@@ -608,21 +608,21 @@ var Validator = (function() {
if (tools.gen >= 4 && learned.charAt(0) <= 3 && move in {'cut':1, 'fly':1, 'surf':1, 'strength':1, 'flash':1, 'rocksmash':1, 'waterfall':1, 'dive':1}) continue;
if (tools.gen >= 5 && learned.charAt(0) <= 4 && move in {'cut':1, 'fly':1, 'surf':1, 'strength':1, 'rocksmash':1, 'waterfall':1, 'rockclimb':1}) continue;
}
- if (learned.substr(0,2) in {'4L':1,'5L':1,'6L':1}) {
+ if (learned.substr(0, 2) in {'4L':1, '5L':1, '6L':1}) {
// gen 4-6 level-up moves
- if (level >= parseInt(learned.substr(2),10)) {
+ if (level >= parseInt(learned.substr(2), 10)) {
// we're past the required level to learn it
return false;
}
if (!template.gender || template.gender === 'F') {
// available as egg move
- learned = learned.charAt(0)+'Eany';
+ learned = learned.charAt(0) + 'Eany';
} else {
// this move is unavailable, skip it
continue;
}
}
- if (learned.charAt(1) in {L:1,M:1,T:1}) {
+ if (learned.charAt(1) in {L:1, M:1, T:1}) {
if (learned.charAt(0) === '6') {
// current-gen TM or tutor moves:
// always available
@@ -631,8 +631,8 @@ var Validator = (function() {
// past-gen level-up, TM, or tutor moves:
// available as long as the source gen was or was before this gen
limit1 = false;
- sourcesBefore = Math.max(sourcesBefore, parseInt(learned.charAt(0),10));
- } else if (learned.charAt(1) in {E:1,S:1,D:1}) {
+ sourcesBefore = Math.max(sourcesBefore, parseInt(learned.charAt(0), 10));
+ } else if (learned.charAt(1) in {E:1, S:1, D:1}) {
// egg, event, or DW moves:
// only if that was the source
if (learned.charAt(1) === 'E') {
@@ -647,33 +647,33 @@ var Validator = (function() {
if (eggGroups[0] === 'Undiscovered') eggGroups = tools.getTemplate(template.evos[0]).eggGroups;
var atLeastOne = false;
var fromSelf = (learned.substr(1) === 'Eany');
- learned = learned.substr(0,2);
+ learned = learned.substr(0, 2);
for (var templateid in tools.data.Pokedex) {
var dexEntry = tools.getTemplate(templateid);
if (
// CAP pokemon can't breed
!dexEntry.isNonstandard &&
// can't breed mons from future gens
- dexEntry.gen <= parseInt(learned.charAt(0),10) &&
+ dexEntry.gen <= parseInt(learned.charAt(0), 10) &&
// genderless pokemon can't pass egg moves
dexEntry.gender !== 'N') {
if (
// chainbreeding
fromSelf ||
// otherwise parent must be able to learn the move
- !alreadyChecked[dexEntry.speciesid] && dexEntry.learnset && (dexEntry.learnset[move]||dexEntry.learnset['sketch'])) {
+ !alreadyChecked[dexEntry.speciesid] && dexEntry.learnset && (dexEntry.learnset[move] || dexEntry.learnset['sketch'])) {
if (dexEntry.eggGroups.intersect(eggGroups).length) {
// we can breed with it
atLeastOne = true;
- sources.push(learned+dexEntry.id);
+ sources.push(learned + dexEntry.id);
}
}
}
}
// chainbreeding with itself from earlier gen
- if (!atLeastOne) sources.push(learned+template.id);
+ if (!atLeastOne) sources.push(learned + template.id);
} else if (learned.charAt(1) === 'S') {
- sources.push(learned+' '+template.id);
+ sources.push(learned + ' ' + template.id);
} else {
sources.push(learned);
}
@@ -686,7 +686,7 @@ var Validator = (function() {
var getGlitch = false;
for (var i in glitchMoves) {
if (template.learnset[i]) {
- if (i === 'mimic' && tools.getAbility(set.ability).gen == 4 && !template.prevo) {
+ if (i === 'mimic' && tools.getAbility(set.ability).gen === 4 && !template.prevo) {
// doesn't get the glitch
} else {
getGlitch = true;
@@ -738,9 +738,9 @@ var Validator = (function() {
var learned;
if (sourcesBefore && lsetData.sources) {
if (!sources) sources = [];
- for (var i=0, len=lsetData.sources.length; i= 650) template.gen = 6;
@@ -210,14 +210,14 @@ module.exports = (function () {
};
Tools.prototype.getMove = function(move) {
if (!move || typeof move === 'string') {
- var name = (move||'').trim();
+ var name = (move || '').trim();
var id = toId(name);
if (this.data.Aliases[id]) {
name = this.data.Aliases[id];
id = toId(name);
}
move = {};
- if (id.substr(0,11) === 'hiddenpower') {
+ if (id.substr(0, 11) === 'hiddenpower') {
var matches = /([a-z]*)([0-9]*)/.exec(id);
id = matches[1];
}
@@ -229,7 +229,7 @@ module.exports = (function () {
}
if (!move.id) move.id = id;
if (!move.name) move.name = name;
- if (!move.fullname) move.fullname = 'move: '+move.name;
+ if (!move.fullname) move.fullname = 'move: ' + move.name;
move.toString = this.effectToString;
if (!move.critRatio) move.critRatio = 1;
if (!move.baseType) move.baseType = move.type;
@@ -269,7 +269,7 @@ module.exports = (function () {
};
Tools.prototype.getEffect = function(effect) {
if (!effect || typeof effect === 'string') {
- var name = (effect||'').trim();
+ var name = (effect || '').trim();
var id = toId(name);
effect = {};
if (id && this.data.Statuses[id]) {
@@ -309,7 +309,7 @@ module.exports = (function () {
};
Tools.prototype.getFormat = function(effect) {
if (!effect || typeof effect === 'string') {
- var name = (effect||'').trim();
+ var name = (effect || '').trim();
var id = toId(name);
if (this.data.Aliases[id]) {
name = this.data.Aliases[id];
@@ -336,7 +336,7 @@ module.exports = (function () {
};
Tools.prototype.getItem = function(item) {
if (!item || typeof item === 'string') {
- var name = (item||'').trim();
+ var name = (item || '').trim();
var id = toId(name);
if (this.data.Aliases[id]) {
name = this.data.Aliases[id];
@@ -351,7 +351,7 @@ module.exports = (function () {
}
if (!item.id) item.id = id;
if (!item.name) item.name = name;
- if (!item.fullname) item.fullname = 'item: '+item.name;
+ if (!item.fullname) item.fullname = 'item: ' + item.name;
item.toString = this.effectToString;
if (!item.category) item.category = 'Effect';
if (!item.effectType) item.effectType = 'Item';
@@ -368,7 +368,7 @@ module.exports = (function () {
};
Tools.prototype.getAbility = function(ability) {
if (!ability || typeof ability === 'string') {
- var name = (ability||'').trim();
+ var name = (ability || '').trim();
var id = toId(name);
ability = {};
if (id && this.data.Abilities[id]) {
@@ -379,7 +379,7 @@ module.exports = (function () {
}
if (!ability.id) ability.id = id;
if (!ability.name) ability.name = name;
- if (!ability.fullname) ability.fullname = 'ability: '+ability.name;
+ if (!ability.fullname) ability.fullname = 'ability: ' + ability.name;
ability.toString = this.effectToString;
if (!ability.category) ability.category = 'Effect';
if (!ability.effectType) ability.effectType = 'Ability';
@@ -396,7 +396,7 @@ module.exports = (function () {
Tools.prototype.getType = function(type) {
if (!type || typeof type === 'string') {
var id = toId(type);
- id = id.substr(0,1).toUpperCase() + id.substr(1);
+ id = id.substr(0, 1).toUpperCase() + id.substr(1);
type = {};
if (id && this.data.TypeChart[id]) {
type = this.data.TypeChart[id];
@@ -457,7 +457,7 @@ module.exports = (function () {
Tools.prototype.getBanlistTable = function(format, subformat, depth) {
var banlistTable;
if (!depth) depth = 0;
- if (depth>8) return; // avoid infinite recursion
+ if (depth > 8) return; // avoid infinite recursion
if (format.banlistTable && !subformat) {
banlistTable = format.banlistTable;
} else {
@@ -468,7 +468,7 @@ module.exports = (function () {
banlistTable = format.banlistTable;
if (!subformat) subformat = format;
if (subformat.banlist) {
- for (var i=0; i 0) {
complexList = subformat.banlist[i].split('++');
- for (var j=0; j l) return Math.abs(m - n);
// Create an array of arrays in javascript (a descending loop is quicker)
@@ -539,10 +539,10 @@ module.exports = (function () {
// Step 4
for (var j = 1; j <= m; j++) {
// Check the jagged ld total so far
- if (i == j && d[i][j] > 4) return n;
+ if (i === j && d[i][j] > 4) return n;
var t_j = t.charAt(j - 1);
- var cost = (s_i == t_j) ? 0 : 1; // Step 5
+ var cost = (s_i === t_j) ? 0 : 1; // Step 5
// Calculate the minimum
var mi = d[i - 1][j] + 1;
@@ -646,7 +646,7 @@ module.exports = (function () {
var buf = '';
- for (var i=0; i> ' || lines.substr(0,4) === '>>> ') {
+ if (lines.substr(0, 3) === '>> ' || lines.substr(0, 4) === '>>> ') {
user.chat(lines, room, connection);
return;
}
@@ -203,7 +203,7 @@ function socketReceive(worker, workerid, socketid, message) {
}
});
}
- for (var i=0; i 1000) return false;
}
@@ -548,23 +548,23 @@ var User = (function () {
this.isStaff = false;
this.isSysop = false;
- for (var i=0; i= 0) {
- this.send('|nametaken|'+"|That name contains a banned word or phrase.");
+ this.send('|nametaken|' + "|That name contains a banned word or phrase.");
return false;
}
}
@@ -622,14 +622,14 @@ var User = (function () {
}
}
if (users[userid] && !users[userid].authenticated && users[userid].connected && !auth) {
- this.send('|nametaken|'+name+"|Someone is already using the name \""+users[userid].name+"\".");
+ this.send('|nametaken|' + name + "|Someone is already using the name \"" + users[userid].name + "\".");
return false;
}
- if (token && token.substr(0,1) !== ';') {
+ if (token && token.substr(0, 1) !== ';') {
var tokenSemicolonPos = token.indexOf(';');
var tokenData = token.substr(0, tokenSemicolonPos);
- var tokenSig = token.substr(tokenSemicolonPos+1);
+ var tokenSig = token.substr(tokenSemicolonPos + 1);
this.renamePending = name;
var self = this;
@@ -637,7 +637,7 @@ var User = (function () {
self.finishRename(success, tokenData, token, auth, challenge);
});
} else {
- this.send('|nametaken|'+name+"|Your authentication token was invalid.");
+ this.send('|nametaken|' + name + "|Your authentication token was invalid.");
}
return false;
@@ -655,8 +655,8 @@ var User = (function () {
expired = true;
} else if ((tokenDataSplit[0] === challenge) && (tokenDataSplit[1] === userid)) {
body = tokenDataSplit[2];
- var expiry = Config.tokenexpiry || 25*60*60;
- if (Math.abs(parseInt(tokenDataSplit[3],10) - Date.now()/1000) > expiry) {
+ var expiry = Config.tokenexpiry || 25 * 60 * 60;
+ if (Math.abs(parseInt(tokenDataSplit[3], 10) - Date.now() / 1000) > expiry) {
expired = true;
}
if (Config.tokenhosts) {
@@ -681,35 +681,35 @@ var User = (function () {
} else {
// a user sent an invalid token
if (tokenDataSplit[0] !== challenge) {
- console.log('verify token challenge mismatch: '+tokenDataSplit[0]+' <=> '+challenge);
+ console.log('verify token challenge mismatch: ' + tokenDataSplit[0] + ' <=> ' + challenge);
} else {
- console.log('verify token mismatch: '+tokenData);
+ console.log('verify token mismatch: ' + tokenData);
}
}
} else {
if (!challenge) {
console.log('verification failed; no challenge');
} else {
- console.log('verify failed: '+token);
+ console.log('verify failed: ' + token);
}
}
if (invalidHost) {
console.log('invalid hostname in token: ' + tokenData);
body = '';
- this.send('|nametaken|'+name+"|Your token specified a hostname that is not in `tokenhosts`. If this is your server, please read the documentation in config/config.js for help. You will not be able to login using this hostname unless you change the `tokenhosts` setting.");
+ this.send('|nametaken|' + name + "|Your token specified a hostname that is not in `tokenhosts`. If this is your server, please read the documentation in config/config.js for help. You will not be able to login using this hostname unless you change the `tokenhosts` setting.");
} else if (expired) {
- console.log('verify failed: '+tokenData);
+ console.log('verify failed: ' + tokenData);
body = '';
- this.send('|nametaken|'+name+"|Your assertion is stale. This usually means that the clock on the server computer is incorrect. If this is your server, please set the clock to the correct time.");
+ this.send('|nametaken|' + name + "|Your assertion is stale. This usually means that the clock on the server computer is incorrect. If this is your server, please set the clock to the correct time.");
} else if (body) {
- //console.log('BODY: "'+body+'"');
+ //console.log('BODY: "' + body + '"');
if (users[userid] && !users[userid].authenticated && users[userid].connected) {
if (auth) {
if (users[userid] !== this) users[userid].resetName();
} else {
- this.send('|nametaken|'+name+"|Someone is already using the name \""+users[userid].name+"\".");
+ this.send('|nametaken|' + name + "|Someone is already using the name \"" + users[userid].name + "\".");
return this;
}
}
@@ -734,7 +734,7 @@ var User = (function () {
}
if (usergroups[userid]) {
- group = usergroups[userid].substr(0,1);
+ group = usergroups[userid].substr(0, 1);
}
if (body === '3') {
@@ -752,7 +752,7 @@ var User = (function () {
return false;
}
for (var i in this.roomCount) {
- Rooms.get(i,'lobby').onLeave(this);
+ Rooms.get(i, 'lobby').onLeave(this);
}
if (!user.authenticated) {
if (Object.isEmpty(Object.select(this.ips, user.ips))) {
@@ -763,8 +763,8 @@ var User = (function () {
this.locked = false;
}
}
- for (var i=0; i 0) {
// should never happen.
- console.log('!! room miscount: '+i+' not left');
- Rooms.get(i,'lobby').onLeave(this);
+ console.log('!! room miscount: ' + i + ' not left');
+ Rooms.get(i, 'lobby').onLeave(this);
}
}
this.roomCount = {};
@@ -925,8 +925,8 @@ var User = (function () {
this.clearChatQueue();
var connection = null;
this.markInactive();
- for (var i=0; i 90*60000) time = 90*60000; // limit 90 minutes
+ if (time > 90 * 60000) time = 90 * 60000; // limit 90 minutes
// recurse only once; the root for-loop already mutes everything with your IP
if (!noRecurse) for (var i in users) {
if (users[i] === this) continue;
@@ -1067,7 +1067,7 @@ var User = (function () {
}
}
if (!connection) {
- for (var i=0; i 0; i++) {
+ for (var i = 0; i < 4 && dotIndex > 0; i++) {
ip = ip.substr(0, dotIndex);
- if (table[ip+'.*']) return table[ip+'.*'];
+ if (table[ip + '.*']) return table[ip + '.*'];
dotIndex = ip.lastIndexOf('.');
}
return false;
@@ -1490,8 +1490,8 @@ exports.usergroups = usergroups;
exports.pruneInactive = User.pruneInactive;
exports.pruneInactiveTimer = setInterval(
User.pruneInactive,
- 1000*60*30,
- Config.inactiveuserthreshold || 1000*60*60
+ 1000 * 60 * 30,
+ Config.inactiveuserthreshold || 1000 * 60 * 60
);
exports.getNextGroupSymbol = function(group, isDown, excludeRooms) {
@@ -1527,7 +1527,7 @@ exports.setOfflineGroup = function(name, group, force) {
var usergroup = usergroups[userid];
if (!usergroup && !force) return false;
name = usergroup ? usergroup.substr(1) : name;
- usergroups[userid] = group+name;
+ usergroups[userid] = group + name;
}
exportUsergroups();
return true;