From ba83e8d205f6d57c75d89c622e498dd194ec281a Mon Sep 17 00:00:00 2001 From: Andrew Miner Date: Mon, 19 Aug 2013 23:05:26 -0700 Subject: [PATCH] [#14] Add list of crafted items * This is step toward implementing #14 in that it shows you a list of the items which need to be crafted. However, it still doesn't show you the steps and proper order in which to craft everything. --- html/crafting.js | 10 +++++++--- html/index.html | 11 +++++++++-- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/html/crafting.js b/html/crafting.js index e625c7dde..1cfc97993 100644 --- a/html/crafting.js +++ b/html/crafting.js @@ -38,13 +38,15 @@ function onCraftingSelectorChanged() { $("#crafting_error").fadeIn(FADE_DURATION).delay(ERROR_DISPLAY_DURATION).fadeOut(FADE_DURATION); } else { var inventory = createManifest(); + var craftedItems = createManifest(); var missingMaterials = createManifest(); for (var i = 0; i < count; i++) { - recipe.craft(inventory, missingMaterials); + recipe.craft(inventory, craftedItems, missingMaterials); if (inventory.contains(count, recipeName)) break; } $("#missing_materials").html(missingMaterials.toHtml()); + $("#crafted_items").html(craftedItems.toHtml()); $("#leftover_materials").html(inventory.toHtml()); $("#crafting_output").fadeIn(FADE_DURATION); } @@ -209,8 +211,9 @@ function createRecipe(data) { // Methods //////////////////////////////////////////// - object.craft = function(inventory, missingMaterials) { + object.craft = function(inventory, craftedItems, missingMaterials) { if (inventory === undefined) inventory = createManifest(); + if (craftedItems === undefined) craftedItems = createManifest(); if (missingMaterials === undefined) missingMaterials = createManifest(); var toCraftManifest = createManifest(); @@ -230,7 +233,7 @@ function createRecipe(data) { inventory.add(1, name); } } else { - itemRecipe.craft(inventory, missingMaterials); + itemRecipe.craft(inventory, craftedItems, missingMaterials); if (consumeItems) { inventory.remove(1, name); } @@ -255,6 +258,7 @@ function createRecipe(data) { drainCraftingManifest(false); $(object.output).each(function(i, output) { + craftedItems.add(output.count, output.name); inventory.add(output.count, output.name); }); }; diff --git a/html/index.html b/html/index.html index b7fcb50c8..3a1acd515 100644 --- a/html/index.html +++ b/html/index.html @@ -45,8 +45,15 @@

- - + + + + + + + + +