Complete basic crafting functionality

This commit is contained in:
Andrew Miner
2014-12-24 19:17:37 -08:00
parent 3ea6a845c7
commit 1a84ce2e28
20 changed files with 427 additions and 90 deletions
+16
View File
@@ -19,6 +19,22 @@ module.exports = class Recipe extends BaseModel
Object.defineProperty this, 'name', get:-> @output[0].name
# Public Methods ###############################################################################
make: (inventory, missing)->
for item in @input
needed = item.quantity
while needed > 0
if inventory.hasAtLeast item.name
inventory.remove item.name
else
missing.add item.name
for item in @output
inventory.add item.name, item.quantity
return this
# Object Overrides #############################################################################
toString: ->