Crafting.js 845 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. class Crafting {
  2. constructor() {
  3. }
  4. init() {
  5. this.recipes = [];
  6. this.recipes.push({
  7. id: 1,
  8. duration: 1000,
  9. ingredients: [{ name: "Scrap Metal", amount: 2 }, { name: "Hydrogen", amount: 1 }],
  10. results: [{ name: "Spare Part", type: "sparepart", amount: 1 }]
  11. });
  12. // this.recipes.push({
  13. // id: 2,
  14. // duration: 2000,
  15. // ingredients: [{ name: "Hydrogen", amount: 100 }],
  16. // results: [{ name: "Fuel", type: "fuel", amount: 1 }]
  17. // });
  18. }
  19. getAllRecipes() {
  20. return this.recipes;
  21. }
  22. getRecipe(recipeId) {
  23. return this.recipes.find((recipe) => recipe.id == recipeId);
  24. }
  25. enableRecipe(recipeName) {
  26. this.recipes.push({
  27. id: 2,
  28. duration: 2000,
  29. ingredients: [{ name: "Hydrogen", amount: 100 }],
  30. results: [{ name: "Fuel", type: "fuel", amount: 1 }]
  31. });
  32. game.playerHud.crafting.buildRecipes();
  33. }
  34. }