Browse Source

eslint fixes

tags/v0.2.1^2
big bad waffle 5 years ago
parent
commit
7c94fae495
39 changed files with 131 additions and 166 deletions
  1. +1
    -1
      .eslintrc
  2. +4
    -8
      src/server/components/aggro.js
  3. +3
    -6
      src/server/components/auth.js
  4. +1
    -1
      src/server/components/chest.js
  5. +0
    -1
      src/server/components/components.js
  6. +5
    -6
      src/server/components/dialogue.js
  7. +1
    -1
      src/server/components/door.js
  8. +3
    -3
      src/server/components/effects.js
  9. +16
    -22
      src/server/components/equipment.js
  10. +3
    -5
      src/server/components/gatherer.js
  11. +13
    -16
      src/server/components/inventory.js
  12. +4
    -4
      src/server/components/mob.js
  13. +2
    -4
      src/server/components/prophecies.js
  14. +3
    -5
      src/server/components/reputation.js
  15. +0
    -6
      src/server/components/social.js
  16. +8
    -8
      src/server/components/spellbook.js
  17. +5
    -5
      src/server/components/stats.js
  18. +1
    -1
      src/server/components/syncer.js
  19. +9
    -9
      src/server/components/trade.js
  20. +1
    -1
      src/server/components/wardrobe.js
  21. +3
    -3
      src/server/components/workbench.js
  22. +1
    -1
      src/server/config/eventPhases/phaseModifyDialogue.js
  23. +1
    -1
      src/server/config/quests/templates/questKillX.js
  24. +1
    -3
      src/server/config/spells/spellAura.js
  25. +2
    -4
      src/server/config/spells/spellProjectile.js
  26. +1
    -4
      src/server/config/spells/spellSmokeBomb.js
  27. +1
    -1
      src/server/config/spells/spellTemplate.js
  28. +1
    -1
      src/server/events/events.js
  29. +1
    -1
      src/server/index.js
  30. +1
    -1
      src/server/items/generators/quality.js
  31. +9
    -9
      src/server/items/generators/stats.js
  32. +1
    -1
      src/server/items/salvager.js
  33. +13
    -3
      src/server/misc/helpers.js
  34. +1
    -3
      src/server/misc/scheduler.js
  35. +4
    -8
      src/server/objects/objBase.js
  36. +1
    -1
      src/server/security/connections.js
  37. +1
    -3
      src/server/security/sheets.js
  38. +3
    -3
      src/server/world/atlas.js
  39. +2
    -2
      src/server/world/instancer.js

+ 1
- 1
.eslintrc View File

@@ -141,7 +141,7 @@
"no-path-concat": 2,
"no-process-exit": 1,
"brace-style": [2,"1tbs",{}],
"camelcase": [1,{"properties":"always"}],
"camelcase": [1,{"properties":"never"}],
"comma-spacing": [2,{"after":true}],
"comma-style": 2,
"eol-last": 2,


+ 4
- 8
src/server/components/aggro.js View File

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

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

if (this.physics.width > 0)
this.move();
else {
//HACK: Don't fire on main thread (no physics set up)
console.log('HACK: cpn/aggro');
}
},

