Browse Source

more work

tags/v0.2.1^2
big bad waffle 5 years ago
parent
commit
544c949a9a
100 changed files with 672 additions and 676 deletions
  1. +22
    -22
      src/server/components/aggro.js
  2. +28
    -28
      src/server/components/auth.js
  3. +3
    -3
      src/server/components/chatter.js
  4. +5
    -5
      src/server/components/chest.js
  5. +3
    -3
      src/server/components/components.js
  6. +7
    -7
      src/server/components/dialogue.js
  7. +7
    -7
      src/server/components/door.js
  8. +8
    -8
      src/server/components/effects.js
  9. +15
    -15
      src/server/components/equipment.js
  10. +2
    -2
      src/server/components/events.js
  11. +6
    -6
      src/server/components/extensions/factionVendor.js
  12. +22
    -22
      src/server/components/extensions/socialCommands.js
  13. +1
    -2
      src/server/components/follower.js
  14. +17
    -17
      src/server/components/gatherer.js
  15. +45
    -45
      src/server/components/inventory.js
  16. +8
    -8
      src/server/components/mob.js
  17. +2
    -2
      src/server/components/notice.js
  18. +10
    -10
      src/server/components/passives.js
  19. +14
    -14
      src/server/components/player.js
  20. +7
    -7
      src/server/components/prophecies.js
  21. +4
    -4
      src/server/components/quests.js
  22. +12
    -12
      src/server/components/reputation.js
  23. +25
    -25
      src/server/components/social.js
  24. +27
    -27
      src/server/components/spellbook.js
  25. +5
    -5
      src/server/components/stash.js
  26. +20
    -21
      src/server/components/stats.js
  27. +9
    -9
      src/server/components/syncer.js
  28. +28
    -28
      src/server/components/trade.js
  29. +3
    -3
      src/server/components/wardrobe.js
  30. +1
    -1
      src/server/config/effects/effectTemplate.js
  31. +4
    -4
      src/server/config/eventPhases/phaseEventChain.js
  32. +3
    -3
      src/server/config/eventPhases/phaseKillMob.js
  33. +2
    -2
      src/server/config/eventPhases/phaseLocateMob.js
  34. +3
    -3
      src/server/config/eventPhases/phaseModifyDialogue.js
  35. +1
    -1
      src/server/config/eventPhases/phaseSpawnMob.js
  36. +2
    -2
      src/server/config/factions/akarei.js
  37. +2
    -2
      src/server/config/factions/anglers.js
  38. +2
    -2
      src/server/config/factions/gaekatla.js
  39. +2
    -2
      src/server/config/itemEffects/alwaysCrit.js
  40. +2
    -2
      src/server/config/itemEffects/damageSelf.js
  41. +2
    -2
      src/server/config/itemEffects/freezeOnHit.js
  42. +2
    -2
      src/server/config/itemEffects/healOnCrit.js
  43. +1
    -1
      src/server/config/loginRewards.js
  44. +2
    -2
      src/server/config/maps/cave/dialogues.js
  45. +3
    -3
      src/server/config/maps/cave/zone.js
  46. +2
    -2
      src/server/config/maps/fjolarok/dialogues.js
  47. +9
    -9
      src/server/config/maps/fjolarok/events/fishingTournament.js
  48. +2
    -2
      src/server/config/prophecies/titangrip.js
  49. +3
    -3
      src/server/config/quests/questBuilder.js
  50. +7
    -7
      src/server/config/quests/templates/questGatherResource.js
  51. +6
    -6
      src/server/config/quests/templates/questKillX.js
  52. +9
    -9
      src/server/config/quests/templates/questLoot.js
  53. +7
    -7
      src/server/config/quests/templates/questLootGen.js
  54. +1
    -1
      src/server/config/quests/templates/questTemplate.js
  55. +4
    -4
      src/server/config/roles.js
  56. +1
    -1
      src/server/config/skins.js
  57. +2
    -2
      src/server/config/spells/spellArcaneBarrier.js
  58. +2
    -2
      src/server/config/spells/spellAura.js
  59. +1
    -1
      src/server/config/spells/spellCallbacks.js
  60. +2
    -2
      src/server/config/spells/spellCharge.js
  61. +2
    -2
      src/server/config/spells/spellFireblast.js
  62. +2
    -2
      src/server/config/spells/spellHealingCircle.js
  63. +1
    -1
      src/server/config/spells/spellSlowBlast.js
  64. +2
    -2
      src/server/config/spells/spellSmokeBomb.js
  65. +1
    -1
      src/server/config/spells/spellSummonConsumableFollower.js
  66. +8
    -8
      src/server/config/spells/spellTemplate.js
  67. +3
    -3
      src/server/config/spells/spellTrailDash.js
  68. +1
    -1
      src/server/config/spells/spellWarnBlast.js
  69. +10
    -10
      src/server/events/events.js
  70. +5
    -5
      src/server/fixes/fixes.js
  71. +0
    -2
      src/server/index.js
  72. +1
    -1
      src/server/items/config/currencies.js
  73. +1
    -1
      src/server/items/config/slots.js
  74. +18
    -17
      src/server/items/enchanter.js
  75. +2
    -2
      src/server/items/generator.js
  76. +1
    -1
      src/server/items/generators/effects.js
  77. +3
    -3
      src/server/items/generators/names.js
  78. +2
    -2
      src/server/items/generators/quality.js
  79. +7
    -7
      src/server/items/generators/spellbook.js
  80. +19
    -19
      src/server/items/generators/stats.js
  81. +2
    -2
      src/server/items/salvager.js
  82. +7
    -7
      src/server/leaderboard/leaderboard.js
  83. +3
    -3
      src/server/misc/events.js
  84. +1
    -1
      src/server/misc/helpers.js
  85. +6
    -6
      src/server/misc/mail.js
  86. +2
    -2
      src/server/misc/pathfinder.js
  87. +2
    -2
      src/server/misc/random.js
  88. +7
    -7
      src/server/misc/scheduler.js
  89. +4
    -4
      src/server/mods/class-necromancer/index.js
  90. +6
    -6
      src/server/mods/event-halloween/index.js
  91. +1
    -1
      src/server/mods/event-halloween/maps/fjolarok/events/halloween.js
  92. +2
    -2
      src/server/mods/event-halloween/mtx/hauntedIceSpear.js
  93. +2
    -2
      src/server/mods/event-halloween/spells/spellScatterPumpkinPieces.js
  94. +9
    -9
      src/server/mods/event-xmas/index.js
  95. +6
    -6
      src/server/mods/event-xmas/maps/fjolarok/events/xmas.js
  96. +6
    -8
      src/server/mods/feature-cards/cards.js
  97. +1
    -1
      src/server/mods/feature-cards/index.js
  98. +33
    -33
      src/server/objects/objBase.js
  99. +12
    -11
      src/server/objects/objects.js
  100. +14
    -14
      src/server/security/connections.js

+ 22
- 22
src/server/components/aggro.js View File

