@@ -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, | |||
@@ -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) { | |||
@@ -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 { | |||
@@ -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) | |||
@@ -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; | |||
@@ -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; | |||
@@ -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); | |||
@@ -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; | |||
@@ -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 () { | |||
@@ -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: { | |||
@@ -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))) { | |||
@@ -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); | |||
@@ -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; | |||
@@ -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) | |||
@@ -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: [{ | |||
@@ -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)) { | |||
@@ -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', { | |||
@@ -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); | |||
@@ -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({ | |||
@@ -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); | |||
@@ -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({ | |||
@@ -30,7 +30,7 @@ module.exports = { | |||
if (!target) | |||
continue; | |||
else if (source == null) { | |||
else if (!source) { | |||
delete dialogue[s]; | |||
continue; | |||
} | |||
@@ -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) | |||
@@ -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, | |||
@@ -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); | |||
} | |||
}; |
@@ -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); | |||
} | |||
@@ -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); | |||
@@ -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); | |||
} | |||
@@ -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(), | |||
@@ -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; | |||
} | |||
@@ -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); | |||
} | |||
@@ -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; | |||
@@ -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) { | |||
@@ -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(); | |||
@@ -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) | |||
@@ -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); | |||
@@ -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); | |||
@@ -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); | |||
@@ -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; | |||
} | |||