Fix crafting algo. to avoid cycles #47

* Adjust recipes in Thermal Expansion to likewise avoid cycles
This commit is contained in:
Andrew Miner
2015-02-09 21:15:10 -08:00
parent e94b5b3d8d
commit 383bc5a904
2 changed files with 42 additions and 34 deletions
@@ -278,14 +278,6 @@ item: Copper Gear
tools: Crafting Table
item: Copper Ingot
recipe:
input: Pulverized Copper, furnace fuel
pattern: .0. ... .1.
tools: Furnace
recipe:
input: Pulverized Copper
pattern: ... .0. ...
tools: Redstone Furnace
recipe:
input: Copper Ore, furnace fuel
pattern: .0. ... .1.
@@ -294,6 +286,14 @@ item: Copper Ingot
input: Copper Ore
pattern: ... .0. ...
tools: Redstone Furnace
recipe:
input: Pulverized Copper, furnace fuel
pattern: .0. ... .1.
tools: Furnace
recipe:
input: Pulverized Copper
pattern: ... .0. ...
tools: Redstone Furnace
recipe:
extras: Gold Ingot
input: Cinnabar, Copper Ore
@@ -1089,14 +1089,6 @@ item: Lead Gear
tools: Crafting Table
item: Lead Ingot
recipe:
input: Pulverized Lead, furnace fuel
pattern: .0. ... .1.
tools: Furnace
recipe:
input: Pulverized Lead
pattern: ... .0. ...
tools: Redstone Furnace
recipe:
input: Lead Ore, furnace fuel
pattern: .0. ... .1.
@@ -1105,6 +1097,14 @@ item: Lead Ingot
input: Lead Ore
pattern: ... .0. ...
tools: Redstone Furnace
recipe:
input: Pulverized Lead, furnace fuel
pattern: .0. ... .1.
tools: Furnace
recipe:
input: Pulverized Lead
pattern: ... .0. ...
tools: Redstone Furnace
recipe:
extras: Silver Ingot
input: Cinnabar, Lead Ore
@@ -2031,14 +2031,6 @@ item: Silver Gear
tools: Crafting Table
item: Silver Ingot
recipe:
input: Pulverized Silver, furnace fuel
pattern: .0. ... .1.
tools: Furnace
recipe:
input: Pulverized Silver
pattern: ... .0. ...
tools: Redstone Furnace
recipe:
input: Silver Ore, furnace fuel
pattern: .0. ... .1.
@@ -2047,6 +2039,14 @@ item: Silver Ingot
input: Silver Ore
pattern: ... .0. ...
tools: Redstone Furnace
recipe:
input: Pulverized Silver, furnace fuel
pattern: .0. ... .1.
tools: Furnace
recipe:
input: Pulverized Silver
pattern: ... .0. ...
tools: Redstone Furnace
recipe:
extras: Lead Ingot
input: Cinnabar, Silver Ore
@@ -2149,14 +2149,6 @@ item: Tin Gear
tools: Crafting Table
item: Tin Ingot
recipe:
input: Pulverized Tin, furnace fuel
pattern: .0. ... .1.
tools: Furnace
recipe:
input: Pulverized Tin
pattern: ... .0. ...
tools: Redstone Furnace
recipe:
input: Tin Ore, furnace fuel
pattern: .0. ... .1.
@@ -2165,6 +2157,14 @@ item: Tin Ingot
input: Tin Ore
pattern: ... .0. ...
tools: Redstone Furnace
recipe:
input: Pulverized Tin, furnace fuel
pattern: .0. ... .1.
tools: Furnace
recipe:
input: Pulverized Tin
pattern: ... .0. ...
tools: Redstone Furnace
recipe:
extras: Iron Ingot
input: Cinnabar, Tin Ore
+10 -2
View File
@@ -47,9 +47,11 @@ module.exports = class CraftingPlan extends BaseModel
@result.addInventory @have
@steps = {}
@_reservedSteps = {}
@want.each (stack)=>
@_findSteps stack.slug
@need.add stack.slug, stack.quantity
@_reservedSteps = null
@steps = _.values @steps
@_resolveNeeds()
@@ -89,7 +91,6 @@ module.exports = class CraftingPlan extends BaseModel
# Private Methods ##############################################################################
_addStep: (recipe)->
return if @_hasStep recipe.slug
logger.verbose "adding step: #{recipe.slug}"
@steps[recipe.slug] = recipe:recipe
@@ -97,6 +98,7 @@ module.exports = class CraftingPlan extends BaseModel
return item.getPrimaryRecipe()
_findSteps: (slug)->
logger.debug "finding steps for #{slug}"
item = @modPack.findItem slug
return unless item?
return unless item.isCraftable
@@ -109,13 +111,19 @@ module.exports = class CraftingPlan extends BaseModel
if not @_hasStep toolStack.slug
@_findSteps toolStack.slug
return if @_hasStep item.slug
logger.debug "reserving: #{item.slug}"
@_reservedSteps[item.slug] = recipe
for inputStack in recipe.input
@_findSteps inputStack.slug
@_addStep recipe
_hasStep: (slug)->
return @steps[slug]?
return true if @steps[slug]?
return true if @_reservedSteps[slug]?
return false
_removeExtraSteps: ->
result = (step for step in @steps when step.multiplier > 0)