You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

41 rivejä
958 B

  1. let events = require('../../misc/events');
  2. const recipesAlchemy = require('./alchemy');
  3. const recipesCooking = require('./cooking');
  4. const recipesEtching = require('./etching');
  5. const recipesEnchanting = require('./enchanting');
  6. let recipes = {
  7. alchemy: [ ...recipesAlchemy ],
  8. cooking: [ ...recipesCooking ],
  9. etching: [ ...recipesEtching ],
  10. enchanting: [ ...recipesEnchanting ]
  11. };
  12. module.exports = {
  13. init: function () {
  14. events.emit('onBeforeGetRecipes', recipes);
  15. },
  16. getList: function (type, unlocked) {
  17. const useRecipes = recipes[type];
  18. if (!useRecipes)
  19. return [];
  20. return useRecipes
  21. .filter(r => {
  22. let hasUnlocked = (r.default !== false);
  23. if (!hasUnlocked)
  24. hasUnlocked = unlocked.some(u => u.profession === type && u.teaches === r.id);
  25. return hasUnlocked;
  26. })
  27. .map(r => r.name);
  28. },
  29. getRecipe: function (type, name) {
  30. let recipe = (recipes[type] || []).find(r => r.name === name);
  31. return recipe;
  32. }
  33. };