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.
 
 
 

39 lines
868 B

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