@@ -119,21 +119,15 @@ 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', { | |||
id: obj.id, | |||
messages: [{ | |||
class: 'color-redA', | |||
message: 'The ' + key.name + ' disintegrates on use', | |||
type: 'info' | |||
}] | |||
}, [obj.serverId]); | |||
const message = `The ${key.name} disintegrates on use`; | |||
obj.social.notifySelf({ message }); | |||
} | |||
} | |||
@@ -89,14 +89,8 @@ module.exports = { | |||
}; | |||
obj.fireEvent('beforeEquipItem', equipMsg); | |||
if (!equipMsg.success) { | |||
obj.instance.syncer.queue('onGetMessages', { | |||
id: obj.id, | |||
messages: [{ | |||
class: 'color-redA', | |||
message: equipMsg.msg || 'you cannot equip that item', | |||
type: 'info' | |||
}] | |||
}, [obj.serverId]); | |||
const message = equipMsg.msg || 'you cannot equip that item'; | |||
obj.social.notifySelf({ message }); | |||
return; | |||
} | |||
@@ -154,14 +148,8 @@ module.exports = { | |||
if (!item) | |||
return; | |||
else if (!ignoreSpaceCheck && !inventory.hasSpace()) { | |||
obj.instance.syncer.queue('onGetMessages', { | |||
id: obj.id, | |||
messages: [{ | |||
class: 'color-redA', | |||
message: 'You do not have room in your inventory to unequip that item', | |||
type: 'info' | |||
}] | |||
}, [obj.serverId]); | |||
const message = 'You do not have room in your inventory to unequip that item'; | |||
obj.social.notifySelf({ message }); | |||
return; | |||
} | |||
@@ -277,14 +265,10 @@ module.exports = { | |||
level: `Your level is too low to equip your ${item.name}` | |||
})[errors[0]]; | |||
this.obj.instance.syncer.queue('onGetMessages', { | |||
id: this.obj.id, | |||
messages: [{ | |||
class: 'color-redA', | |||
message: message, | |||
type: 'rep' | |||
}] | |||
}, [this.obj.serverId]); | |||
this.obj.social.notifySelf({ | |||
message, | |||
type: 'rep' | |||
}); | |||
} | |||
}, this); | |||
}, | |||
@@ -308,14 +292,11 @@ module.exports = { | |||
if (findFaction.tier > tier) { | |||
this.unequip(itemId); | |||
this.obj.instance.syncer.queue('onGetMessages', { | |||
id: this.obj.id, | |||
messages: [{ | |||
class: 'color-redA', | |||
message: 'You unequip your ' + item.name + ' as it zaps you.', | |||
type: 'rep' | |||
}] | |||
}, [this.obj.serverId]); | |||
const message = `You unequip your ${item.name} as it zaps you.`; | |||
this.obj.social.notifySelf({ | |||
message, | |||
type: 'rep' | |||
}); | |||
} | |||
}, this); | |||
}, | |||
@@ -161,14 +161,8 @@ module.exports = { | |||
result = requestedBy.reputation.canEquipItem(item); | |||
if (!result) { | |||
requestedBy.instance.syncer.queue('onGetMessages', { | |||
id: requestedBy.id, | |||
messages: [{ | |||
class: 'color-redA', | |||
message: 'your reputation is too low to buy that item', | |||
type: 'info' | |||
}] | |||
}, [requestedBy.serverId]); | |||
const message = 'your reputation is too low to buy that item'; | |||
requestedBy.social.notifySelf({ message }); | |||
} | |||
return result; | |||
@@ -215,14 +215,8 @@ module.exports = { | |||
}; | |||
this.obj.fireEvent('beforeLearnAbility', learnMsg); | |||
if (!learnMsg.success) { | |||
this.obj.instance.syncer.queue('onGetMessages', { | |||
id: this.obj.id, | |||
messages: [{ | |||
class: 'color-redA', | |||
message: learnMsg.msg || 'you cannot learn that ability', | |||
type: 'info' | |||
}] | |||
}, [this.obj.serverId]); | |||
const message = learnMsg.msg || 'you cannot learn that ability'; | |||
this.obj.social.notifySelf({ message }); | |||
return; | |||
} | |||
@@ -365,15 +359,12 @@ module.exports = { | |||
this.getItem(material, true, false, false, true); | |||
messages.push({ | |||
class: 'q' + material.quality, | |||
className: 'q' + material.quality, | |||
message: 'salvage (' + material.name + ' x' + material.quantity + ')' | |||
}); | |||
} | |||
this.obj.instance.syncer.queue('onGetMessages', { | |||
id: this.obj.id, | |||
messages: messages | |||
}, [this.obj.serverId]); | |||
this.obj.social.notifySelfArray(messages); | |||
}, | |||
destroyItem: function (id, amount, force) { | |||
@@ -805,13 +796,6 @@ module.exports = { | |||
}, | |||
notifyNoBagSpace: function (message = 'Your bags are too full to loot any more items') { | |||
this.obj.instance.syncer.queue('onGetMessages', { | |||
id: this.obj.id, | |||
messages: [{ | |||
class: 'color-redA', | |||
message, | |||
type: 'info' | |||
}] | |||
}, [this.obj.serverId]); | |||
this.obj.social.notifySelf({ message }); | |||
} | |||
}; |
@@ -68,14 +68,7 @@ module.exports = async (cpnInv, itemId) => { | |||
effectEvent.call(obj, effectResult, item, effect); | |||
if (!effectResult.success) { | |||
obj.instance.syncer.queue('onGetMessages', { | |||
id: obj.id, | |||
messages: [{ | |||
class: 'color-redA', | |||
message: effectResult.errorMessage, | |||
type: 'info' | |||
}] | |||
}, [obj.serverId]); | |||
obj.social.notifySelf({ message: effectResult.errorMessage }); | |||
return; | |||
} | |||
@@ -121,14 +121,11 @@ module.exports = { | |||
if (gain < 0) | |||
action = 'lost'; | |||
this.obj.instance.syncer.queue('onGetMessages', { | |||
id: this.obj.id, | |||
messages: [{ | |||
class: (action === 'gained') ? 'color-greenB' : 'color-redA', | |||
message: 'you ' + action + ' ' + Math.abs(gain) + ' reputation with ' + blueprint.name, | |||
type: 'rep' | |||
}] | |||
}, [this.obj.serverId]); | |||
this.obj.social.notifySelf({ | |||
className: (action === 'gained') ? 'color-greenB' : 'color-redA', | |||
message: 'you ' + action + ' ' + Math.abs(gain) + ' reputation with ' + blueprint.name, | |||
type: 'rep' | |||
}); | |||
if (faction.tier !== oldTier) { | |||
this.sendMessage(blueprint.tiers[faction.tier].name, blueprint.name, (faction.tier > oldTier)); | |||
@@ -139,14 +136,11 @@ module.exports = { | |||
}, | |||
sendMessage: function (tierName, factionName, didIncrease) { | |||
this.obj.instance.syncer.queue('onGetMessages', { | |||
id: this.obj.id, | |||
messages: [{ | |||
class: didIncrease ? 'color-greenB' : 'color-redA', | |||
message: 'you are now ' + tierName + ' with ' + factionName, | |||
type: 'rep' | |||
}] | |||
}, [this.obj.serverId]); | |||
this.obj.social.notifySelf({ | |||
className: didIncrease ? 'color-greenB' : 'color-redA', | |||
message: 'you are now ' + tierName + ' with ' + factionName, | |||
type: 'rep' | |||
}); | |||
}, | |||
discoverFaction (factionId) { | |||
@@ -167,14 +161,11 @@ module.exports = { | |||
let tier = blueprint.tiers[this.calculateTier(factionId)].name.toLowerCase(); | |||
if (!blueprint.noGainRep) { | |||
this.obj.instance.syncer.queue('onGetMessages', { | |||
id: this.obj.id, | |||
messages: [{ | |||
class: 'q4', | |||
message: 'you are now ' + tier + ' with ' + blueprint.name, | |||
type: 'rep' | |||
}] | |||
}, [this.obj.serverId]); | |||
this.obj.social.notifySelf({ | |||
className: 'q4', | |||
message: 'you are now ' + tier + ' with ' + blueprint.name, | |||
type: 'rep' | |||
}); | |||
} | |||
this.syncFaction(factionId, true); | |||
@@ -69,14 +69,9 @@ module.exports = { | |||
else if (this.items.length >= this.maxItems) { | |||
let isStackable = this.items.some(stashedItem => item.name === stashedItem.name && (isItemStackable(stashedItem))); | |||
if (!isStackable) { | |||
this.obj.instance.syncer.queue('onGetMessages', { | |||
id: this.obj.id, | |||
messages: [{ | |||
class: 'color-redA', | |||
message: 'You do not have room in your stash to deposit that item', | |||
type: 'info' | |||
}] | |||
}, [this.obj.serverId]); | |||
const message = 'You do not have room in your stash to deposit that item'; | |||
this.obj.social.notifySelf({ message }); | |||
return; | |||
} | |||
} | |||
@@ -109,14 +104,8 @@ module.exports = { | |||
if (!item) | |||
return; | |||
else if (!this.obj.inventory.hasSpace(item)) { | |||
this.obj.instance.syncer.queue('onGetMessages', { | |||
id: this.obj.id, | |||
messages: [{ | |||
class: 'color-redA', | |||
message: 'You do not have room in your inventory to withdraw that item', | |||
type: 'info' | |||
}] | |||
}, [this.obj.serverId]); | |||
const message = 'You do not have room in your inventory to withdraw that item'; | |||
this.obj.social.notifySelf({ message }); | |||
return; | |||
} | |||
@@ -146,14 +135,8 @@ module.exports = { | |||
}); | |||
if (this.active && this.items.length > this.maxItems) { | |||
obj.instance.syncer.queue('onGetMessages', { | |||
id: this.obj.id, | |||
messages: [{ | |||
class: 'color-redA', | |||
message: `You have more than ${this.maxItems} items in your stash. In the next version (v0.3.1) you will lose all items that put you over the limit`, | |||
type: 'info' | |||
}] | |||
}, [obj.serverId]); | |||
const message = `You have more than ${this.maxItems} items in your stash. In the future, these items will be lost.`; | |||
obj.social.notifySelf({ message }); | |||
} | |||
}, | |||
@@ -15,13 +15,11 @@ module.exports = { | |||
this.obj.syncer.setArray(true, 'quests', 'obtainQuests', this.simplify(true)); | |||
if (!hideMessage) { | |||
this.obj.instance.syncer.queue('onGetMessages', { | |||
id: this.obj.id, | |||
messages: [{ | |||
class: 'color-yellowB', | |||
message: 'quest obtained (' + this.name + ')' | |||
}] | |||
}, [this.obj.serverId]); | |||
const message = `Quest obtained (${this.name})`; | |||
this.obj.social.notifySelf({ | |||
message, | |||
className: 'color-yellowB' | |||
}); | |||
} | |||
return true; | |||
@@ -33,13 +31,11 @@ module.exports = { | |||
if (this.oReady) | |||
this.oReady(); | |||
this.obj.instance.syncer.queue('onGetMessages', { | |||
id: this.obj.id, | |||
messages: [{ | |||
class: 'color-yellowB', | |||
message: 'quest ready for turn-in (' + this.name + ')' | |||
}] | |||
}, [this.obj.serverId]); | |||
const message = `Quest ready for turn-in (${this.name})`; | |||
this.obj.social.notifySelf({ | |||
message, | |||
className: 'color-yellowB' | |||
}); | |||
this.obj.syncer.setArray(true, 'quests', 'updateQuests', this.simplify(true)); | |||
}, | |||
@@ -48,27 +44,23 @@ module.exports = { | |||
if (this.oComplete) | |||
this.oComplete(); | |||
let obj = this.obj; | |||
const obj = this.obj; | |||
this.obj.instance.eventEmitter.emitNoSticky('beforeCompleteAutoquest', this, obj); | |||
obj.instance.eventEmitter.emitNoSticky('beforeCompleteAutoquest', this, obj); | |||
obj.instance.syncer.queue('onGetMessages', { | |||
id: obj.id, | |||
messages: [{ | |||
class: 'color-yellowB', | |||
message: 'quest completed (' + this.name + ')' | |||
}] | |||
}, [obj.serverId]); | |||
const message = `Quest completed (${this.name})`; | |||
obj.social.emitNoSticky({ | |||
message, | |||
className: 'color-yellowB' | |||
}); | |||
obj.syncer.setArray(true, 'quests', 'completeQuests', this.id); | |||
this.obj.instance.eventEmitter.emit('onCompleteQuest', this); | |||
obj.instance.eventEmitter.emit('onCompleteQuest', this); | |||
this.rewards.forEach(function (r) { | |||
this.obj.inventory.getItem(r); | |||
}, this); | |||
this.rewards.forEach(reward => obj.inventory.getItem(reward)); | |||
this.obj.stats.getXp(this.xp || 10, this.obj, this); | |||
obj.stats.getXp(this.xp || 10, obj, this); | |||
}, | |||
simplify: function (self) { | |||
@@ -82,14 +82,8 @@ module.exports = { | |||
}, | |||
sendMessage: function (player, msg) { | |||
msg = 'Only certain roles can ' + msg + ' at the moment'; | |||
player.instance.syncer.queue('onGetMessages', { | |||
id: player.id, | |||
messages: { | |||
class: 'color-redA', | |||
message: msg | |||
} | |||
}, [player.serverId]); | |||
const message = `Only certain roles can ${msg} at the moment`; | |||
player.social.notifySelf({ message }); | |||
} | |||
}; |
@@ -54,14 +54,10 @@ module.exports = { | |||
} | |||
} else { | |||
if ((r.msg) && (!sentMessages.some(s => (s === r.msg)))) { | |||
player.instance.syncer.queue('onGetMessages', { | |||
id: player.id, | |||
messages: [{ | |||
class: 'color-greenB', | |||
message: r.msg, | |||
type: 'info' | |||
}] | |||
}, [player.serverId]); | |||
player.social.notifySelf({ | |||
message: r.msg, | |||
className: 'color-greenB' | |||
}); | |||
sentMessages.push(r.msg); | |||
delete r.msg; | |||
@@ -125,14 +121,10 @@ module.exports = { | |||
} | |||
} else { | |||
if ((r.msg) && (!sentMessages.some(s => (s === r.msg)))) { | |||
player.instance.syncer.queue('onGetMessages', { | |||
id: player.id, | |||
messages: [{ | |||
class: 'color-greenB', | |||
message: r.msg, | |||
type: 'info' | |||
}] | |||
}, [player.serverId]); | |||
player.social.notifySelf({ | |||
message: r.msg, | |||
className: 'color-greenB' | |||
}); | |||
sentMessages.push(r.msg); | |||
delete r.msg; | |||
@@ -77,14 +77,10 @@ module.exports = { | |||
} | |||
} else { | |||
if ((r.msg) && (!sentMessages.some(s => (s === r.msg)))) { | |||
player.instance.syncer.queue('onGetMessages', { | |||
id: player.id, | |||
messages: [{ | |||
class: 'color-greenB', | |||
message: r.msg, | |||
type: 'info' | |||
}] | |||
}, [player.serverId]); | |||
player.social.notifySelf({ | |||
message: r.msg, | |||
className: 'color-greenB' | |||
}); | |||
sentMessages.push(r.msg); | |||
delete r.msg; | |||