Fix algo. for compacting steps in a crafting plan

This commit is contained in:
Andrew Miner
2015-01-08 15:11:11 -08:00
parent 7954b86140
commit cf9a76df21
+8 -12
View File
@@ -76,18 +76,14 @@ module.exports = class CraftingTable extends BaseModel
# Private Methods ############################################################################## # Private Methods ##############################################################################
_compactSteps: -> _compactSteps: ->
@_steps = [] steps = {}
currentStep = null
for recipe in @plan.steps for recipe in @plan.steps
if currentStep? step = steps[recipe.name]
if currentStep.recipe.name is recipe.name if not step?
currentStep.multiplier += 1 steps[recipe.name] = multiplier:1, recipe:recipe
else else
currentStep = null step.multiplier += 1
if not currentStep @_steps = (step for name, step of steps)
currentStep = multiplier:1, recipe:recipe return this
@_steps.push currentStep
return @_steps