Fix bug where deep links don't compute
This commit is contained in:
@@ -11,8 +11,8 @@ Inventory = require './inventory'
|
||||
|
||||
module.exports = class CraftingPlan
|
||||
|
||||
constructor: (@catalog, includingTools)->
|
||||
if not @catalog then throw new Error 'catalog is required'
|
||||
constructor: (@modPack, includingTools)->
|
||||
if not @modPack then throw new Error 'modPack is required'
|
||||
@includingTools = if includingTools then true else false
|
||||
@clear()
|
||||
|
||||
@@ -51,9 +51,9 @@ module.exports = class CraftingPlan
|
||||
return unless targetItem?
|
||||
logger.debug "Processing targetItem: #{targetItem}"
|
||||
|
||||
return if @catalog.isRawMaterial targetItem.name
|
||||
return if @modPack.isRawMaterial targetItem.name
|
||||
|
||||
recipes = @catalog.gatherRecipes targetItem.name
|
||||
recipes = @modPack.gatherRecipes targetItem.name
|
||||
return if not recipes.length > 0
|
||||
|
||||
recipe = recipes[0]
|
||||
|
||||
@@ -15,7 +15,7 @@ Inventory = require './inventory'
|
||||
module.exports = class CraftingTable extends BaseModel
|
||||
|
||||
constructor: (attributes={}, options={})->
|
||||
if not attributes.catalog? then throw new Error "attributes.catalog is required"
|
||||
if not attributes.modPack? then throw new Error "attributes.modPack is required"
|
||||
attributes.name ?= null
|
||||
attributes.quantity ?= 1
|
||||
attributes.includingTools ?= false
|
||||
@@ -26,16 +26,16 @@ module.exports = class CraftingTable extends BaseModel
|
||||
# Public Methods ###############################################################################
|
||||
|
||||
craft: ->
|
||||
if not @catalog.hasRecipe @name
|
||||
if not @modPack.hasRecipe @name
|
||||
@plan = null
|
||||
return
|
||||
|
||||
toolPhrase = if @includingTools then ' includingTools' else ''
|
||||
logger.verbose "calculating build plan for #{@quantity} #{@name}#{toolPhrase} with inventory: #{@have}"
|
||||
|
||||
@catalog.enableBooksForRecipe @name
|
||||
@modPack.enableBooksForRecipe @name
|
||||
|
||||
plan = new CraftingPlan @catalog, @includingTools
|
||||
plan = new CraftingPlan @modPack, @includingTools
|
||||
plan.includingTools = @includingTools
|
||||
plan.craft @name, @quantity, @have
|
||||
|
||||
|
||||
@@ -14,6 +14,6 @@ ModPack = require './mod_pack'
|
||||
module.exports = class ItemPage extends BaseModel
|
||||
|
||||
constructor: (attributes={}, options={})->
|
||||
attributes.catalog ?= new ModPack
|
||||
attributes.table ?= new CraftingTable catalog:attributes.catalog
|
||||
attributes.modPack ?= new ModPack
|
||||
attributes.table ?= new CraftingTable modPack:attributes.modPack
|
||||
super attributes, options
|
||||
|
||||
Reference in New Issue
Block a user