Further fixes of how passthrough items are handled
* When evaluating a plan, only give the pass-through treatment to items if the step they're part of was actually executed * When marking a step "complete", ignore passthrough items
This commit is contained in:
@@ -46,16 +46,21 @@ module.exports = class CraftingPlan
|
|||||||
recipe = step.recipe
|
recipe = step.recipe
|
||||||
|
|
||||||
for stack in step.recipe.output
|
for stack in step.recipe.output
|
||||||
|
continue if recipe.isPassThroughFor stack.itemSlug
|
||||||
qualifiedSlug = @_modPack.qualifySlug stack.itemSlug
|
qualifiedSlug = @_modPack.qualifySlug stack.itemSlug
|
||||||
|
|
||||||
if recipe.isPassThroughFor stack.itemSlug
|
while @_need.quantityOf(qualifiedSlug) > 0
|
||||||
|
@_executeStep step
|
||||||
|
|
||||||
|
if step.multiplier > 0
|
||||||
|
for stack in step.recipe.output
|
||||||
|
qualifiedSlug = @_modPack.qualifySlug stack.itemSlug
|
||||||
|
continue unless recipe.isPassThroughFor stack.itemSlug
|
||||||
|
continue if @_made.hasAtLeast qualifiedSlug, 1
|
||||||
continue if @_need.hasAtLeast qualifiedSlug, 1
|
continue if @_need.hasAtLeast qualifiedSlug, 1
|
||||||
continue if @_tools.hasAtLeast qualifiedSlug, 1
|
continue if @_tools.hasAtLeast qualifiedSlug, 1
|
||||||
@_need.add qualifiedSlug, 1
|
@_need.add qualifiedSlug, 1
|
||||||
@_tools.add qualifiedSlug, 1
|
@_tools.add qualifiedSlug, 1
|
||||||
else
|
|
||||||
while @_need.quantityOf(qualifiedSlug) > 0
|
|
||||||
@_executeStep step
|
|
||||||
|
|
||||||
@_made.addInventory @_want
|
@_made.addInventory @_want
|
||||||
@_made.addInventory @_tools
|
@_made.addInventory @_tools
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ module.exports = class CraftingStep
|
|||||||
|
|
||||||
completeInto: (targetInventory)->
|
completeInto: (targetInventory)->
|
||||||
for stack in @_recipe.output
|
for stack in @_recipe.output
|
||||||
|
continue if @_recipe.isPassThroughFor stack.itemSlug
|
||||||
quantity = @_recipe.getQuantityProduced stack.itemSlug
|
quantity = @_recipe.getQuantityProduced stack.itemSlug
|
||||||
targetInventory.add stack.itemSlug, quantity * @_multiplier
|
targetInventory.add stack.itemSlug, quantity * @_multiplier
|
||||||
|
|
||||||
|
|||||||
@@ -40,10 +40,9 @@ module.exports = class Craftsman extends BaseModel
|
|||||||
@_modPack = modPack
|
@_modPack = modPack
|
||||||
|
|
||||||
reset = _.debounce (=> @reset()), 100
|
reset = _.debounce (=> @reset()), 100
|
||||||
reevaluatePlans = _.debounce (=> @reevaluatePlans()), 100
|
|
||||||
|
|
||||||
@_have = new Inventory modPack:@_modPack
|
@_have = new Inventory modPack:@_modPack
|
||||||
@_have.on c.event.change, reevaluatePlans
|
@_have.on c.event.change, reset
|
||||||
|
|
||||||
@_want = new Inventory modPack:@_modPack
|
@_want = new Inventory modPack:@_modPack
|
||||||
@_want.on c.event.change, reset
|
@_want.on c.event.change, reset
|
||||||
@@ -55,14 +54,6 @@ module.exports = class Craftsman extends BaseModel
|
|||||||
|
|
||||||
# Public Methods ###############################################################################
|
# Public Methods ###############################################################################
|
||||||
|
|
||||||
reevaluatePlans: ->
|
|
||||||
@_plans = null
|
|
||||||
@_planEvaluator = null
|
|
||||||
@stage = @STAGE.WAITING
|
|
||||||
@stageCount = 0
|
|
||||||
|
|
||||||
@_scheduleNextWork()
|
|
||||||
|
|
||||||
reset: ->
|
reset: ->
|
||||||
@_graphBuilder = null
|
@_graphBuilder = null
|
||||||
@_planBuilder = null
|
@_planBuilder = null
|
||||||
|
|||||||
@@ -33,10 +33,9 @@ module.exports = class CraftPageController extends PageController
|
|||||||
@_router = options.router
|
@_router = options.router
|
||||||
@_storage = options.storage
|
@_storage = options.storage
|
||||||
|
|
||||||
# c.event Methods ################################################################################
|
# Event Methods ################################################################################
|
||||||
|
|
||||||
onHaveInventoryChanged: ->
|
onHaveInventoryChanged: ->
|
||||||
logger.warning => "storing have: #{@model.craftsman.have.unparse()}"
|
|
||||||
@_storage.store 'crafting-plan:have', @model.craftsman.have.unparse()
|
@_storage.store 'crafting-plan:have', @model.craftsman.have.unparse()
|
||||||
|
|
||||||
onMoveNeedToHave: (itemSlug)->
|
onMoveNeedToHave: (itemSlug)->
|
||||||
@@ -89,7 +88,6 @@ module.exports = class CraftPageController extends PageController
|
|||||||
router: @_router
|
router: @_router
|
||||||
@_haveInventoryController.on c.event.button.first, (controller, itemSlug)=>
|
@_haveInventoryController.on c.event.button.first, (controller, itemSlug)=>
|
||||||
@onRemoveFromHaveInventory itemSlug
|
@onRemoveFromHaveInventory itemSlug
|
||||||
@_haveInventoryController.on c.event.change, (c)=> @onHaveInventoryChanged()
|
|
||||||
|
|
||||||
@_needInventoryController = @addChild InventoryController, '.need .view__inventory',
|
@_needInventoryController = @addChild InventoryController, '.need .view__inventory',
|
||||||
editable: false
|
editable: false
|
||||||
@@ -117,6 +115,7 @@ module.exports = class CraftPageController extends PageController
|
|||||||
onWillRender: ->
|
onWillRender: ->
|
||||||
@model.craftsman.have.clear()
|
@model.craftsman.have.clear()
|
||||||
@model.craftsman.have.parse @_storage.load('crafting-plan:have')
|
@model.craftsman.have.parse @_storage.load('crafting-plan:have')
|
||||||
|
@model.craftsman.have.on c.event.change, => @onHaveInventoryChanged()
|
||||||
super
|
super
|
||||||
|
|
||||||
refresh: ->
|
refresh: ->
|
||||||
|
|||||||
@@ -10,6 +10,19 @@
|
|||||||
.view__adsense
|
.view__adsense
|
||||||
|
|
||||||
.right
|
.right
|
||||||
|
section
|
||||||
|
h3 2016-04-16
|
||||||
|
.panel
|
||||||
|
p.
|
||||||
|
I've been working on adding a new mod, and I ran across a bug which has been in the system for a
|
||||||
|
while now, but which will cause serious problems with a lot of the recipes in the new mod. So, I put
|
||||||
|
the mod aside for a bit to fix it.
|
||||||
|
p.
|
||||||
|
The bug was that when you are making something like an <a
|
||||||
|
href="/browse/forge_multipart/oak_wood_cover">Oak Wood Cover</a> the <a
|
||||||
|
href="/browse/forge_multipart/stone_saw">saw</a> wouldn't be part of the crafting plan. This isn't
|
||||||
|
such a big deal for most things, but for this new mod, it would have been a major problem.
|
||||||
|
|
||||||
section
|
section
|
||||||
h3 2016-04-14
|
h3 2016-04-14
|
||||||
.panel
|
.panel
|
||||||
|
|||||||
Reference in New Issue
Block a user