From 88941245205039c1c37bfc1a30670fb39468020d Mon Sep 17 00:00:00 2001 From: Andrew Miner Date: Fri, 13 Mar 2015 19:06:33 -0700 Subject: [PATCH] Don't show pass-through recipes A pass-through recipe is one which requires an item as input which is carried through to the output (e.g., using a Golden Railway Ticket to create a regular Railway Ticket in Railcraft). As these aren't really recipes, they should not be listed as such in the item detail page. --- src/coffee/models/recipe.coffee | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/coffee/models/recipe.coffee b/src/coffee/models/recipe.coffee index a789ba394..9b906778b 100644 --- a/src/coffee/models/recipe.coffee +++ b/src/coffee/models/recipe.coffee @@ -99,13 +99,26 @@ module.exports = class Recipe extends BaseModel return 0 + isPassThroughFor: (itemSlug)-> + amountCreated = 0 + for stack in @output + if stack.itemSlug.matches itemSlug + amountCreated += stack.quantity + + for stack in @input + if stack.itemSlug.matches itemSlug + amountCreated -= stack.quantity + + return amountCreated <= 0 + produces: (itemSlug)-> if not @_produces? @_produces = {} for stack in @output - @_produces[stack.itemSlug.qualified] = true - @_produces[stack.itemSlug.item] = true + actuallyProduces = not @isPassThroughFor stack.itemSlug + @_produces[stack.itemSlug.qualified] = actuallyProduces + @_produces[stack.itemSlug.item] = actuallyProduces return @_produces[itemSlug.qualified] or @_produces[itemSlug.item]