@@ -1,50 +0,0 @@ | |||||
module.exports = async ({ serverId, name }, { recipe: { profession, teaches } }) => { | |||||
const recipes = await io.getAsync({ | |||||
key: name, | |||||
table: 'recipes', | |||||
isArray: true | |||||
}); | |||||
const known = recipes.some(r => r.profession === profession && r.teaches === teaches); | |||||
if (known) { | |||||
process.send({ | |||||
method: 'events', | |||||
data: { | |||||
onGetAnnouncement: [{ | |||||
obj: { | |||||
msg: 'You already know that recipe' | |||||
}, | |||||
to: [serverId] | |||||
}] | |||||
} | |||||
}); | |||||
return false; | |||||
} | |||||
recipes.push({ | |||||
profession, | |||||
teaches | |||||
}); | |||||
await io.setAsync({ | |||||
key: name, | |||||
table: 'recipes', | |||||
value: recipes, | |||||
serialize: true | |||||
}); | |||||
process.send({ | |||||
method: 'events', | |||||
data: { | |||||
onGetAnnouncement: [{ | |||||
obj: { | |||||
msg: 'The recipe imprints itself in your mind, then vanishes' | |||||
}, | |||||
to: [serverId] | |||||
}] | |||||
} | |||||
}); | |||||
return true; | |||||
}; |
@@ -1,5 +1,3 @@ | |||||
const learnRecipe = require('./learnRecipe'); | |||||
const isOnCooldown = (obj, cpnInv, item) => { | const isOnCooldown = (obj, cpnInv, item) => { | ||||
if (item.cdMax) { | if (item.cdMax) { | ||||
if (item.cd) { | if (item.cd) { | ||||
@@ -38,17 +36,14 @@ module.exports = async (cpnInv, itemId) => { | |||||
if (isOnCooldown(obj, cpnInv, item)) | if (isOnCooldown(obj, cpnInv, item)) | ||||
return; | return; | ||||
let result = {}; | |||||
let result = { | |||||
ignore: false | |||||
}; | |||||
obj.instance.eventEmitter.emit('onBeforeUseItem', obj, item, result); | obj.instance.eventEmitter.emit('onBeforeUseItem', obj, item, result); | ||||
obj.fireEvent('onBeforeUseItem', item, result); | obj.fireEvent('onBeforeUseItem', item, result); | ||||
if (item.recipe) { | |||||
const didLearn = await learnRecipe(obj, item); | |||||
if (didLearn) | |||||
cpnInv.destroyItem(itemId, 1); | |||||
if (result.ignore) | |||||
return; | return; | ||||
} | |||||
let effects = (item.effects || []); | let effects = (item.effects || []); | ||||
let eLen = effects.length; | let eLen = effects.length; | ||||
@@ -1,4 +1,6 @@ | |||||
module.exports = [ | |||||
const events = require('../misc/events'); | |||||
const tableNames = [ | |||||
'character', | 'character', | ||||
'characterList', | 'characterList', | ||||
'stash', | 'stash', | ||||
@@ -11,6 +13,9 @@ module.exports = [ | |||||
'error', | 'error', | ||||
'modLog', | 'modLog', | ||||
'accountInfo', | 'accountInfo', | ||||
'mtxStash', | |||||
'recipes' | |||||
'mtxStash' | |||||
]; | ]; | ||||
events.emit('onBeforeGetTableNames', tableNames); | |||||
module.exports = tableNames; |