Add new CraftingPlan class

This commit is contained in:
Andrew Miner
2015-09-22 19:54:31 -07:00
parent 6ea97ac3aa
commit de04c79d17
9 changed files with 187 additions and 109 deletions
+5 -4
View File
@@ -13,13 +13,14 @@ PlanBuilder = require '../../src/coffee/models/crafting/plan_builder'
describe 'plan_builder.coffee', ->
printPlan = (plan)->
return ((s.slug.replace(/^.*>.*>/, '') for s in plan)).join ' > '
return ((s.slug.replace(/^.*>.*>/, '') for s in plan.steps;;)).join ' > '
it 'generates no plans for a gatherable item', ->
it 'generates an empty plan for a gatherable item', ->
builder = new PlanBuilder fixtures.makeTree 'test__oak_wood'
plans = builder.producePlans 100
plans.length.should.equal 0
plans.length.should.equal 1
plans[0].length.should.equal 0
builder.complete.should.be.true
it 'can find a multi-step plan', ->
@@ -34,5 +35,5 @@ describe 'plan_builder.coffee', ->
builder = new PlanBuilder fixtures.makeTree 'test__iron_ingot'
plans = builder.producePlans 100
printPlan(plans[0]).should.equal 'test__charcoal > test__iron_ingot'
printPlan(plans[0]).should.equal '8 test__charcoal > test__iron_ingot'
printPlan(plans[1]).should.equal 'test__iron_ingot'