Fix algo. for compacting steps in a crafting plan
This commit is contained in:
@@ -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
|
|
||||||
|
|||||||
Reference in New Issue
Block a user