Complete basic crafting functionality

This commit is contained in:
Andrew Miner
2014-12-24 19:17:37 -08:00
parent 3ea6a845c7
commit 1a84ce2e28
20 changed files with 427 additions and 90 deletions
+2 -7
View File
@@ -32,15 +32,10 @@ describe 'InventoryParser', ->
it 'can parse multiple mixed-type items', ->
result = parser.parse '4 wool\n10 string\nboat\n\n'
result._items.wool.quantity.should.equal 4
result._items.string.quantity.should.equal 10
result._items.boat.quantity.should.equal 1
result._names.should.eql ['wool', 'string', 'boat']
result.toList().should.eql ['boat', [10, 'string'], [4, 'wool']]
it 're-uses the given inventory object', ->
inventory = new Inventory
inventory.add 'string', 8
result = parser.parse '4 wool', inventory
inventory._items.string.quantity.should.equal 8
inventory._items.wool.quantity.should.equal 4
inventory._names.should.eql ['string', 'wool']
result.toList().should.eql [[8, 'string'], [4, 'wool']]