Style fixes

- Cut down excessive spacing
- Add braces to missing conditionals
This commit is contained in:
Ivo Julca 2015-11-07 17:08:09 -05:00
parent 2c2a3bdf58
commit 90973d5c0c
16 changed files with 50 additions and 46 deletions

2
app.js
View File

@ -163,7 +163,7 @@ global.Tournaments = require('./tournaments');
try {
global.Dnsbl = require('./dnsbl.js');
} catch (e) {
global.Dnsbl = {query:function () {}, reverse: require('dns').reverse};
global.Dnsbl = {query: function () {}, reverse: require('dns').reverse};
}
global.Cidr = require('./cidr.js');

View File

@ -3382,12 +3382,14 @@ Battle = (function () {
Battle.prototype.getDamage = function (pokemon, target, move, suppressMessages) {
if (typeof move === 'string') move = this.getMove(move);
if (typeof move === 'number') move = {
basePower: move,
type: '???',
category: 'Physical',
flags: {}
};
if (typeof move === 'number') {
move = {
basePower: move,
type: '???',
category: 'Physical',
flags: {}
};
}
if (!move.ignoreImmunity || (move.ignoreImmunity !== true && !move.ignoreImmunity[move.type])) {
if (!target.runImmunity(move.type, !suppressMessages)) {

View File

@ -137,7 +137,7 @@ let commands = exports.commands = {
this.errorReply("User " + this.targetUsername + " is offline.");
return;
} else {
this.errorReply("User " + this.targetUsername + " not found. Did you misspell their name?");
this.errorReply("User " + this.targetUsername + " not found. Did you misspell their name?");
return this.parse('/help msg');
}
return;
@ -875,7 +875,7 @@ let commands = exports.commands = {
if (room.bannedUsers[userid] && room.bannedIps[targetUser.latestIp]) return this.sendReply("User " + targetUser.name + " is already banned from room " + room.id + ".");
if (targetUser in room.users) {
targetUser.popup(
"|html|<p>" + Tools.escapeHTML(user.name) + " has banned you from the room " + room.id + ".</p>" + (target ? "<p>Reason: " + Tools.escapeHTML(target) + "</p>" : "") +
"|html|<p>" + Tools.escapeHTML(user.name) + " has banned you from the room " + room.id + ".</p>" + (target ? "<p>Reason: " + Tools.escapeHTML(target) + "</p>" : "") +
"<p>To appeal the ban, PM the staff member that banned you" + (room.auth ? " or a room owner. </p><p><button name=\"send\" value=\"/roomauth " + room.id + "\">List Room Staff</button></p>" : ".</p>")
);
}
@ -1311,7 +1311,7 @@ let commands = exports.commands = {
if (!target) return this.errorReply("Please specify a range to lock.");
if (!this.can('rangeban')) return false;
let isIp = (target.slice(-1) === '*' ? true : false);
let isIp = (target.slice(-1) === '*');
let range = (isIp ? target : Users.shortenHost(target));
if (Users.lockedRanges[range]) return this.errorReply("The range " + range + " has already been temporarily locked.");
@ -2248,7 +2248,7 @@ let commands = exports.commands = {
if (!this.can('joinbattle', null, room)) return;
room.auth[targetUser.userid] = '\u2605';
this.addModCommand("" + name + " was promoted to Player by " + user.name + ".");
this.addModCommand("" + name + " was promoted to Player by " + user.name + ".");
},
addplayerhelp: ["/addplayer [username] - Allow the specified user to join the battle as a player."],

View File

@ -315,7 +315,7 @@ exports.BattleFormats = {
if (name) {
if (name === team[i].species) continue;
if (nameTable[name]) {
return ["Your Pokémon must have different nicknames.", "(You have more than one " + name + ")"];
return ["Your Pokémon must have different nicknames.", "(You have more than one " + name + ")"];
}
nameTable[name] = true;
}

View File

@ -108,4 +108,3 @@ Ladder.prototype.updateRating = function (p1name, p2name, p1score, room) {
}
});
};

View File

@ -262,4 +262,3 @@ Ladder.prototype.updateRating = function (p1name, p2name, p1score, room) {
}
});
};

View File

@ -725,12 +725,14 @@ exports.BattleScripts = {
getDamage: function (pokemon, target, move, suppressMessages) {
// First of all, we get the move.
if (typeof move === 'string') move = this.getMove(move);
if (typeof move === 'number') move = {
basePower: move,
type: '???',
category: 'Physical',
flags: {}
};
if (typeof move === 'number') {
move = {
basePower: move,
type: '???',
category: 'Physical',
flags: {}
};
}
// Let's see if the target is immune to the move.
if (!move.ignoreImmunity || (move.ignoreImmunity !== true && !move.ignoreImmunity[move.type])) {

View File

@ -282,12 +282,14 @@ exports.BattleScripts = {
getDamage: function (pokemon, target, move, suppressMessages) {
// First of all, we get the move.
if (typeof move === 'string') move = this.getMove(move);
if (typeof move === 'number') move = {
basePower: move,
type: '???',
category: 'Physical',
flags: {}
};
if (typeof move === 'number') {
move = {
basePower: move,
type: '???',
category: 'Physical',
flags: {}
};
}
// Let's test for immunities.
if (!move.ignoreImmunity || (move.ignoreImmunity !== true && !move.ignoreImmunity[move.type])) {

View File

@ -18,4 +18,3 @@ exports.BattleFormats = {
}
}
};

View File

@ -406,12 +406,14 @@ exports.BattleScripts = {
getDamage: function (pokemon, target, move, suppressMessages) {
// First of all, we get the move.
if (typeof move === 'string') move = this.getMove(move);
if (typeof move === 'number') move = {
basePower: move,
type: '???',
category: 'Physical',
flags: {}
};
if (typeof move === 'number') {
move = {
basePower: move,
type: '???',
category: 'Physical',
flags: {}
};
}
// Let's see if the target is immune to the move.
if (!move.ignoreImmunity || (move.ignoreImmunity !== true && !move.ignoreImmunity[move.type])) {

View File

@ -263,7 +263,7 @@ let Battle = (function () {
this.active = !this.ended;
for (let i = 0, len = this.players.length; i < len; i++) {
let player = this.players[i];
this['p' + (i + 1)] = player ? player.name : '';
this['p' + (i + 1)] = player ? player.name : '';
if (!player) {
this.active = false;
continue;

View File

@ -12,7 +12,7 @@ describe('Contrary', function () {
this.timeout(0);
battle = BattleEngine.Battle.construct();
battle.join('p1', 'Guest 1', 1, [{species: "Spinda", ability: 'contrary', moves: ['superpower']}]);
battle.join('p2', 'Guest 2', 1, [{species: "Dragonite", ability: 'multiscale', moves: ['dragondance']}]);
battle.join('p2', 'Guest 2', 1, [{species: "Dragonite", ability: 'multiscale', moves: ['dragondance']}]);
battle.commitDecisions();
assert.strictEqual(battle.p1.active[0].boosts['atk'], 1);
assert.strictEqual(battle.p1.active[0].boosts['def'], 1);
@ -29,7 +29,7 @@ describe('Contrary', function () {
it('should invert Belly Drum maximizing Attack', function () {
battle = BattleEngine.Battle.construct();
battle.join('p1', 'Guest 1', 1, [{species: "Spinda", ability: 'contrary', moves: ['bellydrum']}]);
battle.join('p2', 'Guest 2', 1, [{species: "Dragonite", ability: 'multiscale', moves: ['dragondance']}]);
battle.join('p2', 'Guest 2', 1, [{species: "Dragonite", ability: 'multiscale', moves: ['dragondance']}]);
battle.commitDecisions();
assert.strictEqual(battle.p1.active[0].boosts['atk'], -6);
});
@ -37,7 +37,7 @@ describe('Contrary', function () {
it('should be suppressed by Mold Breaker', function () {
battle = BattleEngine.Battle.construct();
battle.join('p1', 'Guest 1', 1, [{species: "Spinda", ability: 'contrary', moves: ['tackle']}]);
battle.join('p2', 'Guest 2', 1, [{species: "Dragonite", ability: 'moldbreaker', moves: ['growl']}]);
battle.join('p2', 'Guest 2', 1, [{species: "Dragonite", ability: 'moldbreaker', moves: ['growl']}]);
battle.commitDecisions();
assert.strictEqual(battle.p1.active[0].boosts['atk'], -1);
});

View File

@ -11,7 +11,7 @@ describe('Intimidate', function () {
it('should decrease Atk by 1 level', function () {
battle = BattleEngine.Battle.construct();
battle.join('p1', 'Guest 1', 1, [{species: "Smeargle", ability: 'owntempo', moves: ['sketch']}]);
battle.join('p2', 'Guest 2', 1, [{species: "Gyarados", ability: 'intimidate', moves: ['splash']}]);
battle.join('p2', 'Guest 2', 1, [{species: "Gyarados", ability: 'intimidate', moves: ['splash']}]);
assert.strictEqual(battle.p1.active[0].boosts['atk'], -1);
});
@ -21,8 +21,8 @@ describe('Intimidate', function () {
{species: "Escavalier", item: 'leftovers', ability: 'shellarmor', moves: ['substitute']}
]);
battle.join('p2', 'Guest 2', 1, [
{species: "Greninja", item: 'laggingtail', ability: 'protean', moves: ['uturn']},
{species: "Gyarados", item: 'leftovers', ability: 'intimidate', moves: ['splash']}
{species: "Greninja", item: 'laggingtail', ability: 'protean', moves: ['uturn']},
{species: "Gyarados", item: 'leftovers', ability: 'intimidate', moves: ['splash']}
]);
battle.commitDecisions();
battle.choose('p2', 'switch 2');
@ -37,9 +37,9 @@ describe('Intimidate', function () {
{species: "Squirtle", item: 'leftovers', ability: 'torrent', moves: ['bubble']}
]);
battle.join('p2', 'Guest 2', 1, [
{species: "Greninja", ability: 'protean', moves: ['uturn']},
{species: "Mew", ability: 'synchronize', moves: ['softboiled']},
{species: "Gyarados", ability: 'intimidate', moves: ['splash']}
{species: "Greninja", ability: 'protean', moves: ['uturn']},
{species: "Mew", ability: 'synchronize', moves: ['softboiled']},
{species: "Gyarados", ability: 'intimidate', moves: ['splash']}
]);
battle.commitDecisions();
assert.strictEqual(battle.p1.active[0].boosts['atk'], -1);

View File

@ -107,7 +107,7 @@ describe('Pickup', function () {
battle.join('p2', 'Guest 2', 1, [
{species: 'Arcanine', ability: 'flashfire', item: 'firegem', moves: ['flamecharge']},
{species: 'Aggron', ability: 'sturdy', moves: ['rest']},
{species: 'Magikarp', ability: 'swiftswim', moves: ['splash']}
{species: 'Magikarp', ability: 'swiftswim', moves: ['splash']}
]);
battle.commitDecisions();
battle.commitDecisions();

View File

@ -10,7 +10,7 @@ describe('Sturdy', function () {
it('should give the user an immunity to OHKO moves', function () {
battle = BattleEngine.Battle.construct();
battle.join('p1', 'Guest 1', 1, [{species: 'Aron', level: 1, ability: 'sturdy', moves: ['sleeptalk']}]);
battle.join('p1', 'Guest 1', 1, [{species: 'Aron', level: 1, ability: 'sturdy', moves: ['sleeptalk']}]);
battle.join('p2', 'Guest 2', 1, [{species: 'Kyogre', ability: 'noguard', moves: ['sheercold']}]);
battle.commitDecisions();
assert.strictEqual(battle.p1.active[0].hp, battle.p1.active[0].maxhp);

View File

@ -30,4 +30,3 @@ describe('Flame Orb', function () {
assert.strictEqual(battle.p1.active[0].status, 'brn');
});
});