mirror of
https://github.com/smogon/pokemon-showdown.git
synced 2026-05-05 21:17:43 -05:00
Fix Travis build
This commit is contained in:
parent
c08aba185b
commit
f18eef39ca
18
app.js
18
app.js
|
|
@ -235,10 +235,13 @@ global.ResourceMonitor = {
|
|||
|
||||
while (stack.length) {
|
||||
var value = stack.pop();
|
||||
if (typeof value === 'boolean') bytes += 4;
|
||||
else if (typeof value === 'string') bytes += value.length * 2;
|
||||
else if (typeof value === 'number') bytes += 8;
|
||||
else if (typeof value === 'object' && objectList.indexOf(value) < 0) {
|
||||
if (typeof value === 'boolean') {
|
||||
bytes += 4;
|
||||
} else if (typeof value === 'string') {
|
||||
bytes += value.length * 2;
|
||||
} else if (typeof value === 'number') {
|
||||
bytes += 8;
|
||||
} else if (typeof value === 'object' && objectList.indexOf(value) < 0) {
|
||||
objectList.push(value);
|
||||
for (var i in value) stack.push(value[i]);
|
||||
}
|
||||
|
|
@ -295,8 +298,11 @@ global.ResourceMonitor = {
|
|||
* Otherwise, an empty string will be returned.
|
||||
*/
|
||||
global.toId = function (text) {
|
||||
if (text && text.id) text = text.id;
|
||||
else if (text && text.userid) text = text.userid;
|
||||
if (text && text.id) {
|
||||
text = text.id;
|
||||
} else if (text && text.userid) {
|
||||
text = text.userid;
|
||||
}
|
||||
|
||||
return string(text).toLowerCase().replace(/[^a-z0-9]+/g, '');
|
||||
};
|
||||
|
|
|
|||
|
|
@ -38,8 +38,11 @@ if (Config.crashguard) {
|
|||
* Otherwise, an empty string will be returned.
|
||||
*/
|
||||
global.toId = function (text) {
|
||||
if (text && text.id) text = text.id;
|
||||
else if (text && text.userid) text = text.userid;
|
||||
if (text && text.id) {
|
||||
text = text.id;
|
||||
} else if (text && text.userid) {
|
||||
text = text.userid;
|
||||
}
|
||||
|
||||
return string(text).toLowerCase().replace(/[^a-z0-9]+/g, '');
|
||||
};
|
||||
|
|
@ -3088,10 +3091,17 @@ Battle = (function () {
|
|||
};
|
||||
Battle.prototype.chain = function (previousMod, nextMod) {
|
||||
// previousMod or nextMod can be either a number or an array [numerator, denominator]
|
||||
if (previousMod.length) previousMod = Math.floor(previousMod[0] * 4096 / previousMod[1]);
|
||||
else previousMod = Math.floor(previousMod * 4096);
|
||||
if (nextMod.length) nextMod = Math.floor(nextMod[0] * 4096 / nextMod[1]);
|
||||
else nextMod = Math.floor(nextMod * 4096);
|
||||
if (previousMod.length) {
|
||||
previousMod = Math.floor(previousMod[0] * 4096 / previousMod[1]);
|
||||
} else {
|
||||
previousMod = Math.floor(previousMod * 4096);
|
||||
}
|
||||
|
||||
if (nextMod.length) {
|
||||
nextMod = Math.floor(nextMod[0] * 4096 / nextMod[1]);
|
||||
} else {
|
||||
nextMod = Math.floor(nextMod * 4096);
|
||||
}
|
||||
return ((previousMod * nextMod + 2048) >> 12) / 4096; // M'' = ((M * M') + 0x800) >> 12
|
||||
};
|
||||
Battle.prototype.chainModify = function (numerator, denominator) {
|
||||
|
|
@ -3233,11 +3243,17 @@ Battle = (function () {
|
|||
defBoosts = 0;
|
||||
}
|
||||
|
||||
if (move.useTargetOffensive) attack = defender.calculateStat(attackStat, atkBoosts);
|
||||
else attack = attacker.calculateStat(attackStat, atkBoosts);
|
||||
if (move.useTargetOffensive) {
|
||||
attack = defender.calculateStat(attackStat, atkBoosts);
|
||||
} else {
|
||||
attack = attacker.calculateStat(attackStat, atkBoosts);
|
||||
}
|
||||
|
||||
if (move.useSourceDefensive) defense = attacker.calculateStat(defenseStat, defBoosts);
|
||||
else defense = defender.calculateStat(defenseStat, defBoosts);
|
||||
if (move.useSourceDefensive) {
|
||||
defense = attacker.calculateStat(defenseStat, defBoosts);
|
||||
} else {
|
||||
defense = defender.calculateStat(defenseStat, defBoosts);
|
||||
}
|
||||
|
||||
// Apply Stat Modifiers
|
||||
attack = this.runEvent('Modify' + statTable[attackStat], attacker, defender, move, attack);
|
||||
|
|
|
|||
|
|
@ -431,30 +431,30 @@ var commands = exports.commands = {
|
|||
numSide = 0;
|
||||
statSide = 1;
|
||||
switch (inequality) {
|
||||
case '>': direction = 'less'; break;
|
||||
case '<': direction = 'greater'; break;
|
||||
case '=': direction = 'equal'; break;
|
||||
case '>': direction = 'less'; break;
|
||||
case '<': direction = 'greater'; break;
|
||||
case '=': direction = 'equal'; break;
|
||||
}
|
||||
} else if (!isNaN(targetParts[1])) {
|
||||
numSide = 1;
|
||||
statSide = 0;
|
||||
switch (inequality) {
|
||||
case '<': direction = 'less'; break;
|
||||
case '>': direction = 'greater'; break;
|
||||
case '=': direction = 'equal'; break;
|
||||
case '<': direction = 'less'; break;
|
||||
case '>': direction = 'greater'; break;
|
||||
case '=': direction = 'equal'; break;
|
||||
}
|
||||
} else {
|
||||
return this.sendReplyBox("No value given to compare with '" + Tools.escapeHTML(target) + "'.");
|
||||
}
|
||||
var stat = targetParts[statSide];
|
||||
switch (toId(targetParts[statSide])) {
|
||||
case 'attack': stat = 'atk'; break;
|
||||
case 'defense': stat = 'def'; break;
|
||||
case 'specialattack': stat = 'spa'; break;
|
||||
case 'spatk': stat = 'spa'; break;
|
||||
case 'specialdefense': stat = 'spd'; break;
|
||||
case 'spdef': stat = 'spd'; break;
|
||||
case 'speed': stat = 'spe'; break;
|
||||
case 'attack': stat = 'atk'; break;
|
||||
case 'defense': stat = 'def'; break;
|
||||
case 'specialattack': stat = 'spa'; break;
|
||||
case 'spatk': stat = 'spa'; break;
|
||||
case 'specialdefense': stat = 'spd'; break;
|
||||
case 'spdef': stat = 'spd'; break;
|
||||
case 'speed': stat = 'spe'; break;
|
||||
}
|
||||
if (!(stat in allStats)) return this.sendReplyBox("'" + Tools.escapeHTML(target) + "' did not contain a valid stat.");
|
||||
if (!searches['stats']) searches['stats'] = {};
|
||||
|
|
@ -491,137 +491,139 @@ var commands = exports.commands = {
|
|||
var search = categories[cat];
|
||||
if (!searches[search]) continue;
|
||||
switch (search) {
|
||||
case 'types':
|
||||
for (var mon in dex) {
|
||||
if (Object.count(searches[search], true) === 2) {
|
||||
if (!(searches[search][dex[mon].types[0]]) || !(searches[search][dex[mon].types[1]])) delete dex[mon];
|
||||
} else {
|
||||
if (searches[search][dex[mon].types[0]] === false || searches[search][dex[mon].types[1]] === false || (Object.count(searches[search], true) > 0 &&
|
||||
(!(searches[search][dex[mon].types[0]]) && !(searches[search][dex[mon].types[1]])))) delete dex[mon];
|
||||
case 'types':
|
||||
for (var mon in dex) {
|
||||
if (Object.count(searches[search], true) === 2) {
|
||||
if (!(searches[search][dex[mon].types[0]]) || !(searches[search][dex[mon].types[1]])) delete dex[mon];
|
||||
} else {
|
||||
if (searches[search][dex[mon].types[0]] === false || searches[search][dex[mon].types[1]] === false || (Object.count(searches[search], true) > 0 &&
|
||||
(!(searches[search][dex[mon].types[0]]) && !(searches[search][dex[mon].types[1]])))) delete dex[mon];
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 'tier':
|
||||
for (var mon in dex) {
|
||||
if ('lc' in searches[search]) {
|
||||
// some LC legal Pokemon are stored in other tiers (Ferroseed/Murkrow etc)
|
||||
// this checks for LC legality using the going criteria, instead of dex[mon].tier
|
||||
var isLC = (dex[mon].evos && dex[mon].evos.length > 0) && !dex[mon].prevo && dex[mon].tier !== "LC Uber" && Tools.data.Formats['lc'].banlist.indexOf(dex[mon].species) < 0;
|
||||
if ((searches[search]['lc'] && !isLC) || (!searches[search]['lc'] && isLC)) {
|
||||
delete dex[mon];
|
||||
continue;
|
||||
}
|
||||
}
|
||||
break;
|
||||
if (searches[search][String(dex[mon][search]).toLowerCase()] === false ||
|
||||
Object.count(searches[search], true) > 0 && !searches[search][String(dex[mon][search]).toLowerCase()]) {
|
||||
delete dex[mon];
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 'tier':
|
||||
case 'gen':
|
||||
case 'color':
|
||||
for (var mon in dex) {
|
||||
if (searches[search][String(dex[mon][search]).toLowerCase()] === false ||
|
||||
Object.count(searches[search], true) > 0 && !searches[search][String(dex[mon][search]).toLowerCase()]) {
|
||||
delete dex[mon];
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 'ability':
|
||||
for (var mon in dex) {
|
||||
for (var ability in searches[search]) {
|
||||
var needsAbility = searches[search][ability];
|
||||
var hasAbility = Object.count(dex[mon].abilities, ability) > 0;
|
||||
if (hasAbility !== needsAbility) {
|
||||
delete dex[mon];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 'compileLearnsets':
|
||||
for (var mon in dex) {
|
||||
var template = dex[mon];
|
||||
if (!template.learnset) template = Tools.getTemplate(template.baseSpecies);
|
||||
if (!template.learnset) continue;
|
||||
var fullLearnset = template.learnset;
|
||||
while (template.prevo) {
|
||||
template = Tools.getTemplate(template.prevo);
|
||||
for (var move in template.learnset) {
|
||||
if (!fullLearnset[move]) fullLearnset[move] = template.learnset[move];
|
||||
}
|
||||
}
|
||||
dex[mon].learnset = fullLearnset;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'moves':
|
||||
for (var mon in dex) {
|
||||
if (!dex[mon].learnset) continue;
|
||||
for (var move in searches[search]) {
|
||||
var canLearn = (dex[mon].learnset.sketch && ['chatter', 'struggle', 'magikarpsrevenge'].indexOf(move) < 0) || dex[mon].learnset[move];
|
||||
if ((!canLearn && searches[search][move]) || (searches[search][move] === false && canLearn)) {
|
||||
delete dex[mon];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 'recovery':
|
||||
for (var mon in dex) {
|
||||
if (!dex[mon].learnset) continue;
|
||||
var recoveryMoves = ["recover", "roost", "moonlight", "morningsun", "synthesis", "milkdrink", "slackoff", "softboiled", "wish", "healorder"];
|
||||
var canLearn = false;
|
||||
for (var i = 0; i < recoveryMoves.length; i++) {
|
||||
canLearn = (dex[mon].learnset.sketch) || dex[mon].learnset[recoveryMoves[i]];
|
||||
if (canLearn) break;
|
||||
}
|
||||
if ((!canLearn && searches[search]) || (searches[search] === false && canLearn)) delete dex[mon];
|
||||
}
|
||||
break;
|
||||
|
||||
case 'priority':
|
||||
var priorityMoves = [];
|
||||
for (var move in Tools.data.Movedex) {
|
||||
var moveData = Tools.getMove(move);
|
||||
if (moveData.category === "Status") continue;
|
||||
if (moveData.priority > 0) priorityMoves.push(move);
|
||||
}
|
||||
for (var mon in dex) {
|
||||
if (!dex[mon].learnset) continue;
|
||||
var canLearn = false;
|
||||
for (var i = 0; i < priorityMoves.length; i++) {
|
||||
canLearn = (dex[mon].learnset.sketch) || dex[mon].learnset[priorityMoves[i]];
|
||||
if (canLearn) break;
|
||||
}
|
||||
if ((!canLearn && searches[search]) || (searches[search] === false && canLearn)) delete dex[mon];
|
||||
}
|
||||
break;
|
||||
|
||||
case 'stats':
|
||||
for (var stat in searches[search]) {
|
||||
for (var mon in dex) {
|
||||
if ('lc' in searches[search]) {
|
||||
// some LC legal Pokemon are stored in other tiers (Ferroseed/Murkrow etc)
|
||||
// this checks for LC legality using the going criteria, instead of dex[mon].tier
|
||||
var isLC = (dex[mon].evos && dex[mon].evos.length > 0) && !dex[mon].prevo && dex[mon].tier !== "LC Uber" && Tools.data.Formats['lc'].banlist.indexOf(dex[mon].species) < 0;
|
||||
if ((searches[search]['lc'] && !isLC) || (!searches[search]['lc'] && isLC)) {
|
||||
if (typeof searches[search][stat].less === 'number') {
|
||||
if (dex[mon].baseStats[stat] > searches[search][stat].less) {
|
||||
delete dex[mon];
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (searches[search][String(dex[mon][search]).toLowerCase()] === false) {
|
||||
delete dex[mon];
|
||||
} else if (Object.count(searches[search], true) > 0 && !searches[search][String(dex[mon][search]).toLowerCase()]) delete dex[mon];
|
||||
}
|
||||
break;
|
||||
|
||||
case 'gen':
|
||||
case 'color':
|
||||
for (var mon in dex) {
|
||||
if (searches[search][String(dex[mon][search]).toLowerCase()] === false) {
|
||||
delete dex[mon];
|
||||
} else if (Object.count(searches[search], true) > 0 && !searches[search][String(dex[mon][search]).toLowerCase()]) delete dex[mon];
|
||||
}
|
||||
break;
|
||||
|
||||
case 'ability':
|
||||
for (var mon in dex) {
|
||||
for (var ability in searches[search]) {
|
||||
var needsAbility = searches[search][ability];
|
||||
var hasAbility = Object.count(dex[mon].abilities, ability) > 0;
|
||||
if (hasAbility !== needsAbility) {
|
||||
if (typeof searches[search][stat].greater === 'number') {
|
||||
if (dex[mon].baseStats[stat] < searches[search][stat].greater) {
|
||||
delete dex[mon];
|
||||
break;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'compileLearnsets':
|
||||
for (var mon in dex) {
|
||||
var template = dex[mon];
|
||||
if (!template.learnset) template = Tools.getTemplate(template.baseSpecies);
|
||||
if (!template.learnset) continue;
|
||||
var fullLearnset = template.learnset;
|
||||
while (template.prevo) {
|
||||
template = Tools.getTemplate(template.prevo);
|
||||
for (var move in template.learnset) {
|
||||
if (!fullLearnset[move]) fullLearnset[move] = template.learnset[move];
|
||||
}
|
||||
}
|
||||
dex[mon].learnset = fullLearnset;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'moves':
|
||||
for (var mon in dex) {
|
||||
if (!dex[mon].learnset) continue;
|
||||
for (var move in searches[search]) {
|
||||
var canLearn = (dex[mon].learnset.sketch && ['chatter', 'struggle', 'magikarpsrevenge'].indexOf(move) < 0) || dex[mon].learnset[move];
|
||||
if ((!canLearn && searches[search][move]) || (searches[search][move] === false && canLearn)) {
|
||||
delete dex[mon];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 'recovery':
|
||||
for (var mon in dex) {
|
||||
if (!dex[mon].learnset) continue;
|
||||
var recoveryMoves = ["recover", "roost", "moonlight", "morningsun", "synthesis", "milkdrink", "slackoff", "softboiled", "wish", "healorder"];
|
||||
var canLearn = false;
|
||||
for (var i = 0; i < recoveryMoves.length; i++) {
|
||||
canLearn = (dex[mon].learnset.sketch) || dex[mon].learnset[recoveryMoves[i]];
|
||||
if (canLearn) break;
|
||||
}
|
||||
if ((!canLearn && searches[search]) || (searches[search] === false && canLearn)) delete dex[mon];
|
||||
}
|
||||
break;
|
||||
|
||||
case 'priority':
|
||||
var priorityMoves = [];
|
||||
for (var move in Tools.data.Movedex) {
|
||||
var moveData = Tools.getMove(move);
|
||||
if (moveData.category === "Status") continue;
|
||||
if (moveData.priority > 0) priorityMoves.push(move);
|
||||
}
|
||||
for (var mon in dex) {
|
||||
if (!dex[mon].learnset) continue;
|
||||
var canLearn = false;
|
||||
for (var i = 0; i < priorityMoves.length; i++) {
|
||||
canLearn = (dex[mon].learnset.sketch) || dex[mon].learnset[priorityMoves[i]];
|
||||
if (canLearn) break;
|
||||
}
|
||||
if ((!canLearn && searches[search]) || (searches[search] === false && canLearn)) delete dex[mon];
|
||||
}
|
||||
break;
|
||||
|
||||
case 'stats':
|
||||
for (var stat in searches[search]) {
|
||||
for (var mon in dex) {
|
||||
if (typeof searches[search][stat].less === 'number') {
|
||||
if (dex[mon].baseStats[stat] > searches[search][stat].less) {
|
||||
delete dex[mon];
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (typeof searches[search][stat].greater === 'number') {
|
||||
if (dex[mon].baseStats[stat] < searches[search][stat].greater) {
|
||||
delete dex[mon];
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
return this.sendReplyBox("Something broke! PM SolarisFox here or on the Smogon forums with the command you tried.");
|
||||
default:
|
||||
return this.sendReplyBox("Something broke! PM SolarisFox here or on the Smogon forums with the command you tried.");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -746,26 +748,26 @@ var commands = exports.commands = {
|
|||
numSide = 0;
|
||||
propSide = 1;
|
||||
switch (inequality) {
|
||||
case '>': direction = 'less'; break;
|
||||
case '<': direction = 'greater'; break;
|
||||
case '=': direction = 'equal'; break;
|
||||
case '>': direction = 'less'; break;
|
||||
case '<': direction = 'greater'; break;
|
||||
case '=': direction = 'equal'; break;
|
||||
}
|
||||
} else if (!isNaN(targetParts[1])) {
|
||||
numSide = 1;
|
||||
propSide = 0;
|
||||
switch (inequality) {
|
||||
case '<': direction = 'less'; break;
|
||||
case '>': direction = 'greater'; break;
|
||||
case '=': direction = 'equal'; break;
|
||||
case '<': direction = 'less'; break;
|
||||
case '>': direction = 'greater'; break;
|
||||
case '=': direction = 'equal'; break;
|
||||
}
|
||||
} else {
|
||||
return this.sendReplyBox("No value given to compare with '" + Tools.escapeHTML(target) + "'.");
|
||||
}
|
||||
var prop = targetParts[propSide];
|
||||
switch (toId(targetParts[propSide])) {
|
||||
case 'basepower': prop = 'basePower'; break;
|
||||
case 'bp': prop = 'basePower'; break;
|
||||
case 'acc': prop = 'accuracy'; break;
|
||||
case 'basepower': prop = 'basePower'; break;
|
||||
case 'bp': prop = 'basePower'; break;
|
||||
case 'acc': prop = 'accuracy'; break;
|
||||
}
|
||||
if (!(prop in allProperties)) return this.sendReplyBox("'" + Tools.escapeHTML(target) + "' did not contain a valid property.");
|
||||
if (!searches['property']) searches['property'] = {};
|
||||
|
|
@ -807,16 +809,16 @@ var commands = exports.commands = {
|
|||
|
||||
if (target.substr(0, 7) === 'boosts ') {
|
||||
switch (target.substr(7)) {
|
||||
case 'attack': target = 'atk'; break;
|
||||
case 'defense': target = 'def'; break;
|
||||
case 'specialattack': target = 'spa'; break;
|
||||
case 'spatk': target = 'spa'; break;
|
||||
case 'specialdefense': target = 'spd'; break;
|
||||
case 'spdef': target = 'spd'; break;
|
||||
case 'speed': target = 'spe'; break;
|
||||
case 'acc': target = 'accuracy'; break;
|
||||
case 'evasiveness': target = 'evasion'; break;
|
||||
default: target = target.substr(7);
|
||||
case 'attack': target = 'atk'; break;
|
||||
case 'defense': target = 'def'; break;
|
||||
case 'specialattack': target = 'spa'; break;
|
||||
case 'spatk': target = 'spa'; break;
|
||||
case 'specialdefense': target = 'spd'; break;
|
||||
case 'spdef': target = 'spd'; break;
|
||||
case 'speed': target = 'spe'; break;
|
||||
case 'acc': target = 'accuracy'; break;
|
||||
case 'evasiveness': target = 'evasion'; break;
|
||||
default: target = target.substr(7);
|
||||
}
|
||||
if (!(target in allBoosts)) return this.sendReplyBox("'" + Tools.escapeHTML(target.substr(7)) + "' is not a recognized stat.");
|
||||
if (!searches['boost']) searches['boost'] = {};
|
||||
|
|
@ -828,15 +830,15 @@ var commands = exports.commands = {
|
|||
var oldTarget = target;
|
||||
if (target.charAt(target.length - 1) === 's') target = target.substr(0, target.length - 1);
|
||||
switch (target) {
|
||||
case 'toxic': target = 'tox'; break;
|
||||
case 'poison': target = 'psn'; break;
|
||||
case 'burn': target = 'brn'; break;
|
||||
case 'paralyze': target = 'par'; break;
|
||||
case 'freeze': target = 'frz'; break;
|
||||
case 'sleep': target = 'slp'; break;
|
||||
case 'confuse': target = 'confusion'; break;
|
||||
case 'trap': target = 'partiallytrapped'; break;
|
||||
case 'flinche': target = 'flinch'; break;
|
||||
case 'toxic': target = 'tox'; break;
|
||||
case 'poison': target = 'psn'; break;
|
||||
case 'burn': target = 'brn'; break;
|
||||
case 'paralyze': target = 'par'; break;
|
||||
case 'freeze': target = 'frz'; break;
|
||||
case 'sleep': target = 'slp'; break;
|
||||
case 'confuse': target = 'confusion'; break;
|
||||
case 'trap': target = 'partiallytrapped'; break;
|
||||
case 'flinche': target = 'flinch'; break;
|
||||
}
|
||||
|
||||
if (target in allStatus) {
|
||||
|
|
@ -872,108 +874,109 @@ var commands = exports.commands = {
|
|||
|
||||
for (var search in searches) {
|
||||
switch (search) {
|
||||
case 'type':
|
||||
case 'category':
|
||||
for (var move in dex) {
|
||||
if (searches[search][String(dex[move][search])] === false) {
|
||||
delete dex[move];
|
||||
} else if (Object.count(searches[search], true) > 0 && !searches[search][String(dex[move][search])]) delete dex[move];
|
||||
case 'type':
|
||||
case 'category':
|
||||
for (var move in dex) {
|
||||
if (searches[search][String(dex[move][search])] === false ||
|
||||
Object.count(searches[search], true) > 0 && !searches[search][String(dex[move][search])]) {
|
||||
delete dex[move];
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'flags':
|
||||
for (var flag in searches[search]) {
|
||||
for (var move in dex) {
|
||||
if (flag !== 'secondary') {
|
||||
if ((!dex[move].flags[flag] && searches[search][flag]) || (dex[move].flags[flag] && !searches[search][flag])) delete dex[move];
|
||||
case 'flags':
|
||||
for (var flag in searches[search]) {
|
||||
for (var move in dex) {
|
||||
if (flag !== 'secondary') {
|
||||
if ((!dex[move].flags[flag] && searches[search][flag]) || (dex[move].flags[flag] && !searches[search][flag])) delete dex[move];
|
||||
} else {
|
||||
if (searches[search][flag]) {
|
||||
if (!dex[move].secondary && !dex[move].secondaries) delete dex[move];
|
||||
} else {
|
||||
if (searches[search][flag]) {
|
||||
if (!dex[move].secondary && !dex[move].secondaries) delete dex[move];
|
||||
} else {
|
||||
if (dex[move].secondary && dex[move].secondaries) delete dex[move];
|
||||
}
|
||||
if (dex[move].secondary && dex[move].secondaries) delete dex[move];
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'recovery':
|
||||
case 'recovery':
|
||||
for (var move in dex) {
|
||||
var hasRecovery = (dex[move].drain || dex[move].flags.heal);
|
||||
if ((!hasRecovery && searches[search]) || (hasRecovery && !searches[search])) delete dex[move];
|
||||
}
|
||||
break;
|
||||
|
||||
case 'property':
|
||||
for (var prop in searches[search]) {
|
||||
for (var move in dex) {
|
||||
var hasRecovery = (dex[move].drain || dex[move].flags.heal);
|
||||
if ((!hasRecovery && searches[search]) || (hasRecovery && !searches[search])) delete dex[move];
|
||||
}
|
||||
break;
|
||||
|
||||
case 'property':
|
||||
for (var prop in searches[search]) {
|
||||
for (var move in dex) {
|
||||
if (typeof searches[search][prop].less === "number") {
|
||||
if (dex[move][prop] === true) {
|
||||
delete dex[move];
|
||||
continue;
|
||||
}
|
||||
if (dex[move][prop] > searches[search][prop].less) {
|
||||
delete dex[move];
|
||||
continue;
|
||||
}
|
||||
if (typeof searches[search][prop].less === "number") {
|
||||
if (dex[move][prop] === true) {
|
||||
delete dex[move];
|
||||
continue;
|
||||
}
|
||||
if (typeof searches[search][prop].greater === "number") {
|
||||
if (dex[move][prop] === true) {
|
||||
if (dex[move].category === "Status") delete dex[move];
|
||||
continue;
|
||||
}
|
||||
if (dex[move][prop] < searches[search][prop].greater) {
|
||||
delete dex[move];
|
||||
continue;
|
||||
}
|
||||
if (dex[move][prop] > searches[search][prop].less) {
|
||||
delete dex[move];
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (typeof searches[search][prop].greater === "number") {
|
||||
if (dex[move][prop] === true) {
|
||||
if (dex[move].category === "Status") delete dex[move];
|
||||
continue;
|
||||
}
|
||||
if (dex[move][prop] < searches[search][prop].greater) {
|
||||
delete dex[move];
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'boost':
|
||||
for (var boost in searches[search]) {
|
||||
for (var move in dex) {
|
||||
if (dex[move].boosts) {
|
||||
if ((dex[move].boosts[boost] > 0 && searches[search][boost]) ||
|
||||
(dex[move].boosts[boost] < 1 && !searches[search][boost])) continue;
|
||||
} else if (dex[move].secondary && dex[move].secondary.self && dex[move].secondary.self.boosts) {
|
||||
if ((dex[move].secondary.self.boosts[boost] > 0 && searches[search][boost]) ||
|
||||
(dex[move].secondary.self.boosts[boost] < 1 && !searches[search][boost])) continue;
|
||||
}
|
||||
delete dex[move];
|
||||
case 'boost':
|
||||
for (var boost in searches[search]) {
|
||||
for (var move in dex) {
|
||||
if (dex[move].boosts) {
|
||||
if ((dex[move].boosts[boost] > 0 && searches[search][boost]) ||
|
||||
(dex[move].boosts[boost] < 1 && !searches[search][boost])) continue;
|
||||
} else if (dex[move].secondary && dex[move].secondary.self && dex[move].secondary.self.boosts) {
|
||||
if ((dex[move].secondary.self.boosts[boost] > 0 && searches[search][boost]) ||
|
||||
(dex[move].secondary.self.boosts[boost] < 1 && !searches[search][boost])) continue;
|
||||
}
|
||||
delete dex[move];
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'status':
|
||||
case 'volatileStatus':
|
||||
for (var searchStatus in searches[search]) {
|
||||
for (var move in dex) {
|
||||
if (dex[move][search] !== searchStatus) {
|
||||
if (!dex[move].secondaries) {
|
||||
if (!dex[move].secondary) {
|
||||
if (searches[search][searchStatus]) delete dex[move];
|
||||
} else {
|
||||
if ((dex[move].secondary[search] !== searchStatus && searches[search][searchStatus]) ||
|
||||
(dex[move].secondary[search] === searchStatus && !searches[search][searchStatus])) delete dex[move];
|
||||
}
|
||||
case 'status':
|
||||
case 'volatileStatus':
|
||||
for (var searchStatus in searches[search]) {
|
||||
for (var move in dex) {
|
||||
if (dex[move][search] !== searchStatus) {
|
||||
if (!dex[move].secondaries) {
|
||||
if (!dex[move].secondary) {
|
||||
if (searches[search][searchStatus]) delete dex[move];
|
||||
} else {
|
||||
var hasSecondary = false;
|
||||
for (var i = 0; i < dex[move].secondaries.length; i++) {
|
||||
if (dex[move].secondaries[i][search] === searchStatus) hasSecondary = true;
|
||||
}
|
||||
if ((!hasSecondary && searches[search][searchStatus]) || (hasSecondary && !searches[search][searchStatus])) delete dex[move];
|
||||
if ((dex[move].secondary[search] !== searchStatus && searches[search][searchStatus]) ||
|
||||
(dex[move].secondary[search] === searchStatus && !searches[search][searchStatus])) delete dex[move];
|
||||
}
|
||||
} else {
|
||||
if (!searches[search][searchStatus]) delete dex[move];
|
||||
var hasSecondary = false;
|
||||
for (var i = 0; i < dex[move].secondaries.length; i++) {
|
||||
if (dex[move].secondaries[i][search] === searchStatus) hasSecondary = true;
|
||||
}
|
||||
if ((!hasSecondary && searches[search][searchStatus]) || (hasSecondary && !searches[search][searchStatus])) delete dex[move];
|
||||
}
|
||||
} else {
|
||||
if (!searches[search][searchStatus]) delete dex[move];
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
return this.sendReplyBox("Something broke! PM SolarisFox here or on the Smogon forums with the command you tried.");
|
||||
default:
|
||||
return this.sendReplyBox("Something broke! PM SolarisFox here or on the Smogon forums with the command you tried.");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1281,22 +1284,22 @@ var commands = exports.commands = {
|
|||
|
||||
for (var type in bestCoverage) {
|
||||
switch (bestCoverage[type]) {
|
||||
case 0:
|
||||
immune.push(type);
|
||||
break;
|
||||
case 0.25:
|
||||
case 0.5:
|
||||
resists.push(type);
|
||||
break;
|
||||
case 1:
|
||||
neutral.push(type);
|
||||
break;
|
||||
case 2:
|
||||
case 4:
|
||||
superEff.push(type);
|
||||
break;
|
||||
default:
|
||||
throw new Error("/coverage effectiveness of " + bestCoverage[type] + " from parameters: " + target);
|
||||
case 0:
|
||||
immune.push(type);
|
||||
break;
|
||||
case 0.25:
|
||||
case 0.5:
|
||||
resists.push(type);
|
||||
break;
|
||||
case 1:
|
||||
neutral.push(type);
|
||||
break;
|
||||
case 2:
|
||||
case 4:
|
||||
superEff.push(type);
|
||||
break;
|
||||
default:
|
||||
throw new Error("/coverage effectiveness of " + bestCoverage[type] + " from parameters: " + target);
|
||||
}
|
||||
}
|
||||
buffer.push('Coverage for ' + sources.join(' + ') + ':');
|
||||
|
|
@ -1348,22 +1351,22 @@ var commands = exports.commands = {
|
|||
}
|
||||
}
|
||||
switch (bestEff) {
|
||||
case 0:
|
||||
cell += 'bgcolor=#666666 title="' + typing + '"><font color=#000000>' + bestEff + '</font>';
|
||||
break;
|
||||
case 0.25:
|
||||
case 0.5:
|
||||
cell += 'bgcolor=#AA5544 title="' + typing + '"><font color=#660000>' + bestEff + '</font>';
|
||||
break;
|
||||
case 1:
|
||||
cell += 'bgcolor=#6688AA title="' + typing + '"><font color=#000066>' + bestEff + '</font>';
|
||||
break;
|
||||
case 2:
|
||||
case 4:
|
||||
cell += 'bgcolor=#559955 title="' + typing + '"><font color=#003300>' + bestEff + '</font>';
|
||||
break;
|
||||
default:
|
||||
throw new Error("/coverage effectiveness of " + bestEff + " from parameters: " + target);
|
||||
case 0:
|
||||
cell += 'bgcolor=#666666 title="' + typing + '"><font color=#000000>' + bestEff + '</font>';
|
||||
break;
|
||||
case 0.25:
|
||||
case 0.5:
|
||||
cell += 'bgcolor=#AA5544 title="' + typing + '"><font color=#660000>' + bestEff + '</font>';
|
||||
break;
|
||||
case 1:
|
||||
cell += 'bgcolor=#6688AA title="' + typing + '"><font color=#000066>' + bestEff + '</font>';
|
||||
break;
|
||||
case 2:
|
||||
case 4:
|
||||
cell += 'bgcolor=#559955 title="' + typing + '"><font color=#003300>' + bestEff + '</font>';
|
||||
break;
|
||||
default:
|
||||
throw new Error("/coverage effectiveness of " + bestEff + " from parameters: " + target);
|
||||
}
|
||||
cell += '</th>';
|
||||
buffer += cell;
|
||||
|
|
|
|||
|
|
@ -57,10 +57,8 @@ var JeopardyQuestions = (function () {
|
|||
var q1 = start;
|
||||
var q2 = 0;
|
||||
for (; q1 < end && typeof data[q2] === 'object'; ++q1, ++q2) {
|
||||
if (typeof data[q2].value === 'string')
|
||||
this.grid[category][q1].value = data[q2].value;
|
||||
if (typeof data[q2].answer === 'string')
|
||||
this.grid[category][q1].answer = data[q2].answer;
|
||||
if (typeof data[q2].value === 'string') this.grid[category][q1].value = data[q2].value;
|
||||
if (typeof data[q2].answer === 'string') this.grid[category][q1].answer = data[q2].answer;
|
||||
this.grid[category][q1].isDailyDouble = !!data[q2].isDailyDouble;
|
||||
}
|
||||
return q1 - start;
|
||||
|
|
@ -134,30 +132,29 @@ var Jeopardy = (function () {
|
|||
var currentCheck = '';
|
||||
while (!!(currentCheck = checks.pop())) {
|
||||
switch (currentCheck) {
|
||||
case 'started':
|
||||
if (this.isStarted) break;
|
||||
output.sendReply("The Jeopardy match has not started yet.");
|
||||
return false;
|
||||
case 'started':
|
||||
if (this.isStarted) break;
|
||||
output.sendReply("The Jeopardy match has not started yet.");
|
||||
return false;
|
||||
|
||||
case 'notstarted':
|
||||
if (!this.isStarted) break;
|
||||
output.sendReply("The Jeopardy match has already started.");
|
||||
return false;
|
||||
case 'notstarted':
|
||||
if (!this.isStarted) break;
|
||||
output.sendReply("The Jeopardy match has already started.");
|
||||
return false;
|
||||
|
||||
case 'host':
|
||||
if (user === this.host) break;
|
||||
output.sendReply("You are not the host.");
|
||||
return false;
|
||||
case 'host':
|
||||
if (user === this.host) break;
|
||||
output.sendReply("You are not the host.");
|
||||
return false;
|
||||
|
||||
case 'user':
|
||||
if (this.users.has(user)) break;
|
||||
output.sendReply("You are not in the match.");
|
||||
return false;
|
||||
|
||||
default:
|
||||
output.sendReply("Unknown check '" + currentCheck + "'.");
|
||||
return false;
|
||||
case 'user':
|
||||
if (this.users.has(user)) break;
|
||||
output.sendReply("You are not in the match.");
|
||||
return false;
|
||||
|
||||
default:
|
||||
output.sendReply("Unknown check '" + currentCheck + "'.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -587,21 +584,21 @@ var commands = {
|
|||
|
||||
var value = params.slice(3).join(',').trim();
|
||||
switch (editType) {
|
||||
case 'question':
|
||||
questions.setQuestion(categoryNumber, questionNumber, value);
|
||||
this.sendReply("The question has been updated.");
|
||||
break;
|
||||
case 'question':
|
||||
questions.setQuestion(categoryNumber, questionNumber, value);
|
||||
this.sendReply("The question has been updated.");
|
||||
break;
|
||||
|
||||
case 'answer':
|
||||
questions.setAnswer(categoryNumber, questionNumber, value);
|
||||
this.sendReply("The answer has been updated.");
|
||||
break;
|
||||
case 'answer':
|
||||
questions.setAnswer(categoryNumber, questionNumber, value);
|
||||
this.sendReply("The answer has been updated.");
|
||||
break;
|
||||
|
||||
case 'dailydouble':
|
||||
var isSet = toId(value) === 'true';
|
||||
questions.setDailyDouble(categoryNumber, questionNumber, isSet);
|
||||
this.sendReply("The daily double has been " + (isSet ? "set." : "unset."));
|
||||
break;
|
||||
case 'dailydouble':
|
||||
var isSet = toId(value) === 'true';
|
||||
questions.setDailyDouble(categoryNumber, questionNumber, isSet);
|
||||
this.sendReply("The daily double has been " + (isSet ? "set." : "unset."));
|
||||
break;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
|||
|
|
@ -231,16 +231,16 @@ var Trivia = (function () {
|
|||
this.room.update();
|
||||
|
||||
switch (this.mode) {
|
||||
case 'first':
|
||||
this.phaseTimeout = setTimeout(this.noAnswer.bind(this), QUESTION_PERIOD);
|
||||
break;
|
||||
case 'timer':
|
||||
this.askedAt = Date.now();
|
||||
this.phaseTimeout = setTimeout(this.timerAnswers.bind(this), QUESTION_PERIOD);
|
||||
break;
|
||||
case 'number':
|
||||
this.phaseTimeout = setTimeout(this.numberAnswers.bind(this), QUESTION_PERIOD);
|
||||
break;
|
||||
case 'first':
|
||||
this.phaseTimeout = setTimeout(this.noAnswer.bind(this), QUESTION_PERIOD);
|
||||
break;
|
||||
case 'timer':
|
||||
this.askedAt = Date.now();
|
||||
this.phaseTimeout = setTimeout(this.timerAnswers.bind(this), QUESTION_PERIOD);
|
||||
break;
|
||||
case 'number':
|
||||
this.phaseTimeout = setTimeout(this.numberAnswers.bind(this), QUESTION_PERIOD);
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
13
commands.js
13
commands.js
|
|
@ -297,9 +297,7 @@ var commands = exports.commands = {
|
|||
default:
|
||||
if (!this.can('privateroom', null, room)) return;
|
||||
if (room.isPrivate === true) {
|
||||
if (this.can('makeroom'))
|
||||
this.sendReply("This room is a secret room. Use /privateroom to toggle instead.");
|
||||
return;
|
||||
return this.sendReply("This room is a secret room. Use /privateroom to toggle instead.");
|
||||
}
|
||||
setting = 'hidden';
|
||||
break;
|
||||
|
|
@ -1981,12 +1979,13 @@ var commands = exports.commands = {
|
|||
this.logModCommand(user.name + " forced a tie.");
|
||||
return false;
|
||||
}
|
||||
target = Users.get(target);
|
||||
if (target) target = target.userid;
|
||||
else target = '';
|
||||
var targetUser = Users.getExact(target);
|
||||
if (!targetUser) return this.sendReply("User '" + target + "' not found.");
|
||||
|
||||
target = targetUser ? targetUser.userid : '';
|
||||
|
||||
if (target) {
|
||||
room.battle.win(target);
|
||||
room.battle.win(targetUser);
|
||||
this.logModCommand(user.name + " forced a win for " + target + ".");
|
||||
}
|
||||
},
|
||||
|
|
|
|||
|
|
@ -10788,10 +10788,9 @@ exports.BattleMovedex = {
|
|||
priority: 0,
|
||||
flags: {snatch: 1},
|
||||
onHit: function (pokemon) {
|
||||
if (!pokemon.item && pokemon.lastItem) {
|
||||
pokemon.setItem(pokemon.lastItem);
|
||||
this.add("-item", pokemon, pokemon.getItem(), '[from] move: Recycle');
|
||||
} else return false;
|
||||
if (pokemon.item || !pokemon.lastItem) return false;
|
||||
pokemon.setItem(pokemon.lastItem);
|
||||
this.add('-item', pokemon, pokemon.getItem(), '[from] move: Recycle');
|
||||
},
|
||||
secondary: false,
|
||||
target: "self",
|
||||
|
|
|
|||
|
|
@ -757,8 +757,7 @@ exports.BattleScripts = {
|
|||
mbst += Math.floor((stats["spd"] * 2 + 31 + 21 + 100) * level / 100 + 5);
|
||||
mbst += Math.floor((stats["spe"] * 2 + 31 + 21 + 100) * level / 100 + 5);
|
||||
|
||||
if (mbst >= mbstmin)
|
||||
break;
|
||||
if (mbst >= mbstmin) break;
|
||||
level++;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -986,8 +986,7 @@ exports.BattleScripts = {
|
|||
mbst += Math.floor((stats["spd"] * 2 + 30 + 63 + 100) * level / 100 + 5);
|
||||
mbst += Math.floor((stats["spe"] * 2 + 30 + 63 + 100) * level / 100 + 5);
|
||||
|
||||
if (mbst >= mbstmin)
|
||||
break;
|
||||
if (mbst >= mbstmin) break;
|
||||
level++;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -14,9 +14,13 @@ exports.BattleAbilities = {
|
|||
onAfterDamage: function (damage, target, source, move) {
|
||||
if (move && move.flags['contact'] && !source.status) {
|
||||
var r = this.random(300);
|
||||
if (r < 10) source.setStatus('slp');
|
||||
else if (r < 20) source.setStatus('par');
|
||||
else if (r < 30) source.setStatus('psn');
|
||||
if (r < 10) {
|
||||
source.setStatus('slp');
|
||||
} else if (r < 20) {
|
||||
source.setStatus('par');
|
||||
} else if (r < 30) {
|
||||
source.setStatus('psn');
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
|||
|
|
@ -210,11 +210,17 @@ exports.BattleScripts = {
|
|||
var ignoreNegativeOffensive = !!move.ignoreNegativeOffensive;
|
||||
var ignorePositiveDefensive = !!move.ignorePositiveDefensive;
|
||||
|
||||
if (move.useTargetOffensive) attack = defender.calculateStat(attackStat, atkBoosts);
|
||||
else attack = attacker.calculateStat(attackStat, atkBoosts);
|
||||
if (move.useTargetOffensive) {
|
||||
attack = defender.calculateStat(attackStat, atkBoosts);
|
||||
} else {
|
||||
attack = attacker.calculateStat(attackStat, atkBoosts);
|
||||
}
|
||||
|
||||
if (move.useSourceDefensive) defense = attacker.calculateStat(defenseStat, defBoosts);
|
||||
else defense = defender.calculateStat(defenseStat, defBoosts);
|
||||
if (move.useSourceDefensive) {
|
||||
defense = attacker.calculateStat(defenseStat, defBoosts);
|
||||
} else {
|
||||
defense = defender.calculateStat(defenseStat, defBoosts);
|
||||
}
|
||||
|
||||
// Apply Stat Modifiers
|
||||
attack = this.runEvent('Modify' + statTable[attackStat], attacker, defender, move, attack);
|
||||
|
|
|
|||
14
rooms.js
14
rooms.js
|
|
@ -332,8 +332,11 @@ var GlobalRoom = (function () {
|
|||
formatListText += '|,' + (format.column || 1) + '|' + section;
|
||||
}
|
||||
formatListText += '|' + format.name;
|
||||
if (!format.challengeShow) formatListText += ',,';
|
||||
else if (!format.searchShow) formatListText += ',';
|
||||
if (!format.challengeShow) {
|
||||
formatListText += ',,';
|
||||
} else if (!format.searchShow) {
|
||||
formatListText += ',';
|
||||
}
|
||||
if (format.team) formatListText += ',#';
|
||||
}
|
||||
return formatListText;
|
||||
|
|
@ -1019,8 +1022,11 @@ var BattleRoom = (function () {
|
|||
}
|
||||
|
||||
if (inactiveSide < 0) {
|
||||
if (ticksLeft[0]) inactiveSide = 1;
|
||||
else if (ticksLeft[1]) inactiveSide = 0;
|
||||
if (ticksLeft[0]) {
|
||||
inactiveSide = 1;
|
||||
} else if (ticksLeft[1]) {
|
||||
inactiveSide = 0;
|
||||
}
|
||||
}
|
||||
|
||||
this.forfeit(this.battle.getPlayer(inactiveSide), ' lost due to inactivity.', inactiveSide);
|
||||
|
|
|
|||
|
|
@ -118,8 +118,11 @@ if (!process.send) {
|
|||
* Otherwise, an empty string will be returned.
|
||||
*/
|
||||
global.toId = function (text) {
|
||||
if (text && text.id) text = text.id;
|
||||
else if (text && text.userid) text = text.userid;
|
||||
if (text && text.id) {
|
||||
text = text.id;
|
||||
} else if (text && text.userid) {
|
||||
text = text.userid;
|
||||
}
|
||||
|
||||
return string(text).toLowerCase().replace(/[^a-z0-9]+/g, '');
|
||||
};
|
||||
|
|
@ -211,17 +214,17 @@ Validator = (function () {
|
|||
return ["Your team has more than 6 pokemon."];
|
||||
}
|
||||
switch (format.gameType) {
|
||||
case 'doubles':
|
||||
if (team.length < 2) return ["Your Doubles team needs at least 2 pokemon."];
|
||||
break;
|
||||
case 'triples':
|
||||
if (team.length < 3) return ["Your Triples team needs at least 3 pokemon."];
|
||||
break;
|
||||
case 'rotation':
|
||||
if (team.length < 3) return ["Your Rotation team needs at least 3 pokemon."];
|
||||
break;
|
||||
default:
|
||||
if (team.length < 1) return ["Your team has no pokemon."];
|
||||
case 'doubles':
|
||||
if (team.length < 2) return ["Your Doubles team needs at least 2 pokemon."];
|
||||
break;
|
||||
case 'triples':
|
||||
if (team.length < 3) return ["Your Triples team needs at least 3 pokemon."];
|
||||
break;
|
||||
case 'rotation':
|
||||
if (team.length < 3) return ["Your Rotation team needs at least 3 pokemon."];
|
||||
break;
|
||||
default:
|
||||
if (team.length < 1) return ["Your team has no pokemon."];
|
||||
}
|
||||
var teamHas = {};
|
||||
for (var i = 0; i < team.length; i++) {
|
||||
|
|
|
|||
85
tools.js
85
tools.js
|
|
@ -214,11 +214,11 @@ module.exports = (function () {
|
|||
var typeData = this.data.TypeChart[targetTyping];
|
||||
if (!typeData) return 0;
|
||||
switch (typeData.damageTaken[sourceType]) {
|
||||
case 1: return 1; // super-effective
|
||||
case 2: return -1; // resist
|
||||
// in case of weird situations like Gravity, immunity is
|
||||
// handled elsewhere
|
||||
default: return 0;
|
||||
case 1: return 1; // super-effective
|
||||
case 2: return -1; // resist
|
||||
// in case of weird situations like Gravity, immunity is
|
||||
// handled elsewhere
|
||||
default: return 0;
|
||||
}
|
||||
};
|
||||
Tools.prototype.getTemplate = function (template) {
|
||||
|
|
@ -268,13 +268,21 @@ module.exports = (function () {
|
|||
} else if (template.forme === 'Primal') {
|
||||
template.gen = 6;
|
||||
template.isPrimal = true;
|
||||
} else if (template.num >= 650) template.gen = 6;
|
||||
else if (template.num >= 494) template.gen = 5;
|
||||
else if (template.num >= 387) template.gen = 4;
|
||||
else if (template.num >= 252) template.gen = 3;
|
||||
else if (template.num >= 152) template.gen = 2;
|
||||
else if (template.num >= 1) template.gen = 1;
|
||||
else template.gen = 0;
|
||||
} else if (template.num >= 650) {
|
||||
template.gen = 6;
|
||||
} else if (template.num >= 494) {
|
||||
template.gen = 5;
|
||||
} else if (template.num >= 387) {
|
||||
template.gen = 4;
|
||||
} else if (template.num >= 252) {
|
||||
template.gen = 3;
|
||||
} else if (template.num >= 152) {
|
||||
template.gen = 2;
|
||||
} else if (template.num >= 1) {
|
||||
template.gen = 1;
|
||||
} else {
|
||||
template.gen = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
return template;
|
||||
|
|
@ -307,13 +315,21 @@ module.exports = (function () {
|
|||
if (!move.effectType) move.effectType = 'Move';
|
||||
if (!move.secondaries && move.secondary) move.secondaries = [move.secondary];
|
||||
if (!move.gen) {
|
||||
if (move.num >= 560) move.gen = 6;
|
||||
else if (move.num >= 468) move.gen = 5;
|
||||
else if (move.num >= 355) move.gen = 4;
|
||||
else if (move.num >= 252) move.gen = 3;
|
||||
else if (move.num >= 166) move.gen = 2;
|
||||
else if (move.num >= 1) move.gen = 1;
|
||||
else move.gen = 0;
|
||||
if (move.num >= 560) {
|
||||
move.gen = 6;
|
||||
} else if (move.num >= 468) {
|
||||
move.gen = 5;
|
||||
} else if (move.num >= 355) {
|
||||
move.gen = 4;
|
||||
} else if (move.num >= 252) {
|
||||
move.gen = 3;
|
||||
} else if (move.num >= 166) {
|
||||
move.gen = 2;
|
||||
} else if (move.num >= 1) {
|
||||
move.gen = 1;
|
||||
} else {
|
||||
move.gen = 0;
|
||||
}
|
||||
}
|
||||
if (!move.priority) move.priority = 0;
|
||||
if (move.ignoreImmunity === undefined) move.ignoreImmunity = (move.category === 'Status');
|
||||
|
|
@ -432,11 +448,16 @@ module.exports = (function () {
|
|||
if (item.onDrive) item.fling = {basePower: 70};
|
||||
if (item.megaStone) item.fling = {basePower: 80};
|
||||
if (!item.gen) {
|
||||
if (item.num >= 577) item.gen = 6;
|
||||
else if (item.num >= 537) item.gen = 5;
|
||||
else if (item.num >= 377) item.gen = 4;
|
||||
// Due to difference in storing items, gen 2 items must be specified specifically
|
||||
else item.gen = 3;
|
||||
if (item.num >= 577) {
|
||||
item.gen = 6;
|
||||
} else if (item.num >= 537) {
|
||||
item.gen = 5;
|
||||
} else if (item.num >= 377) {
|
||||
item.gen = 4;
|
||||
} else {
|
||||
item.gen = 3;
|
||||
}
|
||||
// Due to difference in storing items, gen 2 items must be specified manually
|
||||
}
|
||||
}
|
||||
return item;
|
||||
|
|
@ -459,11 +480,17 @@ module.exports = (function () {
|
|||
if (!ability.category) ability.category = 'Effect';
|
||||
if (!ability.effectType) ability.effectType = 'Ability';
|
||||
if (!ability.gen) {
|
||||
if (ability.num >= 165) ability.gen = 6;
|
||||
else if (ability.num >= 124) ability.gen = 5;
|
||||
else if (ability.num >= 77) ability.gen = 4;
|
||||
else if (ability.num >= 1) ability.gen = 3;
|
||||
else ability.gen = 0;
|
||||
if (ability.num >= 165) {
|
||||
ability.gen = 6;
|
||||
} else if (ability.num >= 124) {
|
||||
ability.gen = 5;
|
||||
} else if (ability.num >= 77) {
|
||||
ability.gen = 4;
|
||||
} else if (ability.num >= 1) {
|
||||
ability.gen = 3;
|
||||
} else {
|
||||
ability.gen = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
return ability;
|
||||
|
|
|
|||
|
|
@ -419,10 +419,11 @@ var Elimination = (function () {
|
|||
match.onLoseNode.getParent().getValue().state = 'available';
|
||||
|
||||
var error = '';
|
||||
if (this.users.get(userA).isDisqualified)
|
||||
if (this.users.get(userA).isDisqualified) {
|
||||
error = this.setMatchResult([userA, userB], 'loss');
|
||||
else if (this.users.get(userB).isDisqualified)
|
||||
} else if (this.users.get(userB).isDisqualified) {
|
||||
error = this.setMatchResult([userA, userB], 'win');
|
||||
}
|
||||
|
||||
if (error) {
|
||||
throw new Error("Unexpected " + error + " from setMatchResult([" + userA + ", " + userB + "], ...)");
|
||||
|
|
|
|||
14
users.js
14
users.js
|
|
@ -990,8 +990,11 @@ User = (function () {
|
|||
this.connections = [];
|
||||
// merge IPs
|
||||
for (var ip in this.ips) {
|
||||
if (user.ips[ip]) user.ips[ip] += this.ips[ip];
|
||||
else user.ips[ip] = this.ips[ip];
|
||||
if (user.ips[ip]) {
|
||||
user.ips[ip] += this.ips[ip];
|
||||
} else {
|
||||
user.ips[ip] = this.ips[ip];
|
||||
}
|
||||
}
|
||||
this.ips = {};
|
||||
user.latestIp = this.latestIp;
|
||||
|
|
@ -1071,8 +1074,11 @@ User = (function () {
|
|||
str += ' socket' + i + '[';
|
||||
var first = true;
|
||||
for (var j in connection.rooms) {
|
||||
if (first) first = false;
|
||||
else str += ', ';
|
||||
if (first) {
|
||||
first = false;
|
||||
} else {
|
||||
str += ', ';
|
||||
}
|
||||
str += j;
|
||||
}
|
||||
str += ']';
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user