@@ -18,7 +18,7 @@ module.exports = { | |||||
this.faction = blueprint.faction; | this.faction = blueprint.faction; | ||||
//TODO: Why don't we move if faction is null? | //TODO: Why don't we move if faction is null? | ||||
if (this.faction == null) | |||||
if (this.faction === null) | |||||
return; | return; | ||||
if (this.physics.width > 0) | if (this.physics.width > 0) | ||||
@@ -92,7 +92,7 @@ module.exports = { | |||||
let faction = this.faction; | 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))))); | 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; | return; | ||||
let iLen = inRange.length; | let iLen = inRange.length; | ||||
@@ -103,7 +103,7 @@ module.exports = { | |||||
lLen = list.length; | lLen = list.length; | ||||
for (let j = 0; j < lLen; j++) { | for (let j = 0; j < lLen; j++) { | ||||
//Set the enemy to null so we need we need to continue | //Set the enemy to null so we need we need to continue | ||||
if (list[j].obj == enemy) | |||||
if (list[j].obj === enemy) | |||||
enemy = null; | enemy = null; | ||||
} | } | ||||
if (!enemy) | if (!enemy) | ||||
@@ -120,32 +120,32 @@ module.exports = { | |||||
canAttack: function (target) { | canAttack: function (target) { | ||||
let obj = this.obj; | let obj = this.obj; | ||||
if (target == obj) | |||||
if (target === obj) | |||||
return false; | return false; | ||||
else if ((target.player) && (obj.player)) { | else if ((target.player) && (obj.player)) { | ||||
let hasButcher = (obj.prophecies.hasProphecy('butcher')) && (target.prophecies.hasProphecy('butcher')); | let hasButcher = (obj.prophecies.hasProphecy('butcher')) && (target.prophecies.hasProphecy('butcher')); | ||||
if ((!target.social.party) || (!obj.social.party)) | if ((!target.social.party) || (!obj.social.party)) | ||||
return hasButcher; | return hasButcher; | ||||
else if (target.social.partyLeaderId != obj.social.partyLeaderId) | |||||
else if (target.social.partyLeaderId !== obj.social.partyLeaderId) | |||||
return hasButcher; | return hasButcher; | ||||
return false; | return false; | ||||
} else if ((target.follower) && (target.follower.master.player) && (obj.player)) | } else if ((target.follower) && (target.follower.master.player) && (obj.player)) | ||||
return false; | return false; | ||||
else if (obj.player) | else if (obj.player) | ||||
return true; | return true; | ||||
else if (target.aggro.faction != obj.aggro.faction) | |||||
else if (target.aggro.faction !== obj.aggro.faction) | |||||
return true; | return true; | ||||
else if (!!target.player != !!obj.player) | |||||
else if (!!target.player !== !!obj.player) | |||||
return true; | return true; | ||||
}, | }, | ||||
willAutoAttack: function (target) { | willAutoAttack: function (target) { | ||||
if (this.obj == target) | |||||
if (this.obj === target) | |||||
return false; | return false; | ||||
let faction = target.aggro.faction; | let faction = target.aggro.faction; | ||||
if ((faction == null) || (!this.faction)) | |||||
if ((faction === null) || (!this.faction)) | |||||
return false; | return false; | ||||
let rep = this.obj.reputation; | let rep = this.obj.reputation; | ||||
@@ -160,17 +160,17 @@ module.exports = { | |||||
}, | }, | ||||
ignore: function (obj) { | ignore: function (obj) { | ||||
this.ignoreList.spliceWhere(o => o == obj); | |||||
this.ignoreList.spliceWhere(o => o === obj); | |||||
this.ignoreList.push(obj); | this.ignoreList.push(obj); | ||||
}, | }, | ||||
unIgnore: function (obj) { | unIgnore: function (obj) { | ||||
this.ignoreList.spliceWhere(o => o == obj); | |||||
this.ignoreList.spliceWhere(o => o === obj); | |||||
}, | }, | ||||
tryEngage: function (obj, amount, threatMult) { | tryEngage: function (obj, amount, threatMult) { | ||||
//Don't aggro yourself, stupid | //Don't aggro yourself, stupid | ||||
if (obj == this.obj) | |||||
if (obj === this.obj) | |||||
return; | return; | ||||
let result = { | let result = { | ||||
@@ -185,7 +185,7 @@ module.exports = { | |||||
if (!mob) | if (!mob) | ||||
mob = obj.mob; | mob = obj.mob; | ||||
if (mob) { | if (mob) { | ||||
let notMob = (obj == mob) ? this.obj : obj; | |||||
let notMob = (obj === mob) ? this.obj : obj; | |||||
if (!mob.canChase(notMob)) | if (!mob.canChase(notMob)) | ||||
return false; | return false; | ||||
} | } | ||||
@@ -196,7 +196,7 @@ module.exports = { | |||||
amount = amount || 0; | amount = amount || 0; | ||||
threatMult = threatMult || 1; | threatMult = threatMult || 1; | ||||
let exists = list.find(l => l.obj.id == oId); | |||||
let exists = list.find(l => l.obj.id === oId); | |||||
if (exists) { | if (exists) { | ||||
exists.damage += amount; | exists.damage += amount; | ||||
exists.threat += amount * threatMult; | exists.threat += amount * threatMult; | ||||
@@ -251,10 +251,10 @@ module.exports = { | |||||
for (let i = 0; i < lLen; i++) { | for (let i = 0; i < lLen; i++) { | ||||
let l = list[i]; | let l = list[i]; | ||||
if (l.obj != obj) | |||||
if (l.obj !== obj) | |||||
continue; | continue; | ||||
if (amount == null) { | |||||
if (amount === null) { | |||||
list.splice(i, 1); | list.splice(i, 1); | ||||
obj.aggro.unAggro(this.obj); | obj.aggro.unAggro(this.obj); | ||||
break; | 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 | //Stuff like cocoons don't have spellbooks | ||||
if (this.obj.spellbook) | if (this.obj.spellbook) | ||||
this.obj.spellbook.unregisterCallback(obj.id, true); | 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(); | this.obj.stats.resetHp(); | ||||
}, | }, | ||||
@@ -285,7 +285,7 @@ module.exports = { | |||||
}, | }, | ||||
getHighest: function () { | getHighest: function () { | ||||
if (this.list.length == 0) | |||||
if (this.list.length === 0) | |||||
return null; | return null; | ||||
let list = this.list; | let list = this.list; | ||||
@@ -302,13 +302,13 @@ module.exports = { | |||||
let l = list[i]; | let l = list[i]; | ||||
let obj = l.obj; | let obj = l.obj; | ||||
if (this.ignoreList.some(o => o == obj)) | |||||
if (this.ignoreList.some(o => o === obj)) | |||||
continue; | continue; | ||||
if ((highest == null) || (l.threat > highest.threat)) { | |||||
if ((highest === null) || (l.threat > highest.threat)) { | |||||
highest = l; | highest = l; | ||||
closest = Math.max(Math.abs(x - obj.x), Math.abs(y - obj.y)); | 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)); | let distance = Math.max(Math.abs(x - obj.x), Math.abs(y - obj.y)); | ||||
if (distance < closest) { | if (distance < closest) { | ||||
highest = l; | highest = l; | ||||
@@ -23,7 +23,7 @@ module.exports = { | |||||
customChannels: [], | customChannels: [], | ||||
play: function (data) { | play: function (data) { | ||||
if (this.username == null) | |||||
if (this.username === null) | |||||
return; | return; | ||||
let character = this.characters[data.data.name]; | let character = this.characters[data.data.name]; | ||||
@@ -47,7 +47,7 @@ module.exports = { | |||||
let scheduler = require('../misc/scheduler'); | let scheduler = require('../misc/scheduler'); | ||||
let time = scheduler.getTime(); | let time = scheduler.getTime(); | ||||
let lastLogin = accountInfo.lastLogin; | let lastLogin = accountInfo.lastLogin; | ||||
if ((!lastLogin) || (lastLogin.day != time.day)) { | |||||
if ((!lastLogin) || (lastLogin.day !== time.day)) { | |||||
let daysSkipped = 1; | let daysSkipped = 1; | ||||
if (lastLogin) { | if (lastLogin) { | ||||
if (time.day > lastLogin.day) | if (time.day > lastLogin.day) | ||||
@@ -61,7 +61,7 @@ module.exports = { | |||||
} | } | ||||
} | } | ||||
if (daysSkipped == 1) { | |||||
if (daysSkipped === 1) { | |||||
accountInfo.loginStreak++; | accountInfo.loginStreak++; | ||||
if (accountInfo.loginStreak > 21) | if (accountInfo.loginStreak > 21) | ||||
accountInfo.loginStreak = 21; | accountInfo.loginStreak = 21; | ||||
@@ -100,12 +100,12 @@ module.exports = { | |||||
doSave: function (extensionObj) { | doSave: function (extensionObj) { | ||||
let simple = this.obj.getSimple(true, true); | 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); | 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.party; | ||||
delete social.customChannels; | delete social.customChannels; | ||||
@@ -116,11 +116,11 @@ module.exports = { | |||||
if ( | if ( | ||||
( | ( | ||||
(s.indexOf('xp') > -1) && | (s.indexOf('xp') > -1) && | ||||
(s != 'xpIncrease') | |||||
(s !== 'xpIncrease') | |||||
) || | ) || | ||||
(s == 'level') || | |||||
(s == 'hp') || | |||||
(s == 'mana') | |||||
(s === 'level') || | |||||
(s === 'hp') || | |||||
(s === 'mana') | |||||
) | ) | ||||
continue; | continue; | ||||
@@ -129,7 +129,7 @@ module.exports = { | |||||
//Calculate and store the ttl for effects | //Calculate and store the ttl for effects | ||||
let time = +new Date(); | 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) | if (e.expire) | ||||
return; | return; | ||||
@@ -169,7 +169,7 @@ module.exports = { | |||||
}, | }, | ||||
getCharacterList: function (data) { | getCharacterList: function (data) { | ||||
if (this.username == null) | |||||
if (this.username === null) | |||||
return; | return; | ||||
io.get({ | io.get({ | ||||
@@ -182,7 +182,7 @@ module.exports = { | |||||
let characters = JSON.parse(result || '[]'); | let characters = JSON.parse(result || '[]'); | ||||
this.characterList = characters; | this.characterList = characters; | ||||
let result = characters | |||||
result = characters | |||||
.map(c => ({ | .map(c => ({ | ||||
name: c.name ? c.name : c, | name: c.name ? c.name : c, | ||||
level: leaderboard.getLevel(c.name ? c.name : c) | level: leaderboard.getLevel(c.name ? c.name : c) | ||||
@@ -193,7 +193,7 @@ module.exports = { | |||||
getCharacter: function (data) { | getCharacter: function (data) { | ||||
let name = data.data.name; | 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; | return; | ||||
io.get({ | io.get({ | ||||
@@ -237,14 +237,14 @@ module.exports = { | |||||
onGetCustomChannels: function (data, character, result) { | onGetCustomChannels: function (data, character, result) { | ||||
this.customChannels = JSON | this.customChannels = JSON | ||||
.parse(result || '[]') | .parse(result || '[]') | ||||
.filter(c => (typeof (c) == 'string')) | |||||
.filter(c => (typeof (c) === 'string')) | |||||
.map(c => c.split(' ').join('')) | .map(c => c.split(' ').join('')) | ||||
.filter(c => (c.length > 0)); | .filter(c => (c.length > 0)); | ||||
this.customChannels = this.customChannels | 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) | if (social) | ||||
social.customChannels = this.customChannels; | social.customChannels = this.customChannels; | ||||
@@ -269,7 +269,7 @@ module.exports = { | |||||
fixes.fixStash(this.stash); | fixes.fixStash(this.stash); | ||||
if (this.skins != null) { | |||||
if (this.skins !== null) { | |||||
this.verifySkin(character); | this.verifySkin(character); | ||||
data.callback(character); | data.callback(character); | ||||
} else { | } else { | ||||
@@ -328,7 +328,7 @@ module.exports = { | |||||
let list = [...this.skins, ...roles.getSkins(this.username)]; | let list = [...this.skins, ...roles.getSkins(this.username)]; | ||||
let skinList = skins.getSkinList(list); | 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.skinId = '1.0'; | ||||
character.cell = skins.getCell(character.skinId); | character.cell = skins.getCell(character.skinId); | ||||
@@ -337,13 +337,13 @@ module.exports = { | |||||
}, | }, | ||||
doesOwnSkin: function (skinId) { | doesOwnSkin: function (skinId) { | ||||
return this.skins.some(s => s == skinId); | |||||
return this.skins.some(s => s === skinId); | |||||
}, | }, | ||||
login: function (msg) { | login: function (msg) { | ||||
let credentials = msg.data; | let credentials = msg.data; | ||||
if ((credentials.username == '') | (credentials.password == '')) { | |||||
if ((credentials.username === '') | (credentials.password === '')) { | |||||
msg.callback(messages.login.allFields); | msg.callback(messages.login.allFields); | ||||
return; | return; | ||||
} | } | ||||
@@ -366,7 +366,7 @@ module.exports = { | |||||
msg.callback(messages.login.incorrect); | msg.callback(messages.login.incorrect); | ||||
else if (compareResult) { //If stored password matches the hashed password entered by the user, log them in directly | else if (compareResult) { //If stored password matches the hashed password entered by the user, log them in directly | ||||
this.onLoginVerified(msg); | 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); | this.onUnhashedLogin(msg); | ||||
} else | } else | ||||
msg.callback(messages.login.incorrect); | msg.callback(messages.login.incorrect); | ||||
@@ -409,7 +409,7 @@ module.exports = { | |||||
register: function (msg) { | register: function (msg) { | ||||
let credentials = msg.data; | let credentials = msg.data; | ||||
if ((credentials.username == '') || (credentials.password == '')) { | |||||
if ((credentials.username === '') || (credentials.password === '')) { | |||||
msg.callback(messages.login.allFields); | msg.callback(messages.login.allFields); | ||||
return; | 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' | '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); | msg.callback(messages.login.invalid); | ||||
return; | return; | ||||
} | } | ||||
@@ -521,7 +521,7 @@ module.exports = { | |||||
let simple = this.obj.getSimple(true); | let simple = this.obj.getSimple(true); | ||||
let prophecies = data.prophecies || []; | 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({ | simple.components.push({ | ||||
type: 'prophecies', | type: 'prophecies', | ||||
list: prophecies | list: prophecies | ||||
@@ -563,7 +563,7 @@ module.exports = { | |||||
if ((!data.name) || (!this.username)) | if ((!data.name) || (!this.username)) | ||||
return; | 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([]); | msg.callback([]); | ||||
return; | return; | ||||
} | } | ||||
@@ -575,7 +575,7 @@ module.exports = { | |||||
}); | }); | ||||
}, | }, | ||||
onDeleteCharacter: function (msg, result) { | 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 | let characterList = this.characterList | ||||
.map(c => ({ | .map(c => ({ | ||||
name: c.name ? c.name : c, | name: c.name ? c.name : c, | ||||
@@ -592,7 +592,7 @@ module.exports = { | |||||
leaderboard.deleteCharacter(msg.data.name); | leaderboard.deleteCharacter(msg.data.name); | ||||
}, | }, | ||||
onRemoveFromList: function (msg, result) { | onRemoveFromList: function (msg, result) { | ||||
let result = this.characterList | |||||
result = this.characterList | |||||
.map(c => ({ | .map(c => ({ | ||||
name: c.name ? c.name : c, | name: c.name ? c.name : c, | ||||
level: leaderboard.getLevel(c.name ? c.name : c) | level: leaderboard.getLevel(c.name ? c.name : c) | ||||
@@ -13,7 +13,7 @@ module.exports = { | |||||
this.cd = ~~(Math.random() * this.cdMax); | this.cd = ~~(Math.random() * this.cdMax); | ||||
for (let p in blueprint) { | for (let p in blueprint) { | ||||
if (p == 'chats') | |||||
if (p === 'chats') | |||||
continue; | continue; | ||||
this[p] = blueprint[p]; | this[p] = blueprint[p]; | ||||
@@ -23,10 +23,10 @@ module.exports = { | |||||
update: function () { | update: function () { | ||||
if ((this.obj.aggro) && (this.obj.aggro.list.length > 0)) | if ((this.obj.aggro) && (this.obj.aggro.list.length > 0)) | ||||
return; | return; | ||||
else if (this.chats.length == 0) | |||||
else if (this.chats.length === 0) | |||||
return; | return; | ||||
if ((this.cd == 0) && (Math.random() < this.chance)) { | |||||
if ((this.cd === 0) && (Math.random() < this.chance)) { | |||||
this.cd = this.cdMax; | this.cd = this.cdMax; | ||||
let pick = this.chats[~~(Math.random() * this.chats.length)]; | let pick = this.chats[~~(Math.random() * this.chats.length)]; | ||||
@@ -6,7 +6,7 @@ module.exports = { | |||||
ttl: -1, | ttl: -1, | ||||
init: function (blueprint) { | init: function (blueprint) { | ||||
if (blueprint.ownerId != null) | |||||
if (blueprint.ownerId !== null) | |||||
this.ownerId = blueprint.ownerId; | this.ownerId = blueprint.ownerId; | ||||
if (blueprint.ttl) | if (blueprint.ttl) | ||||
@@ -24,7 +24,7 @@ module.exports = { | |||||
if (this.ttl > 0) { | if (this.ttl > 0) { | ||||
this.ttl--; | this.ttl--; | ||||
if (this.ttl == 0) | |||||
if (this.ttl === 0) | |||||
this.obj.destroyed = true; | this.obj.destroyed = true; | ||||
} | } | ||||
}, | }, | ||||
@@ -34,11 +34,11 @@ module.exports = { | |||||
return; | return; | ||||
let ownerId = this.ownerId; | let ownerId = this.ownerId; | ||||
if (ownerId != -1) { | |||||
if (ownerId !== -1) { | |||||
if (ownerId instanceof Array) { | if (ownerId instanceof Array) { | ||||
if (ownerId.indexOf(obj.serverId) == -1) | |||||
if (ownerId.indexOf(obj.serverId) === -1) | |||||
return; | return; | ||||
} else if (ownerId != obj.serverId) | |||||
} else if (ownerId !== obj.serverId) | |||||
return; | return; | ||||
} | } | ||||
@@ -16,9 +16,9 @@ module.exports = { | |||||
getComponentFolder: function () { | getComponentFolder: function () { | ||||
let files = fileLister.getFolder('./components/'); | let files = fileLister.getFolder('./components/'); | ||||
files = files.filter(w => ( | 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; | let fLen = files.length; | ||||
for (let i = 0; i < fLen; i++) | for (let i = 0; i < fLen; i++) | ||||
@@ -21,15 +21,15 @@ module.exports = { | |||||
let target = msg.target; | let target = msg.target; | ||||
if ((target == null) && (!msg.targetName)) | |||||
if ((target === null) && (!msg.targetName)) | |||||
return false; | 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) | if (!target) | ||||
return false; | 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) | if (!target) | ||||
return false; | return false; | ||||
} | } | ||||
@@ -145,7 +145,7 @@ module.exports = { | |||||
} | } | ||||
if (!(result.options instanceof Array)) { | if (!(result.options instanceof Array)) { | ||||
if (result.options[0] == '$') | |||||
if (result.options[0] === '$') | |||||
result.options = this.states[result.options.replace('$', '')].options; | result.options = this.states[result.options.replace('$', '')].options; | ||||
result.options = Object.keys(result.options); | result.options = Object.keys(result.options); | ||||
@@ -196,7 +196,7 @@ module.exports = { | |||||
getItem: function (msg, source) { | getItem: function (msg, source) { | ||||
let inventory = this.obj.inventory; | 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) { | if (!exists) { | ||||
inventory.getItem(msg.item); | inventory.getItem(msg.item); | ||||
return msg.successMsg || false; | return msg.successMsg || false; | ||||
@@ -72,7 +72,7 @@ module.exports = { | |||||
if (this.closed) { | if (this.closed) { | ||||
if (this.locked) { | 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) { | if (!key) { | ||||
canAction = false; | canAction = false; | ||||
msg = 'You don\'t have the key to unlock this door'; | msg = 'You don\'t have the key to unlock this door'; | ||||
@@ -99,17 +99,17 @@ module.exports = { | |||||
}, | }, | ||||
unlock: function (msg) { | unlock: function (msg) { | ||||
if (msg.sourceId == null) | |||||
if (msg.sourceId === null) | |||||
return; | 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)) | if ((!obj) || (!obj.player)) | ||||
return; | return; | ||||
let thisObj = this.obj; | let thisObj = this.obj; | ||||
if ((Math.abs(thisObj.x - obj.x) > 1) || (Math.abs(thisObj.y - obj.y) > 1)) | if ((Math.abs(thisObj.x - obj.x) > 1) || (Math.abs(thisObj.y - obj.y) > 1)) | ||||
return; | return; | ||||
else if ((thisObj.x == obj.x) && (thisObj.y == obj.y)) | |||||
else if ((thisObj.x === obj.x) && (thisObj.y === obj.y)) | |||||
return; | return; | ||||
let syncO = thisObj.syncer.o; | let syncO = thisObj.syncer.o; | ||||
@@ -118,11 +118,11 @@ module.exports = { | |||||
if (this.autoClose) | if (this.autoClose) | ||||
this.autoCloseCd = 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) | if (!key) | ||||
return; | return; | ||||
if (((key.singleUse) || (this.destroyKey)) && (key.keyId != 'world')) { | |||||
if (((key.singleUse) || (this.destroyKey)) && (key.keyId !== 'world')) { | |||||
obj.inventory.destroyItem(key.id, 1); | obj.inventory.destroyItem(key.id, 1); | ||||
obj.instance.syncer.queue('onGetMessages', { | obj.instance.syncer.queue('onGetMessages', { | ||||
@@ -161,7 +161,7 @@ module.exports = { | |||||
this.autoCloseCd--; | this.autoCloseCd--; | ||||
if (this.autoCloseCd == 0) { | |||||
if (this.autoCloseCd === 0) { | |||||
this.obj.cell = this.closedSprite; | this.obj.cell = this.closedSprite; | ||||
this.obj.syncer.o.cell = this.closedSprite; | this.obj.syncer.o.cell = this.closedSprite; | ||||
this.obj.instance.physics.setCollision(this.obj.x, this.obj.y, true); | this.obj.instance.physics.setCollision(this.obj.x, this.obj.y, true); | ||||
@@ -37,7 +37,7 @@ module.exports = { | |||||
type: 'effects', | type: 'effects', | ||||
effects: this.effects | effects: this.effects | ||||
.map(e => e.save()) | .map(e => e.save()) | ||||
.filter(e => e != null) | |||||
.filter(e => e !== null) | |||||
}; | }; | ||||
return e; | return e; | ||||
@@ -52,7 +52,7 @@ module.exports = { | |||||
if ((effects.length > 0) && (effects[0].obj)) { | if ((effects.length > 0) && (effects[0].obj)) { | ||||
effects = effects | effects = effects | ||||
.map(e => e.simplify()) | .map(e => e.simplify()) | ||||
.filter(e => e != null); | |||||
.filter(e => e !== null); | |||||
} | } | ||||
e.effects = effects; | e.effects = effects; | ||||
@@ -115,7 +115,7 @@ module.exports = { | |||||
}, | }, | ||||
canApplyEffect: function (type) { | canApplyEffect: function (type) { | ||||
if (this.ccResistances[type] == null) | |||||
if (this.ccResistances[type] === null) | |||||
return true; | return true; | ||||
let ccResistances = this.ccResistances; | let ccResistances = this.ccResistances; | ||||
@@ -130,12 +130,12 @@ module.exports = { | |||||
return; | return; | ||||
if (!options.new) { | 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) { | if (exists) { | ||||
exists.ttl += options.ttl; | exists.ttl += options.ttl; | ||||
for (let p in options) { | for (let p in options) { | ||||
if (p == 'ttl') | |||||
if (p === 'ttl') | |||||
continue; | continue; | ||||
exists[p] = options[p]; | exists[p] = options[p]; | ||||
@@ -210,7 +210,7 @@ module.exports = { | |||||
let eLen = effects.length; | let eLen = effects.length; | ||||
for (let i = 0; i < eLen; i++) { | for (let i = 0; i < eLen; i++) { | ||||
let effect = effects[i]; | let effect = effects[i]; | ||||
if (effect == checkEffect) { | |||||
if (effect === checkEffect) { | |||||
if (effect.destroy) | if (effect.destroy) | ||||
effect.destroy(); | effect.destroy(); | ||||
this.syncRemove(effect.id, effect.type, noMsg || effect.noMsg); | this.syncRemove(effect.id, effect.type, noMsg || effect.noMsg); | ||||
@@ -224,7 +224,7 @@ module.exports = { | |||||
let eLen = effects.length; | let eLen = effects.length; | ||||
for (let i = 0; i < eLen; i++) { | for (let i = 0; i < eLen; i++) { | ||||
let effect = effects[i]; | let effect = effects[i]; | ||||
if (effect.type == effectName) { | |||||
if (effect.type === effectName) { | |||||
this.syncRemove(effect.id, effect.type, noMsg || effects.noMsg); | this.syncRemove(effect.id, effect.type, noMsg || effects.noMsg); | ||||
effects.splice(i, 1); | effects.splice(i, 1); | ||||
return; | return; | ||||
@@ -267,7 +267,7 @@ module.exports = { | |||||
if (e.ttl > 0) { | if (e.ttl > 0) { | ||||
e.ttl--; | e.ttl--; | ||||
if (e.ttl == 0) | |||||
if (e.ttl === 0) | |||||
e.destroyed = true; | e.destroyed = true; | ||||
} | } | ||||
@@ -40,7 +40,7 @@ module.exports = { | |||||
} | } | ||||
let currentEqId = this.eq[item.slot]; | let currentEqId = this.eq[item.slot]; | ||||
if (currentEqId == null) { | |||||
if (currentEqId === null) { | |||||
this.equip(itemId); | this.equip(itemId); | ||||
return true; | return true; | ||||
} | } | ||||
@@ -48,7 +48,7 @@ module.exports = { | |||||
equip: function (itemId) { | equip: function (itemId) { | ||||
let slot = null; | let slot = null; | ||||
if (typeof (itemId) == 'object') { | |||||
if (typeof (itemId) === 'object') { | |||||
slot = itemId.slot; | slot = itemId.slot; | ||||
itemId = itemId.itemId; | itemId = itemId.itemId; | ||||
} | } | ||||
@@ -63,17 +63,17 @@ module.exports = { | |||||
if (!slot) | if (!slot) | ||||
slot = item.equipSlot || item.slot; | slot = item.equipSlot || item.slot; | ||||
if (slot == 'twoHanded') { | |||||
if (slot === 'twoHanded') { | |||||
let currentEqId = this.eq.offHand; | let currentEqId = this.eq.offHand; | ||||
if (currentEqId != null) | |||||
if (currentEqId !== null) | |||||
this.unequip(currentEqId); | this.unequip(currentEqId); | ||||
slot = 'oneHanded'; | slot = 'oneHanded'; | ||||
} else if (slot == 'offHand') { | |||||
} else if (slot === 'offHand') { | |||||
let currentEqId = this.eq.oneHanded; | let currentEqId = this.eq.oneHanded; | ||||
if (currentEqId != null) { | |||||
if (currentEqId !== null) { | |||||
let currentEq = this.obj.inventory.findItem(currentEqId); | let currentEq = this.obj.inventory.findItem(currentEqId); | ||||
if ((currentEq != null) && (currentEq.slot == 'twoHanded')) | |||||
if ((currentEq !== null) && (currentEq.slot === 'twoHanded')) | |||||
this.unequip(currentEqId); | this.unequip(currentEqId); | ||||
} | } | ||||
} | } | ||||
@@ -99,9 +99,9 @@ module.exports = { | |||||
delete item.pos; | delete item.pos; | ||||
this.obj.syncer.setArray(true, 'inventory', 'getItems', item); | 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)) | if ((f1) && (f2)) | ||||
slot = 'finger-1'; | slot = 'finger-1'; | ||||
@@ -114,9 +114,9 @@ module.exports = { | |||||
let spellId = null; | let spellId = null; | ||||
let currentEqId = this.eq[slot]; | let currentEqId = this.eq[slot]; | ||||
let currentEq = this.obj.inventory.findItem(currentEqId); | let currentEq = this.obj.inventory.findItem(currentEqId); | ||||
if (currentEq == item) | |||||
if (currentEq === item) | |||||
return; | return; | ||||
if (currentEqId != null) { | |||||
if (currentEqId !== null) { | |||||
spellId = currentEq.spellId; | spellId = currentEq.spellId; | ||||
this.unequip(currentEqId); | this.unequip(currentEqId); | ||||
} | } | ||||
@@ -180,12 +180,12 @@ module.exports = { | |||||
unequip: function (itemId) { | unequip: function (itemId) { | ||||
let item = itemId; | let item = itemId; | ||||
let slot = null; | let slot = null; | ||||
if (typeof (itemId) == 'object') { | |||||
if (typeof (itemId) === 'object') { | |||||
slot = itemId.slot; | slot = itemId.slot; | ||||
itemId = itemId.itemId; | itemId = itemId.itemId; | ||||
} | } | ||||
if (item.id == null) | |||||
if (item.id === null) | |||||
item = this.obj.inventory.findItem(itemId); | item = this.obj.inventory.findItem(itemId); | ||||
if (!item) | if (!item) | ||||
@@ -299,7 +299,7 @@ module.exports = { | |||||
if (!factions) | if (!factions) | ||||
return; | return; | ||||
let findFaction = factions.find(f => f.id == factionId); | |||||
let findFaction = factions.find(f => f.id === factionId); | |||||
if (!findFaction) | if (!findFaction) | ||||
return; | return; | ||||
@@ -29,7 +29,7 @@ module.exports = { | |||||
}, | }, | ||||
unregisterEvent: function (event) { | unregisterEvent: function (event) { | ||||
this.list.spliceWhere(l => (l == event)); | |||||
this.list.spliceWhere(l => (l === event)); | |||||
this.obj.syncer.setArray(true, 'events', 'removeList', { | this.obj.syncer.setArray(true, 'events', 'removeList', { | ||||
id: event.id | id: event.id | ||||
@@ -54,7 +54,7 @@ module.exports = { | |||||
return; | return; | ||||
closeEvents.forEach(function (c) { | closeEvents.forEach(function (c) { | ||||
if (this.list.some(l => (l == c))) | |||||
if (this.list.some(l => (l === c))) | |||||
return; | return; | ||||
this.list.push(c); | this.list.push(c); | ||||
@@ -32,7 +32,7 @@ module.exports = { | |||||
this.items[name] = list; | this.items[name] = list; | ||||
this.regenList(list); | this.regenList(list); | ||||
} else if (list.level != requestLevel) | |||||
} else if (list.level !== requestLevel) | |||||
this.regenList(list); | this.regenList(list); | ||||
let reputation = requestedBy.reputation; | let reputation = requestedBy.reputation; | ||||
@@ -148,7 +148,7 @@ module.exports = { | |||||
let item = extend(true, {}, e); | let item = extend(true, {}, e); | ||||
if (item.type == 'skin') { | |||||
if (item.type === 'skin') { | |||||
let skinBlueprint = skins.getBlueprint(item.id); | let skinBlueprint = skins.getBlueprint(item.id); | ||||
item.skinId = item.id; | item.skinId = item.id; | ||||
item.name = skinBlueprint.name; | item.name = skinBlueprint.name; | ||||
@@ -180,9 +180,9 @@ module.exports = { | |||||
canBuy: function (itemId, requestedBy, action) { | canBuy: function (itemId, requestedBy, action) { | ||||
let item = null; | let item = null; | ||||
if (action == 'buy') | |||||
if (action === 'buy') | |||||
item = this.findItem(itemId, requestedBy.name); | item = this.findItem(itemId, requestedBy.name); | ||||
else if (action == 'buyback') | |||||
else if (action === 'buyback') | |||||
item = this.findBuyback(itemId, requestedBy.name); | item = this.findBuyback(itemId, requestedBy.name); | ||||
let result = true; | let result = true; | ||||
@@ -208,7 +208,7 @@ module.exports = { | |||||
if (!list) | if (!list) | ||||
return null; | return null; | ||||
return list.items.find(i => i.id == itemId); | |||||
return list.items.find(i => i.id === itemId); | |||||
}, | }, | ||||
removeItem: function (itemId, sourceName) { | removeItem: function (itemId, sourceName) { | ||||
@@ -216,6 +216,6 @@ module.exports = { | |||||
if (!sourceName) | if (!sourceName) | ||||
return null; | return null; | ||||
return list.items.spliceFirstWhere(i => i.id == itemId); | |||||
return list.items.spliceFirstWhere(i => i.id === itemId); | |||||
} | } | ||||
}; | }; |
@@ -45,7 +45,7 @@ module.exports = { | |||||
init: function (blueprint) { | init: function (blueprint) { | ||||
if (this.customChannels) { | if (this.customChannels) { | ||||
this.customChannels = 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); | this.roleLevel = roles.getRoleLevel(this.obj); | ||||
@@ -53,12 +53,12 @@ module.exports = { | |||||
onBeforeChat: function (msg) { | onBeforeChat: function (msg) { | ||||
let messageText = msg.message; | let messageText = msg.message; | ||||
if (messageText[0] != '/') | |||||
if (messageText[0] !== '/') | |||||
return; | return; | ||||
messageText = messageText.substr(1).split(' '); | messageText = messageText.substr(1).split(' '); | ||||
let actionName = messageText.splice(0, 1)[0].toLowerCase(); | 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) | if (!actionName) | ||||
return; | return; | ||||
@@ -68,7 +68,7 @@ module.exports = { | |||||
msg.ignore = true; | msg.ignore = true; | ||||
let config = {}; | let config = {}; | ||||
if ((messageText.length == 1) && (messageText[0].indexOf('=') == -1)) | |||||
if ((messageText.length === 1) && (messageText[0].indexOf('=') === -1)) | |||||
config = messageText[0]; | config = messageText[0]; | ||||
else { | else { | ||||
messageText.forEach(function (m) { | messageText.forEach(function (m) { | ||||
@@ -90,17 +90,17 @@ module.exports = { | |||||
//actions | //actions | ||||
join: function (value) { | join: function (value) { | ||||
if (typeof (value) != 'string') | |||||
if (typeof (value) !== 'string') | |||||
return; | return; | ||||
value = value.split(' ').join(''); | value = value.split(' ').join(''); | ||||
if (value.lengh == 0) | |||||
if (value.lengh === 0) | |||||
return; | return; | ||||
let obj = this.obj; | let obj = this.obj; | ||||
let channels = obj.auth.customChannels; | let channels = obj.auth.customChannels; | ||||
if (!channels.some(c => (c == value))) | |||||
if (!channels.some(c => (c === value))) | |||||
channels.push(value); | channels.push(value); | ||||
else | else | ||||
return; | return; | ||||
@@ -131,13 +131,13 @@ module.exports = { | |||||
}, | }, | ||||
leave: function (value) { | leave: function (value) { | ||||
if (typeof (value) != 'string') | |||||
if (typeof (value) !== 'string') | |||||
return; | return; | ||||
let obj = this.obj; | let obj = this.obj; | ||||
let channels = obj.auth.customChannels; | let channels = obj.auth.customChannels; | ||||
if (!channels.some(c => (c == value))) { | |||||
if (!channels.some(c => (c === value))) { | |||||
obj.socket.emit('events', { | obj.socket.emit('events', { | ||||
onGetMessages: [{ | onGetMessages: [{ | ||||
messages: [{ | messages: [{ | ||||
@@ -152,7 +152,7 @@ module.exports = { | |||||
} | } | ||||
let channels = obj.auth.customChannels; | let channels = obj.auth.customChannels; | ||||
channels.spliceWhere(c => (c == value)); | |||||
channels.spliceWhere(c => (c === value)); | |||||
let charname = obj.auth.charname; | let charname = obj.auth.charname; | ||||
io.set({ | io.set({ | ||||
@@ -178,7 +178,7 @@ module.exports = { | |||||
}, | }, | ||||
isInChannel: function (character, channel) { | isInChannel: function (character, channel) { | ||||
return character.auth.customChannels.some(c => (c == channel)); | |||||
return character.auth.customChannels.some(c => (c === channel)); | |||||
}, | }, | ||||
unEq: function () { | unEq: function () { | ||||
@@ -189,16 +189,16 @@ module.exports = { | |||||
}, | }, | ||||
mute: function (target, reason) { | mute: function (target, reason) { | ||||
if (typeof (target) == 'object') { | |||||
if (typeof (target) === 'object') { | |||||
let keys = Object.keys(target); | let keys = Object.keys(target); | ||||
target = keys[0]; | target = keys[0]; | ||||
reason = keys[1]; | reason = keys[1]; | ||||
} | } | ||||
if (target == this.obj.name) | |||||
if (target === this.obj.name) | |||||
return; | return; | ||||
let o = connections.players.find(o => (o.name == target)); | |||||
let o = connections.players.find(o => (o.name === target)); | |||||
if (!o) | if (!o) | ||||
return; | return; | ||||
@@ -240,16 +240,16 @@ module.exports = { | |||||
}, | }, | ||||
unmute: function (target, reason) { | unmute: function (target, reason) { | ||||
if (typeof (target) == 'object') { | |||||
if (typeof (target) === 'object') { | |||||
let keys = Object.keys(target); | let keys = Object.keys(target); | ||||
target = keys[0]; | target = keys[0]; | ||||
reason = keys[1]; | reason = keys[1]; | ||||
} | } | ||||
if (target == this.obj.name) | |||||
if (target === this.obj.name) | |||||
return; | return; | ||||
let o = connections.players.find(o => (o.name == target)); | |||||
let o = connections.players.find(o => (o.name === target)); | |||||
if (!o) | if (!o) | ||||
return; | return; | ||||
@@ -300,9 +300,9 @@ module.exports = { | |||||
}, | }, | ||||
getItem: function (config) { | getItem: function (config) { | ||||
if (config.slot == 'set') { | |||||
if (config.slot === 'set') { | |||||
configSlots.slots.forEach(function (s) { | configSlots.slots.forEach(function (s) { | ||||
if (s == 'tool') | |||||
if (s === 'tool') | |||||
return; | return; | ||||
let newConfig = extend(true, {}, config, { | let newConfig = extend(true, {}, config, { | ||||
@@ -351,7 +351,7 @@ module.exports = { | |||||
} | } | ||||
factions.forEach(function (f) { | factions.forEach(function (f) { | ||||
if (f == '') | |||||
if (f === '') | |||||
return; | return; | ||||
let faction = factions.getFaction(f); | let faction = factions.getFaction(f); | ||||
@@ -453,14 +453,14 @@ module.exports = { | |||||
}, | }, | ||||
getReputation: function (faction) { | getReputation: function (faction) { | ||||
if (typeof (faction) != 'string') | |||||
if (typeof (faction) !== 'string') | |||||
return; | return; | ||||
this.obj.reputation.getReputation(faction, 50000); | this.obj.reputation.getReputation(faction, 50000); | ||||
}, | }, | ||||
loseReputation: function (faction) { | loseReputation: function (faction) { | ||||
if (typeof (faction) != 'string') | |||||
if (typeof (faction) !== 'string') | |||||
return; | return; | ||||
this.obj.reputation.getReputation(faction, -50000); | this.obj.reputation.getReputation(faction, -50000); | ||||
@@ -107,7 +107,6 @@ module.exports = { | |||||
let maxDistance = this.maxDistance; | let maxDistance = this.maxDistance; | ||||
let distance = Math.max(Math.abs(obj.x - master.x), Math.abs(obj.y - master.y)); | 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 | //When we're too far, just teleport | ||||
if ((!attacker) && (distance >= maxDistance * 2)) { | if ((!attacker) && (distance >= maxDistance * 2)) { | ||||
this.teleport(); | this.teleport(); | ||||
@@ -119,7 +118,7 @@ module.exports = { | |||||
if (!attacker) { | if (!attacker) { | ||||
let lastMasterPos = this.lastMasterPos; | let lastMasterPos = this.lastMasterPos; | ||||
if ((master.x != lastMasterPos.x) || (master.y != lastMasterPos.y)) { | |||||
if ((master.x !== lastMasterPos.x) || (master.y !== lastMasterPos.y)) { | |||||
doMove = true; | doMove = true; | ||||
lastMasterPos.x = master.x; | lastMasterPos.x = master.x; | ||||
lastMasterPos.y = master.y; | lastMasterPos.y = master.y; | ||||
@@ -16,11 +16,11 @@ module.exports = { | |||||
}, | }, | ||||
gather: function () { | gather: function () { | ||||
if (this.gathering != null) | |||||
if (this.gathering !== null) | |||||
return; | return; | ||||
let nodes = this.nodes; | let nodes = this.nodes; | ||||
if (nodes.length == 0) | |||||
if (nodes.length === 0) | |||||
return; | return; | ||||
let firstNode = nodes[0]; | let firstNode = nodes[0]; | ||||
@@ -29,7 +29,7 @@ module.exports = { | |||||
let ttlMax = firstNode.resourceNode.ttl || this.defaultTtlMax; | let ttlMax = firstNode.resourceNode.ttl || this.defaultTtlMax; | ||||
if (firstNode.resourceNode.nodeType == 'fish') { | |||||
if (firstNode.resourceNode.nodeType === 'fish') { | |||||
let rod = this.obj.equipment.eq.tool; | let rod = this.obj.equipment.eq.tool; | ||||
if (!rod) { | if (!rod) { | ||||
process.send({ | process.send({ | ||||
@@ -73,10 +73,10 @@ module.exports = { | |||||
return; | return; | ||||
} | } | ||||
let isFish = (gathering.resourceNode.nodeType == 'fish'); | |||||
let isFish = (gathering.resourceNode.nodeType === 'fish'); | |||||
if (this.gatheringTtl > 0) { | 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) { | ['x', 'y', 'width', 'height'].forEach(function (p) { | ||||
this.obj.syncer.set(false, 'gatherer', p, gathering[p]); | this.obj.syncer.set(false, 'gatherer', p, gathering[p]); | ||||
}, this); | }, this); | ||||
@@ -175,7 +175,7 @@ module.exports = { | |||||
gatherResult.items.forEach(function (item, i) { | gatherResult.items.forEach(function (item, i) { | ||||
delete item.pos; | delete item.pos; | ||||
if (i == 0) { | |||||
if (i === 0) { | |||||
if (blueprint.itemName) | if (blueprint.itemName) | ||||
item.name = blueprint.itemName; | item.name = blueprint.itemName; | ||||
if (blueprint.itemAmount) | if (blueprint.itemAmount) | ||||
@@ -208,7 +208,7 @@ module.exports = { | |||||
}); | }); | ||||
} | } | ||||
this.nodes.spliceWhere(n => (n == gathering)); | |||||
this.nodes.spliceWhere(n => (n === gathering)); | |||||
} | } | ||||
this.gathering = null; | this.gathering = null; | ||||
@@ -228,9 +228,9 @@ module.exports = { | |||||
}[nodeType]); | }[nodeType]); | ||||
let success = true; | let success = true; | ||||
if (nodeType == 'fish') { | |||||
if (nodeType === 'fish') { | |||||
let rod = this.obj.equipment.eq.tool; | let rod = this.obj.equipment.eq.tool; | ||||
if (rod == null) { | |||||
if (rod === null) { | |||||
success = false; | success = false; | ||||
msg = 'You need a fishing rod to fish'; | 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); | this.nodes.push(node); | ||||
}, | }, | ||||
exit: function (node) { | exit: function (node) { | ||||
this.nodes.spliceWhere(n => (n == node)); | |||||
this.nodes.spliceWhere(n => (n === node)); | |||||
}, | }, | ||||
events: { | events: { | ||||
@@ -272,7 +272,7 @@ module.exports = { | |||||
this.obj.syncer.set(true, 'gatherer', 'progress', 100); | this.obj.syncer.set(true, 'gatherer', 'progress', 100); | ||||
this.obj.syncer.set(false, '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.obj.syncer.set(true, 'gatherer', 'action', 'Fishing'); | ||||
this.gathering = null; | this.gathering = null; | ||||
@@ -284,12 +284,12 @@ module.exports = { | |||||
for (let i = 0; i < nLen; i++) { | for (let i = 0; i < nLen; i++) { | ||||
let node = nodes[i]; | let node = nodes[i]; | ||||
if (item.slot != 'tool') | |||||
if (item.slot !== 'tool') | |||||
continue; | continue; | ||||
if (node.resourceNode.nodeType == 'fish') { | |||||
if (node.resourceNode.nodeType === 'fish') { | |||||
let rod = this.obj.equipment.eq.tool; | let rod = this.obj.equipment.eq.tool; | ||||
if (rod == null) { | |||||
if (rod === null) { | |||||
process.send({ | process.send({ | ||||
method: 'events', | method: 'events', | ||||
data: { | 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.obj.syncer.set(true, 'gatherer', 'action', 'Fishing'); | ||||
this.gathering = null; | this.gathering = null; | ||||
@@ -24,8 +24,8 @@ module.exports = { | |||||
//Spells should be sorted so they're EQ'd in the right order | //Spells should be sorted so they're EQ'd in the right order | ||||
items.sort(function (a, b) { | 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); | return (aId - bId); | ||||
}); | }); | ||||
@@ -48,7 +48,7 @@ module.exports = { | |||||
newItem.pos = pos; | 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(); | this.getDefaultAbilities(); | ||||
delete blueprint.items; | delete blueprint.items; | ||||
@@ -135,7 +135,7 @@ module.exports = { | |||||
enchantItem: function (msg) { | enchantItem: function (msg) { | ||||
let item = this.findItem(msg.itemId); | 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); | this.resolveCallback(msg); | ||||
return; | return; | ||||
} | } | ||||
@@ -153,7 +153,7 @@ module.exports = { | |||||
}, | }, | ||||
learnAbility: function (itemId, runeSlot) { | learnAbility: function (itemId, runeSlot) { | ||||
if (itemId.itemId != null) { | |||||
if (itemId.itemId !== null) { | |||||
let msg = itemId; | let msg = itemId; | ||||
itemId = msg.itemId; | itemId = msg.itemId; | ||||
runeSlot = msg.slot; | runeSlot = msg.slot; | ||||
@@ -191,19 +191,19 @@ module.exports = { | |||||
let spellbook = this.obj.spellbook; | let spellbook = this.obj.spellbook; | ||||
if ((item.slot == 'twoHanded') || (item.slot == 'oneHanded')) | |||||
if ((item.slot === 'twoHanded') || (item.slot === 'oneHanded')) | |||||
runeSlot = 0; | runeSlot = 0; | ||||
else if (runeSlot == null) { | |||||
else if (runeSlot === null) { | |||||
runeSlot = 4; | runeSlot = 4; | ||||
for (let i = 1; i <= 4; i++) { | 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; | runeSlot = i; | ||||
break; | break; | ||||
} | } | ||||
} | } | ||||
} | } | ||||
let currentEq = this.items.find(i => (i.runeSlot == runeSlot)); | |||||
let currentEq = this.items.find(i => (i.runeSlot === runeSlot)); | |||||
if (currentEq) { | if (currentEq) { | ||||
spellbook.removeSpellById(runeSlot); | spellbook.removeSpellById(runeSlot); | ||||
delete currentEq.eq; | delete currentEq.eq; | ||||
@@ -224,7 +224,7 @@ module.exports = { | |||||
let item = this.findItem(itemId); | let item = this.findItem(itemId); | ||||
if (!item) | if (!item) | ||||
return; | return; | ||||
else if (item.type != 'mtx') { | |||||
else if (item.type !== 'mtx') { | |||||
delete item.active; | delete item.active; | ||||
return; | return; | ||||
} | } | ||||
@@ -290,7 +290,7 @@ module.exports = { | |||||
//Find similar items and put them on cooldown too | //Find similar items and put them on cooldown too | ||||
this.items.forEach(function (i) { | 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; | i.cd = i.cdMax; | ||||
}); | }); | ||||
} | } | ||||
@@ -298,7 +298,7 @@ module.exports = { | |||||
let result = {}; | let result = {}; | ||||
this.obj.instance.eventEmitter.emit('onBeforeUseItem', this.obj, item, result); | this.obj.instance.eventEmitter.emit('onBeforeUseItem', this.obj, item, result); | ||||
if (item.type == 'consumable') { | |||||
if (item.type === 'consumable') { | |||||
if (item.uses) { | if (item.uses) { | ||||
item.uses--; | item.uses--; | ||||
this.obj.syncer.setArray(true, 'inventory', 'getItems', item); | this.obj.syncer.setArray(true, 'inventory', 'getItems', item); | ||||
@@ -309,7 +309,7 @@ module.exports = { | |||||
}, | }, | ||||
unlearnAbility: function (itemId) { | unlearnAbility: function (itemId) { | ||||
if (itemId.itemId != null) | |||||
if (itemId.itemId !== null) | |||||
itemId = itemId.itemId; | itemId = itemId.itemId; | ||||
let item = this.findItem(itemId); | let item = this.findItem(itemId); | ||||
@@ -390,12 +390,12 @@ module.exports = { | |||||
if ((item.quantity) && (amount)) { | if ((item.quantity) && (amount)) { | ||||
item.quantity -= amount; | item.quantity -= amount; | ||||
if (item.quantity <= 0) { | 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); | this.obj.syncer.setArray(true, 'inventory', 'destroyItems', id); | ||||
} else | } else | ||||
this.obj.syncer.setArray(true, 'inventory', 'getItems', item); | this.obj.syncer.setArray(true, 'inventory', 'getItems', item); | ||||
} else { | } else { | ||||
this.items.spliceWhere(i => i.id == id); | |||||
this.items.spliceWhere(i => i.id === id); | |||||
this.obj.syncer.setArray(true, 'inventory', 'destroyItems', id); | this.obj.syncer.setArray(true, 'inventory', 'destroyItems', id); | ||||
} | } | ||||
@@ -421,7 +421,7 @@ module.exports = { | |||||
if (item.eq) | if (item.eq) | ||||
this.obj.equipment.unequip(id); | 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); | this.obj.syncer.setArray(true, 'inventory', 'destroyItems', id); | ||||
@@ -471,7 +471,7 @@ module.exports = { | |||||
//Helpers | //Helpers | ||||
hookItemEvents: function (items) { | hookItemEvents: function (items) { | ||||
let items = items || this.items; | |||||
items = items || this.items; | |||||
let iLen = items.length; | let iLen = items.length; | ||||
for (let i = 0; i < iLen; i++) { | for (let i = 0; i < iLen; i++) { | ||||
let item = items[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; | let pos = i; | ||||
for (let j = 0; j < iLen; j++) { | for (let j = 0; j < iLen; j++) { | ||||
if (!items.some(fj => (fj.pos == j))) { | |||||
if (!items.some(fj => (fj.pos === j))) { | |||||
pos = j; | pos = j; | ||||
break; | break; | ||||
} | } | ||||
} | } | ||||
item.pos = pos; | 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; | let pos = item.pos; | ||||
for (let j = 0; j < iLen; j++) { | 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; | pos = j; | ||||
break; | break; | ||||
} | } | ||||
@@ -525,7 +525,7 @@ module.exports = { | |||||
let iSize = this.inventorySize; | let iSize = this.inventorySize; | ||||
for (let i = 0; i < iSize; i++) { | 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; | item.pos = i; | ||||
break; | break; | ||||
} | } | ||||
@@ -533,10 +533,10 @@ module.exports = { | |||||
}, | }, | ||||
resolveCallback: function (msg, result) { | resolveCallback: function (msg, result) { | ||||
let callbackId = (msg.callbackId != null) ? msg.callbackId : msg; | |||||
let callbackId = (msg.callbackId !== null) ? msg.callbackId : msg; | |||||
result = result || []; | result = result || []; | ||||
if (callbackId == null) | |||||
if (callbackId === null) | |||||
return; | return; | ||||
process.send({ | process.send({ | ||||
@@ -550,10 +550,10 @@ module.exports = { | |||||
}, | }, | ||||
findItem: function (id) { | findItem: function (id) { | ||||
if (id == null) | |||||
if (id === null) | |||||
return null; | return null; | ||||
return this.items.find(i => i.id == id); | |||||
return this.items.find(i => i.id === id); | |||||
}, | }, | ||||
getDefaultAbilities: function () { | getDefaultAbilities: function () { | ||||
@@ -561,8 +561,8 @@ module.exports = { | |||||
return ( | return ( | ||||
(i.spell) && | (i.spell) && | ||||
(i.spell.rolls) && | (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) { | let hasSpell = this.items.some(function (i) { | ||||
return ( | return ( | ||||
(i.spell) && | (i.spell) && | ||||
(i.spell.name.toLowerCase() == spellName) | |||||
(i.spell.name.toLowerCase() === spellName) | |||||
); | ); | ||||
}); | }); | ||||
@@ -599,7 +599,7 @@ module.exports = { | |||||
}, | }, | ||||
createBag: function (x, y, items, ownerId) { | createBag: function (x, y, items, ownerId) { | ||||
if (ownerId == null) | |||||
if (ownerId === null) | |||||
ownerId = -1; | ownerId = -1; | ||||
let bagCell = 50; | let bagCell = 50; | ||||
@@ -613,13 +613,13 @@ module.exports = { | |||||
topQuality = quality; | topQuality = quality; | ||||
} | } | ||||
if (topQuality == 0) | |||||
if (topQuality === 0) | |||||
bagCell = 50; | bagCell = 50; | ||||
else if (topQuality == 1) | |||||
else if (topQuality === 1) | |||||
bagCell = 51; | bagCell = 51; | ||||
else if (topQuality == 2) | |||||
else if (topQuality === 2) | |||||
bagCell = 128; | bagCell = 128; | ||||
else if (topQuality == 3) | |||||
else if (topQuality === 3) | |||||
bagCell = 52; | bagCell = 52; | ||||
else | else | ||||
bagCell = 53; | bagCell = 53; | ||||
@@ -644,7 +644,7 @@ module.exports = { | |||||
}, | }, | ||||
hasSpace: function () { | hasSpace: function () { | ||||
if (this.inventorySize != -1) { | |||||
if (this.inventorySize !== -1) { | |||||
let nonEqItems = this.items.filter(f => !f.eq).length; | let nonEqItems = this.items.filter(f => !f.eq).length; | ||||
return (nonEqItems < this.inventorySize); | return (nonEqItems < this.inventorySize); | ||||
} return true; | } return true; | ||||
@@ -656,7 +656,7 @@ module.exports = { | |||||
//We need to know if a mob dropped it for quest purposes | //We need to know if a mob dropped it for quest purposes | ||||
let fromMob = item.fromMob; | let fromMob = item.fromMob; | ||||
if (item.quality == null) | |||||
if (item.quality === null) | |||||
item.quality = 0; | item.quality = 0; | ||||
//Players can't have fromMob items in their inventory but bags can (dropped by a mob) | //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; | let exists = false; | ||||
if (((item.material) || (item.quest) || (item.quantity)) && (!item.noStack) && (!item.uses) && (!noStack)) { | 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) { | if (existItem) { | ||||
exists = true; | exists = true; | ||||
if (!existItem.quantity) | if (!existItem.quantity) | ||||
@@ -713,10 +713,10 @@ module.exports = { | |||||
if (item.eq) | if (item.eq) | ||||
delete item.pos; | delete item.pos; | ||||
if ((item.pos == null) && (!item.eq)) { | |||||
if ((item.pos === null) && (!item.eq)) { | |||||
let pos = iLen; | let pos = iLen; | ||||
for (let i = 0; i < iLen; i++) { | for (let i = 0; i < iLen; i++) { | ||||
if (!items.some(fi => (fi.pos == i))) { | |||||
if (!items.some(fi => (fi.pos === i))) { | |||||
pos = i; | pos = i; | ||||
break; | break; | ||||
} | } | ||||
@@ -759,10 +759,10 @@ module.exports = { | |||||
for (let i = 0; i < sLen; i++) { | for (let i = 0; i < sLen; i++) { | ||||
let s = stats[i]; | let s = stats[i]; | ||||
let val = item.stats[s]; | let val = item.stats[s]; | ||||
if (s == 'maxHp') { | |||||
if (s === 'maxHp') { | |||||
delete item.stats[s]; | delete item.stats[s]; | ||||
item.stats.hpMax = val; | item.stats.hpMax = val; | ||||
} else if (s == 'maxMana') { | |||||
} else if (s === 'maxMana') { | |||||
delete item.stats[s]; | delete item.stats[s]; | ||||
item.stats.manaMax = val; | item.stats.manaMax = val; | ||||
} | } | ||||
@@ -842,7 +842,7 @@ module.exports = { | |||||
return; | return; | ||||
//Only drop loot if this player is in the zone | //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) | if (!playerObject) | ||||
return; | return; | ||||
@@ -853,7 +853,7 @@ module.exports = { | |||||
if (!(spellStatType instanceof Array)) | if (!(spellStatType instanceof Array)) | ||||
spellStatType = [spellStatType]; | spellStatType = [spellStatType]; | ||||
spellStatType.forEach(function (ss) { | spellStatType.forEach(function (ss) { | ||||
if (stats.indexOf(ss) == -1) | |||||
if (stats.indexOf(ss) === -1) | |||||
stats.push(ss); | stats.push(ss); | ||||
}); | }); | ||||
}); | }); | ||||
@@ -919,7 +919,7 @@ module.exports = { | |||||
drop.magicFind = magicFind; | drop.magicFind = magicFind; | ||||
let item = drop; | let item = drop; | ||||
if ((!item.quest) && (item.type != 'key')) | |||||
if ((!item.quest) && (item.type !== 'key')) | |||||
item = generator.generate(drop); | item = generator.generate(drop); | ||||
if (!item.slot) | if (!item.slot) | ||||
@@ -1015,6 +1015,6 @@ module.exports = { | |||||
}, | }, | ||||
canEquipItem: function (item) { | canEquipItem: function (item) { | ||||
return (this.equipItemErrors(item).length == 0); | |||||
return (this.equipItemErrors(item).length === 0); | |||||
} | } | ||||
}; | }; |
@@ -50,7 +50,7 @@ module.exports = { | |||||
if (!this.goHome) { | if (!this.goHome) { | ||||
//Are we in fight mode? | //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); | this.fight(target); | ||||
return; | return; | ||||
} | } | ||||
@@ -108,12 +108,12 @@ module.exports = { | |||||
this.goHome = false; | this.goHome = false; | ||||
}, | }, | ||||
fight: function (target) { | fight: function (target) { | ||||
if (this.target != target) { | |||||
if (this.target !== target) { | |||||
this.obj.clearQueue(); | this.obj.clearQueue(); | ||||
this.target = target; | this.target = target; | ||||
} | } | ||||
//If the target is true, it means we can't reach the target and should wait for a new one | //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; | return; | ||||
let obj = this.obj; | let obj = this.obj; | ||||
@@ -140,7 +140,7 @@ module.exports = { | |||||
target: target | target: target | ||||
}); | }); | ||||
//null means we don't have LoS | //null means we don't have LoS | ||||
if (success != null) | |||||
if (success !== null) | |||||
return; | return; | ||||
hasLos = false; | hasLos = false; | ||||
} else | } else | ||||
@@ -159,17 +159,17 @@ module.exports = { | |||||
let newDistance = max(abs(targetPos.x - tx), abs(targetPos.y - ty)); | let newDistance = max(abs(targetPos.x - tx), abs(targetPos.y - ty)); | ||||
if ((newDistance >= distance) && (newDistance > furthestRange)) { | if ((newDistance >= distance) && (newDistance > furthestRange)) { | ||||
if (hasLos == null) | |||||
if (hasLos === null) | |||||
hasLos = this.physics.hasLos(x, y, tx, ty); | hasLos = this.physics.hasLos(x, y, tx, ty); | ||||
if (hasLos) { | if (hasLos) { | ||||
if (doesCollide == null) | |||||
if (doesCollide === null) | |||||
doesCollide = this.physics.mobsCollide(x, y, obj); | doesCollide = this.physics.mobsCollide(x, y, obj); | ||||
if (!doesCollide) { | if (!doesCollide) { | ||||
obj.aggro.ignore(target); | obj.aggro.ignore(target); | ||||
return; | return; | ||||
} | } | ||||
} else { | } else { | ||||
if (doesCollide == null) | |||||
if (doesCollide === null) | |||||
doesCollide = this.physics.mobsCollide(x, y, obj); | doesCollide = this.physics.mobsCollide(x, y, obj); | ||||
if (!doesCollide) { | if (!doesCollide) { | ||||
obj.aggro.ignore(target); | obj.aggro.ignore(target); | ||||
@@ -185,7 +185,7 @@ module.exports = { | |||||
x: targetPos.x, | x: targetPos.x, | ||||
y: targetPos.y | y: targetPos.y | ||||
}); | }); | ||||
if (path.length == 0) { | |||||
if (path.length === 0) { | |||||
obj.aggro.ignore(target); | obj.aggro.ignore(target); | ||||
//TODO: Don't skip a turn | //TODO: Don't skip a turn | ||||
return; | return; | ||||
@@ -29,7 +29,7 @@ module.exports = { | |||||
return; | return; | ||||
if (action.targetId) { | 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) { | if (target) { | ||||
let cpn = target[action.cpn]; | let cpn = target[action.cpn]; | ||||
if ((cpn) && (cpn[action.method])) | if ((cpn) && (cpn[action.method])) | ||||
@@ -80,7 +80,7 @@ module.exports = { | |||||
return; | return; | ||||
} | } | ||||
this.contents.spliceWhere(c => (c == obj)); | |||||
this.contents.spliceWhere(c => (c === obj)); | |||||
this.callAction(obj, 'exit'); | this.callAction(obj, 'exit'); | ||||
@@ -8,15 +8,15 @@ module.exports = { | |||||
init: function (blueprint) { | init: function (blueprint) { | ||||
this.selected = ((blueprint || {}).selected || []); | 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(); | let points = this.calcPoints(); | ||||
if (points + this.selected.length < this.selected.length) { | if (points + this.selected.length < this.selected.length) { | ||||
this.selected = []; | 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; | blueprint.selected = this.selected; | ||||
points = this.calcPoints(); | points = this.calcPoints(); | ||||
} | } | ||||
@@ -27,7 +27,7 @@ module.exports = { | |||||
let stats = this.obj.stats; | let stats = this.obj.stats; | ||||
this.selected.forEach(function (id) { | 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) { | if (node) { | ||||
for (let p in node.stats) | for (let p in node.stats) | ||||
stats.addStat(p, node.stats[p]); | stats.addStat(p, node.stats[p]); | ||||
@@ -48,7 +48,7 @@ module.exports = { | |||||
applyPassives: function () { | applyPassives: function () { | ||||
let stats = this.obj.stats; | let stats = this.obj.stats; | ||||
this.selected.forEach(function (id) { | 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) { | if (node) { | ||||
for (let p in node.stats) | for (let p in node.stats) | ||||
stats.addStat(p, node.stats[p]); | stats.addStat(p, node.stats[p]); | ||||
@@ -59,17 +59,17 @@ module.exports = { | |||||
tickNode: function (msg) { | tickNode: function (msg) { | ||||
if (this.points <= 0) | if (this.points <= 0) | ||||
return; | return; | ||||
else if (this.selected.some(s => (s == msg.nodeId))) | |||||
else if (this.selected.some(s => (s === msg.nodeId))) | |||||
return; | return; | ||||
let nodeId = msg.nodeId; | 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) | if (node.spiritStart) | ||||
return; | return; | ||||
let linked = passiveTree.links.some(function (l) { | 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 false; | ||||
return ( | return ( | ||||
@@ -99,7 +99,7 @@ module.exports = { | |||||
let stats = this.obj.stats; | let stats = this.obj.stats; | ||||
this.selected.forEach(function (s) { | 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) | if (node.spiritStart) | ||||
return; | return; | ||||
@@ -115,7 +115,7 @@ module.exports = { | |||||
}, this); | }, this); | ||||
this.selected = []; | 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(); | this.obj.spellbook.calcDps(); | ||||
}, | }, | ||||
@@ -44,7 +44,7 @@ module.exports = { | |||||
roles.onBeforePlayerEnterGame(obj, character); | 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]); | extend(true, blueprintStats, classes.stats[obj.class]); | ||||
blueprintStats.values.hpMax = (blueprintStats.values.level || 1) * 32.7; | blueprintStats.values.hpMax = (blueprintStats.values.level || 1) * 32.7; | ||||
if (!blueprintStats.values.hp) | if (!blueprintStats.values.hp) | ||||
@@ -65,10 +65,10 @@ module.exports = { | |||||
obj.addComponent('spellbook'); | obj.addComponent('spellbook'); | ||||
obj.addComponent('dialogue'); | 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) | if (social) | ||||
delete social.party; | delete social.party; | ||||
obj.addComponent('social', social); | obj.addComponent('social', social); | ||||
@@ -82,7 +82,7 @@ module.exports = { | |||||
items: character.stash | items: character.stash | ||||
}); | }); | ||||
let blueprintEffects = character.components.find(c => c.type == 'effects') || {}; | |||||
let blueprintEffects = character.components.find(c => c.type === 'effects') || {}; | |||||
if (blueprintEffects.effects) { | if (blueprintEffects.effects) { | ||||
//Calculate ttl of effects | //Calculate ttl of effects | ||||
let time = +new Date(); | let time = +new Date(); | ||||
@@ -97,15 +97,15 @@ module.exports = { | |||||
} | } | ||||
obj.addComponent('effects', blueprintEffects); | obj.addComponent('effects', blueprintEffects); | ||||
let prophecies = character.components.find(c => c.type == 'prophecies'); | |||||
let prophecies = character.components.find(c => c.type === 'prophecies'); | |||||
if (prophecies) | if (prophecies) | ||||
obj.addComponent('prophecies', 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.xp = stats.values.xp; | ||||
obj.level = stats.values.level; | obj.level = stats.values.level; | ||||
@@ -150,7 +150,7 @@ module.exports = { | |||||
this.seen.push(id); | this.seen.push(id); | ||||
}, | }, | ||||
unsee: function (id) { | unsee: function (id) { | ||||
this.seen.spliceWhere(s => s == id); | |||||
this.seen.spliceWhere(s => s === id); | |||||
}, | }, | ||||
die: function (source, permadeath) { | die: function (source, permadeath) { | ||||
@@ -167,10 +167,10 @@ module.exports = { | |||||
let level = this.obj.stats.values.level; | let level = this.obj.stats.values.level; | ||||
let spawns = this.obj.spawn; | let spawns = this.obj.spawn; | ||||
let spawnPos = spawns.filter(s => (((s.maxLevel) && (s.maxLevel >= level)) || (!s.maxLevel))); | 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]; | spawnPos = spawns[0]; | ||||
else if (source.name) { | 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) | if (sourceSpawnPos) | ||||
spawnPos = sourceSpawnPos; | spawnPos = sourceSpawnPos; | ||||
else | else | ||||
@@ -12,23 +12,23 @@ module.exports = { | |||||
console.log(e); | console.log(e); | ||||
} | } | ||||
if (template == null) | |||||
if (template === null) | |||||
return; | return; | ||||
else if (this.list.some(l => (l.type == p))) | |||||
else if (this.list.some(l => (l.type === p))) | |||||
return; | 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); | }, this); | ||||
delete blueprint.list; | delete blueprint.list; | ||||
}, | }, | ||||
hasProphecy: function (type) { | hasProphecy: function (type) { | ||||
return this.list.some(l => (l.type == type)); | |||||
return this.list.some(l => (l.type === type)); | |||||
}, | }, | ||||
transfer: function () { | transfer: function () { | ||||
@@ -24,23 +24,23 @@ module.exports = { | |||||
}, | }, | ||||
obtain: function (quest, hideMessage) { | obtain: function (quest, hideMessage) { | ||||
quest.active = (this.obj.zoneName == quest.zoneName); | |||||
quest.active = (this.obj.zoneName === quest.zoneName); | |||||
this.quests.push(quest); | this.quests.push(quest); | ||||
if (!quest.init(hideMessage)) { | if (!quest.init(hideMessage)) { | ||||
this.quests.spliceWhere(q => (q == quest)); | |||||
this.quests.spliceWhere(q => (q === quest)); | |||||
return false; | return false; | ||||
} return true; | } return true; | ||||
}, | }, | ||||
complete: function (id) { | 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)) | if ((!quest) || (!quest.isReady)) | ||||
return; | return; | ||||
quest.complete(); | quest.complete(); | ||||
this.quests.spliceWhere(q => q == quest); | |||||
this.quests.spliceWhere(q => q === quest); | |||||
this.obj.instance.questBuilder.obtain(this.obj); | this.obj.instance.questBuilder.obtain(this.obj); | ||||
}, | }, | ||||
@@ -36,7 +36,7 @@ module.exports = { | |||||
factionBlueprint = factions.getFaction(factionId); | factionBlueprint = factions.getFaction(factionId); | ||||
} catch (e) {} | } catch (e) {} | ||||
if (factionBlueprint == null) { | |||||
if (factionBlueprint === null) { | |||||
console.log('No faction blueprint found'); | console.log('No faction blueprint found'); | ||||
return; | return; | ||||
} | } | ||||
@@ -49,10 +49,10 @@ module.exports = { | |||||
}, | }, | ||||
getTier: function (factionId) { | getTier: function (factionId) { | ||||
let faction = this.list.find(l => l.id == factionId); | |||||
let faction = this.list.find(l => l.id === factionId); | |||||
if (!faction) { | if (!faction) { | ||||
this.discoverFaction(factionId); | this.discoverFaction(factionId); | ||||
faction = this.list.find(l => l.id == factionId); | |||||
faction = this.list.find(l => l.id === factionId); | |||||
} | } | ||||
return (faction || { | return (faction || { | ||||
@@ -75,7 +75,7 @@ module.exports = { | |||||
calculateTier: function (factionId) { | calculateTier: function (factionId) { | ||||
let blueprint = this.getBlueprint(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 rep = faction.rep; | ||||
let tier = 0; | let tier = 0; | ||||
@@ -87,7 +87,7 @@ module.exports = { | |||||
if (t.rep > rep) | if (t.rep > rep) | ||||
break; | break; | ||||
else if (i == tLen - 1) | |||||
else if (i === tLen - 1) | |||||
tier = i; | tier = i; | ||||
} | } | ||||
@@ -100,10 +100,10 @@ module.exports = { | |||||
}, | }, | ||||
getReputation: function (factionId, gain) { | getReputation: function (factionId, gain) { | ||||
let fullSync = (this.factions[factionId] == null); | |||||
let fullSync = (this.factions[factionId] === null); | |||||
let blueprint = this.getBlueprint(factionId); | 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) { | if (!faction) { | ||||
this.list.push({ | this.list.push({ | ||||
id: factionId, | id: factionId, | ||||
@@ -125,13 +125,13 @@ module.exports = { | |||||
this.obj.instance.syncer.queue('onGetMessages', { | this.obj.instance.syncer.queue('onGetMessages', { | ||||
id: this.obj.id, | id: this.obj.id, | ||||
messages: [{ | 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, | message: 'you ' + action + ' ' + Math.abs(gain) + ' reputation with ' + blueprint.name, | ||||
type: 'rep' | type: 'rep' | ||||
}] | }] | ||||
}, [this.obj.serverId]); | }, [this.obj.serverId]); | ||||
if (faction.tier != oldTier) { | |||||
if (faction.tier !== oldTier) { | |||||
this.sendMessage(blueprint.tiers[faction.tier].name, blueprint.name, (faction.tier > oldTier)); | this.sendMessage(blueprint.tiers[faction.tier].name, blueprint.name, (faction.tier > oldTier)); | ||||
this.obj.equipment.unequipFactionGear(faction.id, faction.tier); | this.obj.equipment.unequipFactionGear(faction.id, faction.tier); | ||||
} | } | ||||
@@ -151,10 +151,10 @@ module.exports = { | |||||
}, | }, | ||||
discoverFaction (factionId) { | discoverFaction (factionId) { | ||||
if (this.list.some(l => l.id == factionId)) | |||||
if (this.list.some(l => l.id === factionId)) | |||||
return; | return; | ||||
let fullSync = (this.factions[factionId] == null); | |||||
let fullSync = (this.factions[factionId] === null); | |||||
let blueprint = this.getBlueprint(factionId); | let blueprint = this.getBlueprint(factionId); | ||||
if (!blueprint) | if (!blueprint) | ||||
@@ -209,7 +209,7 @@ module.exports = { | |||||
}, | }, | ||||
syncFaction: function (factionId, full) { | syncFaction: function (factionId, full) { | ||||
let l = this.list.find(l => (l.id == factionId)); | |||||
let l = this.list.find(l => (l.id === factionId)); | |||||
let faction = { | let faction = { | ||||
id: factionId, | id: factionId, | ||||
rep: l.rep, | rep: l.rep, | ||||
@@ -60,7 +60,7 @@ module.exports = { | |||||
let message = msg.data.message.substr(1); | let message = msg.data.message.substr(1); | ||||
this.party.forEach(function (p) { | 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', { | player.socket.emit('events', { | ||||
onGetMessages: [{ | onGetMessages: [{ | ||||
@@ -134,7 +134,7 @@ module.exports = { | |||||
if (!msg.data.message) | if (!msg.data.message) | ||||
return; | return; | ||||
if (msg.data.message.trim() == '') | |||||
if (msg.data.message.trim() === '') | |||||
return; | return; | ||||
this.onBeforeChat(msg.data); | this.onBeforeChat(msg.data); | ||||
@@ -156,7 +156,7 @@ module.exports = { | |||||
history.spliceWhere(h => ((time - h.time) > 5000)); | history.spliceWhere(h => ((time - h.time) > 5000)); | ||||
if (history.length > 0) { | 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'); | this.sendMessage('You have already sent that message', 'color-redA'); | ||||
return; | return; | ||||
} else if (history.length >= 3) { | } else if (history.length >= 3) { | ||||
@@ -180,10 +180,10 @@ module.exports = { | |||||
}; | }; | ||||
events.emit('onBeforeSendMessage', msgEvent); | events.emit('onBeforeSendMessage', msgEvent); | ||||
messageString = msgEvent.msg; | messageString = msgEvent.msg; | ||||
if (messageString[0] == '@') { | |||||
if (messageString[0] === '@') { | |||||
let playerName = ''; | let playerName = ''; | ||||
//Check if there's a space in the name | //Check if there's a space in the name | ||||
if (messageString[1] == "'") { | |||||
if (messageString[1] === "'") { | |||||
playerName = messageString.substring(2, messageString.indexOf("'", 2)); | playerName = messageString.substring(2, messageString.indexOf("'", 2)); | ||||
messageString = messageString.replace("@'" + playerName + "' ", ''); | messageString = messageString.replace("@'" + playerName + "' ", ''); | ||||
} else { | } else { | ||||
@@ -191,10 +191,10 @@ module.exports = { | |||||
messageString = messageString.replace('@' + playerName + ' ', ''); | messageString = messageString.replace('@' + playerName + ' ', ''); | ||||
} | } | ||||
if (playerName == this.obj.name) | |||||
if (playerName === this.obj.name) | |||||
return; | return; | ||||
let target = cons.players.find(p => p.name == playerName); | |||||
let target = cons.players.find(p => p.name === playerName); | |||||
if (!target) | if (!target) | ||||
return; | return; | ||||
@@ -219,9 +219,9 @@ module.exports = { | |||||
}] | }] | ||||
} | } | ||||
}); | }); | ||||
} else if (messageString[0] == '$') | |||||
} else if (messageString[0] === '$') | |||||
this.sendCustomChannelMessage(msg); | this.sendCustomChannelMessage(msg); | ||||
else if (messageString[0] == '%') | |||||
else if (messageString[0] === '%') | |||||
this.sendPartyMessage(msg); | this.sendPartyMessage(msg); | ||||
else { | else { | ||||
let prefix = roles.getRoleMessagePrefix(this.obj) || ''; | let prefix = roles.getRoleMessagePrefix(this.obj) || ''; | ||||
@@ -255,10 +255,10 @@ module.exports = { | |||||
let obj = this.obj; | let obj = this.obj; | ||||
let sourceId = msg.data.sourceId; | let sourceId = msg.data.sourceId; | ||||
if (sourceId == obj.id) | |||||
if (sourceId === obj.id) | |||||
return; | return; | ||||
let source = cons.players.find(c => c.id == sourceId); | |||||
let source = cons.players.find(c => c.id === sourceId); | |||||
if (!source) | if (!source) | ||||
return; | return; | ||||
@@ -274,7 +274,7 @@ module.exports = { | |||||
//This gets called on the player that initiated the invite | //This gets called on the player that initiated the invite | ||||
acceptInvite: function (msg) { | acceptInvite: function (msg) { | ||||
let sourceId = msg.data.sourceId; | 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) | if (!source) | ||||
return; | return; | ||||
@@ -291,12 +291,12 @@ module.exports = { | |||||
this.updatePartyOnThread(); | this.updatePartyOnThread(); | ||||
this.party.forEach(function (p) { | 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.party = this.party; | ||||
player.social.updatePartyOnThread(); | player.social.updatePartyOnThread(); | ||||
let msg = source.name + ' has joined the party'; | let msg = source.name + ' has joined the party'; | ||||
if (p == sourceId) | |||||
if (p === sourceId) | |||||
msg = 'you have joined a party'; | msg = 'you have joined a party'; | ||||
player.social.sendMessage(msg, 'color-yellowB'); | player.social.sendMessage(msg, 'color-yellowB'); | ||||
@@ -309,7 +309,7 @@ module.exports = { | |||||
}, | }, | ||||
declineInvite: function (msg) { | declineInvite: function (msg) { | ||||
let targetId = msg.data.targetId; | 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) | if (!target) | ||||
return; | return; | ||||
@@ -320,17 +320,17 @@ module.exports = { | |||||
leaveParty: function (msg) { | leaveParty: function (msg) { | ||||
let name = this.obj.name; | 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) { | 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 = [{ | let messages = [{ | ||||
class: 'q0', | class: 'q0', | ||||
message: name + ' has left the party' | message: name + ' has left the party' | ||||
}]; | }]; | ||||
let party = this.party; | let party = this.party; | ||||
if (this.party.length == 1) { | |||||
if (this.party.length === 1) { | |||||
messages.push({ | messages.push({ | ||||
class: 'q0', | class: 'q0', | ||||
message: 'your group has been disbanded' | message: 'your group has been disbanded' | ||||
@@ -369,14 +369,14 @@ module.exports = { | |||||
}); | }); | ||||
if ((this.isPartyLeader) && (this.party.length >= 2)) { | 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; | newLeader.isPartyLeader = true; | ||||
this.party.forEach(function (p) { | this.party.forEach(function (p) { | ||||
let msg = newLeader.obj.name + ' is now the party leader'; | 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'; | 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: [{ | onGetMessages: [{ | ||||
messages: [{ | messages: [{ | ||||
class: 'q0', | class: 'q0', | ||||
@@ -398,14 +398,14 @@ module.exports = { | |||||
return; | return; | ||||
} | } | ||||
let target = cons.players.find(c => c.id == msg.data); | |||||
let target = cons.players.find(c => c.id === msg.data); | |||||
if (!target) | if (!target) | ||||
return; | return; | ||||
this.party.spliceWhere(p => p == target.id); | |||||
this.party.spliceWhere(p => p === target.id); | |||||
this.party.forEach(function (p) { | this.party.forEach(function (p) { | ||||
cons.players.find(c => c.id == p) | |||||
cons.players.find(c => c.id === p) | |||||
.socket.emit('events', { | .socket.emit('events', { | ||||
onGetParty: [this.party], | onGetParty: [this.party], | ||||
onGetMessages: [{ | onGetMessages: [{ | ||||
@@ -431,7 +431,7 @@ module.exports = { | |||||
target.social.isPartyLeader = false; | target.social.isPartyLeader = false; | ||||
target.social.updatePartyOnThread(); | target.social.updatePartyOnThread(); | ||||
if (this.party.length == 1) { | |||||
if (this.party.length === 1) { | |||||
this.party = null; | this.party = null; | ||||
this.isPartyLeader = null; | this.isPartyLeader = null; | ||||
this.updatePartyOnThread(); | this.updatePartyOnThread(); | ||||
@@ -100,9 +100,9 @@ module.exports = { | |||||
let sheetName = this.obj.sheetName || '../../../images/characters.png'; | let sheetName = this.obj.sheetName || '../../../images/characters.png'; | ||||
let animationName = builtSpell.animation; | let animationName = builtSpell.animation; | ||||
if (sheetName == 'mobs') | |||||
if (sheetName === 'mobs') | |||||
animation = animations.mobs; | animation = animations.mobs; | ||||
else if (sheetName == 'bosses') | |||||
else if (sheetName === 'bosses') | |||||
animation = animations.bosses; | animation = animations.bosses; | ||||
else if (sheetName.indexOf('/') > -1) | else if (sheetName.indexOf('/') > -1) | ||||
animation = animations.mobs[sheetName]; | animation = animations.mobs[sheetName]; | ||||
@@ -116,12 +116,12 @@ module.exports = { | |||||
builtSpell.animation = null; | builtSpell.animation = null; | ||||
} | } | ||||
if ((this.closestRange == -1) || (builtSpell.range < this.closestRange)) | |||||
if ((this.closestRange === -1) || (builtSpell.range < this.closestRange)) | |||||
this.closestRange = builtSpell.range; | this.closestRange = builtSpell.range; | ||||
if ((this.furthestRange == -1) || (builtSpell.range > this.furthestRange)) | |||||
if ((this.furthestRange === -1) || (builtSpell.range > this.furthestRange)) | |||||
this.furthestRange = builtSpell.range; | this.furthestRange = builtSpell.range; | ||||
if ((options.id == null) && (spellId == null)) { | |||||
if ((options.id === null) && (spellId === null)) { | |||||
spellId = 0; | spellId = 0; | ||||
this.spells.forEach(function (s) { | this.spells.forEach(function (s) { | ||||
if (s.id >= spellId) | 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.push(builtSpell); | ||||
this.spells.sort(function (a, b) { | this.spells.sort(function (a, b) { | ||||
return (a.id - b.id); | return (a.id - b.id); | ||||
@@ -147,7 +147,7 @@ module.exports = { | |||||
addSpellFromRune: function (runeSpell, spellId) { | addSpellFromRune: function (runeSpell, spellId) { | ||||
let type = runeSpell.type; | 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]; | let playerSpellConfig = playerSpellsConfig.spells[runeSpell.name.toLowerCase()] || playerSpellsConfig.spells[runeSpell.type]; | ||||
if (!playerSpellConfig) | if (!playerSpellConfig) | ||||
return -1; | return -1; | ||||
@@ -167,7 +167,7 @@ module.exports = { | |||||
let roll = runeSpell.rolls[r] || 0; | let roll = runeSpell.rolls[r] || 0; | ||||
runeSpell.rolls[r] = roll; | 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); | let val = range[0] + ((range[1] - range[0]) * roll); | ||||
if (int) { | if (int) { | ||||
@@ -200,7 +200,7 @@ module.exports = { | |||||
}, | }, | ||||
removeSpellById: function (id) { | 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) { | ||||
if ((exists.manaReserve) && (exists.active)) { | if ((exists.manaReserve) && (exists.active)) { | ||||
@@ -214,7 +214,7 @@ module.exports = { | |||||
exists.unlearn && exists.unlearn(); | exists.unlearn && exists.unlearn(); | ||||
this.obj.syncer.setArray(true, 'spellbook', 'removeSpells', id); | 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) | if (!action.auto) | ||||
return true; | return true; | ||||
let exists = this.auto.find(a => (a.spell == action.spell)); | |||||
let exists = this.auto.find(a => (a.spell === action.spell)); | |||||
if (!exists) { | if (!exists) { | ||||
this.auto.push({ | this.auto.push({ | ||||
spell: action.spell, | spell: action.spell, | ||||
@@ -244,12 +244,12 @@ module.exports = { | |||||
return null; | return null; | ||||
}, | }, | ||||
cast: function (action, isAuto) { | cast: function (action, isAuto) { | ||||
if (action.spell == null) { | |||||
if (action.spell === null) { | |||||
this.auto = []; | this.auto = []; | ||||
return true; | return true; | ||||
} | } | ||||
let spell = this.spells.find(s => (s.id == action.spell)); | |||||
let spell = this.spells.find(s => (s.id === action.spell)); | |||||
if (!spell) | if (!spell) | ||||
return false; | return false; | ||||
@@ -261,22 +261,22 @@ module.exports = { | |||||
x: this.obj.x, | x: this.obj.x, | ||||
y: this.obj.y | y: this.obj.y | ||||
}; | }; | ||||
} else if (spell.spellType == 'buff') | |||||
} else if (spell.spellType === 'buff') | |||||
action.target = this.obj; | action.target = this.obj; | ||||
} | } | ||||
if ((!spell.aura) && (!spell.targetGround)) { | if ((!spell.aura) && (!spell.targetGround)) { | ||||
//Did we pass in the target id? | //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) | if (!action.target) | ||||
return false; | return false; | ||||
} | } | ||||
if ((action.target == this.obj) && (spell.noTargetSelf)) | |||||
if ((action.target === this.obj) && (spell.noTargetSelf)) | |||||
action.target = null; | action.target = null; | ||||
if ((action.target == null) || (!action.target.player)) { | |||||
if ((action.target === null) || (!action.target.player)) { | |||||
if (spell.autoTargetFollower) { | if (spell.autoTargetFollower) { | ||||
action.target = this.spells.find(s => (s.minions) && (s.minions.length > 0)); | action.target = this.spells.find(s => (s.minions) && (s.minions.length > 0)); | ||||
if (action.target) | 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; | return; | ||||
} else if ((action.target.aggro) && (!this.obj.aggro.canAttack(action.target))) { | } else if ((action.target.aggro) && (!this.obj.aggro.canAttack(action.target))) { | ||||
if (this.obj.player) | if (this.obj.player) | ||||
@@ -326,7 +326,7 @@ module.exports = { | |||||
} else | } else | ||||
this.obj.stats.addStat('manaReservePercent', -reserve.percentage); | this.obj.stats.addStat('manaReservePercent', -reserve.percentage); | ||||
} | } | ||||
} else if (spell.range != null) { | |||||
} else if (spell.range !== null) { | |||||
//Distance Check | //Distance Check | ||||
let fromX = this.obj.x; | let fromX = this.obj.x; | ||||
let fromY = this.obj.y; | let fromY = this.obj.y; | ||||
@@ -380,7 +380,7 @@ module.exports = { | |||||
cd: spell.cdMax | cd: spell.cdMax | ||||
}; | }; | ||||
let isAttack = (spell.type == 'melee'); | |||||
let isAttack = (spell.type === 'melee'); | |||||
if ((Math.random() * 100) < stats[isAttack ? 'attackSpeed' : 'castSpeed']) | if ((Math.random() * 100) < stats[isAttack ? 'attackSpeed' : 'castSpeed']) | ||||
cd.cd = 1; | cd.cd = 1; | ||||
@@ -420,7 +420,7 @@ module.exports = { | |||||
if ((spell.range > furthest) && (spell.canCast())) | if ((spell.range > furthest) && (spell.canCast())) | ||||
furthest = spell.range; | furthest = spell.range; | ||||
} | } | ||||
if (furthest == 0) | |||||
if (furthest === 0) | |||||
furthest = this.furthestRange; | furthest = this.furthestRange; | ||||
return furthest; | return furthest; | ||||
@@ -432,7 +432,7 @@ module.exports = { | |||||
s => cds.push({ | s => cds.push({ | ||||
cd: s.cd, | cd: s.cd, | ||||
cdMax: s.cdMax, | 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); | }), this); | ||||
return cds; | return cds; | ||||
@@ -512,9 +512,9 @@ module.exports = { | |||||
let match = false; | let match = false; | ||||
if (!target) | if (!target) | ||||
match = (c.sourceId == sourceId); | |||||
match = (c.sourceId === sourceId); | |||||
else | else | ||||
match = (c.targetId == sourceId); | |||||
match = (c.targetId === sourceId); | |||||
if (match) { | if (match) { | ||||
if (c.destroyCallback) | if (c.destroyCallback) | ||||
@@ -555,7 +555,7 @@ module.exports = { | |||||
callback.apply(s, args); | callback.apply(s, args); | ||||
} | } | ||||
if (s.castEvent == event) | |||||
if (s.castEvent === event) | |||||
s.cast(); | s.cast(); | ||||
} | } | ||||
}, | }, | ||||
@@ -20,7 +20,7 @@ module.exports = { | |||||
//Material? | //Material? | ||||
let exists = false; | let exists = false; | ||||
if (((item.material) || (item.quest) || (item.quantity)) && (!item.noStack) && (!item.uses)) { | 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) { | if (existItem) { | ||||
exists = true; | exists = true; | ||||
if (!existItem.quantity) | if (!existItem.quantity) | ||||
@@ -64,11 +64,11 @@ module.exports = { | |||||
}, | }, | ||||
destroyItem: function (id) { | destroyItem: function (id) { | ||||
let item = this.items.find(i => i.id == id); | |||||
let item = this.items.find(i => i.id === id); | |||||
if (!item) | if (!item) | ||||
return; | return; | ||||
this.items.spliceWhere(i => i == item); | |||||
this.items.spliceWhere(i => i === item); | |||||
this.obj.syncer.setArray(true, 'stash', 'destroyItems', id); | this.obj.syncer.setArray(true, 'stash', 'destroyItems', id); | ||||
@@ -79,12 +79,12 @@ module.exports = { | |||||
if (!this.active) | if (!this.active) | ||||
return; | return; | ||||
let item = this.items.find(i => i.id == id); | |||||
let item = this.items.find(i => i.id === id); | |||||
if (!item) | if (!item) | ||||
return; | return; | ||||
this.obj.inventory.getItem(item); | 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); | this.obj.syncer.setArray(true, 'stash', 'destroyItems', id); | ||||
@@ -189,10 +189,10 @@ module.exports = { | |||||
addStat: function (stat, value) { | addStat: function (stat, value) { | ||||
let values = this.values; | let values = this.values; | ||||
if (['lvlRequire', 'allAttributes'].indexOf(stat) == -1) | |||||
if (['lvlRequire', 'allAttributes'].indexOf(stat) === -1) | |||||
values[stat] += value; | 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]); | this.obj.syncer.setObject(sendOnlyToSelf, 'stats', 'values', stat, values[stat]); | ||||
if (sendOnlyToSelf) | if (sendOnlyToSelf) | ||||
@@ -206,27 +206,27 @@ module.exports = { | |||||
let morphStat = stat.substr(3); | let morphStat = stat.substr(3); | ||||
morphStat = morphStat[0].toLowerCase() + morphStat.substr(1); | morphStat = morphStat[0].toLowerCase() + morphStat.substr(1); | ||||
this.addStat(morphStat, value); | this.addStat(morphStat, value); | ||||
} else if (stat == 'vit') | |||||
} else if (stat === 'vit') | |||||
this.addStat('hpMax', (value * this.statScales.vitToHp)); | this.addStat('hpMax', (value * this.statScales.vitToHp)); | ||||
else if (stat == 'allAttributes') { | |||||
else if (stat === 'allAttributes') { | |||||
['int', 'str', 'dex'].forEach(function (s) { | ['int', 'str', 'dex'].forEach(function (s) { | ||||
this.addStat(s, value); | this.addStat(s, value); | ||||
}, this); | }, this); | ||||
} else if (stat == 'elementAllResist') { | |||||
} else if (stat === 'elementAllResist') { | |||||
['arcane', 'frost', 'fire', 'holy', 'poison'].forEach(function (s) { | ['arcane', 'frost', 'fire', 'holy', 'poison'].forEach(function (s) { | ||||
let element = 'element' + (s[0].toUpperCase() + s.substr(1)) + 'Resist'; | let element = 'element' + (s[0].toUpperCase() + s.substr(1)) + 'Resist'; | ||||
this.addStat(element, value); | this.addStat(element, value); | ||||
}, this); | }, this); | ||||
} else if (stat == 'elementPercent') { | |||||
} else if (stat === 'elementPercent') { | |||||
['arcane', 'frost', 'fire', 'holy', 'poison'].forEach(function (s) { | ['arcane', 'frost', 'fire', 'holy', 'poison'].forEach(function (s) { | ||||
let element = 'element' + (s[0].toUpperCase() + s.substr(1)) + 'Percent'; | let element = 'element' + (s[0].toUpperCase() + s.substr(1)) + 'Percent'; | ||||
this.addStat(element, value); | this.addStat(element, value); | ||||
}, this); | }, this); | ||||
} else if (stat == 'str') | |||||
} else if (stat === 'str') | |||||
this.addStat('armor', (value * this.statScales.strToArmor)); | this.addStat('armor', (value * this.statScales.strToArmor)); | ||||
else if (stat == 'int') | |||||
else if (stat === 'int') | |||||
this.addStat('manaMax', (value * this.statScales.intToMana)); | this.addStat('manaMax', (value * this.statScales.intToMana)); | ||||
else if (stat == 'dex') | |||||
else if (stat === 'dex') | |||||
this.addStat('dodgeAttackChance', (value * this.statScales.dexToDodge)); | this.addStat('dodgeAttackChance', (value * this.statScales.dexToDodge)); | ||||
this.obj.equipment.unequipAttrRqrGear(); | this.obj.equipment.unequipAttrRqrGear(); | ||||
@@ -245,7 +245,7 @@ module.exports = { | |||||
let obj = this.obj; | let obj = this.obj; | ||||
let values = this.values; | let values = this.values; | ||||
if (values.level == 20) | |||||
if (values.level === 20) | |||||
return; | return; | ||||
let xpEvent = { | let xpEvent = { | ||||
@@ -255,7 +255,7 @@ module.exports = { | |||||
}; | }; | ||||
this.obj.fireEvent('beforeGetXp', xpEvent); | this.obj.fireEvent('beforeGetXp', xpEvent); | ||||
if (xpEvent.amount == 0) | |||||
if (xpEvent.amount === 0) | |||||
return; | return; | ||||
amount = ~~(xpEvent.amount * (1 + (values.xpIncrease / 100))); | amount = ~~(xpEvent.amount * (1 + (values.xpIncrease / 100))); | ||||
@@ -283,7 +283,7 @@ module.exports = { | |||||
this.obj.fireEvent('onLevelUp', this.values.level); | this.obj.fireEvent('onLevelUp', this.values.level); | ||||
if (values.level == 20) | |||||
if (values.level === 20) | |||||
values.xp = 0; | values.xp = 0; | ||||
values.hpMax = values.level * 32.7; | values.hpMax = values.level * 32.7; | ||||
@@ -393,7 +393,6 @@ module.exports = { | |||||
obj.syncer.set(true, null, 'dead', true); | obj.syncer.set(true, null, 'dead', true); | ||||
let obj = obj; | |||||
let syncO = obj.syncer.o; | let syncO = obj.syncer.o; | ||||
obj.hidden = true; | obj.hidden = true; | ||||
@@ -484,9 +483,9 @@ module.exports = { | |||||
this.values.hp -= amount; | this.values.hp -= amount; | ||||
let recipients = []; | let recipients = []; | ||||
if (this.obj.serverId != null) | |||||
if (this.obj.serverId !== null) | |||||
recipients.push(this.obj.serverId); | recipients.push(this.obj.serverId); | ||||
if (source.serverId != null) | |||||
if (source.serverId !== null) | |||||
recipients.push(source.serverId); | recipients.push(source.serverId); | ||||
if ((source.follower) && (source.follower.master.serverId)) | if ((source.follower) && (source.follower.master.serverId)) | ||||
recipients.push(source.follower.master.serverId); | recipients.push(source.follower.master.serverId); | ||||
@@ -574,7 +573,7 @@ module.exports = { | |||||
for (let i = 0; i < aLen; i++) { | for (let i = 0; i < aLen; i++) { | ||||
let a = aggroList[i]; | let a = aggroList[i]; | ||||
if ((!a.threat) || (a.obj.serverId == null)) | |||||
if ((!a.threat) || (a.obj.serverId === null)) | |||||
continue; | continue; | ||||
this.obj.inventory.dropBag(a.obj.serverId, killSource); | this.obj.inventory.dropBag(a.obj.serverId, killSource); | ||||
@@ -593,7 +592,7 @@ module.exports = { | |||||
getHp: function (heal, source) { | getHp: function (heal, source) { | ||||
let amount = heal.amount; | let amount = heal.amount; | ||||
if (amount == 0) | |||||
if (amount === 0) | |||||
return; | return; | ||||
let threatMult = heal.threatMult; | let threatMult = heal.threatMult; | ||||
@@ -614,9 +613,9 @@ module.exports = { | |||||
values.hp = hpMax; | values.hp = hpMax; | ||||
let recipients = []; | let recipients = []; | ||||
if (this.obj.serverId != null) | |||||
if (this.obj.serverId !== null) | |||||
recipients.push(this.obj.serverId); | recipients.push(this.obj.serverId); | ||||
if (source.serverId != null) | |||||
if (source.serverId !== null) | |||||
recipients.push(source.serverId); | recipients.push(source.serverId); | ||||
if (recipients.length > 0) { | if (recipients.length > 0) { | ||||
this.syncer.queue('onGetDamage', { | this.syncer.queue('onGetDamage', { | ||||
@@ -707,7 +706,7 @@ module.exports = { | |||||
if (!lootStats) | if (!lootStats) | ||||
this.stats.lootStats[mob.name] = time; | this.stats.lootStats[mob.name] = time; | ||||
else | else | ||||
return ((lootStats.day != time.day), (lootStats.month != time.month)); | |||||
return ((lootStats.day !== time.day), (lootStats.month !== time.month)); | |||||
}, | }, | ||||
events: { | events: { | ||||
@@ -722,7 +721,7 @@ module.exports = { | |||||
mobKillStreaks[mobName]++; | mobKillStreaks[mobName]++; | ||||
for (let p in mobKillStreaks) { | for (let p in mobKillStreaks) { | ||||
if (p == mobName) | |||||
if (p === mobName) | |||||
continue; | continue; | ||||
mobKillStreaks[p]--; | mobKillStreaks[p]--; | ||||
@@ -21,8 +21,8 @@ module.exports = { | |||||
o = this.oSelf; | o = this.oSelf; | ||||
let keys = Object.keys(o); | 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; | return null; | ||||
delete o.components; | delete o.components; | ||||
} | } | ||||
@@ -37,7 +37,7 @@ module.exports = { | |||||
o = this.oSelf; | o = this.oSelf; | ||||
if (cpnType) { | if (cpnType) { | ||||
let cpn = o.components.find(c => (c.type == cpnType)); | |||||
let cpn = o.components.find(c => (c.type === cpnType)); | |||||
if (!cpn) { | if (!cpn) { | ||||
cpn = { | cpn = { | ||||
@@ -54,7 +54,7 @@ module.exports = { | |||||
let o = this.o; | let o = this.o; | ||||
if (self) | if (self) | ||||
o = this.oSelf; | o = this.oSelf; | ||||
let cpn = o.components.find(c => (c.type == cpnType)); | |||||
let cpn = o.components.find(c => (c.type === cpnType)); | |||||
if (!cpn) { | if (!cpn) { | ||||
cpn = { | cpn = { | ||||
@@ -75,7 +75,7 @@ module.exports = { | |||||
let o = this.o; | let o = this.o; | ||||
if (self) | if (self) | ||||
o = this.oSelf; | o = this.oSelf; | ||||
let cpn = o.components.find(c => (c.type == cpnType)); | |||||
let cpn = o.components.find(c => (c.type === cpnType)); | |||||
if (!cpn) { | if (!cpn) { | ||||
cpn = { | cpn = { | ||||
@@ -84,10 +84,10 @@ module.exports = { | |||||
o.components.push(cpn); | o.components.push(cpn); | ||||
} | } | ||||
if (cpn[property] == null) | |||||
if (cpn[property] === null) | |||||
cpn[property] = []; | cpn[property] = []; | ||||
if ((noDuplicate) && (cpn[property].find(f => (f == value)))) | |||||
if ((noDuplicate) && (cpn[property].find(f => (f === value)))) | |||||
return; | return; | ||||
cpn[property].push(value); | cpn[property].push(value); | ||||
@@ -98,7 +98,7 @@ module.exports = { | |||||
if (self) | if (self) | ||||
o = this.oSelf; | o = this.oSelf; | ||||
if (o[property] == null) | |||||
if (o[property] === null) | |||||
o[property] = []; | o[property] = []; | ||||
o[property].push(value); | o[property].push(value); | ||||
@@ -110,7 +110,7 @@ module.exports = { | |||||
o = this.oSelf; | o = this.oSelf; | ||||
if (cpnType) { | if (cpnType) { | ||||
let cpn = o.components.find(c => (c.type == cpnType)); | |||||
let cpn = o.components.find(c => (c.type === cpnType)); | |||||
if (!cpn) | if (!cpn) | ||||
return; | return; | ||||
@@ -31,7 +31,7 @@ module.exports = { | |||||
id = checkItem.id + 1; | id = checkItem.id + 1; | ||||
}); | }); | ||||
if (item.type == 'skin') { | |||||
if (item.type === 'skin') { | |||||
let skinBlueprint = skins.getBlueprint(item.id); | let skinBlueprint = skins.getBlueprint(item.id); | ||||
item.name = skinBlueprint.name; | item.name = skinBlueprint.name; | ||||
item.sprite = skinBlueprint.sprite; | item.sprite = skinBlueprint.sprite; | ||||
@@ -80,13 +80,13 @@ module.exports = { | |||||
startBuy: function (msg) { | startBuy: function (msg) { | ||||
let target = msg.target; | let target = msg.target; | ||||
if ((target == null) && (!msg.targetName)) | |||||
if ((target === null) && (!msg.targetName)) | |||||
return false; | 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) | 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; | this.target = null; | ||||
@@ -98,7 +98,7 @@ module.exports = { | |||||
let itemList = target.trade.getItems(this.obj); | let itemList = target.trade.getItems(this.obj); | ||||
let markup = target.trade.markup.sell; | let markup = target.trade.markup.sell; | ||||
if (msg.action == 'buyback') { | |||||
if (msg.action === 'buyback') { | |||||
itemList = target.trade.buyback[this.obj.name] || []; | itemList = target.trade.buyback[this.obj.name] || []; | ||||
markup = target.trade.markup.buy; | markup = target.trade.markup.buy; | ||||
} | } | ||||
@@ -106,16 +106,16 @@ module.exports = { | |||||
this.obj.syncer.set(true, 'trade', 'buyList', { | this.obj.syncer.set(true, 'trade', 'buyList', { | ||||
markup: markup, | markup: markup, | ||||
items: itemList, | items: itemList, | ||||
buyback: (msg.action == 'buyback') | |||||
buyback: (msg.action === 'buyback') | |||||
}); | }); | ||||
}, | }, | ||||
buySell: function (msg) { | buySell: function (msg) { | ||||
if (msg.action == 'buy') | |||||
if (msg.action === 'buy') | |||||
this.buy(msg); | this.buy(msg); | ||||
else if (msg.action == 'sell') | |||||
else if (msg.action === 'sell') | |||||
this.sell(msg); | this.sell(msg); | ||||
else if (msg.action == 'buyback') | |||||
else if (msg.action === 'buyback') | |||||
this.buyback(msg); | this.buyback(msg); | ||||
}, | }, | ||||
@@ -128,7 +128,7 @@ module.exports = { | |||||
let targetTrade = target.trade; | let targetTrade = target.trade; | ||||
let markup = targetTrade.markup.sell; | let markup = targetTrade.markup.sell; | ||||
if (msg.action == 'buyback') { | |||||
if (msg.action === 'buyback') { | |||||
item = targetTrade.findBuyback(msg.itemId, this.obj.name); | item = targetTrade.findBuyback(msg.itemId, this.obj.name); | ||||
markup = targetTrade.markup.buy; | markup = targetTrade.markup.buy; | ||||
} else | } else | ||||
@@ -141,7 +141,7 @@ module.exports = { | |||||
let canAfford = false; | let canAfford = false; | ||||
if (item.worth.currency) { | 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)); | canAfford = ((currencyItem) && (currencyItem.quantity >= item.worth.amount)); | ||||
} else | } else | ||||
canAfford = this.gold >= ~~(item.worth * markup); | canAfford = this.gold >= ~~(item.worth * markup); | ||||
@@ -165,7 +165,7 @@ module.exports = { | |||||
return; | return; | ||||
} | } | ||||
if (item.type == 'skin') { | |||||
if (item.type === 'skin') { | |||||
let haveSkin = this.obj.auth.doesOwnSkin(item.skinId); | let haveSkin = this.obj.auth.doesOwnSkin(item.skinId); | ||||
if (haveSkin) { | if (haveSkin) { | ||||
@@ -183,13 +183,13 @@ module.exports = { | |||||
} | } | ||||
} | } | ||||
if (msg.action == 'buyback') | |||||
if (msg.action === 'buyback') | |||||
targetTrade.removeBuyback(msg.itemId, this.obj.name); | 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); | targetTrade.removeItem(msg.itemId, this.obj.name); | ||||
if (item.worth.currency) { | 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); | this.obj.inventory.destroyItem(currencyItem.id, item.worth.amount, true); | ||||
} else { | } else { | ||||
targetTrade.gold += ~~(item.worth * markup); | targetTrade.gold += ~~(item.worth * markup); | ||||
@@ -197,7 +197,7 @@ module.exports = { | |||||
this.obj.syncer.set(true, 'trade', 'gold', this.gold); | this.obj.syncer.set(true, 'trade', 'gold', this.gold); | ||||
} | } | ||||
if (item.type != 'skin') { | |||||
if (item.type !== 'skin') { | |||||
if (!item.infinite) | if (!item.infinite) | ||||
this.obj.syncer.setArray(true, 'trade', 'removeItems', item.id); | this.obj.syncer.setArray(true, 'trade', 'removeItems', item.id); | ||||
@@ -276,13 +276,13 @@ module.exports = { | |||||
let target = msg.target; | let target = msg.target; | ||||
let targetName = (msg.targetName || '').toLowerCase(); | let targetName = (msg.targetName || '').toLowerCase(); | ||||
if ((target == null) && (!targetName)) | |||||
if ((target === null) && (!targetName)) | |||||
return false; | 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; | this.target = null; | ||||
@@ -330,11 +330,11 @@ module.exports = { | |||||
}, | }, | ||||
removeItem: function (itemId) { | removeItem: function (itemId) { | ||||
return this.items.spliceFirstWhere(i => i.id == itemId); | |||||
return this.items.spliceFirstWhere(i => i.id === itemId); | |||||
}, | }, | ||||
removeBuyback: function (itemId, name) { | 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) { | getItems: function (requestedBy) { | ||||
@@ -372,18 +372,18 @@ module.exports = { | |||||
}, | }, | ||||
findItem: function (itemId, sourceName) { | findItem: function (itemId, sourceName) { | ||||
return this.items.find(i => i.id == itemId); | |||||
return this.items.find(i => i.id === itemId); | |||||
}, | }, | ||||
findBuyback: function (itemId, sourceName) { | 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) { | resolveCallback: function (msg, result) { | ||||
let callbackId = (msg.callbackId != null) ? msg.callbackId : msg; | |||||
let callbackId = (msg.callbackId !== null) ? msg.callbackId : msg; | |||||
result = result || []; | result = result || []; | ||||
if (callbackId == null) | |||||
if (callbackId === null) | |||||
return; | return; | ||||
process.send({ | process.send({ | ||||
@@ -68,10 +68,10 @@ module.exports = { | |||||
}, | }, | ||||
open: function (msg) { | open: function (msg) { | ||||
if (msg.sourceId == null) | |||||
if (msg.sourceId === null) | |||||
return; | 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)) | if ((!obj) || (!obj.player)) | ||||
return; | return; | ||||
@@ -85,7 +85,7 @@ module.exports = { | |||||
}, | }, | ||||
apply: function (msg) { | 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) | if (!obj) | ||||
return; | return; | ||||
@@ -6,7 +6,7 @@ module.exports = { | |||||
let values = {}; | let values = {}; | ||||
for (let p in this) { | for (let p in this) { | ||||
let value = this[p]; | let value = this[p]; | ||||
if ((typeof(value) == 'function') || (p == 'obj') || (p == 'events')) | |||||
if ((typeof(value) === 'function') || (p === 'obj') || (p === 'events')) | |||||
continue; | continue; | ||||
values[p] = value; | values[p] = value; | ||||
@@ -9,7 +9,7 @@ module.exports = { | |||||
}, | }, | ||||
update: function () { | update: function () { | ||||
if (this.cd == 0) { | |||||
if (this.cd === 0) { | |||||
if (this.state < this.config.length - 1) { | if (this.state < this.config.length - 1) { | ||||
this.state++; | this.state++; | ||||
let stateConfig = this.config[this.state]; | let stateConfig = this.config[this.state]; | ||||
@@ -41,7 +41,7 @@ module.exports = { | |||||
events: { | events: { | ||||
mobTalk: function (config) { | 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; | let text = (config.text instanceof Array) ? config.text[config.oldRepeat - config.repeat - 1] : config.text; | ||||
if (config.zone) { | if (config.zone) { | ||||
@@ -70,7 +70,7 @@ module.exports = { | |||||
let mLen = mobs.length; | let mLen = mobs.length; | ||||
for (let i = 0; i < mLen; i++) { | 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++) { | for (let j = 0; j < cLen; j++) { | ||||
let c = components[j]; | let c = components[j]; | ||||
mob.addComponent(c.type, components[j]); | mob.addComponent(c.type, components[j]); | ||||
@@ -91,7 +91,7 @@ module.exports = { | |||||
let mLen = mobs.length; | let mLen = mobs.length; | ||||
for (let i = 0; i < mLen; i++) { | 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++) | for (let j = 0; j < cLen; j++) | ||||
mob.removeComponent(components[j]); | mob.removeComponent(components[j]); | ||||
} | } | ||||
@@ -30,7 +30,7 @@ module.exports = { | |||||
for (let i = 0; i < oLen; i++) { | for (let i = 0; i < oLen; i++) { | ||||
let o = objects[i]; | let o = objects[i]; | ||||
let index = mobs.indexOf(o.id); | let index = mobs.indexOf(o.id); | ||||
if (index == -1) | |||||
if (index === -1) | |||||
continue; | continue; | ||||
if (percentage) { | if (percentage) { | ||||
@@ -52,7 +52,7 @@ module.exports = { | |||||
let m = mobs[i]; | let m = mobs[i]; | ||||
let destroyed = m.destroyed; | let destroyed = m.destroyed; | ||||
if (!destroyed) { | if (!destroyed) { | ||||
let deathStopper = m.components.find(c => (c.type == 'deathStopper')); | |||||
let deathStopper = m.components.find(c => (c.type === 'deathStopper')); | |||||
if (deathStopper) | if (deathStopper) | ||||
destroyed = deathStopper.end; | destroyed = deathStopper.end; | ||||
} | } | ||||
@@ -64,7 +64,7 @@ module.exports = { | |||||
} | } | ||||
} | } | ||||
if (mobs.length == 0) | |||||
if (mobs.length === 0) | |||||
this.end = true; | this.end = true; | ||||
} | } | ||||
}; | }; |
@@ -12,7 +12,7 @@ module.exports = { | |||||
for (let i = 0; i < oLen; i++) { | for (let i = 0; i < oLen; i++) { | ||||
let o = objects[i]; | let o = objects[i]; | ||||
let index = mobs.indexOf(o.id); | let index = mobs.indexOf(o.id); | ||||
if (index == -1) | |||||
if (index === -1) | |||||
continue; | continue; | ||||
mobs.splice(index, 1, o); | mobs.splice(index, 1, o); | ||||
@@ -44,7 +44,7 @@ module.exports = { | |||||
} | } | ||||
} | } | ||||
if (mobs.length == 0) | |||||
if (mobs.length === 0) | |||||
this.end = true; | this.end = true; | ||||
} | } | ||||
}; | }; |
@@ -1,6 +1,6 @@ | |||||
module.exports = { | module.exports = { | ||||
init: function () { | 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; | let states = mob.dialogue.states; | ||||
this.addStates(states, this.dialogue.add || {}); | this.addStates(states, this.dialogue.add || {}); | ||||
@@ -30,7 +30,7 @@ module.exports = { | |||||
if (!target) | if (!target) | ||||
continue; | continue; | ||||
else if (source == null) { | |||||
else if (source === null) { | |||||
delete dialogue[s]; | delete dialogue[s]; | ||||
continue; | continue; | ||||
} | } | ||||
@@ -38,7 +38,7 @@ module.exports = { | |||||
for (let o in source) { | for (let o in source) { | ||||
let targetOptions = target.msg[0].options; | let targetOptions = target.msg[0].options; | ||||
if (targetOptions.options) | if (targetOptions.options) | ||||
targetOptions.spliceWhere(t => (t == o)); | |||||
targetOptions.spliceWhere(t => (t === o)); | |||||
delete target.options[o]; | delete target.options[o]; | ||||
} | } | ||||
@@ -47,7 +47,7 @@ module.exports = { | |||||
} | } | ||||
if (l.exists) { | 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; | mob.mob.walkDistance = 0; | ||||
this.spawnAnimation(mob); | this.spawnAnimation(mob); | ||||
mob.performMove({ | mob.performMove({ | ||||
@@ -21,7 +21,7 @@ module.exports = { | |||||
let result = null; | let result = null; | ||||
if (item.effects) | if (item.effects) | ||||
result = item.effects.find(e => (e.factionId == 'akarei')); | |||||
result = item.effects.find(e => (e.factionId === 'akarei')); | |||||
if (!result) { | if (!result) { | ||||
if (!item.effects) | if (!item.effects) | ||||
@@ -53,7 +53,7 @@ module.exports = { | |||||
if (!damage.crit) | if (!damage.crit) | ||||
return; | return; | ||||
let effect = item.effects.find(e => (e.factionId == 'akarei')); | |||||
let effect = item.effects.find(e => (e.factionId === 'akarei')); | |||||
let roll = Math.random() * 100; | let roll = Math.random() * 100; | ||||
if (roll >= effect.properties.chance) | if (roll >= effect.properties.chance) | ||||
@@ -15,7 +15,7 @@ module.exports = { | |||||
let result = null; | let result = null; | ||||
if (item.effects) | if (item.effects) | ||||
result = item.effects.find(e => (e.factionId == 'anglers')); | |||||
result = item.effects.find(e => (e.factionId === 'anglers')); | |||||
if (!result) { | if (!result) { | ||||
if (!item.effects) | if (!item.effects) | ||||
@@ -42,7 +42,7 @@ module.exports = { | |||||
events: { | events: { | ||||
beforeGatherResource: function (item, gatherResult, source) { | 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; | let roll = Math.random() * 100; | ||||
if (roll >= effect.chance) | if (roll >= effect.chance) | ||||
@@ -18,7 +18,7 @@ module.exports = { | |||||
let result = null; | let result = null; | ||||
if (item.effects) | if (item.effects) | ||||
result = item.effects.find(e => (e.factionId == 'gaekatla')); | |||||
result = item.effects.find(e => (e.factionId === 'gaekatla')); | |||||
if (!result) { | if (!result) { | ||||
if (!item.effects) | if (!item.effects) | ||||
@@ -50,7 +50,7 @@ module.exports = { | |||||
events: { | events: { | ||||
afterKillMob: function (item, mob) { | 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; | let roll = Math.random() * 100; | ||||
if (roll >= effect.chance) | if (roll >= effect.chance) | ||||
@@ -1,13 +1,13 @@ | |||||
module.exports = { | module.exports = { | ||||
events: { | events: { | ||||
onGetText: function (item) { | 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'; | return 'your hits always crit'; | ||||
}, | }, | ||||
onBeforeCalculateDamage: function (item, damage, target) { | 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; | damage.crit = true; | ||||
} | } | ||||
@@ -5,13 +5,13 @@ module.exports = { | |||||
element: null, | element: null, | ||||
onGetText: function (item) { | 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`; | return `you take ${rolls.percentage}% of the damage you deal`; | ||||
}, | }, | ||||
afterDealDamage: function (item, damage, target) { | 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 rolls = effect.rolls; | ||||
let amount = (damage.dealt / 100) * rolls.percentage; | let amount = (damage.dealt / 100) * rolls.percentage; | ||||
@@ -1,13 +1,13 @@ | |||||
module.exports = { | module.exports = { | ||||
events: { | events: { | ||||
onGetText: function (item) { | 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`; | return `${rolls.chance}% chance on hit to freeze target for ${rolls.duration} ticks`; | ||||
}, | }, | ||||
afterDealDamage: function (item, damage, target) { | 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; | let chanceRoll = Math.random() * 100; | ||||
if (chanceRoll >= rolls.chance) | if (chanceRoll >= rolls.chance) | ||||
@@ -1,7 +1,7 @@ | |||||
module.exports = { | module.exports = { | ||||
events: { | events: { | ||||
onGetText: function (item) { | 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 chance = rolls.chance || 100; | ||||
let amount = rolls.amount; | let amount = rolls.amount; | ||||
let percentage = rolls.percentage; | let percentage = rolls.percentage; | ||||
@@ -25,7 +25,7 @@ module.exports = { | |||||
if (!damage.crit) | if (!damage.crit) | ||||
return; | 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; | let chanceRoll = Math.random() * 100; | ||||
if (chanceRoll >= (rolls.chance || 100)) | if (chanceRoll >= (rolls.chance || 100)) | ||||
@@ -54,7 +54,7 @@ module.exports = { | |||||
let amount = 1 + ~~(Math.random() * (total - 1)); | let amount = 1 + ~~(Math.random() * (total - 1)); | ||||
total -= amount; | total -= amount; | ||||
let item = items.find(f => (f.name == pick.name)); | |||||
let item = items.find(f => (f.name === pick.name)); | |||||
if (!item) { | if (!item) { | ||||
item = extend(true, { | item = extend(true, { | ||||
material: true, | material: true, | ||||
@@ -29,7 +29,7 @@ module.exports = { | |||||
1.6: { | 1.6: { | ||||
msg: 'I have some crystals for you.', | msg: 'I have some crystals for you.', | ||||
prereq: function (obj) { | 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; | return !!crystals; | ||||
}, | }, | ||||
goto: 'giveCrystals' | goto: 'giveCrystals' | ||||
@@ -226,7 +226,7 @@ module.exports = { | |||||
method: function (obj) { | method: function (obj) { | ||||
let inventory = obj.inventory; | 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) | if (!crystals) | ||||
return; | return; | ||||
obj.reputation.getReputation('akarei', (crystals.quantity || 1) * 15); | obj.reputation.getReputation('akarei', (crystals.quantity || 1) * 15); | ||||
@@ -486,7 +486,7 @@ module.exports = { | |||||
activated.push(order); | activated.push(order); | ||||
let valid = true; | let valid = true; | ||||
for (let i = 0; i < activated.length; i++) { | for (let i = 0; i < activated.length; i++) { | ||||
if (activated[i] != i) { | |||||
if (activated[i] !== i) { | |||||
valid = false; | valid = false; | ||||
break; | break; | ||||
} | } | ||||
@@ -508,7 +508,7 @@ module.exports = { | |||||
}); | }); | ||||
return; | return; | ||||
} else if (activated.length == 4) { | |||||
} else if (activated.length === 4) { | |||||
triggerPuzzle.activated = []; | triggerPuzzle.activated = []; | ||||
this.activate(); | this.activate(); | ||||
} | } | ||||
@@ -528,7 +528,7 @@ module.exports = { | |||||
activate: function () { | activate: function () { | ||||
let syncer = this.obj.instance.syncer; | let syncer = this.obj.instance.syncer; | ||||
let physics = this.obj.instance.physics; | 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) { | walls.forEach(function (w) { | ||||
w.destroyed = true; | w.destroyed = true; | ||||
physics.setCollision(w.x, w.y, false); | physics.setCollision(w.x, w.y, false); | ||||
@@ -225,12 +225,12 @@ module.exports = { | |||||
let sets = items.filter(function (i) { | let sets = items.filter(function (i) { | ||||
return ( | return ( | ||||
(i.type == 'Reward Card') && | |||||
(i.type === 'Reward Card') && | |||||
(i.quantity >= i.setSize) | (i.quantity >= i.setSize) | ||||
); | ); | ||||
}); | }); | ||||
if (sets.length == 0) | |||||
if (sets.length === 0) | |||||
return 'Sorry, you don\'t have any completed sets.'; | return 'Sorry, you don\'t have any completed sets.'; | ||||
sets.forEach(function (s) { | sets.forEach(function (s) { | ||||
@@ -73,7 +73,7 @@ module.exports = { | |||||
let fish = []; | let fish = []; | ||||
tempFish.forEach(function (t) { | tempFish.forEach(function (t) { | ||||
if (!fish.some(f => (f.owner == t.owner))) | |||||
if (!fish.some(f => (f.owner === t.owner))) | |||||
fish.push(t); | fish.push(t); | ||||
}); | }); | ||||
@@ -128,10 +128,10 @@ module.exports = { | |||||
let ranks = event.ranks; | let ranks = event.ranks; | ||||
let winText = 'Angler Nayla: '; | 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; | let wLen = winners.length; | ||||
winners.forEach(function (w, i) { | 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!'; | winText += 'won!'; | ||||
@@ -147,7 +147,7 @@ module.exports = { | |||||
.filter(i => (i.name.indexOf('Ancient Carp') > -1)) | .filter(i => (i.name.indexOf('Ancient Carp') > -1)) | ||||
.sort((a, b) => (b.stats.weight - a.stats.weight)) | .sort((a, b) => (b.stats.weight - a.stats.weight)) | ||||
.forEach(function (f, i) { | .forEach(function (f, i) { | ||||
if (i == 0) { | |||||
if (i === 0) { | |||||
f.owner = source.name; | f.owner = source.name; | ||||
tgtInventory.getItem(extend(true, {}, f)); | tgtInventory.getItem(extend(true, {}, f)); | ||||
} | } | ||||
@@ -340,10 +340,10 @@ module.exports = { | |||||
auto: true, | auto: true, | ||||
events: { | events: { | ||||
beforeGatherResource: function (gatherResult, gatherer) { | beforeGatherResource: function (gatherResult, gatherer) { | ||||
if (gatherResult.nodeType != 'fish') | |||||
if (gatherResult.nodeType !== 'fish') | |||||
return; | 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) | if (!hasCompRod) | ||||
return; | return; | ||||
@@ -357,7 +357,7 @@ module.exports = { | |||||
}, | }, | ||||
beforeEnterPool: function (gatherResult, gatherer) { | beforeEnterPool: function (gatherResult, gatherer) { | ||||
if (gatherResult.nodeName == 'Sun Carp') | |||||
if (gatherResult.nodeName === 'Sun Carp') | |||||
gatherResult.nodeName = 'Ancient Carp'; | gatherResult.nodeName = 'Ancient Carp'; | ||||
} | } | ||||
} | } | ||||
@@ -398,7 +398,7 @@ module.exports = { | |||||
let newRank = helpers.getRank(event, obj.name); | let newRank = helpers.getRank(event, obj.name); | ||||
helpers.updateDescription(event, this.instance.events); | helpers.updateDescription(event, this.instance.events); | ||||
if (oldRank != newRank) { | |||||
if (oldRank !== newRank) { | |||||
helpers.updateWinText(event, this.instance.events); | helpers.updateWinText(event, this.instance.events); | ||||
return { | return { | ||||
@@ -406,7 +406,7 @@ module.exports = { | |||||
2: 'Nice catch. You took second place!', | 2: 'Nice catch. You took second place!', | ||||
3: 'Not bad at all. You took third place!' | 3: 'Not bad at all. You took third place!' | ||||
}[newRank]; | }[newRank]; | ||||
} else if (newRank == 1) | |||||
} else if (newRank === 1) | |||||
return 'Great, you\'re still in first place!'; | return 'Great, you\'re still in first place!'; | ||||
return 'Not quite heavy enough, keep trying!'; | return 'Not quite heavy enough, keep trying!'; | ||||
} | } | ||||
@@ -13,7 +13,7 @@ module.exports = { | |||||
events: { | events: { | ||||
afterEquipItem: function (item) { | afterEquipItem: function (item) { | ||||
if (['oneHanded', 'twoHanded'].indexOf(item.slot) == -1) | |||||
if (['oneHanded', 'twoHanded'].indexOf(item.slot) === -1) | |||||
return; | return; | ||||
let stats = item.stats; | let stats = item.stats; | ||||
@@ -24,7 +24,7 @@ module.exports = { | |||||
} | } | ||||
}, | }, | ||||
afterUnequipItem: function (item) { | afterUnequipItem: function (item) { | ||||
if (['oneHanded', 'twoHanded'].indexOf(item.slot) == -1) | |||||
if (['oneHanded', 'twoHanded'].indexOf(item.slot) === -1) | |||||
return; | return; | ||||
let stats = item.stats; | let stats = item.stats; | ||||
@@ -10,7 +10,7 @@ module.exports = { | |||||
obtain: function (obj, template) { | obtain: function (obj, template) { | ||||
let zoneName = template ? template.zoneName : obj.zoneName; | let zoneName = template ? template.zoneName : obj.zoneName; | ||||
let oQuests = obj.quests; | 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; | return; | ||||
let zoneTemplate = null; | let zoneTemplate = null; | ||||
@@ -26,12 +26,12 @@ module.exports = { | |||||
let config = extend(true, {}, zoneTemplate); | let config = extend(true, {}, zoneTemplate); | ||||
this.instance.eventEmitter.emit('onBeforeGetQuests', config); | this.instance.eventEmitter.emit('onBeforeGetQuests', config); | ||||
if (config.infini.length == 0) | |||||
if (config.infini.length === 0) | |||||
return; | return; | ||||
let pickQuest = null; | let pickQuest = null; | ||||
if ((template) && (template.type)) | if ((template) && (template.type)) | ||||
pickQuest = config.infini.find(c => c.type == template.type); | |||||
pickQuest = config.infini.find(c => c.type === template.type); | |||||
if (!pickQuest) | if (!pickQuest) | ||||
pickQuest = config.infini[~~(Math.random() * config.infini.length)]; | pickQuest = config.infini[~~(Math.random() * config.infini.length)]; | ||||
@@ -14,7 +14,7 @@ module.exports = { | |||||
this.gatherType = ['herb', 'fish'][~~(Math.random() * 2)]; | this.gatherType = ['herb', 'fish'][~~(Math.random() * 2)]; | ||||
if (this.gatherType == 'fish') { | |||||
if (this.gatherType === 'fish') { | |||||
this.name = 'Lure of the Sea'; | this.name = 'Lure of the Sea'; | ||||
let isQualityQ = (Math.random() < 0.3); | 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.gatherType = 'herb'; | ||||
this.typeName = (this.gatherType == 'herb') ? 'herbs' : 'fish'; | |||||
this.typeName = (this.gatherType === 'herb') ? 'herbs' : 'fish'; | |||||
this.updateDescription(); | this.updateDescription(); | ||||
@@ -36,9 +36,9 @@ module.exports = { | |||||
}, | }, | ||||
getXpMultiplier: function () { | getXpMultiplier: function () { | ||||
if (this.requiredQuality == 2) | |||||
if (this.requiredQuality === 2) | |||||
return 8; | return 8; | ||||
else if (this.requiredQuality == 1) | |||||
else if (this.requiredQuality === 1) | |||||
return 6; | return 6; | ||||
return this.need; | return this.need; | ||||
}, | }, | ||||
@@ -58,12 +58,12 @@ module.exports = { | |||||
events: { | events: { | ||||
afterGatherResource: function (gatherResult) { | afterGatherResource: function (gatherResult) { | ||||
if (gatherResult.nodeType != this.gatherType) | |||||
if (gatherResult.nodeType !== this.gatherType) | |||||
return; | return; | ||||
else if ((this.requiredQuality) && (gatherResult.items[0].quality < this.requiredQuality)) | else if ((this.requiredQuality) && (gatherResult.items[0].quality < this.requiredQuality)) | ||||
return; | return; | ||||
if ((this.obj.zoneName != this.zoneName) || (this.have >= this.need)) | |||||
if ((this.obj.zoneName !== this.zoneName) || (this.have >= this.need)) | |||||
return; | return; | ||||
this.have++; | this.have++; | ||||
@@ -9,12 +9,12 @@ module.exports = { | |||||
build: function () { | build: function () { | ||||
//If we're not in the correct zone, don't do this check, it'll just crash the server | //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 | // 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; | let mobTypes = this.obj.instance.spawners.zone.mobs; | ||||
if (this.mobName) { | if (this.mobName) { | ||||
let mobType = mobTypes[this.mobName.toLowerCase()]; | let mobType = mobTypes[this.mobName.toLowerCase()]; | ||||
//Maybe the zoneFile changed in the meantime. If so, regenerate | //Maybe the zoneFile changed in the meantime. If so, regenerate | ||||
if ((!mobType) || (mobType.attackable == false)) | |||||
if ((!mobType) || (mobType.attackable === false)) | |||||
this.mobName = null; | this.mobName = null; | ||||
} | } | ||||
@@ -24,10 +24,10 @@ module.exports = { | |||||
let mobBlueprint = mobTypes[m]; | let mobBlueprint = mobTypes[m]; | ||||
return ( | return ( | ||||
(m != 'default') && | |||||
(m !== 'default') && | |||||
( | ( | ||||
(mobBlueprint.attackable) || | (mobBlueprint.attackable) || | ||||
(mobBlueprint.attackable == null) | |||||
(mobBlueprint.attackable === null) | |||||
) && | ) && | ||||
(mobBlueprint.level <= ~~(this.obj.stats.values.level * 1.35)) && | (mobBlueprint.level <= ~~(this.obj.stats.values.level * 1.35)) && | ||||
(mobCounts[m] > 1) | (mobCounts[m] > 1) | ||||
@@ -35,7 +35,7 @@ module.exports = { | |||||
}, this); | }, this); | ||||
//No level appropriate mobs found | //No level appropriate mobs found | ||||
if (keys.length == 0) | |||||
if (keys.length === 0) | |||||
return false; | return false; | ||||
this.mobType = keys[~~(Math.random() * keys.length)]; | this.mobType = keys[~~(Math.random() * keys.length)]; | ||||
@@ -59,7 +59,7 @@ module.exports = { | |||||
events: { | events: { | ||||
afterKillMob: function (mob) { | 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; | return; | ||||
this.have++; | this.have++; | ||||
@@ -8,10 +8,10 @@ module.exports = { | |||||
build: function () { | build: function () { | ||||
let slotNames = slots.slots | let slotNames = slots.slots | ||||
.filter(s => (s != 'tool')); | |||||
.filter(s => (s !== 'tool')); | |||||
if (this.slot) { | if (this.slot) { | ||||
if (!slotNames.some(s => (s == this.slot))) | |||||
if (!slotNames.some(s => (s === this.slot))) | |||||
this.slot = null; | this.slot = null; | ||||
} | } | ||||
@@ -20,9 +20,9 @@ module.exports = { | |||||
this.quality = 1 + ~~(Math.random() * 2); | this.quality = 1 + ~~(Math.random() * 2); | ||||
this.slotName = ''; | this.slotName = ''; | ||||
if (this.quality == 1) { | |||||
if (this.quality === 1) { | |||||
let roll = ~~(Math.random() * 2); | let roll = ~~(Math.random() * 2); | ||||
if (roll == 0) | |||||
if (roll === 0) | |||||
this.slotName = 'Magic Armor'; | this.slotName = 'Magic Armor'; | ||||
else | else | ||||
this.slotName = 'Magic Accessory'; | this.slotName = 'Magic Accessory'; | ||||
@@ -66,9 +66,9 @@ module.exports = { | |||||
if (!this.quality) | if (!this.quality) | ||||
multiplier *= 8; | multiplier *= 8; | ||||
else if (this.quality == 2) | |||||
else if (this.quality === 2) | |||||
multiplier *= 6; | multiplier *= 6; | ||||
else if (this.quality == 1) | |||||
else if (this.quality === 1) | |||||
multiplier *= 4; | multiplier *= 4; | ||||
return multiplier; | return multiplier; | ||||
@@ -78,18 +78,18 @@ module.exports = { | |||||
afterLootMobItem: function (item) { | afterLootMobItem: function (item) { | ||||
if ( | if ( | ||||
(this.isReady) || | (this.isReady) || | ||||
(this.obj.zoneName != this.zoneName) || | |||||
(this.obj.zoneName !== this.zoneName) || | |||||
( | ( | ||||
(this.quality) && | (this.quality) && | ||||
(item.quality < this.quality) | (item.quality < this.quality) | ||||
) || | ) || | ||||
( | ( | ||||
(this.slot.indexOf) && | (this.slot.indexOf) && | ||||
(this.slot.indexOf(item.slot) == -1) | |||||
(this.slot.indexOf(item.slot) === -1) | |||||
) || | ) || | ||||
( | ( | ||||
(!this.slot.indexOf) && | (!this.slot.indexOf) && | ||||
(this.slot != item.slot) | |||||
(this.slot !== item.slot) | |||||
) | ) | ||||
) | ) | ||||
return; | return; | ||||
@@ -18,14 +18,14 @@ module.exports = { | |||||
let mobBlueprint = mobTypes[m]; | let mobBlueprint = mobTypes[m]; | ||||
return ( | return ( | ||||
(m != 'default') && | |||||
(m !== 'default') && | |||||
(mobBlueprint.questItem) && | (mobBlueprint.questItem) && | ||||
(mobBlueprint.level <= (this.obj.stats.values.level * 1.35)) | (mobBlueprint.level <= (this.obj.stats.values.level * 1.35)) | ||||
); | ); | ||||
}, this); | }, this); | ||||
//No level appropriate mobs found | //No level appropriate mobs found | ||||
if (keys.length == 0) | |||||
if (keys.length === 0) | |||||
return false; | return false; | ||||
this.mobType = keys[~~(Math.random() * keys.length)]; | this.mobType = keys[~~(Math.random() * keys.length)]; | ||||
@@ -51,14 +51,14 @@ module.exports = { | |||||
oComplete: function () { | oComplete: function () { | ||||
let inventory = this.obj.inventory; | 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) | if (item) | ||||
this.obj.inventory.destroyItem(item.id, this.need); | this.obj.inventory.destroyItem(item.id, this.need); | ||||
}, | }, | ||||
events: { | events: { | ||||
beforeTargetDeath: function (target, dropItems) { | 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; | return; | ||||
let roll = Math.random(); | let roll = Math.random(); | ||||
@@ -76,11 +76,11 @@ module.exports = { | |||||
}, | }, | ||||
afterLootMobItem: function (item) { | 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; | return; | ||||
this.have++; | this.have++; | ||||
if (this.have == this.need) | |||||
if (this.have === this.need) | |||||
this.ready(); | this.ready(); | ||||
this.description = 'Loot ' + this.have + '/' + this.need + ' ' + this.item.name + ' from ' + this.mobName; | this.description = 'Loot ' + this.have + '/' + this.need + ' ' + this.item.name + ' from ' + this.mobName; | ||||
@@ -88,7 +88,7 @@ module.exports = { | |||||
}, | }, | ||||
afterDestroyItem: function (item, quantity) { | afterDestroyItem: function (item, quantity) { | ||||
if (item.name.toLowerCase() != this.item.name.toLowerCase()) | |||||
if (item.name.toLowerCase() !== this.item.name.toLowerCase()) | |||||
return; | return; | ||||
this.have -= quantity; | this.have -= quantity; | ||||
@@ -73,7 +73,7 @@ module.exports = { | |||||
let values = {}; | let values = {}; | ||||
for (let p in this) { | for (let p in this) { | ||||
let value = this[p]; | let value = this[p]; | ||||
if ((typeof (value) == 'function') || (p == 'obj')) | |||||
if ((typeof (value) === 'function') || (p === 'obj')) | |||||
continue; | continue; | ||||
values[p] = value; | values[p] = value; | ||||
@@ -9,7 +9,7 @@ module.exports = { | |||||
let account = obj.account; | let account = obj.account; | ||||
let config = this.getAccount(account) || {}; | let config = this.getAccount(account) || {}; | ||||
if (config.items) { | if (config.items) { | ||||
let blueprintInventory = blueprint.components.find(c => (c.type == 'inventory')); | |||||
let blueprintInventory = blueprint.components.find(c => (c.type === 'inventory')); | |||||
if (!blueprintInventory) { | if (!blueprintInventory) { | ||||
blueprint.components.push({ | blueprint.components.push({ | ||||
type: 'inventory', | type: 'inventory', | ||||
@@ -22,7 +22,7 @@ module.exports = { | |||||
let items = blueprintInventory.items; | let items = blueprintInventory.items; | ||||
config.items.forEach(function (item) { | 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) | if (hasItem) | ||||
return; | return; | ||||
@@ -62,14 +62,14 @@ module.exports = { | |||||
getSkins: function (account) { | getSkins: function (account) { | ||||
let skins = []; | let skins = []; | ||||
let account = this.getAccount(account) || { | |||||
account = this.getAccount(account) || { | |||||
skins: [] | skins: [] | ||||
}; | }; | ||||
(account.skins || []).forEach(function (s) { | (account.skins || []).forEach(function (s) { | ||||
skins.push(s); | skins.push(s); | ||||
}); | }); | ||||
skins = skins.filter((s, i) => (skins.indexOf(s) == i)); | |||||
skins = skins.filter((s, i) => (skins.indexOf(s) === i)); | |||||
return skins; | return skins; | ||||
}, | }, | ||||
@@ -117,7 +117,7 @@ module.exports = { | |||||
getSkinList: function (skins) { | getSkinList: function (skins) { | ||||
let list = Object.keys(config) | let list = Object.keys(config) | ||||
.filter(function (s) { | .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) { | .map(function (s) { | ||||
let res = extend(true, {}, config[s]); | let res = extend(true, {}, config[s]); | ||||
@@ -15,7 +15,7 @@ let cpnArcanePatch = { | |||||
let isPlayer = !!this.caster.player; | let isPlayer = !!this.caster.player; | ||||
let isTargetPlayer = !!o.player; | let isTargetPlayer = !!o.player; | ||||
if ((this.caster.aggro.canAttack(o)) || (isPlayer != isTargetPlayer)) | |||||
if ((this.caster.aggro.canAttack(o)) || (isPlayer !== isTargetPlayer)) | |||||
return; | return; | ||||
this.contents.push(o); | this.contents.push(o); | ||||
@@ -25,7 +25,7 @@ let cpnArcanePatch = { | |||||
let contents = this.contents; | let contents = this.contents; | ||||
let cLen = contents.length; | let cLen = contents.length; | ||||
for (let i = 0; i < cLen; i++) { | for (let i = 0; i < cLen; i++) { | ||||
if (contents[i] == o) { | |||||
if (contents[i] === o) { | |||||
contents.splice(i, 1); | contents.splice(i, 1); | ||||
return; | return; | ||||
} | } | ||||
@@ -42,7 +42,7 @@ module.exports = { | |||||
updateActive: function () { | updateActive: function () { | ||||
let o = this.obj; | let o = this.obj; | ||||
let amount = 0; | let amount = 0; | ||||
if (this.name == 'Innervation') | |||||
if (this.name === 'Innervation') | |||||
amount = ~~((o.stats.values.hpMax / 100) * this.values.regenPercentage); | amount = ~~((o.stats.values.hpMax / 100) * this.values.regenPercentage); | ||||
else | else | ||||
amount = this.values.regenPercentage || this.values.chance; | amount = this.values.regenPercentage || this.values.chance; | ||||
@@ -103,7 +103,7 @@ module.exports = { | |||||
if (!effect) | if (!effect) | ||||
return; | return; | ||||
let obj = objects.find(o => (o.serverId == m)); | |||||
let obj = objects.find(o => (o.serverId === m)); | |||||
if (!obj) { | if (!obj) { | ||||
delete effects[m]; | delete effects[m]; | ||||
return; | return; | ||||
@@ -25,7 +25,7 @@ module.exports = { | |||||
for (let i = 0; i < cLen; i++) { | for (let i = 0; i < cLen; i++) { | ||||
let c = callbacks[i]; | let c = callbacks[i]; | ||||
if (c.sourceId == sourceId) { | |||||
if (c.sourceId === sourceId) { | |||||
if (c.destroyCallback) | if (c.destroyCallback) | ||||
c.destroyCallback(); | c.destroyCallback(); | ||||
callbacks.splice(i, 1); | callbacks.splice(i, 1); | ||||
@@ -23,11 +23,11 @@ module.exports = { | |||||
//We need to stop just short of the target | //We need to stop just short of the target | ||||
let offsetX = 0; | let offsetX = 0; | ||||
if (dx != 0) | |||||
if (dx !== 0) | |||||
offsetX = dx / Math.abs(dx); | offsetX = dx / Math.abs(dx); | ||||
let offsetY = 0; | let offsetY = 0; | ||||
if (dy != 0) | |||||
if (dy !== 0) | |||||
offsetY = dy / Math.abs(dy); | offsetY = dy / Math.abs(dy); | ||||
let targetPos = { | let targetPos = { | ||||
@@ -32,7 +32,7 @@ module.exports = { | |||||
}] | }] | ||||
}; | }; | ||||
if ((i != x) || (j != y)) | |||||
if ((i !== x) || (j !== y)) | |||||
syncer.queue('onGetObject', effect, -1); | syncer.queue('onGetObject', effect, -1); | ||||
let mobs = physics.getCell(i, j); | let mobs = physics.getCell(i, j); | ||||
@@ -66,7 +66,7 @@ module.exports = { | |||||
let dx = m.x - obj.x; | let dx = m.x - obj.x; | ||||
let dy = m.y - obj.y; | let dy = m.y - obj.y; | ||||
while ((dx == 0) && (dy == 0)) { | |||||
while ((dx === 0) && (dy === 0)) { | |||||
dx = ~~(Math.random() * 2) - 1; | dx = ~~(Math.random() * 2) - 1; | ||||
dy = ~~(Math.random() * 2) - 1; | dy = ~~(Math.random() * 2) - 1; | ||||
} | } | ||||
@@ -19,7 +19,7 @@ let cpnHealPatch = { | |||||
let isPlayer = !!this.caster.player; | let isPlayer = !!this.caster.player; | ||||
let isTargetPlayer = !!o.player; | let isTargetPlayer = !!o.player; | ||||
if ((this.caster.aggro.canAttack(o)) || (isPlayer != isTargetPlayer)) | |||||
if ((this.caster.aggro.canAttack(o)) || (isPlayer !== isTargetPlayer)) | |||||
return; | return; | ||||
this.contents.push(o); | this.contents.push(o); | ||||
@@ -29,7 +29,7 @@ let cpnHealPatch = { | |||||
let contents = this.contents; | let contents = this.contents; | ||||
let cLen = contents.length; | let cLen = contents.length; | ||||
for (let i = 0; i < cLen; i++) { | for (let i = 0; i < cLen; i++) { | ||||
if (contents[i] == o) { | |||||
if (contents[i] === o) { | |||||
contents.splice(i, 1); | contents.splice(i, 1); | ||||
return; | return; | ||||
} | } | ||||
@@ -61,7 +61,7 @@ module.exports = { | |||||
continue; | continue; | ||||
let distance = ~~Math.sqrt(Math.pow(dx, 2) + Math.pow(dy, 2)); | let distance = ~~Math.sqrt(Math.pow(dx, 2) + Math.pow(dy, 2)); | ||||
if (distance != radius) | |||||
if (distance !== radius) | |||||
continue; | continue; | ||||
if (!physics.hasLos(x, y, i, j)) | if (!physics.hasLos(x, y, i, j)) | ||||
@@ -21,7 +21,7 @@ let cpnSmokePatch = { | |||||
let contents = this.contents; | let contents = this.contents; | ||||
let cLen = contents.length; | let cLen = contents.length; | ||||
for (let i = 0; i < cLen; i++) { | for (let i = 0; i < cLen; i++) { | ||||
if (contents[i] == o) { | |||||
if (contents[i] === o) { | |||||
contents.splice(i, 1); | contents.splice(i, 1); | ||||
return; | return; | ||||
} | } | ||||
@@ -89,7 +89,7 @@ module.exports = { | |||||
if (this.randomPos) { | if (this.randomPos) { | ||||
let range = this.range; | 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; | x = obj.x + ~~(Math.random() * range * 2) - range; | ||||
y = obj.y + ~~(Math.random() * range * 2) - range; | y = obj.y + ~~(Math.random() * range * 2) - range; | ||||
} | } | ||||
@@ -110,7 +110,7 @@ module.exports = { | |||||
}] | }] | ||||
}, -1); | }, -1); | ||||
} else | } else | ||||
m.mob.update = (this.walkCd == 0) ? m.mob.realUpdate : null; | |||||
m.mob.update = (this.walkCd === 0) ? m.mob.realUpdate : null; | |||||
} | } | ||||
}, | }, | ||||
@@ -28,7 +28,7 @@ module.exports = { | |||||
return true; | return true; | ||||
let inRange = true; | let inRange = true; | ||||
if (this.range != null) { | |||||
if (this.range !== null) { | |||||
let obj = this.obj; | let obj = this.obj; | ||||
let distance = Math.max(Math.abs(target.x - obj.x), Math.abs(target.y - obj.y)); | let distance = Math.max(Math.abs(target.x - obj.x), Math.abs(target.y - obj.y)); | ||||
inRange = (distance <= this.range); | inRange = (distance <= this.range); | ||||
@@ -43,7 +43,7 @@ module.exports = { | |||||
}, | }, | ||||
calcDps: function (target, noSync) { | calcDps: function (target, noSync) { | ||||
if ((!this.values) || (this.spellType == 'buff')) | |||||
if ((!this.values) || (this.spellType === 'buff')) | |||||
return; | return; | ||||
if ((!this.damage) && (!this.healing)) | if ((!this.damage) && (!this.healing)) | ||||
@@ -67,7 +67,7 @@ module.exports = { | |||||
noCrit: true | noCrit: true | ||||
}).amount; | }).amount; | ||||
let isAttack = (this.type == 'melee'); | |||||
let isAttack = (this.type === 'melee'); | |||||
let statValues = this.obj.stats.values; | let statValues = this.obj.stats.values; | ||||
@@ -140,7 +140,7 @@ module.exports = { | |||||
let values = {}; | let values = {}; | ||||
for (let p in this) { | for (let p in this) { | ||||
let value = this[p]; | let value = this[p]; | ||||
if ((typeof (value) == 'function') || (p == 'obj')) | |||||
if ((typeof (value) === 'function') || (p === 'obj')) | |||||
continue; | continue; | ||||
values[p] = value; | values[p] = value; | ||||
@@ -158,7 +158,7 @@ module.exports = { | |||||
}, | }, | ||||
getDamage: function (target, noMitigate) { | getDamage: function (target, noMitigate) { | ||||
let damage = { | |||||
let config = { | |||||
source: this.obj, | source: this.obj, | ||||
target: target, | target: target, | ||||
damage: (this.damage || this.healing) * (this.dmgMult || 1), | damage: (this.damage || this.healing) * (this.dmgMult || 1), | ||||
@@ -166,13 +166,13 @@ module.exports = { | |||||
element: this.element, | element: this.element, | ||||
statType: this.statType, | statType: this.statType, | ||||
statMult: this.statMult, | statMult: this.statMult, | ||||
isAttack: (this.type == 'melee'), | |||||
isAttack: (this.type === 'melee'), | |||||
noMitigate: noMitigate | noMitigate: noMitigate | ||||
}; | }; | ||||
this.obj.fireEvent('onBeforeCalculateDamage', damage); | |||||
this.obj.fireEvent('onBeforeCalculateDamage', config); | |||||
let damage = combat.getDamage(damage); | |||||
let damage = combat.getDamage(config); | |||||
return damage; | return damage; | ||||
}, | }, | ||||
@@ -18,7 +18,7 @@ let cpnSpikePatch = { | |||||
let contents = this.contents; | let contents = this.contents; | ||||
let cLen = contents.length; | let cLen = contents.length; | ||||
for (let i = 0; i < cLen; i++) { | for (let i = 0; i < cLen; i++) { | ||||
if (contents[i] == o) { | |||||
if (contents[i] === o) { | |||||
contents.splice(i, 1); | contents.splice(i, 1); | ||||
return; | return; | ||||
} | } | ||||
@@ -83,8 +83,8 @@ module.exports = { | |||||
if (this.obj.instance.physics.isTileBlocking(x, y)) | if (this.obj.instance.physics.isTileBlocking(x, y)) | ||||
this.distance = 7; | 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 particles = this.particles; | ||||
let spike = this.obj.instance.objects.buildObjects([{ | let spike = this.obj.instance.objects.buildObjects([{ | ||||
@@ -47,7 +47,7 @@ module.exports = { | |||||
if (!physics.hasLos(x, y, i, j)) | if (!physics.hasLos(x, y, i, j)) | ||||
continue; | continue; | ||||
else if ((attackTemplate) && (attackTemplate[count] == 'x')) | |||||
else if ((attackTemplate) && (attackTemplate[count] === 'x')) | |||||
continue; | continue; | ||||
if ((attackTemplate) && (~~attackTemplate[count] > 0)) { | if ((attackTemplate) && (~~attackTemplate[count] > 0)) { | ||||
@@ -25,7 +25,7 @@ module.exports = { | |||||
}, | }, | ||||
getEvent: function (name) { | 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) { | setEventDescription: function (name, desc) { | ||||
let config = this.getEvent(name); | let config = this.getEvent(name); | ||||
@@ -202,7 +202,7 @@ module.exports = { | |||||
} | } | ||||
if (event.config.notifications) { | 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) { | if (n) { | ||||
this.instance.syncer.queue('onGetMessages', { | this.instance.syncer.queue('onGetMessages', { | ||||
messages: { | messages: { | ||||
@@ -211,7 +211,7 @@ module.exports = { | |||||
} | } | ||||
}, -1); | }, -1); | ||||
if (n.desc != null) { | |||||
if (n.desc !== null) { | |||||
event.config.descTimer = n.desc; | event.config.descTimer = n.desc; | ||||
this.setEventDescription(event.config.name); | this.setEventDescription(event.config.name); | ||||
} | } | ||||
@@ -220,9 +220,9 @@ module.exports = { | |||||
event.age++; | event.age++; | ||||
if (event.age == event.config.duration) | |||||
if (event.age === event.config.duration) | |||||
event.done = true; | 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); | this.giveRewards(event.config); | ||||
if (stillBusy) | if (stillBusy) | ||||
@@ -258,7 +258,7 @@ module.exports = { | |||||
event.done = true; | event.done = true; | ||||
let oList = this.instance.objects.objects; | let oList = this.instance.objects.objects; | ||||
let oLen = oList.length; | |||||
oLen = oList.length; | |||||
for (let i = 0; i < oLen; i++) { | for (let i = 0; i < oLen; i++) { | ||||
let o = oList[i]; | let o = oList[i]; | ||||
if (!o.player) | if (!o.player) | ||||
@@ -283,16 +283,16 @@ module.exports = { | |||||
if (!event) | if (!event) | ||||
continue; | continue; | ||||
let exists = event.participators.find(p => (p.name == obj.name)); | |||||
let exists = event.participators.find(p => (p.name === obj.name)); | |||||
if (exists) { | if (exists) { | ||||
event.participators.spliceWhere(p => (p == exists)); | |||||
event.participators.spliceWhere(p => (p === exists)); | |||||
event.participators.push(obj); | event.participators.push(obj); | ||||
result.push(event); | result.push(event); | ||||
continue; | continue; | ||||
} | } | ||||
let distance = event.config.distance; | let distance = event.config.distance; | ||||
if (distance == -1) { | |||||
if (distance === -1) { | |||||
event.participators.push(obj); | event.participators.push(obj); | ||||
result.push(event); | result.push(event); | ||||
@@ -312,7 +312,7 @@ module.exports = { | |||||
let o = objects[j]; | let o = objects[j]; | ||||
if ( | if ( | ||||
(distance == -1) || | |||||
(distance === -1) || | |||||
(!distance) || | (!distance) || | ||||
( | ( | ||||
(Math.abs(x - o.x) < distance) && | (Math.abs(x - o.x) < distance) && | ||||
@@ -3,7 +3,7 @@ let configSkins = require('../config/skins'); | |||||
module.exports = { | module.exports = { | ||||
fixCharacter: function (player) { | 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)) | if ((inv) && (inv.items)) | ||||
this.fixItems(inv.items); | this.fixItems(inv.items); | ||||
}, | }, | ||||
@@ -14,7 +14,7 @@ module.exports = { | |||||
fixItems: function (items) { | fixItems: function (items) { | ||||
items | items | ||||
.filter(i => ((i.name == 'Cowl of Obscurity') && (!i.factions))) | |||||
.filter(i => ((i.name === 'Cowl of Obscurity') && (!i.factions))) | |||||
.forEach(function (i) { | .forEach(function (i) { | ||||
i.factions = [{ | i.factions = [{ | ||||
id: 'gaekatla', | id: 'gaekatla', | ||||
@@ -23,7 +23,7 @@ module.exports = { | |||||
}); | }); | ||||
items | items | ||||
.filter(i => (i.name == 'Steelclaw\'s Bite')) | |||||
.filter(i => (i.name === 'Steelclaw\'s Bite')) | |||||
.forEach(function (i) { | .forEach(function (i) { | ||||
let effect = i.effects[0]; | let effect = i.effects[0]; | ||||
@@ -36,7 +36,7 @@ module.exports = { | |||||
}); | }); | ||||
items | 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) { | .forEach(function (i) { | ||||
let effect = i.effects[0]; | let effect = i.effects[0]; | ||||
let chance = parseFloat(effect.text.split(' ')[0].replace('%', '')); | let chance = parseFloat(effect.text.split(' ')[0].replace('%', '')); | ||||
@@ -63,7 +63,7 @@ module.exports = { | |||||
let length = skins.length; | let length = skins.length; | ||||
skins = skins.filter(s => !!configSkins.getBlueprint(s)); | skins = skins.filter(s => !!configSkins.getBlueprint(s)); | ||||
if (length != skins.length) { | |||||
if (length !== skins.length) { | |||||
io.set({ | io.set({ | ||||
ent: username, | ent: username, | ||||
field: 'skins', | field: 'skins', | ||||
@@ -15,8 +15,6 @@ let spells = require('./config/spells'); | |||||
let itemTypes = require('./items/config/types'); | let itemTypes = require('./items/config/types'); | ||||
let sheets = require('./security/sheets'); | let sheets = require('./security/sheets'); | ||||
global.io = true; | |||||
let startup = { | let startup = { | ||||
init: function () { | init: function () { | ||||
io.init(this.onDbReady.bind(this)); | io.init(this.onDbReady.bind(this)); | ||||
@@ -52,7 +52,7 @@ module.exports = { | |||||
getCurrencyFromAction: function (action) { | getCurrencyFromAction: function (action) { | ||||
let currencies = this.currencies; | 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, { | return extend(true, { | ||||
name: pick | name: pick | ||||
@@ -50,7 +50,7 @@ module.exports = { | |||||
getRandomSlot: function (exclude) { | getRandomSlot: function (exclude) { | ||||
let chances = []; | let chances = []; | ||||
for (let c in this.chance) { | for (let c in this.chance) { | ||||
if (c == exclude) | |||||
if (c === exclude) | |||||
continue; | continue; | ||||
let rolls = this.chance[c]; | let rolls = this.chance[c]; | ||||
@@ -14,7 +14,7 @@ module.exports = { | |||||
let success = true; | let success = true; | ||||
config.materials.forEach(function (m) { | 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) | if (hasMaterial) | ||||
hasMaterial = hasMaterial.quantity >= m.quantity; | hasMaterial = hasMaterial.quantity >= m.quantity; | ||||
if (!hasMaterial) | if (!hasMaterial) | ||||
@@ -32,11 +32,11 @@ module.exports = { | |||||
}; | }; | ||||
config.materials.forEach(function (m) { | 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); | inventory.destroyItem(invMaterial.id, m.quantity); | ||||
}); | }); | ||||
if (msg.action == 'reroll') { | |||||
if (msg.action === 'reroll') { | |||||
let enchantedStats = item.enchantedStats || {}; | let enchantedStats = item.enchantedStats || {}; | ||||
delete item.enchantedStats; | delete item.enchantedStats; | ||||
delete msg.addStatMsgs; | delete msg.addStatMsgs; | ||||
@@ -63,15 +63,15 @@ module.exports = { | |||||
item.stats[p] += enchantedStats[p]; | item.stats[p] += enchantedStats[p]; | ||||
if (p == 'lvlRequire') { | |||||
if (p === 'lvlRequire') { | |||||
item.level -= enchantedStats[p]; | item.level -= enchantedStats[p]; | ||||
if (item.level < 1) | if (item.level < 1) | ||||
item.level = 1; | item.level = 1; | ||||
} | } | ||||
} | } | ||||
item.enchantedStats = enchantedStats; | item.enchantedStats = enchantedStats; | ||||
} else if (msg.action == 'relevel') { | |||||
if (item.slot == 'tool') | |||||
} else if (msg.action === 'relevel') { | |||||
if (item.slot === 'tool') | |||||
return; | return; | ||||
let offset = 1 + ~~(Math.random() * 2); | let offset = 1 + ~~(Math.random() * 2); | ||||
@@ -83,7 +83,7 @@ module.exports = { | |||||
item.originalLevel = Math.min(20, item.originalLevel + offset); | item.originalLevel = Math.min(20, item.originalLevel + offset); | ||||
item.level = Math.min(20, item.level + offset); | item.level = Math.min(20, item.level + offset); | ||||
} | } | ||||
} else if (msg.action == 'reslot') { | |||||
} else if (msg.action === 'reslot') { | |||||
if (item.effects) | if (item.effects) | ||||
return; | return; | ||||
@@ -111,7 +111,7 @@ module.exports = { | |||||
newItem.stats[p] += enchantedStats[p]; | newItem.stats[p] += enchantedStats[p]; | ||||
if (p == 'lvlRequire') { | |||||
if (p === 'lvlRequire') { | |||||
newItem.level -= enchantedStats[p]; | newItem.level -= enchantedStats[p]; | ||||
if (newItem.level < 1) | if (newItem.level < 1) | ||||
newItem.level = 1; | newItem.level = 1; | ||||
@@ -120,7 +120,7 @@ module.exports = { | |||||
newItem.enchantedStats = enchantedStats; | newItem.enchantedStats = enchantedStats; | ||||
extend(true, item, newItem); | extend(true, item, newItem); | ||||
} else if (msg.action == 'reforge') { | |||||
} else if (msg.action === 'reforge') { | |||||
if (!item.spell) | if (!item.spell) | ||||
return; | return; | ||||
@@ -132,7 +132,7 @@ module.exports = { | |||||
spellName: spellName | spellName: spellName | ||||
}); | }); | ||||
item.spell = extend(true, oldSpell, item.spell); | item.spell = extend(true, oldSpell, item.spell); | ||||
} else if (msg.action == 'scour') { | |||||
} else if (msg.action === 'scour') { | |||||
if (!item.power) | if (!item.power) | ||||
return; | return; | ||||
@@ -148,7 +148,7 @@ module.exports = { | |||||
if (item.stats[p] <= 0) | if (item.stats[p] <= 0) | ||||
delete item.stats[p]; | delete item.stats[p]; | ||||
if (p == 'lvlRequire') { | |||||
if (p === 'lvlRequire') { | |||||
item.level += value; | item.level += value; | ||||
delete item.originalLevel; | delete item.originalLevel; | ||||
} | } | ||||
@@ -182,20 +182,21 @@ module.exports = { | |||||
getEnchantMaterials: function (item, action) { | getEnchantMaterials: function (item, action) { | ||||
let result = null; | let result = null; | ||||
if (action == 'reroll') | |||||
if (action === 'reroll') | |||||
result = [configCurrencies.getCurrencyFromAction('reroll')]; | result = [configCurrencies.getCurrencyFromAction('reroll')]; | ||||
else if (action == 'relevel') | |||||
else if (action === 'relevel') | |||||
result = [configCurrencies.getCurrencyFromAction('relevel')]; | result = [configCurrencies.getCurrencyFromAction('relevel')]; | ||||
else if (action == 'reslot') | |||||
else if (action === 'reslot') | |||||
result = [configCurrencies.getCurrencyFromAction('reslot')]; | result = [configCurrencies.getCurrencyFromAction('reslot')]; | ||||
else if (action == 'reforge') | |||||
else if (action === 'reforge') | |||||
result = [configCurrencies.getCurrencyFromAction('reforge')]; | result = [configCurrencies.getCurrencyFromAction('reforge')]; | ||||
else if (action == 'scour') | |||||
else if (action === 'scour') | |||||
result = [configCurrencies.getCurrencyFromAction('scour')]; | result = [configCurrencies.getCurrencyFromAction('scour')]; | ||||
else { | else { | ||||
let powerLevel = item.power || 0; | let powerLevel = item.power || 0; | ||||
let mult = null; | |||||
if (powerLevel < 3) | if (powerLevel < 3) | ||||
let mult = [5, 10, 20][powerLevel]; | |||||
mult = [5, 10, 20][powerLevel]; | |||||
else | else | ||||
return; | return; | ||||
@@ -57,7 +57,7 @@ module.exports = { | |||||
item.noSalvage = blueprint.noSalvage; | item.noSalvage = blueprint.noSalvage; | ||||
item.noDestroy = blueprint.noDestroy; | item.noDestroy = blueprint.noDestroy; | ||||
materialGenerators.forEach(g => g.generate(item, blueprint)); | materialGenerators.forEach(g => g.generate(item, blueprint)); | ||||
} else if (blueprint.type == 'mtx') { | |||||
} else if (blueprint.type === 'mtx') { | |||||
item = extend(true, {}, blueprint); | item = extend(true, {}, blueprint); | ||||
delete item.chance; | delete item.chance; | ||||
} else { | } else { | ||||
@@ -81,7 +81,7 @@ module.exports = { | |||||
removeStat: function (item, stat) { | removeStat: function (item, stat) { | ||||
if (!stat) { | if (!stat) { | ||||
stat = Object.keys(item.stats) | stat = Object.keys(item.stats) | ||||
.filter(s => (s != 'armor')); | |||||
.filter(s => (s !== 'armor')); | |||||
stat = stat[~~(Math.random() * stat.length)]; | stat = stat[~~(Math.random() * stat.length)]; | ||||
} | } | ||||
@@ -7,7 +7,7 @@ module.exports = { | |||||
let rolls = e.rolls; | let rolls = e.rolls; | ||||
let newRolls = {}; | let newRolls = {}; | ||||
for (let p in rolls) { | for (let p in rolls) { | ||||
let isInt = (p.indexOf('i_') == 0); | |||||
let isInt = (p.indexOf('i_') === 0); | |||||
let fieldName = p.replace('i_', ''); | let fieldName = p.replace('i_', ''); | ||||
let range = rolls[p]; | let range = rolls[p]; | ||||
@@ -33,7 +33,7 @@ module.exports = { | |||||
if (item.stats.armor) | if (item.stats.armor) | ||||
list = list.concat(prefixes.armor); | list = list.concat(prefixes.armor); | ||||
else if (item.slot == 'twoHanded') | |||||
else if (item.slot === 'twoHanded') | |||||
list = list.concat(prefixes.weapons); | list = list.concat(prefixes.weapons); | ||||
let pick = list[~~(Math.random() * list.length)]; | let pick = list[~~(Math.random() * list.length)]; | ||||
@@ -48,14 +48,14 @@ module.exports = { | |||||
gSuffix: function (item, blueprint) { | gSuffix: function (item, blueprint) { | ||||
let list = null; | let list = null; | ||||
if (item.slot == 'tool') | |||||
if (item.slot === 'tool') | |||||
list = suffixes.slots.tool; | list = suffixes.slots.tool; | ||||
else { | else { | ||||
list = suffixes.generic.concat(suffixes.slots[item.slot] || []); | list = suffixes.generic.concat(suffixes.slots[item.slot] || []); | ||||
if (item.stats.armor) | if (item.stats.armor) | ||||
list = list.concat(suffixes.armor); | list = list.concat(suffixes.armor); | ||||
else if (item.slot == 'twoHanded') | |||||
else if (item.slot === 'twoHanded') | |||||
list = list.concat(suffixes.weapons); | list = list.concat(suffixes.weapons); | ||||
} | } | ||||
@@ -10,7 +10,7 @@ module.exports = { | |||||
magicFindMult: 7, | magicFindMult: 7, | ||||
generate: function (item, blueprint) { | generate: function (item, blueprint) { | ||||
if (blueprint.quality != null) { | |||||
if (blueprint.quality !== null) { | |||||
item.quality = ~~blueprint.quality; | item.quality = ~~blueprint.quality; | ||||
return; | return; | ||||
} | } | ||||
@@ -29,7 +29,7 @@ module.exports = { | |||||
for (let i = 0; i < mLen; i++) { | for (let i = 0; i < mLen; i++) { | ||||
qualities[i] = Math.max(0, qualities[i] - magicFind[i]); | qualities[i] = Math.max(0, qualities[i] - magicFind[i]); | ||||
if (qualities[i] > 0) { | if (qualities[i] > 0) { | ||||
if (i == 0) { | |||||
if (i === 0) { | |||||
qualities[i] -= (bonusMagicFind * this.magicFindMult); | qualities[i] -= (bonusMagicFind * this.magicFindMult); | ||||
if (qualities[i] < 0) | if (qualities[i] < 0) | ||||
qualities[i] = 0; | qualities[i] = 0; | ||||
@@ -16,14 +16,14 @@ module.exports = { | |||||
} | } | ||||
let spell = spellsConfig.spells[spellName]; | 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) { | if (!item.slot) { | ||||
let sprite = [10, 0]; | let sprite = [10, 0]; | ||||
let statType = spell.statType; | let statType = spell.statType; | ||||
if (statType == 'dex') | |||||
if (statType === 'dex') | |||||
sprite = [10, 1]; | sprite = [10, 1]; | ||||
else if (statType == 'str') | |||||
else if (statType === 'str') | |||||
sprite = [10, 2]; | sprite = [10, 2]; | ||||
else if (statType instanceof Array) { | else if (statType instanceof Array) { | ||||
if ((statType.indexOf('dex') > -1) && (statType.indexOf('int') > -1)) | if ((statType.indexOf('dex') > -1) && (statType.indexOf('int') > -1)) | ||||
@@ -35,7 +35,7 @@ module.exports = { | |||||
item.name = 'Rune of ' + spellAesthetic.name; | item.name = 'Rune of ' + spellAesthetic.name; | ||||
item.ability = true; | item.ability = true; | ||||
item.sprite = sprite; | item.sprite = sprite; | ||||
} else if (spellQuality == 'basic') | |||||
} else if (spellQuality === 'basic') | |||||
item.stats = {}; | item.stats = {}; | ||||
if (blueprint.spellConfig) | if (blueprint.spellConfig) | ||||
@@ -68,14 +68,14 @@ module.exports = { | |||||
let max = Math.min(20, item.level) / 20; | let max = Math.min(20, item.level) / 20; | ||||
let roll = random.expNorm(0, max); | let roll = random.expNorm(0, max); | ||||
if (spellQuality == 'basic') | |||||
if (spellQuality === 'basic') | |||||
roll = 0; | roll = 0; | ||||
else if (spellQuality == 'mid') | |||||
else if (spellQuality === 'mid') | |||||
roll = 0.5; | roll = 0.5; | ||||
item.spell.rolls[r] = roll; | 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); | let val = range[0] + ((range[1] - range[0]) * roll); | ||||
if (int) { | if (int) { | ||||
@@ -7,56 +7,56 @@ module.exports = { | |||||
if (calcPerfection) | if (calcPerfection) | ||||
return (calcPerfection / max); | return (calcPerfection / max); | ||||
else if (perfection == null) | |||||
else if (perfection === null) | |||||
return random.norm(1, max) * (blueprint.statMult.elementDmgPercent || 1); | return random.norm(1, max) * (blueprint.statMult.elementDmgPercent || 1); | ||||
return max * perfection * (blueprint.statMult.elementDmgPercent || 1); | return max * perfection * (blueprint.statMult.elementDmgPercent || 1); | ||||
}, | }, | ||||
addCritMultiplier: function (item, level, blueprint, perfection, calcPerfection) { | addCritMultiplier: function (item, level, blueprint, perfection, calcPerfection) { | ||||
let div = 1 / 11; | let div = 1 / 11; | ||||
if (item.slot == 'twoHanded') | |||||
if (item.slot === 'twoHanded') | |||||
div *= 2; | div *= 2; | ||||
let max = (level * 15) * div; | let max = (level * 15) * div; | ||||
if (calcPerfection) | if (calcPerfection) | ||||
return (calcPerfection / max); | return (calcPerfection / max); | ||||
else if (perfection == null) | |||||
else if (perfection === null) | |||||
return random.norm(1, max) * (blueprint.statMult.addCritMultiplier || 1); | return random.norm(1, max) * (blueprint.statMult.addCritMultiplier || 1); | ||||
return max * perfection * (blueprint.statMult.addCritMultiplier || 1); | return max * perfection * (blueprint.statMult.addCritMultiplier || 1); | ||||
}, | }, | ||||
addCritChance: function (item, level, blueprint, perfection, calcPerfection) { | addCritChance: function (item, level, blueprint, perfection, calcPerfection) { | ||||
let div = 1 / 11; | let div = 1 / 11; | ||||
if (item.slot == 'twoHanded') | |||||
if (item.slot === 'twoHanded') | |||||
div *= 2; | div *= 2; | ||||
let max = (level - 3) * 50 * div; | let max = (level - 3) * 50 * div; | ||||
if (calcPerfection) | if (calcPerfection) | ||||
return (calcPerfection / max); | return (calcPerfection / max); | ||||
else if (perfection == null) | |||||
else if (perfection === null) | |||||
return random.norm(1, max) * (blueprint.statMult.addCritChance || 1); | return random.norm(1, max) * (blueprint.statMult.addCritChance || 1); | ||||
return max * perfection * (blueprint.statMult.addCritChance || 1); | return max * perfection * (blueprint.statMult.addCritChance || 1); | ||||
}, | }, | ||||
vit: function (item, level, blueprint, perfection, calcPerfection) { | vit: function (item, level, blueprint, perfection, calcPerfection) { | ||||
let div = 1 / 11; | let div = 1 / 11; | ||||
if (item.slot == 'twoHanded') | |||||
if (item.slot === 'twoHanded') | |||||
div *= 2; | 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; | 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) | if (calcPerfection) | ||||
return (calcPerfection / max); | return (calcPerfection / max); | ||||
else if (perfection == null) | |||||
else if (perfection === null) | |||||
return random.norm(1, max) * (blueprint.statMult.vit || 1); | return random.norm(1, max) * (blueprint.statMult.vit || 1); | ||||
return max * perfection * (blueprint.statMult.vit || 1); | return max * perfection * (blueprint.statMult.vit || 1); | ||||
}, | }, | ||||
mainStat: function (item, level, blueprint, perfection, calcPerfection) { | mainStat: function (item, level, blueprint, perfection, calcPerfection) { | ||||
let div = 1 / 11; | let div = 1 / 11; | ||||
if (item.slot == 'twoHanded') | |||||
if (item.slot === 'twoHanded') | |||||
div *= 2; | div *= 2; | ||||
let min = (level / 15) * div; | let min = (level / 15) * div; | ||||
@@ -64,7 +64,7 @@ module.exports = { | |||||
if (calcPerfection) | if (calcPerfection) | ||||
return ((calcPerfection - min) / (max - min)); | return ((calcPerfection - min) / (max - min)); | ||||
else if (perfection == null) | |||||
else if (perfection === null) | |||||
return random.norm(min, max) * (blueprint.statMult.mainStat || 1); | return random.norm(min, max) * (blueprint.statMult.mainStat || 1); | ||||
return (min + ((max - min) * perfection)) * (blueprint.statMult.mainStat || 1); | return (min + ((max - min) * perfection)) * (blueprint.statMult.mainStat || 1); | ||||
}, | }, | ||||
@@ -74,31 +74,31 @@ module.exports = { | |||||
if (calcPerfection) | if (calcPerfection) | ||||
return ((calcPerfection - min) / (max - min)); | return ((calcPerfection - min) / (max - min)); | ||||
else if (perfection == null) | |||||
else if (perfection === null) | |||||
return random.norm(min, max) * blueprint.statMult.armor; | return random.norm(min, max) * blueprint.statMult.armor; | ||||
return (min + ((max - min) * perfection)) * (blueprint.statMult.armor || 1); | return (min + ((max - min) * perfection)) * (blueprint.statMult.armor || 1); | ||||
}, | }, | ||||
elementResist: function (item, level, blueprint, perfection, calcPerfection) { | elementResist: function (item, level, blueprint, perfection, calcPerfection) { | ||||
let div = 1 / 11; | let div = 1 / 11; | ||||
if (item.slot == 'twoHanded') | |||||
if (item.slot === 'twoHanded') | |||||
div *= 2; | div *= 2; | ||||
if (calcPerfection) | if (calcPerfection) | ||||
return (calcPerfection / (100 * div)); | return (calcPerfection / (100 * div)); | ||||
else if (perfection == null) | |||||
else if (perfection === null) | |||||
return random.norm(1, 100) * (blueprint.statMult.elementResist || 1) * div; | return random.norm(1, 100) * (blueprint.statMult.elementResist || 1) * div; | ||||
return ~~((1 + (99 * perfection)) * (blueprint.statMult.elementResist || 1) * div); | return ~~((1 + (99 * perfection)) * (blueprint.statMult.elementResist || 1) * div); | ||||
}, | }, | ||||
regenHp: function (item, level, blueprint, perfection, calcPerfection) { | regenHp: function (item, level, blueprint, perfection, calcPerfection) { | ||||
let div = 1 / 11; | let div = 1 / 11; | ||||
if (item.slot == 'twoHanded') | |||||
if (item.slot === 'twoHanded') | |||||
div *= 2; | 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; | 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) | if (calcPerfection) | ||||
return (calcPerfection / max); | return (calcPerfection / max); | ||||
else if (perfection == null) | |||||
else if (perfection === null) | |||||
return random.norm(1, max) * (blueprint.statMult.regenHp || 1); | return random.norm(1, max) * (blueprint.statMult.regenHp || 1); | ||||
return max * perfection * (blueprint.statMult.regenHp || 1); | return max * perfection * (blueprint.statMult.regenHp || 1); | ||||
}, | }, | ||||
@@ -107,7 +107,7 @@ module.exports = { | |||||
if (calcPerfection) | if (calcPerfection) | ||||
return (calcPerfection / max); | return (calcPerfection / max); | ||||
else if (perfection == null) | |||||
else if (perfection === null) | |||||
return random.norm(1, max) * (blueprint.statMult.lvlRequire || 1); | return random.norm(1, max) * (blueprint.statMult.lvlRequire || 1); | ||||
return max * perfection * (blueprint.statMult.lvlRequire || 1); | return max * perfection * (blueprint.statMult.lvlRequire || 1); | ||||
} | } | ||||
@@ -465,7 +465,7 @@ module.exports = { | |||||
}, | }, | ||||
generate: function (item, blueprint, result) { | generate: function (item, blueprint, result) { | ||||
if (item.slot == 'tool') { | |||||
if (item.slot === 'tool') { | |||||
statsFishingRod.generate(item, blueprint, result); | statsFishingRod.generate(item, blueprint, result); | ||||
return; | return; | ||||
} | } | ||||
@@ -509,7 +509,7 @@ module.exports = { | |||||
let addStats = Math.min(statCount, blueprint.stats.length); | let addStats = Math.min(statCount, blueprint.stats.length); | ||||
for (let i = 0; i < addStats; i++) { | for (let i = 0; i < addStats; i++) { | ||||
let choice = useStats[~~(Math.random() * useStats.length)]; | let choice = useStats[~~(Math.random() * useStats.length)]; | ||||
useStats.spliceFirstWhere(s => s == choice); | |||||
useStats.spliceFirstWhere(s => s === choice); | |||||
this.buildStat(item, blueprint, choice, result); | this.buildStat(item, blueprint, choice, result); | ||||
statCount--; | statCount--; | ||||
} | } | ||||
@@ -520,7 +520,7 @@ module.exports = { | |||||
for (let s in item.stats) { | for (let s in item.stats) { | ||||
item.stats[s] = Math.ceil(item.stats[s]); | item.stats[s] = Math.ceil(item.stats[s]); | ||||
if (item.stats[s] == 0) | |||||
if (item.stats[s] === 0) | |||||
delete item.stats[s]; | delete item.stats[s]; | ||||
} | } | ||||
}, | }, | ||||
@@ -584,7 +584,7 @@ module.exports = { | |||||
item.enchantedStats[stat] = value; | item.enchantedStats[stat] = value; | ||||
} | } | ||||
if (stat == 'lvlRequire') { | |||||
if (stat === 'lvlRequire') { | |||||
if (!item.originalLevel) | if (!item.originalLevel) | ||||
item.originalLevel = item.level; | item.originalLevel = item.level; | ||||
@@ -113,7 +113,7 @@ module.exports = { | |||||
temp.forEach(function (t) { | temp.forEach(function (t) { | ||||
let mats = t.materials; | let mats = t.materials; | ||||
mats.forEach(function (m) { | mats.forEach(function (m) { | ||||
let exists = materials.find(mf => (mf.name == m.name)); | |||||
let exists = materials.find(mf => (mf.name === m.name)); | |||||
if (exists) { | if (exists) { | ||||
exists.chance = Math.max(exists.chance, m.chance); | exists.chance = Math.max(exists.chance, m.chance); | ||||
exists.quantity = Math.max(exists.quantity, m.quantity); | exists.quantity = Math.max(exists.quantity, m.quantity); | ||||
@@ -146,7 +146,7 @@ module.exports = { | |||||
if (m.qualityName) { | if (m.qualityName) { | ||||
newItem.quality = item.quality; | newItem.quality = item.quality; | ||||
newItem.name = m.qualityName[item.quality]; | newItem.name = m.qualityName[item.quality]; | ||||
} else if (m.quality != null) | |||||
} else if (m.quality !== null) | |||||
newItem.quality = m.quality; | newItem.quality = m.quality; | ||||
newItem.sprite = materialItems[newItem.name].sprite; | newItem.sprite = materialItems[newItem.name].sprite; | ||||
@@ -25,7 +25,7 @@ module.exports = { | |||||
let match = true; | let match = true; | ||||
for (let i = 0; i < pLen; i++) { | for (let i = 0; i < pLen; i++) { | ||||
if (!rProphecies.some(rp => rp == prophecyFilter[i])) { | |||||
if (!rProphecies.some(rp => rp === prophecyFilter[i])) { | |||||
match = false; | match = false; | ||||
break; | break; | ||||
} | } | ||||
@@ -90,7 +90,7 @@ module.exports = { | |||||
let doSave = false; | let doSave = false; | ||||
this.waiting.forEach(function (w) { | 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); | this.list.push(w); | ||||
doSave = true; | doSave = true; | ||||
} | } | ||||
@@ -106,7 +106,7 @@ module.exports = { | |||||
if (!this.list) | if (!this.list) | ||||
return null; | return null; | ||||
let result = this.list.find(l => (l.name == name)); | |||||
let result = this.list.find(l => (l.name === name)); | |||||
if (result) | if (result) | ||||
return result.level; | return result.level; | ||||
return null; | return null; | ||||
@@ -123,9 +123,9 @@ module.exports = { | |||||
return; | return; | ||||
} | } | ||||
let exists = this.list.find(l => l.name == name); | |||||
let exists = this.list.find(l => l.name === name); | |||||
if (exists) { | if (exists) { | ||||
if (exists.level != level) { | |||||
if (exists.level !== level) { | |||||
exists.level = level; | exists.level = level; | ||||
this.save(); | this.save(); | ||||
@@ -142,12 +142,12 @@ module.exports = { | |||||
}, | }, | ||||
deleteCharacter: function (name) { | deleteCharacter: function (name) { | ||||
this.list.spliceWhere(l => (l.name == name)); | |||||
this.list.spliceWhere(l => (l.name === name)); | |||||
this.save(); | this.save(); | ||||
}, | }, | ||||
killCharacter: function (name) { | killCharacter: function (name) { | ||||
let character = this.list.find(l => (l.name == name)); | |||||
let character = this.list.find(l => (l.name === name)); | |||||
if (!character) | if (!character) | ||||
return; | return; | ||||
@@ -7,7 +7,7 @@ module.exports = { | |||||
for (let i = 0; i < this.queue.length; i++) { | for (let i = 0; i < this.queue.length; i++) { | ||||
let q = this.queue[i]; | let q = this.queue[i]; | ||||
if (q.event != event) | |||||
if (q.event !== event) | |||||
continue; | continue; | ||||
this.queue.splice(i, 1); | this.queue.splice(i, 1); | ||||
@@ -24,14 +24,14 @@ module.exports = { | |||||
let list = this.events[event] || []; | let list = this.events[event] || []; | ||||
let lLen = list.length; | let lLen = list.length; | ||||
for (let i = 0; i < lLen; i++) { | for (let i = 0; i < lLen; i++) { | ||||
if (list[i] == callback) { | |||||
if (list[i] === callback) { | |||||
list.splice(i, 1); | list.splice(i, 1); | ||||
i--; | i--; | ||||
lLen--; | lLen--; | ||||
} | } | ||||
} | } | ||||
if (lLen == 0) | |||||
if (lLen === 0) | |||||
delete this.events[event]; | delete this.events[event]; | ||||
}, | }, | ||||
emit: function (event) { | emit: function (event) { | ||||
@@ -72,7 +72,7 @@ module.exports = { | |||||
for (let i = 0; i < w; i++) { | for (let i = 0; i < w; i++) { | ||||
let inner = []; | let inner = []; | ||||
for (let j = 0; j < h; j++) { | for (let j = 0; j < h; j++) { | ||||
if (def == 'array') | |||||
if (def === 'array') | |||||
inner.push([]); | inner.push([]); | ||||
else | else | ||||
inner.push(def); | inner.push(def); | ||||
@@ -9,7 +9,7 @@ module.exports = { | |||||
}, | }, | ||||
getMail: function (playerName) { | 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) { | if (!player) { | ||||
process.send({ | process.send({ | ||||
method: 'callDifferentThread', | method: 'callDifferentThread', | ||||
@@ -32,12 +32,12 @@ module.exports = { | |||||
}); | }); | ||||
}, | }, | ||||
onGetMail: function (player, result) { | onGetMail: function (player, result) { | ||||
if (result == 'null') | |||||
if (result === 'null') | |||||
result = null; | result = null; | ||||
else if (result) { | else if (result) { | ||||
result = result.split('`').join('\''); | result = result.split('`').join('\''); | ||||
//Hack for weird google datastore error | //Hack for weird google datastore error | ||||
if (result[0] == '<') | |||||
if (result[0] === '<') | |||||
return; | return; | ||||
} | } | ||||
@@ -69,7 +69,7 @@ module.exports = { | |||||
} else | } else | ||||
console.log(player.name + ' has no stash'); | console.log(player.name + ' has no stash'); | ||||
} else { | } else { | ||||
if ((r.msg) && (!sentMessages.some(s => (s == r.msg)))) { | |||||
if ((r.msg) && (!sentMessages.some(s => (s === r.msg)))) { | |||||
player.instance.syncer.queue('onGetMessages', { | player.instance.syncer.queue('onGetMessages', { | ||||
id: player.id, | id: player.id, | ||||
messages: [{ | messages: [{ | ||||
@@ -124,7 +124,7 @@ module.exports = { | |||||
let player = null; | let player = null; | ||||
if (this.instance) | 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({ | io.get({ | ||||
ent: playerName, | ent: playerName, | ||||
@@ -133,7 +133,7 @@ module.exports = { | |||||
}); | }); | ||||
}, | }, | ||||
doSendMail: function (playerName, items, callback, result) { | doSendMail: function (playerName, items, callback, result) { | ||||
if (result == 'null') | |||||
if (result === 'null') | |||||
result = null; | result = null; | ||||
result = JSON.parse(result || '[]'); | result = JSON.parse(result || '[]'); | ||||
@@ -73,7 +73,7 @@ | |||||
if (!onWall) { | if (!onWall) { | ||||
if (distance) { | if (distance) { | ||||
if (currentNode.h == distance) | |||||
if (currentNode.h === distance) | |||||
return pathTo(currentNode); | return pathTo(currentNode); | ||||
} else { | } else { | ||||
// End case -- result has been found, return the traced path. | // End case -- result has been found, return the traced path. | ||||
@@ -277,7 +277,7 @@ | |||||
GridNode.prototype.getCost = function (fromNeighbor) { | GridNode.prototype.getCost = function (fromNeighbor) { | ||||
// Take diagonal weight into consideration. | // 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 * 1.41421; | ||||
return this.weight; | return this.weight; | ||||
@@ -13,7 +13,7 @@ this.mt[this.N - 1], b = 1); | |||||
}; | }; | ||||
Random.prototype.genrand_int32 = function () { | Random.prototype.genrand_int32 = function () { | ||||
let a, c = [0, this.MATRIX_A]; if (this.mti >= this.N) { | 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; | 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; | }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 () { | }; 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; | 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; | for (let g = this.random(); g <= 1.0E-7;)g = this.random(); return -Math.log(g) * c; | ||||
} else { | } else { | ||||
for (;;) { | for (;;) { | ||||
@@ -13,7 +13,7 @@ module.exports = { | |||||
shouldRun: function (c) { | shouldRun: function (c) { | ||||
let cron = c.cron.split(' '); | let cron = c.cron.split(' '); | ||||
if (cron.length != 5) { | |||||
if (cron.length !== 5) { | |||||
console.log('Invalid Cron Format: ' + cron.join(' ')); | console.log('Invalid Cron Format: ' + cron.join(' ')); | ||||
return false; | return false; | ||||
} | } | ||||
@@ -23,7 +23,7 @@ module.exports = { | |||||
let lastRun = c.lastRun; | let lastRun = c.lastRun; | ||||
if (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; | return false; | ||||
} | } | ||||
@@ -32,7 +32,7 @@ module.exports = { | |||||
let run = ['minute', 'hour', 'day', 'month', 'weekday'].every(function (t, i) { | let run = ['minute', 'hour', 'day', 'month', 'weekday'].every(function (t, i) { | ||||
let tCheck = cron[i]; | let tCheck = cron[i]; | ||||
if (tCheck == '*') | |||||
if (tCheck === '*') | |||||
return true; | return true; | ||||
let overflow = timeOverflows[i]; | let overflow = timeOverflows[i]; | ||||
@@ -53,11 +53,11 @@ module.exports = { | |||||
return tCheck.some(function (f) { | return tCheck.some(function (f) { | ||||
f = f.split('-'); | f = f.split('-'); | ||||
if (f.length == 1) { | |||||
if (f.length === 1) { | |||||
f = f[0].split('/'); | 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])); | return ((useTime >= f[0]) && (useTime <= f[1])); | ||||
}); | }); | ||||
@@ -19,7 +19,7 @@ module.exports = { | |||||
}, | }, | ||||
onAfterGetZone: function (zone, config) { | onAfterGetZone: function (zone, config) { | ||||
if (zone != 'fjolarok') | |||||
if (zone !== 'fjolarok') | |||||
return; | return; | ||||
let newRunes = [{ | let newRunes = [{ | ||||
@@ -104,11 +104,11 @@ module.exports = { | |||||
}, | }, | ||||
beforeGetSpellTemplate: function (spell) { | beforeGetSpellTemplate: function (spell) { | ||||
if (spell.type == 'HarvestLife') | |||||
if (spell.type === 'HarvestLife') | |||||
spell.template = require('./spells/spellHarvestLife'); | spell.template = require('./spells/spellHarvestLife'); | ||||
else if (spell.type == 'SummonSkeleton') | |||||
else if (spell.type === 'SummonSkeleton') | |||||
spell.template = require('./spells/spellSummonSkeleton'); | spell.template = require('./spells/spellSummonSkeleton'); | ||||
else if (spell.type == 'BloodBarrier') | |||||
else if (spell.type === 'BloodBarrier') | |||||
spell.template = require('./spells/spellBloodBarrier'); | spell.template = require('./spells/spellBloodBarrier'); | ||||
}, | }, | ||||
@@ -87,7 +87,7 @@ module.exports = { | |||||
}, | }, | ||||
beforeGetSpellTemplate: function (spell) { | beforeGetSpellTemplate: function (spell) { | ||||
if (spell.type == 'ScatterPumpkinPieces') | |||||
if (spell.type === 'ScatterPumpkinPieces') | |||||
spell.template = require('./spells/spellScatterPumpkinPieces.js'); | spell.template = require('./spells/spellScatterPumpkinPieces.js'); | ||||
}, | }, | ||||
@@ -180,10 +180,10 @@ module.exports = { | |||||
}, | }, | ||||
onAfterGetLayerObjects: function (info) { | onAfterGetLayerObjects: function (info) { | ||||
if (info.map != 'fjolarok') | |||||
if (info.map !== 'fjolarok') | |||||
return; | 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) { | if (layer) { | ||||
let offset = this.mapOffset; | let offset = this.mapOffset; | ||||
let mapScale = this.mapFile.tilesets[0].tileheight; | let mapScale = this.mapFile.tilesets[0].tileheight; | ||||
@@ -199,7 +199,7 @@ module.exports = { | |||||
}, | }, | ||||
onBeforeBuildLayerTile: function (info) { | onBeforeBuildLayerTile: function (info) { | ||||
if (info.map != 'fjolarok') | |||||
if (info.map !== 'fjolarok') | |||||
return; | return; | ||||
let offset = this.mapOffset; | let offset = this.mapOffset; | ||||
@@ -211,13 +211,13 @@ module.exports = { | |||||
return; | return; | ||||
let i = ((y - offset.y) * this.mapW) + (x - offset.x); | 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) | if (layer) | ||||
info.cell = layer.data[i]; | info.cell = layer.data[i]; | ||||
}, | }, | ||||
onBeforeGetEventList: function (zone, list) { | onBeforeGetEventList: function (zone, list) { | ||||
if (zone != 'fjolarok') | |||||
if (zone !== 'fjolarok') | |||||
return; | return; | ||||
list.push(this.relativeFolderName + '/maps/fjolarok/events/halloween.js'); | list.push(this.relativeFolderName + '/maps/fjolarok/events/halloween.js'); | ||||
@@ -52,7 +52,7 @@ module.exports = { | |||||
events: { | events: { | ||||
beforeGatherResource: function (gatherResult, gatherer) { | beforeGatherResource: function (gatherResult, gatherer) { | ||||
let itemName = gatherResult.blueprint.itemName; | let itemName = gatherResult.blueprint.itemName; | ||||
if ((!itemName) || (itemName.toLowerCase() != 'candy corn')) | |||||
if ((!itemName) || (itemName.toLowerCase() !== 'candy corn')) | |||||
return; | return; | ||||
gatherer.reputation.getReputation('pumpkinSailor', 40); | gatherer.reputation.getReputation('pumpkinSailor', 40); | ||||
@@ -1,10 +1,10 @@ | |||||
module.exports = { | module.exports = { | ||||
events: { | events: { | ||||
beforeSpawnProjectile: function (item, spell, projectileConfig) { | beforeSpawnProjectile: function (item, spell, projectileConfig) { | ||||
if (spell.name.toLowerCase() != 'ice spear') | |||||
if (spell.name.toLowerCase() !== 'ice spear') | |||||
return; | return; | ||||
let cpnProjectile = projectileConfig.components.find(c => (c.type == 'projectile')); | |||||
let cpnProjectile = projectileConfig.components.find(c => (c.type === 'projectile')); | |||||
cpnProjectile.particles = { | cpnProjectile.particles = { | ||||
color: { | color: { | ||||
start: ['51fc9a', '48edff'], | start: ['51fc9a', '48edff'], | ||||
@@ -9,7 +9,7 @@ let cpnPumpkinChunk = { | |||||
update: function () { | update: function () { | ||||
this.ttl--; | this.ttl--; | ||||
if (this.ttl == 0) | |||||
if (this.ttl === 0) | |||||
this.obj.destroyed = true; | this.obj.destroyed = true; | ||||
}, | }, | ||||
@@ -20,7 +20,7 @@ let cpnPumpkinChunk = { | |||||
this.obj.destroyed = true; | this.obj.destroyed = true; | ||||
if (this.isRotten) { | 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]) | if (drainCounts[o.name]) | ||||
drainCounts[o.name] += 2; | drainCounts[o.name] += 2; | ||||
else | else | ||||
@@ -56,7 +56,7 @@ module.exports = { | |||||
}, | }, | ||||
onBeforeGetEffect: function (result) { | onBeforeGetEffect: function (result) { | ||||
if (result.type.toLowerCase() == 'merry') | |||||
if (result.type.toLowerCase() === 'merry') | |||||
result.url = `${this.relativeFolderName}/effects/effectMerry.js`; | result.url = `${this.relativeFolderName}/effects/effectMerry.js`; | ||||
}, | }, | ||||
@@ -103,7 +103,7 @@ module.exports = { | |||||
let ox = obj.x; | let ox = obj.x; | ||||
let oy = obj.y; | 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 closestDistance = 999; | ||||
let closest = null; | let closest = null; | ||||
let oLen = objects.length; | let oLen = objects.length; | ||||
@@ -208,10 +208,10 @@ module.exports = { | |||||
}, | }, | ||||
onAfterGetLayerObjects: function (info) { | onAfterGetLayerObjects: function (info) { | ||||
if (info.map != 'fjolarok') | |||||
if (info.map !== 'fjolarok') | |||||
return; | 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) { | if (layer) { | ||||
let offset = this.mapOffset; | let offset = this.mapOffset; | ||||
let mapScale = this.mapFile.tilesets[0].tileheight; | let mapScale = this.mapFile.tilesets[0].tileheight; | ||||
@@ -227,7 +227,7 @@ module.exports = { | |||||
}, | }, | ||||
onBeforeBuildLayerTile: function (info) { | onBeforeBuildLayerTile: function (info) { | ||||
if (info.map != 'fjolarok') | |||||
if (info.map !== 'fjolarok') | |||||
return; | return; | ||||
let offset = this.mapOffset; | let offset = this.mapOffset; | ||||
@@ -239,7 +239,7 @@ module.exports = { | |||||
return; | return; | ||||
let i = ((y - offset.y) * this.mapW) + (x - offset.x); | 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) { | if (layer) { | ||||
let cell = layer.data[i]; | let cell = layer.data[i]; | ||||
if (cell) | if (cell) | ||||
@@ -286,7 +286,7 @@ module.exports = { | |||||
}, | }, | ||||
onBeforeGetCardReward: function (msg) { | onBeforeGetCardReward: function (msg) { | ||||
if (msg.reward == 'Rare Festive Spear') { | |||||
if (msg.reward === 'Rare Festive Spear') { | |||||
msg.handler = function (card) { | msg.handler = function (card) { | ||||
return itemGenerator.generate({ | return itemGenerator.generate({ | ||||
name: 'Festive Spear', | name: 'Festive Spear', | ||||
@@ -300,7 +300,7 @@ module.exports = { | |||||
sprite: [0, 0] | sprite: [0, 0] | ||||
}); | }); | ||||
}; | }; | ||||
} else if (msg.reward == 'Scented Beard Oil') { | |||||
} else if (msg.reward === 'Scented Beard Oil') { | |||||
msg.handler = function (card) { | msg.handler = function (card) { | ||||
return { | return { | ||||
name: 'Scented Beard Oil', | name: 'Scented Beard Oil', | ||||
@@ -323,7 +323,7 @@ module.exports = { | |||||
}, | }, | ||||
onBeforeGetEventList: function (zone, list) { | onBeforeGetEventList: function (zone, list) { | ||||
if (zone != 'fjolarok') | |||||
if (zone !== 'fjolarok') | |||||
return; | return; | ||||
list.push(this.relativeFolderName + '/maps/fjolarok/events/xmas.js'); | list.push(this.relativeFolderName + '/maps/fjolarok/events/xmas.js'); | ||||
@@ -88,15 +88,15 @@ module.exports = { | |||||
method: function (obj) { | method: function (obj) { | ||||
let inventory = obj.inventory; | 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)) | if ((!snowflakes) || (snowflakes.quantity < 15)) | ||||
return 'Sorry, please come back when you have at least fifteen.'; | return 'Sorry, please come back when you have at least fifteen.'; | ||||
while (true) { | while (true) { | ||||
snowflakes = inventory.items.find(i => (i.name == 'Snowflake')); | |||||
snowflakes = inventory.items.find(i => (i.name === 'Snowflake')); | |||||
if ((!snowflakes) || (snowflakes.quantity < 15)) | if ((!snowflakes) || (snowflakes.quantity < 15)) | ||||
return; | 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.'; | return 'Sorry, it seems you don\'t have enough space to accept my gifts.'; | ||||
obj.reputation.getReputation('theWinterMan', 100); | obj.reputation.getReputation('theWinterMan', 100); | ||||
@@ -153,7 +153,7 @@ module.exports = { | |||||
}); | }); | ||||
let pick = pool[~~(Math.random() * pool.length)]; | 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)); | inventory.getItem(extend(true, {}, blueprint)); | ||||
@@ -251,12 +251,12 @@ module.exports = { | |||||
beforeGatherResource: function (gatherResult, gatherer) { | beforeGatherResource: function (gatherResult, gatherer) { | ||||
let itemName = gatherResult.blueprint.itemName; | let itemName = gatherResult.blueprint.itemName; | ||||
if ((!itemName) || (itemName.toLowerCase() != 'snowflake')) | |||||
if ((!itemName) || (itemName.toLowerCase() !== 'snowflake')) | |||||
return; | return; | ||||
gatherer.reputation.getReputation('theWinterMan', 40); | gatherer.reputation.getReputation('theWinterMan', 40); | ||||
if ((gatherResult.name != 'Gilded Gift') || (Math.random() >= 0.05)) | |||||
if ((gatherResult.name !== 'Gilded Gift') || (Math.random() >= 0.05)) | |||||
return; | return; | ||||
gatherResult.items.push({ | gatherResult.items.push({ | ||||
@@ -68,18 +68,18 @@ module.exports = { | |||||
if (rqrLevel) { | if (rqrLevel) { | ||||
if ((rqrLevel.push) && ((mobLevel < rqrLevel[0]) || (mobLevel > rqrLevel[1]))) | if ((rqrLevel.push) && ((mobLevel < rqrLevel[0]) || (mobLevel > rqrLevel[1]))) | ||||
return; | return; | ||||
else if ((!rqrLevel.push) && (mobLevel != rqrLevel)) | |||||
else if ((!rqrLevel.push) && (mobLevel !== rqrLevel)) | |||||
return; | return; | ||||
} | } | ||||
let mobName = card.mobName; | let mobName = card.mobName; | ||||
if (mobName) { | if (mobName) { | ||||
if ((mobName.toLowerCase) && (mob.name.toLowerCase() != mobName.toLowerCase())) | |||||
if ((mobName.toLowerCase) && (mob.name.toLowerCase() !== mobName.toLowerCase())) | |||||
return; | 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; | return; | ||||
} | } | ||||
if ((card.zone) && (looter.zoneName != card.zone)) | |||||
if ((card.zone) && (looter.zoneName !== card.zone)) | |||||
return; | return; | ||||
if (Math.random() >= card.chance) | if (Math.random() >= card.chance) | ||||
@@ -88,7 +88,7 @@ module.exports = { | |||||
pool.push(c); | pool.push(c); | ||||
}, this); | }, this); | ||||
if (pool.length == 0) | |||||
if (pool.length === 0) | |||||
return; | return; | ||||
let pickName = pool[~~(Math.random() * pool.length)]; | let pickName = pool[~~(Math.random() * pool.length)]; | ||||
@@ -125,7 +125,7 @@ module.exports = { | |||||
}, | }, | ||||
rewards: { | rewards: { | ||||
'Level 10 Rune': function (obj) { | |||||
'Level 10 Rune': function () { | |||||
return itemGenerator.generate({ | return itemGenerator.generate({ | ||||
level: 10, | level: 10, | ||||
spell: true | spell: true | ||||
@@ -163,7 +163,6 @@ module.exports = { | |||||
sprite: [0, 0], | sprite: [0, 0], | ||||
spritesheet: '../../../images/legendaryItems.png', | spritesheet: '../../../images/legendaryItems.png', | ||||
type: 'Trident', | type: 'Trident', | ||||
spellName: 'magic missile', | |||||
description: 'Summoned from the ancient depths of the ocean by the Benthic Incantation.', | description: 'Summoned from the ancient depths of the ocean by the Benthic Incantation.', | ||||
stats: ['elementFrostPercent', 'elementFrostPercent', 'elementFrostPercent'], | stats: ['elementFrostPercent', 'elementFrostPercent', 'elementFrostPercent'], | ||||
effects: [{ | effects: [{ | ||||
@@ -209,7 +208,6 @@ module.exports = { | |||||
sprite: [1, 0], | sprite: [1, 0], | ||||
spritesheet: '../../../images/legendaryItems.png', | spritesheet: '../../../images/legendaryItems.png', | ||||
type: 'Curved Dagger', | type: 'Curved Dagger', | ||||
spellName: 'double slash', | |||||
description: 'The blade seems to be made of some kind of bone and steel alloy.', | description: 'The blade seems to be made of some kind of bone and steel alloy.', | ||||
stats: ['dex', 'dex', 'addCritMultiplier', 'addCritMultiplier'], | stats: ['dex', 'dex', 'addCritMultiplier', 'addCritMultiplier'], | ||||
effects: [{ | effects: [{ | ||||
@@ -35,7 +35,7 @@ module.exports = { | |||||
}, | }, | ||||
onBeforeGetItem: function (item, obj) { | onBeforeGetItem: function (item, obj) { | ||||
if ((!obj.player) && (item.type != 'Reward Card')) | |||||
if ((!obj.player) && (item.type !== 'Reward Card')) | |||||
return; | return; | ||||
cards.fixCard(item); | cards.fixCard(item); | ||||
@@ -15,14 +15,14 @@ module.exports = { | |||||
}, blueprint || {}); | }, blueprint || {}); | ||||
} | } | ||||
let cpn = extend(true, {}, template); | |||||
cpn = extend(true, {}, template); | |||||
cpn.obj = this; | cpn.obj = this; | ||||
this.components.push(cpn); | this.components.push(cpn); | ||||
this[cpn.type] = cpn; | this[cpn.type] = cpn; | ||||
} | } | ||||
if ((cpn.init) && (this.instance != null)) | |||||
if ((cpn.init) && (this.instance !== null)) | |||||
cpn.init(blueprint || {}, isTransfer); | cpn.init(blueprint || {}, isTransfer); | ||||
else { | else { | ||||
for (let p in blueprint) | for (let p in blueprint) | ||||
@@ -55,14 +55,14 @@ module.exports = { | |||||
update: function () { | update: function () { | ||||
let usedTurn = false; | 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++) { | for (let i = 0; i < len; i++) { | ||||
let c = components[i]; | |||||
let c = cpns[i]; | |||||
if (c.destroyed) { | if (c.destroyed) { | ||||
this.syncer.setSelfArray(false, 'removeComponents', c.type); | this.syncer.setSelfArray(false, 'removeComponents', c.type); | ||||
this.components.spliceWhere(f => (f == c)); | |||||
cpns.spliceWhere(f => (f === c)); | |||||
delete this[c.type]; | delete this[c.type]; | ||||
len--; | len--; | ||||
i--; | i--; | ||||
@@ -82,9 +82,9 @@ module.exports = { | |||||
if ((self) && (!isSave)) { | if ((self) && (!isSave)) { | ||||
let syncer = this.syncer; | 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) | //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) | .filter((c => !this[c.type]), this) | ||||
.forEach(c => s.components.push(c)); | .forEach(c => s.components.push(c)); | ||||
} | } | ||||
@@ -103,13 +103,13 @@ module.exports = { | |||||
for (let p in o) { | for (let p in o) { | ||||
let value = o[p]; | let value = o[p]; | ||||
if (value == null) | |||||
if (value === null) | |||||
continue; | continue; | ||||
let type = typeof (value); | let type = typeof (value); | ||||
//build component | //build component | ||||
if (type == 'object') { | |||||
if (type === 'object') { | |||||
if (value.type) { | if (value.type) { | ||||
if (!value.simplify) { | if (!value.simplify) { | ||||
if (self) { | if (self) { | ||||
@@ -140,7 +140,7 @@ module.exports = { | |||||
} | } | ||||
} else if (syncTypes.indexOf(p) > -1) | } else if (syncTypes.indexOf(p) > -1) | ||||
result[p] = value; | result[p] = value; | ||||
} else if (type != 'function') | |||||
} else if (type !== 'function') | |||||
result[p] = value; | result[p] = value; | ||||
} | } | ||||
@@ -180,13 +180,13 @@ module.exports = { | |||||
this.actionQueue.push(action); | this.actionQueue.push(action); | ||||
}, | }, | ||||
dequeue: function () { | dequeue: function () { | ||||
if (this.actionQueue.length == 0) | |||||
if (this.actionQueue.length === 0) | |||||
return null; | return null; | ||||
return this.actionQueue.splice(0, 1)[0]; | return this.actionQueue.splice(0, 1)[0]; | ||||
}, | }, | ||||
clearQueue: function () { | clearQueue: function () { | ||||
if (this.serverId != null) { | |||||
if (this.serverId !== null) { | |||||
this.instance.syncer.queue('onClearQueue', { | this.instance.syncer.queue('onClearQueue', { | ||||
id: this.id | id: this.id | ||||
}, [this.serverId]); | }, [this.serverId]); | ||||
@@ -215,8 +215,8 @@ module.exports = { | |||||
if (!q) | if (!q) | ||||
return; | 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 sprintChance = this.stats.values.sprintChance || 0; | ||||
let physics = this.instance.physics; | let physics = this.instance.physics; | ||||
if ((~~(Math.random() * 100) < sprintChance) && (!physics.isTileBlocking(q.data.x, q.data.y))) { | if ((~~(Math.random() * 100) < sprintChance) && (!physics.isTileBlocking(q.data.x, q.data.y))) { | ||||
@@ -227,9 +227,9 @@ module.exports = { | |||||
let success = this.performMove(q); | let success = this.performMove(q); | ||||
if (!success) | if (!success) | ||||
this.clearQueue(); | this.clearQueue(); | ||||
} else if (q.action == 'clearQueue') | |||||
} else if (q.action === 'clearQueue') | |||||
this.clearQueue(); | this.clearQueue(); | ||||
else if (q.action == 'spell') { | |||||
else if (q.action === 'spell') { | |||||
let success = this.spellbook.cast(q); | let success = this.spellbook.cast(q); | ||||
if (!success) | if (!success) | ||||
this.performQueue(); | this.performQueue(); | ||||
@@ -245,7 +245,7 @@ module.exports = { | |||||
data.success = true; | data.success = true; | ||||
this.fireEvent('beforeMove', data); | this.fireEvent('beforeMove', data); | ||||
if (data.success == false) { | |||||
if (data.success === false) { | |||||
action.priority = true; | action.priority = true; | ||||
this.queue(action); | this.queue(action); | ||||
return true; | return true; | ||||
@@ -261,8 +261,8 @@ module.exports = { | |||||
(deltaY > maxDistance) | (deltaY > maxDistance) | ||||
) || | ) || | ||||
( | ( | ||||
(deltaX == 0) && | |||||
(deltaY == 0) | |||||
(deltaX === 0) && | |||||
(deltaY === 0) | |||||
) | ) | ||||
) | ) | ||||
return false; | return false; | ||||
@@ -297,10 +297,10 @@ module.exports = { | |||||
}, | }, | ||||
collisionEnter: function (obj) { | 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++) { | for (let i = 0; i < cLen; i++) { | ||||
let c = components[i]; | |||||
let c = cpns[i]; | |||||
if (c.collisionEnter) { | if (c.collisionEnter) { | ||||
if (c.collisionEnter(obj)) | if (c.collisionEnter(obj)) | ||||
return true; | return true; | ||||
@@ -308,10 +308,10 @@ module.exports = { | |||||
} | } | ||||
}, | }, | ||||
collisionExit: function (obj) { | 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++) { | for (let i = 0; i < cLen; i++) { | ||||
let c = components[i]; | |||||
let c = cpns[i]; | |||||
if (c.collisionExit) | if (c.collisionExit) | ||||
c.collisionExit(obj); | c.collisionExit(obj); | ||||
} | } | ||||
@@ -320,10 +320,10 @@ module.exports = { | |||||
fireEvent: function (event) { | fireEvent: function (event) { | ||||
let args = [].slice.call(arguments, 1); | 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++) { | for (let i = 0; i < cLen; i++) { | ||||
let cpn = components[i]; | |||||
let cpn = cpns[i]; | |||||
let events = cpn.events; | let events = cpn.events; | ||||
if (!events) | if (!events) | ||||
continue; | continue; | ||||
@@ -348,14 +348,14 @@ module.exports = { | |||||
}, | }, | ||||
destroy: function () { | 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++) { | for (let i = 0; i < len; i++) { | ||||
let c = components[i]; | |||||
let c = cpns[i]; | |||||
if (c.destroy) | if (c.destroy) | ||||
c.destroy(); | c.destroy(); | ||||
} | } | ||||
components = null; | |||||
this.components = null; | |||||
} | } | ||||
}; | }; |
@@ -85,7 +85,7 @@ module.exports = { | |||||
let properties = extend(true, {}, l.properties); | let properties = extend(true, {}, l.properties); | ||||
['cpnMob'].forEach(function (c) { | ['cpnMob'].forEach(function (c) { | ||||
let blueprint = properties[c] || null; | let blueprint = properties[c] || null; | ||||
if ((blueprint) && (typeof (blueprint) == 'string')) | |||||
if ((blueprint) && (typeof (blueprint) === 'string')) | |||||
blueprint = JSON.parse(blueprint); | blueprint = JSON.parse(blueprint); | ||||
if (!blueprint) | if (!blueprint) | ||||
@@ -99,7 +99,7 @@ module.exports = { | |||||
}, this); | }, this); | ||||
for (let p in properties) { | for (let p in properties) { | ||||
if (p.indexOf('cpn') == -1) { | |||||
if (p.indexOf('cpn') === -1) { | |||||
obj[p] = properties[p]; | obj[p] = properties[p]; | ||||
continue; | continue; | ||||
} | } | ||||
@@ -107,7 +107,7 @@ module.exports = { | |||||
let type = p.replace('cpn', ''); | let type = p.replace('cpn', ''); | ||||
type = type[0].toLowerCase() + type.substr(1); | type = type[0].toLowerCase() + type.substr(1); | ||||
let blueprint = properties[p] || null; | let blueprint = properties[p] || null; | ||||
if ((blueprint) && (typeof (blueprint) == 'string')) | |||||
if ((blueprint) && (typeof (blueprint) === 'string')) | |||||
blueprint = JSON.parse(blueprint); | blueprint = JSON.parse(blueprint); | ||||
obj.addComponent(type, blueprint); | obj.addComponent(type, blueprint); | ||||
@@ -134,7 +134,7 @@ module.exports = { | |||||
if (obj.aggro) | if (obj.aggro) | ||||
obj.aggro.move(); | obj.aggro.move(); | ||||
if (lLen == 1) | |||||
if (lLen === 1) | |||||
return obj; | return obj; | ||||
} | } | ||||
}, | }, | ||||
@@ -151,9 +151,9 @@ module.exports = { | |||||
let o = objects[i]; | let o = objects[i]; | ||||
let match = false; | let match = false; | ||||
if (useServerId) | if (useServerId) | ||||
match = (o.serverId == obj.id); | |||||
match = (o.serverId === obj.id); | |||||
else | else | ||||
match = (o.id == obj.id); | |||||
match = (o.id === obj.id); | |||||
if (match) { | if (match) { | ||||
o.destroy(); | o.destroy(); | ||||
@@ -171,7 +171,8 @@ module.exports = { | |||||
physics.removeRegion(found); | physics.removeRegion(found); | ||||
} | } | ||||
callback && callback(found); | |||||
if (callback) | |||||
callback(found); | |||||
}, | }, | ||||
addObject: function (o, callback) { | addObject: function (o, callback) { | ||||
@@ -204,7 +205,7 @@ module.exports = { | |||||
return newO; | return newO; | ||||
}, | }, | ||||
sendEvent: function (msg) { | 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) | if (!player) | ||||
return; | return; | ||||
@@ -227,7 +228,7 @@ module.exports = { | |||||
let obj = eventEntry.obj; | let obj = eventEntry.obj; | ||||
if (e != 'serverModule') { | |||||
if (e !== 'serverModule') { | |||||
let to = eventEntry.to; | let to = eventEntry.to; | ||||
let toLen = to.length; | let toLen = to.length; | ||||
for (let i = 0; i < toLen; i++) { | for (let i = 0; i < toLen; i++) { | ||||
@@ -235,7 +236,7 @@ module.exports = { | |||||
let player = players[toId]; | let player = players[toId]; | ||||
if (!player) { | if (!player) { | ||||
let findPlayer = objects.find(o => o.id == toId); | |||||
let findPlayer = objects.find(o => o.id === toId); | |||||
if (!findPlayer) | if (!findPlayer) | ||||
continue; | continue; | ||||
else { | else { | ||||
@@ -260,7 +261,7 @@ module.exports = { | |||||
} | } | ||||
}, | }, | ||||
updateObject: function (msg) { | 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) | if (!player) | ||||
return; | return; | ||||
@@ -12,14 +12,14 @@ module.exports = { | |||||
this.players.push(p); | this.players.push(p); | ||||
}, | }, | ||||
onDisconnect: function (socket) { | 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) | if (!player) | ||||
return; | return; | ||||
let sessionDuration = 0; | let sessionDuration = 0; | ||||
if (player.id != null) { | |||||
if (player.id !== null) { | |||||
if (player.social) | if (player.social) | ||||
player.social.dc(); | player.social.dc(); | ||||
sessionDuration = ~~(((+new Date()) - player.player.sessionStart) / 1000); | 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) { | route: function (socket, msg) { | ||||
let player = null; | 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) | if (!source) | ||||
return; | return; | ||||
if (!msg.data) | if (!msg.data) | ||||
msg.data = {}; | msg.data = {}; | ||||
msg.data.sourceId = source.id; | msg.data.sourceId = source.id; | ||||
} else | } else | ||||
player = this.players.find(p => p.socket.id == socket.id); | |||||
player = this.players.find(p => p.socket.id === socket.id); | |||||
if ( | if ( | ||||
(!player) || | (!player) || | ||||
@@ -68,7 +68,7 @@ module.exports = { | |||||
) || | ) || | ||||
( | ( | ||||
(player.dead) && | (player.dead) && | ||||
(msg.data.method != 'respawn') | |||||
(msg.data.method !== 'respawn') | |||||
) | ) | ||||
) | ) | ||||
return; | return; | ||||
@@ -82,7 +82,7 @@ module.exports = { | |||||
}, | }, | ||||
unzone: function (msg) { | unzone: function (msg) { | ||||
let socket = msg.socket; | 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) | if (!player) | ||||
return; | return; | ||||
@@ -94,9 +94,9 @@ module.exports = { | |||||
let keys = Object.keys(player); | let keys = Object.keys(player); | ||||
keys.forEach(function (k) { | keys.forEach(function (k) { | ||||
let val = player[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; | let type = val.type; | ||||
if ((type != 'player') && (type != 'auth') && (type != 'syncer')) | |||||
if ((type !== 'player') && (type !== 'auth') && (type !== 'syncer')) | |||||
delete player[k]; | delete player[k]; | ||||
} | } | ||||
}); | }); | ||||
@@ -124,15 +124,15 @@ module.exports = { | |||||
for (let i = 0; i < pLen; i++) { | for (let i = 0; i < pLen; i++) { | ||||
let p = players[i]; | let p = players[i]; | ||||
if ((!p) || (p == exclude) || (!p.auth)) | |||||
if ((!p) || (p === exclude) || (!p.auth)) | |||||
continue; | continue; | ||||
if (p.auth.username == exclude.auth.username) | |||||
if (p.auth.username === exclude.auth.username) | |||||
p.socket.emit('dc', {}); | p.socket.emit('dc', {}); | ||||
} | } | ||||
}, | }, | ||||
getCharacterList: function (msg) { | |||||
getCharacterList: function () { | |||||
let result = []; | let result = []; | ||||
let players = this.players; | let players = this.players; | ||||
let pLen = players.length; | let pLen = players.length; | ||||