From 544c949a9acb210da6977584b6f3d896bbde7a8f Mon Sep 17 00:00:00 2001 From: big bad waffle Date: Fri, 27 Jul 2018 14:56:45 +0200 Subject: [PATCH] more work --- src/server/components/aggro.js | 44 ++++----- src/server/components/auth.js | 56 ++++++------ src/server/components/chatter.js | 6 +- src/server/components/chest.js | 10 +-- src/server/components/components.js | 6 +- src/server/components/dialogue.js | 14 +-- src/server/components/door.js | 14 +-- src/server/components/effects.js | 16 ++-- src/server/components/equipment.js | 30 +++---- src/server/components/events.js | 4 +- .../components/extensions/factionVendor.js | 12 +-- .../components/extensions/socialCommands.js | 44 ++++----- src/server/components/follower.js | 3 +- src/server/components/gatherer.js | 34 +++---- src/server/components/inventory.js | 90 +++++++++---------- src/server/components/mob.js | 16 ++-- src/server/components/notice.js | 4 +- src/server/components/passives.js | 20 ++--- src/server/components/player.js | 28 +++--- src/server/components/prophecies.js | 14 +-- src/server/components/quests.js | 8 +- src/server/components/reputation.js | 24 ++--- src/server/components/social.js | 50 +++++------ src/server/components/spellbook.js | 54 +++++------ src/server/components/stash.js | 10 +-- src/server/components/stats.js | 41 +++++---- src/server/components/syncer.js | 18 ++-- src/server/components/trade.js | 56 ++++++------ src/server/components/wardrobe.js | 6 +- src/server/config/effects/effectTemplate.js | 2 +- .../config/eventPhases/phaseEventChain.js | 8 +- src/server/config/eventPhases/phaseKillMob.js | 6 +- .../config/eventPhases/phaseLocateMob.js | 4 +- .../config/eventPhases/phaseModifyDialogue.js | 6 +- .../config/eventPhases/phaseSpawnMob.js | 2 +- src/server/config/factions/akarei.js | 4 +- src/server/config/factions/anglers.js | 4 +- src/server/config/factions/gaekatla.js | 4 +- src/server/config/itemEffects/alwaysCrit.js | 4 +- src/server/config/itemEffects/damageSelf.js | 4 +- src/server/config/itemEffects/freezeOnHit.js | 4 +- src/server/config/itemEffects/healOnCrit.js | 4 +- src/server/config/loginRewards.js | 2 +- src/server/config/maps/cave/dialogues.js | 4 +- src/server/config/maps/cave/zone.js | 6 +- src/server/config/maps/fjolarok/dialogues.js | 4 +- .../maps/fjolarok/events/fishingTournament.js | 18 ++-- src/server/config/prophecies/titangrip.js | 4 +- src/server/config/quests/questBuilder.js | 6 +- .../quests/templates/questGatherResource.js | 14 +-- .../config/quests/templates/questKillX.js | 12 +-- .../config/quests/templates/questLoot.js | 18 ++-- .../config/quests/templates/questLootGen.js | 14 +-- .../config/quests/templates/questTemplate.js | 2 +- src/server/config/roles.js | 8 +- src/server/config/skins.js | 2 +- .../config/spells/spellArcaneBarrier.js | 4 +- src/server/config/spells/spellAura.js | 4 +- src/server/config/spells/spellCallbacks.js | 2 +- src/server/config/spells/spellCharge.js | 4 +- src/server/config/spells/spellFireblast.js | 4 +- .../config/spells/spellHealingCircle.js | 4 +- src/server/config/spells/spellSlowBlast.js | 2 +- src/server/config/spells/spellSmokeBomb.js | 4 +- .../spells/spellSummonConsumableFollower.js | 2 +- src/server/config/spells/spellTemplate.js | 16 ++-- src/server/config/spells/spellTrailDash.js | 6 +- src/server/config/spells/spellWarnBlast.js | 2 +- src/server/events/events.js | 20 ++--- src/server/fixes/fixes.js | 10 +-- src/server/index.js | 2 - src/server/items/config/currencies.js | 2 +- src/server/items/config/slots.js | 2 +- src/server/items/enchanter.js | 35 ++++---- src/server/items/generator.js | 4 +- src/server/items/generators/effects.js | 2 +- src/server/items/generators/names.js | 6 +- src/server/items/generators/quality.js | 4 +- src/server/items/generators/spellbook.js | 14 +-- src/server/items/generators/stats.js | 38 ++++---- src/server/items/salvager.js | 4 +- src/server/leaderboard/leaderboard.js | 14 +-- src/server/misc/events.js | 6 +- src/server/misc/helpers.js | 2 +- src/server/misc/mail.js | 12 +-- src/server/misc/pathfinder.js | 4 +- src/server/misc/random.js | 4 +- src/server/misc/scheduler.js | 14 +-- src/server/mods/class-necromancer/index.js | 8 +- src/server/mods/event-halloween/index.js | 12 +-- .../maps/fjolarok/events/halloween.js | 2 +- .../event-halloween/mtx/hauntedIceSpear.js | 4 +- .../spells/spellScatterPumpkinPieces.js | 4 +- src/server/mods/event-xmas/index.js | 18 ++-- .../event-xmas/maps/fjolarok/events/xmas.js | 12 +-- src/server/mods/feature-cards/cards.js | 14 ++- src/server/mods/feature-cards/index.js | 2 +- src/server/objects/objBase.js | 66 +++++++------- src/server/objects/objects.js | 23 ++--- src/server/security/connections.js | 28 +++--- src/server/security/sheets.js | 6 +- src/server/server.js | 6 +- src/server/world/atlas.js | 35 ++++---- src/server/world/customMap.js | 29 ++---- src/server/world/instancer.js | 60 +++++-------- src/server/world/map.js | 46 +++++----- src/server/world/mobBuilder.js | 8 +- src/server/world/physics.js | 22 ++--- src/server/world/randomMap.js | 36 ++++---- src/server/world/resourceSpawner.js | 18 ++-- src/server/world/spawners.js | 12 +-- src/server/world/worker.js | 11 +-- 112 files changed, 802 insertions(+), 835 deletions(-) diff --git a/src/server/components/aggro.js b/src/server/components/aggro.js index a97fc674..d54e5999 100644 --- a/src/server/components/aggro.js +++ b/src/server/components/aggro.js @@ -18,7 +18,7 @@ module.exports = { this.faction = blueprint.faction; //TODO: Why don't we move if faction is null? - if (this.faction == null) + if (this.faction === null) return; if (this.physics.width > 0) @@ -92,7 +92,7 @@ module.exports = { let faction = this.faction; let inRange = this.physics.getArea(x - range, y - range, x + range, y + range, (c => (((!c.player) || (!obj.player)) && (!obj.dead) && (c.aggro) && (c.aggro.willAutoAttack(obj))))); - if (inRange.length == 0) + if (inRange.length === 0) return; let iLen = inRange.length; @@ -103,7 +103,7 @@ module.exports = { lLen = list.length; for (let j = 0; j < lLen; j++) { //Set the enemy to null so we need we need to continue - if (list[j].obj == enemy) + if (list[j].obj === enemy) enemy = null; } if (!enemy) @@ -120,32 +120,32 @@ module.exports = { canAttack: function (target) { let obj = this.obj; - if (target == obj) + if (target === obj) return false; else if ((target.player) && (obj.player)) { let hasButcher = (obj.prophecies.hasProphecy('butcher')) && (target.prophecies.hasProphecy('butcher')); if ((!target.social.party) || (!obj.social.party)) return hasButcher; - else if (target.social.partyLeaderId != obj.social.partyLeaderId) + else if (target.social.partyLeaderId !== obj.social.partyLeaderId) return hasButcher; return false; } else if ((target.follower) && (target.follower.master.player) && (obj.player)) return false; else if (obj.player) return true; - else if (target.aggro.faction != obj.aggro.faction) + else if (target.aggro.faction !== obj.aggro.faction) return true; - else if (!!target.player != !!obj.player) + else if (!!target.player !== !!obj.player) return true; }, willAutoAttack: function (target) { - if (this.obj == target) + if (this.obj === target) return false; let faction = target.aggro.faction; - if ((faction == null) || (!this.faction)) + if ((faction === null) || (!this.faction)) return false; let rep = this.obj.reputation; @@ -160,17 +160,17 @@ module.exports = { }, ignore: function (obj) { - this.ignoreList.spliceWhere(o => o == obj); + this.ignoreList.spliceWhere(o => o === obj); this.ignoreList.push(obj); }, unIgnore: function (obj) { - this.ignoreList.spliceWhere(o => o == obj); + this.ignoreList.spliceWhere(o => o === obj); }, tryEngage: function (obj, amount, threatMult) { //Don't aggro yourself, stupid - if (obj == this.obj) + if (obj === this.obj) return; let result = { @@ -185,7 +185,7 @@ module.exports = { if (!mob) mob = obj.mob; if (mob) { - let notMob = (obj == mob) ? this.obj : obj; + let notMob = (obj === mob) ? this.obj : obj; if (!mob.canChase(notMob)) return false; } @@ -196,7 +196,7 @@ module.exports = { amount = amount || 0; threatMult = threatMult || 1; - let exists = list.find(l => l.obj.id == oId); + let exists = list.find(l => l.obj.id === oId); if (exists) { exists.damage += amount; exists.threat += amount * threatMult; @@ -251,10 +251,10 @@ module.exports = { for (let i = 0; i < lLen; i++) { let l = list[i]; - if (l.obj != obj) + if (l.obj !== obj) continue; - if (amount == null) { + if (amount === null) { list.splice(i, 1); obj.aggro.unAggro(this.obj); break; @@ -268,13 +268,13 @@ module.exports = { } } - this.ignoreList.spliceWhere(o => o == obj); + this.ignoreList.spliceWhere(o => o === obj); //Stuff like cocoons don't have spellbooks if (this.obj.spellbook) this.obj.spellbook.unregisterCallback(obj.id, true); - if ((this.list.length == 0) && (this.obj.mob) && (!this.obj.follower)) + if ((this.list.length === 0) && (this.obj.mob) && (!this.obj.follower)) this.obj.stats.resetHp(); }, @@ -285,7 +285,7 @@ module.exports = { }, getHighest: function () { - if (this.list.length == 0) + if (this.list.length === 0) return null; let list = this.list; @@ -302,13 +302,13 @@ module.exports = { let l = list[i]; let obj = l.obj; - if (this.ignoreList.some(o => o == obj)) + if (this.ignoreList.some(o => o === obj)) continue; - if ((highest == null) || (l.threat > highest.threat)) { + if ((highest === null) || (l.threat > highest.threat)) { highest = l; closest = Math.max(Math.abs(x - obj.x), Math.abs(y - obj.y)); - } else if (l.threat == highest.threat) { + } else if (l.threat === highest.threat) { let distance = Math.max(Math.abs(x - obj.x), Math.abs(y - obj.y)); if (distance < closest) { highest = l; diff --git a/src/server/components/auth.js b/src/server/components/auth.js index f2808b6e..c23c8a60 100644 --- a/src/server/components/auth.js +++ b/src/server/components/auth.js @@ -23,7 +23,7 @@ module.exports = { customChannels: [], play: function (data) { - if (this.username == null) + if (this.username === null) return; let character = this.characters[data.data.name]; @@ -47,7 +47,7 @@ module.exports = { let scheduler = require('../misc/scheduler'); let time = scheduler.getTime(); let lastLogin = accountInfo.lastLogin; - if ((!lastLogin) || (lastLogin.day != time.day)) { + if ((!lastLogin) || (lastLogin.day !== time.day)) { let daysSkipped = 1; if (lastLogin) { if (time.day > lastLogin.day) @@ -61,7 +61,7 @@ module.exports = { } } - if (daysSkipped == 1) { + if (daysSkipped === 1) { accountInfo.loginStreak++; if (accountInfo.loginStreak > 21) accountInfo.loginStreak = 21; @@ -100,12 +100,12 @@ module.exports = { doSave: function (extensionObj) { let simple = this.obj.getSimple(true, true); - simple.components.spliceWhere(c => c.type == 'stash'); + simple.components.spliceWhere(c => c.type === 'stash'); - let stats = simple.components.find(c => c.type == 'stats'); + let stats = simple.components.find(c => c.type === 'stats'); stats.values = extend(true, {}, stats.values); - let social = simple.components.find(c => c.type == 'social'); + let social = simple.components.find(c => c.type === 'social'); delete social.party; delete social.customChannels; @@ -116,11 +116,11 @@ module.exports = { if ( ( (s.indexOf('xp') > -1) && - (s != 'xpIncrease') + (s !== 'xpIncrease') ) || - (s == 'level') || - (s == 'hp') || - (s == 'mana') + (s === 'level') || + (s === 'hp') || + (s === 'mana') ) continue; @@ -129,7 +129,7 @@ module.exports = { //Calculate and store the ttl for effects let time = +new Date(); - simple.components.find(e => e.type == 'effects').effects.forEach(function (e) { + simple.components.find(e => e.type === 'effects').effects.forEach(function (e) { if (e.expire) return; @@ -169,7 +169,7 @@ module.exports = { }, getCharacterList: function (data) { - if (this.username == null) + if (this.username === null) return; io.get({ @@ -182,7 +182,7 @@ module.exports = { let characters = JSON.parse(result || '[]'); this.characterList = characters; - let result = characters + result = characters .map(c => ({ name: c.name ? c.name : c, level: leaderboard.getLevel(c.name ? c.name : c) @@ -193,7 +193,7 @@ module.exports = { getCharacter: function (data) { let name = data.data.name; - if (!this.characterList.some(c => ((c.name == name) || (c == name)))) + if (!this.characterList.some(c => ((c.name === name) || (c === name)))) return; io.get({ @@ -237,14 +237,14 @@ module.exports = { onGetCustomChannels: function (data, character, result) { this.customChannels = JSON .parse(result || '[]') - .filter(c => (typeof (c) == 'string')) + .filter(c => (typeof (c) === 'string')) .map(c => c.split(' ').join('')) .filter(c => (c.length > 0)); this.customChannels = this.customChannels - .filter((c, i) => (this.customChannels.indexOf(c) == i)); + .filter((c, i) => (this.customChannels.indexOf(c) === i)); - let social = character.components.find(c => (c.type == 'social')); + let social = character.components.find(c => (c.type === 'social')); if (social) social.customChannels = this.customChannels; @@ -269,7 +269,7 @@ module.exports = { fixes.fixStash(this.stash); - if (this.skins != null) { + if (this.skins !== null) { this.verifySkin(character); data.callback(character); } else { @@ -328,7 +328,7 @@ module.exports = { let list = [...this.skins, ...roles.getSkins(this.username)]; let skinList = skins.getSkinList(list); - if (!skinList.some(s => (s.id == character.skinId))) { + if (!skinList.some(s => (s.id === character.skinId))) { character.skinId = '1.0'; character.cell = skins.getCell(character.skinId); @@ -337,13 +337,13 @@ module.exports = { }, doesOwnSkin: function (skinId) { - return this.skins.some(s => s == skinId); + return this.skins.some(s => s === skinId); }, login: function (msg) { let credentials = msg.data; - if ((credentials.username == '') | (credentials.password == '')) { + if ((credentials.username === '') | (credentials.password === '')) { msg.callback(messages.login.allFields); return; } @@ -366,7 +366,7 @@ module.exports = { msg.callback(messages.login.incorrect); else if (compareResult) { //If stored password matches the hashed password entered by the user, log them in directly this.onLoginVerified(msg); - } else if (msg.data.password == storedPassword) { //If the stored password matches a plaintext password entered by the user; In that case the password gets hashed for the future + } else if (msg.data.password === storedPassword) { //If the stored password matches a plaintext password entered by the user; In that case the password gets hashed for the future this.onUnhashedLogin(msg); } else msg.callback(messages.login.incorrect); @@ -409,7 +409,7 @@ module.exports = { register: function (msg) { let credentials = msg.data; - if ((credentials.username == '') || (credentials.password == '')) { + if ((credentials.username === '') || (credentials.password === '')) { msg.callback(messages.login.allFields); return; } @@ -490,7 +490,7 @@ module.exports = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z' ]; - if (valid.indexOf(char) == -1) { + if (valid.indexOf(char) === -1) { msg.callback(messages.login.invalid); return; } @@ -521,7 +521,7 @@ module.exports = { let simple = this.obj.getSimple(true); let prophecies = data.prophecies || []; - prophecies = prophecies.filter((p, i) => (prophecies.indexOf(p) == i)); + prophecies = prophecies.filter((p, i) => (prophecies.indexOf(p) === i)); simple.components.push({ type: 'prophecies', list: prophecies @@ -563,7 +563,7 @@ module.exports = { if ((!data.name) || (!this.username)) return; - if (!this.characterList.some(c => ((c.name == data.name) || (c == data.name)))) { + if (!this.characterList.some(c => ((c.name === data.name) || (c === data.name)))) { msg.callback([]); return; } @@ -575,7 +575,7 @@ module.exports = { }); }, onDeleteCharacter: function (msg, result) { - this.characterList.spliceWhere(c => ((c.name == msg.data.name) || (c == msg.data.name))); + this.characterList.spliceWhere(c => ((c.name === msg.data.name) || (c === msg.data.name))); let characterList = this.characterList .map(c => ({ name: c.name ? c.name : c, @@ -592,7 +592,7 @@ module.exports = { leaderboard.deleteCharacter(msg.data.name); }, onRemoveFromList: function (msg, result) { - let result = this.characterList + result = this.characterList .map(c => ({ name: c.name ? c.name : c, level: leaderboard.getLevel(c.name ? c.name : c) diff --git a/src/server/components/chatter.js b/src/server/components/chatter.js index 7b6d180e..9880fd80 100644 --- a/src/server/components/chatter.js +++ b/src/server/components/chatter.js @@ -13,7 +13,7 @@ module.exports = { this.cd = ~~(Math.random() * this.cdMax); for (let p in blueprint) { - if (p == 'chats') + if (p === 'chats') continue; this[p] = blueprint[p]; @@ -23,10 +23,10 @@ module.exports = { update: function () { if ((this.obj.aggro) && (this.obj.aggro.list.length > 0)) return; - else if (this.chats.length == 0) + else if (this.chats.length === 0) return; - if ((this.cd == 0) && (Math.random() < this.chance)) { + if ((this.cd === 0) && (Math.random() < this.chance)) { this.cd = this.cdMax; let pick = this.chats[~~(Math.random() * this.chats.length)]; diff --git a/src/server/components/chest.js b/src/server/components/chest.js index f1aaf38b..1df80a90 100644 --- a/src/server/components/chest.js +++ b/src/server/components/chest.js @@ -6,7 +6,7 @@ module.exports = { ttl: -1, init: function (blueprint) { - if (blueprint.ownerId != null) + if (blueprint.ownerId !== null) this.ownerId = blueprint.ownerId; if (blueprint.ttl) @@ -24,7 +24,7 @@ module.exports = { if (this.ttl > 0) { this.ttl--; - if (this.ttl == 0) + if (this.ttl === 0) this.obj.destroyed = true; } }, @@ -34,11 +34,11 @@ module.exports = { return; let ownerId = this.ownerId; - if (ownerId != -1) { + if (ownerId !== -1) { if (ownerId instanceof Array) { - if (ownerId.indexOf(obj.serverId) == -1) + if (ownerId.indexOf(obj.serverId) === -1) return; - } else if (ownerId != obj.serverId) + } else if (ownerId !== obj.serverId) return; } diff --git a/src/server/components/components.js b/src/server/components/components.js index 631129cd..76cb8f49 100644 --- a/src/server/components/components.js +++ b/src/server/components/components.js @@ -16,9 +16,9 @@ module.exports = { getComponentFolder: function () { let files = fileLister.getFolder('./components/'); files = files.filter(w => ( - (w.indexOf('components') == -1) && - (w.indexOf('cpnBase') == -1) && - (w.indexOf('projectile') == -1) + (w.indexOf('components') === -1) && + (w.indexOf('cpnBase') === -1) && + (w.indexOf('projectile') === -1) )); let fLen = files.length; for (let i = 0; i < fLen; i++) diff --git a/src/server/components/dialogue.js b/src/server/components/dialogue.js index 547ed24b..f03079c1 100644 --- a/src/server/components/dialogue.js +++ b/src/server/components/dialogue.js @@ -21,15 +21,15 @@ module.exports = { let target = msg.target; - if ((target == null) && (!msg.targetName)) + if ((target === null) && (!msg.targetName)) return false; - if ((target != null) && (target.id == null)) { - target = this.obj.instance.objects.objects.find(o => o.id == target); + if ((target !== null) && (target.id === null)) { + target = this.obj.instance.objects.objects.find(o => o.id === target); if (!target) return false; - } else if (msg.targetName != null) { - target = this.obj.instance.objects.objects.find(o => ((o.name) && (o.name.toLowerCase() == msg.targetName.toLowerCase()))); + } else if (msg.targetName !== null) { + target = this.obj.instance.objects.objects.find(o => ((o.name) && (o.name.toLowerCase() === msg.targetName.toLowerCase()))); if (!target) return false; } @@ -145,7 +145,7 @@ module.exports = { } if (!(result.options instanceof Array)) { - if (result.options[0] == '$') + if (result.options[0] === '$') result.options = this.states[result.options.replace('$', '')].options; result.options = Object.keys(result.options); @@ -196,7 +196,7 @@ module.exports = { getItem: function (msg, source) { let inventory = this.obj.inventory; - let exists = inventory.items.find(i => (i.name == msg.item.name)); + let exists = inventory.items.find(i => (i.name === msg.item.name)); if (!exists) { inventory.getItem(msg.item); return msg.successMsg || false; diff --git a/src/server/components/door.js b/src/server/components/door.js index e63618dd..1f3f2192 100644 --- a/src/server/components/door.js +++ b/src/server/components/door.js @@ -72,7 +72,7 @@ module.exports = { if (this.closed) { if (this.locked) { - let key = obj.inventory.items.find(i => ((i.keyId == this.key) || (i.keyId == 'world'))); + let key = obj.inventory.items.find(i => ((i.keyId === this.key) || (i.keyId === 'world'))); if (!key) { canAction = false; msg = 'You don\'t have the key to unlock this door'; @@ -99,17 +99,17 @@ module.exports = { }, unlock: function (msg) { - if (msg.sourceId == null) + if (msg.sourceId === null) return; - let obj = this.obj.instance.objects.objects.find(o => o.serverId == msg.sourceId); + let obj = this.obj.instance.objects.objects.find(o => o.serverId === msg.sourceId); if ((!obj) || (!obj.player)) return; let thisObj = this.obj; if ((Math.abs(thisObj.x - obj.x) > 1) || (Math.abs(thisObj.y - obj.y) > 1)) return; - else if ((thisObj.x == obj.x) && (thisObj.y == obj.y)) + else if ((thisObj.x === obj.x) && (thisObj.y === obj.y)) return; let syncO = thisObj.syncer.o; @@ -118,11 +118,11 @@ module.exports = { if (this.autoClose) this.autoCloseCd = this.autoClose; - let key = obj.inventory.items.find(i => ((i.keyId == this.key) || (i.keyId == 'world'))); + let key = obj.inventory.items.find(i => ((i.keyId === this.key) || (i.keyId === 'world'))); if (!key) return; - if (((key.singleUse) || (this.destroyKey)) && (key.keyId != 'world')) { + if (((key.singleUse) || (this.destroyKey)) && (key.keyId !== 'world')) { obj.inventory.destroyItem(key.id, 1); obj.instance.syncer.queue('onGetMessages', { @@ -161,7 +161,7 @@ module.exports = { this.autoCloseCd--; - if (this.autoCloseCd == 0) { + if (this.autoCloseCd === 0) { this.obj.cell = this.closedSprite; this.obj.syncer.o.cell = this.closedSprite; this.obj.instance.physics.setCollision(this.obj.x, this.obj.y, true); diff --git a/src/server/components/effects.js b/src/server/components/effects.js index 42c5c532..5512a126 100644 --- a/src/server/components/effects.js +++ b/src/server/components/effects.js @@ -37,7 +37,7 @@ module.exports = { type: 'effects', effects: this.effects .map(e => e.save()) - .filter(e => e != null) + .filter(e => e !== null) }; return e; @@ -52,7 +52,7 @@ module.exports = { if ((effects.length > 0) && (effects[0].obj)) { effects = effects .map(e => e.simplify()) - .filter(e => e != null); + .filter(e => e !== null); } e.effects = effects; @@ -115,7 +115,7 @@ module.exports = { }, canApplyEffect: function (type) { - if (this.ccResistances[type] == null) + if (this.ccResistances[type] === null) return true; let ccResistances = this.ccResistances; @@ -130,12 +130,12 @@ module.exports = { return; if (!options.new) { - let exists = this.effects.find(e => e.type == options.type); + let exists = this.effects.find(e => e.type === options.type); if (exists) { exists.ttl += options.ttl; for (let p in options) { - if (p == 'ttl') + if (p === 'ttl') continue; exists[p] = options[p]; @@ -210,7 +210,7 @@ module.exports = { let eLen = effects.length; for (let i = 0; i < eLen; i++) { let effect = effects[i]; - if (effect == checkEffect) { + if (effect === checkEffect) { if (effect.destroy) effect.destroy(); this.syncRemove(effect.id, effect.type, noMsg || effect.noMsg); @@ -224,7 +224,7 @@ module.exports = { let eLen = effects.length; for (let i = 0; i < eLen; i++) { let effect = effects[i]; - if (effect.type == effectName) { + if (effect.type === effectName) { this.syncRemove(effect.id, effect.type, noMsg || effects.noMsg); effects.splice(i, 1); return; @@ -267,7 +267,7 @@ module.exports = { if (e.ttl > 0) { e.ttl--; - if (e.ttl == 0) + if (e.ttl === 0) e.destroyed = true; } diff --git a/src/server/components/equipment.js b/src/server/components/equipment.js index 9940ad60..ff51fa18 100644 --- a/src/server/components/equipment.js +++ b/src/server/components/equipment.js @@ -40,7 +40,7 @@ module.exports = { } let currentEqId = this.eq[item.slot]; - if (currentEqId == null) { + if (currentEqId === null) { this.equip(itemId); return true; } @@ -48,7 +48,7 @@ module.exports = { equip: function (itemId) { let slot = null; - if (typeof (itemId) == 'object') { + if (typeof (itemId) === 'object') { slot = itemId.slot; itemId = itemId.itemId; } @@ -63,17 +63,17 @@ module.exports = { if (!slot) slot = item.equipSlot || item.slot; - if (slot == 'twoHanded') { + if (slot === 'twoHanded') { let currentEqId = this.eq.offHand; - if (currentEqId != null) + if (currentEqId !== null) this.unequip(currentEqId); slot = 'oneHanded'; - } else if (slot == 'offHand') { + } else if (slot === 'offHand') { let currentEqId = this.eq.oneHanded; - if (currentEqId != null) { + if (currentEqId !== null) { let currentEq = this.obj.inventory.findItem(currentEqId); - if ((currentEq != null) && (currentEq.slot == 'twoHanded')) + if ((currentEq !== null) && (currentEq.slot === 'twoHanded')) this.unequip(currentEqId); } } @@ -99,9 +99,9 @@ module.exports = { delete item.pos; this.obj.syncer.setArray(true, 'inventory', 'getItems', item); - if (slot == 'finger') { - let f1 = (this.eq['finger-1'] != null); - let f2 = (this.eq['finger-2'] != null); + if (slot === 'finger') { + let f1 = (this.eq['finger-1'] !== null); + let f2 = (this.eq['finger-2'] !== null); if ((f1) && (f2)) slot = 'finger-1'; @@ -114,9 +114,9 @@ module.exports = { let spellId = null; let currentEqId = this.eq[slot]; let currentEq = this.obj.inventory.findItem(currentEqId); - if (currentEq == item) + if (currentEq === item) return; - if (currentEqId != null) { + if (currentEqId !== null) { spellId = currentEq.spellId; this.unequip(currentEqId); } @@ -180,12 +180,12 @@ module.exports = { unequip: function (itemId) { let item = itemId; let slot = null; - if (typeof (itemId) == 'object') { + if (typeof (itemId) === 'object') { slot = itemId.slot; itemId = itemId.itemId; } - if (item.id == null) + if (item.id === null) item = this.obj.inventory.findItem(itemId); if (!item) @@ -299,7 +299,7 @@ module.exports = { if (!factions) return; - let findFaction = factions.find(f => f.id == factionId); + let findFaction = factions.find(f => f.id === factionId); if (!findFaction) return; diff --git a/src/server/components/events.js b/src/server/components/events.js index 5d6a457c..da7f31d3 100644 --- a/src/server/components/events.js +++ b/src/server/components/events.js @@ -29,7 +29,7 @@ module.exports = { }, unregisterEvent: function (event) { - this.list.spliceWhere(l => (l == event)); + this.list.spliceWhere(l => (l === event)); this.obj.syncer.setArray(true, 'events', 'removeList', { id: event.id @@ -54,7 +54,7 @@ module.exports = { return; closeEvents.forEach(function (c) { - if (this.list.some(l => (l == c))) + if (this.list.some(l => (l === c))) return; this.list.push(c); diff --git a/src/server/components/extensions/factionVendor.js b/src/server/components/extensions/factionVendor.js index 4aec8085..010ce761 100644 --- a/src/server/components/extensions/factionVendor.js +++ b/src/server/components/extensions/factionVendor.js @@ -32,7 +32,7 @@ module.exports = { this.items[name] = list; this.regenList(list); - } else if (list.level != requestLevel) + } else if (list.level !== requestLevel) this.regenList(list); let reputation = requestedBy.reputation; @@ -148,7 +148,7 @@ module.exports = { let item = extend(true, {}, e); - if (item.type == 'skin') { + if (item.type === 'skin') { let skinBlueprint = skins.getBlueprint(item.id); item.skinId = item.id; item.name = skinBlueprint.name; @@ -180,9 +180,9 @@ module.exports = { canBuy: function (itemId, requestedBy, action) { let item = null; - if (action == 'buy') + if (action === 'buy') item = this.findItem(itemId, requestedBy.name); - else if (action == 'buyback') + else if (action === 'buyback') item = this.findBuyback(itemId, requestedBy.name); let result = true; @@ -208,7 +208,7 @@ module.exports = { if (!list) return null; - return list.items.find(i => i.id == itemId); + return list.items.find(i => i.id === itemId); }, removeItem: function (itemId, sourceName) { @@ -216,6 +216,6 @@ module.exports = { if (!sourceName) return null; - return list.items.spliceFirstWhere(i => i.id == itemId); + return list.items.spliceFirstWhere(i => i.id === itemId); } }; diff --git a/src/server/components/extensions/socialCommands.js b/src/server/components/extensions/socialCommands.js index ac1e5bab..0c5f146f 100644 --- a/src/server/components/extensions/socialCommands.js +++ b/src/server/components/extensions/socialCommands.js @@ -45,7 +45,7 @@ module.exports = { init: function (blueprint) { if (this.customChannels) { this.customChannels = this.customChannels - .filter((c, i) => (this.customChannels.indexOf(c) == i)); + .filter((c, i) => (this.customChannels.indexOf(c) === i)); } this.roleLevel = roles.getRoleLevel(this.obj); @@ -53,12 +53,12 @@ module.exports = { onBeforeChat: function (msg) { let messageText = msg.message; - if (messageText[0] != '/') + if (messageText[0] !== '/') return; messageText = messageText.substr(1).split(' '); let actionName = messageText.splice(0, 1)[0].toLowerCase(); - actionName = Object.keys(commandRoles).find(a => (a.toLowerCase() == actionName)); + actionName = Object.keys(commandRoles).find(a => (a.toLowerCase() === actionName)); if (!actionName) return; @@ -68,7 +68,7 @@ module.exports = { msg.ignore = true; let config = {}; - if ((messageText.length == 1) && (messageText[0].indexOf('=') == -1)) + if ((messageText.length === 1) && (messageText[0].indexOf('=') === -1)) config = messageText[0]; else { messageText.forEach(function (m) { @@ -90,17 +90,17 @@ module.exports = { //actions join: function (value) { - if (typeof (value) != 'string') + if (typeof (value) !== 'string') return; value = value.split(' ').join(''); - if (value.lengh == 0) + if (value.lengh === 0) return; let obj = this.obj; let channels = obj.auth.customChannels; - if (!channels.some(c => (c == value))) + if (!channels.some(c => (c === value))) channels.push(value); else return; @@ -131,13 +131,13 @@ module.exports = { }, leave: function (value) { - if (typeof (value) != 'string') + if (typeof (value) !== 'string') return; let obj = this.obj; let channels = obj.auth.customChannels; - if (!channels.some(c => (c == value))) { + if (!channels.some(c => (c === value))) { obj.socket.emit('events', { onGetMessages: [{ messages: [{ @@ -152,7 +152,7 @@ module.exports = { } let channels = obj.auth.customChannels; - channels.spliceWhere(c => (c == value)); + channels.spliceWhere(c => (c === value)); let charname = obj.auth.charname; io.set({ @@ -178,7 +178,7 @@ module.exports = { }, isInChannel: function (character, channel) { - return character.auth.customChannels.some(c => (c == channel)); + return character.auth.customChannels.some(c => (c === channel)); }, unEq: function () { @@ -189,16 +189,16 @@ module.exports = { }, mute: function (target, reason) { - if (typeof (target) == 'object') { + if (typeof (target) === 'object') { let keys = Object.keys(target); target = keys[0]; reason = keys[1]; } - if (target == this.obj.name) + if (target === this.obj.name) return; - let o = connections.players.find(o => (o.name == target)); + let o = connections.players.find(o => (o.name === target)); if (!o) return; @@ -240,16 +240,16 @@ module.exports = { }, unmute: function (target, reason) { - if (typeof (target) == 'object') { + if (typeof (target) === 'object') { let keys = Object.keys(target); target = keys[0]; reason = keys[1]; } - if (target == this.obj.name) + if (target === this.obj.name) return; - let o = connections.players.find(o => (o.name == target)); + let o = connections.players.find(o => (o.name === target)); if (!o) return; @@ -300,9 +300,9 @@ module.exports = { }, getItem: function (config) { - if (config.slot == 'set') { + if (config.slot === 'set') { configSlots.slots.forEach(function (s) { - if (s == 'tool') + if (s === 'tool') return; let newConfig = extend(true, {}, config, { @@ -351,7 +351,7 @@ module.exports = { } factions.forEach(function (f) { - if (f == '') + if (f === '') return; let faction = factions.getFaction(f); @@ -453,14 +453,14 @@ module.exports = { }, getReputation: function (faction) { - if (typeof (faction) != 'string') + if (typeof (faction) !== 'string') return; this.obj.reputation.getReputation(faction, 50000); }, loseReputation: function (faction) { - if (typeof (faction) != 'string') + if (typeof (faction) !== 'string') return; this.obj.reputation.getReputation(faction, -50000); diff --git a/src/server/components/follower.js b/src/server/components/follower.js index 951013ef..39351303 100644 --- a/src/server/components/follower.js +++ b/src/server/components/follower.js @@ -107,7 +107,6 @@ module.exports = { let maxDistance = this.maxDistance; let distance = Math.max(Math.abs(obj.x - master.x), Math.abs(obj.y - master.y)); - let doMove = (distance >= maxDistance); //When we're too far, just teleport if ((!attacker) && (distance >= maxDistance * 2)) { this.teleport(); @@ -119,7 +118,7 @@ module.exports = { if (!attacker) { let lastMasterPos = this.lastMasterPos; - if ((master.x != lastMasterPos.x) || (master.y != lastMasterPos.y)) { + if ((master.x !== lastMasterPos.x) || (master.y !== lastMasterPos.y)) { doMove = true; lastMasterPos.x = master.x; lastMasterPos.y = master.y; diff --git a/src/server/components/gatherer.js b/src/server/components/gatherer.js index 1b9c9dff..43d61740 100644 --- a/src/server/components/gatherer.js +++ b/src/server/components/gatherer.js @@ -16,11 +16,11 @@ module.exports = { }, gather: function () { - if (this.gathering != null) + if (this.gathering !== null) return; let nodes = this.nodes; - if (nodes.length == 0) + if (nodes.length === 0) return; let firstNode = nodes[0]; @@ -29,7 +29,7 @@ module.exports = { let ttlMax = firstNode.resourceNode.ttl || this.defaultTtlMax; - if (firstNode.resourceNode.nodeType == 'fish') { + if (firstNode.resourceNode.nodeType === 'fish') { let rod = this.obj.equipment.eq.tool; if (!rod) { process.send({ @@ -73,10 +73,10 @@ module.exports = { return; } - let isFish = (gathering.resourceNode.nodeType == 'fish'); + let isFish = (gathering.resourceNode.nodeType === 'fish'); if (this.gatheringTtl > 0) { - if ((this.gatheringTtl == this.gatheringTtlMax) && (gathering.width)) { + if ((this.gatheringTtl === this.gatheringTtlMax) && (gathering.width)) { ['x', 'y', 'width', 'height'].forEach(function (p) { this.obj.syncer.set(false, 'gatherer', p, gathering[p]); }, this); @@ -175,7 +175,7 @@ module.exports = { gatherResult.items.forEach(function (item, i) { delete item.pos; - if (i == 0) { + if (i === 0) { if (blueprint.itemName) item.name = blueprint.itemName; if (blueprint.itemAmount) @@ -208,7 +208,7 @@ module.exports = { }); } - this.nodes.spliceWhere(n => (n == gathering)); + this.nodes.spliceWhere(n => (n === gathering)); } this.gathering = null; @@ -228,9 +228,9 @@ module.exports = { }[nodeType]); let success = true; - if (nodeType == 'fish') { + if (nodeType === 'fish') { let rod = this.obj.equipment.eq.tool; - if (rod == null) { + if (rod === null) { success = false; msg = 'You need a fishing rod to fish'; } @@ -248,12 +248,12 @@ module.exports = { } }); - this.nodes.spliceWhere(n => (n == node)); + this.nodes.spliceWhere(n => (n === node)); this.nodes.push(node); }, exit: function (node) { - this.nodes.spliceWhere(n => (n == node)); + this.nodes.spliceWhere(n => (n === node)); }, events: { @@ -272,7 +272,7 @@ module.exports = { this.obj.syncer.set(true, 'gatherer', 'progress', 100); this.obj.syncer.set(false, 'gatherer', 'progress', 100); - if (this.gathering.resourceNode.nodeType == 'fish') + if (this.gathering.resourceNode.nodeType === 'fish') this.obj.syncer.set(true, 'gatherer', 'action', 'Fishing'); this.gathering = null; @@ -284,12 +284,12 @@ module.exports = { for (let i = 0; i < nLen; i++) { let node = nodes[i]; - if (item.slot != 'tool') + if (item.slot !== 'tool') continue; - if (node.resourceNode.nodeType == 'fish') { + if (node.resourceNode.nodeType === 'fish') { let rod = this.obj.equipment.eq.tool; - if (rod == null) { + if (rod === null) { process.send({ method: 'events', data: { @@ -302,8 +302,8 @@ module.exports = { } }); - if (this.gathering == node) { - if (this.gathering.resourceNode.nodeType == 'fish') + if (this.gathering === node) { + if (this.gathering.resourceNode.nodeType === 'fish') this.obj.syncer.set(true, 'gatherer', 'action', 'Fishing'); this.gathering = null; diff --git a/src/server/components/inventory.js b/src/server/components/inventory.js index bac0d9ef..98a397f4 100644 --- a/src/server/components/inventory.js +++ b/src/server/components/inventory.js @@ -24,8 +24,8 @@ module.exports = { //Spells should be sorted so they're EQ'd in the right order items.sort(function (a, b) { - let aId = (a.spellId != null) ? ~~a.spellId : 9999; - let bId = (b.spellId != null) ? ~~b.spellId : 9999; + let aId = (a.spellId !== null) ? ~~a.spellId : 9999; + let bId = (b.spellId !== null) ? ~~b.spellId : 9999; return (aId - bId); }); @@ -48,7 +48,7 @@ module.exports = { newItem.pos = pos; } - if ((this.obj.player) && (!isTransfer) && (this.obj.stats.values.level == 1)) + if ((this.obj.player) && (!isTransfer) && (this.obj.stats.values.level === 1)) this.getDefaultAbilities(); delete blueprint.items; @@ -135,7 +135,7 @@ module.exports = { enchantItem: function (msg) { let item = this.findItem(msg.itemId); - if ((!item) || (!item.slot) || (item.eq) || (item.noAugment) || ((msg.action == 'scour') && (item.power == 0))) { + if ((!item) || (!item.slot) || (item.eq) || (item.noAugment) || ((msg.action === 'scour') && (item.power === 0))) { this.resolveCallback(msg); return; } @@ -153,7 +153,7 @@ module.exports = { }, learnAbility: function (itemId, runeSlot) { - if (itemId.itemId != null) { + if (itemId.itemId !== null) { let msg = itemId; itemId = msg.itemId; runeSlot = msg.slot; @@ -191,19 +191,19 @@ module.exports = { let spellbook = this.obj.spellbook; - if ((item.slot == 'twoHanded') || (item.slot == 'oneHanded')) + if ((item.slot === 'twoHanded') || (item.slot === 'oneHanded')) runeSlot = 0; - else if (runeSlot == null) { + else if (runeSlot === null) { runeSlot = 4; for (let i = 1; i <= 4; i++) { - if (!this.items.some(j => (j.runeSlot == i))) { + if (!this.items.some(j => (j.runeSlot === i))) { runeSlot = i; break; } } } - let currentEq = this.items.find(i => (i.runeSlot == runeSlot)); + let currentEq = this.items.find(i => (i.runeSlot === runeSlot)); if (currentEq) { spellbook.removeSpellById(runeSlot); delete currentEq.eq; @@ -224,7 +224,7 @@ module.exports = { let item = this.findItem(itemId); if (!item) return; - else if (item.type != 'mtx') { + else if (item.type !== 'mtx') { delete item.active; return; } @@ -290,7 +290,7 @@ module.exports = { //Find similar items and put them on cooldown too this.items.forEach(function (i) { - if ((i.name == item.name) && (i.cdMax == item.cdMax)) + if ((i.name === item.name) && (i.cdMax === item.cdMax)) i.cd = i.cdMax; }); } @@ -298,7 +298,7 @@ module.exports = { let result = {}; this.obj.instance.eventEmitter.emit('onBeforeUseItem', this.obj, item, result); - if (item.type == 'consumable') { + if (item.type === 'consumable') { if (item.uses) { item.uses--; this.obj.syncer.setArray(true, 'inventory', 'getItems', item); @@ -309,7 +309,7 @@ module.exports = { }, unlearnAbility: function (itemId) { - if (itemId.itemId != null) + if (itemId.itemId !== null) itemId = itemId.itemId; let item = this.findItem(itemId); @@ -390,12 +390,12 @@ module.exports = { if ((item.quantity) && (amount)) { item.quantity -= amount; if (item.quantity <= 0) { - this.items.spliceWhere(i => i.id == id); + this.items.spliceWhere(i => i.id === id); this.obj.syncer.setArray(true, 'inventory', 'destroyItems', id); } else this.obj.syncer.setArray(true, 'inventory', 'getItems', item); } else { - this.items.spliceWhere(i => i.id == id); + this.items.spliceWhere(i => i.id === id); this.obj.syncer.setArray(true, 'inventory', 'destroyItems', id); } @@ -421,7 +421,7 @@ module.exports = { if (item.eq) this.obj.equipment.unequip(id); - this.items.spliceWhere(i => i.id == id); + this.items.spliceWhere(i => i.id === id); this.obj.syncer.setArray(true, 'inventory', 'destroyItems', id); @@ -471,7 +471,7 @@ module.exports = { //Helpers hookItemEvents: function (items) { - let items = items || this.items; + items = items || this.items; let iLen = items.length; for (let i = 0; i < iLen; i++) { let item = items[i]; @@ -496,19 +496,19 @@ module.exports = { }); } - if ((item.pos == null) && (!item.eq)) { + if ((item.pos === null) && (!item.eq)) { let pos = i; for (let j = 0; j < iLen; j++) { - if (!items.some(fj => (fj.pos == j))) { + if (!items.some(fj => (fj.pos === j))) { pos = j; break; } } item.pos = pos; - } else if ((!item.eq) && (items.some(ii => ((ii != item) && (ii.pos == item.pos))))) { + } else if ((!item.eq) && (items.some(ii => ((ii !== item) && (ii.pos === item.pos))))) { let pos = item.pos; for (let j = 0; j < iLen; j++) { - if (!items.some(fi => ((fi != item) && (fi.pos == j)))) { + if (!items.some(fi => ((fi !== item) && (fi.pos === j)))) { pos = j; break; } @@ -525,7 +525,7 @@ module.exports = { let iSize = this.inventorySize; for (let i = 0; i < iSize; i++) { - if (!this.items.some(j => (j.pos == i))) { + if (!this.items.some(j => (j.pos === i))) { item.pos = i; break; } @@ -533,10 +533,10 @@ module.exports = { }, resolveCallback: function (msg, result) { - let callbackId = (msg.callbackId != null) ? msg.callbackId : msg; + let callbackId = (msg.callbackId !== null) ? msg.callbackId : msg; result = result || []; - if (callbackId == null) + if (callbackId === null) return; process.send({ @@ -550,10 +550,10 @@ module.exports = { }, findItem: function (id) { - if (id == null) + if (id === null) return null; - return this.items.find(i => i.id == id); + return this.items.find(i => i.id === id); }, getDefaultAbilities: function () { @@ -561,8 +561,8 @@ module.exports = { return ( (i.spell) && (i.spell.rolls) && - (i.spell.rolls.damage != null) && - ((i.slot == 'twoHanded') || (i.slot == 'oneHanded')) + (i.spell.rolls.damage !== null) && + ((i.slot === 'twoHanded') || (i.slot === 'oneHanded')) ); }); @@ -581,7 +581,7 @@ module.exports = { let hasSpell = this.items.some(function (i) { return ( (i.spell) && - (i.spell.name.toLowerCase() == spellName) + (i.spell.name.toLowerCase() === spellName) ); }); @@ -599,7 +599,7 @@ module.exports = { }, createBag: function (x, y, items, ownerId) { - if (ownerId == null) + if (ownerId === null) ownerId = -1; let bagCell = 50; @@ -613,13 +613,13 @@ module.exports = { topQuality = quality; } - if (topQuality == 0) + if (topQuality === 0) bagCell = 50; - else if (topQuality == 1) + else if (topQuality === 1) bagCell = 51; - else if (topQuality == 2) + else if (topQuality === 2) bagCell = 128; - else if (topQuality == 3) + else if (topQuality === 3) bagCell = 52; else bagCell = 53; @@ -644,7 +644,7 @@ module.exports = { }, hasSpace: function () { - if (this.inventorySize != -1) { + if (this.inventorySize !== -1) { let nonEqItems = this.items.filter(f => !f.eq).length; return (nonEqItems < this.inventorySize); } return true; @@ -656,7 +656,7 @@ module.exports = { //We need to know if a mob dropped it for quest purposes let fromMob = item.fromMob; - if (item.quality == null) + if (item.quality === null) item.quality = 0; //Players can't have fromMob items in their inventory but bags can (dropped by a mob) @@ -668,7 +668,7 @@ module.exports = { let exists = false; if (((item.material) || (item.quest) || (item.quantity)) && (!item.noStack) && (!item.uses) && (!noStack)) { - let existItem = this.items.find(i => (i.name == item.name)); + let existItem = this.items.find(i => (i.name === item.name)); if (existItem) { exists = true; if (!existItem.quantity) @@ -713,10 +713,10 @@ module.exports = { if (item.eq) delete item.pos; - if ((item.pos == null) && (!item.eq)) { + if ((item.pos === null) && (!item.eq)) { let pos = iLen; for (let i = 0; i < iLen; i++) { - if (!items.some(fi => (fi.pos == i))) { + if (!items.some(fi => (fi.pos === i))) { pos = i; break; } @@ -759,10 +759,10 @@ module.exports = { for (let i = 0; i < sLen; i++) { let s = stats[i]; let val = item.stats[s]; - if (s == 'maxHp') { + if (s === 'maxHp') { delete item.stats[s]; item.stats.hpMax = val; - } else if (s == 'maxMana') { + } else if (s === 'maxMana') { delete item.stats[s]; item.stats.manaMax = val; } @@ -842,7 +842,7 @@ module.exports = { return; //Only drop loot if this player is in the zone - let playerObject = this.obj.instance.objects.find(o => o.serverId == ownerId); + let playerObject = this.obj.instance.objects.find(o => o.serverId === ownerId); if (!playerObject) return; @@ -853,7 +853,7 @@ module.exports = { if (!(spellStatType instanceof Array)) spellStatType = [spellStatType]; spellStatType.forEach(function (ss) { - if (stats.indexOf(ss) == -1) + if (stats.indexOf(ss) === -1) stats.push(ss); }); }); @@ -919,7 +919,7 @@ module.exports = { drop.magicFind = magicFind; let item = drop; - if ((!item.quest) && (item.type != 'key')) + if ((!item.quest) && (item.type !== 'key')) item = generator.generate(drop); if (!item.slot) @@ -1015,6 +1015,6 @@ module.exports = { }, canEquipItem: function (item) { - return (this.equipItemErrors(item).length == 0); + return (this.equipItemErrors(item).length === 0); } }; diff --git a/src/server/components/mob.js b/src/server/components/mob.js index 76daf1a2..0d3c8f3c 100644 --- a/src/server/components/mob.js +++ b/src/server/components/mob.js @@ -50,7 +50,7 @@ module.exports = { if (!this.goHome) { //Are we in fight mode? - if ((target) && (target != obj) && ((!obj.follower) || (obj.follower.master != target))) { + if ((target) && (target !== obj) && ((!obj.follower) || (obj.follower.master !== target))) { this.fight(target); return; } @@ -108,12 +108,12 @@ module.exports = { this.goHome = false; }, fight: function (target) { - if (this.target != target) { + if (this.target !== target) { this.obj.clearQueue(); this.target = target; } //If the target is true, it means we can't reach the target and should wait for a new one - if (this.target == true) + if (this.target === true) return; let obj = this.obj; @@ -140,7 +140,7 @@ module.exports = { target: target }); //null means we don't have LoS - if (success != null) + if (success !== null) return; hasLos = false; } else @@ -159,17 +159,17 @@ module.exports = { let newDistance = max(abs(targetPos.x - tx), abs(targetPos.y - ty)); if ((newDistance >= distance) && (newDistance > furthestRange)) { - if (hasLos == null) + if (hasLos === null) hasLos = this.physics.hasLos(x, y, tx, ty); if (hasLos) { - if (doesCollide == null) + if (doesCollide === null) doesCollide = this.physics.mobsCollide(x, y, obj); if (!doesCollide) { obj.aggro.ignore(target); return; } } else { - if (doesCollide == null) + if (doesCollide === null) doesCollide = this.physics.mobsCollide(x, y, obj); if (!doesCollide) { obj.aggro.ignore(target); @@ -185,7 +185,7 @@ module.exports = { x: targetPos.x, y: targetPos.y }); - if (path.length == 0) { + if (path.length === 0) { obj.aggro.ignore(target); //TODO: Don't skip a turn return; diff --git a/src/server/components/notice.js b/src/server/components/notice.js index 08371911..224c6701 100644 --- a/src/server/components/notice.js +++ b/src/server/components/notice.js @@ -29,7 +29,7 @@ module.exports = { return; if (action.targetId) { - let target = this.obj.instance.objects.find(o => o.id == action.targetId); + let target = this.obj.instance.objects.find(o => o.id === action.targetId); if (target) { let cpn = target[action.cpn]; if ((cpn) && (cpn[action.method])) @@ -80,7 +80,7 @@ module.exports = { return; } - this.contents.spliceWhere(c => (c == obj)); + this.contents.spliceWhere(c => (c === obj)); this.callAction(obj, 'exit'); diff --git a/src/server/components/passives.js b/src/server/components/passives.js index 66305af6..f218bb54 100644 --- a/src/server/components/passives.js +++ b/src/server/components/passives.js @@ -8,15 +8,15 @@ module.exports = { init: function (blueprint) { this.selected = ((blueprint || {}).selected || []); - this.selected.spliceWhere(s => (passiveTree.nodes.some(n => ((n.id == s) && (n.spiritStart))))); + this.selected.spliceWhere(s => (passiveTree.nodes.some(n => ((n.id === s) && (n.spiritStart))))); - this.selected.push(passiveTree.nodes.find(n => (n.spiritStart == this.obj.class)).id); + this.selected.push(passiveTree.nodes.find(n => (n.spiritStart === this.obj.class)).id); let points = this.calcPoints(); if (points + this.selected.length < this.selected.length) { this.selected = []; - this.selected.push(passiveTree.nodes.find(n => (n.spiritStart == this.obj.class)).id); + this.selected.push(passiveTree.nodes.find(n => (n.spiritStart === this.obj.class)).id); blueprint.selected = this.selected; points = this.calcPoints(); } @@ -27,7 +27,7 @@ module.exports = { let stats = this.obj.stats; this.selected.forEach(function (id) { - let node = passiveTree.nodes.find(n => (n.id == id)); + let node = passiveTree.nodes.find(n => (n.id === id)); if (node) { for (let p in node.stats) stats.addStat(p, node.stats[p]); @@ -48,7 +48,7 @@ module.exports = { applyPassives: function () { let stats = this.obj.stats; this.selected.forEach(function (id) { - let node = passiveTree.nodes.find(n => (n.id == id)); + let node = passiveTree.nodes.find(n => (n.id === id)); if (node) { for (let p in node.stats) stats.addStat(p, node.stats[p]); @@ -59,17 +59,17 @@ module.exports = { tickNode: function (msg) { if (this.points <= 0) return; - else if (this.selected.some(s => (s == msg.nodeId))) + else if (this.selected.some(s => (s === msg.nodeId))) return; let nodeId = msg.nodeId; - let node = passiveTree.nodes.find(n => (n.id == nodeId)); + let node = passiveTree.nodes.find(n => (n.id === nodeId)); if (node.spiritStart) return; let linked = passiveTree.links.some(function (l) { - if ((l.from.id != node.id) && (l.to.id != node.id)) + if ((l.from.id !== node.id) && (l.to.id !== node.id)) return false; return ( @@ -99,7 +99,7 @@ module.exports = { let stats = this.obj.stats; this.selected.forEach(function (s) { - let node = passiveTree.nodes.find(n => (n.id == s)); + let node = passiveTree.nodes.find(n => (n.id === s)); if (node.spiritStart) return; @@ -115,7 +115,7 @@ module.exports = { }, this); this.selected = []; - this.selected.push(passiveTree.nodes.find(n => (n.spiritStart == this.obj.class)).id); + this.selected.push(passiveTree.nodes.find(n => (n.spiritStart === this.obj.class)).id); this.obj.spellbook.calcDps(); }, diff --git a/src/server/components/player.js b/src/server/components/player.js index d5f39ca9..33194300 100644 --- a/src/server/components/player.js +++ b/src/server/components/player.js @@ -44,7 +44,7 @@ module.exports = { roles.onBeforePlayerEnterGame(obj, character); - let blueprintStats = character.components.find(c => c.type == 'stats') || {}; + let blueprintStats = character.components.find(c => c.type === 'stats') || {}; extend(true, blueprintStats, classes.stats[obj.class]); blueprintStats.values.hpMax = (blueprintStats.values.level || 1) * 32.7; if (!blueprintStats.values.hp) @@ -65,10 +65,10 @@ module.exports = { obj.addComponent('spellbook'); obj.addComponent('dialogue'); - obj.addComponent('trade', character.components.find(c => c.type == 'trade')); - obj.addComponent('reputation', character.components.find(c => c.type == 'reputation')); + obj.addComponent('trade', character.components.find(c => c.type === 'trade')); + obj.addComponent('reputation', character.components.find(c => c.type === 'reputation')); - let social = character.components.find(c => c.type == 'social'); + let social = character.components.find(c => c.type === 'social'); if (social) delete social.party; obj.addComponent('social', social); @@ -82,7 +82,7 @@ module.exports = { items: character.stash }); - let blueprintEffects = character.components.find(c => c.type == 'effects') || {}; + let blueprintEffects = character.components.find(c => c.type === 'effects') || {}; if (blueprintEffects.effects) { //Calculate ttl of effects let time = +new Date(); @@ -97,15 +97,15 @@ module.exports = { } obj.addComponent('effects', blueprintEffects); - let prophecies = character.components.find(c => c.type == 'prophecies'); + let prophecies = character.components.find(c => c.type === 'prophecies'); if (prophecies) obj.addComponent('prophecies', prophecies); - obj.addComponent('equipment', character.components.find(c => c.type == 'equipment')); - obj.addComponent('inventory', character.components.find(c => c.type == 'inventory')); - obj.addComponent('passives', character.components.find(c => c.type == 'passives')); - obj.addComponent('quests', character.components.find(c => c.type == 'quests')); - obj.addComponent('events', character.components.find(c => c.type == 'events')); + obj.addComponent('equipment', character.components.find(c => c.type === 'equipment')); + obj.addComponent('inventory', character.components.find(c => c.type === 'inventory')); + obj.addComponent('passives', character.components.find(c => c.type === 'passives')); + obj.addComponent('quests', character.components.find(c => c.type === 'quests')); + obj.addComponent('events', character.components.find(c => c.type === 'events')); obj.xp = stats.values.xp; obj.level = stats.values.level; @@ -150,7 +150,7 @@ module.exports = { this.seen.push(id); }, unsee: function (id) { - this.seen.spliceWhere(s => s == id); + this.seen.spliceWhere(s => s === id); }, die: function (source, permadeath) { @@ -167,10 +167,10 @@ module.exports = { let level = this.obj.stats.values.level; let spawns = this.obj.spawn; let spawnPos = spawns.filter(s => (((s.maxLevel) && (s.maxLevel >= level)) || (!s.maxLevel))); - if ((spawnPos.length == 0) || (!source.name)) + if ((spawnPos.length === 0) || (!source.name)) spawnPos = spawns[0]; else if (source.name) { - let sourceSpawnPos = spawnPos.find(s => ((s.source) && (s.source.toLowerCase() == source.name.toLowerCase()))); + let sourceSpawnPos = spawnPos.find(s => ((s.source) && (s.source.toLowerCase() === source.name.toLowerCase()))); if (sourceSpawnPos) spawnPos = sourceSpawnPos; else diff --git a/src/server/components/prophecies.js b/src/server/components/prophecies.js index 0e56de4c..e8e0e209 100644 --- a/src/server/components/prophecies.js +++ b/src/server/components/prophecies.js @@ -12,23 +12,23 @@ module.exports = { console.log(e); } - if (template == null) + if (template === null) return; - else if (this.list.some(l => (l.type == p))) + else if (this.list.some(l => (l.type === p))) return; - let p = extend(true, {}, template); - p.obj = this.obj; - p.init(); + let prophecy = extend(true, {}, template); + prophecy.obj = this.obj; + prophecy.init(); - this.list.push(p); + this.list.push(prophecy); }, this); delete blueprint.list; }, hasProphecy: function (type) { - return this.list.some(l => (l.type == type)); + return this.list.some(l => (l.type === type)); }, transfer: function () { diff --git a/src/server/components/quests.js b/src/server/components/quests.js index c1ca3af7..d60fb361 100644 --- a/src/server/components/quests.js +++ b/src/server/components/quests.js @@ -24,23 +24,23 @@ module.exports = { }, obtain: function (quest, hideMessage) { - quest.active = (this.obj.zoneName == quest.zoneName); + quest.active = (this.obj.zoneName === quest.zoneName); this.quests.push(quest); if (!quest.init(hideMessage)) { - this.quests.spliceWhere(q => (q == quest)); + this.quests.spliceWhere(q => (q === quest)); return false; } return true; }, complete: function (id) { - let quest = this.quests.find(q => q.id == id); + let quest = this.quests.find(q => q.id === id); if ((!quest) || (!quest.isReady)) return; quest.complete(); - this.quests.spliceWhere(q => q == quest); + this.quests.spliceWhere(q => q === quest); this.obj.instance.questBuilder.obtain(this.obj); }, diff --git a/src/server/components/reputation.js b/src/server/components/reputation.js index d400dd60..37707b9c 100644 --- a/src/server/components/reputation.js +++ b/src/server/components/reputation.js @@ -36,7 +36,7 @@ module.exports = { factionBlueprint = factions.getFaction(factionId); } catch (e) {} - if (factionBlueprint == null) { + if (factionBlueprint === null) { console.log('No faction blueprint found'); return; } @@ -49,10 +49,10 @@ module.exports = { }, getTier: function (factionId) { - let faction = this.list.find(l => l.id == factionId); + let faction = this.list.find(l => l.id === factionId); if (!faction) { this.discoverFaction(factionId); - faction = this.list.find(l => l.id == factionId); + faction = this.list.find(l => l.id === factionId); } return (faction || { @@ -75,7 +75,7 @@ module.exports = { calculateTier: function (factionId) { let blueprint = this.getBlueprint(factionId); - let faction = this.list.find(l => l.id == factionId); + let faction = this.list.find(l => l.id === factionId); let rep = faction.rep; let tier = 0; @@ -87,7 +87,7 @@ module.exports = { if (t.rep > rep) break; - else if (i == tLen - 1) + else if (i === tLen - 1) tier = i; } @@ -100,10 +100,10 @@ module.exports = { }, getReputation: function (factionId, gain) { - let fullSync = (this.factions[factionId] == null); + let fullSync = (this.factions[factionId] === null); let blueprint = this.getBlueprint(factionId); - let faction = this.list.find(l => l.id == factionId); + let faction = this.list.find(l => l.id === factionId); if (!faction) { this.list.push({ id: factionId, @@ -125,13 +125,13 @@ module.exports = { this.obj.instance.syncer.queue('onGetMessages', { id: this.obj.id, messages: [{ - class: (action == 'gained') ? 'color-greenB' : 'color-redA', + class: (action === 'gained') ? 'color-greenB' : 'color-redA', message: 'you ' + action + ' ' + Math.abs(gain) + ' reputation with ' + blueprint.name, type: 'rep' }] }, [this.obj.serverId]); - if (faction.tier != oldTier) { + if (faction.tier !== oldTier) { this.sendMessage(blueprint.tiers[faction.tier].name, blueprint.name, (faction.tier > oldTier)); this.obj.equipment.unequipFactionGear(faction.id, faction.tier); } @@ -151,10 +151,10 @@ module.exports = { }, discoverFaction (factionId) { - if (this.list.some(l => l.id == factionId)) + if (this.list.some(l => l.id === factionId)) return; - let fullSync = (this.factions[factionId] == null); + let fullSync = (this.factions[factionId] === null); let blueprint = this.getBlueprint(factionId); if (!blueprint) @@ -209,7 +209,7 @@ module.exports = { }, syncFaction: function (factionId, full) { - let l = this.list.find(l => (l.id == factionId)); + let l = this.list.find(l => (l.id === factionId)); let faction = { id: factionId, rep: l.rep, diff --git a/src/server/components/social.js b/src/server/components/social.js index b104e791..1541d38e 100644 --- a/src/server/components/social.js +++ b/src/server/components/social.js @@ -60,7 +60,7 @@ module.exports = { let message = msg.data.message.substr(1); this.party.forEach(function (p) { - let player = cons.players.find(c => c.id == p); + let player = cons.players.find(c => c.id === p); player.socket.emit('events', { onGetMessages: [{ @@ -134,7 +134,7 @@ module.exports = { if (!msg.data.message) return; - if (msg.data.message.trim() == '') + if (msg.data.message.trim() === '') return; this.onBeforeChat(msg.data); @@ -156,7 +156,7 @@ module.exports = { history.spliceWhere(h => ((time - h.time) > 5000)); if (history.length > 0) { - if (history[history.length - 1].msg == messageString) { + if (history[history.length - 1].msg === messageString) { this.sendMessage('You have already sent that message', 'color-redA'); return; } else if (history.length >= 3) { @@ -180,10 +180,10 @@ module.exports = { }; events.emit('onBeforeSendMessage', msgEvent); messageString = msgEvent.msg; - if (messageString[0] == '@') { + if (messageString[0] === '@') { let playerName = ''; //Check if there's a space in the name - if (messageString[1] == "'") { + if (messageString[1] === "'") { playerName = messageString.substring(2, messageString.indexOf("'", 2)); messageString = messageString.replace("@'" + playerName + "' ", ''); } else { @@ -191,10 +191,10 @@ module.exports = { messageString = messageString.replace('@' + playerName + ' ', ''); } - if (playerName == this.obj.name) + if (playerName === this.obj.name) return; - let target = cons.players.find(p => p.name == playerName); + let target = cons.players.find(p => p.name === playerName); if (!target) return; @@ -219,9 +219,9 @@ module.exports = { }] } }); - } else if (messageString[0] == '$') + } else if (messageString[0] === '$') this.sendCustomChannelMessage(msg); - else if (messageString[0] == '%') + else if (messageString[0] === '%') this.sendPartyMessage(msg); else { let prefix = roles.getRoleMessagePrefix(this.obj) || ''; @@ -255,10 +255,10 @@ module.exports = { let obj = this.obj; let sourceId = msg.data.sourceId; - if (sourceId == obj.id) + if (sourceId === obj.id) return; - let source = cons.players.find(c => c.id == sourceId); + let source = cons.players.find(c => c.id === sourceId); if (!source) return; @@ -274,7 +274,7 @@ module.exports = { //This gets called on the player that initiated the invite acceptInvite: function (msg) { let sourceId = msg.data.sourceId; - let source = cons.players.find(c => c.id == sourceId); + let source = cons.players.find(c => c.id === sourceId); if (!source) return; @@ -291,12 +291,12 @@ module.exports = { this.updatePartyOnThread(); this.party.forEach(function (p) { - let player = cons.players.find(c => c.id == p); + let player = cons.players.find(c => c.id === p); player.social.party = this.party; player.social.updatePartyOnThread(); let msg = source.name + ' has joined the party'; - if (p == sourceId) + if (p === sourceId) msg = 'you have joined a party'; player.social.sendMessage(msg, 'color-yellowB'); @@ -309,7 +309,7 @@ module.exports = { }, declineInvite: function (msg) { let targetId = msg.data.targetId; - let target = cons.players.find(c => c.id == targetId); + let target = cons.players.find(c => c.id === targetId); if (!target) return; @@ -320,17 +320,17 @@ module.exports = { leaveParty: function (msg) { let name = this.obj.name; - this.party.spliceWhere(p => p == this.obj.id); + this.party.spliceWhere(p => p === this.obj.id); this.party.forEach(function (p) { - let player = cons.players.find(c => c.id == p); + let player = cons.players.find(c => c.id === p); let messages = [{ class: 'q0', message: name + ' has left the party' }]; let party = this.party; - if (this.party.length == 1) { + if (this.party.length === 1) { messages.push({ class: 'q0', message: 'your group has been disbanded' @@ -369,14 +369,14 @@ module.exports = { }); if ((this.isPartyLeader) && (this.party.length >= 2)) { - let newLeader = cons.players.find(c => c.id == this.party[0]).social; + let newLeader = cons.players.find(c => c.id === this.party[0]).social; newLeader.isPartyLeader = true; this.party.forEach(function (p) { let msg = newLeader.obj.name + ' is now the party leader'; - if (p == newLeader.obj.id) + if (p === newLeader.obj.id) msg = 'you are now the party leader'; - cons.players.find(c => c.id == p).socket.emit('events', { + cons.players.find(c => c.id === p).socket.emit('events', { onGetMessages: [{ messages: [{ class: 'q0', @@ -398,14 +398,14 @@ module.exports = { return; } - let target = cons.players.find(c => c.id == msg.data); + let target = cons.players.find(c => c.id === msg.data); if (!target) return; - this.party.spliceWhere(p => p == target.id); + this.party.spliceWhere(p => p === target.id); this.party.forEach(function (p) { - cons.players.find(c => c.id == p) + cons.players.find(c => c.id === p) .socket.emit('events', { onGetParty: [this.party], onGetMessages: [{ @@ -431,7 +431,7 @@ module.exports = { target.social.isPartyLeader = false; target.social.updatePartyOnThread(); - if (this.party.length == 1) { + if (this.party.length === 1) { this.party = null; this.isPartyLeader = null; this.updatePartyOnThread(); diff --git a/src/server/components/spellbook.js b/src/server/components/spellbook.js index 0869e48a..474efc46 100644 --- a/src/server/components/spellbook.js +++ b/src/server/components/spellbook.js @@ -100,9 +100,9 @@ module.exports = { let sheetName = this.obj.sheetName || '../../../images/characters.png'; let animationName = builtSpell.animation; - if (sheetName == 'mobs') + if (sheetName === 'mobs') animation = animations.mobs; - else if (sheetName == 'bosses') + else if (sheetName === 'bosses') animation = animations.bosses; else if (sheetName.indexOf('/') > -1) animation = animations.mobs[sheetName]; @@ -116,12 +116,12 @@ module.exports = { builtSpell.animation = null; } - if ((this.closestRange == -1) || (builtSpell.range < this.closestRange)) + if ((this.closestRange === -1) || (builtSpell.range < this.closestRange)) this.closestRange = builtSpell.range; - if ((this.furthestRange == -1) || (builtSpell.range > this.furthestRange)) + if ((this.furthestRange === -1) || (builtSpell.range > this.furthestRange)) this.furthestRange = builtSpell.range; - if ((options.id == null) && (spellId == null)) { + if ((options.id === null) && (spellId === null)) { spellId = 0; this.spells.forEach(function (s) { if (s.id >= spellId) @@ -129,7 +129,7 @@ module.exports = { }); } - builtSpell.id = (options.id == null) ? spellId : options.id; + builtSpell.id = (options.id === null) ? spellId : options.id; this.spells.push(builtSpell); this.spells.sort(function (a, b) { return (a.id - b.id); @@ -147,7 +147,7 @@ module.exports = { addSpellFromRune: function (runeSpell, spellId) { let type = runeSpell.type; - let playerSpell = playerSpells.spells.find(s => (s.name.toLowerCase() == runeSpell.name.toLowerCase())) || playerSpells.spells.find(s => (s.type == type)); + let playerSpell = playerSpells.spells.find(s => (s.name.toLowerCase() === runeSpell.name.toLowerCase())) || playerSpells.spells.find(s => (s.type === type)); let playerSpellConfig = playerSpellsConfig.spells[runeSpell.name.toLowerCase()] || playerSpellsConfig.spells[runeSpell.type]; if (!playerSpellConfig) return -1; @@ -167,7 +167,7 @@ module.exports = { let roll = runeSpell.rolls[r] || 0; runeSpell.rolls[r] = roll; - let int = r.indexOf('i_') == 0; + let int = r.indexOf('i_') === 0; let val = range[0] + ((range[1] - range[0]) * roll); if (int) { @@ -200,7 +200,7 @@ module.exports = { }, removeSpellById: function (id) { - let exists = this.spells.spliceFirstWhere(s => (s.id == id)); + let exists = this.spells.spliceFirstWhere(s => (s.id === id)); if (exists) { if ((exists.manaReserve) && (exists.active)) { @@ -214,7 +214,7 @@ module.exports = { exists.unlearn && exists.unlearn(); this.obj.syncer.setArray(true, 'spellbook', 'removeSpells', id); - this.auto.spliceWhere(a => a.spell == id); + this.auto.spliceWhere(a => a.spell === id); } }, @@ -222,7 +222,7 @@ module.exports = { if (!action.auto) return true; - let exists = this.auto.find(a => (a.spell == action.spell)); + let exists = this.auto.find(a => (a.spell === action.spell)); if (!exists) { this.auto.push({ spell: action.spell, @@ -244,12 +244,12 @@ module.exports = { return null; }, cast: function (action, isAuto) { - if (action.spell == null) { + if (action.spell === null) { this.auto = []; return true; } - let spell = this.spells.find(s => (s.id == action.spell)); + let spell = this.spells.find(s => (s.id === action.spell)); if (!spell) return false; @@ -261,22 +261,22 @@ module.exports = { x: this.obj.x, y: this.obj.y }; - } else if (spell.spellType == 'buff') + } else if (spell.spellType === 'buff') action.target = this.obj; } if ((!spell.aura) && (!spell.targetGround)) { //Did we pass in the target id? - if ((action.target != null) && (action.target.id == null)) { - action.target = this.objects.objects.find(o => o.id == action.target); + if ((action.target !== null) && (action.target.id === null)) { + action.target = this.objects.objects.find(o => o.id === action.target); if (!action.target) return false; } - if ((action.target == this.obj) && (spell.noTargetSelf)) + if ((action.target === this.obj) && (spell.noTargetSelf)) action.target = null; - if ((action.target == null) || (!action.target.player)) { + if ((action.target === null) || (!action.target.player)) { if (spell.autoTargetFollower) { action.target = this.spells.find(s => (s.minions) && (s.minions.length > 0)); if (action.target) @@ -286,8 +286,8 @@ module.exports = { } } - if (spell.spellType == 'buff') { - if (this.obj.aggro.faction != action.target.aggro.faction) + if (spell.spellType === 'buff') { + if (this.obj.aggro.faction !== action.target.aggro.faction) return; } else if ((action.target.aggro) && (!this.obj.aggro.canAttack(action.target))) { if (this.obj.player) @@ -326,7 +326,7 @@ module.exports = { } else this.obj.stats.addStat('manaReservePercent', -reserve.percentage); } - } else if (spell.range != null) { + } else if (spell.range !== null) { //Distance Check let fromX = this.obj.x; let fromY = this.obj.y; @@ -380,7 +380,7 @@ module.exports = { cd: spell.cdMax }; - let isAttack = (spell.type == 'melee'); + let isAttack = (spell.type === 'melee'); if ((Math.random() * 100) < stats[isAttack ? 'attackSpeed' : 'castSpeed']) cd.cd = 1; @@ -420,7 +420,7 @@ module.exports = { if ((spell.range > furthest) && (spell.canCast())) furthest = spell.range; } - if (furthest == 0) + if (furthest === 0) furthest = this.furthestRange; return furthest; @@ -432,7 +432,7 @@ module.exports = { s => cds.push({ cd: s.cd, cdMax: s.cdMax, - canCast: ((s.manaCost <= this.obj.stats.values.mana) && (s.cd == 0)) + canCast: ((s.manaCost <= this.obj.stats.values.mana) && (s.cd === 0)) }), this); return cds; @@ -512,9 +512,9 @@ module.exports = { let match = false; if (!target) - match = (c.sourceId == sourceId); + match = (c.sourceId === sourceId); else - match = (c.targetId == sourceId); + match = (c.targetId === sourceId); if (match) { if (c.destroyCallback) @@ -555,7 +555,7 @@ module.exports = { callback.apply(s, args); } - if (s.castEvent == event) + if (s.castEvent === event) s.cast(); } }, diff --git a/src/server/components/stash.js b/src/server/components/stash.js index 5e1cebce..0b0a9fc5 100644 --- a/src/server/components/stash.js +++ b/src/server/components/stash.js @@ -20,7 +20,7 @@ module.exports = { //Material? let exists = false; if (((item.material) || (item.quest) || (item.quantity)) && (!item.noStack) && (!item.uses)) { - let existItem = this.items.find(i => i.name == item.name); + let existItem = this.items.find(i => i.name === item.name); if (existItem) { exists = true; if (!existItem.quantity) @@ -64,11 +64,11 @@ module.exports = { }, destroyItem: function (id) { - let item = this.items.find(i => i.id == id); + let item = this.items.find(i => i.id === id); if (!item) return; - this.items.spliceWhere(i => i == item); + this.items.spliceWhere(i => i === item); this.obj.syncer.setArray(true, 'stash', 'destroyItems', id); @@ -79,12 +79,12 @@ module.exports = { if (!this.active) return; - let item = this.items.find(i => i.id == id); + let item = this.items.find(i => i.id === id); if (!item) return; this.obj.inventory.getItem(item); - this.items.spliceWhere(i => i == item); + this.items.spliceWhere(i => i === item); this.obj.syncer.setArray(true, 'stash', 'destroyItems', id); diff --git a/src/server/components/stats.js b/src/server/components/stats.js index d13db315..4ae0203f 100644 --- a/src/server/components/stats.js +++ b/src/server/components/stats.js @@ -189,10 +189,10 @@ module.exports = { addStat: function (stat, value) { let values = this.values; - if (['lvlRequire', 'allAttributes'].indexOf(stat) == -1) + if (['lvlRequire', 'allAttributes'].indexOf(stat) === -1) values[stat] += value; - let sendOnlyToSelf = (['hp', 'hpMax', 'mana', 'manaMax', 'vit'].indexOf(stat) == -1); + let sendOnlyToSelf = (['hp', 'hpMax', 'mana', 'manaMax', 'vit'].indexOf(stat) === -1); this.obj.syncer.setObject(sendOnlyToSelf, 'stats', 'values', stat, values[stat]); if (sendOnlyToSelf) @@ -206,27 +206,27 @@ module.exports = { let morphStat = stat.substr(3); morphStat = morphStat[0].toLowerCase() + morphStat.substr(1); this.addStat(morphStat, value); - } else if (stat == 'vit') + } else if (stat === 'vit') this.addStat('hpMax', (value * this.statScales.vitToHp)); - else if (stat == 'allAttributes') { + else if (stat === 'allAttributes') { ['int', 'str', 'dex'].forEach(function (s) { this.addStat(s, value); }, this); - } else if (stat == 'elementAllResist') { + } else if (stat === 'elementAllResist') { ['arcane', 'frost', 'fire', 'holy', 'poison'].forEach(function (s) { let element = 'element' + (s[0].toUpperCase() + s.substr(1)) + 'Resist'; this.addStat(element, value); }, this); - } else if (stat == 'elementPercent') { + } else if (stat === 'elementPercent') { ['arcane', 'frost', 'fire', 'holy', 'poison'].forEach(function (s) { let element = 'element' + (s[0].toUpperCase() + s.substr(1)) + 'Percent'; this.addStat(element, value); }, this); - } else if (stat == 'str') + } else if (stat === 'str') this.addStat('armor', (value * this.statScales.strToArmor)); - else if (stat == 'int') + else if (stat === 'int') this.addStat('manaMax', (value * this.statScales.intToMana)); - else if (stat == 'dex') + else if (stat === 'dex') this.addStat('dodgeAttackChance', (value * this.statScales.dexToDodge)); this.obj.equipment.unequipAttrRqrGear(); @@ -245,7 +245,7 @@ module.exports = { let obj = this.obj; let values = this.values; - if (values.level == 20) + if (values.level === 20) return; let xpEvent = { @@ -255,7 +255,7 @@ module.exports = { }; this.obj.fireEvent('beforeGetXp', xpEvent); - if (xpEvent.amount == 0) + if (xpEvent.amount === 0) return; amount = ~~(xpEvent.amount * (1 + (values.xpIncrease / 100))); @@ -283,7 +283,7 @@ module.exports = { this.obj.fireEvent('onLevelUp', this.values.level); - if (values.level == 20) + if (values.level === 20) values.xp = 0; values.hpMax = values.level * 32.7; @@ -393,7 +393,6 @@ module.exports = { obj.syncer.set(true, null, 'dead', true); - let obj = obj; let syncO = obj.syncer.o; obj.hidden = true; @@ -484,9 +483,9 @@ module.exports = { this.values.hp -= amount; let recipients = []; - if (this.obj.serverId != null) + if (this.obj.serverId !== null) recipients.push(this.obj.serverId); - if (source.serverId != null) + if (source.serverId !== null) recipients.push(source.serverId); if ((source.follower) && (source.follower.master.serverId)) recipients.push(source.follower.master.serverId); @@ -574,7 +573,7 @@ module.exports = { for (let i = 0; i < aLen; i++) { let a = aggroList[i]; - if ((!a.threat) || (a.obj.serverId == null)) + if ((!a.threat) || (a.obj.serverId === null)) continue; this.obj.inventory.dropBag(a.obj.serverId, killSource); @@ -593,7 +592,7 @@ module.exports = { getHp: function (heal, source) { let amount = heal.amount; - if (amount == 0) + if (amount === 0) return; let threatMult = heal.threatMult; @@ -614,9 +613,9 @@ module.exports = { values.hp = hpMax; let recipients = []; - if (this.obj.serverId != null) + if (this.obj.serverId !== null) recipients.push(this.obj.serverId); - if (source.serverId != null) + if (source.serverId !== null) recipients.push(source.serverId); if (recipients.length > 0) { this.syncer.queue('onGetDamage', { @@ -707,7 +706,7 @@ module.exports = { if (!lootStats) this.stats.lootStats[mob.name] = time; else - return ((lootStats.day != time.day), (lootStats.month != time.month)); + return ((lootStats.day !== time.day), (lootStats.month !== time.month)); }, events: { @@ -722,7 +721,7 @@ module.exports = { mobKillStreaks[mobName]++; for (let p in mobKillStreaks) { - if (p == mobName) + if (p === mobName) continue; mobKillStreaks[p]--; diff --git a/src/server/components/syncer.js b/src/server/components/syncer.js index 1e43ed60..3627f764 100644 --- a/src/server/components/syncer.js +++ b/src/server/components/syncer.js @@ -21,8 +21,8 @@ module.exports = { o = this.oSelf; let keys = Object.keys(o); - if (o.components.length == 0) { - if (keys.length == 1) + if (o.components.length === 0) { + if (keys.length === 1) return null; delete o.components; } @@ -37,7 +37,7 @@ module.exports = { o = this.oSelf; if (cpnType) { - let cpn = o.components.find(c => (c.type == cpnType)); + let cpn = o.components.find(c => (c.type === cpnType)); if (!cpn) { cpn = { @@ -54,7 +54,7 @@ module.exports = { let o = this.o; if (self) o = this.oSelf; - let cpn = o.components.find(c => (c.type == cpnType)); + let cpn = o.components.find(c => (c.type === cpnType)); if (!cpn) { cpn = { @@ -75,7 +75,7 @@ module.exports = { let o = this.o; if (self) o = this.oSelf; - let cpn = o.components.find(c => (c.type == cpnType)); + let cpn = o.components.find(c => (c.type === cpnType)); if (!cpn) { cpn = { @@ -84,10 +84,10 @@ module.exports = { o.components.push(cpn); } - if (cpn[property] == null) + if (cpn[property] === null) cpn[property] = []; - if ((noDuplicate) && (cpn[property].find(f => (f == value)))) + if ((noDuplicate) && (cpn[property].find(f => (f === value)))) return; cpn[property].push(value); @@ -98,7 +98,7 @@ module.exports = { if (self) o = this.oSelf; - if (o[property] == null) + if (o[property] === null) o[property] = []; o[property].push(value); @@ -110,7 +110,7 @@ module.exports = { o = this.oSelf; if (cpnType) { - let cpn = o.components.find(c => (c.type == cpnType)); + let cpn = o.components.find(c => (c.type === cpnType)); if (!cpn) return; diff --git a/src/server/components/trade.js b/src/server/components/trade.js index b2a079f7..e958d957 100644 --- a/src/server/components/trade.js +++ b/src/server/components/trade.js @@ -31,7 +31,7 @@ module.exports = { id = checkItem.id + 1; }); - if (item.type == 'skin') { + if (item.type === 'skin') { let skinBlueprint = skins.getBlueprint(item.id); item.name = skinBlueprint.name; item.sprite = skinBlueprint.sprite; @@ -80,13 +80,13 @@ module.exports = { startBuy: function (msg) { let target = msg.target; - if ((target == null) && (!msg.targetName)) + if ((target === null) && (!msg.targetName)) return false; - if ((target != null) && (target.id == null)) - target = this.obj.instance.objects.objects.find(o => o.id == target); + if ((target !== null) && (target.id === null)) + target = this.obj.instance.objects.objects.find(o => o.id === target); else if (msg.targetName) - target = this.obj.instance.objects.objects.find(o => ((o.name) && (o.name.toLowerCase() == msg.targetName.toLowerCase()))); + target = this.obj.instance.objects.objects.find(o => ((o.name) && (o.name.toLowerCase() === msg.targetName.toLowerCase()))); this.target = null; @@ -98,7 +98,7 @@ module.exports = { let itemList = target.trade.getItems(this.obj); let markup = target.trade.markup.sell; - if (msg.action == 'buyback') { + if (msg.action === 'buyback') { itemList = target.trade.buyback[this.obj.name] || []; markup = target.trade.markup.buy; } @@ -106,16 +106,16 @@ module.exports = { this.obj.syncer.set(true, 'trade', 'buyList', { markup: markup, items: itemList, - buyback: (msg.action == 'buyback') + buyback: (msg.action === 'buyback') }); }, buySell: function (msg) { - if (msg.action == 'buy') + if (msg.action === 'buy') this.buy(msg); - else if (msg.action == 'sell') + else if (msg.action === 'sell') this.sell(msg); - else if (msg.action == 'buyback') + else if (msg.action === 'buyback') this.buyback(msg); }, @@ -128,7 +128,7 @@ module.exports = { let targetTrade = target.trade; let markup = targetTrade.markup.sell; - if (msg.action == 'buyback') { + if (msg.action === 'buyback') { item = targetTrade.findBuyback(msg.itemId, this.obj.name); markup = targetTrade.markup.buy; } else @@ -141,7 +141,7 @@ module.exports = { let canAfford = false; if (item.worth.currency) { - let currencyItem = this.obj.inventory.items.find(i => (i.name == item.worth.currency)); + let currencyItem = this.obj.inventory.items.find(i => (i.name === item.worth.currency)); canAfford = ((currencyItem) && (currencyItem.quantity >= item.worth.amount)); } else canAfford = this.gold >= ~~(item.worth * markup); @@ -165,7 +165,7 @@ module.exports = { return; } - if (item.type == 'skin') { + if (item.type === 'skin') { let haveSkin = this.obj.auth.doesOwnSkin(item.skinId); if (haveSkin) { @@ -183,13 +183,13 @@ module.exports = { } } - if (msg.action == 'buyback') + if (msg.action === 'buyback') targetTrade.removeBuyback(msg.itemId, this.obj.name); - else if ((item.type != 'skin') && (!item.infinite)) + else if ((item.type !== 'skin') && (!item.infinite)) targetTrade.removeItem(msg.itemId, this.obj.name); if (item.worth.currency) { - let currencyItem = this.obj.inventory.items.find(i => (i.name == item.worth.currency)); + let currencyItem = this.obj.inventory.items.find(i => (i.name === item.worth.currency)); this.obj.inventory.destroyItem(currencyItem.id, item.worth.amount, true); } else { targetTrade.gold += ~~(item.worth * markup); @@ -197,7 +197,7 @@ module.exports = { this.obj.syncer.set(true, 'trade', 'gold', this.gold); } - if (item.type != 'skin') { + if (item.type !== 'skin') { if (!item.infinite) this.obj.syncer.setArray(true, 'trade', 'removeItems', item.id); @@ -276,13 +276,13 @@ module.exports = { let target = msg.target; let targetName = (msg.targetName || '').toLowerCase(); - if ((target == null) && (!targetName)) + if ((target === null) && (!targetName)) return false; - if ((target != null) && (target.id == null)) - target = this.obj.instance.objects.objects.find(o => o.id == target); - else if (targetName != null) - target = this.obj.instance.objects.objects.find(o => ((o.name) && (o.name.toLowerCase() == targetName))); + if ((target !== null) && (target.id === null)) + target = this.obj.instance.objects.objects.find(o => o.id === target); + else if (targetName !== null) + target = this.obj.instance.objects.objects.find(o => ((o.name) && (o.name.toLowerCase() === targetName))); this.target = null; @@ -330,11 +330,11 @@ module.exports = { }, removeItem: function (itemId) { - return this.items.spliceFirstWhere(i => i.id == itemId); + return this.items.spliceFirstWhere(i => i.id === itemId); }, removeBuyback: function (itemId, name) { - return (this.buyback[name] || []).spliceFirstWhere(i => i.id == itemId); + return (this.buyback[name] || []).spliceFirstWhere(i => i.id === itemId); }, getItems: function (requestedBy) { @@ -372,18 +372,18 @@ module.exports = { }, findItem: function (itemId, sourceName) { - return this.items.find(i => i.id == itemId); + return this.items.find(i => i.id === itemId); }, findBuyback: function (itemId, sourceName) { - return (this.buyback[sourceName] || []).find(i => i.id == itemId); + return (this.buyback[sourceName] || []).find(i => i.id === itemId); }, resolveCallback: function (msg, result) { - let callbackId = (msg.callbackId != null) ? msg.callbackId : msg; + let callbackId = (msg.callbackId !== null) ? msg.callbackId : msg; result = result || []; - if (callbackId == null) + if (callbackId === null) return; process.send({ diff --git a/src/server/components/wardrobe.js b/src/server/components/wardrobe.js index 3fda1081..b4fd8daa 100644 --- a/src/server/components/wardrobe.js +++ b/src/server/components/wardrobe.js @@ -68,10 +68,10 @@ module.exports = { }, open: function (msg) { - if (msg.sourceId == null) + if (msg.sourceId === null) return; - let obj = this.obj.instance.objects.objects.find(o => o.serverId == msg.sourceId); + let obj = this.obj.instance.objects.objects.find(o => o.serverId === msg.sourceId); if ((!obj) || (!obj.player)) return; @@ -85,7 +85,7 @@ module.exports = { }, apply: function (msg) { - let obj = this.obj.instance.objects.objects.find(o => o.serverId == msg.sourceId); + let obj = this.obj.instance.objects.objects.find(o => o.serverId === msg.sourceId); if (!obj) return; diff --git a/src/server/config/effects/effectTemplate.js b/src/server/config/effects/effectTemplate.js index d3378ed9..9ebc7bdd 100644 --- a/src/server/config/effects/effectTemplate.js +++ b/src/server/config/effects/effectTemplate.js @@ -6,7 +6,7 @@ module.exports = { let values = {}; for (let p in this) { let value = this[p]; - if ((typeof(value) == 'function') || (p == 'obj') || (p == 'events')) + if ((typeof(value) === 'function') || (p === 'obj') || (p === 'events')) continue; values[p] = value; diff --git a/src/server/config/eventPhases/phaseEventChain.js b/src/server/config/eventPhases/phaseEventChain.js index 648885d0..aaa9f152 100644 --- a/src/server/config/eventPhases/phaseEventChain.js +++ b/src/server/config/eventPhases/phaseEventChain.js @@ -9,7 +9,7 @@ module.exports = { }, update: function () { - if (this.cd == 0) { + if (this.cd === 0) { if (this.state < this.config.length - 1) { this.state++; let stateConfig = this.config[this.state]; @@ -41,7 +41,7 @@ module.exports = { events: { mobTalk: function (config) { - let mob = this.instance.objects.objects.find(o => (o.id == config.id)); + let mob = this.instance.objects.objects.find(o => (o.id === config.id)); let text = (config.text instanceof Array) ? config.text[config.oldRepeat - config.repeat - 1] : config.text; if (config.zone) { @@ -70,7 +70,7 @@ module.exports = { let mLen = mobs.length; for (let i = 0; i < mLen; i++) { - let mob = objects.find(o => (o.id == mobs[i])); + let mob = objects.find(o => (o.id === mobs[i])); for (let j = 0; j < cLen; j++) { let c = components[j]; mob.addComponent(c.type, components[j]); @@ -91,7 +91,7 @@ module.exports = { let mLen = mobs.length; for (let i = 0; i < mLen; i++) { - let mob = objects.find(o => (o.id == mobs[i])); + let mob = objects.find(o => (o.id === mobs[i])); for (let j = 0; j < cLen; j++) mob.removeComponent(components[j]); } diff --git a/src/server/config/eventPhases/phaseKillMob.js b/src/server/config/eventPhases/phaseKillMob.js index 8481ab49..c8d7bdd8 100644 --- a/src/server/config/eventPhases/phaseKillMob.js +++ b/src/server/config/eventPhases/phaseKillMob.js @@ -30,7 +30,7 @@ module.exports = { for (let i = 0; i < oLen; i++) { let o = objects[i]; let index = mobs.indexOf(o.id); - if (index == -1) + if (index === -1) continue; if (percentage) { @@ -52,7 +52,7 @@ module.exports = { let m = mobs[i]; let destroyed = m.destroyed; if (!destroyed) { - let deathStopper = m.components.find(c => (c.type == 'deathStopper')); + let deathStopper = m.components.find(c => (c.type === 'deathStopper')); if (deathStopper) destroyed = deathStopper.end; } @@ -64,7 +64,7 @@ module.exports = { } } - if (mobs.length == 0) + if (mobs.length === 0) this.end = true; } }; diff --git a/src/server/config/eventPhases/phaseLocateMob.js b/src/server/config/eventPhases/phaseLocateMob.js index b0cb95e0..6427f16c 100644 --- a/src/server/config/eventPhases/phaseLocateMob.js +++ b/src/server/config/eventPhases/phaseLocateMob.js @@ -12,7 +12,7 @@ module.exports = { for (let i = 0; i < oLen; i++) { let o = objects[i]; let index = mobs.indexOf(o.id); - if (index == -1) + if (index === -1) continue; mobs.splice(index, 1, o); @@ -44,7 +44,7 @@ module.exports = { } } - if (mobs.length == 0) + if (mobs.length === 0) this.end = true; } }; diff --git a/src/server/config/eventPhases/phaseModifyDialogue.js b/src/server/config/eventPhases/phaseModifyDialogue.js index 6c317261..411e26ce 100644 --- a/src/server/config/eventPhases/phaseModifyDialogue.js +++ b/src/server/config/eventPhases/phaseModifyDialogue.js @@ -1,6 +1,6 @@ module.exports = { init: function () { - let mob = this.instance.objects.objects.find(m => (m.id == this.mobId)); + let mob = this.instance.objects.objects.find(m => (m.id === this.mobId)); let states = mob.dialogue.states; this.addStates(states, this.dialogue.add || {}); @@ -30,7 +30,7 @@ module.exports = { if (!target) continue; - else if (source == null) { + else if (source === null) { delete dialogue[s]; continue; } @@ -38,7 +38,7 @@ module.exports = { for (let o in source) { let targetOptions = target.msg[0].options; if (targetOptions.options) - targetOptions.spliceWhere(t => (t == o)); + targetOptions.spliceWhere(t => (t === o)); delete target.options[o]; } diff --git a/src/server/config/eventPhases/phaseSpawnMob.js b/src/server/config/eventPhases/phaseSpawnMob.js index 682f1a5a..fe3952ba 100644 --- a/src/server/config/eventPhases/phaseSpawnMob.js +++ b/src/server/config/eventPhases/phaseSpawnMob.js @@ -47,7 +47,7 @@ module.exports = { } if (l.exists) { - let mob = objects.objects.find(o => (o.name == l.name)); + let mob = objects.objects.find(o => (o.name === l.name)); mob.mob.walkDistance = 0; this.spawnAnimation(mob); mob.performMove({ diff --git a/src/server/config/factions/akarei.js b/src/server/config/factions/akarei.js index 842773a0..1326fb9c 100644 --- a/src/server/config/factions/akarei.js +++ b/src/server/config/factions/akarei.js @@ -21,7 +21,7 @@ module.exports = { let result = null; if (item.effects) - result = item.effects.find(e => (e.factionId == 'akarei')); + result = item.effects.find(e => (e.factionId === 'akarei')); if (!result) { if (!item.effects) @@ -53,7 +53,7 @@ module.exports = { if (!damage.crit) return; - let effect = item.effects.find(e => (e.factionId == 'akarei')); + let effect = item.effects.find(e => (e.factionId === 'akarei')); let roll = Math.random() * 100; if (roll >= effect.properties.chance) diff --git a/src/server/config/factions/anglers.js b/src/server/config/factions/anglers.js index 63de7d07..da64b888 100644 --- a/src/server/config/factions/anglers.js +++ b/src/server/config/factions/anglers.js @@ -15,7 +15,7 @@ module.exports = { let result = null; if (item.effects) - result = item.effects.find(e => (e.factionId == 'anglers')); + result = item.effects.find(e => (e.factionId === 'anglers')); if (!result) { if (!item.effects) @@ -42,7 +42,7 @@ module.exports = { events: { beforeGatherResource: function (item, gatherResult, source) { - let effect = item.effects.find(e => (e.factionId == 'anglers')); + let effect = item.effects.find(e => (e.factionId === 'anglers')); let roll = Math.random() * 100; if (roll >= effect.chance) diff --git a/src/server/config/factions/gaekatla.js b/src/server/config/factions/gaekatla.js index 442ff584..896ac8ab 100644 --- a/src/server/config/factions/gaekatla.js +++ b/src/server/config/factions/gaekatla.js @@ -18,7 +18,7 @@ module.exports = { let result = null; if (item.effects) - result = item.effects.find(e => (e.factionId == 'gaekatla')); + result = item.effects.find(e => (e.factionId === 'gaekatla')); if (!result) { if (!item.effects) @@ -50,7 +50,7 @@ module.exports = { events: { afterKillMob: function (item, mob) { - let effect = item.effects.find(e => (e.factionId == 'gaekatla')); + let effect = item.effects.find(e => (e.factionId === 'gaekatla')); let roll = Math.random() * 100; if (roll >= effect.chance) diff --git a/src/server/config/itemEffects/alwaysCrit.js b/src/server/config/itemEffects/alwaysCrit.js index 451a365b..3a219db6 100644 --- a/src/server/config/itemEffects/alwaysCrit.js +++ b/src/server/config/itemEffects/alwaysCrit.js @@ -1,13 +1,13 @@ module.exports = { events: { onGetText: function (item) { - let rolls = item.effects.find(e => (e.type == 'alwaysCrit')).rolls; + let rolls = item.effects.find(e => (e.type === 'alwaysCrit')).rolls; return 'your hits always crit'; }, onBeforeCalculateDamage: function (item, damage, target) { - let rolls = item.effects.find(e => (e.type == 'alwaysCrit')).rolls; + let rolls = item.effects.find(e => (e.type === 'alwaysCrit')).rolls; damage.crit = true; } diff --git a/src/server/config/itemEffects/damageSelf.js b/src/server/config/itemEffects/damageSelf.js index 180adae0..741ac3f2 100644 --- a/src/server/config/itemEffects/damageSelf.js +++ b/src/server/config/itemEffects/damageSelf.js @@ -5,13 +5,13 @@ module.exports = { element: null, onGetText: function (item) { - let rolls = item.effects.find(e => (e.type == 'damageSelf')).rolls; + let rolls = item.effects.find(e => (e.type === 'damageSelf')).rolls; return `you take ${rolls.percentage}% of the damage you deal`; }, afterDealDamage: function (item, damage, target) { - let effect = item.effects.find(e => (e.type == 'damageSelf')); + let effect = item.effects.find(e => (e.type === 'damageSelf')); let rolls = effect.rolls; let amount = (damage.dealt / 100) * rolls.percentage; diff --git a/src/server/config/itemEffects/freezeOnHit.js b/src/server/config/itemEffects/freezeOnHit.js index 7538f651..9310666d 100644 --- a/src/server/config/itemEffects/freezeOnHit.js +++ b/src/server/config/itemEffects/freezeOnHit.js @@ -1,13 +1,13 @@ module.exports = { events: { onGetText: function (item) { - let rolls = item.effects.find(e => (e.type == 'freezeOnHit')).rolls; + let rolls = item.effects.find(e => (e.type === 'freezeOnHit')).rolls; return `${rolls.chance}% chance on hit to freeze target for ${rolls.duration} ticks`; }, afterDealDamage: function (item, damage, target) { - let rolls = item.effects.find(e => (e.type == 'freezeOnHit')).rolls; + let rolls = item.effects.find(e => (e.type === 'freezeOnHit')).rolls; let chanceRoll = Math.random() * 100; if (chanceRoll >= rolls.chance) diff --git a/src/server/config/itemEffects/healOnCrit.js b/src/server/config/itemEffects/healOnCrit.js index 0e464608..438f9872 100644 --- a/src/server/config/itemEffects/healOnCrit.js +++ b/src/server/config/itemEffects/healOnCrit.js @@ -1,7 +1,7 @@ module.exports = { events: { onGetText: function (item) { - let rolls = item.effects.find(e => (e.type == 'healOnCrit')).rolls; + let rolls = item.effects.find(e => (e.type === 'healOnCrit')).rolls; let chance = rolls.chance || 100; let amount = rolls.amount; let percentage = rolls.percentage; @@ -25,7 +25,7 @@ module.exports = { if (!damage.crit) return; - let rolls = item.effects.find(e => (e.type == 'healOnCrit')).rolls; + let rolls = item.effects.find(e => (e.type === 'healOnCrit')).rolls; let chanceRoll = Math.random() * 100; if (chanceRoll >= (rolls.chance || 100)) diff --git a/src/server/config/loginRewards.js b/src/server/config/loginRewards.js index 33307fa6..7d80c4f1 100644 --- a/src/server/config/loginRewards.js +++ b/src/server/config/loginRewards.js @@ -54,7 +54,7 @@ module.exports = { let amount = 1 + ~~(Math.random() * (total - 1)); total -= amount; - let item = items.find(f => (f.name == pick.name)); + let item = items.find(f => (f.name === pick.name)); if (!item) { item = extend(true, { material: true, diff --git a/src/server/config/maps/cave/dialogues.js b/src/server/config/maps/cave/dialogues.js index 7ccb49f2..b0582937 100644 --- a/src/server/config/maps/cave/dialogues.js +++ b/src/server/config/maps/cave/dialogues.js @@ -29,7 +29,7 @@ module.exports = { 1.6: { msg: 'I have some crystals for you.', prereq: function (obj) { - let crystals = obj.inventory.items.find(i => (i.name == 'Digested Crystal')); + let crystals = obj.inventory.items.find(i => (i.name === 'Digested Crystal')); return !!crystals; }, goto: 'giveCrystals' @@ -226,7 +226,7 @@ module.exports = { method: function (obj) { let inventory = obj.inventory; - let crystals = inventory.items.find(i => (i.name == 'Digested Crystal')); + let crystals = inventory.items.find(i => (i.name === 'Digested Crystal')); if (!crystals) return; obj.reputation.getReputation('akarei', (crystals.quantity || 1) * 15); diff --git a/src/server/config/maps/cave/zone.js b/src/server/config/maps/cave/zone.js index 0d71fe00..b95cbb33 100644 --- a/src/server/config/maps/cave/zone.js +++ b/src/server/config/maps/cave/zone.js @@ -486,7 +486,7 @@ module.exports = { activated.push(order); let valid = true; for (let i = 0; i < activated.length; i++) { - if (activated[i] != i) { + if (activated[i] !== i) { valid = false; break; } @@ -508,7 +508,7 @@ module.exports = { }); return; - } else if (activated.length == 4) { + } else if (activated.length === 4) { triggerPuzzle.activated = []; this.activate(); } @@ -528,7 +528,7 @@ module.exports = { activate: function () { let syncer = this.obj.instance.syncer; let physics = this.obj.instance.physics; - let walls = this.obj.instance.objects.objects.filter(o => (o.objZoneName == 'redWall')); + let walls = this.obj.instance.objects.objects.filter(o => (o.objZoneName === 'redWall')); walls.forEach(function (w) { w.destroyed = true; physics.setCollision(w.x, w.y, false); diff --git a/src/server/config/maps/fjolarok/dialogues.js b/src/server/config/maps/fjolarok/dialogues.js index a26a7eb4..505d5cb9 100644 --- a/src/server/config/maps/fjolarok/dialogues.js +++ b/src/server/config/maps/fjolarok/dialogues.js @@ -225,12 +225,12 @@ module.exports = { let sets = items.filter(function (i) { return ( - (i.type == 'Reward Card') && + (i.type === 'Reward Card') && (i.quantity >= i.setSize) ); }); - if (sets.length == 0) + if (sets.length === 0) return 'Sorry, you don\'t have any completed sets.'; sets.forEach(function (s) { diff --git a/src/server/config/maps/fjolarok/events/fishingTournament.js b/src/server/config/maps/fjolarok/events/fishingTournament.js index 64c16913..f7aed8d2 100644 --- a/src/server/config/maps/fjolarok/events/fishingTournament.js +++ b/src/server/config/maps/fjolarok/events/fishingTournament.js @@ -73,7 +73,7 @@ module.exports = { let fish = []; tempFish.forEach(function (t) { - if (!fish.some(f => (f.owner == t.owner))) + if (!fish.some(f => (f.owner === t.owner))) fish.push(t); }); @@ -128,10 +128,10 @@ module.exports = { let ranks = event.ranks; let winText = 'Angler Nayla: '; - let winners = Object.keys(ranks).filter(r => (ranks[r] == 1)); + let winners = Object.keys(ranks).filter(r => (ranks[r] === 1)); let wLen = winners.length; winners.forEach(function (w, i) { - winText += ((wLen > 1) && (i == wLen - 1)) ? `and ${w} ` : `${w} `; + winText += ((wLen > 1) && (i === wLen - 1)) ? `and ${w} ` : `${w} `; }); winText += 'won!'; @@ -147,7 +147,7 @@ module.exports = { .filter(i => (i.name.indexOf('Ancient Carp') > -1)) .sort((a, b) => (b.stats.weight - a.stats.weight)) .forEach(function (f, i) { - if (i == 0) { + if (i === 0) { f.owner = source.name; tgtInventory.getItem(extend(true, {}, f)); } @@ -340,10 +340,10 @@ module.exports = { auto: true, events: { beforeGatherResource: function (gatherResult, gatherer) { - if (gatherResult.nodeType != 'fish') + if (gatherResult.nodeType !== 'fish') return; - let hasCompRod = gatherer.inventory.items.some(i => ((i.name == 'Competition Rod') && (i.eq))); + let hasCompRod = gatherer.inventory.items.some(i => ((i.name === 'Competition Rod') && (i.eq))); if (!hasCompRod) return; @@ -357,7 +357,7 @@ module.exports = { }, beforeEnterPool: function (gatherResult, gatherer) { - if (gatherResult.nodeName == 'Sun Carp') + if (gatherResult.nodeName === 'Sun Carp') gatherResult.nodeName = 'Ancient Carp'; } } @@ -398,7 +398,7 @@ module.exports = { let newRank = helpers.getRank(event, obj.name); helpers.updateDescription(event, this.instance.events); - if (oldRank != newRank) { + if (oldRank !== newRank) { helpers.updateWinText(event, this.instance.events); return { @@ -406,7 +406,7 @@ module.exports = { 2: 'Nice catch. You took second place!', 3: 'Not bad at all. You took third place!' }[newRank]; - } else if (newRank == 1) + } else if (newRank === 1) return 'Great, you\'re still in first place!'; return 'Not quite heavy enough, keep trying!'; } diff --git a/src/server/config/prophecies/titangrip.js b/src/server/config/prophecies/titangrip.js index 156c224f..87aa7df3 100644 --- a/src/server/config/prophecies/titangrip.js +++ b/src/server/config/prophecies/titangrip.js @@ -13,7 +13,7 @@ module.exports = { events: { afterEquipItem: function (item) { - if (['oneHanded', 'twoHanded'].indexOf(item.slot) == -1) + if (['oneHanded', 'twoHanded'].indexOf(item.slot) === -1) return; let stats = item.stats; @@ -24,7 +24,7 @@ module.exports = { } }, afterUnequipItem: function (item) { - if (['oneHanded', 'twoHanded'].indexOf(item.slot) == -1) + if (['oneHanded', 'twoHanded'].indexOf(item.slot) === -1) return; let stats = item.stats; diff --git a/src/server/config/quests/questBuilder.js b/src/server/config/quests/questBuilder.js index 46dd47f6..9bcbc5d9 100644 --- a/src/server/config/quests/questBuilder.js +++ b/src/server/config/quests/questBuilder.js @@ -10,7 +10,7 @@ module.exports = { obtain: function (obj, template) { let zoneName = template ? template.zoneName : obj.zoneName; let oQuests = obj.quests; - if (oQuests.quests.filter(q => q.zoneName == zoneName).length > 0) + if (oQuests.quests.filter(q => q.zoneName === zoneName).length > 0) return; let zoneTemplate = null; @@ -26,12 +26,12 @@ module.exports = { let config = extend(true, {}, zoneTemplate); this.instance.eventEmitter.emit('onBeforeGetQuests', config); - if (config.infini.length == 0) + if (config.infini.length === 0) return; let pickQuest = null; if ((template) && (template.type)) - pickQuest = config.infini.find(c => c.type == template.type); + pickQuest = config.infini.find(c => c.type === template.type); if (!pickQuest) pickQuest = config.infini[~~(Math.random() * config.infini.length)]; diff --git a/src/server/config/quests/templates/questGatherResource.js b/src/server/config/quests/templates/questGatherResource.js index c31c30c9..372fdf88 100644 --- a/src/server/config/quests/templates/questGatherResource.js +++ b/src/server/config/quests/templates/questGatherResource.js @@ -14,7 +14,7 @@ module.exports = { this.gatherType = ['herb', 'fish'][~~(Math.random() * 2)]; - if (this.gatherType == 'fish') { + if (this.gatherType === 'fish') { this.name = 'Lure of the Sea'; let isQualityQ = (Math.random() < 0.3); @@ -25,10 +25,10 @@ module.exports = { } } - if (['herb', 'fish'].indexOf(this.gatherType) == -1) + if (['herb', 'fish'].indexOf(this.gatherType) === -1) this.gatherType = 'herb'; - this.typeName = (this.gatherType == 'herb') ? 'herbs' : 'fish'; + this.typeName = (this.gatherType === 'herb') ? 'herbs' : 'fish'; this.updateDescription(); @@ -36,9 +36,9 @@ module.exports = { }, getXpMultiplier: function () { - if (this.requiredQuality == 2) + if (this.requiredQuality === 2) return 8; - else if (this.requiredQuality == 1) + else if (this.requiredQuality === 1) return 6; return this.need; }, @@ -58,12 +58,12 @@ module.exports = { events: { afterGatherResource: function (gatherResult) { - if (gatherResult.nodeType != this.gatherType) + if (gatherResult.nodeType !== this.gatherType) return; else if ((this.requiredQuality) && (gatherResult.items[0].quality < this.requiredQuality)) return; - if ((this.obj.zoneName != this.zoneName) || (this.have >= this.need)) + if ((this.obj.zoneName !== this.zoneName) || (this.have >= this.need)) return; this.have++; diff --git a/src/server/config/quests/templates/questKillX.js b/src/server/config/quests/templates/questKillX.js index eac11b9b..01a40a72 100644 --- a/src/server/config/quests/templates/questKillX.js +++ b/src/server/config/quests/templates/questKillX.js @@ -9,12 +9,12 @@ module.exports = { build: function () { //If we're not in the correct zone, don't do this check, it'll just crash the server // since the mob won't be available (most likely) in the zoneFile - if (this.obj.zoneName == this.zoneName) { + if (this.obj.zoneName === this.zoneName) { let mobTypes = this.obj.instance.spawners.zone.mobs; if (this.mobName) { let mobType = mobTypes[this.mobName.toLowerCase()]; //Maybe the zoneFile changed in the meantime. If so, regenerate - if ((!mobType) || (mobType.attackable == false)) + if ((!mobType) || (mobType.attackable === false)) this.mobName = null; } @@ -24,10 +24,10 @@ module.exports = { let mobBlueprint = mobTypes[m]; return ( - (m != 'default') && + (m !== 'default') && ( (mobBlueprint.attackable) || - (mobBlueprint.attackable == null) + (mobBlueprint.attackable === null) ) && (mobBlueprint.level <= ~~(this.obj.stats.values.level * 1.35)) && (mobCounts[m] > 1) @@ -35,7 +35,7 @@ module.exports = { }, this); //No level appropriate mobs found - if (keys.length == 0) + if (keys.length === 0) return false; this.mobType = keys[~~(Math.random() * keys.length)]; @@ -59,7 +59,7 @@ module.exports = { events: { afterKillMob: function (mob) { - if ((mob.name.toLowerCase() != this.mobName.toLowerCase()) || (this.have >= this.need)) + if ((mob.name.toLowerCase() !== this.mobName.toLowerCase()) || (this.have >= this.need)) return; this.have++; diff --git a/src/server/config/quests/templates/questLoot.js b/src/server/config/quests/templates/questLoot.js index 7f129036..ec57b337 100644 --- a/src/server/config/quests/templates/questLoot.js +++ b/src/server/config/quests/templates/questLoot.js @@ -8,10 +8,10 @@ module.exports = { build: function () { let slotNames = slots.slots - .filter(s => (s != 'tool')); + .filter(s => (s !== 'tool')); if (this.slot) { - if (!slotNames.some(s => (s == this.slot))) + if (!slotNames.some(s => (s === this.slot))) this.slot = null; } @@ -20,9 +20,9 @@ module.exports = { this.quality = 1 + ~~(Math.random() * 2); this.slotName = ''; - if (this.quality == 1) { + if (this.quality === 1) { let roll = ~~(Math.random() * 2); - if (roll == 0) + if (roll === 0) this.slotName = 'Magic Armor'; else this.slotName = 'Magic Accessory'; @@ -66,9 +66,9 @@ module.exports = { if (!this.quality) multiplier *= 8; - else if (this.quality == 2) + else if (this.quality === 2) multiplier *= 6; - else if (this.quality == 1) + else if (this.quality === 1) multiplier *= 4; return multiplier; @@ -78,18 +78,18 @@ module.exports = { afterLootMobItem: function (item) { if ( (this.isReady) || - (this.obj.zoneName != this.zoneName) || + (this.obj.zoneName !== this.zoneName) || ( (this.quality) && (item.quality < this.quality) ) || ( (this.slot.indexOf) && - (this.slot.indexOf(item.slot) == -1) + (this.slot.indexOf(item.slot) === -1) ) || ( (!this.slot.indexOf) && - (this.slot != item.slot) + (this.slot !== item.slot) ) ) return; diff --git a/src/server/config/quests/templates/questLootGen.js b/src/server/config/quests/templates/questLootGen.js index 8744afe8..85566513 100644 --- a/src/server/config/quests/templates/questLootGen.js +++ b/src/server/config/quests/templates/questLootGen.js @@ -18,14 +18,14 @@ module.exports = { let mobBlueprint = mobTypes[m]; return ( - (m != 'default') && + (m !== 'default') && (mobBlueprint.questItem) && (mobBlueprint.level <= (this.obj.stats.values.level * 1.35)) ); }, this); //No level appropriate mobs found - if (keys.length == 0) + if (keys.length === 0) return false; this.mobType = keys[~~(Math.random() * keys.length)]; @@ -51,14 +51,14 @@ module.exports = { oComplete: function () { let inventory = this.obj.inventory; - let item = inventory.items.find((i => i.name == this.item.name).bind(this)); + let item = inventory.items.find((i => i.name === this.item.name).bind(this)); if (item) this.obj.inventory.destroyItem(item.id, this.need); }, events: { beforeTargetDeath: function (target, dropItems) { - if ((this.obj.zoneName != this.zoneName) || (target.name.toLowerCase() != this.mobType) || (this.have >= this.need)) + if ((this.obj.zoneName !== this.zoneName) || (target.name.toLowerCase() !== this.mobType) || (this.have >= this.need)) return; let roll = Math.random(); @@ -76,11 +76,11 @@ module.exports = { }, afterLootMobItem: function (item) { - if ((this.obj.zoneName != this.zoneName) || (item.name.toLowerCase() != this.item.name.toLowerCase())) + if ((this.obj.zoneName !== this.zoneName) || (item.name.toLowerCase() !== this.item.name.toLowerCase())) return; this.have++; - if (this.have == this.need) + if (this.have === this.need) this.ready(); this.description = 'Loot ' + this.have + '/' + this.need + ' ' + this.item.name + ' from ' + this.mobName; @@ -88,7 +88,7 @@ module.exports = { }, afterDestroyItem: function (item, quantity) { - if (item.name.toLowerCase() != this.item.name.toLowerCase()) + if (item.name.toLowerCase() !== this.item.name.toLowerCase()) return; this.have -= quantity; diff --git a/src/server/config/quests/templates/questTemplate.js b/src/server/config/quests/templates/questTemplate.js index 7499a8cd..c5f7a504 100644 --- a/src/server/config/quests/templates/questTemplate.js +++ b/src/server/config/quests/templates/questTemplate.js @@ -73,7 +73,7 @@ module.exports = { let values = {}; for (let p in this) { let value = this[p]; - if ((typeof (value) == 'function') || (p == 'obj')) + if ((typeof (value) === 'function') || (p === 'obj')) continue; values[p] = value; diff --git a/src/server/config/roles.js b/src/server/config/roles.js index 2329de63..083a3bd3 100644 --- a/src/server/config/roles.js +++ b/src/server/config/roles.js @@ -9,7 +9,7 @@ module.exports = { let account = obj.account; let config = this.getAccount(account) || {}; if (config.items) { - let blueprintInventory = blueprint.components.find(c => (c.type == 'inventory')); + let blueprintInventory = blueprint.components.find(c => (c.type === 'inventory')); if (!blueprintInventory) { blueprint.components.push({ type: 'inventory', @@ -22,7 +22,7 @@ module.exports = { let items = blueprintInventory.items; config.items.forEach(function (item) { - let hasItem = items.find(i => (i.name == item.name)); + let hasItem = items.find(i => (i.name === item.name)); if (hasItem) return; @@ -62,14 +62,14 @@ module.exports = { getSkins: function (account) { let skins = []; - let account = this.getAccount(account) || { + account = this.getAccount(account) || { skins: [] }; (account.skins || []).forEach(function (s) { skins.push(s); }); - skins = skins.filter((s, i) => (skins.indexOf(s) == i)); + skins = skins.filter((s, i) => (skins.indexOf(s) === i)); return skins; }, diff --git a/src/server/config/skins.js b/src/server/config/skins.js index 88abf3a6..e350bfce 100644 --- a/src/server/config/skins.js +++ b/src/server/config/skins.js @@ -117,7 +117,7 @@ module.exports = { getSkinList: function (skins) { let list = Object.keys(config) .filter(function (s) { - return ((config[s].default) || (skins.some(f => ((f == s) || (f == '*'))))); + return ((config[s].default) || (skins.some(f => ((f === s) || (f === '*'))))); }) .map(function (s) { let res = extend(true, {}, config[s]); diff --git a/src/server/config/spells/spellArcaneBarrier.js b/src/server/config/spells/spellArcaneBarrier.js index d051eb60..e3a92c99 100644 --- a/src/server/config/spells/spellArcaneBarrier.js +++ b/src/server/config/spells/spellArcaneBarrier.js @@ -15,7 +15,7 @@ let cpnArcanePatch = { let isPlayer = !!this.caster.player; let isTargetPlayer = !!o.player; - if ((this.caster.aggro.canAttack(o)) || (isPlayer != isTargetPlayer)) + if ((this.caster.aggro.canAttack(o)) || (isPlayer !== isTargetPlayer)) return; this.contents.push(o); @@ -25,7 +25,7 @@ let cpnArcanePatch = { let contents = this.contents; let cLen = contents.length; for (let i = 0; i < cLen; i++) { - if (contents[i] == o) { + if (contents[i] === o) { contents.splice(i, 1); return; } diff --git a/src/server/config/spells/spellAura.js b/src/server/config/spells/spellAura.js index 313eba7b..55e741ea 100644 --- a/src/server/config/spells/spellAura.js +++ b/src/server/config/spells/spellAura.js @@ -42,7 +42,7 @@ module.exports = { updateActive: function () { let o = this.obj; let amount = 0; - if (this.name == 'Innervation') + if (this.name === 'Innervation') amount = ~~((o.stats.values.hpMax / 100) * this.values.regenPercentage); else amount = this.values.regenPercentage || this.values.chance; @@ -103,7 +103,7 @@ module.exports = { if (!effect) return; - let obj = objects.find(o => (o.serverId == m)); + let obj = objects.find(o => (o.serverId === m)); if (!obj) { delete effects[m]; return; diff --git a/src/server/config/spells/spellCallbacks.js b/src/server/config/spells/spellCallbacks.js index b3fdfd9d..96ed6173 100644 --- a/src/server/config/spells/spellCallbacks.js +++ b/src/server/config/spells/spellCallbacks.js @@ -25,7 +25,7 @@ module.exports = { for (let i = 0; i < cLen; i++) { let c = callbacks[i]; - if (c.sourceId == sourceId) { + if (c.sourceId === sourceId) { if (c.destroyCallback) c.destroyCallback(); callbacks.splice(i, 1); diff --git a/src/server/config/spells/spellCharge.js b/src/server/config/spells/spellCharge.js index b641b1a5..daddb66e 100644 --- a/src/server/config/spells/spellCharge.js +++ b/src/server/config/spells/spellCharge.js @@ -23,11 +23,11 @@ module.exports = { //We need to stop just short of the target let offsetX = 0; - if (dx != 0) + if (dx !== 0) offsetX = dx / Math.abs(dx); let offsetY = 0; - if (dy != 0) + if (dy !== 0) offsetY = dy / Math.abs(dy); let targetPos = { diff --git a/src/server/config/spells/spellFireblast.js b/src/server/config/spells/spellFireblast.js index a22c6188..acd5eff4 100644 --- a/src/server/config/spells/spellFireblast.js +++ b/src/server/config/spells/spellFireblast.js @@ -32,7 +32,7 @@ module.exports = { }] }; - if ((i != x) || (j != y)) + if ((i !== x) || (j !== y)) syncer.queue('onGetObject', effect, -1); let mobs = physics.getCell(i, j); @@ -66,7 +66,7 @@ module.exports = { let dx = m.x - obj.x; let dy = m.y - obj.y; - while ((dx == 0) && (dy == 0)) { + while ((dx === 0) && (dy === 0)) { dx = ~~(Math.random() * 2) - 1; dy = ~~(Math.random() * 2) - 1; } diff --git a/src/server/config/spells/spellHealingCircle.js b/src/server/config/spells/spellHealingCircle.js index 59fd86f5..a752ed13 100644 --- a/src/server/config/spells/spellHealingCircle.js +++ b/src/server/config/spells/spellHealingCircle.js @@ -19,7 +19,7 @@ let cpnHealPatch = { let isPlayer = !!this.caster.player; let isTargetPlayer = !!o.player; - if ((this.caster.aggro.canAttack(o)) || (isPlayer != isTargetPlayer)) + if ((this.caster.aggro.canAttack(o)) || (isPlayer !== isTargetPlayer)) return; this.contents.push(o); @@ -29,7 +29,7 @@ let cpnHealPatch = { let contents = this.contents; let cLen = contents.length; for (let i = 0; i < cLen; i++) { - if (contents[i] == o) { + if (contents[i] === o) { contents.splice(i, 1); return; } diff --git a/src/server/config/spells/spellSlowBlast.js b/src/server/config/spells/spellSlowBlast.js index 1084fdb1..df77f5b3 100644 --- a/src/server/config/spells/spellSlowBlast.js +++ b/src/server/config/spells/spellSlowBlast.js @@ -61,7 +61,7 @@ module.exports = { continue; let distance = ~~Math.sqrt(Math.pow(dx, 2) + Math.pow(dy, 2)); - if (distance != radius) + if (distance !== radius) continue; if (!physics.hasLos(x, y, i, j)) diff --git a/src/server/config/spells/spellSmokeBomb.js b/src/server/config/spells/spellSmokeBomb.js index 6d5c36d4..a3108e6f 100644 --- a/src/server/config/spells/spellSmokeBomb.js +++ b/src/server/config/spells/spellSmokeBomb.js @@ -21,7 +21,7 @@ let cpnSmokePatch = { let contents = this.contents; let cLen = contents.length; for (let i = 0; i < cLen; i++) { - if (contents[i] == o) { + if (contents[i] === o) { contents.splice(i, 1); return; } @@ -89,7 +89,7 @@ module.exports = { if (this.randomPos) { let range = this.range; - while ((x == obj.x) && (y == obj.y)) { + while ((x === obj.x) && (y === obj.y)) { x = obj.x + ~~(Math.random() * range * 2) - range; y = obj.y + ~~(Math.random() * range * 2) - range; } diff --git a/src/server/config/spells/spellSummonConsumableFollower.js b/src/server/config/spells/spellSummonConsumableFollower.js index 992a0b9a..7cb35197 100644 --- a/src/server/config/spells/spellSummonConsumableFollower.js +++ b/src/server/config/spells/spellSummonConsumableFollower.js @@ -110,7 +110,7 @@ module.exports = { }] }, -1); } else - m.mob.update = (this.walkCd == 0) ? m.mob.realUpdate : null; + m.mob.update = (this.walkCd === 0) ? m.mob.realUpdate : null; } }, diff --git a/src/server/config/spells/spellTemplate.js b/src/server/config/spells/spellTemplate.js index e3fbe7af..460c59e4 100644 --- a/src/server/config/spells/spellTemplate.js +++ b/src/server/config/spells/spellTemplate.js @@ -28,7 +28,7 @@ module.exports = { return true; let inRange = true; - if (this.range != null) { + if (this.range !== null) { let obj = this.obj; let distance = Math.max(Math.abs(target.x - obj.x), Math.abs(target.y - obj.y)); inRange = (distance <= this.range); @@ -43,7 +43,7 @@ module.exports = { }, calcDps: function (target, noSync) { - if ((!this.values) || (this.spellType == 'buff')) + if ((!this.values) || (this.spellType === 'buff')) return; if ((!this.damage) && (!this.healing)) @@ -67,7 +67,7 @@ module.exports = { noCrit: true }).amount; - let isAttack = (this.type == 'melee'); + let isAttack = (this.type === 'melee'); let statValues = this.obj.stats.values; @@ -140,7 +140,7 @@ module.exports = { let values = {}; for (let p in this) { let value = this[p]; - if ((typeof (value) == 'function') || (p == 'obj')) + if ((typeof (value) === 'function') || (p === 'obj')) continue; values[p] = value; @@ -158,7 +158,7 @@ module.exports = { }, getDamage: function (target, noMitigate) { - let damage = { + let config = { source: this.obj, target: target, damage: (this.damage || this.healing) * (this.dmgMult || 1), @@ -166,13 +166,13 @@ module.exports = { element: this.element, statType: this.statType, statMult: this.statMult, - isAttack: (this.type == 'melee'), + isAttack: (this.type === 'melee'), noMitigate: noMitigate }; - this.obj.fireEvent('onBeforeCalculateDamage', damage); + this.obj.fireEvent('onBeforeCalculateDamage', config); - let damage = combat.getDamage(damage); + let damage = combat.getDamage(config); return damage; }, diff --git a/src/server/config/spells/spellTrailDash.js b/src/server/config/spells/spellTrailDash.js index a3af58c5..9705a5f8 100644 --- a/src/server/config/spells/spellTrailDash.js +++ b/src/server/config/spells/spellTrailDash.js @@ -18,7 +18,7 @@ let cpnSpikePatch = { let contents = this.contents; let cLen = contents.length; for (let i = 0; i < cLen; i++) { - if (contents[i] == o) { + if (contents[i] === o) { contents.splice(i, 1); return; } @@ -83,8 +83,8 @@ module.exports = { if (this.obj.instance.physics.isTileBlocking(x, y)) this.distance = 7; - else if ((x != this.obj.x) || (y != this.obj.y)) { - //if ((x != this.targetX) || (y != this.targetY)) { + else if ((x !== this.obj.x) || (y !== this.obj.y)) { + //if ((x !== this.targetX) || (y !== this.targetY)) { let particles = this.particles; let spike = this.obj.instance.objects.buildObjects([{ diff --git a/src/server/config/spells/spellWarnBlast.js b/src/server/config/spells/spellWarnBlast.js index adb3f350..6b492d2e 100644 --- a/src/server/config/spells/spellWarnBlast.js +++ b/src/server/config/spells/spellWarnBlast.js @@ -47,7 +47,7 @@ module.exports = { if (!physics.hasLos(x, y, i, j)) continue; - else if ((attackTemplate) && (attackTemplate[count] == 'x')) + else if ((attackTemplate) && (attackTemplate[count] === 'x')) continue; if ((attackTemplate) && (~~attackTemplate[count] > 0)) { diff --git a/src/server/events/events.js b/src/server/events/events.js index a615ffe4..ca5a0f9c 100644 --- a/src/server/events/events.js +++ b/src/server/events/events.js @@ -25,7 +25,7 @@ module.exports = { }, getEvent: function (name) { - return this.configs.find(c => (c.name == name)).event.config; + return this.configs.find(c => (c.name === name)).event.config; }, setEventDescription: function (name, desc) { let config = this.getEvent(name); @@ -202,7 +202,7 @@ module.exports = { } if (event.config.notifications) { - let n = event.config.notifications.find(f => (f.mark == event.age)); + let n = event.config.notifications.find(f => (f.mark === event.age)); if (n) { this.instance.syncer.queue('onGetMessages', { messages: { @@ -211,7 +211,7 @@ module.exports = { } }, -1); - if (n.desc != null) { + if (n.desc !== null) { event.config.descTimer = n.desc; this.setEventDescription(event.config.name); } @@ -220,9 +220,9 @@ module.exports = { event.age++; - if (event.age == event.config.duration) + if (event.age === event.config.duration) event.done = true; - else if ((event.config.prizeTime) && (event.age == event.config.prizeTime)) + else if ((event.config.prizeTime) && (event.age === event.config.prizeTime)) this.giveRewards(event.config); if (stillBusy) @@ -258,7 +258,7 @@ module.exports = { event.done = true; let oList = this.instance.objects.objects; - let oLen = oList.length; + oLen = oList.length; for (let i = 0; i < oLen; i++) { let o = oList[i]; if (!o.player) @@ -283,16 +283,16 @@ module.exports = { if (!event) continue; - let exists = event.participators.find(p => (p.name == obj.name)); + let exists = event.participators.find(p => (p.name === obj.name)); if (exists) { - event.participators.spliceWhere(p => (p == exists)); + event.participators.spliceWhere(p => (p === exists)); event.participators.push(obj); result.push(event); continue; } let distance = event.config.distance; - if (distance == -1) { + if (distance === -1) { event.participators.push(obj); result.push(event); @@ -312,7 +312,7 @@ module.exports = { let o = objects[j]; if ( - (distance == -1) || + (distance === -1) || (!distance) || ( (Math.abs(x - o.x) < distance) && diff --git a/src/server/fixes/fixes.js b/src/server/fixes/fixes.js index 5e33daa6..d83e3467 100644 --- a/src/server/fixes/fixes.js +++ b/src/server/fixes/fixes.js @@ -3,7 +3,7 @@ let configSkins = require('../config/skins'); module.exports = { fixCharacter: function (player) { - let inv = player.components.find(c => (c.type == 'inventory')); + let inv = player.components.find(c => (c.type === 'inventory')); if ((inv) && (inv.items)) this.fixItems(inv.items); }, @@ -14,7 +14,7 @@ module.exports = { fixItems: function (items) { items - .filter(i => ((i.name == 'Cowl of Obscurity') && (!i.factions))) + .filter(i => ((i.name === 'Cowl of Obscurity') && (!i.factions))) .forEach(function (i) { i.factions = [{ id: 'gaekatla', @@ -23,7 +23,7 @@ module.exports = { }); items - .filter(i => (i.name == 'Steelclaw\'s Bite')) + .filter(i => (i.name === 'Steelclaw\'s Bite')) .forEach(function (i) { let effect = i.effects[0]; @@ -36,7 +36,7 @@ module.exports = { }); items - .filter(f => ((f.effects) && (f.effects[0].factionId == 'akarei') && (!f.effects[0].properties))) + .filter(f => ((f.effects) && (f.effects[0].factionId === 'akarei') && (!f.effects[0].properties))) .forEach(function (i) { let effect = i.effects[0]; let chance = parseFloat(effect.text.split(' ')[0].replace('%', '')); @@ -63,7 +63,7 @@ module.exports = { let length = skins.length; skins = skins.filter(s => !!configSkins.getBlueprint(s)); - if (length != skins.length) { + if (length !== skins.length) { io.set({ ent: username, field: 'skins', diff --git a/src/server/index.js b/src/server/index.js index f9816025..d133dad4 100644 --- a/src/server/index.js +++ b/src/server/index.js @@ -15,8 +15,6 @@ let spells = require('./config/spells'); let itemTypes = require('./items/config/types'); let sheets = require('./security/sheets'); -global.io = true; - let startup = { init: function () { io.init(this.onDbReady.bind(this)); diff --git a/src/server/items/config/currencies.js b/src/server/items/config/currencies.js index 510453dc..22825746 100644 --- a/src/server/items/config/currencies.js +++ b/src/server/items/config/currencies.js @@ -52,7 +52,7 @@ module.exports = { getCurrencyFromAction: function (action) { let currencies = this.currencies; - let pick = Object.keys(currencies).find(o => (currencies[o].action == action)); + let pick = Object.keys(currencies).find(o => (currencies[o].action === action)); return extend(true, { name: pick diff --git a/src/server/items/config/slots.js b/src/server/items/config/slots.js index 8e3fb5a1..805c225d 100644 --- a/src/server/items/config/slots.js +++ b/src/server/items/config/slots.js @@ -50,7 +50,7 @@ module.exports = { getRandomSlot: function (exclude) { let chances = []; for (let c in this.chance) { - if (c == exclude) + if (c === exclude) continue; let rolls = this.chance[c]; diff --git a/src/server/items/enchanter.js b/src/server/items/enchanter.js index 7cf17b1c..0aa440c4 100644 --- a/src/server/items/enchanter.js +++ b/src/server/items/enchanter.js @@ -14,7 +14,7 @@ module.exports = { let success = true; config.materials.forEach(function (m) { - let hasMaterial = inventory.items.find(i => i.name == m.name); + let hasMaterial = inventory.items.find(i => i.name === m.name); if (hasMaterial) hasMaterial = hasMaterial.quantity >= m.quantity; if (!hasMaterial) @@ -32,11 +32,11 @@ module.exports = { }; config.materials.forEach(function (m) { - let invMaterial = inventory.items.find(i => i.name == m.name); + let invMaterial = inventory.items.find(i => i.name === m.name); inventory.destroyItem(invMaterial.id, m.quantity); }); - if (msg.action == 'reroll') { + if (msg.action === 'reroll') { let enchantedStats = item.enchantedStats || {}; delete item.enchantedStats; delete msg.addStatMsgs; @@ -63,15 +63,15 @@ module.exports = { item.stats[p] += enchantedStats[p]; - if (p == 'lvlRequire') { + if (p === 'lvlRequire') { item.level -= enchantedStats[p]; if (item.level < 1) item.level = 1; } } item.enchantedStats = enchantedStats; - } else if (msg.action == 'relevel') { - if (item.slot == 'tool') + } else if (msg.action === 'relevel') { + if (item.slot === 'tool') return; let offset = 1 + ~~(Math.random() * 2); @@ -83,7 +83,7 @@ module.exports = { item.originalLevel = Math.min(20, item.originalLevel + offset); item.level = Math.min(20, item.level + offset); } - } else if (msg.action == 'reslot') { + } else if (msg.action === 'reslot') { if (item.effects) return; @@ -111,7 +111,7 @@ module.exports = { newItem.stats[p] += enchantedStats[p]; - if (p == 'lvlRequire') { + if (p === 'lvlRequire') { newItem.level -= enchantedStats[p]; if (newItem.level < 1) newItem.level = 1; @@ -120,7 +120,7 @@ module.exports = { newItem.enchantedStats = enchantedStats; extend(true, item, newItem); - } else if (msg.action == 'reforge') { + } else if (msg.action === 'reforge') { if (!item.spell) return; @@ -132,7 +132,7 @@ module.exports = { spellName: spellName }); item.spell = extend(true, oldSpell, item.spell); - } else if (msg.action == 'scour') { + } else if (msg.action === 'scour') { if (!item.power) return; @@ -148,7 +148,7 @@ module.exports = { if (item.stats[p] <= 0) delete item.stats[p]; - if (p == 'lvlRequire') { + if (p === 'lvlRequire') { item.level += value; delete item.originalLevel; } @@ -182,20 +182,21 @@ module.exports = { getEnchantMaterials: function (item, action) { let result = null; - if (action == 'reroll') + if (action === 'reroll') result = [configCurrencies.getCurrencyFromAction('reroll')]; - else if (action == 'relevel') + else if (action === 'relevel') result = [configCurrencies.getCurrencyFromAction('relevel')]; - else if (action == 'reslot') + else if (action === 'reslot') result = [configCurrencies.getCurrencyFromAction('reslot')]; - else if (action == 'reforge') + else if (action === 'reforge') result = [configCurrencies.getCurrencyFromAction('reforge')]; - else if (action == 'scour') + else if (action === 'scour') result = [configCurrencies.getCurrencyFromAction('scour')]; else { let powerLevel = item.power || 0; + let mult = null; if (powerLevel < 3) - let mult = [5, 10, 20][powerLevel]; + mult = [5, 10, 20][powerLevel]; else return; diff --git a/src/server/items/generator.js b/src/server/items/generator.js index 63ec36ac..f9942616 100644 --- a/src/server/items/generator.js +++ b/src/server/items/generator.js @@ -57,7 +57,7 @@ module.exports = { item.noSalvage = blueprint.noSalvage; item.noDestroy = blueprint.noDestroy; materialGenerators.forEach(g => g.generate(item, blueprint)); - } else if (blueprint.type == 'mtx') { + } else if (blueprint.type === 'mtx') { item = extend(true, {}, blueprint); delete item.chance; } else { @@ -81,7 +81,7 @@ module.exports = { removeStat: function (item, stat) { if (!stat) { stat = Object.keys(item.stats) - .filter(s => (s != 'armor')); + .filter(s => (s !== 'armor')); stat = stat[~~(Math.random() * stat.length)]; } diff --git a/src/server/items/generators/effects.js b/src/server/items/generators/effects.js index 7a7e73a8..e011bfbc 100644 --- a/src/server/items/generators/effects.js +++ b/src/server/items/generators/effects.js @@ -7,7 +7,7 @@ module.exports = { let rolls = e.rolls; let newRolls = {}; for (let p in rolls) { - let isInt = (p.indexOf('i_') == 0); + let isInt = (p.indexOf('i_') === 0); let fieldName = p.replace('i_', ''); let range = rolls[p]; diff --git a/src/server/items/generators/names.js b/src/server/items/generators/names.js index e4a3b944..e34bb138 100644 --- a/src/server/items/generators/names.js +++ b/src/server/items/generators/names.js @@ -33,7 +33,7 @@ module.exports = { if (item.stats.armor) list = list.concat(prefixes.armor); - else if (item.slot == 'twoHanded') + else if (item.slot === 'twoHanded') list = list.concat(prefixes.weapons); let pick = list[~~(Math.random() * list.length)]; @@ -48,14 +48,14 @@ module.exports = { gSuffix: function (item, blueprint) { let list = null; - if (item.slot == 'tool') + if (item.slot === 'tool') list = suffixes.slots.tool; else { list = suffixes.generic.concat(suffixes.slots[item.slot] || []); if (item.stats.armor) list = list.concat(suffixes.armor); - else if (item.slot == 'twoHanded') + else if (item.slot === 'twoHanded') list = list.concat(suffixes.weapons); } diff --git a/src/server/items/generators/quality.js b/src/server/items/generators/quality.js index eb271264..e49be2fe 100644 --- a/src/server/items/generators/quality.js +++ b/src/server/items/generators/quality.js @@ -10,7 +10,7 @@ module.exports = { magicFindMult: 7, generate: function (item, blueprint) { - if (blueprint.quality != null) { + if (blueprint.quality !== null) { item.quality = ~~blueprint.quality; return; } @@ -29,7 +29,7 @@ module.exports = { for (let i = 0; i < mLen; i++) { qualities[i] = Math.max(0, qualities[i] - magicFind[i]); if (qualities[i] > 0) { - if (i == 0) { + if (i === 0) { qualities[i] -= (bonusMagicFind * this.magicFindMult); if (qualities[i] < 0) qualities[i] = 0; diff --git a/src/server/items/generators/spellbook.js b/src/server/items/generators/spellbook.js index 7e7526d0..63966df5 100644 --- a/src/server/items/generators/spellbook.js +++ b/src/server/items/generators/spellbook.js @@ -16,14 +16,14 @@ module.exports = { } let spell = spellsConfig.spells[spellName]; - let spellAesthetic = spells.spells.find(s => s.name.toLowerCase() == spellName) || {}; + let spellAesthetic = spells.spells.find(s => s.name.toLowerCase() === spellName) || {}; if (!item.slot) { let sprite = [10, 0]; let statType = spell.statType; - if (statType == 'dex') + if (statType === 'dex') sprite = [10, 1]; - else if (statType == 'str') + else if (statType === 'str') sprite = [10, 2]; else if (statType instanceof Array) { if ((statType.indexOf('dex') > -1) && (statType.indexOf('int') > -1)) @@ -35,7 +35,7 @@ module.exports = { item.name = 'Rune of ' + spellAesthetic.name; item.ability = true; item.sprite = sprite; - } else if (spellQuality == 'basic') + } else if (spellQuality === 'basic') item.stats = {}; if (blueprint.spellConfig) @@ -68,14 +68,14 @@ module.exports = { let max = Math.min(20, item.level) / 20; let roll = random.expNorm(0, max); - if (spellQuality == 'basic') + if (spellQuality === 'basic') roll = 0; - else if (spellQuality == 'mid') + else if (spellQuality === 'mid') roll = 0.5; item.spell.rolls[r] = roll; - let int = r.indexOf('i_') == 0; + let int = r.indexOf('i_') === 0; let val = range[0] + ((range[1] - range[0]) * roll); if (int) { diff --git a/src/server/items/generators/stats.js b/src/server/items/generators/stats.js index eb047dee..ea134a59 100644 --- a/src/server/items/generators/stats.js +++ b/src/server/items/generators/stats.js @@ -7,56 +7,56 @@ module.exports = { if (calcPerfection) return (calcPerfection / max); - else if (perfection == null) + else if (perfection === null) return random.norm(1, max) * (blueprint.statMult.elementDmgPercent || 1); return max * perfection * (blueprint.statMult.elementDmgPercent || 1); }, addCritMultiplier: function (item, level, blueprint, perfection, calcPerfection) { let div = 1 / 11; - if (item.slot == 'twoHanded') + if (item.slot === 'twoHanded') div *= 2; let max = (level * 15) * div; if (calcPerfection) return (calcPerfection / max); - else if (perfection == null) + else if (perfection === null) return random.norm(1, max) * (blueprint.statMult.addCritMultiplier || 1); return max * perfection * (blueprint.statMult.addCritMultiplier || 1); }, addCritChance: function (item, level, blueprint, perfection, calcPerfection) { let div = 1 / 11; - if (item.slot == 'twoHanded') + if (item.slot === 'twoHanded') div *= 2; let max = (level - 3) * 50 * div; if (calcPerfection) return (calcPerfection / max); - else if (perfection == null) + else if (perfection === null) return random.norm(1, max) * (blueprint.statMult.addCritChance || 1); return max * perfection * (blueprint.statMult.addCritChance || 1); }, vit: function (item, level, blueprint, perfection, calcPerfection) { let div = 1 / 11; - if (item.slot == 'twoHanded') + if (item.slot === 'twoHanded') div *= 2; let max = ((-0.6340155 + (13.68923 * level) - (0.34383 * Math.pow(level, 2)) + (0.06754871 * Math.pow(level, 3)) + (0.000174046 * Math.pow(level, 4)) + (0.000007675887 * Math.pow(level, 5))) / 10) * div; if (calcPerfection) return (calcPerfection / max); - else if (perfection == null) + else if (perfection === null) return random.norm(1, max) * (blueprint.statMult.vit || 1); return max * perfection * (blueprint.statMult.vit || 1); }, mainStat: function (item, level, blueprint, perfection, calcPerfection) { let div = 1 / 11; - if (item.slot == 'twoHanded') + if (item.slot === 'twoHanded') div *= 2; let min = (level / 15) * div; @@ -64,7 +64,7 @@ module.exports = { if (calcPerfection) return ((calcPerfection - min) / (max - min)); - else if (perfection == null) + else if (perfection === null) return random.norm(min, max) * (blueprint.statMult.mainStat || 1); return (min + ((max - min) * perfection)) * (blueprint.statMult.mainStat || 1); }, @@ -74,31 +74,31 @@ module.exports = { if (calcPerfection) return ((calcPerfection - min) / (max - min)); - else if (perfection == null) + else if (perfection === null) return random.norm(min, max) * blueprint.statMult.armor; return (min + ((max - min) * perfection)) * (blueprint.statMult.armor || 1); }, elementResist: function (item, level, blueprint, perfection, calcPerfection) { let div = 1 / 11; - if (item.slot == 'twoHanded') + if (item.slot === 'twoHanded') div *= 2; if (calcPerfection) return (calcPerfection / (100 * div)); - else if (perfection == null) + else if (perfection === null) return random.norm(1, 100) * (blueprint.statMult.elementResist || 1) * div; return ~~((1 + (99 * perfection)) * (blueprint.statMult.elementResist || 1) * div); }, regenHp: function (item, level, blueprint, perfection, calcPerfection) { let div = 1 / 11; - if (item.slot == 'twoHanded') + if (item.slot === 'twoHanded') div *= 2; let max = (-0.05426729 + (3.477385 * level) - (0.03890282 * Math.pow(level, 2)) + (0.009244822 * Math.pow(level, 3)) + (0.0001700915 * Math.pow(level, 4)) - (0.00000138085 * Math.pow(level, 5))) * div; if (calcPerfection) return (calcPerfection / max); - else if (perfection == null) + else if (perfection === null) return random.norm(1, max) * (blueprint.statMult.regenHp || 1); return max * perfection * (blueprint.statMult.regenHp || 1); }, @@ -107,7 +107,7 @@ module.exports = { if (calcPerfection) return (calcPerfection / max); - else if (perfection == null) + else if (perfection === null) return random.norm(1, max) * (blueprint.statMult.lvlRequire || 1); return max * perfection * (blueprint.statMult.lvlRequire || 1); } @@ -465,7 +465,7 @@ module.exports = { }, generate: function (item, blueprint, result) { - if (item.slot == 'tool') { + if (item.slot === 'tool') { statsFishingRod.generate(item, blueprint, result); return; } @@ -509,7 +509,7 @@ module.exports = { let addStats = Math.min(statCount, blueprint.stats.length); for (let i = 0; i < addStats; i++) { let choice = useStats[~~(Math.random() * useStats.length)]; - useStats.spliceFirstWhere(s => s == choice); + useStats.spliceFirstWhere(s => s === choice); this.buildStat(item, blueprint, choice, result); statCount--; } @@ -520,7 +520,7 @@ module.exports = { for (let s in item.stats) { item.stats[s] = Math.ceil(item.stats[s]); - if (item.stats[s] == 0) + if (item.stats[s] === 0) delete item.stats[s]; } }, @@ -584,7 +584,7 @@ module.exports = { item.enchantedStats[stat] = value; } - if (stat == 'lvlRequire') { + if (stat === 'lvlRequire') { if (!item.originalLevel) item.originalLevel = item.level; diff --git a/src/server/items/salvager.js b/src/server/items/salvager.js index e734929e..32d668a2 100644 --- a/src/server/items/salvager.js +++ b/src/server/items/salvager.js @@ -113,7 +113,7 @@ module.exports = { temp.forEach(function (t) { let mats = t.materials; mats.forEach(function (m) { - let exists = materials.find(mf => (mf.name == m.name)); + let exists = materials.find(mf => (mf.name === m.name)); if (exists) { exists.chance = Math.max(exists.chance, m.chance); exists.quantity = Math.max(exists.quantity, m.quantity); @@ -146,7 +146,7 @@ module.exports = { if (m.qualityName) { newItem.quality = item.quality; newItem.name = m.qualityName[item.quality]; - } else if (m.quality != null) + } else if (m.quality !== null) newItem.quality = m.quality; newItem.sprite = materialItems[newItem.name].sprite; diff --git a/src/server/leaderboard/leaderboard.js b/src/server/leaderboard/leaderboard.js index 58952bae..d1f9a172 100644 --- a/src/server/leaderboard/leaderboard.js +++ b/src/server/leaderboard/leaderboard.js @@ -25,7 +25,7 @@ module.exports = { let match = true; for (let i = 0; i < pLen; i++) { - if (!rProphecies.some(rp => rp == prophecyFilter[i])) { + if (!rProphecies.some(rp => rp === prophecyFilter[i])) { match = false; break; } @@ -90,7 +90,7 @@ module.exports = { let doSave = false; this.waiting.forEach(function (w) { - if (!this.list.some(l => l.name == w.name)) { + if (!this.list.some(l => l.name === w.name)) { this.list.push(w); doSave = true; } @@ -106,7 +106,7 @@ module.exports = { if (!this.list) return null; - let result = this.list.find(l => (l.name == name)); + let result = this.list.find(l => (l.name === name)); if (result) return result.level; return null; @@ -123,9 +123,9 @@ module.exports = { return; } - let exists = this.list.find(l => l.name == name); + let exists = this.list.find(l => l.name === name); if (exists) { - if (exists.level != level) { + if (exists.level !== level) { exists.level = level; this.save(); @@ -142,12 +142,12 @@ module.exports = { }, deleteCharacter: function (name) { - this.list.spliceWhere(l => (l.name == name)); + this.list.spliceWhere(l => (l.name === name)); this.save(); }, killCharacter: function (name) { - let character = this.list.find(l => (l.name == name)); + let character = this.list.find(l => (l.name === name)); if (!character) return; diff --git a/src/server/misc/events.js b/src/server/misc/events.js index 05e59b42..8a39a5e3 100644 --- a/src/server/misc/events.js +++ b/src/server/misc/events.js @@ -7,7 +7,7 @@ module.exports = { for (let i = 0; i < this.queue.length; i++) { let q = this.queue[i]; - if (q.event != event) + if (q.event !== event) continue; this.queue.splice(i, 1); @@ -24,14 +24,14 @@ module.exports = { let list = this.events[event] || []; let lLen = list.length; for (let i = 0; i < lLen; i++) { - if (list[i] == callback) { + if (list[i] === callback) { list.splice(i, 1); i--; lLen--; } } - if (lLen == 0) + if (lLen === 0) delete this.events[event]; }, emit: function (event) { diff --git a/src/server/misc/helpers.js b/src/server/misc/helpers.js index 4712c9ff..06359153 100644 --- a/src/server/misc/helpers.js +++ b/src/server/misc/helpers.js @@ -72,7 +72,7 @@ module.exports = { for (let i = 0; i < w; i++) { let inner = []; for (let j = 0; j < h; j++) { - if (def == 'array') + if (def === 'array') inner.push([]); else inner.push(def); diff --git a/src/server/misc/mail.js b/src/server/misc/mail.js index b5042b4c..361da2ed 100644 --- a/src/server/misc/mail.js +++ b/src/server/misc/mail.js @@ -9,7 +9,7 @@ module.exports = { }, getMail: function (playerName) { - let player = this.instance.objects.objects.find(o => (o.name == playerName)); + let player = this.instance.objects.objects.find(o => (o.name === playerName)); if (!player) { process.send({ method: 'callDifferentThread', @@ -32,12 +32,12 @@ module.exports = { }); }, onGetMail: function (player, result) { - if (result == 'null') + if (result === 'null') result = null; else if (result) { result = result.split('`').join('\''); //Hack for weird google datastore error - if (result[0] == '<') + if (result[0] === '<') return; } @@ -69,7 +69,7 @@ module.exports = { } else console.log(player.name + ' has no stash'); } else { - if ((r.msg) && (!sentMessages.some(s => (s == r.msg)))) { + if ((r.msg) && (!sentMessages.some(s => (s === r.msg)))) { player.instance.syncer.queue('onGetMessages', { id: player.id, messages: [{ @@ -124,7 +124,7 @@ module.exports = { let player = null; if (this.instance) - player = this.instance.objects.objects.find(o => (o.name == playerName)); + player = this.instance.objects.objects.find(o => (o.name === playerName)); io.get({ ent: playerName, @@ -133,7 +133,7 @@ module.exports = { }); }, doSendMail: function (playerName, items, callback, result) { - if (result == 'null') + if (result === 'null') result = null; result = JSON.parse(result || '[]'); diff --git a/src/server/misc/pathfinder.js b/src/server/misc/pathfinder.js index 2c57f3ac..cefae10f 100644 --- a/src/server/misc/pathfinder.js +++ b/src/server/misc/pathfinder.js @@ -73,7 +73,7 @@ if (!onWall) { if (distance) { - if (currentNode.h == distance) + if (currentNode.h === distance) return pathTo(currentNode); } else { // End case -- result has been found, return the traced path. @@ -277,7 +277,7 @@ GridNode.prototype.getCost = function (fromNeighbor) { // Take diagonal weight into consideration. - if (fromNeighbor && fromNeighbor.x != this.x && fromNeighbor.y != this.y) + if (fromNeighbor && fromNeighbor.x !== this.x && fromNeighbor.y !== this.y) return this.weight * 1.41421; return this.weight; diff --git a/src/server/misc/random.js b/src/server/misc/random.js index be640cca..83bb5e46 100644 --- a/src/server/misc/random.js +++ b/src/server/misc/random.js @@ -13,7 +13,7 @@ this.mt[this.N - 1], b = 1); }; Random.prototype.genrand_int32 = function () { let a, c = [0, this.MATRIX_A]; if (this.mti >= this.N) { - let b; this.mti == this.N + 1 && this.init_genrand(5489); for (b = 0; b < this.N - this.M; b++)a = this.mt[b] & this.UPPER_MASK | this.mt[b + 1] & this.LOWER_MASK, this.mt[b] = this.mt[b + this.M] ^ a >>> 1 ^ c[a & 1]; for (;b < this.N - 1; b++)a = this.mt[b] & this.UPPER_MASK | this.mt[b + 1] & this.LOWER_MASK, this.mt[b] = this.mt[b + (this.M - this.N)] ^ a >>> 1 ^ c[a & 1]; a = this.mt[this.N - 1] & this.UPPER_MASK | this.mt[0] & this.LOWER_MASK; this.mt[this.N - 1] = this.mt[this.M - 1] ^ a >>> 1 ^ + let b; this.mti === this.N + 1 && this.init_genrand(5489); for (b = 0; b < this.N - this.M; b++)a = this.mt[b] & this.UPPER_MASK | this.mt[b + 1] & this.LOWER_MASK, this.mt[b] = this.mt[b + this.M] ^ a >>> 1 ^ c[a & 1]; for (;b < this.N - 1; b++)a = this.mt[b] & this.UPPER_MASK | this.mt[b + 1] & this.LOWER_MASK, this.mt[b] = this.mt[b + (this.M - this.N)] ^ a >>> 1 ^ c[a & 1]; a = this.mt[this.N - 1] & this.UPPER_MASK | this.mt[0] & this.LOWER_MASK; this.mt[this.N - 1] = this.mt[this.M - 1] ^ a >>> 1 ^ c[a & 1]; this.mti = 0; }a = this.mt[this.mti++]; a ^= a >>> 11; a ^= a << 7 & 2636928640; a ^= a << 15 & 4022730752; a ^= a >>> 18; return a >>> 0; }; Random.prototype.genrand_int31 = function () { @@ -37,7 +37,7 @@ Random.prototype.gamma = function (a, c) { let j = 1 - this.random(), i = Math.log(d / (1 - d)) / b, h = a * Math.exp(i), d = d * d * j, i = f + e * i - h; if (i + this.SG_MAGICCONST - 4.5 * d >= 0 || i >= Math.log(d)) return h * c; } } - } else if (a == 1) { + } else if (a === 1) { for (let g = this.random(); g <= 1.0E-7;)g = this.random(); return -Math.log(g) * c; } else { for (;;) { diff --git a/src/server/misc/scheduler.js b/src/server/misc/scheduler.js index f127b931..05e47c60 100644 --- a/src/server/misc/scheduler.js +++ b/src/server/misc/scheduler.js @@ -13,7 +13,7 @@ module.exports = { shouldRun: function (c) { let cron = c.cron.split(' '); - if (cron.length != 5) { + if (cron.length !== 5) { console.log('Invalid Cron Format: ' + cron.join(' ')); return false; } @@ -23,7 +23,7 @@ module.exports = { let lastRun = c.lastRun; if (lastRun) { - if (Object.keys(lastRun).every(e => (lastRun[e] == time[e]))) + if (Object.keys(lastRun).every(e => (lastRun[e] === time[e]))) return false; } @@ -32,7 +32,7 @@ module.exports = { let run = ['minute', 'hour', 'day', 'month', 'weekday'].every(function (t, i) { let tCheck = cron[i]; - if (tCheck == '*') + if (tCheck === '*') return true; let overflow = timeOverflows[i]; @@ -53,11 +53,11 @@ module.exports = { return tCheck.some(function (f) { f = f.split('-'); - if (f.length == 1) { + if (f.length === 1) { f = f[0].split('/'); - if (f.length == 1) - return (useTime == f[0]); - return ((useTime % f[1]) == 0); + if (f.length === 1) + return (useTime === f[0]); + return ((useTime % f[1]) === 0); } return ((useTime >= f[0]) && (useTime <= f[1])); }); diff --git a/src/server/mods/class-necromancer/index.js b/src/server/mods/class-necromancer/index.js index eecb716b..1660c1a9 100644 --- a/src/server/mods/class-necromancer/index.js +++ b/src/server/mods/class-necromancer/index.js @@ -19,7 +19,7 @@ module.exports = { }, onAfterGetZone: function (zone, config) { - if (zone != 'fjolarok') + if (zone !== 'fjolarok') return; let newRunes = [{ @@ -104,11 +104,11 @@ module.exports = { }, beforeGetSpellTemplate: function (spell) { - if (spell.type == 'HarvestLife') + if (spell.type === 'HarvestLife') spell.template = require('./spells/spellHarvestLife'); - else if (spell.type == 'SummonSkeleton') + else if (spell.type === 'SummonSkeleton') spell.template = require('./spells/spellSummonSkeleton'); - else if (spell.type == 'BloodBarrier') + else if (spell.type === 'BloodBarrier') spell.template = require('./spells/spellBloodBarrier'); }, diff --git a/src/server/mods/event-halloween/index.js b/src/server/mods/event-halloween/index.js index 2e993963..68cc5b8d 100644 --- a/src/server/mods/event-halloween/index.js +++ b/src/server/mods/event-halloween/index.js @@ -87,7 +87,7 @@ module.exports = { }, beforeGetSpellTemplate: function (spell) { - if (spell.type == 'ScatterPumpkinPieces') + if (spell.type === 'ScatterPumpkinPieces') spell.template = require('./spells/spellScatterPumpkinPieces.js'); }, @@ -180,10 +180,10 @@ module.exports = { }, onAfterGetLayerObjects: function (info) { - if (info.map != 'fjolarok') + if (info.map !== 'fjolarok') return; - let layer = this.mapFile.layers.find(l => (l.name == info.layer)); + let layer = this.mapFile.layers.find(l => (l.name === info.layer)); if (layer) { let offset = this.mapOffset; let mapScale = this.mapFile.tilesets[0].tileheight; @@ -199,7 +199,7 @@ module.exports = { }, onBeforeBuildLayerTile: function (info) { - if (info.map != 'fjolarok') + if (info.map !== 'fjolarok') return; let offset = this.mapOffset; @@ -211,13 +211,13 @@ module.exports = { return; let i = ((y - offset.y) * this.mapW) + (x - offset.x); - let layer = this.mapFile.layers.find(l => (l.name == info.layer)); + let layer = this.mapFile.layers.find(l => (l.name === info.layer)); if (layer) info.cell = layer.data[i]; }, onBeforeGetEventList: function (zone, list) { - if (zone != 'fjolarok') + if (zone !== 'fjolarok') return; list.push(this.relativeFolderName + '/maps/fjolarok/events/halloween.js'); diff --git a/src/server/mods/event-halloween/maps/fjolarok/events/halloween.js b/src/server/mods/event-halloween/maps/fjolarok/events/halloween.js index 898920c6..098cadf5 100644 --- a/src/server/mods/event-halloween/maps/fjolarok/events/halloween.js +++ b/src/server/mods/event-halloween/maps/fjolarok/events/halloween.js @@ -52,7 +52,7 @@ module.exports = { events: { beforeGatherResource: function (gatherResult, gatherer) { let itemName = gatherResult.blueprint.itemName; - if ((!itemName) || (itemName.toLowerCase() != 'candy corn')) + if ((!itemName) || (itemName.toLowerCase() !== 'candy corn')) return; gatherer.reputation.getReputation('pumpkinSailor', 40); diff --git a/src/server/mods/event-halloween/mtx/hauntedIceSpear.js b/src/server/mods/event-halloween/mtx/hauntedIceSpear.js index c636a9ff..971c820e 100644 --- a/src/server/mods/event-halloween/mtx/hauntedIceSpear.js +++ b/src/server/mods/event-halloween/mtx/hauntedIceSpear.js @@ -1,10 +1,10 @@ module.exports = { events: { beforeSpawnProjectile: function (item, spell, projectileConfig) { - if (spell.name.toLowerCase() != 'ice spear') + if (spell.name.toLowerCase() !== 'ice spear') return; - let cpnProjectile = projectileConfig.components.find(c => (c.type == 'projectile')); + let cpnProjectile = projectileConfig.components.find(c => (c.type === 'projectile')); cpnProjectile.particles = { color: { start: ['51fc9a', '48edff'], diff --git a/src/server/mods/event-halloween/spells/spellScatterPumpkinPieces.js b/src/server/mods/event-halloween/spells/spellScatterPumpkinPieces.js index 31d0f81f..c01c2466 100644 --- a/src/server/mods/event-halloween/spells/spellScatterPumpkinPieces.js +++ b/src/server/mods/event-halloween/spells/spellScatterPumpkinPieces.js @@ -9,7 +9,7 @@ let cpnPumpkinChunk = { update: function () { this.ttl--; - if (this.ttl == 0) + if (this.ttl === 0) this.obj.destroyed = true; }, @@ -20,7 +20,7 @@ let cpnPumpkinChunk = { this.obj.destroyed = true; if (this.isRotten) { - let drainCounts = this.caster.spellbook.spells.find(s => (s.type == 'scatterPumpkinPieces')).drainCounts; + let drainCounts = this.caster.spellbook.spells.find(s => (s.type === 'scatterPumpkinPieces')).drainCounts; if (drainCounts[o.name]) drainCounts[o.name] += 2; else diff --git a/src/server/mods/event-xmas/index.js b/src/server/mods/event-xmas/index.js index 626316cf..cee7e1c1 100644 --- a/src/server/mods/event-xmas/index.js +++ b/src/server/mods/event-xmas/index.js @@ -56,7 +56,7 @@ module.exports = { }, onBeforeGetEffect: function (result) { - if (result.type.toLowerCase() == 'merry') + if (result.type.toLowerCase() === 'merry') result.url = `${this.relativeFolderName}/effects/effectMerry.js`; }, @@ -103,7 +103,7 @@ module.exports = { let ox = obj.x; let oy = obj.y; - let objects = obj.instance.objects.objects.filter(o => (((o.mob) || (o.player)) && (o.name) && (o != obj))); + let objects = obj.instance.objects.objects.filter(o => (((o.mob) || (o.player)) && (o.name) && (o !== obj))); let closestDistance = 999; let closest = null; let oLen = objects.length; @@ -208,10 +208,10 @@ module.exports = { }, onAfterGetLayerObjects: function (info) { - if (info.map != 'fjolarok') + if (info.map !== 'fjolarok') return; - let layer = this.mapFile.layers.find(l => (l.name == info.layer)); + let layer = this.mapFile.layers.find(l => (l.name === info.layer)); if (layer) { let offset = this.mapOffset; let mapScale = this.mapFile.tilesets[0].tileheight; @@ -227,7 +227,7 @@ module.exports = { }, onBeforeBuildLayerTile: function (info) { - if (info.map != 'fjolarok') + if (info.map !== 'fjolarok') return; let offset = this.mapOffset; @@ -239,7 +239,7 @@ module.exports = { return; let i = ((y - offset.y) * this.mapW) + (x - offset.x); - let layer = this.mapFile.layers.find(l => (l.name == info.layer)); + let layer = this.mapFile.layers.find(l => (l.name === info.layer)); if (layer) { let cell = layer.data[i]; if (cell) @@ -286,7 +286,7 @@ module.exports = { }, onBeforeGetCardReward: function (msg) { - if (msg.reward == 'Rare Festive Spear') { + if (msg.reward === 'Rare Festive Spear') { msg.handler = function (card) { return itemGenerator.generate({ name: 'Festive Spear', @@ -300,7 +300,7 @@ module.exports = { sprite: [0, 0] }); }; - } else if (msg.reward == 'Scented Beard Oil') { + } else if (msg.reward === 'Scented Beard Oil') { msg.handler = function (card) { return { name: 'Scented Beard Oil', @@ -323,7 +323,7 @@ module.exports = { }, onBeforeGetEventList: function (zone, list) { - if (zone != 'fjolarok') + if (zone !== 'fjolarok') return; list.push(this.relativeFolderName + '/maps/fjolarok/events/xmas.js'); diff --git a/src/server/mods/event-xmas/maps/fjolarok/events/xmas.js b/src/server/mods/event-xmas/maps/fjolarok/events/xmas.js index 081892bd..c66bc1da 100644 --- a/src/server/mods/event-xmas/maps/fjolarok/events/xmas.js +++ b/src/server/mods/event-xmas/maps/fjolarok/events/xmas.js @@ -88,15 +88,15 @@ module.exports = { method: function (obj) { let inventory = obj.inventory; - let snowflakes = inventory.items.find(i => (i.name == 'Snowflake')); + let snowflakes = inventory.items.find(i => (i.name === 'Snowflake')); if ((!snowflakes) || (snowflakes.quantity < 15)) return 'Sorry, please come back when you have at least fifteen.'; while (true) { - snowflakes = inventory.items.find(i => (i.name == 'Snowflake')); + snowflakes = inventory.items.find(i => (i.name === 'Snowflake')); if ((!snowflakes) || (snowflakes.quantity < 15)) return; - else if ((!inventory.hasSpace()) && (snowflakes.quantity != 15)) + else if ((!inventory.hasSpace()) && (snowflakes.quantity !== 15)) return 'Sorry, it seems you don\'t have enough space to accept my gifts.'; obj.reputation.getReputation('theWinterMan', 100); @@ -153,7 +153,7 @@ module.exports = { }); let pick = pool[~~(Math.random() * pool.length)]; - let blueprint = rewards.find(r => (r.name == pick)); + let blueprint = rewards.find(r => (r.name === pick)); inventory.getItem(extend(true, {}, blueprint)); @@ -251,12 +251,12 @@ module.exports = { beforeGatherResource: function (gatherResult, gatherer) { let itemName = gatherResult.blueprint.itemName; - if ((!itemName) || (itemName.toLowerCase() != 'snowflake')) + if ((!itemName) || (itemName.toLowerCase() !== 'snowflake')) return; gatherer.reputation.getReputation('theWinterMan', 40); - if ((gatherResult.name != 'Gilded Gift') || (Math.random() >= 0.05)) + if ((gatherResult.name !== 'Gilded Gift') || (Math.random() >= 0.05)) return; gatherResult.items.push({ diff --git a/src/server/mods/feature-cards/cards.js b/src/server/mods/feature-cards/cards.js index ba297578..e0e1a806 100644 --- a/src/server/mods/feature-cards/cards.js +++ b/src/server/mods/feature-cards/cards.js @@ -68,18 +68,18 @@ module.exports = { if (rqrLevel) { if ((rqrLevel.push) && ((mobLevel < rqrLevel[0]) || (mobLevel > rqrLevel[1]))) return; - else if ((!rqrLevel.push) && (mobLevel != rqrLevel)) + else if ((!rqrLevel.push) && (mobLevel !== rqrLevel)) return; } let mobName = card.mobName; if (mobName) { - if ((mobName.toLowerCase) && (mob.name.toLowerCase() != mobName.toLowerCase())) + if ((mobName.toLowerCase) && (mob.name.toLowerCase() !== mobName.toLowerCase())) return; - else if ((mobName.push) && (!mobName.some(m => (m.toLowerCase() == mob.name.toLowerCase())))) + else if ((mobName.push) && (!mobName.some(m => (m.toLowerCase() === mob.name.toLowerCase())))) return; } - if ((card.zone) && (looter.zoneName != card.zone)) + if ((card.zone) && (looter.zoneName !== card.zone)) return; if (Math.random() >= card.chance) @@ -88,7 +88,7 @@ module.exports = { pool.push(c); }, this); - if (pool.length == 0) + if (pool.length === 0) return; let pickName = pool[~~(Math.random() * pool.length)]; @@ -125,7 +125,7 @@ module.exports = { }, rewards: { - 'Level 10 Rune': function (obj) { + 'Level 10 Rune': function () { return itemGenerator.generate({ level: 10, spell: true @@ -163,7 +163,6 @@ module.exports = { sprite: [0, 0], spritesheet: '../../../images/legendaryItems.png', type: 'Trident', - spellName: 'magic missile', description: 'Summoned from the ancient depths of the ocean by the Benthic Incantation.', stats: ['elementFrostPercent', 'elementFrostPercent', 'elementFrostPercent'], effects: [{ @@ -209,7 +208,6 @@ module.exports = { sprite: [1, 0], spritesheet: '../../../images/legendaryItems.png', type: 'Curved Dagger', - spellName: 'double slash', description: 'The blade seems to be made of some kind of bone and steel alloy.', stats: ['dex', 'dex', 'addCritMultiplier', 'addCritMultiplier'], effects: [{ diff --git a/src/server/mods/feature-cards/index.js b/src/server/mods/feature-cards/index.js index 0dc0c84e..eab6f642 100644 --- a/src/server/mods/feature-cards/index.js +++ b/src/server/mods/feature-cards/index.js @@ -35,7 +35,7 @@ module.exports = { }, onBeforeGetItem: function (item, obj) { - if ((!obj.player) && (item.type != 'Reward Card')) + if ((!obj.player) && (item.type !== 'Reward Card')) return; cards.fixCard(item); diff --git a/src/server/objects/objBase.js b/src/server/objects/objBase.js index cd5974ed..fd7b5ef1 100644 --- a/src/server/objects/objBase.js +++ b/src/server/objects/objBase.js @@ -15,14 +15,14 @@ module.exports = { }, blueprint || {}); } - let cpn = extend(true, {}, template); + cpn = extend(true, {}, template); cpn.obj = this; this.components.push(cpn); this[cpn.type] = cpn; } - if ((cpn.init) && (this.instance != null)) + if ((cpn.init) && (this.instance !== null)) cpn.init(blueprint || {}, isTransfer); else { for (let p in blueprint) @@ -55,14 +55,14 @@ module.exports = { update: function () { let usedTurn = false; - let components = this.components; - let len = components.length; + let cpns = this.components; + let len = cpns.length; for (let i = 0; i < len; i++) { - let c = components[i]; + let c = cpns[i]; if (c.destroyed) { this.syncer.setSelfArray(false, 'removeComponents', c.type); - this.components.spliceWhere(f => (f == c)); + cpns.spliceWhere(f => (f === c)); delete this[c.type]; len--; i--; @@ -82,9 +82,9 @@ module.exports = { if ((self) && (!isSave)) { let syncer = this.syncer; - if (this.syncer) { + if (syncer) { //Add things that have been queued by the syncer (that aren't tied to server-side components) - let components = this.syncer.oSelf.components + syncer.oSelf.components .filter((c => !this[c.type]), this) .forEach(c => s.components.push(c)); } @@ -103,13 +103,13 @@ module.exports = { for (let p in o) { let value = o[p]; - if (value == null) + if (value === null) continue; let type = typeof (value); //build component - if (type == 'object') { + if (type === 'object') { if (value.type) { if (!value.simplify) { if (self) { @@ -140,7 +140,7 @@ module.exports = { } } else if (syncTypes.indexOf(p) > -1) result[p] = value; - } else if (type != 'function') + } else if (type !== 'function') result[p] = value; } @@ -180,13 +180,13 @@ module.exports = { this.actionQueue.push(action); }, dequeue: function () { - if (this.actionQueue.length == 0) + if (this.actionQueue.length === 0) return null; return this.actionQueue.splice(0, 1)[0]; }, clearQueue: function () { - if (this.serverId != null) { + if (this.serverId !== null) { this.instance.syncer.queue('onClearQueue', { id: this.id }, [this.serverId]); @@ -215,8 +215,8 @@ module.exports = { if (!q) return; - if (q.action == 'move') { - if ((this.actionQueue[0]) && (this.actionQueue[0].action == 'move')) { + if (q.action === 'move') { + if ((this.actionQueue[0]) && (this.actionQueue[0].action === 'move')) { let sprintChance = this.stats.values.sprintChance || 0; let physics = this.instance.physics; if ((~~(Math.random() * 100) < sprintChance) && (!physics.isTileBlocking(q.data.x, q.data.y))) { @@ -227,9 +227,9 @@ module.exports = { let success = this.performMove(q); if (!success) this.clearQueue(); - } else if (q.action == 'clearQueue') + } else if (q.action === 'clearQueue') this.clearQueue(); - else if (q.action == 'spell') { + else if (q.action === 'spell') { let success = this.spellbook.cast(q); if (!success) this.performQueue(); @@ -245,7 +245,7 @@ module.exports = { data.success = true; this.fireEvent('beforeMove', data); - if (data.success == false) { + if (data.success === false) { action.priority = true; this.queue(action); return true; @@ -261,8 +261,8 @@ module.exports = { (deltaY > maxDistance) ) || ( - (deltaX == 0) && - (deltaY == 0) + (deltaX === 0) && + (deltaY === 0) ) ) return false; @@ -297,10 +297,10 @@ module.exports = { }, collisionEnter: function (obj) { - let components = this.components; - let cLen = components.length; + let cpns = this.components; + let cLen = cpns.length; for (let i = 0; i < cLen; i++) { - let c = components[i]; + let c = cpns[i]; if (c.collisionEnter) { if (c.collisionEnter(obj)) return true; @@ -308,10 +308,10 @@ module.exports = { } }, collisionExit: function (obj) { - let components = this.components; - let cLen = components.length; + let cpns = this.components; + let cLen = cpns.length; for (let i = 0; i < cLen; i++) { - let c = components[i]; + let c = cpns[i]; if (c.collisionExit) c.collisionExit(obj); } @@ -320,10 +320,10 @@ module.exports = { fireEvent: function (event) { let args = [].slice.call(arguments, 1); - let components = this.components; - let cLen = components.length; + let cpns = this.components; + let cLen = cpns.length; for (let i = 0; i < cLen; i++) { - let cpn = components[i]; + let cpn = cpns[i]; let events = cpn.events; if (!events) continue; @@ -348,14 +348,14 @@ module.exports = { }, destroy: function () { - let components = this.components; - let len = components.length; + let cpns = this.components; + let len = cpns.length; for (let i = 0; i < len; i++) { - let c = components[i]; + let c = cpns[i]; if (c.destroy) c.destroy(); } - components = null; + this.components = null; } }; diff --git a/src/server/objects/objects.js b/src/server/objects/objects.js index 82877335..021613d9 100644 --- a/src/server/objects/objects.js +++ b/src/server/objects/objects.js @@ -85,7 +85,7 @@ module.exports = { let properties = extend(true, {}, l.properties); ['cpnMob'].forEach(function (c) { let blueprint = properties[c] || null; - if ((blueprint) && (typeof (blueprint) == 'string')) + if ((blueprint) && (typeof (blueprint) === 'string')) blueprint = JSON.parse(blueprint); if (!blueprint) @@ -99,7 +99,7 @@ module.exports = { }, this); for (let p in properties) { - if (p.indexOf('cpn') == -1) { + if (p.indexOf('cpn') === -1) { obj[p] = properties[p]; continue; } @@ -107,7 +107,7 @@ module.exports = { let type = p.replace('cpn', ''); type = type[0].toLowerCase() + type.substr(1); let blueprint = properties[p] || null; - if ((blueprint) && (typeof (blueprint) == 'string')) + if ((blueprint) && (typeof (blueprint) === 'string')) blueprint = JSON.parse(blueprint); obj.addComponent(type, blueprint); @@ -134,7 +134,7 @@ module.exports = { if (obj.aggro) obj.aggro.move(); - if (lLen == 1) + if (lLen === 1) return obj; } }, @@ -151,9 +151,9 @@ module.exports = { let o = objects[i]; let match = false; if (useServerId) - match = (o.serverId == obj.id); + match = (o.serverId === obj.id); else - match = (o.id == obj.id); + match = (o.id === obj.id); if (match) { o.destroy(); @@ -171,7 +171,8 @@ module.exports = { physics.removeRegion(found); } - callback && callback(found); + if (callback) + callback(found); }, addObject: function (o, callback) { @@ -204,7 +205,7 @@ module.exports = { return newO; }, sendEvent: function (msg) { - let player = this.objects.find(p => p.id == msg.id); + let player = this.objects.find(p => p.id === msg.id); if (!player) return; @@ -227,7 +228,7 @@ module.exports = { let obj = eventEntry.obj; - if (e != 'serverModule') { + if (e !== 'serverModule') { let to = eventEntry.to; let toLen = to.length; for (let i = 0; i < toLen; i++) { @@ -235,7 +236,7 @@ module.exports = { let player = players[toId]; if (!player) { - let findPlayer = objects.find(o => o.id == toId); + let findPlayer = objects.find(o => o.id === toId); if (!findPlayer) continue; else { @@ -260,7 +261,7 @@ module.exports = { } }, updateObject: function (msg) { - let player = this.objects.find(p => p.id == msg.serverId); + let player = this.objects.find(p => p.id === msg.serverId); if (!player) return; diff --git a/src/server/security/connections.js b/src/server/security/connections.js index d5de1f53..8c1c5724 100644 --- a/src/server/security/connections.js +++ b/src/server/security/connections.js @@ -12,14 +12,14 @@ module.exports = { this.players.push(p); }, onDisconnect: function (socket) { - let player = this.players.find(p => p.socket.id == socket.id); + let player = this.players.find(p => p.socket.id === socket.id); if (!player) return; let sessionDuration = 0; - if (player.id != null) { + if (player.id !== null) { if (player.social) player.social.dc(); sessionDuration = ~~(((+new Date()) - player.player.sessionStart) / 1000); @@ -44,21 +44,21 @@ module.exports = { }); } - this.players.spliceWhere(p => p.socket.id == socket.id); + this.players.spliceWhere(p => p.socket.id === socket.id); }, route: function (socket, msg) { let player = null; - if (msg.id != null) { - player = this.players.find(p => p.id == msg.id); - let source = this.players.find(p => p.socket.id == socket.id); + if (msg.id !== null) { + player = this.players.find(p => p.id === msg.id); + let source = this.players.find(p => p.socket.id === socket.id); if (!source) return; if (!msg.data) msg.data = {}; msg.data.sourceId = source.id; } else - player = this.players.find(p => p.socket.id == socket.id); + player = this.players.find(p => p.socket.id === socket.id); if ( (!player) || @@ -68,7 +68,7 @@ module.exports = { ) || ( (player.dead) && - (msg.data.method != 'respawn') + (msg.data.method !== 'respawn') ) ) return; @@ -82,7 +82,7 @@ module.exports = { }, unzone: function (msg) { let socket = msg.socket; - let player = this.players.find(p => p.socket.id == socket.id); + let player = this.players.find(p => p.socket.id === socket.id); if (!player) return; @@ -94,9 +94,9 @@ module.exports = { let keys = Object.keys(player); keys.forEach(function (k) { let val = player[k]; - if ((val != null) && (typeof (val) == 'object') && (val.type)) { + if ((val !== null) && (typeof (val) === 'object') && (val.type)) { let type = val.type; - if ((type != 'player') && (type != 'auth') && (type != 'syncer')) + if ((type !== 'player') && (type !== 'auth') && (type !== 'syncer')) delete player[k]; } }); @@ -124,15 +124,15 @@ module.exports = { for (let i = 0; i < pLen; i++) { let p = players[i]; - if ((!p) || (p == exclude) || (!p.auth)) + if ((!p) || (p === exclude) || (!p.auth)) continue; - if (p.auth.username == exclude.auth.username) + if (p.auth.username === exclude.auth.username) p.socket.emit('dc', {}); } }, - getCharacterList: function (msg) { + getCharacterList: function () { let result = []; let players = this.players; let pLen = players.length; diff --git a/src/server/security/sheets.js b/src/server/security/sheets.js index 32f828d9..4e2dfdfc 100644 --- a/src/server/security/sheets.js +++ b/src/server/security/sheets.js @@ -35,7 +35,7 @@ module.exports = { }, getRecord: function (name) { - return (this.records || []).find(r => (r.username == name)); + return (this.records || []).find(r => (r.username === name)); }, onGetRows: function (err, rows) { @@ -55,9 +55,9 @@ module.exports = { o.messagePrefix = o.messageprefix; delete o.messageprefix; - if (typeof (o.items) == 'string') + if (typeof (o.items) === 'string') o.items = JSON.parse(o.items || '[]'); - if (typeof (o.skins) == 'string') + if (typeof (o.skins) === 'string') o.skins = JSON.parse(o.skins || '[]'); return o; diff --git a/src/server/server.js b/src/server/server.js index 6333ee79..dc3369dc 100644 --- a/src/server/server.js +++ b/src/server/server.js @@ -8,7 +8,7 @@ module.exports = { global.io = require('socket.io')(server); app.use(function (req, res, next) { - if ((req.url.indexOf('/server') != 0) && (req.url.indexOf('/mods') != 0)) + if ((req.url.indexOf('/server') !== 0) && (req.url.indexOf('/mods') !== 0)) req.url = '/client/' + req.url; next(); @@ -72,12 +72,12 @@ module.exports = { requests: { root: function (req, res) { //let ip = req.headers['x-forwarded-for'] || req.connection.remoteAddress; - //if (ip != '::1') + //if (ip !== '::1') // return; res.sendFile('index.html'); }, - default: function (req, res, next) { + default: function (req, res) { let root = req.url.split('/')[1]; let file = req.params[0]; diff --git a/src/server/world/atlas.js b/src/server/world/atlas.js index 14ed967f..3ac547c3 100644 --- a/src/server/world/atlas.js +++ b/src/server/world/atlas.js @@ -1,4 +1,3 @@ -let fileLister = require('../misc/fileLister'); let childProcess = require('child_process'); let objects = require('../objects/objects'); let mapList = require('../config/maps/mapList'); @@ -19,7 +18,7 @@ module.exports = { let thread = this.getThreadFromName(obj.zoneName); let instanceId = obj.instanceId; - if ((!thread) || (obj.zoneName != thread.name)) + if ((!thread) || (obj.zoneName !== thread.name)) instanceId = -1; if (!thread) { @@ -95,7 +94,7 @@ module.exports = { return this.nextCallbackId - 1; }, resolveCallback: function (msg) { - let callback = this.callbacks.spliceFirstWhere(c => c.id == msg.msg.id); + let callback = this.callbacks.spliceFirstWhere(c => c.id === msg.msg.id); if (!callback) return; @@ -109,10 +108,10 @@ module.exports = { }, getThreadFromId: function (id) { - return this.threads.find(t => t.id == id); + return this.threads.find(t => t.id === id); }, getThreadFromName: function (name) { - return this.threads.find(t => t.name == name); + return this.threads.find(t => t.name === name); }, getMapFiles: function () { @@ -136,7 +135,7 @@ module.exports = { onMessage: function (thread, message) { if (message.module) global[message.module][message.method](message); - else if (message.event == 'onCrashed') { + else if (message.event === 'onCrashed') { thread.worker.kill(); process.exit(); } else @@ -162,14 +161,14 @@ module.exports = { objects.updateObject(message); }, callDifferentThread: function (thread, message) { - let obj = connections.players.find(p => (p.name == message.playerName)); + let obj = connections.players.find(p => (p.name === message.playerName)); if (!obj) return; - let thread = this.getThreadFromName(obj.zoneName); - if (!thread) + let newThread = this.getThreadFromName(obj.zoneName); + if (!newThread) return; - thread.worker.send({ + newThread.worker.send({ module: message.data.module, method: message.data.method, args: message.data.args @@ -181,19 +180,19 @@ module.exports = { obj.zoneName = message.args.newZone; obj.id = obj.serverId; - let serverObj = objects.objects.find(o => o.id == obj.id); + let serverObj = objects.objects.find(o => o.id === obj.id); serverObj.zoneName = obj.zoneName; - let thread = this.getThreadFromName(obj.zoneName); + let newThread = this.getThreadFromName(obj.zoneName); - if (!thread) { - thread = this.getThreadFromName(serverConfig.defaultZone); - obj.zoneName = thread.name; - serverObj.zoneName = thread.name; + if (!newThread) { + newThread = this.getThreadFromName(serverConfig.defaultZone); + obj.zoneName = newThread.name; + serverObj.zoneName = newThread.name; } - serverObj.zone = thread.id; - obj.zone = thread.id; + serverObj.zone = newThread.id; + obj.zone = newThread.id; serverObj.player.broadcastSelf(); diff --git a/src/server/world/customMap.js b/src/server/world/customMap.js index 35a4a8ba..f0d0b6cf 100644 --- a/src/server/world/customMap.js +++ b/src/server/world/customMap.js @@ -1,5 +1,3 @@ -let io = require('../security/io'); - module.exports = { instance: null, ent: null, @@ -9,7 +7,7 @@ module.exports = { load: function (instance, objToAdd, callback) { this.instance = instance; - this.ent = instance.zone.name + '-' + objToAdd.components.find(c => c.type == 'auth').username; + this.ent = instance.zone.name + '-' + objToAdd.components.find(c => c.type === 'auth').username; io.get({ ent: this.ent, @@ -24,31 +22,21 @@ module.exports = { }, save: function () { - //this.tiles = []; - io.set({ ent: this.ent, field: 'customMap', - value: JSON.stringify(this.tiles), - callback: this.onSave.bind(this) + value: JSON.stringify(this.tiles) }); }, - onSave: function (result) { - - }, build: function (callback) { let map = this.instance.map.clientMap.map; - let w = map.length; - let h = map[0].length; this.tiles.forEach(function (t) { t = t.split('|'); this.customize(t[0], t[1], t[2], true); }, this); - //this.customize(~~(Math.random() * w), ~~(Math.random() * h), 52); - this.save(); callback(); @@ -56,7 +44,7 @@ module.exports = { customize: function (x, y, tile, noStore) { let action = null; - if (arguments.length == 1) { + if (arguments.length === 1) { action = x; let obj = action.obj; tile = action.tile; @@ -74,19 +62,18 @@ module.exports = { if (!noStore) { let exists = this.tiles.find(function (t) { t = t.split('|'); - if ((t[0] == x) && (t[1] == y)) + if ((t[0] === x) && (t[1] === y)) return true; }); if (exists) { tile = this.oldTiles[x + '|' + y]; collide = false; - this.tiles.spliceWhere(t => t == exists); - } - //Can't build on natural collisions - else if (this.instance.map.clientMap.collisionMap[x][y]) + this.tiles.spliceWhere(t => t === exists); + } else if (this.instance.map.clientMap.collisionMap[x][y]) { + //Can't build on natural collisions return; - else + } else this.tiles.push(x + '|' + y + '|' + tile); } diff --git a/src/server/world/instancer.js b/src/server/world/instancer.js index 7eadffcf..bad3b646 100644 --- a/src/server/world/instancer.js +++ b/src/server/world/instancer.js @@ -41,8 +41,7 @@ module.exports = { mail: mail, map: map, scheduler: scheduler, - eventEmitter: eventEmitter, - zone: map.zone + eventEmitter: eventEmitter }; this.instances.push(fakeInstance); @@ -61,7 +60,6 @@ module.exports = { this.queueAction = this.nonInstanced.queueAction.bind(this); this.performAction = this.nonInstanced.performAction.bind(this); this.removeObject = this.nonInstanced.removeObject.bind(this); - this.onRemoveObject = this.nonInstanced.onRemoveObject.bind(this); this.tick = this.nonInstanced.tick.bind(this); this.tick(); @@ -79,7 +77,6 @@ module.exports = { this.queueAction = this.instanced.queueAction.bind(this); this.performAction = this.instanced.performAction.bind(this); this.removeObject = this.instanced.removeObject.bind(this); - this.onRemoveObject = this.instanced.onRemoveObject.bind(this); if (map.mapFile.properties.isRandom) this.ttlGen = 0; @@ -111,7 +108,7 @@ module.exports = { let spawnPos = map.getSpawnPos(obj); - if ((!msg.keepPos) || (obj.x == null)) { + if ((!msg.keepPos) || (obj.x === null)) { obj.x = spawnPos.x; obj.y = spawnPos.y; } @@ -142,7 +139,7 @@ module.exports = { } }, updateObject: function (msg) { - let obj = objects.find(o => o.serverId == msg.id); + let obj = objects.find(o => o.serverId === msg.id); if (!obj) return; @@ -164,11 +161,11 @@ module.exports = { }, queueAction: function (msg) { - let obj = objects.find(o => o.serverId == msg.id); + let obj = objects.find(o => o.serverId === msg.id); if (!obj) return; - else if (msg.action.action == 'move') { - let moveEntries = obj.actionQueue.filter(q => (q.action == 'move')).length; + else if (msg.action.action === 'move') { + let moveEntries = obj.actionQueue.filter(q => (q.action === 'move')).length; if (moveEntries >= 50) return; } @@ -180,9 +177,9 @@ module.exports = { let obj = null; let targetId = msg.action.targetId; if (!targetId) - obj = objects.find(o => o.serverId == msg.id); + obj = objects.find(o => o.serverId === msg.id); else { - obj = objects.find(o => o.id == targetId); + obj = objects.find(o => o.id === targetId); if (obj) { let action = msg.action; if (!action.data) @@ -199,7 +196,7 @@ module.exports = { removeObject: function (msg) { let obj = msg.obj; - obj = objects.find(o => o.serverId == obj.id); + obj = objects.find(o => o.serverId === obj.id); if (!obj) { //We should probably never reach this return; @@ -212,9 +209,6 @@ module.exports = { obj.fireEvent('beforeRezone'); obj.destroyed = true; - }, - onRemoveObject: function (obj) { - } }, instanced: { @@ -251,7 +245,7 @@ module.exports = { instance.syncer.update(); - if (instance.closeTtl != null) { + if (instance.closeTtl !== null) { let hasPlayers = instance.objects.objects.some(o => o.player); if (hasPlayers) { delete instance.closeTtl; @@ -281,7 +275,7 @@ module.exports = { let instanceId = msg.instanceId; //Maybe a party member is in here already? - let social = obj.components.find(c => c.type == 'social'); + let social = obj.components.find(c => c.type === 'social'); if ((social) && (social.party)) { let party = social.party; let instances = this.instances; @@ -291,7 +285,7 @@ module.exports = { let partyInside = instance.objects.objects.some(o => party.indexOf(o.serverId) > -1); if (partyInside) { - if (instance.id != obj.instanceId) + if (instance.id !== obj.instanceId) msg.keepPos = false; obj.instanceId = instance.id; obj.instance = instance; @@ -304,7 +298,7 @@ module.exports = { if (msg.transfer) msg.keepPos = false; - let exists = this.instances.find(i => i.id == instanceId); + let exists = this.instances.find(i => i.id === instanceId); if (exists) { if ((msg.keepPos) && (!exists.physics.isValid(obj.x, obj.y))) @@ -316,7 +310,7 @@ module.exports = { if (exists) spawnPos = exists.map.getSpawnPos(obj); - if ((!msg.keepPos) || (obj.x == null)) { + if ((!msg.keepPos) || (obj.x === null)) { obj.x = spawnPos.x; obj.y = spawnPos.y; } @@ -328,8 +322,6 @@ module.exports = { obj.serverId = obj.id; delete obj.id; - let spawnPos = exists.map.getSpawnPos(obj); - obj.spawn = exists.map.spawn; exists.syncer.queue('onGetMap', exists.map.clientMap, [obj.serverId]); @@ -377,11 +369,11 @@ module.exports = { let id = msg.id; let instanceId = msg.instanceId; - let exists = this.instances.find(i => i.id == instanceId); + let exists = this.instances.find(i => i.id === instanceId); if (!exists) return; - let obj = exists.objects.find(o => o.serverId == id); + let obj = exists.objects.find(o => o.serverId === id); if (!obj) return; @@ -406,11 +398,11 @@ module.exports = { let id = msg.id; let instanceId = msg.instanceId; - let exists = this.instances.find(i => i.id == instanceId); + let exists = this.instances.find(i => i.id === instanceId); if (!exists) return; - let obj = exists.objects.find(o => o.serverId == id); + let obj = exists.objects.find(o => o.serverId === id); if (!obj) return; @@ -421,14 +413,14 @@ module.exports = { let id = msg.id; let instanceId = msg.instanceId; - let exists = this.instances.find(i => i.id == instanceId); + let exists = this.instances.find(i => i.id === instanceId); if (!exists) return; - let obj = exists.objects.find(o => o.serverId == id); + let obj = exists.objects.find(o => o.serverId === id); if (obj) { - if (msg.action.action == 'move') { - let moveEntries = obj.actionQueue.filter(q => (q.action == 'move')).length; + if (msg.action.action === 'move') { + let moveEntries = obj.actionQueue.filter(q => (q.action === 'move')).length; if (moveEntries >= 50) return; } @@ -441,12 +433,11 @@ module.exports = { let obj = msg.obj; let instanceId = msg.instanceId; - let exists = this.instances.find(i => i.id == instanceId); + let exists = this.instances.find(i => i.id === instanceId); if (!exists) return; - let obj = msg.obj; - obj = exists.objects.find(o => o.serverId == obj.id); + obj = exists.objects.find(o => o.serverId === obj.id); if (!obj) return; @@ -456,9 +447,6 @@ module.exports = { obj.destroyed = true; }, - onRemoveObject: function (obj) { - - }, createInstance: function (objToAdd, transfer) { let newMap = { diff --git a/src/server/world/map.js b/src/server/world/map.js index fc8e8315..7392ba92 100644 --- a/src/server/world/map.js +++ b/src/server/world/map.js @@ -7,7 +7,7 @@ let randomMap = require('./randomMap'); let events = require('../misc/events'); let mapFile = null; -let mapscale = 38; +let mapScale = null; let padding = null; module.exports = { @@ -87,7 +87,7 @@ module.exports = { this.instanced = mapFile.properties.instanced; this.custom = mapFile.properties.custom; if (this.instanced) - this.instanced = (this.instanced == '1'); + this.instanced = (this.instanced === '1'); if (mapFile.properties.spawn) { this.spawn = JSON.parse(mapFile.properties.spawn); @@ -134,7 +134,7 @@ module.exports = { newCell += newC; //Wall? - if ((c >= 160) && (c <= 352) && (newC == 0)) + if ((c >= 160) && (c <= 352) && (newC === 0)) this.collisionMap[i][j] = 0; if (k < cLen - 1) @@ -210,7 +210,7 @@ module.exports = { let data = layer.data || layer.objects; let firstItem = data[0]; - if ((firstItem) && (firstItem.width != null)) { + if ((firstItem) && (firstItem.width !== null)) { let info = { map: this.name, layer: layerName, @@ -273,8 +273,8 @@ module.exports = { let y = ~~(i / this.size.w); let x = i - (y * this.size.w); - if (cell == 0) { - if (layerName == 'tiles') + if (cell === 0) { + if (layerName === 'tiles') this.collisionMap[x][y] = 1; return; @@ -282,31 +282,31 @@ module.exports = { let cellInfo = this.builders.getCellInfo(cell); let sheetName = cellInfo.sheetName; - let cell = cellInfo.cell; - if (sheetName == 'walls') + cell = cellInfo.cell; + if (sheetName === 'walls') cell += 192; - else if (sheetName == 'objects') + else if (sheetName === 'objects') cell += 448; - if ((layerName != 'hiddenWalls') && (layerName != 'hiddenTiles')) { + if ((layerName !== 'hiddenWalls') && (layerName !== 'hiddenTiles')) { let layer = this.layers; if (this.oldLayers[layerName]) this.oldLayers[layerName][x][y] = cell; - layer[x][y] = (layer[x][y] == null) ? cell : layer[x][y] + ',' + cell; - } else if (layerName == 'hiddenWalls') + layer[x][y] = (layer[x][y] === null) ? cell : layer[x][y] + ',' + cell; + } else if (layerName === 'hiddenWalls') this.hiddenWalls[x][y] = cell; - else if (layerName == 'hiddenTiles') + else if (layerName === 'hiddenTiles') this.hiddenTiles[x][y] = cell; if (layerName.indexOf('walls') > -1) this.collisionMap[x][y] = 1; else if (sheetName.toLowerCase().indexOf('tiles') > -1) { - if ((cell == 6) || (cell == 7) || (cell == 54) || (cell == 55) || (cell == 62) || (cell == 63) || (cell == 154) || (cell == 189) || (cell == 190)) + if ((cell === 6) || (cell === 7) || (cell === 54) || (cell === 55) || (cell === 62) || (cell === 63) || (cell === 154) || (cell === 189) || (cell === 190)) this.collisionMap[x][y] = 1; } }, - object: function (layerName, cell, i) { - let clientObj = (layerName == 'clientObjects'); + object: function (layerName, cell) { + let clientObj = (layerName === 'clientObjects'); let cellInfo = this.builders.getCellInfo(cell.gid); let name = (cell.name || ''); @@ -327,7 +327,7 @@ module.exports = { properties: cell.properties || {} }; - if (objZoneName != name) + if (objZoneName !== name) blueprint.objZoneName = objZoneName; if (this.zone) { @@ -340,14 +340,14 @@ module.exports = { if (blueprint.blocking) this.collisionMap[blueprint.x][blueprint.y] = 1; - if ((blueprint.properties.cpnNotice) || (blueprint.properties.cpnLightPatch) || (layerName == 'rooms') || (layerName == 'hiddenRooms')) { + if ((blueprint.properties.cpnNotice) || (blueprint.properties.cpnLightPatch) || (layerName === 'rooms') || (layerName === 'hiddenRooms')) { blueprint.y++; blueprint.width = cell.width / mapScale; blueprint.height = cell.height / mapScale; - } else if (cell.width == 24) + } else if (cell.width === 24) blueprint.x++; - if (layerName == 'rooms') { + if (layerName === 'rooms') { if (blueprint.properties.exit) { let room = this.rooms.find(function (r) { return (!( @@ -366,9 +366,9 @@ module.exports = { blueprint.objects = []; this.rooms.push(blueprint); } - } else if (layerName == 'hiddenRooms') + } else if (layerName === 'hiddenRooms') this.hiddenRooms.push(blueprint); - else if (!clientObj) { + else if (!clientObj) { if (!mapFile.properties.isRandom) spawners.register(blueprint, blueprint.spawnCd || mapFile.properties.spawnCd); else { @@ -390,7 +390,7 @@ module.exports = { }, getSpawnPos: function (obj) { - let stats = obj.components.find(c => (c.type == 'stats')); + let stats = obj.components.find(c => (c.type === 'stats')); let level = stats.values.level; let spawns = this.spawn.filter(s => (((s.maxLevel) && (s.maxLevel >= level)) || (!s.maxLevel))); diff --git a/src/server/world/mobBuilder.js b/src/server/world/mobBuilder.js index a53d4f87..fcf4c95e 100644 --- a/src/server/world/mobBuilder.js +++ b/src/server/world/mobBuilder.js @@ -17,7 +17,7 @@ module.exports = { mob.addComponent('effects'); if (type) { - if (type != 'regular') { + if (type !== 'regular') { mob.effects.addEffect({ type: type }); @@ -29,7 +29,7 @@ module.exports = { if (typeDefinition.sheetName) mob.sheetName = typeDefinition.sheetName; - if (typeDefinition.cell != null) + if (typeDefinition.cell !== null) mob.cell = typeDefinition.cell; } } @@ -50,7 +50,7 @@ module.exports = { let spells = extend(true, [], blueprint.spells); spells.forEach(function (s) { if (!s.animation) { - if ((mob.sheetName == 'mobs') && (animations.mobs[mob.cell])) + if ((mob.sheetName === 'mobs') && (animations.mobs[mob.cell])) s.animation = 'basic'; } }); @@ -142,7 +142,7 @@ module.exports = { drops.blueprints.forEach(function (d) { let drop = extend(true, {}, d); d.level = level; - if (drop.type == 'key') + if (drop.type === 'key') return; mob.inventory.getItem(itemGenerator.generate(drop)); diff --git a/src/server/world/physics.js b/src/server/world/physics.js index 15f7cf6c..e04f97cd 100644 --- a/src/server/world/physics.js +++ b/src/server/world/physics.js @@ -73,7 +73,7 @@ module.exports = { for (let k = 0; k < cLen; k++) { let c = cell[k]; - if (c.id != oId) { + if (c.id !== oId) { c.collisionExit(obj); obj.collisionExit(c); } else { @@ -134,7 +134,7 @@ module.exports = { for (let i = 0; i < cLen; i++) { let c = cell[i]; - if (c.id != oId) { + if (c.id !== oId) { //If we have toX and toY, check if the target cell doesn't contain the same obj (like a notice area) if ((c.width) && (toX)) { if ((toX < c.x) || (toY < c.y) || (toX >= c.x + c.width) || (toY >= c.y + c.height)) { @@ -251,7 +251,7 @@ module.exports = { continue; let cell = row[j]; - if (cell.length == 0) { + if (cell.length === 0) { return { x: i, y: j @@ -366,9 +366,9 @@ module.exports = { let node = graphGrid[x][y]; - if ((!node) || (node.weight == 0)) + if ((!node) || (node.weight === 0)) return false; - else if ((x == toX) && (y == toY)) + else if ((x === toX) && (y === toY)) return true; } @@ -417,7 +417,7 @@ module.exports = { highY = y2 + 1; } - for (let i = lowX; i != highX; i += incX) { + for (let i = lowX; i !== highX; i += incX) { if ((i < 0) || (i >= width)) continue; @@ -428,14 +428,14 @@ module.exports = { if (!t) t = tried[i] = {}; - for (let j = lowY; j != highY; j += incY) { + for (let j = lowY; j !== highY; j += incY) { if (t[j]) continue; t[j] = 1; if ( - ((i == toX) && (j == toY)) || + ((i === toX) && (j === toY)) || ((j < 0) || (j >= height)) || (row[j]) ) @@ -448,7 +448,7 @@ module.exports = { for (let k = 0; k < cLen; k++) { let aggro = cell[k].aggro; if (aggro) { - blocking = aggro.list.some(a => a.obj == target); + blocking = aggro.list.some(a => a.obj === target); if (blocking) break; } @@ -475,14 +475,14 @@ module.exports = { let cell = this.cells[x][y]; let cLen = cell.length; - if (cLen == 1) + if (cLen === 1) return false; let found = false; for (let i = 0; i < cLen; i++) { let c = cell[i]; if (c.aggro) { - if ((!found) && (c == obj)) + if ((!found) && (c === obj)) found = true; else return true; diff --git a/src/server/world/randomMap.js b/src/server/world/randomMap.js index 89b00c0e..a1a1c525 100644 --- a/src/server/world/randomMap.js +++ b/src/server/world/randomMap.js @@ -34,8 +34,8 @@ module.exports = { }, isValidDungeon: function () { - let endRooms = this.rooms.filter(r => r.connections.length == 0); - let endDistanceReached = endRooms.find(r => r.distance == this.maxDistance, this); + let endRooms = this.rooms.filter(r => r.connections.length === 0); + let endDistanceReached = endRooms.find(r => r.distance === this.maxDistance, this); if (!endDistanceReached) return false; @@ -63,7 +63,7 @@ module.exports = { for (let i = 0; i < 2; i++) { for (let j = 0; j < 2; j++) { for (let k = 0; k < 2; k++) { - if (i + j + k == 0) + if (i + j + k === 0) continue; let flipped = extend(true, { @@ -285,7 +285,7 @@ module.exports = { template.objects.spliceWhere(function (o) { let ox = o.x - template.x + room.x; let oy = o.y - template.y + room.y; - return ((ox == x) && (oy == y)); + return ((ox === x) && (oy === y)); }); } @@ -379,9 +379,9 @@ module.exports = { this.setupConnection(room, !isHallway); } - if ((isHallway) && (room.connections.length == 0)) { - this.rooms.spliceWhere(r => r == room); - room.parent.connections.spliceWhere(c => c == room); + if ((isHallway) && (room.connections.length === 0)) { + this.rooms.spliceWhere(r => r === room); + room.parent.connections.spliceWhere(c => c === room); return false; } @@ -389,7 +389,7 @@ module.exports = { }, setupConnection: function (fromRoom, isHallway) { - if (fromRoom.template.exits.length == 0) + if (fromRoom.template.exits.length === 0) return true; let fromExit = fromRoom.template.exits.splice(this.randInt(0, fromRoom.template.exits.length), 1)[0]; @@ -397,27 +397,27 @@ module.exports = { let templates = this.templates.filter(function (t) { if ( (t.properties.mapping) || - (!!t.properties.hallway != isHallway) || + (!!t.properties.hallway !== isHallway) || (t.properties.start) || ( (t.properties.end) && - (fromRoom.distance + 1 != this.maxDistance) + (fromRoom.distance + 1 !== this.maxDistance) ) ) return false; let isValid = t.exits.some(function (e) { let direction = JSON.parse(e.properties.exit); - return ((direction[0] == -exitDirection[0]) && (direction[1] == -exitDirection[1])); + return ((direction[0] === -exitDirection[0]) && (direction[1] === -exitDirection[1])); }); if ((isValid) && (t.properties.maxOccur)) { - let occurs = this.rooms.filter(r => (r.template.typeId == t.typeId)).length; + let occurs = this.rooms.filter(r => (r.template.typeId === t.typeId)).length; if (occurs >= ~~t.properties.maxOccur) isValid = false; } - if ((isValid) && (fromRoom.distance + 1 == this.maxDistance)) { + if ((isValid) && (fromRoom.distance + 1 === this.maxDistance)) { //If there is an exit available, rather use that if (!t.properties.end) { let endsAvailable = this.templates.filter(function (tt) { @@ -425,7 +425,7 @@ module.exports = { return false; else if (!~~tt.properties.maxOccur) return true; - else if (this.rooms.filter(r => r.template.typeId == tt.typeId).length < ~~tt.properties.maxOccur) + else if (this.rooms.filter(r => r.template.typeId === tt.typeId).length < ~~tt.properties.maxOccur) return true; }, this); @@ -437,7 +437,7 @@ module.exports = { return isValid; }, this); - if (templates.length == 0) { + if (templates.length === 0) { fromRoom.template.exits.push(fromExit); return false; } @@ -446,10 +446,10 @@ module.exports = { let templateExit = template.exits.filter(function (e) { let direction = JSON.parse(e.properties.exit); - return ((direction[0] == -exitDirection[0]) && (direction[1] == -exitDirection[1])); + return ((direction[0] === -exitDirection[0]) && (direction[1] === -exitDirection[1])); }); templateExit = templateExit[this.randInt(0, templateExit.length)]; - let exitIndex = template.exits.firstIndex(e => e == templateExit); + let exitIndex = template.exits.firstIndex(e => e === templateExit); template.exits.splice(exitIndex, 1); @@ -489,7 +489,7 @@ module.exports = { doesCollide: function (room, ignore) { for (let i = 0; i < this.rooms.length; i++) { let r = this.rooms[i]; - if (r == ignore) + if (r === ignore) continue; let collides = (!( diff --git a/src/server/world/resourceSpawner.js b/src/server/world/resourceSpawner.js index 87072270..7537111f 100644 --- a/src/server/world/resourceSpawner.js +++ b/src/server/world/resourceSpawner.js @@ -21,7 +21,7 @@ module.exports = { }, register: function (name, blueprint) { - let exists = this.nodes.find(n => (n.blueprint.name == name)); + let exists = this.nodes.find(n => (n.blueprint.name === name)); if (exists) { if (!exists.blueprint.positions) { exists.blueprint.positions = [{ @@ -69,7 +69,7 @@ module.exports = { let position = null; - if (blueprint.type == 'herb') { + if (blueprint.type === 'herb') { x = ~~(Math.random() * w); y = ~~(Math.random() * h); @@ -86,7 +86,7 @@ module.exports = { let endTile = path[path.length - 1]; if (!endTile) return false; - else if ((endTile.x != x) || (endTile.y != y)) + else if ((endTile.x !== x) || (endTile.y !== y)) return false; //Don't spawn in rooms or on objects/other resources @@ -98,8 +98,8 @@ module.exports = { blueprint.y = y; } else if (blueprint.positions) { //Find all possible positions in which a node hasn't spawned yet - position = blueprint.positions.filter(f => !node.spawns.some(s => ((s.x == f.x) && (s.y == f.y)))); - if (position.length == 0) + position = blueprint.positions.filter(f => !node.spawns.some(s => ((s.x === f.x) && (s.y === f.y)))); + if (position.length === 0) return false; position = position[~~(Math.random() * position.length)]; @@ -123,7 +123,7 @@ module.exports = { let obj = this.objects.buildObjects([objBlueprint]); delete obj.ttl; - if (blueprint.type == 'herb') { + if (blueprint.type === 'herb') { this.syncer.queue('onGetObject', { x: obj.x, y: obj.y, @@ -145,14 +145,14 @@ module.exports = { type: node.type, sprite: node.blueprint.itemSprite, name: node.blueprint.name, - quantity: (blueprint.type != 'fish') ? 1 : null, + quantity: (blueprint.type !== 'fish') ? 1 : null, quality: 0 }; if (blueprint.itemSheet) item.spritesheet = blueprint.itemSheet; - if (blueprint.type == 'fish') + if (blueprint.type === 'fish') item.noStack = true; inventory.getItem(item); @@ -183,7 +183,7 @@ module.exports = { } } - if ((sLen < node.max) && (node.cd == 0)) { + if ((sLen < node.max) && (node.cd === 0)) { if (this.spawn(node)) { node.cd = this.cdMax; break; diff --git a/src/server/world/spawners.js b/src/server/world/spawners.js index aa5e1a6b..18d61296 100644 --- a/src/server/world/spawners.js +++ b/src/server/world/spawners.js @@ -31,7 +31,7 @@ module.exports = { this.list.push(spawner); - if ((blueprint.sheetName != 'mobs') && (blueprint.sheetName != 'bosses')) + if ((blueprint.sheetName !== 'mobs') && (blueprint.sheetName !== 'bosses')) return; let name = blueprint.name.toLowerCase(); @@ -44,7 +44,7 @@ module.exports = { }, spawn: function (spawner) { - if (spawner.amountLeft == 0) + if (spawner.amountLeft === 0) return; let blueprint = spawner.blueprint; @@ -78,7 +78,7 @@ module.exports = { }, -1); } - if (spawner.amountLeft != -1) + if (spawner.amountLeft !== -1) spawner.amountLeft--; return obj; @@ -131,7 +131,7 @@ module.exports = { ) || ( (!l.cron) && - (l.cd == 0) + (l.cd === 0) ) || ( (!l.mob) && @@ -149,7 +149,7 @@ module.exports = { let name = (l.blueprint.objZoneName || l.blueprint.name).toLowerCase(); - if ((l.blueprint.sheetName == 'mobs') || (l.blueprint.sheetName == 'bosses')) + if ((l.blueprint.sheetName === 'mobs') || (l.blueprint.sheetName === 'bosses')) this.setupMob(mob, l.zonePrint, l.blueprint.scaleDrops); else { let blueprint = extend(true, {}, this.zone.objects.default, this.zone.objects[name] || {}); @@ -189,7 +189,7 @@ module.exports = { (l.mob) && (!l.mob.destroyed) && (l.mob.isRare) && - (l.mob.baseName == mob.name) + (l.mob.baseName === mob.name) )); if (rareCount.length < blueprint.rare.count) { let roll = Math.random() * 100; diff --git a/src/server/world/worker.js b/src/server/world/worker.js index 2daa5a86..6e9b4e8b 100644 --- a/src/server/world/worker.js +++ b/src/server/world/worker.js @@ -1,10 +1,9 @@ -global.io = true; - global.extend = require('extend'); -let helpers = require('../misc/helpers'); +global.io = require('../security/io'); +global._ = require('../misc/helpers'); +global.instancer = require('./instancer'); + let components = require('../components/components'); -let instancer = require('./instancer'); -let io = require('../security/io'); let mods = require('../misc/mods'); let mtx = require('../mtx/mtx'); let animations = require('../config/animations'); @@ -37,8 +36,6 @@ let onModsReady = function () { }; let onDbReady = function () { - global._ = helpers; - global.instancer = instancer; require('../misc/random'); mods.init(onModsReady);