项目作者: gw2efficiency

项目描述 :
Nest an array of recipes into a tree
高级语言: JavaScript
项目地址: git://github.com/gw2efficiency/recipe-nesting.git
创建时间: 2016-02-29T17:37:45Z
项目社区:https://github.com/gw2efficiency/recipe-nesting

开源协议:MIT License

下载



recipe-nesting


Nest an array of crafting recipes into a tree.



Package Version



Build Status



Code Coverage



This is part of gw2efficiency. Please report all issues in the central repository.


Installation
Usage
Contributors
License


Installation

  1. yarn add @gw2efficiency/recipe-nesting

If you want to calculate the price of the tree generated from this, take a look at
@gw2efficiency/recipe-calculation.

Usage

  1. import { nestRecipes } from '@gw2efficiency/recipe-nesting'
  2. // Expects a list of crafting recipes in the API format. This needs to include at least
  3. // the recipe you want to transform and all sub-recipes including guild upgrade recipes.
  4. const recipes = [
  5. {
  6. type: 'Refinement',
  7. output_item_id: 19713,
  8. output_item_count: 1,
  9. min_rating: 75,
  10. time_to_craft_ms: 2000,
  11. disciplines: ['Artificer', 'Weaponsmith', 'Scribe', 'Huntsman'],
  12. flags: ['AutoLearned'],
  13. ingredients: [
  14. {
  15. item_id: 19726,
  16. count: 2,
  17. },
  18. ],
  19. id: 1,
  20. chat_link: '[&CQEAAAA=]',
  21. },
  22. // ...
  23. ]
  24. // This is a (optional) map of guild upgrade ids to item ids. This should only be used
  25. // for type == Decoration, and resolves all the basic decorations needed for Scribing.
  26. const decorationsToItemsMap = {
  27. 42: 1337,
  28. // ...
  29. }
  30. const nestedRecipes = nestRecipes(recipes, decorationsToItemsMap)
  31. // -> [
  32. // {
  33. // "id": 13243,
  34. // "quantity": 5,
  35. // "output": 1,
  36. // "components": [
  37. // {
  38. // "id": 19712,
  39. // "quantity": 2,
  40. // "output": 1,
  41. // "components": [
  42. // {
  43. // "id": 19725,
  44. // "quantity": 3
  45. // },
  46. // // ...
  47. // ]
  48. // },
  49. // // ...
  50. // ]
  51. // }
  52. // // ...
  53. // ]

Contributors

Thanks goes to these wonderful people (emoji key):






David Reeß

💻 📖 ⚠️

This project follows the all-contributors
specification. Contributions of any kind welcome!

License

MIT