events: {
@@ -144,7 +140,7 @@ module.exports = {
return false;

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

let rep = this.obj.reputation;
@@ -252,7 +248,7 @@ module.exports = {
if (l.obj !== obj)
continue;

if (amount == null) {
if (!amount) {
list.splice(i, 1);
obj.aggro.unAggro(this.obj);
break;
@@ -303,7 +299,7 @@ module.exports = {
if (this.ignoreList.some(o => o === obj))
continue;

if ((highest == null) || (l.threat > highest.threat)) {
if (!highest || 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) {


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

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

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

let character = this.characters[data.data.name];
@@ -167,7 +167,7 @@ module.exports = {
},

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

io.get({
@@ -204,9 +204,6 @@ module.exports = {
if (result) {
result = result.split('`').join('\'');
result = result.replace(/''+/g, '\'');
} else {
console.log('char not found');
console.log(data);
}

let character = JSON.parse(result || '{}');
@@ -267,7 +264,7 @@ module.exports = {

fixes.fixStash(this.stash);

if (this.skins != null) {
if (this.skins) {
this.verifySkin(character);
data.callback(character);
} else {


+ 1
- 1
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)
this.ownerId = blueprint.ownerId;

if (blueprint.ttl)


+ 0
- 1
src/server/components/components.js View File

@@ -1,6 +1,5 @@
let fileLister = require('../misc/fileLister');
let events = require('../misc/events');
let pathUtilities = require('path');
const componentBase = require('./componentBase');

let onReady = null;


+ 5
- 6
src/server/components/dialogue.js View File

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

let target = msg.target;

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

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

this.sourceStates[sourceObj.id] = state;

if (!this.states) {
console.log(sourceObj.name, this.obj.name, state);
if (!this.states)
return null;
}
let stateConfig = this.states[state];
if (!stateConfig)
return null;


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

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

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

let obj = this.obj.instance.objects.objects.find(o => o.serverId === msg.sourceId);


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

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

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

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

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

let ccResistances = this.ccResistances;


+ 16
- 22
src/server/components/equipment.js View File

@@ -37,8 +37,7 @@ module.exports = {
return;
}

let currentEqId = this.eq[item.slot];
if (currentEqId == null) {
if (!this.eq.has(item.slot)) {
this.equip(itemId);
return true;
}
@@ -62,17 +61,15 @@ module.exports = {
if (!slot)
slot = item.equipSlot || item.slot;
if (slot === 'twoHanded') {
let offHandEqId = this.eq.offHand;
if (offHandEqId != null)
this.unequip(offHandEqId);
if (this.eq.has('offHand'))
this.unequip(this.eq.offHand);

slot = 'oneHanded';
} else if (slot === 'offHand') {
let oneHandedEqId = this.eq.oneHanded;
if (oneHandedEqId != null) {
let oneHandedEq = this.obj.inventory.findItem(oneHandedEqId);
if (oneHandedEq && oneHandedEq.slot === 'twoHanded')
this.unequip(oneHandedEqId);
if (this.eq.has('oneHanded')) {
let oneHandedEq = this.obj.inventory.findItem(this.eq.oneHanded);
if (oneHandedEq.slot === 'twoHanded')
this.unequip(this.eq.oneHanded);
}
}

@@ -98,8 +95,8 @@ module.exports = {
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);
let f1 = (this.eq.has('finger-1'));
let f2 = (this.eq.has('finger-2'));

if ((f1) && (f2))
slot = 'finger-1';
@@ -109,12 +106,12 @@ module.exports = {
slot = 'finger-2';
}

let currentEqId = this.eq[slot];
let currentEq = this.obj.inventory.findItem(currentEqId);
if (currentEq === item)
return;
if (currentEqId != null)
this.unequip(currentEqId);
if (this.eq.has(slot)) {
if (this.eq[slot].id === item.id)
return;
this.unequip(this.eq[slot].id);
}

let stats = item.stats;
for (let s in stats) {
@@ -177,7 +174,7 @@ module.exports = {
if (typeof (itemId) === 'object')
itemId = itemId.itemId;

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

if (!item)
@@ -267,9 +264,6 @@ module.exports = {

item.quickSlot = msg.slot;
obj.syncer.setArray(true, 'inventory', 'getItems', item);

console.log(item);
console.log(this.quickSlots);
},

unequipAttrRqrGear: function () {


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

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

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

let nodes = this.nodes;
@@ -223,8 +223,7 @@ module.exports = {
}[nodeType]);

if (nodeType === 'fish') {
let rod = this.obj.equipment.eq.tool;
if (rod == null)
if (!this.obj.equipment.eq.has('tool'))
msg = 'You need a fishing rod to fish';
}

@@ -280,8 +279,7 @@ module.exports = {
continue;

if (node.resourceNode.nodeType === 'fish') {
let rod = this.obj.equipment.eq.tool;
if (rod == null) {
if (!this.obj.equipment.eq.has('tool')) {
process.send({
method: 'events',
data: {


+ 13
- 16
src/server/components/inventory.js View File

@@ -23,8 +23,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.has('spellId') ? ~~a.spellId : 9999;
let bId = b.has('spellId') ? ~~b.spellId : 9999;
return (aId - bId);
});

@@ -98,9 +98,6 @@ module.exports = {
if (factionTier < f.tier)
noEquip = true;

if (!faction)
console.log(f);

return {
id: f.id,
name: faction.name,
@@ -152,7 +149,7 @@ module.exports = {
},

learnAbility: function (itemId, runeSlot) {
if (itemId.itemId != null) {
if (itemId.has('itemId')) {
let msg = itemId;
itemId = msg.itemId;
runeSlot = msg.slot;
@@ -192,7 +189,7 @@ module.exports = {

if ((item.slot === 'twoHanded') || (item.slot === 'oneHanded'))
runeSlot = 0;
else if (runeSlot == null) {
else if (!runeSlot) {
runeSlot = 4;
for (let i = 1; i <= 4; i++) {
if (!this.items.some(j => (j.runeSlot === i))) {
@@ -308,7 +305,7 @@ module.exports = {
},

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

let item = this.findItem(itemId);
@@ -494,7 +491,7 @@ module.exports = {
});
}

if ((item.pos == null) && (!item.eq)) {
if (!item.has('pos') && !item.eq) {
let pos = i;
for (let j = 0; j < iLen; j++) {
if (!items.some(fj => (fj.pos === j))) {
@@ -531,10 +528,10 @@ module.exports = {
},

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

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

process.send({
@@ -548,7 +545,7 @@ module.exports = {
},

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

return this.items.find(i => i.id === id);
@@ -559,7 +556,7 @@ module.exports = {
return (
(i.spell) &&
(i.spell.rolls) &&
(i.spell.rolls.damage != null) &&
(i.spell.rolls.has('damage')) &&
((i.slot === 'twoHanded') || (i.slot === 'oneHanded'))
);
});
@@ -597,7 +594,7 @@ module.exports = {
},

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

let bagCell = 50;
@@ -654,7 +651,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.has('quality'))
item.quality = 0;

//Players can't have fromMob items in their inventory but bags can (dropped by a mob)
@@ -711,7 +708,7 @@ module.exports = {
if (item.eq)
delete item.pos;

if ((item.pos == null) && (!item.eq)) {
if (!item.has('pos') && !item.eq) {
let pos = iLen;
for (let i = 0; i < iLen; i++) {
if (!items.some(fi => (fi.pos === i))) {


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

@@ -137,7 +137,7 @@ module.exports = {
target: target
});
//null means we don't have LoS
if (success != null)
if (success !== null)
return;
hasLos = false;
} else
@@ -156,17 +156,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);


+ 2
- 4
src/server/components/prophecies.js View File

@@ -8,11 +8,9 @@ module.exports = {
let template = null;
try {
template = require('../config/prophecies/' + p);
} catch (e) {
console.log(e);
}
} catch (e) {}

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


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

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

if (factionBlueprint == null) {
console.log('No faction blueprint found');
if (!factionBlueprint)
return;
}

factionBlueprint = extend(true, {}, factionBase, factionBlueprint);

@@ -100,7 +98,7 @@ module.exports = {
},

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

let faction = this.list.find(l => l.id === factionId);
@@ -154,7 +152,7 @@ module.exports = {
if (this.list.some(l => l.id === factionId))
return;

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

if (!blueprint)


+ 0
- 6
src/server/components/social.js View File

@@ -341,12 +341,6 @@ module.exports = {
party = null;
}

if (!player) {
console.log('no player');
console.log(this.party);
console.log(this.obj.name);
}

player.socket.emit('events', {
onGetParty: [party],
onGetMessages: [{


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

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

this.dmgMult = blueprint.dmgMult;

(blueprint.spells || []).forEach(s => this.addSpell(s));
(blueprint.spells || []).forEach(s => this.addSpell(s, -1));

delete blueprint.spells;
},
@@ -33,7 +33,7 @@ module.exports = {
this.spells = [];

spells.forEach(function (s) {
this.addSpell(s);
this.addSpell(s, -1);
}, this);
},

@@ -119,7 +119,7 @@ module.exports = {
if ((this.furthestRange === -1) || (builtSpell.range > this.furthestRange))
this.furthestRange = builtSpell.range;

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

builtSpell.id = (options.id == null) ? spellId : options.id;
builtSpell.id = !options.has('id') ? spellId : options.id;
this.spells.push(builtSpell);
this.spells.sort(function (a, b) {
return (a.id - b.id);
@@ -242,7 +242,7 @@ module.exports = {
return null;
},
cast: function (action, isAuto) {
if (action.spell == null) {
if (!action.has('spell')) {
this.auto = [];
return true;
}
@@ -265,7 +265,7 @@ module.exports = {

if ((!spell.aura) && (!spell.targetGround)) {
//Did we pass in the target id?
if ((action.target != null) && (action.target.id == null)) {
if (action.target && !action.target.id) {
action.target = this.objects.objects.find(o => o.id === action.target);
if (!action.target)
return false;
@@ -274,7 +274,7 @@ module.exports = {
if ((action.target === this.obj) && (spell.noTargetSelf))
action.target = null;

if ((action.target == null) || (!action.target.player)) {
if (!action.target || !action.target.player) {
if (spell.autoTargetFollower) {
action.target = this.spells.find(s => (s.minions) && (s.minions.length > 0));
if (action.target)
@@ -323,7 +323,7 @@ module.exports = {
} else
this.obj.stats.addStat('manaReservePercent', -reserve.percentage);
}
} else if (spell.range != null) {
} else if (spell.has('range')) {
let distance = Math.max(Math.abs(action.target.x - this.obj.x), Math.abs(action.target.y - this.obj.y));
let range = spell.range;
if ((spell.useWeaponRange) && (this.obj.player)) {


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

@@ -476,9 +476,9 @@ module.exports = {

this.values.hp -= amount;
let recipients = [];
if (this.obj.serverId != null)
if (this.obj.serverId)
recipients.push(this.obj.serverId);
if (source.serverId != null)
if (source.serverId)
recipients.push(source.serverId);
if ((source.follower) && (source.follower.master.serverId))
recipients.push(source.follower.master.serverId);
@@ -566,7 +566,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))
continue;

this.obj.inventory.dropBag(a.obj.serverId, killSource);
@@ -606,9 +606,9 @@ module.exports = {
values.hp = hpMax;

let recipients = [];
if (this.obj.serverId != null)
if (this.obj.serverId)
recipients.push(this.obj.serverId);
if (source.serverId != null)
if (source.serverId)
recipients.push(source.serverId);
if (recipients.length > 0) {
this.syncer.queue('onGetDamage', {


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

@@ -98,7 +98,7 @@ module.exports = {
if (self)
o = this.oSelf;

if (o[property] == null)
if (!o.has(property))
o[property] = [];

o[property].push(value);


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

@@ -78,12 +78,12 @@ module.exports = {
},

startBuy: function (msg) {
let target = msg.target;

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

if ((target != null) && (target.id == null))
let target = msg.target;

if (target && !target.id)
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())));
@@ -276,12 +276,12 @@ module.exports = {
let target = msg.target;
let targetName = (msg.targetName || '').toLowerCase();

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

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

this.target = null;
@@ -380,10 +380,10 @@ module.exports = {
},

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

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

process.send({


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

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

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

let obj = this.obj.instance.objects.objects.find(o => o.serverId === msg.sourceId);


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

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

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

let obj = this.obj.instance.objects.objects.find(o => o.serverId === msg.sourceId);
@@ -157,10 +157,10 @@ module.exports = {
},

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

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

process.send({


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

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

if (!target)
continue;
else if (source == null) {
else if (!source) {
delete dialogue[s];
continue;
}


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

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


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

@@ -78,10 +78,8 @@ module.exports = {
if (effect)
return;

if (!obj.effects) {
console.log('No Effects ', obj.name);
if (!obj.effects)
return;
}

effects[obj.serverId] = obj.effects.addEffect({
type: this.effect,


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

@@ -99,11 +99,9 @@ module.exports = {

let damage = this.getDamage(target);

if (!target.stats) {
console.log('has no stats???');
console.log(target);
if (!target.stats)
return;
}

target.stats.takeDamage(damage, this.threatMult, this.obj);
}
};

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

@@ -36,10 +36,7 @@ let cpnSmokePatch = {
for (let i = 0; i < contents.length; i++) {
let c = contents[i];

if (!c) {
console.log('NO SMOKEBOMB TARGET');
console.log(this.obj.name, this.obj.x, this.obj.y);
} else {
if (c) {
let damage = this.getDamage(c);
this.applyDamage(c, damage);
}


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

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


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

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

if (n.desc != null) {
if (n.has('desc')) {
event.config.descTimer = n.desc;
this.setEventDescription(event.config.name);
}


+ 1
- 1
src/server/index.js View File

@@ -51,11 +51,11 @@ let startup = {
},

onError: function (e) {
console.log(e);
if (e.toString().indexOf('ERR_IPC_CHANNEL_CLOSED') > -1)
return;

console.log('Error Logged: ' + e.toString());
console.log(e.stack);

io.set({
ent: new Date(),


+ 1
- 1
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.has('quality')) {
item.quality = ~~blueprint.quality;
return;
}


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

@@ -7,7 +7,7 @@ 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);
},
@@ -21,7 +21,7 @@ module.exports = {

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);
},
@@ -35,7 +35,7 @@ module.exports = {

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);
},
@@ -49,7 +49,7 @@ module.exports = {

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);
},
@@ -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,7 +74,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.armor;
return (min + ((max - min) * perfection)) * (blueprint.statMult.armor || 1);
},
@@ -85,7 +85,7 @@ module.exports = {

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);
},
@@ -98,7 +98,7 @@ module.exports = {

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);
}


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

@@ -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.has('quality'))
newItem.quality = m.quality;

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


+ 13
- 3
src/server/misc/helpers.js View File

@@ -1,4 +1,7 @@
Object.defineProperty(Array.prototype, 'firstIndex', {
//Hack to bypass eslint
let Obj = Object;

Obj.defineProperty(Array.prototype, 'firstIndex', {
enumerable: false,
value: function (callback, thisArg) {
let T = thisArg;
@@ -23,7 +26,7 @@ Object.defineProperty(Array.prototype, 'firstIndex', {
}
});

Object.defineProperty(Array.prototype, 'spliceWhere', {
Obj.defineProperty(Array.prototype, 'spliceWhere', {
enumerable: false,
value: function (callback, thisArg) {
let T = thisArg;
@@ -48,7 +51,7 @@ Object.defineProperty(Array.prototype, 'spliceWhere', {
}
});

Object.defineProperty(Array.prototype, 'spliceFirstWhere', {
Obj.defineProperty(Array.prototype, 'spliceFirstWhere', {
enumerable: false,
value: function (callback, thisArg) {
let T = thisArg;
@@ -72,6 +75,13 @@ Object.defineProperty(Array.prototype, 'spliceFirstWhere', {
}
}
});

Obj.defineProperty(Object.prototype, 'has', {
enumerable: false,
value: function (prop) {
return (this.hasOwnProperty(prop) && this[prop] !== null);
}
});
module.exports = {
get2dArray: function (w, h, def) {


+ 1
- 3
src/server/misc/scheduler.js View File

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

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

let lastTime = this.lastTime;
let time = this.getTime();


+ 4
- 8
src/server/objects/objBase.js View File

@@ -22,7 +22,7 @@ module.exports = {
this[cpn.type] = cpn;
}

if ((cpn.init) && (this.instance != null))
if (cpn.init && this.has('instance'))
cpn.init(blueprint || {}, isTransfer);
else {
for (let p in blueprint)
@@ -103,7 +103,7 @@ module.exports = {

for (let p in o) {
let value = o[p];
if (value == null)
if (value === null)
continue;

let type = typeof (value);
@@ -186,7 +186,7 @@ module.exports = {
return this.actionQueue.splice(0, 1)[0];
},
clearQueue: function () {
if (this.serverId != null) {
if (this.has('serverId')) {
this.instance.syncer.queue('onClearQueue', {
id: this.id
}, [this.serverId]);
@@ -196,12 +196,8 @@ module.exports = {
},

performAction: function (action) {
if (action.instanceModule) {
/*action.data.obj = this;
this.instance[action.instanceModule][action.method](action.data);
this.inventory.resolveCallback(action.data, action.data.result);*/
if (action.instanceModule)
return;
}

let cpn = this[action.cpn];
if (!cpn)


+ 1
- 1
src/server/security/connections.js View File

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

let sessionDuration = 0;

if (player.id != null) {
if (player.has('id')) {
if (player.social)
player.social.dc();
sessionDuration = ~~(((+new Date()) - player.player.sessionStart) / 1000);


+ 1
- 3
src/server/security/sheets.js View File

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

this.records = records;
} catch (e) {
console.log('Sheets in error state');
}
} catch (e) {}
}

setTimeout(this.update.bind(this), 300000);


+ 3
- 3
src/server/world/atlas.js View File

@@ -6,7 +6,7 @@ let serverConfig = require('../config/serverConfig');

module.exports = {
nextId: 0,
nextCallbackId: 0,
lastCallbackId: 0,
threads: [],
callbacks: [],

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

registerCallback: function (callback) {
this.callbacks.push({
id: this.nextCallbackId++,
id: ++this.nextCallbackId,
callback: callback
});

return this.nextCallbackId - 1;
return this.nextCallbackId;
},
resolveCallback: function (msg) {
let callback = this.callbacks.spliceFirstWhere(c => c.id === msg.msg.id);


+ 2
- 2
src/server/world/instancer.js View File

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

let spawnPos = map.getSpawnPos(obj);

if ((!msg.keepPos) || (obj.x == null)) {
if (!msg.keepPos || !obj.has('x')) {
obj.x = spawnPos.x;
obj.y = spawnPos.y;
}
@@ -310,7 +310,7 @@ module.exports = {
if (exists)
spawnPos = exists.map.getSpawnPos(obj);

if ((!msg.keepPos) || (obj.x == null)) {
if (!msg.keepPos || !obj.has('x')) {
obj.x = spawnPos.x;
obj.y = spawnPos.y;
}


Loading…
Cancel
Save