Fix bug where items with one plan don't get scored
This commit is contained in:
@@ -100,16 +100,18 @@ module.exports = class CraftingPlan
|
|||||||
result.push " #{stack}"
|
result.push " #{stack}"
|
||||||
|
|
||||||
result.push "Start with:"
|
result.push "Start with:"
|
||||||
@_need.each (stack)->
|
if @_need?
|
||||||
result.push " #{stack}"
|
@_need.each (stack)->
|
||||||
|
result.push " #{stack}"
|
||||||
|
|
||||||
result.push "Use these recipes:"
|
result.push "Use these recipes:"
|
||||||
for step in @_steps
|
for step in @_steps
|
||||||
result.push " #{step}"
|
result.push " #{step}"
|
||||||
|
|
||||||
result.push "To produce:"
|
result.push "To produce:"
|
||||||
@_made.each (stack)->
|
if @_made?
|
||||||
result.push " #{stack}"
|
@_made.each (stack)->
|
||||||
|
result.push " #{stack}"
|
||||||
|
|
||||||
if _.keys(@_rawScores).length > 0
|
if _.keys(@_rawScores).length > 0
|
||||||
result.push "Scores:"
|
result.push "Scores:"
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ module.exports = class PlanEvaluator
|
|||||||
if not plans? then throw new Error 'plans is required'
|
if not plans? then throw new Error 'plans is required'
|
||||||
|
|
||||||
@_plans = plans
|
@_plans = plans
|
||||||
@_lastScored = 0
|
@_lastScored = -1
|
||||||
@_normalized = false
|
@_normalized = false
|
||||||
|
|
||||||
# Public Methods ###############################################################################
|
# Public Methods ###############################################################################
|
||||||
@@ -41,7 +41,7 @@ module.exports = class PlanEvaluator
|
|||||||
return if @complete
|
return if @complete
|
||||||
|
|
||||||
maxPlanIndex = Math.min @_lastScored + count, @_plans.length - 1
|
maxPlanIndex = Math.min @_lastScored + count, @_plans.length - 1
|
||||||
for i in [@_lastScored..maxPlanIndex]
|
for i in [(@_lastScored + 1)..maxPlanIndex]
|
||||||
@_plans[i].computeRequired()
|
@_plans[i].computeRequired()
|
||||||
@_scorePlan @_plans[i]
|
@_scorePlan @_plans[i]
|
||||||
@_lastScored = i
|
@_lastScored = i
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ module.exports = class Inventory extends BaseModel
|
|||||||
|
|
||||||
if qualifiedSlug?
|
if qualifiedSlug?
|
||||||
newSlugs.push qualifiedSlug
|
newSlugs.push qualifiedSlug
|
||||||
newStacks.push new Stack itemSlug:qualifiedSlug, stack.quantity
|
newStacks.push new Stack itemSlug:qualifiedSlug, quantity:stack.quantity
|
||||||
else
|
else
|
||||||
newSlugs.push itemSlug
|
newSlugs.push itemSlug
|
||||||
newStacks.push stack
|
newStacks.push stack
|
||||||
|
|||||||
@@ -66,21 +66,32 @@ module.exports = class SimpleInventory
|
|||||||
localize: ->
|
localize: ->
|
||||||
if not @modPack? then throw new Error 'localize requires @modPack'
|
if not @modPack? then throw new Error 'localize requires @modPack'
|
||||||
|
|
||||||
|
changed = false
|
||||||
newSlugs = []
|
newSlugs = []
|
||||||
|
newStacks = []
|
||||||
for itemSlug in @_itemSlugs
|
for itemSlug in @_itemSlugs
|
||||||
stack = @_stacks[itemSlug]
|
stack = @_stacks[itemSlug]
|
||||||
|
continue unless stack?
|
||||||
|
|
||||||
|
qualifiedSlug = if itemSlug.isQualified then itemSlug else null
|
||||||
|
if not qualifiedSlug?
|
||||||
|
qualifiedSlug = @modPack.findItem(itemSlug)?.slug
|
||||||
|
changed = qualifiedSlug?
|
||||||
|
|
||||||
qualifiedSlug = @modPack.findItem(itemSlug)?.slug
|
|
||||||
if qualifiedSlug?
|
if qualifiedSlug?
|
||||||
delete @_stacks[itemSlug]
|
|
||||||
newSlugs.push qualifiedSlug
|
newSlugs.push qualifiedSlug
|
||||||
@_stacks[qualifiedSlug] = stack
|
newStacks.push new Stack itemSlug:qualifiedSlug, quantity:stack.quantity
|
||||||
stack.itemSlug = qualifiedSlug
|
|
||||||
else
|
else
|
||||||
newSlugs.push itemSlug
|
newSlugs.push itemSlug
|
||||||
|
newStacks.push stack
|
||||||
|
|
||||||
@_itemSlugs = newSlugs
|
if changed
|
||||||
@_sort()
|
@_itemSlugs = newSlugs
|
||||||
|
@_stacks = {}
|
||||||
|
for stack in newStacks
|
||||||
|
@_stacks[stack.itemSlug] = stack
|
||||||
|
|
||||||
|
@_sort()
|
||||||
|
|
||||||
pop: ->
|
pop: ->
|
||||||
itemSlug = @_itemSlugs.pop()
|
itemSlug = @_itemSlugs.pop()
|
||||||
|
|||||||
Reference in New Issue
Block a user