From ae6da14ca095dce382ecaa2e38fc409e15533c9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E5=A4=AA?= Date: Sun, 12 Oct 2014 21:32:44 -0500 Subject: [PATCH] Misc cleanup The important fixes from pull request #865 --- battle-engine.js | 22 ++++++---------------- command-parser.js | 4 ---- 2 files changed, 6 insertions(+), 20 deletions(-) diff --git a/battle-engine.js b/battle-engine.js index f70ea1ee79..85bb8e504e 100644 --- a/battle-engine.js +++ b/battle-engine.js @@ -389,7 +389,6 @@ BattlePokemon = (function () { }; BattlePokemon.prototype.calculateStat = function (statName, boost, modifier) { statName = toId(statName); - // var boost = this.boosts[statName]; if (statName === 'hp') return this.maxhp; // please just read .maxhp directly @@ -712,16 +711,9 @@ BattlePokemon = (function () { evasion: 0 }; - this.moveset = []; - this.moves = []; - // we're copying array contents - // DO NOT "optimize" it to copy just the pointer - // if you don't know what a pointer is, please don't - // touch this code - for (var i = 0; i < this.baseMoveset.length; i++) { - this.moveset.push(this.baseMoveset[i]); - this.moves.push(toId(this.baseMoveset[i].move)); - } + this.moveset = this.baseMoveset.slice(); + this.moves = this.moveset.map('move'); + this.transformed = false; this.ability = this.baseAbility; this.set.ivs = this.baseIvs; @@ -760,12 +752,14 @@ BattlePokemon = (function () { }; // returns the amount of damage actually dealt BattlePokemon.prototype.faint = function (source, effect) { + // This function only puts the pokemon in the faint queue; + // actually setting of this.fainted comes later when the + // faint queue is resolved. if (this.fainted || this.status === 'fnt') return 0; var d = this.hp; this.hp = 0; this.switchFlag = false; this.status = 'fnt'; - // this.fainted = true; this.battle.faintQueue.push({ target: this, source: source, @@ -2927,9 +2921,6 @@ Battle = (function () { // randomizer // this is not a modifier - // gen 1-2 - //var randFactor = Math.floor(Math.random() * 39) + 217; - //baseDamage *= Math.floor(randFactor * 100 / 255) / 100; baseDamage = Math.floor(baseDamage * (100 - this.random(16)) / 100); // STAB @@ -3366,7 +3357,6 @@ Battle = (function () { break; } this.switchIn(decision.target, decision.pokemon.position); - //decision.target.runSwitchIn(); break; case 'runSwitch': decision.pokemon.isStarted = true; diff --git a/command-parser.js b/command-parser.js index 9f133b3233..d6489329f9 100644 --- a/command-parser.js +++ b/command-parser.js @@ -163,10 +163,6 @@ var parse = exports.parse = function (message, room, user, connection, levelsDee 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 && (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'); - } } else { if (levelsDeep > MAX_PARSE_RECURSION) { return connection.sendTo(room, "Error: Too much recursion");