@@ -18,7 +18,7 @@ module.exports = {
this.faction = blueprint.faction;

//TODO: Why don't we move if faction is null?
if (this.faction == null)
if (this.faction === null)
return;

if (this.physics.width > 0)
@@ -92,7 +92,7 @@ module.exports = {
let faction = this.faction;
let inRange = this.physics.getArea(x - range, y - range, x + range, y + range, (c => (((!c.player) || (!obj.player)) && (!obj.dead) && (c.aggro) && (c.aggro.willAutoAttack(obj)))));

if (inRange.length == 0)
if (inRange.length === 0)
return;

let iLen = inRange.length;
@@ -103,7 +103,7 @@ module.exports = {
lLen = list.length;
for (let j = 0; j < lLen; j++) {
//Set the enemy to null so we need we need to continue
if (list[j].obj == enemy)
if (list[j].obj === enemy)
enemy = null;
}
if (!enemy)
@@ -120,32 +120,32 @@ module.exports = {

canAttack: function (target) {
let obj = this.obj;
if (target == obj)
if (target === obj)
return false;
else if ((target.player) && (obj.player)) {
let hasButcher = (obj.prophecies.hasProphecy('butcher')) && (target.prophecies.hasProphecy('butcher'));

if ((!target.social.party) || (!obj.social.party))
return hasButcher;
else if (target.social.partyLeaderId != obj.social.partyLeaderId)
else if (target.social.partyLeaderId !== obj.social.partyLeaderId)
return hasButcher;
return false;
} else if ((target.follower) && (target.follower.master.player) && (obj.player))
return false;
else if (obj.player)
return true;
else if (target.aggro.faction != obj.aggro.faction)
else if (target.aggro.faction !== obj.aggro.faction)
return true;
else if (!!target.player != !!obj.player)
else if (!!target.player !== !!obj.player)
return true;
},

willAutoAttack: function (target) {
if (this.obj == target)
if (this.obj === target)
return false;

let faction = target.aggro.faction;
if ((faction == null) || (!this.faction))
if ((faction === null) || (!this.faction))
return false;

let rep = this.obj.reputation;
@@ -160,17 +160,17 @@ module.exports = {
},

ignore: function (obj) {
this.ignoreList.spliceWhere(o => o == obj);
this.ignoreList.spliceWhere(o => o === obj);
this.ignoreList.push(obj);
},

unIgnore: function (obj) {
this.ignoreList.spliceWhere(o => o == obj);
this.ignoreList.spliceWhere(o => o === obj);
},

tryEngage: function (obj, amount, threatMult) {
//Don't aggro yourself, stupid
if (obj == this.obj)
if (obj === this.obj)
return;

let result = {
@@ -185,7 +185,7 @@ module.exports = {
if (!mob)
mob = obj.mob;
if (mob) {
let notMob = (obj == mob) ? this.obj : obj;
let notMob = (obj === mob) ? this.obj : obj;
if (!mob.canChase(notMob))
return false;
}
@@ -196,7 +196,7 @@ module.exports = {
amount = amount || 0;
threatMult = threatMult || 1;

let exists = list.find(l => l.obj.id == oId);
let exists = list.find(l => l.obj.id === oId);
if (exists) {
exists.damage += amount;
exists.threat += amount * threatMult;
@@ -251,10 +251,10 @@ module.exports = {
for (let i = 0; i < lLen; i++) {
let l = list[i];

if (l.obj != obj)
if (l.obj !== obj)
continue;

if (amount == null) {
if (amount === null) {
list.splice(i, 1);
obj.aggro.unAggro(this.obj);
break;
@@ -268,13 +268,13 @@ module.exports = {
}
}

this.ignoreList.spliceWhere(o => o == obj);
this.ignoreList.spliceWhere(o => o === obj);

//Stuff like cocoons don't have spellbooks
if (this.obj.spellbook)
this.obj.spellbook.unregisterCallback(obj.id, true);

if ((this.list.length == 0) && (this.obj.mob) && (!this.obj.follower))
if ((this.list.length === 0) && (this.obj.mob) && (!this.obj.follower))
this.obj.stats.resetHp();
},

@@ -285,7 +285,7 @@ module.exports = {
},

getHighest: function () {
if (this.list.length == 0)
if (this.list.length === 0)
return null;

let list = this.list;
@@ -302,13 +302,13 @@ module.exports = {
let l = list[i];
let obj = l.obj;

if (this.ignoreList.some(o => o == obj))
if (this.ignoreList.some(o => o === obj))
continue;

if ((highest == null) || (l.threat > highest.threat)) {
if ((highest === null) || (l.threat > highest.threat)) {
highest = l;
closest = Math.max(Math.abs(x - obj.x), Math.abs(y - obj.y));
} else if (l.threat == highest.threat) {
} else if (l.threat === highest.threat) {
let distance = Math.max(Math.abs(x - obj.x), Math.abs(y - obj.y));
if (distance < closest) {
highest = l;


+ 28
- 28
src/server/components/auth.js View File

@@ -23,7 +23,7 @@ module.exports = {
customChannels: [],

play: function (data) {
if (this.username == null)
if (this.username === null)
return;

let character = this.characters[data.data.name];
@@ -47,7 +47,7 @@ module.exports = {
let scheduler = require('../misc/scheduler');
let time = scheduler.getTime();
let lastLogin = accountInfo.lastLogin;
if ((!lastLogin) || (lastLogin.day != time.day)) {
if ((!lastLogin) || (lastLogin.day !== time.day)) {
let daysSkipped = 1;
if (lastLogin) {
if (time.day > lastLogin.day)
@@ -61,7 +61,7 @@ module.exports = {
}
}

if (daysSkipped == 1) {
if (daysSkipped === 1) {
accountInfo.loginStreak++;
if (accountInfo.loginStreak > 21)
accountInfo.loginStreak = 21;
@@ -100,12 +100,12 @@ module.exports = {

doSave: function (extensionObj) {
let simple = this.obj.getSimple(true, true);
simple.components.spliceWhere(c => c.type == 'stash');
simple.components.spliceWhere(c => c.type === 'stash');

let stats = simple.components.find(c => c.type == 'stats');
let stats = simple.components.find(c => c.type === 'stats');
stats.values = extend(true, {}, stats.values);

let social = simple.components.find(c => c.type == 'social');
let social = simple.components.find(c => c.type === 'social');
delete social.party;
delete social.customChannels;

@@ -116,11 +116,11 @@ module.exports = {
if (
(
(s.indexOf('xp') > -1) &&
(s != 'xpIncrease')
(s !== 'xpIncrease')
) ||
(s == 'level') ||
(s == 'hp') ||
(s == 'mana')
(s === 'level') ||
(s === 'hp') ||
(s === 'mana')
)
continue;

@@ -129,7 +129,7 @@ module.exports = {

//Calculate and store the ttl for effects
let time = +new Date();
simple.components.find(e => e.type == 'effects').effects.forEach(function (e) {
simple.components.find(e => e.type === 'effects').effects.forEach(function (e) {
if (e.expire)
return;

@@ -169,7 +169,7 @@ module.exports = {
},

getCharacterList: function (data) {
if (this.username == null)
if (this.username === null)
return;

io.get({
@@ -182,7 +182,7 @@ module.exports = {
let characters = JSON.parse(result || '[]');
this.characterList = characters;

let result = characters
result = characters
.map(c => ({
name: c.name ? c.name : c,
level: leaderboard.getLevel(c.name ? c.name : c)
@@ -193,7 +193,7 @@ module.exports = {

getCharacter: function (data) {
let name = data.data.name;
if (!this.characterList.some(c => ((c.name == name) || (c == name))))
if (!this.characterList.some(c => ((c.name === name) || (c === name))))
return;

io.get({
@@ -237,14 +237,14 @@ module.exports = {
onGetCustomChannels: function (data, character, result) {
this.customChannels = JSON
.parse(result || '[]')
.filter(c => (typeof (c) == 'string'))
.filter(c => (typeof (c) === 'string'))
.map(c => c.split(' ').join(''))
.filter(c => (c.length > 0));

this.customChannels = this.customChannels
.filter((c, i) => (this.customChannels.indexOf(c) == i));
.filter((c, i) => (this.customChannels.indexOf(c) === i));

let social = character.components.find(c => (c.type == 'social'));
let social = character.components.find(c => (c.type === 'social'));
if (social)
social.customChannels = this.customChannels;

@@ -269,7 +269,7 @@ module.exports = {

fixes.fixStash(this.stash);

if (this.skins != null) {
if (this.skins !== null) {
this.verifySkin(character);
data.callback(character);
} else {
@@ -328,7 +328,7 @@ module.exports = {
let list = [...this.skins, ...roles.getSkins(this.username)];
let skinList = skins.getSkinList(list);

if (!skinList.some(s => (s.id == character.skinId))) {
if (!skinList.some(s => (s.id === character.skinId))) {
character.skinId = '1.0';

character.cell = skins.getCell(character.skinId);
@@ -337,13 +337,13 @@ module.exports = {
},

doesOwnSkin: function (skinId) {
return this.skins.some(s => s == skinId);
return this.skins.some(s => s === skinId);
},

login: function (msg) {
let credentials = msg.data;

if ((credentials.username == '') | (credentials.password == '')) {
if ((credentials.username === '') | (credentials.password === '')) {
msg.callback(messages.login.allFields);
return;
}
@@ -366,7 +366,7 @@ module.exports = {
msg.callback(messages.login.incorrect);
else if (compareResult) { //If stored password matches the hashed password entered by the user, log them in directly
this.onLoginVerified(msg);
} else if (msg.data.password == storedPassword) { //If the stored password matches a plaintext password entered by the user; In that case the password gets hashed for the future
} else if (msg.data.password === storedPassword) { //If the stored password matches a plaintext password entered by the user; In that case the password gets hashed for the future
this.onUnhashedLogin(msg);
} else
msg.callback(messages.login.incorrect);
@@ -409,7 +409,7 @@ module.exports = {
register: function (msg) {
let credentials = msg.data;

if ((credentials.username == '') || (credentials.password == '')) {
if ((credentials.username === '') || (credentials.password === '')) {
msg.callback(messages.login.allFields);
return;
}
@@ -490,7 +490,7 @@ module.exports = {
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'
];

if (valid.indexOf(char) == -1) {
if (valid.indexOf(char) === -1) {
msg.callback(messages.login.invalid);
return;
}
@@ -521,7 +521,7 @@ module.exports = {

let simple = this.obj.getSimple(true);
let prophecies = data.prophecies || [];
prophecies = prophecies.filter((p, i) => (prophecies.indexOf(p) == i));
prophecies = prophecies.filter((p, i) => (prophecies.indexOf(p) === i));
simple.components.push({
type: 'prophecies',
list: prophecies
@@ -563,7 +563,7 @@ module.exports = {
if ((!data.name) || (!this.username))
return;

if (!this.characterList.some(c => ((c.name == data.name) || (c == data.name)))) {
if (!this.characterList.some(c => ((c.name === data.name) || (c === data.name)))) {
msg.callback([]);
return;
}
@@ -575,7 +575,7 @@ module.exports = {
});
},
onDeleteCharacter: function (msg, result) {
this.characterList.spliceWhere(c => ((c.name == msg.data.name) || (c == msg.data.name)));
this.characterList.spliceWhere(c => ((c.name === msg.data.name) || (c === msg.data.name)));
let characterList = this.characterList
.map(c => ({
name: c.name ? c.name : c,
@@ -592,7 +592,7 @@ module.exports = {
leaderboard.deleteCharacter(msg.data.name);
},
onRemoveFromList: function (msg, result) {
let result = this.characterList
result = this.characterList
.map(c => ({
name: c.name ? c.name : c,
level: leaderboard.getLevel(c.name ? c.name : c)


+ 3
- 3
src/server/components/chatter.js View File

@@ -13,7 +13,7 @@ module.exports = {
this.cd = ~~(Math.random() * this.cdMax);

for (let p in blueprint) {
if (p == 'chats')
if (p === 'chats')
continue;

this[p] = blueprint[p];
@@ -23,10 +23,10 @@ module.exports = {
update: function () {
if ((this.obj.aggro) && (this.obj.aggro.list.length > 0))
return;
else if (this.chats.length == 0)
else if (this.chats.length === 0)
return;

if ((this.cd == 0) && (Math.random() < this.chance)) {
if ((this.cd === 0) && (Math.random() < this.chance)) {
this.cd = this.cdMax;

let pick = this.chats[~~(Math.random() * this.chats.length)];


+ 5
- 5
src/server/components/chest.js View File

@@ -6,7 +6,7 @@ module.exports = {
ttl: -1,

init: function (blueprint) {
if (blueprint.ownerId != null)
if (blueprint.ownerId !== null)
this.ownerId = blueprint.ownerId;

if (blueprint.ttl)
@@ -24,7 +24,7 @@ module.exports = {
if (this.ttl > 0) {
this.ttl--;

if (this.ttl == 0)
if (this.ttl === 0)
this.obj.destroyed = true;
}
},
@@ -34,11 +34,11 @@ module.exports = {
return;

let ownerId = this.ownerId;
if (ownerId != -1) {
if (ownerId !== -1) {
if (ownerId instanceof Array) {
if (ownerId.indexOf(obj.serverId) == -1)
if (ownerId.indexOf(obj.serverId) === -1)
return;
} else if (ownerId != obj.serverId)
} else if (ownerId !== obj.serverId)
return;
}



+ 3
- 3
src/server/components/components.js View File

@@ -16,9 +16,9 @@ module.exports = {
getComponentFolder: function () {
let files = fileLister.getFolder('./components/');
files = files.filter(w => (
(w.indexOf('components') == -1) &&
(w.indexOf('cpnBase') == -1) &&
(w.indexOf('projectile') == -1)
(w.indexOf('components') === -1) &&
(w.indexOf('cpnBase') === -1) &&
(w.indexOf('projectile') === -1)
));
let fLen = files.length;
for (let i = 0; i < fLen; i++)


+ 7
- 7
src/server/components/dialogue.js View File

@@ -21,15 +21,15 @@ module.exports = {

let target = msg.target;

if ((target == null) && (!msg.targetName))
if ((target === null) && (!msg.targetName))
return false;

if ((target != null) && (target.id == null)) {
target = this.obj.instance.objects.objects.find(o => o.id == target);
if ((target !== null) && (target.id === null)) {
target = this.obj.instance.objects.objects.find(o => o.id === target);
if (!target)
return false;
} else if (msg.targetName != null) {
target = this.obj.instance.objects.objects.find(o => ((o.name) && (o.name.toLowerCase() == msg.targetName.toLowerCase())));
} else if (msg.targetName !== null) {
target = this.obj.instance.objects.objects.find(o => ((o.name) && (o.name.toLowerCase() === msg.targetName.toLowerCase())));
if (!target)
return false;
}
@@ -145,7 +145,7 @@ module.exports = {
}

if (!(result.options instanceof Array)) {
if (result.options[0] == '$')
if (result.options[0] === '$')
result.options = this.states[result.options.replace('$', '')].options;

result.options = Object.keys(result.options);
@@ -196,7 +196,7 @@ module.exports = {

getItem: function (msg, source) {
let inventory = this.obj.inventory;
let exists = inventory.items.find(i => (i.name == msg.item.name));
let exists = inventory.items.find(i => (i.name === msg.item.name));
if (!exists) {
inventory.getItem(msg.item);
return msg.successMsg || false;


+ 7
- 7
src/server/components/door.js View File

@@ -72,7 +72,7 @@ module.exports = {

if (this.closed) {
if (this.locked) {
let key = obj.inventory.items.find(i => ((i.keyId == this.key) || (i.keyId == 'world')));
let key = obj.inventory.items.find(i => ((i.keyId === this.key) || (i.keyId === 'world')));
if (!key) {
canAction = false;
msg = 'You don\'t have the key to unlock this door';
@@ -99,17 +99,17 @@ module.exports = {
},

unlock: function (msg) {
if (msg.sourceId == null)
if (msg.sourceId === null)
return;

let obj = this.obj.instance.objects.objects.find(o => o.serverId == msg.sourceId);
let obj = this.obj.instance.objects.objects.find(o => o.serverId === msg.sourceId);
if ((!obj) || (!obj.player))
return;

let thisObj = this.obj;
if ((Math.abs(thisObj.x - obj.x) > 1) || (Math.abs(thisObj.y - obj.y) > 1))
return;
else if ((thisObj.x == obj.x) && (thisObj.y == obj.y))
else if ((thisObj.x === obj.x) && (thisObj.y === obj.y))
return;

let syncO = thisObj.syncer.o;
@@ -118,11 +118,11 @@ module.exports = {
if (this.autoClose)
this.autoCloseCd = this.autoClose;

let key = obj.inventory.items.find(i => ((i.keyId == this.key) || (i.keyId == 'world')));
let key = obj.inventory.items.find(i => ((i.keyId === this.key) || (i.keyId === 'world')));
if (!key)
return;

if (((key.singleUse) || (this.destroyKey)) && (key.keyId != 'world')) {
if (((key.singleUse) || (this.destroyKey)) && (key.keyId !== 'world')) {
obj.inventory.destroyItem(key.id, 1);

obj.instance.syncer.queue('onGetMessages', {
@@ -161,7 +161,7 @@ module.exports = {

this.autoCloseCd--;

if (this.autoCloseCd == 0) {
if (this.autoCloseCd === 0) {
this.obj.cell = this.closedSprite;
this.obj.syncer.o.cell = this.closedSprite;
this.obj.instance.physics.setCollision(this.obj.x, this.obj.y, true);


+ 8
- 8
src/server/components/effects.js View File

@@ -37,7 +37,7 @@ module.exports = {
type: 'effects',
effects: this.effects
.map(e => e.save())
.filter(e => e != null)
.filter(e => e !== null)
};

return e;
@@ -52,7 +52,7 @@ module.exports = {
if ((effects.length > 0) && (effects[0].obj)) {
effects = effects
.map(e => e.simplify())
.filter(e => e != null);
.filter(e => e !== null);
}
e.effects = effects;

@@ -115,7 +115,7 @@ module.exports = {
},

canApplyEffect: function (type) {
if (this.ccResistances[type] == null)
if (this.ccResistances[type] === null)
return true;

let ccResistances = this.ccResistances;
@@ -130,12 +130,12 @@ module.exports = {
return;

if (!options.new) {
let exists = this.effects.find(e => e.type == options.type);
let exists = this.effects.find(e => e.type === options.type);
if (exists) {
exists.ttl += options.ttl;

for (let p in options) {
if (p == 'ttl')
if (p === 'ttl')
continue;

exists[p] = options[p];
@@ -210,7 +210,7 @@ module.exports = {
let eLen = effects.length;
for (let i = 0; i < eLen; i++) {
let effect = effects[i];
if (effect == checkEffect) {
if (effect === checkEffect) {
if (effect.destroy)
effect.destroy();
this.syncRemove(effect.id, effect.type, noMsg || effect.noMsg);
@@ -224,7 +224,7 @@ module.exports = {
let eLen = effects.length;
for (let i = 0; i < eLen; i++) {
let effect = effects[i];
if (effect.type == effectName) {
if (effect.type === effectName) {
this.syncRemove(effect.id, effect.type, noMsg || effects.noMsg);
effects.splice(i, 1);
return;
@@ -267,7 +267,7 @@ module.exports = {

if (e.ttl > 0) {
e.ttl--;
if (e.ttl == 0)
if (e.ttl === 0)
e.destroyed = true;
}



+ 15
- 15
src/server/components/equipment.js View File

@@ -40,7 +40,7 @@ module.exports = {
}

let currentEqId = this.eq[item.slot];
if (currentEqId == null) {
if (currentEqId === null) {
this.equip(itemId);
return true;
}
@@ -48,7 +48,7 @@ module.exports = {

equip: function (itemId) {
let slot = null;
if (typeof (itemId) == 'object') {
if (typeof (itemId) === 'object') {
slot = itemId.slot;
itemId = itemId.itemId;
}
@@ -63,17 +63,17 @@ module.exports = {

if (!slot)
slot = item.equipSlot || item.slot;
if (slot == 'twoHanded') {
if (slot === 'twoHanded') {
let currentEqId = this.eq.offHand;
if (currentEqId != null)
if (currentEqId !== null)
this.unequip(currentEqId);

slot = 'oneHanded';
} else if (slot == 'offHand') {
} else if (slot === 'offHand') {
let currentEqId = this.eq.oneHanded;
if (currentEqId != null) {
if (currentEqId !== null) {
let currentEq = this.obj.inventory.findItem(currentEqId);
if ((currentEq != null) && (currentEq.slot == 'twoHanded'))
if ((currentEq !== null) && (currentEq.slot === 'twoHanded'))
this.unequip(currentEqId);
}
}
@@ -99,9 +99,9 @@ module.exports = {
delete item.pos;
this.obj.syncer.setArray(true, 'inventory', 'getItems', item);

if (slot == 'finger') {
let f1 = (this.eq['finger-1'] != null);
let f2 = (this.eq['finger-2'] != null);
if (slot === 'finger') {
let f1 = (this.eq['finger-1'] !== null);
let f2 = (this.eq['finger-2'] !== null);

if ((f1) && (f2))
slot = 'finger-1';
@@ -114,9 +114,9 @@ module.exports = {
let spellId = null;
let currentEqId = this.eq[slot];
let currentEq = this.obj.inventory.findItem(currentEqId);
if (currentEq == item)
if (currentEq === item)
return;
if (currentEqId != null) {
if (currentEqId !== null) {
spellId = currentEq.spellId;
this.unequip(currentEqId);
}
@@ -180,12 +180,12 @@ module.exports = {
unequip: function (itemId) {
let item = itemId;
let slot = null;
if (typeof (itemId) == 'object') {
if (typeof (itemId) === 'object') {
slot = itemId.slot;
itemId = itemId.itemId;
}

if (item.id == null)
if (item.id === null)
item = this.obj.inventory.findItem(itemId);

if (!item)
@@ -299,7 +299,7 @@ module.exports = {
if (!factions)
return;

let findFaction = factions.find(f => f.id == factionId);
let findFaction = factions.find(f => f.id === factionId);
if (!findFaction)
return;



+ 2
- 2
src/server/components/events.js View File

@@ -29,7 +29,7 @@ module.exports = {
},

unregisterEvent: function (event) {
this.list.spliceWhere(l => (l == event));
this.list.spliceWhere(l => (l === event));

this.obj.syncer.setArray(true, 'events', 'removeList', {
id: event.id
@@ -54,7 +54,7 @@ module.exports = {
return;

closeEvents.forEach(function (c) {
if (this.list.some(l => (l == c)))
if (this.list.some(l => (l === c)))
return;

this.list.push(c);


+ 6
- 6
src/server/components/extensions/factionVendor.js View File

@@ -32,7 +32,7 @@ module.exports = {

this.items[name] = list;
this.regenList(list);
} else if (list.level != requestLevel)
} else if (list.level !== requestLevel)
this.regenList(list);

let reputation = requestedBy.reputation;
@@ -148,7 +148,7 @@ module.exports = {

let item = extend(true, {}, e);

if (item.type == 'skin') {
if (item.type === 'skin') {
let skinBlueprint = skins.getBlueprint(item.id);
item.skinId = item.id;
item.name = skinBlueprint.name;
@@ -180,9 +180,9 @@ module.exports = {

canBuy: function (itemId, requestedBy, action) {
let item = null;
if (action == 'buy')
if (action === 'buy')
item = this.findItem(itemId, requestedBy.name);
else if (action == 'buyback')
else if (action === 'buyback')
item = this.findBuyback(itemId, requestedBy.name);

let result = true;
@@ -208,7 +208,7 @@ module.exports = {
if (!list)
return null;

return list.items.find(i => i.id == itemId);
return list.items.find(i => i.id === itemId);
},

removeItem: function (itemId, sourceName) {
@@ -216,6 +216,6 @@ module.exports = {
if (!sourceName)
return null;

return list.items.spliceFirstWhere(i => i.id == itemId);
return list.items.spliceFirstWhere(i => i.id === itemId);
}
};

+ 22
- 22
src/server/components/extensions/socialCommands.js View File

@@ -45,7 +45,7 @@ module.exports = {
init: function (blueprint) {
if (this.customChannels) {
this.customChannels = this.customChannels
.filter((c, i) => (this.customChannels.indexOf(c) == i));
.filter((c, i) => (this.customChannels.indexOf(c) === i));
}

this.roleLevel = roles.getRoleLevel(this.obj);
@@ -53,12 +53,12 @@ module.exports = {

onBeforeChat: function (msg) {
let messageText = msg.message;
if (messageText[0] != '/')
if (messageText[0] !== '/')
return;

messageText = messageText.substr(1).split(' ');
let actionName = messageText.splice(0, 1)[0].toLowerCase();
actionName = Object.keys(commandRoles).find(a => (a.toLowerCase() == actionName));
actionName = Object.keys(commandRoles).find(a => (a.toLowerCase() === actionName));

if (!actionName)
return;
@@ -68,7 +68,7 @@ module.exports = {
msg.ignore = true;

let config = {};
if ((messageText.length == 1) && (messageText[0].indexOf('=') == -1))
if ((messageText.length === 1) && (messageText[0].indexOf('=') === -1))
config = messageText[0];
else {
messageText.forEach(function (m) {
@@ -90,17 +90,17 @@ module.exports = {

//actions
join: function (value) {
if (typeof (value) != 'string')
if (typeof (value) !== 'string')
return;

value = value.split(' ').join('');
if (value.lengh == 0)
if (value.lengh === 0)
return;

let obj = this.obj;

let channels = obj.auth.customChannels;
if (!channels.some(c => (c == value)))
if (!channels.some(c => (c === value)))
channels.push(value);
else
return;
@@ -131,13 +131,13 @@ module.exports = {
},

leave: function (value) {
if (typeof (value) != 'string')
if (typeof (value) !== 'string')
return;

let obj = this.obj;

let channels = obj.auth.customChannels;
if (!channels.some(c => (c == value))) {
if (!channels.some(c => (c === value))) {
obj.socket.emit('events', {
onGetMessages: [{
messages: [{
@@ -152,7 +152,7 @@ module.exports = {
}

let channels = obj.auth.customChannels;
channels.spliceWhere(c => (c == value));
channels.spliceWhere(c => (c === value));

let charname = obj.auth.charname;
io.set({
@@ -178,7 +178,7 @@ module.exports = {
},

isInChannel: function (character, channel) {
return character.auth.customChannels.some(c => (c == channel));
return character.auth.customChannels.some(c => (c === channel));
},

unEq: function () {
@@ -189,16 +189,16 @@ module.exports = {
},

mute: function (target, reason) {
if (typeof (target) == 'object') {
if (typeof (target) === 'object') {
let keys = Object.keys(target);
target = keys[0];
reason = keys[1];
}

if (target == this.obj.name)
if (target === this.obj.name)
return;

let o = connections.players.find(o => (o.name == target));
let o = connections.players.find(o => (o.name === target));
if (!o)
return;

@@ -240,16 +240,16 @@ module.exports = {
},

unmute: function (target, reason) {
if (typeof (target) == 'object') {
if (typeof (target) === 'object') {
let keys = Object.keys(target);
target = keys[0];
reason = keys[1];
}

if (target == this.obj.name)
if (target === this.obj.name)
return;

let o = connections.players.find(o => (o.name == target));
let o = connections.players.find(o => (o.name === target));
if (!o)
return;

@@ -300,9 +300,9 @@ module.exports = {
},

getItem: function (config) {
if (config.slot == 'set') {
if (config.slot === 'set') {
configSlots.slots.forEach(function (s) {
if (s == 'tool')
if (s === 'tool')
return;

let newConfig = extend(true, {}, config, {
@@ -351,7 +351,7 @@ module.exports = {
}

factions.forEach(function (f) {
if (f == '')
if (f === '')
return;

let faction = factions.getFaction(f);
@@ -453,14 +453,14 @@ module.exports = {
},

getReputation: function (faction) {
if (typeof (faction) != 'string')
if (typeof (faction) !== 'string')
return;

this.obj.reputation.getReputation(faction, 50000);
},

loseReputation: function (faction) {
if (typeof (faction) != 'string')
if (typeof (faction) !== 'string')
return;

this.obj.reputation.getReputation(faction, -50000);


+ 1
- 2
src/server/components/follower.js View File

@@ -107,7 +107,6 @@ module.exports = {
let maxDistance = this.maxDistance;
let distance = Math.max(Math.abs(obj.x - master.x), Math.abs(obj.y - master.y));

let doMove = (distance >= maxDistance);
//When we're too far, just teleport
if ((!attacker) && (distance >= maxDistance * 2)) {
this.teleport();
@@ -119,7 +118,7 @@ module.exports = {
if (!attacker) {
let lastMasterPos = this.lastMasterPos;

if ((master.x != lastMasterPos.x) || (master.y != lastMasterPos.y)) {
if ((master.x !== lastMasterPos.x) || (master.y !== lastMasterPos.y)) {
doMove = true;
lastMasterPos.x = master.x;
lastMasterPos.y = master.y;


+ 17
- 17
src/server/components/gatherer.js View File

@@ -16,11 +16,11 @@ module.exports = {
},

gather: function () {
if (this.gathering != null)
if (this.gathering !== null)
return;

let nodes = this.nodes;
if (nodes.length == 0)
if (nodes.length === 0)
return;

let firstNode = nodes[0];
@@ -29,7 +29,7 @@ module.exports = {

let ttlMax = firstNode.resourceNode.ttl || this.defaultTtlMax;

if (firstNode.resourceNode.nodeType == 'fish') {
if (firstNode.resourceNode.nodeType === 'fish') {
let rod = this.obj.equipment.eq.tool;
if (!rod) {
process.send({
@@ -73,10 +73,10 @@ module.exports = {
return;
}

let isFish = (gathering.resourceNode.nodeType == 'fish');
let isFish = (gathering.resourceNode.nodeType === 'fish');

if (this.gatheringTtl > 0) {
if ((this.gatheringTtl == this.gatheringTtlMax) && (gathering.width)) {
if ((this.gatheringTtl === this.gatheringTtlMax) && (gathering.width)) {
['x', 'y', 'width', 'height'].forEach(function (p) {
this.obj.syncer.set(false, 'gatherer', p, gathering[p]);
}, this);
@@ -175,7 +175,7 @@ module.exports = {
gatherResult.items.forEach(function (item, i) {
delete item.pos;

if (i == 0) {
if (i === 0) {
if (blueprint.itemName)
item.name = blueprint.itemName;
if (blueprint.itemAmount)
@@ -208,7 +208,7 @@ module.exports = {
});
}

this.nodes.spliceWhere(n => (n == gathering));
this.nodes.spliceWhere(n => (n === gathering));
}

this.gathering = null;
@@ -228,9 +228,9 @@ module.exports = {
}[nodeType]);

let success = true;
if (nodeType == 'fish') {
if (nodeType === 'fish') {
let rod = this.obj.equipment.eq.tool;
if (rod == null) {
if (rod === null) {
success = false;
msg = 'You need a fishing rod to fish';
}
@@ -248,12 +248,12 @@ module.exports = {
}
});

this.nodes.spliceWhere(n => (n == node));
this.nodes.spliceWhere(n => (n === node));
this.nodes.push(node);
},

exit: function (node) {
this.nodes.spliceWhere(n => (n == node));
this.nodes.spliceWhere(n => (n === node));
},

events: {
@@ -272,7 +272,7 @@ module.exports = {
this.obj.syncer.set(true, 'gatherer', 'progress', 100);
this.obj.syncer.set(false, 'gatherer', 'progress', 100);

if (this.gathering.resourceNode.nodeType == 'fish')
if (this.gathering.resourceNode.nodeType === 'fish')
this.obj.syncer.set(true, 'gatherer', 'action', 'Fishing');

this.gathering = null;
@@ -284,12 +284,12 @@ module.exports = {

for (let i = 0; i < nLen; i++) {
let node = nodes[i];
if (item.slot != 'tool')
if (item.slot !== 'tool')
continue;

if (node.resourceNode.nodeType == 'fish') {
if (node.resourceNode.nodeType === 'fish') {
let rod = this.obj.equipment.eq.tool;
if (rod == null) {
if (rod === null) {
process.send({
method: 'events',
data: {
@@ -302,8 +302,8 @@ module.exports = {
}
});

if (this.gathering == node) {
if (this.gathering.resourceNode.nodeType == 'fish')
if (this.gathering === node) {
if (this.gathering.resourceNode.nodeType === 'fish')
this.obj.syncer.set(true, 'gatherer', 'action', 'Fishing');

this.gathering = null;


+ 45
- 45
src/server/components/inventory.js View File

@@ -24,8 +24,8 @@ module.exports = {

//Spells should be sorted so they're EQ'd in the right order
items.sort(function (a, b) {
let aId = (a.spellId != null) ? ~~a.spellId : 9999;
let bId = (b.spellId != null) ? ~~b.spellId : 9999;
let aId = (a.spellId !== null) ? ~~a.spellId : 9999;
let bId = (b.spellId !== null) ? ~~b.spellId : 9999;
return (aId - bId);
});

@@ -48,7 +48,7 @@ module.exports = {
newItem.pos = pos;
}

if ((this.obj.player) && (!isTransfer) && (this.obj.stats.values.level == 1))
if ((this.obj.player) && (!isTransfer) && (this.obj.stats.values.level === 1))
this.getDefaultAbilities();

delete blueprint.items;
@@ -135,7 +135,7 @@ module.exports = {

enchantItem: function (msg) {
let item = this.findItem(msg.itemId);
if ((!item) || (!item.slot) || (item.eq) || (item.noAugment) || ((msg.action == 'scour') && (item.power == 0))) {
if ((!item) || (!item.slot) || (item.eq) || (item.noAugment) || ((msg.action === 'scour') && (item.power === 0))) {
this.resolveCallback(msg);
return;
}
@@ -153,7 +153,7 @@ module.exports = {
},

learnAbility: function (itemId, runeSlot) {
if (itemId.itemId != null) {
if (itemId.itemId !== null) {
let msg = itemId;
itemId = msg.itemId;
runeSlot = msg.slot;
@@ -191,19 +191,19 @@ module.exports = {

let spellbook = this.obj.spellbook;

if ((item.slot == 'twoHanded') || (item.slot == 'oneHanded'))
if ((item.slot === 'twoHanded') || (item.slot === 'oneHanded'))
runeSlot = 0;
else if (runeSlot == null) {
else if (runeSlot === null) {
runeSlot = 4;
for (let i = 1; i <= 4; i++) {
if (!this.items.some(j => (j.runeSlot == i))) {
if (!this.items.some(j => (j.runeSlot === i))) {
runeSlot = i;
break;
}
}
}

let currentEq = this.items.find(i => (i.runeSlot == runeSlot));
let currentEq = this.items.find(i => (i.runeSlot === runeSlot));
if (currentEq) {
spellbook.removeSpellById(runeSlot);
delete currentEq.eq;
@@ -224,7 +224,7 @@ module.exports = {
let item = this.findItem(itemId);
if (!item)
return;
else if (item.type != 'mtx') {
else if (item.type !== 'mtx') {
delete item.active;
return;
}
@@ -290,7 +290,7 @@ module.exports = {

//Find similar items and put them on cooldown too
this.items.forEach(function (i) {
if ((i.name == item.name) && (i.cdMax == item.cdMax))
if ((i.name === item.name) && (i.cdMax === item.cdMax))
i.cd = i.cdMax;
});
}
@@ -298,7 +298,7 @@ module.exports = {
let result = {};
this.obj.instance.eventEmitter.emit('onBeforeUseItem', this.obj, item, result);

if (item.type == 'consumable') {
if (item.type === 'consumable') {
if (item.uses) {
item.uses--;
this.obj.syncer.setArray(true, 'inventory', 'getItems', item);
@@ -309,7 +309,7 @@ module.exports = {
},

unlearnAbility: function (itemId) {
if (itemId.itemId != null)
if (itemId.itemId !== null)
itemId = itemId.itemId;

let item = this.findItem(itemId);
@@ -390,12 +390,12 @@ module.exports = {
if ((item.quantity) && (amount)) {
item.quantity -= amount;
if (item.quantity <= 0) {
this.items.spliceWhere(i => i.id == id);
this.items.spliceWhere(i => i.id === id);
this.obj.syncer.setArray(true, 'inventory', 'destroyItems', id);
} else
this.obj.syncer.setArray(true, 'inventory', 'getItems', item);
} else {
this.items.spliceWhere(i => i.id == id);
this.items.spliceWhere(i => i.id === id);
this.obj.syncer.setArray(true, 'inventory', 'destroyItems', id);
}

@@ -421,7 +421,7 @@ module.exports = {
if (item.eq)
this.obj.equipment.unequip(id);

this.items.spliceWhere(i => i.id == id);
this.items.spliceWhere(i => i.id === id);

this.obj.syncer.setArray(true, 'inventory', 'destroyItems', id);

@@ -471,7 +471,7 @@ module.exports = {
//Helpers

hookItemEvents: function (items) {
let items = items || this.items;
items = items || this.items;
let iLen = items.length;
for (let i = 0; i < iLen; i++) {
let item = items[i];
@@ -496,19 +496,19 @@ module.exports = {
});
}

if ((item.pos == null) && (!item.eq)) {
if ((item.pos === null) && (!item.eq)) {
let pos = i;
for (let j = 0; j < iLen; j++) {
if (!items.some(fj => (fj.pos == j))) {
if (!items.some(fj => (fj.pos === j))) {
pos = j;
break;
}
}
item.pos = pos;
} else if ((!item.eq) && (items.some(ii => ((ii != item) && (ii.pos == item.pos))))) {
} else if ((!item.eq) && (items.some(ii => ((ii !== item) && (ii.pos === item.pos))))) {
let pos = item.pos;
for (let j = 0; j < iLen; j++) {
if (!items.some(fi => ((fi != item) && (fi.pos == j)))) {
if (!items.some(fi => ((fi !== item) && (fi.pos === j)))) {
pos = j;
break;
}
@@ -525,7 +525,7 @@ module.exports = {

let iSize = this.inventorySize;
for (let i = 0; i < iSize; i++) {
if (!this.items.some(j => (j.pos == i))) {
if (!this.items.some(j => (j.pos === i))) {
item.pos = i;
break;
}
@@ -533,10 +533,10 @@ module.exports = {
},

resolveCallback: function (msg, result) {
let callbackId = (msg.callbackId != null) ? msg.callbackId : msg;
let callbackId = (msg.callbackId !== null) ? msg.callbackId : msg;
result = result || [];

if (callbackId == null)
if (callbackId === null)
return;

process.send({
@@ -550,10 +550,10 @@ module.exports = {
},

findItem: function (id) {
if (id == null)
if (id === null)
return null;

return this.items.find(i => i.id == id);
return this.items.find(i => i.id === id);
},

getDefaultAbilities: function () {
@@ -561,8 +561,8 @@ module.exports = {
return (
(i.spell) &&
(i.spell.rolls) &&
(i.spell.rolls.damage != null) &&
((i.slot == 'twoHanded') || (i.slot == 'oneHanded'))
(i.spell.rolls.damage !== null) &&
((i.slot === 'twoHanded') || (i.slot === 'oneHanded'))
);
});

@@ -581,7 +581,7 @@ module.exports = {
let hasSpell = this.items.some(function (i) {
return (
(i.spell) &&
(i.spell.name.toLowerCase() == spellName)
(i.spell.name.toLowerCase() === spellName)
);
});

@@ -599,7 +599,7 @@ module.exports = {
},

createBag: function (x, y, items, ownerId) {
if (ownerId == null)
if (ownerId === null)
ownerId = -1;

let bagCell = 50;
@@ -613,13 +613,13 @@ module.exports = {
topQuality = quality;
}

if (topQuality == 0)
if (topQuality === 0)
bagCell = 50;
else if (topQuality == 1)
else if (topQuality === 1)
bagCell = 51;
else if (topQuality == 2)
else if (topQuality === 2)
bagCell = 128;
else if (topQuality == 3)
else if (topQuality === 3)
bagCell = 52;
else
bagCell = 53;
@@ -644,7 +644,7 @@ module.exports = {
},

hasSpace: function () {
if (this.inventorySize != -1) {
if (this.inventorySize !== -1) {
let nonEqItems = this.items.filter(f => !f.eq).length;
return (nonEqItems < this.inventorySize);
} return true;
@@ -656,7 +656,7 @@ module.exports = {
//We need to know if a mob dropped it for quest purposes
let fromMob = item.fromMob;

if (item.quality == null)
if (item.quality === null)
item.quality = 0;

//Players can't have fromMob items in their inventory but bags can (dropped by a mob)
@@ -668,7 +668,7 @@ module.exports = {

let exists = false;
if (((item.material) || (item.quest) || (item.quantity)) && (!item.noStack) && (!item.uses) && (!noStack)) {
let existItem = this.items.find(i => (i.name == item.name));
let existItem = this.items.find(i => (i.name === item.name));
if (existItem) {
exists = true;
if (!existItem.quantity)
@@ -713,10 +713,10 @@ module.exports = {
if (item.eq)
delete item.pos;

if ((item.pos == null) && (!item.eq)) {
if ((item.pos === null) && (!item.eq)) {
let pos = iLen;
for (let i = 0; i < iLen; i++) {
if (!items.some(fi => (fi.pos == i))) {
if (!items.some(fi => (fi.pos === i))) {
pos = i;
break;
}
@@ -759,10 +759,10 @@ module.exports = {
for (let i = 0; i < sLen; i++) {
let s = stats[i];
let val = item.stats[s];
if (s == 'maxHp') {
if (s === 'maxHp') {
delete item.stats[s];
item.stats.hpMax = val;
} else if (s == 'maxMana') {
} else if (s === 'maxMana') {
delete item.stats[s];
item.stats.manaMax = val;
}
@@ -842,7 +842,7 @@ module.exports = {
return;

//Only drop loot if this player is in the zone
let playerObject = this.obj.instance.objects.find(o => o.serverId == ownerId);
let playerObject = this.obj.instance.objects.find(o => o.serverId === ownerId);
if (!playerObject)
return;

@@ -853,7 +853,7 @@ module.exports = {
if (!(spellStatType instanceof Array))
spellStatType = [spellStatType];
spellStatType.forEach(function (ss) {
if (stats.indexOf(ss) == -1)
if (stats.indexOf(ss) === -1)
stats.push(ss);
});
});
@@ -919,7 +919,7 @@ module.exports = {
drop.magicFind = magicFind;

let item = drop;
if ((!item.quest) && (item.type != 'key'))
if ((!item.quest) && (item.type !== 'key'))
item = generator.generate(drop);

if (!item.slot)
@@ -1015,6 +1015,6 @@ module.exports = {
},

canEquipItem: function (item) {
return (this.equipItemErrors(item).length == 0);
return (this.equipItemErrors(item).length === 0);
}
};

+ 8
- 8
src/server/components/mob.js View File

@@ -50,7 +50,7 @@ module.exports = {

if (!this.goHome) {
//Are we in fight mode?
if ((target) && (target != obj) && ((!obj.follower) || (obj.follower.master != target))) {
if ((target) && (target !== obj) && ((!obj.follower) || (obj.follower.master !== target))) {
this.fight(target);
return;
}
@@ -108,12 +108,12 @@ module.exports = {
this.goHome = false;
},
fight: function (target) {
if (this.target != target) {
if (this.target !== target) {
this.obj.clearQueue();
this.target = target;
}
//If the target is true, it means we can't reach the target and should wait for a new one
if (this.target == true)
if (this.target === true)
return;

let obj = this.obj;
@@ -140,7 +140,7 @@ module.exports = {
target: target
});
//null means we don't have LoS
if (success != null)
if (success !== null)
return;
hasLos = false;
} else
@@ -159,17 +159,17 @@ module.exports = {
let newDistance = max(abs(targetPos.x - tx), abs(targetPos.y - ty));

if ((newDistance >= distance) && (newDistance > furthestRange)) {
if (hasLos == null)
if (hasLos === null)
hasLos = this.physics.hasLos(x, y, tx, ty);
if (hasLos) {
if (doesCollide == null)
if (doesCollide === null)
doesCollide = this.physics.mobsCollide(x, y, obj);
if (!doesCollide) {
obj.aggro.ignore(target);
return;
}
} else {
if (doesCollide == null)
if (doesCollide === null)
doesCollide = this.physics.mobsCollide(x, y, obj);
if (!doesCollide) {
obj.aggro.ignore(target);
@@ -185,7 +185,7 @@ module.exports = {
x: targetPos.x,
y: targetPos.y
});
if (path.length == 0) {
if (path.length === 0) {
obj.aggro.ignore(target);
//TODO: Don't skip a turn
return;


+ 2
- 2
src/server/components/notice.js View File

@@ -29,7 +29,7 @@ module.exports = {
return;

if (action.targetId) {
let target = this.obj.instance.objects.find(o => o.id == action.targetId);
let target = this.obj.instance.objects.find(o => o.id === action.targetId);
if (target) {
let cpn = target[action.cpn];
if ((cpn) && (cpn[action.method]))
@@ -80,7 +80,7 @@ module.exports = {
return;
}

this.contents.spliceWhere(c => (c == obj));
this.contents.spliceWhere(c => (c === obj));

this.callAction(obj, 'exit');



+ 10
- 10
src/server/components/passives.js View File

@@ -8,15 +8,15 @@ module.exports = {

init: function (blueprint) {
this.selected = ((blueprint || {}).selected || []);
this.selected.spliceWhere(s => (passiveTree.nodes.some(n => ((n.id == s) && (n.spiritStart)))));
this.selected.spliceWhere(s => (passiveTree.nodes.some(n => ((n.id === s) && (n.spiritStart)))));

this.selected.push(passiveTree.nodes.find(n => (n.spiritStart == this.obj.class)).id);
this.selected.push(passiveTree.nodes.find(n => (n.spiritStart === this.obj.class)).id);

let points = this.calcPoints();

if (points + this.selected.length < this.selected.length) {
this.selected = [];
this.selected.push(passiveTree.nodes.find(n => (n.spiritStart == this.obj.class)).id);
this.selected.push(passiveTree.nodes.find(n => (n.spiritStart === this.obj.class)).id);
blueprint.selected = this.selected;
points = this.calcPoints();
}
@@ -27,7 +27,7 @@ module.exports = {
let stats = this.obj.stats;

this.selected.forEach(function (id) {
let node = passiveTree.nodes.find(n => (n.id == id));
let node = passiveTree.nodes.find(n => (n.id === id));
if (node) {
for (let p in node.stats)
stats.addStat(p, node.stats[p]);
@@ -48,7 +48,7 @@ module.exports = {
applyPassives: function () {
let stats = this.obj.stats;
this.selected.forEach(function (id) {
let node = passiveTree.nodes.find(n => (n.id == id));
let node = passiveTree.nodes.find(n => (n.id === id));
if (node) {
for (let p in node.stats)
stats.addStat(p, node.stats[p]);
@@ -59,17 +59,17 @@ module.exports = {
tickNode: function (msg) {
if (this.points <= 0)
return;
else if (this.selected.some(s => (s == msg.nodeId)))
else if (this.selected.some(s => (s === msg.nodeId)))
return;

let nodeId = msg.nodeId;
let node = passiveTree.nodes.find(n => (n.id == nodeId));
let node = passiveTree.nodes.find(n => (n.id === nodeId));

if (node.spiritStart)
return;

let linked = passiveTree.links.some(function (l) {
if ((l.from.id != node.id) && (l.to.id != node.id))
if ((l.from.id !== node.id) && (l.to.id !== node.id))
return false;

return (
@@ -99,7 +99,7 @@ module.exports = {
let stats = this.obj.stats;

this.selected.forEach(function (s) {
let node = passiveTree.nodes.find(n => (n.id == s));
let node = passiveTree.nodes.find(n => (n.id === s));
if (node.spiritStart)
return;

@@ -115,7 +115,7 @@ module.exports = {
}, this);

this.selected = [];
this.selected.push(passiveTree.nodes.find(n => (n.spiritStart == this.obj.class)).id);
this.selected.push(passiveTree.nodes.find(n => (n.spiritStart === this.obj.class)).id);

this.obj.spellbook.calcDps();
},


+ 14
- 14
src/server/components/player.js View File

@@ -44,7 +44,7 @@ module.exports = {

roles.onBeforePlayerEnterGame(obj, character);

let blueprintStats = character.components.find(c => c.type == 'stats') || {};
let blueprintStats = character.components.find(c => c.type === 'stats') || {};
extend(true, blueprintStats, classes.stats[obj.class]);
blueprintStats.values.hpMax = (blueprintStats.values.level || 1) * 32.7;
if (!blueprintStats.values.hp)
@@ -65,10 +65,10 @@ module.exports = {
obj.addComponent('spellbook');

obj.addComponent('dialogue');
obj.addComponent('trade', character.components.find(c => c.type == 'trade'));
obj.addComponent('reputation', character.components.find(c => c.type == 'reputation'));
obj.addComponent('trade', character.components.find(c => c.type === 'trade'));
obj.addComponent('reputation', character.components.find(c => c.type === 'reputation'));

let social = character.components.find(c => c.type == 'social');
let social = character.components.find(c => c.type === 'social');
if (social)
delete social.party;
obj.addComponent('social', social);
@@ -82,7 +82,7 @@ module.exports = {
items: character.stash
});

let blueprintEffects = character.components.find(c => c.type == 'effects') || {};
let blueprintEffects = character.components.find(c => c.type === 'effects') || {};
if (blueprintEffects.effects) {
//Calculate ttl of effects
let time = +new Date();
@@ -97,15 +97,15 @@ module.exports = {
}
obj.addComponent('effects', blueprintEffects);

let prophecies = character.components.find(c => c.type == 'prophecies');
let prophecies = character.components.find(c => c.type === 'prophecies');
if (prophecies)
obj.addComponent('prophecies', prophecies);

obj.addComponent('equipment', character.components.find(c => c.type == 'equipment'));
obj.addComponent('inventory', character.components.find(c => c.type == 'inventory'));
obj.addComponent('passives', character.components.find(c => c.type == 'passives'));
obj.addComponent('quests', character.components.find(c => c.type == 'quests'));
obj.addComponent('events', character.components.find(c => c.type == 'events'));
obj.addComponent('equipment', character.components.find(c => c.type === 'equipment'));
obj.addComponent('inventory', character.components.find(c => c.type === 'inventory'));
obj.addComponent('passives', character.components.find(c => c.type === 'passives'));
obj.addComponent('quests', character.components.find(c => c.type === 'quests'));
obj.addComponent('events', character.components.find(c => c.type === 'events'));

obj.xp = stats.values.xp;
obj.level = stats.values.level;
@@ -150,7 +150,7 @@ module.exports = {
this.seen.push(id);
},
unsee: function (id) {
this.seen.spliceWhere(s => s == id);
this.seen.spliceWhere(s => s === id);
},

die: function (source, permadeath) {
@@ -167,10 +167,10 @@ module.exports = {
let level = this.obj.stats.values.level;
let spawns = this.obj.spawn;
let spawnPos = spawns.filter(s => (((s.maxLevel) && (s.maxLevel >= level)) || (!s.maxLevel)));
if ((spawnPos.length == 0) || (!source.name))
if ((spawnPos.length === 0) || (!source.name))
spawnPos = spawns[0];
else if (source.name) {
let sourceSpawnPos = spawnPos.find(s => ((s.source) && (s.source.toLowerCase() == source.name.toLowerCase())));
let sourceSpawnPos = spawnPos.find(s => ((s.source) && (s.source.toLowerCase() === source.name.toLowerCase())));
if (sourceSpawnPos)
spawnPos = sourceSpawnPos;
else


+ 7
- 7
src/server/components/prophecies.js View File

@@ -12,23 +12,23 @@ module.exports = {
console.log(e);
}

if (template == null)
if (template === null)
return;
else if (this.list.some(l => (l.type == p)))
else if (this.list.some(l => (l.type === p)))
return;

let p = extend(true, {}, template);
p.obj = this.obj;
p.init();
let prophecy = extend(true, {}, template);
prophecy.obj = this.obj;
prophecy.init();

this.list.push(p);
this.list.push(prophecy);
}, this);

delete blueprint.list;
},

hasProphecy: function (type) {
return this.list.some(l => (l.type == type));
return this.list.some(l => (l.type === type));
},

transfer: function () {


+ 4
- 4
src/server/components/quests.js View File

@@ -24,23 +24,23 @@ module.exports = {
},

obtain: function (quest, hideMessage) {
quest.active = (this.obj.zoneName == quest.zoneName);
quest.active = (this.obj.zoneName === quest.zoneName);

this.quests.push(quest);
if (!quest.init(hideMessage)) {
this.quests.spliceWhere(q => (q == quest));
this.quests.spliceWhere(q => (q === quest));
return false;
} return true;
},

complete: function (id) {
let quest = this.quests.find(q => q.id == id);
let quest = this.quests.find(q => q.id === id);
if ((!quest) || (!quest.isReady))
return;

quest.complete();

this.quests.spliceWhere(q => q == quest);
this.quests.spliceWhere(q => q === quest);

this.obj.instance.questBuilder.obtain(this.obj);
},


+ 12
- 12
src/server/components/reputation.js View File

@@ -36,7 +36,7 @@ module.exports = {
factionBlueprint = factions.getFaction(factionId);
} catch (e) {}

if (factionBlueprint == null) {
if (factionBlueprint === null) {
console.log('No faction blueprint found');
return;
}
@@ -49,10 +49,10 @@ module.exports = {
},

getTier: function (factionId) {
let faction = this.list.find(l => l.id == factionId);
let faction = this.list.find(l => l.id === factionId);
if (!faction) {
this.discoverFaction(factionId);
faction = this.list.find(l => l.id == factionId);
faction = this.list.find(l => l.id === factionId);
}

return (faction || {
@@ -75,7 +75,7 @@ module.exports = {
calculateTier: function (factionId) {
let blueprint = this.getBlueprint(factionId);

let faction = this.list.find(l => l.id == factionId);
let faction = this.list.find(l => l.id === factionId);
let rep = faction.rep;

let tier = 0;
@@ -87,7 +87,7 @@ module.exports = {

if (t.rep > rep)
break;
else if (i == tLen - 1)
else if (i === tLen - 1)
tier = i;
}

@@ -100,10 +100,10 @@ module.exports = {
},

getReputation: function (factionId, gain) {
let fullSync = (this.factions[factionId] == null);
let fullSync = (this.factions[factionId] === null);
let blueprint = this.getBlueprint(factionId);

let faction = this.list.find(l => l.id == factionId);
let faction = this.list.find(l => l.id === factionId);
if (!faction) {
this.list.push({
id: factionId,
@@ -125,13 +125,13 @@ module.exports = {
this.obj.instance.syncer.queue('onGetMessages', {
id: this.obj.id,
messages: [{
class: (action == 'gained') ? 'color-greenB' : 'color-redA',
class: (action === 'gained') ? 'color-greenB' : 'color-redA',
message: 'you ' + action + ' ' + Math.abs(gain) + ' reputation with ' + blueprint.name,
type: 'rep'
}]
}, [this.obj.serverId]);

if (faction.tier != oldTier) {
if (faction.tier !== oldTier) {
this.sendMessage(blueprint.tiers[faction.tier].name, blueprint.name, (faction.tier > oldTier));
this.obj.equipment.unequipFactionGear(faction.id, faction.tier);
}
@@ -151,10 +151,10 @@ module.exports = {
},

discoverFaction (factionId) {
if (this.list.some(l => l.id == factionId))
if (this.list.some(l => l.id === factionId))
return;

let fullSync = (this.factions[factionId] == null);
let fullSync = (this.factions[factionId] === null);
let blueprint = this.getBlueprint(factionId);

if (!blueprint)
@@ -209,7 +209,7 @@ module.exports = {
},

syncFaction: function (factionId, full) {
let l = this.list.find(l => (l.id == factionId));
let l = this.list.find(l => (l.id === factionId));
let faction = {
id: factionId,
rep: l.rep,


+ 25
- 25
src/server/components/social.js View File

@@ -60,7 +60,7 @@ module.exports = {
let message = msg.data.message.substr(1);

this.party.forEach(function (p) {
let player = cons.players.find(c => c.id == p);
let player = cons.players.find(c => c.id === p);

player.socket.emit('events', {
onGetMessages: [{
@@ -134,7 +134,7 @@ module.exports = {
if (!msg.data.message)
return;

if (msg.data.message.trim() == '')
if (msg.data.message.trim() === '')
return;

this.onBeforeChat(msg.data);
@@ -156,7 +156,7 @@ module.exports = {
history.spliceWhere(h => ((time - h.time) > 5000));

if (history.length > 0) {
if (history[history.length - 1].msg == messageString) {
if (history[history.length - 1].msg === messageString) {
this.sendMessage('You have already sent that message', 'color-redA');
return;
} else if (history.length >= 3) {
@@ -180,10 +180,10 @@ module.exports = {
};
events.emit('onBeforeSendMessage', msgEvent);
messageString = msgEvent.msg;
if (messageString[0] == '@') {
if (messageString[0] === '@') {
let playerName = '';
//Check if there's a space in the name
if (messageString[1] == "'") {
if (messageString[1] === "'") {
playerName = messageString.substring(2, messageString.indexOf("'", 2));
messageString = messageString.replace("@'" + playerName + "' ", '');
} else {
@@ -191,10 +191,10 @@ module.exports = {
messageString = messageString.replace('@' + playerName + ' ', '');
}

if (playerName == this.obj.name)
if (playerName === this.obj.name)
return;

let target = cons.players.find(p => p.name == playerName);
let target = cons.players.find(p => p.name === playerName);
if (!target)
return;

@@ -219,9 +219,9 @@ module.exports = {
}]
}
});
} else if (messageString[0] == '$')
} else if (messageString[0] === '$')
this.sendCustomChannelMessage(msg);
else if (messageString[0] == '%')
else if (messageString[0] === '%')
this.sendPartyMessage(msg);
else {
let prefix = roles.getRoleMessagePrefix(this.obj) || '';
@@ -255,10 +255,10 @@ module.exports = {
let obj = this.obj;
let sourceId = msg.data.sourceId;

if (sourceId == obj.id)
if (sourceId === obj.id)
return;

let source = cons.players.find(c => c.id == sourceId);
let source = cons.players.find(c => c.id === sourceId);
if (!source)
return;

@@ -274,7 +274,7 @@ module.exports = {
//This gets called on the player that initiated the invite
acceptInvite: function (msg) {
let sourceId = msg.data.sourceId;
let source = cons.players.find(c => c.id == sourceId);
let source = cons.players.find(c => c.id === sourceId);
if (!source)
return;

@@ -291,12 +291,12 @@ module.exports = {
this.updatePartyOnThread();

this.party.forEach(function (p) {
let player = cons.players.find(c => c.id == p);
let player = cons.players.find(c => c.id === p);
player.social.party = this.party;
player.social.updatePartyOnThread();

let msg = source.name + ' has joined the party';
if (p == sourceId)
if (p === sourceId)
msg = 'you have joined a party';
player.social.sendMessage(msg, 'color-yellowB');

@@ -309,7 +309,7 @@ module.exports = {
},
declineInvite: function (msg) {
let targetId = msg.data.targetId;
let target = cons.players.find(c => c.id == targetId);
let target = cons.players.find(c => c.id === targetId);
if (!target)
return;

@@ -320,17 +320,17 @@ module.exports = {
leaveParty: function (msg) {
let name = this.obj.name;

this.party.spliceWhere(p => p == this.obj.id);
this.party.spliceWhere(p => p === this.obj.id);

this.party.forEach(function (p) {
let player = cons.players.find(c => c.id == p);
let player = cons.players.find(c => c.id === p);

let messages = [{
class: 'q0',
message: name + ' has left the party'
}];
let party = this.party;
if (this.party.length == 1) {
if (this.party.length === 1) {
messages.push({
class: 'q0',
message: 'your group has been disbanded'
@@ -369,14 +369,14 @@ module.exports = {
});

if ((this.isPartyLeader) && (this.party.length >= 2)) {
let newLeader = cons.players.find(c => c.id == this.party[0]).social;
let newLeader = cons.players.find(c => c.id === this.party[0]).social;
newLeader.isPartyLeader = true;
this.party.forEach(function (p) {
let msg = newLeader.obj.name + ' is now the party leader';
if (p == newLeader.obj.id)
if (p === newLeader.obj.id)
msg = 'you are now the party leader';

cons.players.find(c => c.id == p).socket.emit('events', {
cons.players.find(c => c.id === p).socket.emit('events', {
onGetMessages: [{
messages: [{
class: 'q0',
@@ -398,14 +398,14 @@ module.exports = {
return;
}

let target = cons.players.find(c => c.id == msg.data);
let target = cons.players.find(c => c.id === msg.data);
if (!target)
return;

this.party.spliceWhere(p => p == target.id);
this.party.spliceWhere(p => p === target.id);

this.party.forEach(function (p) {
cons.players.find(c => c.id == p)
cons.players.find(c => c.id === p)
.socket.emit('events', {
onGetParty: [this.party],
onGetMessages: [{
@@ -431,7 +431,7 @@ module.exports = {
target.social.isPartyLeader = false;
target.social.updatePartyOnThread();

if (this.party.length == 1) {
if (this.party.length === 1) {
this.party = null;
this.isPartyLeader = null;
this.updatePartyOnThread();


+ 27
- 27
src/server/components/spellbook.js View File

@@ -100,9 +100,9 @@ module.exports = {
let sheetName = this.obj.sheetName || '../../../images/characters.png';
let animationName = builtSpell.animation;

if (sheetName == 'mobs')
if (sheetName === 'mobs')
animation = animations.mobs;
else if (sheetName == 'bosses')
else if (sheetName === 'bosses')
animation = animations.bosses;
else if (sheetName.indexOf('/') > -1)
animation = animations.mobs[sheetName];
@@ -116,12 +116,12 @@ module.exports = {
builtSpell.animation = null;
}

if ((this.closestRange == -1) || (builtSpell.range < this.closestRange))
if ((this.closestRange === -1) || (builtSpell.range < this.closestRange))
this.closestRange = builtSpell.range;
if ((this.furthestRange == -1) || (builtSpell.range > this.furthestRange))
if ((this.furthestRange === -1) || (builtSpell.range > this.furthestRange))
this.furthestRange = builtSpell.range;

if ((options.id == null) && (spellId == null)) {
if ((options.id === null) && (spellId === null)) {
spellId = 0;
this.spells.forEach(function (s) {
if (s.id >= spellId)
@@ -129,7 +129,7 @@ module.exports = {
});
}

builtSpell.id = (options.id == null) ? spellId : options.id;
builtSpell.id = (options.id === null) ? spellId : options.id;
this.spells.push(builtSpell);
this.spells.sort(function (a, b) {
return (a.id - b.id);
@@ -147,7 +147,7 @@ module.exports = {

addSpellFromRune: function (runeSpell, spellId) {
let type = runeSpell.type;
let playerSpell = playerSpells.spells.find(s => (s.name.toLowerCase() == runeSpell.name.toLowerCase())) || playerSpells.spells.find(s => (s.type == type));
let playerSpell = playerSpells.spells.find(s => (s.name.toLowerCase() === runeSpell.name.toLowerCase())) || playerSpells.spells.find(s => (s.type === type));
let playerSpellConfig = playerSpellsConfig.spells[runeSpell.name.toLowerCase()] || playerSpellsConfig.spells[runeSpell.type];
if (!playerSpellConfig)
return -1;
@@ -167,7 +167,7 @@ module.exports = {
let roll = runeSpell.rolls[r] || 0;
runeSpell.rolls[r] = roll;

let int = r.indexOf('i_') == 0;
let int = r.indexOf('i_') === 0;

let val = range[0] + ((range[1] - range[0]) * roll);
if (int) {
@@ -200,7 +200,7 @@ module.exports = {
},

removeSpellById: function (id) {
let exists = this.spells.spliceFirstWhere(s => (s.id == id));
let exists = this.spells.spliceFirstWhere(s => (s.id === id));

if (exists) {
if ((exists.manaReserve) && (exists.active)) {
@@ -214,7 +214,7 @@ module.exports = {
exists.unlearn && exists.unlearn();

this.obj.syncer.setArray(true, 'spellbook', 'removeSpells', id);
this.auto.spliceWhere(a => a.spell == id);
this.auto.spliceWhere(a => a.spell === id);
}
},

@@ -222,7 +222,7 @@ module.exports = {
if (!action.auto)
return true;

let exists = this.auto.find(a => (a.spell == action.spell));
let exists = this.auto.find(a => (a.spell === action.spell));
if (!exists) {
this.auto.push({
spell: action.spell,
@@ -244,12 +244,12 @@ module.exports = {
return null;
},
cast: function (action, isAuto) {
if (action.spell == null) {
if (action.spell === null) {
this.auto = [];
return true;
}

let spell = this.spells.find(s => (s.id == action.spell));
let spell = this.spells.find(s => (s.id === action.spell));

if (!spell)
return false;
@@ -261,22 +261,22 @@ module.exports = {
x: this.obj.x,
y: this.obj.y
};
} else if (spell.spellType == 'buff')
} else if (spell.spellType === 'buff')
action.target = this.obj;
}

if ((!spell.aura) && (!spell.targetGround)) {
//Did we pass in the target id?
if ((action.target != null) && (action.target.id == null)) {
action.target = this.objects.objects.find(o => o.id == action.target);
if ((action.target !== null) && (action.target.id === null)) {
action.target = this.objects.objects.find(o => o.id === action.target);
if (!action.target)
return false;
}

if ((action.target == this.obj) && (spell.noTargetSelf))
if ((action.target === this.obj) && (spell.noTargetSelf))
action.target = null;

if ((action.target == null) || (!action.target.player)) {
if ((action.target === null) || (!action.target.player)) {
if (spell.autoTargetFollower) {
action.target = this.spells.find(s => (s.minions) && (s.minions.length > 0));
if (action.target)
@@ -286,8 +286,8 @@ module.exports = {
}
}

if (spell.spellType == 'buff') {
if (this.obj.aggro.faction != action.target.aggro.faction)
if (spell.spellType === 'buff') {
if (this.obj.aggro.faction !== action.target.aggro.faction)
return;
} else if ((action.target.aggro) && (!this.obj.aggro.canAttack(action.target))) {
if (this.obj.player)
@@ -326,7 +326,7 @@ module.exports = {
} else
this.obj.stats.addStat('manaReservePercent', -reserve.percentage);
}
} else if (spell.range != null) {
} else if (spell.range !== null) {
//Distance Check
let fromX = this.obj.x;
let fromY = this.obj.y;
@@ -380,7 +380,7 @@ module.exports = {
cd: spell.cdMax
};

let isAttack = (spell.type == 'melee');
let isAttack = (spell.type === 'melee');
if ((Math.random() * 100) < stats[isAttack ? 'attackSpeed' : 'castSpeed'])
cd.cd = 1;

@@ -420,7 +420,7 @@ module.exports = {
if ((spell.range > furthest) && (spell.canCast()))
furthest = spell.range;
}
if (furthest == 0)
if (furthest === 0)
furthest = this.furthestRange;

return furthest;
@@ -432,7 +432,7 @@ module.exports = {
s => cds.push({
cd: s.cd,
cdMax: s.cdMax,
canCast: ((s.manaCost <= this.obj.stats.values.mana) && (s.cd == 0))
canCast: ((s.manaCost <= this.obj.stats.values.mana) && (s.cd === 0))
}), this);

return cds;
@@ -512,9 +512,9 @@ module.exports = {

let match = false;
if (!target)
match = (c.sourceId == sourceId);
match = (c.sourceId === sourceId);
else
match = (c.targetId == sourceId);
match = (c.targetId === sourceId);

if (match) {
if (c.destroyCallback)
@@ -555,7 +555,7 @@ module.exports = {
callback.apply(s, args);
}

if (s.castEvent == event)
if (s.castEvent === event)
s.cast();
}
},


+ 5
- 5
src/server/components/stash.js View File

@@ -20,7 +20,7 @@ module.exports = {
//Material?
let exists = false;
if (((item.material) || (item.quest) || (item.quantity)) && (!item.noStack) && (!item.uses)) {
let existItem = this.items.find(i => i.name == item.name);
let existItem = this.items.find(i => i.name === item.name);
if (existItem) {
exists = true;
if (!existItem.quantity)
@@ -64,11 +64,11 @@ module.exports = {
},

destroyItem: function (id) {
let item = this.items.find(i => i.id == id);
let item = this.items.find(i => i.id === id);
if (!item)
return;

this.items.spliceWhere(i => i == item);
this.items.spliceWhere(i => i === item);

this.obj.syncer.setArray(true, 'stash', 'destroyItems', id);

@@ -79,12 +79,12 @@ module.exports = {
if (!this.active)
return;

let item = this.items.find(i => i.id == id);
let item = this.items.find(i => i.id === id);
if (!item)
return;

this.obj.inventory.getItem(item);
this.items.spliceWhere(i => i == item);
this.items.spliceWhere(i => i === item);

this.obj.syncer.setArray(true, 'stash', 'destroyItems', id);



+ 20
- 21
src/server/components/stats.js View File

@@ -189,10 +189,10 @@ module.exports = {
addStat: function (stat, value) {
let values = this.values;

if (['lvlRequire', 'allAttributes'].indexOf(stat) == -1)
if (['lvlRequire', 'allAttributes'].indexOf(stat) === -1)
values[stat] += value;

let sendOnlyToSelf = (['hp', 'hpMax', 'mana', 'manaMax', 'vit'].indexOf(stat) == -1);
let sendOnlyToSelf = (['hp', 'hpMax', 'mana', 'manaMax', 'vit'].indexOf(stat) === -1);

this.obj.syncer.setObject(sendOnlyToSelf, 'stats', 'values', stat, values[stat]);
if (sendOnlyToSelf)
@@ -206,27 +206,27 @@ module.exports = {
let morphStat = stat.substr(3);
morphStat = morphStat[0].toLowerCase() + morphStat.substr(1);
this.addStat(morphStat, value);
} else if (stat == 'vit')
} else if (stat === 'vit')
this.addStat('hpMax', (value * this.statScales.vitToHp));
else if (stat == 'allAttributes') {
else if (stat === 'allAttributes') {
['int', 'str', 'dex'].forEach(function (s) {
this.addStat(s, value);
}, this);
} else if (stat == 'elementAllResist') {
} else if (stat === 'elementAllResist') {
['arcane', 'frost', 'fire', 'holy', 'poison'].forEach(function (s) {
let element = 'element' + (s[0].toUpperCase() + s.substr(1)) + 'Resist';
this.addStat(element, value);
}, this);
} else if (stat == 'elementPercent') {
} else if (stat === 'elementPercent') {
['arcane', 'frost', 'fire', 'holy', 'poison'].forEach(function (s) {
let element = 'element' + (s[0].toUpperCase() + s.substr(1)) + 'Percent';
this.addStat(element, value);
}, this);
} else if (stat == 'str')
} else if (stat === 'str')
this.addStat('armor', (value * this.statScales.strToArmor));
else if (stat == 'int')
else if (stat === 'int')
this.addStat('manaMax', (value * this.statScales.intToMana));
else if (stat == 'dex')
else if (stat === 'dex')
this.addStat('dodgeAttackChance', (value * this.statScales.dexToDodge));

this.obj.equipment.unequipAttrRqrGear();
@@ -245,7 +245,7 @@ module.exports = {
let obj = this.obj;
let values = this.values;

if (values.level == 20)
if (values.level === 20)
return;

let xpEvent = {
@@ -255,7 +255,7 @@ module.exports = {
};

this.obj.fireEvent('beforeGetXp', xpEvent);
if (xpEvent.amount == 0)
if (xpEvent.amount === 0)
return;

amount = ~~(xpEvent.amount * (1 + (values.xpIncrease / 100)));
@@ -283,7 +283,7 @@ module.exports = {

this.obj.fireEvent('onLevelUp', this.values.level);

if (values.level == 20)
if (values.level === 20)
values.xp = 0;

values.hpMax = values.level * 32.7;
@@ -393,7 +393,6 @@ module.exports = {

obj.syncer.set(true, null, 'dead', true);

let obj = obj;
let syncO = obj.syncer.o;

obj.hidden = true;
@@ -484,9 +483,9 @@ module.exports = {

this.values.hp -= amount;
let recipients = [];
if (this.obj.serverId != null)
if (this.obj.serverId !== null)
recipients.push(this.obj.serverId);
if (source.serverId != null)
if (source.serverId !== null)
recipients.push(source.serverId);
if ((source.follower) && (source.follower.master.serverId))
recipients.push(source.follower.master.serverId);
@@ -574,7 +573,7 @@ module.exports = {
for (let i = 0; i < aLen; i++) {
let a = aggroList[i];

if ((!a.threat) || (a.obj.serverId == null))
if ((!a.threat) || (a.obj.serverId === null))
continue;

this.obj.inventory.dropBag(a.obj.serverId, killSource);
@@ -593,7 +592,7 @@ module.exports = {

getHp: function (heal, source) {
let amount = heal.amount;
if (amount == 0)
if (amount === 0)
return;

let threatMult = heal.threatMult;
@@ -614,9 +613,9 @@ module.exports = {
values.hp = hpMax;

let recipients = [];
if (this.obj.serverId != null)
if (this.obj.serverId !== null)
recipients.push(this.obj.serverId);
if (source.serverId != null)
if (source.serverId !== null)
recipients.push(source.serverId);
if (recipients.length > 0) {
this.syncer.queue('onGetDamage', {
@@ -707,7 +706,7 @@ module.exports = {
if (!lootStats)
this.stats.lootStats[mob.name] = time;
else
return ((lootStats.day != time.day), (lootStats.month != time.month));
return ((lootStats.day !== time.day), (lootStats.month !== time.month));
},

events: {
@@ -722,7 +721,7 @@ module.exports = {
mobKillStreaks[mobName]++;

for (let p in mobKillStreaks) {
if (p == mobName)
if (p === mobName)
continue;

mobKillStreaks[p]--;


+ 9
- 9
src/server/components/syncer.js View File

@@ -21,8 +21,8 @@ module.exports = {
o = this.oSelf;

let keys = Object.keys(o);
if (o.components.length == 0) {
if (keys.length == 1)
if (o.components.length === 0) {
if (keys.length === 1)
return null;
delete o.components;
}
@@ -37,7 +37,7 @@ module.exports = {
o = this.oSelf;

if (cpnType) {
let cpn = o.components.find(c => (c.type == cpnType));
let cpn = o.components.find(c => (c.type === cpnType));

if (!cpn) {
cpn = {
@@ -54,7 +54,7 @@ module.exports = {
let o = this.o;
if (self)
o = this.oSelf;
let cpn = o.components.find(c => (c.type == cpnType));
let cpn = o.components.find(c => (c.type === cpnType));

if (!cpn) {
cpn = {
@@ -75,7 +75,7 @@ module.exports = {
let o = this.o;
if (self)
o = this.oSelf;
let cpn = o.components.find(c => (c.type == cpnType));
let cpn = o.components.find(c => (c.type === cpnType));

if (!cpn) {
cpn = {
@@ -84,10 +84,10 @@ module.exports = {
o.components.push(cpn);
}

if (cpn[property] == null)
if (cpn[property] === null)
cpn[property] = [];

if ((noDuplicate) && (cpn[property].find(f => (f == value))))
if ((noDuplicate) && (cpn[property].find(f => (f === value))))
return;

cpn[property].push(value);
@@ -98,7 +98,7 @@ module.exports = {
if (self)
o = this.oSelf;

if (o[property] == null)
if (o[property] === null)
o[property] = [];

o[property].push(value);
@@ -110,7 +110,7 @@ module.exports = {
o = this.oSelf;

if (cpnType) {
let cpn = o.components.find(c => (c.type == cpnType));
let cpn = o.components.find(c => (c.type === cpnType));

if (!cpn)
return;


+ 28
- 28
src/server/components/trade.js View File

@@ -31,7 +31,7 @@ module.exports = {
id = checkItem.id + 1;
});

if (item.type == 'skin') {
if (item.type === 'skin') {
let skinBlueprint = skins.getBlueprint(item.id);
item.name = skinBlueprint.name;
item.sprite = skinBlueprint.sprite;
@@ -80,13 +80,13 @@ module.exports = {
startBuy: function (msg) {
let target = msg.target;

if ((target == null) && (!msg.targetName))
if ((target === null) && (!msg.targetName))
return false;

if ((target != null) && (target.id == null))
target = this.obj.instance.objects.objects.find(o => o.id == target);
if ((target !== null) && (target.id === null))
target = this.obj.instance.objects.objects.find(o => o.id === target);
else if (msg.targetName)
target = this.obj.instance.objects.objects.find(o => ((o.name) && (o.name.toLowerCase() == msg.targetName.toLowerCase())));
target = this.obj.instance.objects.objects.find(o => ((o.name) && (o.name.toLowerCase() === msg.targetName.toLowerCase())));

this.target = null;

@@ -98,7 +98,7 @@ module.exports = {
let itemList = target.trade.getItems(this.obj);
let markup = target.trade.markup.sell;

if (msg.action == 'buyback') {
if (msg.action === 'buyback') {
itemList = target.trade.buyback[this.obj.name] || [];
markup = target.trade.markup.buy;
}
@@ -106,16 +106,16 @@ module.exports = {
this.obj.syncer.set(true, 'trade', 'buyList', {
markup: markup,
items: itemList,
buyback: (msg.action == 'buyback')
buyback: (msg.action === 'buyback')
});
},

buySell: function (msg) {
if (msg.action == 'buy')
if (msg.action === 'buy')
this.buy(msg);
else if (msg.action == 'sell')
else if (msg.action === 'sell')
this.sell(msg);
else if (msg.action == 'buyback')
else if (msg.action === 'buyback')
this.buyback(msg);
},

@@ -128,7 +128,7 @@ module.exports = {
let targetTrade = target.trade;
let markup = targetTrade.markup.sell;

if (msg.action == 'buyback') {
if (msg.action === 'buyback') {
item = targetTrade.findBuyback(msg.itemId, this.obj.name);
markup = targetTrade.markup.buy;
} else
@@ -141,7 +141,7 @@ module.exports = {

let canAfford = false;
if (item.worth.currency) {
let currencyItem = this.obj.inventory.items.find(i => (i.name == item.worth.currency));
let currencyItem = this.obj.inventory.items.find(i => (i.name === item.worth.currency));
canAfford = ((currencyItem) && (currencyItem.quantity >= item.worth.amount));
} else
canAfford = this.gold >= ~~(item.worth * markup);
@@ -165,7 +165,7 @@ module.exports = {
return;
}

if (item.type == 'skin') {
if (item.type === 'skin') {
let haveSkin = this.obj.auth.doesOwnSkin(item.skinId);

if (haveSkin) {
@@ -183,13 +183,13 @@ module.exports = {
}
}

if (msg.action == 'buyback')
if (msg.action === 'buyback')
targetTrade.removeBuyback(msg.itemId, this.obj.name);
else if ((item.type != 'skin') && (!item.infinite))
else if ((item.type !== 'skin') && (!item.infinite))
targetTrade.removeItem(msg.itemId, this.obj.name);

if (item.worth.currency) {
let currencyItem = this.obj.inventory.items.find(i => (i.name == item.worth.currency));
let currencyItem = this.obj.inventory.items.find(i => (i.name === item.worth.currency));
this.obj.inventory.destroyItem(currencyItem.id, item.worth.amount, true);
} else {
targetTrade.gold += ~~(item.worth * markup);
@@ -197,7 +197,7 @@ module.exports = {
this.obj.syncer.set(true, 'trade', 'gold', this.gold);
}

if (item.type != 'skin') {
if (item.type !== 'skin') {
if (!item.infinite)
this.obj.syncer.setArray(true, 'trade', 'removeItems', item.id);

@@ -276,13 +276,13 @@ module.exports = {
let target = msg.target;
let targetName = (msg.targetName || '').toLowerCase();

if ((target == null) && (!targetName))
if ((target === null) && (!targetName))
return false;

if ((target != null) && (target.id == null))
target = this.obj.instance.objects.objects.find(o => o.id == target);
else if (targetName != null)
target = this.obj.instance.objects.objects.find(o => ((o.name) && (o.name.toLowerCase() == targetName)));
if ((target !== null) && (target.id === null))
target = this.obj.instance.objects.objects.find(o => o.id === target);
else if (targetName !== null)
target = this.obj.instance.objects.objects.find(o => ((o.name) && (o.name.toLowerCase() === targetName)));

this.target = null;

@@ -330,11 +330,11 @@ module.exports = {
},

removeItem: function (itemId) {
return this.items.spliceFirstWhere(i => i.id == itemId);
return this.items.spliceFirstWhere(i => i.id === itemId);
},

removeBuyback: function (itemId, name) {
return (this.buyback[name] || []).spliceFirstWhere(i => i.id == itemId);
return (this.buyback[name] || []).spliceFirstWhere(i => i.id === itemId);
},

getItems: function (requestedBy) {
@@ -372,18 +372,18 @@ module.exports = {
},

findItem: function (itemId, sourceName) {
return this.items.find(i => i.id == itemId);
return this.items.find(i => i.id === itemId);
},

findBuyback: function (itemId, sourceName) {
return (this.buyback[sourceName] || []).find(i => i.id == itemId);
return (this.buyback[sourceName] || []).find(i => i.id === itemId);
},

resolveCallback: function (msg, result) {
let callbackId = (msg.callbackId != null) ? msg.callbackId : msg;
let callbackId = (msg.callbackId !== null) ? msg.callbackId : msg;
result = result || [];

if (callbackId == null)
if (callbackId === null)
return;

process.send({


+ 3
- 3
src/server/components/wardrobe.js View File

@@ -68,10 +68,10 @@ module.exports = {
},

open: function (msg) {
if (msg.sourceId == null)
if (msg.sourceId === null)
return;

let obj = this.obj.instance.objects.objects.find(o => o.serverId == msg.sourceId);
let obj = this.obj.instance.objects.objects.find(o => o.serverId === msg.sourceId);
if ((!obj) || (!obj.player))
return;

@@ -85,7 +85,7 @@ module.exports = {
},

apply: function (msg) {
let obj = this.obj.instance.objects.objects.find(o => o.serverId == msg.sourceId);
let obj = this.obj.instance.objects.objects.find(o => o.serverId === msg.sourceId);
if (!obj)
return;



+ 1
- 1
src/server/config/effects/effectTemplate.js View File

@@ -6,7 +6,7 @@ module.exports = {
let values = {};
for (let p in this) {
let value = this[p];
if ((typeof(value) == 'function') || (p == 'obj') || (p == 'events'))
if ((typeof(value) === 'function') || (p === 'obj') || (p === 'events'))
continue;

values[p] = value;


+ 4
- 4
src/server/config/eventPhases/phaseEventChain.js View File

@@ -9,7 +9,7 @@ module.exports = {
},

update: function () {
if (this.cd == 0) {
if (this.cd === 0) {
if (this.state < this.config.length - 1) {
this.state++;
let stateConfig = this.config[this.state];
@@ -41,7 +41,7 @@ module.exports = {

events: {
mobTalk: function (config) {
let mob = this.instance.objects.objects.find(o => (o.id == config.id));
let mob = this.instance.objects.objects.find(o => (o.id === config.id));
let text = (config.text instanceof Array) ? config.text[config.oldRepeat - config.repeat - 1] : config.text;

if (config.zone) {
@@ -70,7 +70,7 @@ module.exports = {
let mLen = mobs.length;

for (let i = 0; i < mLen; i++) {
let mob = objects.find(o => (o.id == mobs[i]));
let mob = objects.find(o => (o.id === mobs[i]));
for (let j = 0; j < cLen; j++) {
let c = components[j];
mob.addComponent(c.type, components[j]);
@@ -91,7 +91,7 @@ module.exports = {
let mLen = mobs.length;

for (let i = 0; i < mLen; i++) {
let mob = objects.find(o => (o.id == mobs[i]));
let mob = objects.find(o => (o.id === mobs[i]));
for (let j = 0; j < cLen; j++)
mob.removeComponent(components[j]);
}


+ 3
- 3
src/server/config/eventPhases/phaseKillMob.js View File

@@ -30,7 +30,7 @@ module.exports = {
for (let i = 0; i < oLen; i++) {
let o = objects[i];
let index = mobs.indexOf(o.id);
if (index == -1)
if (index === -1)
continue;

if (percentage) {
@@ -52,7 +52,7 @@ module.exports = {
let m = mobs[i];
let destroyed = m.destroyed;
if (!destroyed) {
let deathStopper = m.components.find(c => (c.type == 'deathStopper'));
let deathStopper = m.components.find(c => (c.type === 'deathStopper'));
if (deathStopper)
destroyed = deathStopper.end;
}
@@ -64,7 +64,7 @@ module.exports = {
}
}

if (mobs.length == 0)
if (mobs.length === 0)
this.end = true;
}
};

+ 2
- 2
src/server/config/eventPhases/phaseLocateMob.js View File

@@ -12,7 +12,7 @@ module.exports = {
for (let i = 0; i < oLen; i++) {
let o = objects[i];
let index = mobs.indexOf(o.id);
if (index == -1)
if (index === -1)
continue;

mobs.splice(index, 1, o);
@@ -44,7 +44,7 @@ module.exports = {
}
}

if (mobs.length == 0)
if (mobs.length === 0)
this.end = true;
}
};

+ 3
- 3
src/server/config/eventPhases/phaseModifyDialogue.js View File

@@ -1,6 +1,6 @@
module.exports = {
init: function () {
let mob = this.instance.objects.objects.find(m => (m.id == this.mobId));
let mob = this.instance.objects.objects.find(m => (m.id === this.mobId));
let states = mob.dialogue.states;

this.addStates(states, this.dialogue.add || {});
@@ -30,7 +30,7 @@ module.exports = {

if (!target)
continue;
else if (source == null) {
else if (source === null) {
delete dialogue[s];
continue;
}
@@ -38,7 +38,7 @@ module.exports = {
for (let o in source) {
let targetOptions = target.msg[0].options;
if (targetOptions.options)
targetOptions.spliceWhere(t => (t == o));
targetOptions.spliceWhere(t => (t === o));

delete target.options[o];
}


+ 1
- 1
src/server/config/eventPhases/phaseSpawnMob.js View File

@@ -47,7 +47,7 @@ module.exports = {
}

if (l.exists) {
let mob = objects.objects.find(o => (o.name == l.name));
let mob = objects.objects.find(o => (o.name === l.name));
mob.mob.walkDistance = 0;
this.spawnAnimation(mob);
mob.performMove({


+ 2
- 2
src/server/config/factions/akarei.js View File

@@ -21,7 +21,7 @@ module.exports = {

let result = null;
if (item.effects)
result = item.effects.find(e => (e.factionId == 'akarei'));
result = item.effects.find(e => (e.factionId === 'akarei'));

if (!result) {
if (!item.effects)
@@ -53,7 +53,7 @@ module.exports = {
if (!damage.crit)
return;

let effect = item.effects.find(e => (e.factionId == 'akarei'));
let effect = item.effects.find(e => (e.factionId === 'akarei'));

let roll = Math.random() * 100;
if (roll >= effect.properties.chance)


+ 2
- 2
src/server/config/factions/anglers.js View File

@@ -15,7 +15,7 @@ module.exports = {

let result = null;
if (item.effects)
result = item.effects.find(e => (e.factionId == 'anglers'));
result = item.effects.find(e => (e.factionId === 'anglers'));

if (!result) {
if (!item.effects)
@@ -42,7 +42,7 @@ module.exports = {

events: {
beforeGatherResource: function (item, gatherResult, source) {
let effect = item.effects.find(e => (e.factionId == 'anglers'));
let effect = item.effects.find(e => (e.factionId === 'anglers'));

let roll = Math.random() * 100;
if (roll >= effect.chance)


+ 2
- 2
src/server/config/factions/gaekatla.js View File

@@ -18,7 +18,7 @@ module.exports = {

let result = null;
if (item.effects)
result = item.effects.find(e => (e.factionId == 'gaekatla'));
result = item.effects.find(e => (e.factionId === 'gaekatla'));

if (!result) {
if (!item.effects)
@@ -50,7 +50,7 @@ module.exports = {

events: {
afterKillMob: function (item, mob) {
let effect = item.effects.find(e => (e.factionId == 'gaekatla'));
let effect = item.effects.find(e => (e.factionId === 'gaekatla'));

let roll = Math.random() * 100;
if (roll >= effect.chance)


+ 2
- 2
src/server/config/itemEffects/alwaysCrit.js View File

@@ -1,13 +1,13 @@
module.exports = {
events: {
onGetText: function (item) {
let rolls = item.effects.find(e => (e.type == 'alwaysCrit')).rolls;
let rolls = item.effects.find(e => (e.type === 'alwaysCrit')).rolls;

return 'your hits always crit';
},

onBeforeCalculateDamage: function (item, damage, target) {
let rolls = item.effects.find(e => (e.type == 'alwaysCrit')).rolls;
let rolls = item.effects.find(e => (e.type === 'alwaysCrit')).rolls;

damage.crit = true;
}


+ 2
- 2
src/server/config/itemEffects/damageSelf.js View File

@@ -5,13 +5,13 @@ module.exports = {
element: null,

onGetText: function (item) {
let rolls = item.effects.find(e => (e.type == 'damageSelf')).rolls;
let rolls = item.effects.find(e => (e.type === 'damageSelf')).rolls;

return `you take ${rolls.percentage}% of the damage you deal`;
},

afterDealDamage: function (item, damage, target) {
let effect = item.effects.find(e => (e.type == 'damageSelf'));
let effect = item.effects.find(e => (e.type === 'damageSelf'));
let rolls = effect.rolls;

let amount = (damage.dealt / 100) * rolls.percentage;


+ 2
- 2
src/server/config/itemEffects/freezeOnHit.js View File

@@ -1,13 +1,13 @@
module.exports = {
events: {
onGetText: function (item) {
let rolls = item.effects.find(e => (e.type == 'freezeOnHit')).rolls;
let rolls = item.effects.find(e => (e.type === 'freezeOnHit')).rolls;

return `${rolls.chance}% chance on hit to freeze target for ${rolls.duration} ticks`;
},

afterDealDamage: function (item, damage, target) {
let rolls = item.effects.find(e => (e.type == 'freezeOnHit')).rolls;
let rolls = item.effects.find(e => (e.type === 'freezeOnHit')).rolls;

let chanceRoll = Math.random() * 100;
if (chanceRoll >= rolls.chance)


+ 2
- 2
src/server/config/itemEffects/healOnCrit.js View File

@@ -1,7 +1,7 @@
module.exports = {
events: {
onGetText: function (item) {
let rolls = item.effects.find(e => (e.type == 'healOnCrit')).rolls;
let rolls = item.effects.find(e => (e.type === 'healOnCrit')).rolls;
let chance = rolls.chance || 100;
let amount = rolls.amount;
let percentage = rolls.percentage;
@@ -25,7 +25,7 @@ module.exports = {
if (!damage.crit)
return;

let rolls = item.effects.find(e => (e.type == 'healOnCrit')).rolls;
let rolls = item.effects.find(e => (e.type === 'healOnCrit')).rolls;

let chanceRoll = Math.random() * 100;
if (chanceRoll >= (rolls.chance || 100))


+ 1
- 1
src/server/config/loginRewards.js View File

@@ -54,7 +54,7 @@ module.exports = {
let amount = 1 + ~~(Math.random() * (total - 1));
total -= amount;

let item = items.find(f => (f.name == pick.name));
let item = items.find(f => (f.name === pick.name));
if (!item) {
item = extend(true, {
material: true,


+ 2
- 2
src/server/config/maps/cave/dialogues.js View File

@@ -29,7 +29,7 @@ module.exports = {
1.6: {
msg: 'I have some crystals for you.',
prereq: function (obj) {
let crystals = obj.inventory.items.find(i => (i.name == 'Digested Crystal'));
let crystals = obj.inventory.items.find(i => (i.name === 'Digested Crystal'));
return !!crystals;
},
goto: 'giveCrystals'
@@ -226,7 +226,7 @@ module.exports = {
method: function (obj) {
let inventory = obj.inventory;

let crystals = inventory.items.find(i => (i.name == 'Digested Crystal'));
let crystals = inventory.items.find(i => (i.name === 'Digested Crystal'));
if (!crystals)
return;
obj.reputation.getReputation('akarei', (crystals.quantity || 1) * 15);


+ 3
- 3
src/server/config/maps/cave/zone.js View File

@@ -486,7 +486,7 @@ module.exports = {
activated.push(order);
let valid = true;
for (let i = 0; i < activated.length; i++) {
if (activated[i] != i) {
if (activated[i] !== i) {
valid = false;
break;
}
@@ -508,7 +508,7 @@ module.exports = {
});

return;
} else if (activated.length == 4) {
} else if (activated.length === 4) {
triggerPuzzle.activated = [];
this.activate();
}
@@ -528,7 +528,7 @@ module.exports = {
activate: function () {
let syncer = this.obj.instance.syncer;
let physics = this.obj.instance.physics;
let walls = this.obj.instance.objects.objects.filter(o => (o.objZoneName == 'redWall'));
let walls = this.obj.instance.objects.objects.filter(o => (o.objZoneName === 'redWall'));
walls.forEach(function (w) {
w.destroyed = true;
physics.setCollision(w.x, w.y, false);


+ 2
- 2
src/server/config/maps/fjolarok/dialogues.js View File

@@ -225,12 +225,12 @@ module.exports = {

let sets = items.filter(function (i) {
return (
(i.type == 'Reward Card') &&
(i.type === 'Reward Card') &&
(i.quantity >= i.setSize)
);
});

if (sets.length == 0)
if (sets.length === 0)
return 'Sorry, you don\'t have any completed sets.';

sets.forEach(function (s) {


+ 9
- 9
src/server/config/maps/fjolarok/events/fishingTournament.js View File

@@ -73,7 +73,7 @@ module.exports = {

let fish = [];
tempFish.forEach(function (t) {
if (!fish.some(f => (f.owner == t.owner)))
if (!fish.some(f => (f.owner === t.owner)))
fish.push(t);
});

@@ -128,10 +128,10 @@ module.exports = {
let ranks = event.ranks;

let winText = 'Angler Nayla: ';
let winners = Object.keys(ranks).filter(r => (ranks[r] == 1));
let winners = Object.keys(ranks).filter(r => (ranks[r] === 1));
let wLen = winners.length;
winners.forEach(function (w, i) {
winText += ((wLen > 1) && (i == wLen - 1)) ? `and ${w} ` : `${w} `;
winText += ((wLen > 1) && (i === wLen - 1)) ? `and ${w} ` : `${w} `;
});

winText += 'won!';
@@ -147,7 +147,7 @@ module.exports = {
.filter(i => (i.name.indexOf('Ancient Carp') > -1))
.sort((a, b) => (b.stats.weight - a.stats.weight))
.forEach(function (f, i) {
if (i == 0) {
if (i === 0) {
f.owner = source.name;
tgtInventory.getItem(extend(true, {}, f));
}
@@ -340,10 +340,10 @@ module.exports = {
auto: true,
events: {
beforeGatherResource: function (gatherResult, gatherer) {
if (gatherResult.nodeType != 'fish')
if (gatherResult.nodeType !== 'fish')
return;

let hasCompRod = gatherer.inventory.items.some(i => ((i.name == 'Competition Rod') && (i.eq)));
let hasCompRod = gatherer.inventory.items.some(i => ((i.name === 'Competition Rod') && (i.eq)));
if (!hasCompRod)
return;

@@ -357,7 +357,7 @@ module.exports = {
},

beforeEnterPool: function (gatherResult, gatherer) {
if (gatherResult.nodeName == 'Sun Carp')
if (gatherResult.nodeName === 'Sun Carp')
gatherResult.nodeName = 'Ancient Carp';
}
}
@@ -398,7 +398,7 @@ module.exports = {
let newRank = helpers.getRank(event, obj.name);
helpers.updateDescription(event, this.instance.events);

if (oldRank != newRank) {
if (oldRank !== newRank) {
helpers.updateWinText(event, this.instance.events);

return {
@@ -406,7 +406,7 @@ module.exports = {
2: 'Nice catch. You took second place!',
3: 'Not bad at all. You took third place!'
}[newRank];
} else if (newRank == 1)
} else if (newRank === 1)
return 'Great, you\'re still in first place!';
return 'Not quite heavy enough, keep trying!';
}


+ 2
- 2
src/server/config/prophecies/titangrip.js View File

@@ -13,7 +13,7 @@ module.exports = {

events: {
afterEquipItem: function (item) {
if (['oneHanded', 'twoHanded'].indexOf(item.slot) == -1)
if (['oneHanded', 'twoHanded'].indexOf(item.slot) === -1)
return;

let stats = item.stats;
@@ -24,7 +24,7 @@ module.exports = {
}
},
afterUnequipItem: function (item) {
if (['oneHanded', 'twoHanded'].indexOf(item.slot) == -1)
if (['oneHanded', 'twoHanded'].indexOf(item.slot) === -1)
return;

let stats = item.stats;


+ 3
- 3
src/server/config/quests/questBuilder.js View File

@@ -10,7 +10,7 @@ module.exports = {
obtain: function (obj, template) {
let zoneName = template ? template.zoneName : obj.zoneName;
let oQuests = obj.quests;
if (oQuests.quests.filter(q => q.zoneName == zoneName).length > 0)
if (oQuests.quests.filter(q => q.zoneName === zoneName).length > 0)
return;

let zoneTemplate = null;
@@ -26,12 +26,12 @@ module.exports = {

let config = extend(true, {}, zoneTemplate);
this.instance.eventEmitter.emit('onBeforeGetQuests', config);
if (config.infini.length == 0)
if (config.infini.length === 0)
return;

let pickQuest = null;
if ((template) && (template.type))
pickQuest = config.infini.find(c => c.type == template.type);
pickQuest = config.infini.find(c => c.type === template.type);

if (!pickQuest)
pickQuest = config.infini[~~(Math.random() * config.infini.length)];


+ 7
- 7
src/server/config/quests/templates/questGatherResource.js View File

@@ -14,7 +14,7 @@ module.exports = {

this.gatherType = ['herb', 'fish'][~~(Math.random() * 2)];

if (this.gatherType == 'fish') {
if (this.gatherType === 'fish') {
this.name = 'Lure of the Sea';

let isQualityQ = (Math.random() < 0.3);
@@ -25,10 +25,10 @@ module.exports = {
}
}

if (['herb', 'fish'].indexOf(this.gatherType) == -1)
if (['herb', 'fish'].indexOf(this.gatherType) === -1)
this.gatherType = 'herb';

this.typeName = (this.gatherType == 'herb') ? 'herbs' : 'fish';
this.typeName = (this.gatherType === 'herb') ? 'herbs' : 'fish';

this.updateDescription();

@@ -36,9 +36,9 @@ module.exports = {
},

getXpMultiplier: function () {
if (this.requiredQuality == 2)
if (this.requiredQuality === 2)
return 8;
else if (this.requiredQuality == 1)
else if (this.requiredQuality === 1)
return 6;
return this.need;
},
@@ -58,12 +58,12 @@ module.exports = {

events: {
afterGatherResource: function (gatherResult) {
if (gatherResult.nodeType != this.gatherType)
if (gatherResult.nodeType !== this.gatherType)
return;
else if ((this.requiredQuality) && (gatherResult.items[0].quality < this.requiredQuality))
return;

if ((this.obj.zoneName != this.zoneName) || (this.have >= this.need))
if ((this.obj.zoneName !== this.zoneName) || (this.have >= this.need))
return;

this.have++;


+ 6
- 6
src/server/config/quests/templates/questKillX.js View File

@@ -9,12 +9,12 @@ module.exports = {
build: function () {
//If we're not in the correct zone, don't do this check, it'll just crash the server
// since the mob won't be available (most likely) in the zoneFile
if (this.obj.zoneName == this.zoneName) {
if (this.obj.zoneName === this.zoneName) {
let mobTypes = this.obj.instance.spawners.zone.mobs;
if (this.mobName) {
let mobType = mobTypes[this.mobName.toLowerCase()];
//Maybe the zoneFile changed in the meantime. If so, regenerate
if ((!mobType) || (mobType.attackable == false))
if ((!mobType) || (mobType.attackable === false))
this.mobName = null;
}

@@ -24,10 +24,10 @@ module.exports = {
let mobBlueprint = mobTypes[m];

return (
(m != 'default') &&
(m !== 'default') &&
(
(mobBlueprint.attackable) ||
(mobBlueprint.attackable == null)
(mobBlueprint.attackable === null)
) &&
(mobBlueprint.level <= ~~(this.obj.stats.values.level * 1.35)) &&
(mobCounts[m] > 1)
@@ -35,7 +35,7 @@ module.exports = {
}, this);

//No level appropriate mobs found
if (keys.length == 0)
if (keys.length === 0)
return false;

this.mobType = keys[~~(Math.random() * keys.length)];
@@ -59,7 +59,7 @@ module.exports = {

events: {
afterKillMob: function (mob) {
if ((mob.name.toLowerCase() != this.mobName.toLowerCase()) || (this.have >= this.need))
if ((mob.name.toLowerCase() !== this.mobName.toLowerCase()) || (this.have >= this.need))
return;

this.have++;


+ 9
- 9
src/server/config/quests/templates/questLoot.js View File

@@ -8,10 +8,10 @@ module.exports = {

build: function () {
let slotNames = slots.slots
.filter(s => (s != 'tool'));
.filter(s => (s !== 'tool'));

if (this.slot) {
if (!slotNames.some(s => (s == this.slot)))
if (!slotNames.some(s => (s === this.slot)))
this.slot = null;
}

@@ -20,9 +20,9 @@ module.exports = {
this.quality = 1 + ~~(Math.random() * 2);
this.slotName = '';

if (this.quality == 1) {
if (this.quality === 1) {
let roll = ~~(Math.random() * 2);
if (roll == 0)
if (roll === 0)
this.slotName = 'Magic Armor';
else
this.slotName = 'Magic Accessory';
@@ -66,9 +66,9 @@ module.exports = {

if (!this.quality)
multiplier *= 8;
else if (this.quality == 2)
else if (this.quality === 2)
multiplier *= 6;
else if (this.quality == 1)
else if (this.quality === 1)
multiplier *= 4;

return multiplier;
@@ -78,18 +78,18 @@ module.exports = {
afterLootMobItem: function (item) {
if (
(this.isReady) ||
(this.obj.zoneName != this.zoneName) ||
(this.obj.zoneName !== this.zoneName) ||
(
(this.quality) &&
(item.quality < this.quality)
) ||
(
(this.slot.indexOf) &&
(this.slot.indexOf(item.slot) == -1)
(this.slot.indexOf(item.slot) === -1)
) ||
(
(!this.slot.indexOf) &&
(this.slot != item.slot)
(this.slot !== item.slot)
)
)
return;


+ 7
- 7
src/server/config/quests/templates/questLootGen.js View File

@@ -18,14 +18,14 @@ module.exports = {
let mobBlueprint = mobTypes[m];

return (
(m != 'default') &&
(m !== 'default') &&
(mobBlueprint.questItem) &&
(mobBlueprint.level <= (this.obj.stats.values.level * 1.35))
);
}, this);

//No level appropriate mobs found
if (keys.length == 0)
if (keys.length === 0)
return false;

this.mobType = keys[~~(Math.random() * keys.length)];
@@ -51,14 +51,14 @@ module.exports = {

oComplete: function () {
let inventory = this.obj.inventory;
let item = inventory.items.find((i => i.name == this.item.name).bind(this));
let item = inventory.items.find((i => i.name === this.item.name).bind(this));
if (item)
this.obj.inventory.destroyItem(item.id, this.need);
},

events: {
beforeTargetDeath: function (target, dropItems) {
if ((this.obj.zoneName != this.zoneName) || (target.name.toLowerCase() != this.mobType) || (this.have >= this.need))
if ((this.obj.zoneName !== this.zoneName) || (target.name.toLowerCase() !== this.mobType) || (this.have >= this.need))
return;

let roll = Math.random();
@@ -76,11 +76,11 @@ module.exports = {
},

afterLootMobItem: function (item) {
if ((this.obj.zoneName != this.zoneName) || (item.name.toLowerCase() != this.item.name.toLowerCase()))
if ((this.obj.zoneName !== this.zoneName) || (item.name.toLowerCase() !== this.item.name.toLowerCase()))
return;

this.have++;
if (this.have == this.need)
if (this.have === this.need)
this.ready();

this.description = 'Loot ' + this.have + '/' + this.need + ' ' + this.item.name + ' from ' + this.mobName;
@@ -88,7 +88,7 @@ module.exports = {
},

afterDestroyItem: function (item, quantity) {
if (item.name.toLowerCase() != this.item.name.toLowerCase())
if (item.name.toLowerCase() !== this.item.name.toLowerCase())
return;

this.have -= quantity;


+ 1
- 1
src/server/config/quests/templates/questTemplate.js View File

@@ -73,7 +73,7 @@ module.exports = {
let values = {};
for (let p in this) {
let value = this[p];
if ((typeof (value) == 'function') || (p == 'obj'))
if ((typeof (value) === 'function') || (p === 'obj'))
continue;

values[p] = value;


+ 4
- 4
src/server/config/roles.js View File

@@ -9,7 +9,7 @@ module.exports = {
let account = obj.account;
let config = this.getAccount(account) || {};
if (config.items) {
let blueprintInventory = blueprint.components.find(c => (c.type == 'inventory'));
let blueprintInventory = blueprint.components.find(c => (c.type === 'inventory'));
if (!blueprintInventory) {
blueprint.components.push({
type: 'inventory',
@@ -22,7 +22,7 @@ module.exports = {

let items = blueprintInventory.items;
config.items.forEach(function (item) {
let hasItem = items.find(i => (i.name == item.name));
let hasItem = items.find(i => (i.name === item.name));
if (hasItem)
return;

@@ -62,14 +62,14 @@ module.exports = {

getSkins: function (account) {
let skins = [];
let account = this.getAccount(account) || {
account = this.getAccount(account) || {
skins: []
};
(account.skins || []).forEach(function (s) {
skins.push(s);
});

skins = skins.filter((s, i) => (skins.indexOf(s) == i));
skins = skins.filter((s, i) => (skins.indexOf(s) === i));
return skins;
},



+ 1
- 1
src/server/config/skins.js View File

@@ -117,7 +117,7 @@ module.exports = {
getSkinList: function (skins) {
let list = Object.keys(config)
.filter(function (s) {
return ((config[s].default) || (skins.some(f => ((f == s) || (f == '*')))));
return ((config[s].default) || (skins.some(f => ((f === s) || (f === '*')))));
})
.map(function (s) {
let res = extend(true, {}, config[s]);


+ 2
- 2
src/server/config/spells/spellArcaneBarrier.js View File

@@ -15,7 +15,7 @@ let cpnArcanePatch = {
let isPlayer = !!this.caster.player;
let isTargetPlayer = !!o.player;

if ((this.caster.aggro.canAttack(o)) || (isPlayer != isTargetPlayer))
if ((this.caster.aggro.canAttack(o)) || (isPlayer !== isTargetPlayer))
return;

this.contents.push(o);
@@ -25,7 +25,7 @@ let cpnArcanePatch = {
let contents = this.contents;
let cLen = contents.length;
for (let i = 0; i < cLen; i++) {
if (contents[i] == o) {
if (contents[i] === o) {
contents.splice(i, 1);
return;
}


+ 2
- 2
src/server/config/spells/spellAura.js View File

@@ -42,7 +42,7 @@ module.exports = {
updateActive: function () {
let o = this.obj;
let amount = 0;
if (this.name == 'Innervation')
if (this.name === 'Innervation')
amount = ~~((o.stats.values.hpMax / 100) * this.values.regenPercentage);
else
amount = this.values.regenPercentage || this.values.chance;
@@ -103,7 +103,7 @@ module.exports = {
if (!effect)
return;

let obj = objects.find(o => (o.serverId == m));
let obj = objects.find(o => (o.serverId === m));
if (!obj) {
delete effects[m];
return;


+ 1
- 1
src/server/config/spells/spellCallbacks.js View File

@@ -25,7 +25,7 @@ module.exports = {
for (let i = 0; i < cLen; i++) {
let c = callbacks[i];

if (c.sourceId == sourceId) {
if (c.sourceId === sourceId) {
if (c.destroyCallback)
c.destroyCallback();
callbacks.splice(i, 1);


+ 2
- 2
src/server/config/spells/spellCharge.js View File

@@ -23,11 +23,11 @@ module.exports = {

//We need to stop just short of the target
let offsetX = 0;
if (dx != 0)
if (dx !== 0)
offsetX = dx / Math.abs(dx);

let offsetY = 0;
if (dy != 0)
if (dy !== 0)
offsetY = dy / Math.abs(dy);

let targetPos = {


+ 2
- 2
src/server/config/spells/spellFireblast.js View File

@@ -32,7 +32,7 @@ module.exports = {
}]
};

if ((i != x) || (j != y))
if ((i !== x) || (j !== y))
syncer.queue('onGetObject', effect, -1);

let mobs = physics.getCell(i, j);
@@ -66,7 +66,7 @@ module.exports = {
let dx = m.x - obj.x;
let dy = m.y - obj.y;

while ((dx == 0) && (dy == 0)) {
while ((dx === 0) && (dy === 0)) {
dx = ~~(Math.random() * 2) - 1;
dy = ~~(Math.random() * 2) - 1;
}


+ 2
- 2
src/server/config/spells/spellHealingCircle.js View File

@@ -19,7 +19,7 @@ let cpnHealPatch = {
let isPlayer = !!this.caster.player;
let isTargetPlayer = !!o.player;

if ((this.caster.aggro.canAttack(o)) || (isPlayer != isTargetPlayer))
if ((this.caster.aggro.canAttack(o)) || (isPlayer !== isTargetPlayer))
return;

this.contents.push(o);
@@ -29,7 +29,7 @@ let cpnHealPatch = {
let contents = this.contents;
let cLen = contents.length;
for (let i = 0; i < cLen; i++) {
if (contents[i] == o) {
if (contents[i] === o) {
contents.splice(i, 1);
return;
}


+ 1
- 1
src/server/config/spells/spellSlowBlast.js View File

@@ -61,7 +61,7 @@ module.exports = {
continue;

let distance = ~~Math.sqrt(Math.pow(dx, 2) + Math.pow(dy, 2));
if (distance != radius)
if (distance !== radius)
continue;

if (!physics.hasLos(x, y, i, j))


+ 2
- 2
src/server/config/spells/spellSmokeBomb.js View File

@@ -21,7 +21,7 @@ let cpnSmokePatch = {
let contents = this.contents;
let cLen = contents.length;
for (let i = 0; i < cLen; i++) {
if (contents[i] == o) {
if (contents[i] === o) {
contents.splice(i, 1);
return;
}
@@ -89,7 +89,7 @@ module.exports = {

if (this.randomPos) {
let range = this.range;
while ((x == obj.x) && (y == obj.y)) {
while ((x === obj.x) && (y === obj.y)) {
x = obj.x + ~~(Math.random() * range * 2) - range;
y = obj.y + ~~(Math.random() * range * 2) - range;
}


+ 1
- 1
src/server/config/spells/spellSummonConsumableFollower.js View File

@@ -110,7 +110,7 @@ module.exports = {
}]
}, -1);
} else
m.mob.update = (this.walkCd == 0) ? m.mob.realUpdate : null;
m.mob.update = (this.walkCd === 0) ? m.mob.realUpdate : null;
}
},



+ 8
- 8
src/server/config/spells/spellTemplate.js View File

@@ -28,7 +28,7 @@ module.exports = {
return true;
let inRange = true;
if (this.range != null) {
if (this.range !== null) {
let obj = this.obj;
let distance = Math.max(Math.abs(target.x - obj.x), Math.abs(target.y - obj.y));
inRange = (distance <= this.range);
@@ -43,7 +43,7 @@ module.exports = {
},

calcDps: function (target, noSync) {
if ((!this.values) || (this.spellType == 'buff'))
if ((!this.values) || (this.spellType === 'buff'))
return;

if ((!this.damage) && (!this.healing))
@@ -67,7 +67,7 @@ module.exports = {
noCrit: true
}).amount;

let isAttack = (this.type == 'melee');
let isAttack = (this.type === 'melee');

let statValues = this.obj.stats.values;

@@ -140,7 +140,7 @@ module.exports = {
let values = {};
for (let p in this) {
let value = this[p];
if ((typeof (value) == 'function') || (p == 'obj'))
if ((typeof (value) === 'function') || (p === 'obj'))
continue;

values[p] = value;
@@ -158,7 +158,7 @@ module.exports = {
},

getDamage: function (target, noMitigate) {
let damage = {
let config = {
source: this.obj,
target: target,
damage: (this.damage || this.healing) * (this.dmgMult || 1),
@@ -166,13 +166,13 @@ module.exports = {
element: this.element,
statType: this.statType,
statMult: this.statMult,
isAttack: (this.type == 'melee'),
isAttack: (this.type === 'melee'),
noMitigate: noMitigate
};

this.obj.fireEvent('onBeforeCalculateDamage', damage);
this.obj.fireEvent('onBeforeCalculateDamage', config);

let damage = combat.getDamage(damage);
let damage = combat.getDamage(config);

return damage;
},


+ 3
- 3
src/server/config/spells/spellTrailDash.js View File

@@ -18,7 +18,7 @@ let cpnSpikePatch = {
let contents = this.contents;
let cLen = contents.length;
for (let i = 0; i < cLen; i++) {
if (contents[i] == o) {
if (contents[i] === o) {
contents.splice(i, 1);
return;
}
@@ -83,8 +83,8 @@ module.exports = {

if (this.obj.instance.physics.isTileBlocking(x, y))
this.distance = 7;
else if ((x != this.obj.x) || (y != this.obj.y)) {
//if ((x != this.targetX) || (y != this.targetY)) {
else if ((x !== this.obj.x) || (y !== this.obj.y)) {
//if ((x !== this.targetX) || (y !== this.targetY)) {
let particles = this.particles;

let spike = this.obj.instance.objects.buildObjects([{


+ 1
- 1
src/server/config/spells/spellWarnBlast.js View File

@@ -47,7 +47,7 @@ module.exports = {

if (!physics.hasLos(x, y, i, j))
continue;
else if ((attackTemplate) && (attackTemplate[count] == 'x'))
else if ((attackTemplate) && (attackTemplate[count] === 'x'))
continue;

if ((attackTemplate) && (~~attackTemplate[count] > 0)) {


+ 10
- 10
src/server/events/events.js View File

@@ -25,7 +25,7 @@ module.exports = {
},

getEvent: function (name) {
return this.configs.find(c => (c.name == name)).event.config;
return this.configs.find(c => (c.name === name)).event.config;
},
setEventDescription: function (name, desc) {
let config = this.getEvent(name);
@@ -202,7 +202,7 @@ module.exports = {
}

if (event.config.notifications) {
let n = event.config.notifications.find(f => (f.mark == event.age));
let n = event.config.notifications.find(f => (f.mark === event.age));
if (n) {
this.instance.syncer.queue('onGetMessages', {
messages: {
@@ -211,7 +211,7 @@ module.exports = {
}
}, -1);

if (n.desc != null) {
if (n.desc !== null) {
event.config.descTimer = n.desc;
this.setEventDescription(event.config.name);
}
@@ -220,9 +220,9 @@ module.exports = {

event.age++;

if (event.age == event.config.duration)
if (event.age === event.config.duration)
event.done = true;
else if ((event.config.prizeTime) && (event.age == event.config.prizeTime))
else if ((event.config.prizeTime) && (event.age === event.config.prizeTime))
this.giveRewards(event.config);

if (stillBusy)
@@ -258,7 +258,7 @@ module.exports = {
event.done = true;

let oList = this.instance.objects.objects;
let oLen = oList.length;
oLen = oList.length;
for (let i = 0; i < oLen; i++) {
let o = oList[i];
if (!o.player)
@@ -283,16 +283,16 @@ module.exports = {
if (!event)
continue;

let exists = event.participators.find(p => (p.name == obj.name));
let exists = event.participators.find(p => (p.name === obj.name));
if (exists) {
event.participators.spliceWhere(p => (p == exists));
event.participators.spliceWhere(p => (p === exists));
event.participators.push(obj);
result.push(event);
continue;
}

let distance = event.config.distance;
if (distance == -1) {
if (distance === -1) {
event.participators.push(obj);
result.push(event);

@@ -312,7 +312,7 @@ module.exports = {
let o = objects[j];

if (
(distance == -1) ||
(distance === -1) ||
(!distance) ||
(
(Math.abs(x - o.x) < distance) &&


+ 5
- 5
src/server/fixes/fixes.js View File

@@ -3,7 +3,7 @@ let configSkins = require('../config/skins');

module.exports = {
fixCharacter: function (player) {
let inv = player.components.find(c => (c.type == 'inventory'));
let inv = player.components.find(c => (c.type === 'inventory'));
if ((inv) && (inv.items))
this.fixItems(inv.items);
},
@@ -14,7 +14,7 @@ module.exports = {

fixItems: function (items) {
items
.filter(i => ((i.name == 'Cowl of Obscurity') && (!i.factions)))
.filter(i => ((i.name === 'Cowl of Obscurity') && (!i.factions)))
.forEach(function (i) {
i.factions = [{
id: 'gaekatla',
@@ -23,7 +23,7 @@ module.exports = {
});

items
.filter(i => (i.name == 'Steelclaw\'s Bite'))
.filter(i => (i.name === 'Steelclaw\'s Bite'))
.forEach(function (i) {
let effect = i.effects[0];

@@ -36,7 +36,7 @@ module.exports = {
});

items
.filter(f => ((f.effects) && (f.effects[0].factionId == 'akarei') && (!f.effects[0].properties)))
.filter(f => ((f.effects) && (f.effects[0].factionId === 'akarei') && (!f.effects[0].properties)))
.forEach(function (i) {
let effect = i.effects[0];
let chance = parseFloat(effect.text.split(' ')[0].replace('%', ''));
@@ -63,7 +63,7 @@ module.exports = {
let length = skins.length;
skins = skins.filter(s => !!configSkins.getBlueprint(s));

if (length != skins.length) {
if (length !== skins.length) {
io.set({
ent: username,
field: 'skins',


+ 0
- 2
src/server/index.js View File

@@ -15,8 +15,6 @@ let spells = require('./config/spells');
let itemTypes = require('./items/config/types');
let sheets = require('./security/sheets');

global.io = true;

let startup = {
init: function () {
io.init(this.onDbReady.bind(this));


+ 1
- 1
src/server/items/config/currencies.js View File

@@ -52,7 +52,7 @@ module.exports = {

getCurrencyFromAction: function (action) {
let currencies = this.currencies;
let pick = Object.keys(currencies).find(o => (currencies[o].action == action));
let pick = Object.keys(currencies).find(o => (currencies[o].action === action));

return extend(true, {
name: pick


+ 1
- 1
src/server/items/config/slots.js View File

@@ -50,7 +50,7 @@ module.exports = {
getRandomSlot: function (exclude) {
let chances = [];
for (let c in this.chance) {
if (c == exclude)
if (c === exclude)
continue;

let rolls = this.chance[c];


+ 18
- 17
src/server/items/enchanter.js View File

@@ -14,7 +14,7 @@ module.exports = {

let success = true;
config.materials.forEach(function (m) {
let hasMaterial = inventory.items.find(i => i.name == m.name);
let hasMaterial = inventory.items.find(i => i.name === m.name);
if (hasMaterial)
hasMaterial = hasMaterial.quantity >= m.quantity;
if (!hasMaterial)
@@ -32,11 +32,11 @@ module.exports = {
};

config.materials.forEach(function (m) {
let invMaterial = inventory.items.find(i => i.name == m.name);
let invMaterial = inventory.items.find(i => i.name === m.name);
inventory.destroyItem(invMaterial.id, m.quantity);
});

if (msg.action == 'reroll') {
if (msg.action === 'reroll') {
let enchantedStats = item.enchantedStats || {};
delete item.enchantedStats;
delete msg.addStatMsgs;
@@ -63,15 +63,15 @@ module.exports = {

item.stats[p] += enchantedStats[p];

if (p == 'lvlRequire') {
if (p === 'lvlRequire') {
item.level -= enchantedStats[p];
if (item.level < 1)
item.level = 1;
}
}
item.enchantedStats = enchantedStats;
} else if (msg.action == 'relevel') {
if (item.slot == 'tool')
} else if (msg.action === 'relevel') {
if (item.slot === 'tool')
return;

let offset = 1 + ~~(Math.random() * 2);
@@ -83,7 +83,7 @@ module.exports = {
item.originalLevel = Math.min(20, item.originalLevel + offset);
item.level = Math.min(20, item.level + offset);
}
} else if (msg.action == 'reslot') {
} else if (msg.action === 'reslot') {
if (item.effects)
return;

@@ -111,7 +111,7 @@ module.exports = {

newItem.stats[p] += enchantedStats[p];

if (p == 'lvlRequire') {
if (p === 'lvlRequire') {
newItem.level -= enchantedStats[p];
if (newItem.level < 1)
newItem.level = 1;
@@ -120,7 +120,7 @@ module.exports = {
newItem.enchantedStats = enchantedStats;

extend(true, item, newItem);
} else if (msg.action == 'reforge') {
} else if (msg.action === 'reforge') {
if (!item.spell)
return;

@@ -132,7 +132,7 @@ module.exports = {
spellName: spellName
});
item.spell = extend(true, oldSpell, item.spell);
} else if (msg.action == 'scour') {
} else if (msg.action === 'scour') {
if (!item.power)
return;

@@ -148,7 +148,7 @@ module.exports = {
if (item.stats[p] <= 0)
delete item.stats[p];

if (p == 'lvlRequire') {
if (p === 'lvlRequire') {
item.level += value;
delete item.originalLevel;
}
@@ -182,20 +182,21 @@ module.exports = {
getEnchantMaterials: function (item, action) {
let result = null;

if (action == 'reroll')
if (action === 'reroll')
result = [configCurrencies.getCurrencyFromAction('reroll')];
else if (action == 'relevel')
else if (action === 'relevel')
result = [configCurrencies.getCurrencyFromAction('relevel')];
else if (action == 'reslot')
else if (action === 'reslot')
result = [configCurrencies.getCurrencyFromAction('reslot')];
else if (action == 'reforge')
else if (action === 'reforge')
result = [configCurrencies.getCurrencyFromAction('reforge')];
else if (action == 'scour')
else if (action === 'scour')
result = [configCurrencies.getCurrencyFromAction('scour')];
else {
let powerLevel = item.power || 0;
let mult = null;
if (powerLevel < 3)
let mult = [5, 10, 20][powerLevel];
mult = [5, 10, 20][powerLevel];
else
return;



+ 2
- 2
src/server/items/generator.js View File

@@ -57,7 +57,7 @@ module.exports = {
item.noSalvage = blueprint.noSalvage;
item.noDestroy = blueprint.noDestroy;
materialGenerators.forEach(g => g.generate(item, blueprint));
} else if (blueprint.type == 'mtx') {
} else if (blueprint.type === 'mtx') {
item = extend(true, {}, blueprint);
delete item.chance;
} else {
@@ -81,7 +81,7 @@ module.exports = {
removeStat: function (item, stat) {
if (!stat) {
stat = Object.keys(item.stats)
.filter(s => (s != 'armor'));
.filter(s => (s !== 'armor'));

stat = stat[~~(Math.random() * stat.length)];
}


+ 1
- 1
src/server/items/generators/effects.js View File

@@ -7,7 +7,7 @@ module.exports = {
let rolls = e.rolls;
let newRolls = {};
for (let p in rolls) {
let isInt = (p.indexOf('i_') == 0);
let isInt = (p.indexOf('i_') === 0);
let fieldName = p.replace('i_', '');

let range = rolls[p];


+ 3
- 3
src/server/items/generators/names.js View File

@@ -33,7 +33,7 @@ module.exports = {

if (item.stats.armor)
list = list.concat(prefixes.armor);
else if (item.slot == 'twoHanded')
else if (item.slot === 'twoHanded')
list = list.concat(prefixes.weapons);

let pick = list[~~(Math.random() * list.length)];
@@ -48,14 +48,14 @@ module.exports = {
gSuffix: function (item, blueprint) {
let list = null;

if (item.slot == 'tool')
if (item.slot === 'tool')
list = suffixes.slots.tool;
else {
list = suffixes.generic.concat(suffixes.slots[item.slot] || []);

if (item.stats.armor)
list = list.concat(suffixes.armor);
else if (item.slot == 'twoHanded')
else if (item.slot === 'twoHanded')
list = list.concat(suffixes.weapons);
}



+ 2
- 2
src/server/items/generators/quality.js View File

@@ -10,7 +10,7 @@ module.exports = {
magicFindMult: 7,

generate: function (item, blueprint) {
if (blueprint.quality != null) {
if (blueprint.quality !== null) {
item.quality = ~~blueprint.quality;
return;
}
@@ -29,7 +29,7 @@ module.exports = {
for (let i = 0; i < mLen; i++) {
qualities[i] = Math.max(0, qualities[i] - magicFind[i]);
if (qualities[i] > 0) {
if (i == 0) {
if (i === 0) {
qualities[i] -= (bonusMagicFind * this.magicFindMult);
if (qualities[i] < 0)
qualities[i] = 0;


+ 7
- 7
src/server/items/generators/spellbook.js View File

@@ -16,14 +16,14 @@ module.exports = {
}

let spell = spellsConfig.spells[spellName];
let spellAesthetic = spells.spells.find(s => s.name.toLowerCase() == spellName) || {};
let spellAesthetic = spells.spells.find(s => s.name.toLowerCase() === spellName) || {};

if (!item.slot) {
let sprite = [10, 0];
let statType = spell.statType;
if (statType == 'dex')
if (statType === 'dex')
sprite = [10, 1];
else if (statType == 'str')
else if (statType === 'str')
sprite = [10, 2];
else if (statType instanceof Array) {
if ((statType.indexOf('dex') > -1) && (statType.indexOf('int') > -1))
@@ -35,7 +35,7 @@ module.exports = {
item.name = 'Rune of ' + spellAesthetic.name;
item.ability = true;
item.sprite = sprite;
} else if (spellQuality == 'basic')
} else if (spellQuality === 'basic')
item.stats = {};

if (blueprint.spellConfig)
@@ -68,14 +68,14 @@ module.exports = {
let max = Math.min(20, item.level) / 20;

let roll = random.expNorm(0, max);
if (spellQuality == 'basic')
if (spellQuality === 'basic')
roll = 0;
else if (spellQuality == 'mid')
else if (spellQuality === 'mid')
roll = 0.5;

item.spell.rolls[r] = roll;

let int = r.indexOf('i_') == 0;
let int = r.indexOf('i_') === 0;
let val = range[0] + ((range[1] - range[0]) * roll);

if (int) {


+ 19
- 19
src/server/items/generators/stats.js View File

@@ -7,56 +7,56 @@ module.exports = {

if (calcPerfection)
return (calcPerfection / max);
else if (perfection == null)
else if (perfection === null)
return random.norm(1, max) * (blueprint.statMult.elementDmgPercent || 1);
return max * perfection * (blueprint.statMult.elementDmgPercent || 1);
},

addCritMultiplier: function (item, level, blueprint, perfection, calcPerfection) {
let div = 1 / 11;
if (item.slot == 'twoHanded')
if (item.slot === 'twoHanded')
div *= 2;

let max = (level * 15) * div;

if (calcPerfection)
return (calcPerfection / max);
else if (perfection == null)
else if (perfection === null)
return random.norm(1, max) * (blueprint.statMult.addCritMultiplier || 1);
return max * perfection * (blueprint.statMult.addCritMultiplier || 1);
},

addCritChance: function (item, level, blueprint, perfection, calcPerfection) {
let div = 1 / 11;
if (item.slot == 'twoHanded')
if (item.slot === 'twoHanded')
div *= 2;

let max = (level - 3) * 50 * div;

if (calcPerfection)
return (calcPerfection / max);
else if (perfection == null)
else if (perfection === null)
return random.norm(1, max) * (blueprint.statMult.addCritChance || 1);
return max * perfection * (blueprint.statMult.addCritChance || 1);
},

vit: function (item, level, blueprint, perfection, calcPerfection) {
let div = 1 / 11;
if (item.slot == 'twoHanded')
if (item.slot === 'twoHanded')
div *= 2;

let max = ((-0.6340155 + (13.68923 * level) - (0.34383 * Math.pow(level, 2)) + (0.06754871 * Math.pow(level, 3)) + (0.000174046 * Math.pow(level, 4)) + (0.000007675887 * Math.pow(level, 5))) / 10) * div;

if (calcPerfection)
return (calcPerfection / max);
else if (perfection == null)
else if (perfection === null)
return random.norm(1, max) * (blueprint.statMult.vit || 1);
return max * perfection * (blueprint.statMult.vit || 1);
},

mainStat: function (item, level, blueprint, perfection, calcPerfection) {
let div = 1 / 11;
if (item.slot == 'twoHanded')
if (item.slot === 'twoHanded')
div *= 2;

let min = (level / 15) * div;
@@ -64,7 +64,7 @@ module.exports = {

if (calcPerfection)
return ((calcPerfection - min) / (max - min));
else if (perfection == null)
else if (perfection === null)
return random.norm(min, max) * (blueprint.statMult.mainStat || 1);
return (min + ((max - min) * perfection)) * (blueprint.statMult.mainStat || 1);
},
@@ -74,31 +74,31 @@ module.exports = {

if (calcPerfection)
return ((calcPerfection - min) / (max - min));
else if (perfection == null)
else if (perfection === null)
return random.norm(min, max) * blueprint.statMult.armor;
return (min + ((max - min) * perfection)) * (blueprint.statMult.armor || 1);
},
elementResist: function (item, level, blueprint, perfection, calcPerfection) {
let div = 1 / 11;
if (item.slot == 'twoHanded')
if (item.slot === 'twoHanded')
div *= 2;

if (calcPerfection)
return (calcPerfection / (100 * div));
else if (perfection == null)
else if (perfection === null)
return random.norm(1, 100) * (blueprint.statMult.elementResist || 1) * div;
return ~~((1 + (99 * perfection)) * (blueprint.statMult.elementResist || 1) * div);
},
regenHp: function (item, level, blueprint, perfection, calcPerfection) {
let div = 1 / 11;
if (item.slot == 'twoHanded')
if (item.slot === 'twoHanded')
div *= 2;

let max = (-0.05426729 + (3.477385 * level) - (0.03890282 * Math.pow(level, 2)) + (0.009244822 * Math.pow(level, 3)) + (0.0001700915 * Math.pow(level, 4)) - (0.00000138085 * Math.pow(level, 5))) * div;

if (calcPerfection)
return (calcPerfection / max);
else if (perfection == null)
else if (perfection === null)
return random.norm(1, max) * (blueprint.statMult.regenHp || 1);
return max * perfection * (blueprint.statMult.regenHp || 1);
},
@@ -107,7 +107,7 @@ module.exports = {

if (calcPerfection)
return (calcPerfection / max);
else if (perfection == null)
else if (perfection === null)
return random.norm(1, max) * (blueprint.statMult.lvlRequire || 1);
return max * perfection * (blueprint.statMult.lvlRequire || 1);
}
@@ -465,7 +465,7 @@ module.exports = {
},

generate: function (item, blueprint, result) {
if (item.slot == 'tool') {
if (item.slot === 'tool') {
statsFishingRod.generate(item, blueprint, result);
return;
}
@@ -509,7 +509,7 @@ module.exports = {
let addStats = Math.min(statCount, blueprint.stats.length);
for (let i = 0; i < addStats; i++) {
let choice = useStats[~~(Math.random() * useStats.length)];
useStats.spliceFirstWhere(s => s == choice);
useStats.spliceFirstWhere(s => s === choice);
this.buildStat(item, blueprint, choice, result);
statCount--;
}
@@ -520,7 +520,7 @@ module.exports = {

for (let s in item.stats) {
item.stats[s] = Math.ceil(item.stats[s]);
if (item.stats[s] == 0)
if (item.stats[s] === 0)
delete item.stats[s];
}
},
@@ -584,7 +584,7 @@ module.exports = {
item.enchantedStats[stat] = value;
}

if (stat == 'lvlRequire') {
if (stat === 'lvlRequire') {
if (!item.originalLevel)
item.originalLevel = item.level;



+ 2
- 2
src/server/items/salvager.js View File

@@ -113,7 +113,7 @@ module.exports = {
temp.forEach(function (t) {
let mats = t.materials;
mats.forEach(function (m) {
let exists = materials.find(mf => (mf.name == m.name));
let exists = materials.find(mf => (mf.name === m.name));
if (exists) {
exists.chance = Math.max(exists.chance, m.chance);
exists.quantity = Math.max(exists.quantity, m.quantity);
@@ -146,7 +146,7 @@ module.exports = {
if (m.qualityName) {
newItem.quality = item.quality;
newItem.name = m.qualityName[item.quality];
} else if (m.quality != null)
} else if (m.quality !== null)
newItem.quality = m.quality;

newItem.sprite = materialItems[newItem.name].sprite;


+ 7
- 7
src/server/leaderboard/leaderboard.js View File

@@ -25,7 +25,7 @@ module.exports = {

let match = true;
for (let i = 0; i < pLen; i++) {
if (!rProphecies.some(rp => rp == prophecyFilter[i])) {
if (!rProphecies.some(rp => rp === prophecyFilter[i])) {
match = false;
break;
}
@@ -90,7 +90,7 @@ module.exports = {
let doSave = false;

this.waiting.forEach(function (w) {
if (!this.list.some(l => l.name == w.name)) {
if (!this.list.some(l => l.name === w.name)) {
this.list.push(w);
doSave = true;
}
@@ -106,7 +106,7 @@ module.exports = {
if (!this.list)
return null;

let result = this.list.find(l => (l.name == name));
let result = this.list.find(l => (l.name === name));
if (result)
return result.level;
return null;
@@ -123,9 +123,9 @@ module.exports = {
return;
}

let exists = this.list.find(l => l.name == name);
let exists = this.list.find(l => l.name === name);
if (exists) {
if (exists.level != level) {
if (exists.level !== level) {
exists.level = level;

this.save();
@@ -142,12 +142,12 @@ module.exports = {
},

deleteCharacter: function (name) {
this.list.spliceWhere(l => (l.name == name));
this.list.spliceWhere(l => (l.name === name));
this.save();
},

killCharacter: function (name) {
let character = this.list.find(l => (l.name == name));
let character = this.list.find(l => (l.name === name));
if (!character)
return;



+ 3
- 3
src/server/misc/events.js View File

@@ -7,7 +7,7 @@ module.exports = {

for (let i = 0; i < this.queue.length; i++) {
let q = this.queue[i];
if (q.event != event)
if (q.event !== event)
continue;

this.queue.splice(i, 1);
@@ -24,14 +24,14 @@ module.exports = {
let list = this.events[event] || [];
let lLen = list.length;
for (let i = 0; i < lLen; i++) {
if (list[i] == callback) {
if (list[i] === callback) {
list.splice(i, 1);
i--;
lLen--;
}
}

if (lLen == 0)
if (lLen === 0)
delete this.events[event];
},
emit: function (event) {


+ 1
- 1
src/server/misc/helpers.js View File

@@ -72,7 +72,7 @@ module.exports = {
for (let i = 0; i < w; i++) {
let inner = [];
for (let j = 0; j < h; j++) {
if (def == 'array')
if (def === 'array')
inner.push([]);
else
inner.push(def);


+ 6
- 6
src/server/misc/mail.js View File

@@ -9,7 +9,7 @@ module.exports = {
},

getMail: function (playerName) {
let player = this.instance.objects.objects.find(o => (o.name == playerName));
let player = this.instance.objects.objects.find(o => (o.name === playerName));
if (!player) {
process.send({
method: 'callDifferentThread',
@@ -32,12 +32,12 @@ module.exports = {
});
},
onGetMail: function (player, result) {
if (result == 'null')
if (result === 'null')
result = null;
else if (result) {
result = result.split('`').join('\'');
//Hack for weird google datastore error
if (result[0] == '<')
if (result[0] === '<')
return;
}

@@ -69,7 +69,7 @@ module.exports = {
} else
console.log(player.name + ' has no stash');
} else {
if ((r.msg) && (!sentMessages.some(s => (s == r.msg)))) {
if ((r.msg) && (!sentMessages.some(s => (s === r.msg)))) {
player.instance.syncer.queue('onGetMessages', {
id: player.id,
messages: [{
@@ -124,7 +124,7 @@ module.exports = {

let player = null;
if (this.instance)
player = this.instance.objects.objects.find(o => (o.name == playerName));
player = this.instance.objects.objects.find(o => (o.name === playerName));

io.get({
ent: playerName,
@@ -133,7 +133,7 @@ module.exports = {
});
},
doSendMail: function (playerName, items, callback, result) {
if (result == 'null')
if (result === 'null')
result = null;

result = JSON.parse(result || '[]');


+ 2
- 2
src/server/misc/pathfinder.js View File

@@ -73,7 +73,7 @@

if (!onWall) {
if (distance) {
if (currentNode.h == distance)
if (currentNode.h === distance)
return pathTo(currentNode);
} else {
// End case -- result has been found, return the traced path.
@@ -277,7 +277,7 @@

GridNode.prototype.getCost = function (fromNeighbor) {
// Take diagonal weight into consideration.
if (fromNeighbor && fromNeighbor.x != this.x && fromNeighbor.y != this.y)
if (fromNeighbor && fromNeighbor.x !== this.x && fromNeighbor.y !== this.y)
return this.weight * 1.41421;
return this.weight;


+ 2
- 2
src/server/misc/random.js View File

@@ -13,7 +13,7 @@ this.mt[this.N - 1], b = 1);
};
Random.prototype.genrand_int32 = function () {
let a, c = [0, this.MATRIX_A]; if (this.mti >= this.N) {
let b; this.mti == this.N + 1 && this.init_genrand(5489); for (b = 0; b < this.N - this.M; b++)a = this.mt[b] & this.UPPER_MASK | this.mt[b + 1] & this.LOWER_MASK, this.mt[b] = this.mt[b + this.M] ^ a >>> 1 ^ c[a & 1]; for (;b < this.N - 1; b++)a = this.mt[b] & this.UPPER_MASK | this.mt[b + 1] & this.LOWER_MASK, this.mt[b] = this.mt[b + (this.M - this.N)] ^ a >>> 1 ^ c[a & 1]; a = this.mt[this.N - 1] & this.UPPER_MASK | this.mt[0] & this.LOWER_MASK; this.mt[this.N - 1] = this.mt[this.M - 1] ^ a >>> 1 ^
let b; this.mti === this.N + 1 && this.init_genrand(5489); for (b = 0; b < this.N - this.M; b++)a = this.mt[b] & this.UPPER_MASK | this.mt[b + 1] & this.LOWER_MASK, this.mt[b] = this.mt[b + this.M] ^ a >>> 1 ^ c[a & 1]; for (;b < this.N - 1; b++)a = this.mt[b] & this.UPPER_MASK | this.mt[b + 1] & this.LOWER_MASK, this.mt[b] = this.mt[b + (this.M - this.N)] ^ a >>> 1 ^ c[a & 1]; a = this.mt[this.N - 1] & this.UPPER_MASK | this.mt[0] & this.LOWER_MASK; this.mt[this.N - 1] = this.mt[this.M - 1] ^ a >>> 1 ^
c[a & 1]; this.mti = 0;
}a = this.mt[this.mti++]; a ^= a >>> 11; a ^= a << 7 & 2636928640; a ^= a << 15 & 4022730752; a ^= a >>> 18; return a >>> 0;
}; Random.prototype.genrand_int31 = function () {
@@ -37,7 +37,7 @@ Random.prototype.gamma = function (a, c) {
let j = 1 - this.random(), i = Math.log(d / (1 - d)) / b, h = a * Math.exp(i), d = d * d * j, i = f + e * i - h; if (i + this.SG_MAGICCONST - 4.5 * d >= 0 || i >= Math.log(d)) return h * c;
}
}
} else if (a == 1) {
} else if (a === 1) {
for (let g = this.random(); g <= 1.0E-7;)g = this.random(); return -Math.log(g) * c;
} else {
for (;;) {


+ 7
- 7
src/server/misc/scheduler.js View File

@@ -13,7 +13,7 @@ module.exports = {

shouldRun: function (c) {
let cron = c.cron.split(' ');
if (cron.length != 5) {
if (cron.length !== 5) {
console.log('Invalid Cron Format: ' + cron.join(' '));
return false;
}
@@ -23,7 +23,7 @@ module.exports = {

let lastRun = c.lastRun;
if (lastRun) {
if (Object.keys(lastRun).every(e => (lastRun[e] == time[e])))
if (Object.keys(lastRun).every(e => (lastRun[e] === time[e])))
return false;
}

@@ -32,7 +32,7 @@ module.exports = {
let run = ['minute', 'hour', 'day', 'month', 'weekday'].every(function (t, i) {
let tCheck = cron[i];

if (tCheck == '*')
if (tCheck === '*')
return true;
let overflow = timeOverflows[i];
@@ -53,11 +53,11 @@ module.exports = {

return tCheck.some(function (f) {
f = f.split('-');
if (f.length == 1) {
if (f.length === 1) {
f = f[0].split('/');
if (f.length == 1)
return (useTime == f[0]);
return ((useTime % f[1]) == 0);
if (f.length === 1)
return (useTime === f[0]);
return ((useTime % f[1]) === 0);
}
return ((useTime >= f[0]) && (useTime <= f[1]));
});


+ 4
- 4
src/server/mods/class-necromancer/index.js View File

@@ -19,7 +19,7 @@ module.exports = {
},

onAfterGetZone: function (zone, config) {
if (zone != 'fjolarok')
if (zone !== 'fjolarok')
return;

let newRunes = [{
@@ -104,11 +104,11 @@ module.exports = {
},

beforeGetSpellTemplate: function (spell) {
if (spell.type == 'HarvestLife')
if (spell.type === 'HarvestLife')
spell.template = require('./spells/spellHarvestLife');
else if (spell.type == 'SummonSkeleton')
else if (spell.type === 'SummonSkeleton')
spell.template = require('./spells/spellSummonSkeleton');
else if (spell.type == 'BloodBarrier')
else if (spell.type === 'BloodBarrier')
spell.template = require('./spells/spellBloodBarrier');
},



+ 6
- 6
src/server/mods/event-halloween/index.js View File

@@ -87,7 +87,7 @@ module.exports = {
},

beforeGetSpellTemplate: function (spell) {
if (spell.type == 'ScatterPumpkinPieces')
if (spell.type === 'ScatterPumpkinPieces')
spell.template = require('./spells/spellScatterPumpkinPieces.js');
},

@@ -180,10 +180,10 @@ module.exports = {
},

onAfterGetLayerObjects: function (info) {
if (info.map != 'fjolarok')
if (info.map !== 'fjolarok')
return;

let layer = this.mapFile.layers.find(l => (l.name == info.layer));
let layer = this.mapFile.layers.find(l => (l.name === info.layer));
if (layer) {
let offset = this.mapOffset;
let mapScale = this.mapFile.tilesets[0].tileheight;
@@ -199,7 +199,7 @@ module.exports = {
},

onBeforeBuildLayerTile: function (info) {
if (info.map != 'fjolarok')
if (info.map !== 'fjolarok')
return;

let offset = this.mapOffset;
@@ -211,13 +211,13 @@ module.exports = {
return;

let i = ((y - offset.y) * this.mapW) + (x - offset.x);
let layer = this.mapFile.layers.find(l => (l.name == info.layer));
let layer = this.mapFile.layers.find(l => (l.name === info.layer));
if (layer)
info.cell = layer.data[i];
},

onBeforeGetEventList: function (zone, list) {
if (zone != 'fjolarok')
if (zone !== 'fjolarok')
return;

list.push(this.relativeFolderName + '/maps/fjolarok/events/halloween.js');


+ 1
- 1
src/server/mods/event-halloween/maps/fjolarok/events/halloween.js View File

@@ -52,7 +52,7 @@ module.exports = {
events: {
beforeGatherResource: function (gatherResult, gatherer) {
let itemName = gatherResult.blueprint.itemName;
if ((!itemName) || (itemName.toLowerCase() != 'candy corn'))
if ((!itemName) || (itemName.toLowerCase() !== 'candy corn'))
return;

gatherer.reputation.getReputation('pumpkinSailor', 40);


+ 2
- 2
src/server/mods/event-halloween/mtx/hauntedIceSpear.js View File

@@ -1,10 +1,10 @@
module.exports = {
events: {
beforeSpawnProjectile: function (item, spell, projectileConfig) {
if (spell.name.toLowerCase() != 'ice spear')
if (spell.name.toLowerCase() !== 'ice spear')
return;

let cpnProjectile = projectileConfig.components.find(c => (c.type == 'projectile'));
let cpnProjectile = projectileConfig.components.find(c => (c.type === 'projectile'));
cpnProjectile.particles = {
color: {
start: ['51fc9a', '48edff'],


+ 2
- 2
src/server/mods/event-halloween/spells/spellScatterPumpkinPieces.js View File

@@ -9,7 +9,7 @@ let cpnPumpkinChunk = {
update: function () {
this.ttl--;

if (this.ttl == 0)
if (this.ttl === 0)
this.obj.destroyed = true;
},

@@ -20,7 +20,7 @@ let cpnPumpkinChunk = {
this.obj.destroyed = true;

if (this.isRotten) {
let drainCounts = this.caster.spellbook.spells.find(s => (s.type == 'scatterPumpkinPieces')).drainCounts;
let drainCounts = this.caster.spellbook.spells.find(s => (s.type === 'scatterPumpkinPieces')).drainCounts;
if (drainCounts[o.name])
drainCounts[o.name] += 2;
else


+ 9
- 9
src/server/mods/event-xmas/index.js View File

@@ -56,7 +56,7 @@ module.exports = {
},

onBeforeGetEffect: function (result) {
if (result.type.toLowerCase() == 'merry')
if (result.type.toLowerCase() === 'merry')
result.url = `${this.relativeFolderName}/effects/effectMerry.js`;
},

@@ -103,7 +103,7 @@ module.exports = {
let ox = obj.x;
let oy = obj.y;

let objects = obj.instance.objects.objects.filter(o => (((o.mob) || (o.player)) && (o.name) && (o != obj)));
let objects = obj.instance.objects.objects.filter(o => (((o.mob) || (o.player)) && (o.name) && (o !== obj)));
let closestDistance = 999;
let closest = null;
let oLen = objects.length;
@@ -208,10 +208,10 @@ module.exports = {
},

onAfterGetLayerObjects: function (info) {
if (info.map != 'fjolarok')
if (info.map !== 'fjolarok')
return;

let layer = this.mapFile.layers.find(l => (l.name == info.layer));
let layer = this.mapFile.layers.find(l => (l.name === info.layer));
if (layer) {
let offset = this.mapOffset;
let mapScale = this.mapFile.tilesets[0].tileheight;
@@ -227,7 +227,7 @@ module.exports = {
},

onBeforeBuildLayerTile: function (info) {
if (info.map != 'fjolarok')
if (info.map !== 'fjolarok')
return;

let offset = this.mapOffset;
@@ -239,7 +239,7 @@ module.exports = {
return;

let i = ((y - offset.y) * this.mapW) + (x - offset.x);
let layer = this.mapFile.layers.find(l => (l.name == info.layer));
let layer = this.mapFile.layers.find(l => (l.name === info.layer));
if (layer) {
let cell = layer.data[i];
if (cell)
@@ -286,7 +286,7 @@ module.exports = {
},

onBeforeGetCardReward: function (msg) {
if (msg.reward == 'Rare Festive Spear') {
if (msg.reward === 'Rare Festive Spear') {
msg.handler = function (card) {
return itemGenerator.generate({
name: 'Festive Spear',
@@ -300,7 +300,7 @@ module.exports = {
sprite: [0, 0]
});
};
} else if (msg.reward == 'Scented Beard Oil') {
} else if (msg.reward === 'Scented Beard Oil') {
msg.handler = function (card) {
return {
name: 'Scented Beard Oil',
@@ -323,7 +323,7 @@ module.exports = {
},

onBeforeGetEventList: function (zone, list) {
if (zone != 'fjolarok')
if (zone !== 'fjolarok')
return;

list.push(this.relativeFolderName + '/maps/fjolarok/events/xmas.js');


+ 6
- 6
src/server/mods/event-xmas/maps/fjolarok/events/xmas.js View File

@@ -88,15 +88,15 @@ module.exports = {
method: function (obj) {
let inventory = obj.inventory;

let snowflakes = inventory.items.find(i => (i.name == 'Snowflake'));
let snowflakes = inventory.items.find(i => (i.name === 'Snowflake'));
if ((!snowflakes) || (snowflakes.quantity < 15))
return 'Sorry, please come back when you have at least fifteen.';

while (true) {
snowflakes = inventory.items.find(i => (i.name == 'Snowflake'));
snowflakes = inventory.items.find(i => (i.name === 'Snowflake'));
if ((!snowflakes) || (snowflakes.quantity < 15))
return;
else if ((!inventory.hasSpace()) && (snowflakes.quantity != 15))
else if ((!inventory.hasSpace()) && (snowflakes.quantity !== 15))
return 'Sorry, it seems you don\'t have enough space to accept my gifts.';

obj.reputation.getReputation('theWinterMan', 100);
@@ -153,7 +153,7 @@ module.exports = {
});

let pick = pool[~~(Math.random() * pool.length)];
let blueprint = rewards.find(r => (r.name == pick));
let blueprint = rewards.find(r => (r.name === pick));

inventory.getItem(extend(true, {}, blueprint));

@@ -251,12 +251,12 @@ module.exports = {

beforeGatherResource: function (gatherResult, gatherer) {
let itemName = gatherResult.blueprint.itemName;
if ((!itemName) || (itemName.toLowerCase() != 'snowflake'))
if ((!itemName) || (itemName.toLowerCase() !== 'snowflake'))
return;

gatherer.reputation.getReputation('theWinterMan', 40);

if ((gatherResult.name != 'Gilded Gift') || (Math.random() >= 0.05))
if ((gatherResult.name !== 'Gilded Gift') || (Math.random() >= 0.05))
return;

gatherResult.items.push({


+ 6
- 8
src/server/mods/feature-cards/cards.js View File

@@ -68,18 +68,18 @@ module.exports = {
if (rqrLevel) {
if ((rqrLevel.push) && ((mobLevel < rqrLevel[0]) || (mobLevel > rqrLevel[1])))
return;
else if ((!rqrLevel.push) && (mobLevel != rqrLevel))
else if ((!rqrLevel.push) && (mobLevel !== rqrLevel))
return;
}
let mobName = card.mobName;
if (mobName) {
if ((mobName.toLowerCase) && (mob.name.toLowerCase() != mobName.toLowerCase()))
if ((mobName.toLowerCase) && (mob.name.toLowerCase() !== mobName.toLowerCase()))
return;
else if ((mobName.push) && (!mobName.some(m => (m.toLowerCase() == mob.name.toLowerCase()))))
else if ((mobName.push) && (!mobName.some(m => (m.toLowerCase() === mob.name.toLowerCase()))))
return;
}

if ((card.zone) && (looter.zoneName != card.zone))
if ((card.zone) && (looter.zoneName !== card.zone))
return;

if (Math.random() >= card.chance)
@@ -88,7 +88,7 @@ module.exports = {
pool.push(c);
}, this);

if (pool.length == 0)
if (pool.length === 0)
return;

let pickName = pool[~~(Math.random() * pool.length)];
@@ -125,7 +125,7 @@ module.exports = {
},

rewards: {
'Level 10 Rune': function (obj) {
'Level 10 Rune': function () {
return itemGenerator.generate({
level: 10,
spell: true
@@ -163,7 +163,6 @@ module.exports = {
sprite: [0, 0],
spritesheet: '../../../images/legendaryItems.png',
type: 'Trident',
spellName: 'magic missile',
description: 'Summoned from the ancient depths of the ocean by the Benthic Incantation.',
stats: ['elementFrostPercent', 'elementFrostPercent', 'elementFrostPercent'],
effects: [{
@@ -209,7 +208,6 @@ module.exports = {
sprite: [1, 0],
spritesheet: '../../../images/legendaryItems.png',
type: 'Curved Dagger',
spellName: 'double slash',
description: 'The blade seems to be made of some kind of bone and steel alloy.',
stats: ['dex', 'dex', 'addCritMultiplier', 'addCritMultiplier'],
effects: [{


+ 1
- 1
src/server/mods/feature-cards/index.js View File

@@ -35,7 +35,7 @@ module.exports = {
},

onBeforeGetItem: function (item, obj) {
if ((!obj.player) && (item.type != 'Reward Card'))
if ((!obj.player) && (item.type !== 'Reward Card'))
return;

cards.fixCard(item);


+ 33
- 33
src/server/objects/objBase.js View File

@@ -15,14 +15,14 @@ module.exports = {
}, blueprint || {});
}

let cpn = extend(true, {}, template);
cpn = extend(true, {}, template);
cpn.obj = this;

this.components.push(cpn);
this[cpn.type] = cpn;
}

if ((cpn.init) && (this.instance != null))
if ((cpn.init) && (this.instance !== null))
cpn.init(blueprint || {}, isTransfer);
else {
for (let p in blueprint)
@@ -55,14 +55,14 @@ module.exports = {
update: function () {
let usedTurn = false;

let components = this.components;
let len = components.length;
let cpns = this.components;
let len = cpns.length;
for (let i = 0; i < len; i++) {
let c = components[i];
let c = cpns[i];

if (c.destroyed) {
this.syncer.setSelfArray(false, 'removeComponents', c.type);
this.components.spliceWhere(f => (f == c));
cpns.spliceWhere(f => (f === c));
delete this[c.type];
len--;
i--;
@@ -82,9 +82,9 @@ module.exports = {

if ((self) && (!isSave)) {
let syncer = this.syncer;
if (this.syncer) {
if (syncer) {
//Add things that have been queued by the syncer (that aren't tied to server-side components)
let components = this.syncer.oSelf.components
syncer.oSelf.components
.filter((c => !this[c.type]), this)
.forEach(c => s.components.push(c));
}
@@ -103,13 +103,13 @@ module.exports = {

for (let p in o) {
let value = o[p];
if (value == null)
if (value === null)
continue;

let type = typeof (value);

//build component
if (type == 'object') {
if (type === 'object') {
if (value.type) {
if (!value.simplify) {
if (self) {
@@ -140,7 +140,7 @@ module.exports = {
}
} else if (syncTypes.indexOf(p) > -1)
result[p] = value;
} else if (type != 'function')
} else if (type !== 'function')
result[p] = value;
}

@@ -180,13 +180,13 @@ module.exports = {
this.actionQueue.push(action);
},
dequeue: function () {
if (this.actionQueue.length == 0)
if (this.actionQueue.length === 0)
return null;

return this.actionQueue.splice(0, 1)[0];
},
clearQueue: function () {
if (this.serverId != null) {
if (this.serverId !== null) {
this.instance.syncer.queue('onClearQueue', {
id: this.id
}, [this.serverId]);
@@ -215,8 +215,8 @@ module.exports = {
if (!q)
return;

if (q.action == 'move') {
if ((this.actionQueue[0]) && (this.actionQueue[0].action == 'move')) {
if (q.action === 'move') {
if ((this.actionQueue[0]) && (this.actionQueue[0].action === 'move')) {
let sprintChance = this.stats.values.sprintChance || 0;
let physics = this.instance.physics;
if ((~~(Math.random() * 100) < sprintChance) && (!physics.isTileBlocking(q.data.x, q.data.y))) {
@@ -227,9 +227,9 @@ module.exports = {
let success = this.performMove(q);
if (!success)
this.clearQueue();
} else if (q.action == 'clearQueue')
} else if (q.action === 'clearQueue')
this.clearQueue();
else if (q.action == 'spell') {
else if (q.action === 'spell') {
let success = this.spellbook.cast(q);
if (!success)
this.performQueue();
@@ -245,7 +245,7 @@ module.exports = {

data.success = true;
this.fireEvent('beforeMove', data);
if (data.success == false) {
if (data.success === false) {
action.priority = true;
this.queue(action);
return true;
@@ -261,8 +261,8 @@ module.exports = {
(deltaY > maxDistance)
) ||
(
(deltaX == 0) &&
(deltaY == 0)
(deltaX === 0) &&
(deltaY === 0)
)
)
return false;
@@ -297,10 +297,10 @@ module.exports = {
},

collisionEnter: function (obj) {
let components = this.components;
let cLen = components.length;
let cpns = this.components;
let cLen = cpns.length;
for (let i = 0; i < cLen; i++) {
let c = components[i];
let c = cpns[i];
if (c.collisionEnter) {
if (c.collisionEnter(obj))
return true;
@@ -308,10 +308,10 @@ module.exports = {
}
},
collisionExit: function (obj) {
let components = this.components;
let cLen = components.length;
let cpns = this.components;
let cLen = cpns.length;
for (let i = 0; i < cLen; i++) {
let c = components[i];
let c = cpns[i];
if (c.collisionExit)
c.collisionExit(obj);
}
@@ -320,10 +320,10 @@ module.exports = {
fireEvent: function (event) {
let args = [].slice.call(arguments, 1);

let components = this.components;
let cLen = components.length;
let cpns = this.components;
let cLen = cpns.length;
for (let i = 0; i < cLen; i++) {
let cpn = components[i];
let cpn = cpns[i];
let events = cpn.events;
if (!events)
continue;
@@ -348,14 +348,14 @@ module.exports = {
},

destroy: function () {
let components = this.components;
let len = components.length;
let cpns = this.components;
let len = cpns.length;
for (let i = 0; i < len; i++) {
let c = components[i];
let c = cpns[i];
if (c.destroy)
c.destroy();
}

components = null;
this.components = null;
}
};

+ 12
- 11
src/server/objects/objects.js View File

@@ -85,7 +85,7 @@ module.exports = {
let properties = extend(true, {}, l.properties);
['cpnMob'].forEach(function (c) {
let blueprint = properties[c] || null;
if ((blueprint) && (typeof (blueprint) == 'string'))
if ((blueprint) && (typeof (blueprint) === 'string'))
blueprint = JSON.parse(blueprint);

if (!blueprint)
@@ -99,7 +99,7 @@ module.exports = {
}, this);

for (let p in properties) {
if (p.indexOf('cpn') == -1) {
if (p.indexOf('cpn') === -1) {
obj[p] = properties[p];
continue;
}
@@ -107,7 +107,7 @@ module.exports = {
let type = p.replace('cpn', '');
type = type[0].toLowerCase() + type.substr(1);
let blueprint = properties[p] || null;
if ((blueprint) && (typeof (blueprint) == 'string'))
if ((blueprint) && (typeof (blueprint) === 'string'))
blueprint = JSON.parse(blueprint);

obj.addComponent(type, blueprint);
@@ -134,7 +134,7 @@ module.exports = {
if (obj.aggro)
obj.aggro.move();

if (lLen == 1)
if (lLen === 1)
return obj;
}
},
@@ -151,9 +151,9 @@ module.exports = {
let o = objects[i];
let match = false;
if (useServerId)
match = (o.serverId == obj.id);
match = (o.serverId === obj.id);
else
match = (o.id == obj.id);
match = (o.id === obj.id);

if (match) {
o.destroy();
@@ -171,7 +171,8 @@ module.exports = {
physics.removeRegion(found);
}

callback && callback(found);
if (callback)
callback(found);
},

addObject: function (o, callback) {
@@ -204,7 +205,7 @@ module.exports = {
return newO;
},
sendEvent: function (msg) {
let player = this.objects.find(p => p.id == msg.id);
let player = this.objects.find(p => p.id === msg.id);
if (!player)
return;

@@ -227,7 +228,7 @@ module.exports = {

let obj = eventEntry.obj;

if (e != 'serverModule') {
if (e !== 'serverModule') {
let to = eventEntry.to;
let toLen = to.length;
for (let i = 0; i < toLen; i++) {
@@ -235,7 +236,7 @@ module.exports = {

let player = players[toId];
if (!player) {
let findPlayer = objects.find(o => o.id == toId);
let findPlayer = objects.find(o => o.id === toId);
if (!findPlayer)
continue;
else {
@@ -260,7 +261,7 @@ module.exports = {
}
},
updateObject: function (msg) {
let player = this.objects.find(p => p.id == msg.serverId);
let player = this.objects.find(p => p.id === msg.serverId);
if (!player)
return;



+ 14
- 14
src/server/security/connections.js View File

@@ -12,14 +12,14 @@ module.exports = {
this.players.push(p);
},
onDisconnect: function (socket) {
let player = this.players.find(p => p.socket.id == socket.id);
let player = this.players.find(p => p.socket.id === socket.id);

if (!player)
return;

let sessionDuration = 0;

if (player.id != null) {
if (player.id !== null) {
if (player.social)
player.social.dc();
sessionDuration = ~~(((+new Date()) - player.player.sessionStart) / 1000);
@@ -44,21 +44,21 @@ module.exports = {
});
}

this.players.spliceWhere(p => p.socket.id == socket.id);
this.players.spliceWhere(p => p.socket.id === socket.id);
},
route: function (socket, msg) {
let player = null;

if (msg.id != null) {
player = this.players.find(p => p.id == msg.id);
let source = this.players.find(p => p.socket.id == socket.id);
if (msg.id !== null) {
player = this.players.find(p => p.id === msg.id);
let source = this.players.find(p => p.socket.id === socket.id);
if (!source)
return;
if (!msg.data)
msg.data = {};
msg.data.sourceId = source.id;
} else
player = this.players.find(p => p.socket.id == socket.id);
player = this.players.find(p => p.socket.id === socket.id);

if (
(!player) ||
@@ -68,7 +68,7 @@ module.exports = {
) ||
(
(player.dead) &&
(msg.data.method != 'respawn')
(msg.data.method !== 'respawn')
)
)
return;
@@ -82,7 +82,7 @@ module.exports = {
},
unzone: function (msg) {
let socket = msg.socket;
let player = this.players.find(p => p.socket.id == socket.id);
let player = this.players.find(p => p.socket.id === socket.id);

if (!player)
return;
@@ -94,9 +94,9 @@ module.exports = {
let keys = Object.keys(player);
keys.forEach(function (k) {
let val = player[k];
if ((val != null) && (typeof (val) == 'object') && (val.type)) {
if ((val !== null) && (typeof (val) === 'object') && (val.type)) {
let type = val.type;
if ((type != 'player') && (type != 'auth') && (type != 'syncer'))
if ((type !== 'player') && (type !== 'auth') && (type !== 'syncer'))
delete player[k];
}
});
@@ -124,15 +124,15 @@ module.exports = {
for (let i = 0; i < pLen; i++) {
let p = players[i];

if ((!p) || (p == exclude) || (!p.auth))
if ((!p) || (p === exclude) || (!p.auth))
continue;

if (p.auth.username == exclude.auth.username)
if (p.auth.username === exclude.auth.username)
p.socket.emit('dc', {});
}
},

getCharacterList: function (msg) {
getCharacterList: function () {
let result = [];
let players = this.players;
let pLen = players.length;


Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save