Initial version of the new crafting table

This commit is contained in:
Andrew Miner
2015-01-08 11:03:43 -08:00
parent 9f79722378
commit 9424af9d84
26 changed files with 280 additions and 228 deletions
+20 -1
View File
@@ -16,7 +16,7 @@ module.exports = class Recipe extends BaseModel
if not attributes.input? then throw new Error 'attributes.input is required'
if not attributes.output? then throw new Error 'attributes.output is required'
attributes.pattern ?= (i for i in [0...attributes.input.length]).join('')
attributes.pattern ?= @_computeShapelessPattern attributes.input
attributes.tools ?= []
super attributes, options
@@ -24,6 +24,15 @@ module.exports = class Recipe extends BaseModel
# Public Methods ###############################################################################
getItemSlugAt: (index)->
patternDigit = @pattern[index]
return null unless patternDigit?
stack = @input[parseInt(patternDigit)]
return null unless stack?
return stack.itemSlug
make: (inventory, missing)->
for stack in @input
itemSlug = stack.itemSlug
@@ -71,3 +80,13 @@ module.exports = class Recipe extends BaseModel
result.push '}'
return result.join ''
# Private Methods ##############################################################################
_computeShapelessPattern: (input)->
result = []
for i in [0...input.length]
stack = input[i]
for j in [0...stack.quantity]
result.push "#{i}"
return result.join ''