Convert codebase to using ItemSlug
* Flesh out the formerly incomplete ItemSlug class * Convert all uses of text item slugs to use ItemSlug * Move the ItemSlug class under models where it properly belongs * Avoid the use of `slug` as a local variable or item attribute wherever possible to avoid confusion between various kinds of slugs * Merge the InventoryParser class into the Inventory class as it is unlikely to need to support multiple versions * Simplify the ModPack/Mod/ModVersion interfaces by replacing the use of various "helper" methods with equivalent use of more generic methods * Update the various methods of ModPack/Mod/ModVersion to be able to work with qualified or unqualified ItemSlugs * Remove the unused BaseCollection class * Add tests for ItemSlug and update all other tests to reflect all the other changes
This commit is contained in:
@@ -6,6 +6,7 @@ All rights reserved.
|
||||
###
|
||||
|
||||
CraftingPlan = require '../src/scripts/models/crafting_plan'
|
||||
ItemSlug = require '../src/scripts/models/item_slug'
|
||||
Mod = require '../src/scripts/models/mod'
|
||||
ModPack = require '../src/scripts/models/mod_pack'
|
||||
ModVersion = require '../src/scripts/models/mod_version'
|
||||
@@ -41,54 +42,43 @@ describe 'crafting_plan.coffee', ->
|
||||
describe 'under the simplest conditions', ->
|
||||
|
||||
it 'can craft a single step recipe', ->
|
||||
plan.want.add 'oak_plank'
|
||||
plan.want.add ItemSlug.slugify 'oak_plank'
|
||||
plan.craft()
|
||||
plan.need.toList().should.eql ['oak_log']
|
||||
plan.result.toList().should.eql [[4, 'minecraft__oak_plank']]
|
||||
plan.need.unparse().should.equal 'oak_log'
|
||||
plan.result.unparse().should.equal '4.minecraft__oak_plank'
|
||||
|
||||
it 'can craft a multi-step recipe', ->
|
||||
plan.want.add 'crafting_table'
|
||||
plan.want.add ItemSlug.slugify 'crafting_table'
|
||||
plan.craft()
|
||||
plan.need.toList().should.eql ['oak_log']
|
||||
plan.result.toList().should.eql ['minecraft__crafting_table']
|
||||
plan.need.unparse().should.equal 'oak_log'
|
||||
plan.result.unparse().should.equal 'minecraft__crafting_table'
|
||||
|
||||
it 'can craft a multi-step recipe using tools', ->
|
||||
plan.want.add 'furnace'
|
||||
plan.want.add ItemSlug.slugify 'furnace'
|
||||
plan.craft()
|
||||
plan.need.toList().should.eql [[8, 'cobblestone']]
|
||||
plan.result.toList().should.eql ['minecraft__furnace']
|
||||
plan.need.unparse().should.equal '8.cobblestone'
|
||||
plan.result.unparse().should.equal 'minecraft__furnace'
|
||||
|
||||
it 'can craft a multi-step recipe re-using tools', ->
|
||||
plan.want.add 'iron_sword'
|
||||
plan.want.add ItemSlug.slugify 'iron_sword'
|
||||
plan.craft()
|
||||
plan.need.toList().should.eql [[2, 'furnace_fuel'], [2, 'iron_ore'], 'oak_log']
|
||||
plan.result.toList().should.eql [
|
||||
'minecraft__iron_sword',
|
||||
[2, 'minecraft__oak_plank'],
|
||||
[3, 'minecraft__stick']
|
||||
]
|
||||
plan.need.unparse().should.equal '2.furnace_fuel:2.iron_ore:oak_log'
|
||||
plan.result.unparse().should.equal 'minecraft__iron_sword:2.minecraft__oak_plank:3.minecraft__stick'
|
||||
|
||||
describe 'with building tools', ->
|
||||
|
||||
it 'can craft a multi-step recipe using tools', ->
|
||||
plan.includingTools = true
|
||||
plan.want.add 'furnace'
|
||||
plan.want.add ItemSlug.slugify 'furnace'
|
||||
plan.craft()
|
||||
plan.need.toList().should.eql [[8, 'cobblestone'], 'oak_log']
|
||||
plan.result.toList().should.eql ['minecraft__crafting_table', 'minecraft__furnace']
|
||||
plan.need.unparse().should.equal '8.cobblestone:oak_log'
|
||||
plan.result.unparse().should.equal 'minecraft__crafting_table:minecraft__furnace'
|
||||
|
||||
it 'can craft a multi-step recipe re-using tools', ->
|
||||
plan.includingTools = true
|
||||
plan.want.add 'iron_sword'
|
||||
plan.want.add ItemSlug.slugify 'iron_sword'
|
||||
plan.craft()
|
||||
|
||||
plan.need.toList().should.eql [
|
||||
[8, 'cobblestone'], [2, 'furnace_fuel'], [2, 'iron_ore'], [2, 'oak_log']
|
||||
]
|
||||
plan.result.toList().should.eql [
|
||||
'minecraft__crafting_table',
|
||||
'minecraft__furnace',
|
||||
'minecraft__iron_sword',
|
||||
[2, 'minecraft__oak_plank'],
|
||||
[3, 'minecraft__stick']
|
||||
]
|
||||
plan.need.unparse().should.eql '8.cobblestone:2.furnace_fuel:2.iron_ore:2.oak_log'
|
||||
plan.result.unparse().should.equal 'minecraft__crafting_table:minecraft__furnace:' +
|
||||
'minecraft__iron_sword:2.minecraft__oak_plank:3.minecraft__stick'
|
||||
|
||||
Reference in New Issue
Block a user