Fix bugs in reformat script from recent refactor
This commit is contained in:
+1
-1
@@ -41,7 +41,7 @@ try
|
||||
text = fs.readFileSync sourceFileName, 'UTF-8'
|
||||
parser = new ModVersionParser model:new ModVersion modSlug:'', version:''
|
||||
modVersion = parser.parse text
|
||||
text = parser.unparse modVersion
|
||||
text = parser.unparse(modVersion).trim().replace(/^\s\s*$/gm, '')
|
||||
|
||||
if targetFileName is '-'
|
||||
console.log text
|
||||
|
||||
@@ -94,98 +94,95 @@ group: Agriculture
|
||||
recipe:
|
||||
input: Steak, Tin Can
|
||||
pattern: 101 111 111
|
||||
tools: Canning Machine
|
||||
quantity: 8
|
||||
tools: Canning Machine
|
||||
recipe:
|
||||
input: Cooked Porkchop, Tin Can
|
||||
pattern: 101 111 111
|
||||
tools: Canning Machine
|
||||
quantity: 8
|
||||
tools: Canning Machine
|
||||
recipe:
|
||||
input: Baked Potato, Tin Can
|
||||
pattern: .0. 111 111
|
||||
tools: Canning Machine
|
||||
quantity: 6
|
||||
tools: Canning Machine
|
||||
recipe:
|
||||
input: Cooked Chicken, Tin Can
|
||||
pattern: .0. 111 111
|
||||
tools: Canning Machine
|
||||
quantity: 6
|
||||
tools: Canning Machine
|
||||
recipe:
|
||||
input: Pumpkin Pie, Tin Can
|
||||
pattern: .0. 111 111
|
||||
tools: Canning Machine
|
||||
quantity: 6
|
||||
tools: Canning Machine
|
||||
recipe:
|
||||
input: Mushroom Stew, Tin Can
|
||||
pattern: .0. 111 111
|
||||
tools: Canning Machine
|
||||
quantity: 6
|
||||
tools: Canning Machine
|
||||
recipe:
|
||||
input: Bread, Tin Can
|
||||
pattern: ... 101 111
|
||||
tools: Canning Machine
|
||||
quantity: 5
|
||||
tools: Canning Machine
|
||||
recipe:
|
||||
input: Cooked Fish, Tin Can
|
||||
pattern: ... 101 111
|
||||
tools: Canning Machine
|
||||
quantity: 5
|
||||
tools: Canning Machine
|
||||
recipe:
|
||||
input: Carrot, Tin Can
|
||||
pattern: ... .01 111
|
||||
tools: Canning Machine
|
||||
quantity: 4
|
||||
tools: Canning Machine
|
||||
recipe:
|
||||
input: Apple, Tin Can
|
||||
pattern: ... .01 111
|
||||
tools: Canning Machine
|
||||
quantity: 4
|
||||
tools: Canning Machine
|
||||
recipe:
|
||||
input: Raw Beef, Tin Can
|
||||
pattern: ... .0. 111
|
||||
tools: Canning Machine
|
||||
quantity: 3
|
||||
tools: Canning Machine
|
||||
recipe:
|
||||
input: Raw Porkchop, Tin Can
|
||||
pattern: ... .0. 111
|
||||
tools: Canning Machine
|
||||
quantity: 3
|
||||
tools: Canning Machine
|
||||
recipe:
|
||||
input: Melon, Tin Can
|
||||
pattern: ... .0. 1.1
|
||||
tools: Canning Machine
|
||||
quantity: 2
|
||||
tools: Canning Machine
|
||||
recipe:
|
||||
input: Cookie, Tin Can
|
||||
pattern: ... .0. 1.1
|
||||
tools: Canning Machine
|
||||
quantity: 2
|
||||
tools: Canning Machine
|
||||
recipe:
|
||||
input: Raw Chicken, Tin Can
|
||||
pattern: ... .0. 1.1
|
||||
tools: Canning Machine
|
||||
quantity: 2
|
||||
tools: Canning Machine
|
||||
recipe:
|
||||
input: Raw Fish, Tin Can
|
||||
pattern: ... .0. 1.1
|
||||
tools: Canning Machine
|
||||
quantity: 2
|
||||
tools: Canning Machine
|
||||
recipe:
|
||||
input: Potato, Tin Can
|
||||
pattern: ... .0. .1.
|
||||
tools: Canning Machine
|
||||
quantity: 1
|
||||
recipe:
|
||||
input: Poisonous Potato, Tin Can
|
||||
pattern: .0. .0. .1.
|
||||
tools: Canning Machine
|
||||
quantity: 1
|
||||
recipe:
|
||||
input: Rotten Flesh, Tin Can
|
||||
pattern: .0. .0. .1.
|
||||
tools: Canning Machine
|
||||
quantity: 1
|
||||
|
||||
item: Grin Powder
|
||||
recipe:
|
||||
@@ -566,10 +563,10 @@ group: Energy: Transmission
|
||||
|
||||
item: Copper Cable
|
||||
recipe:
|
||||
tools: Cutter
|
||||
input: Copper Plate
|
||||
pattern: ... .0. ...
|
||||
quantity: 2
|
||||
tools: Cutter
|
||||
recipe:
|
||||
input: Copper Ingot
|
||||
pattern: ... .0. ...
|
||||
@@ -607,10 +604,10 @@ group: Energy: Transmission
|
||||
|
||||
item: Gold Cable
|
||||
recipe:
|
||||
tools: Cutter
|
||||
input: Gold Plate
|
||||
pattern: ... .0. ...
|
||||
quantity: 4
|
||||
tools: Cutter
|
||||
recipe:
|
||||
input: Gold Ingot
|
||||
pattern: ... .0. ...
|
||||
@@ -674,10 +671,10 @@ group: Energy: Transmission
|
||||
|
||||
item: Tin Cable
|
||||
recipe:
|
||||
tools: Cutter
|
||||
input: Tin Plate
|
||||
pattern: ... .0. ...
|
||||
quantity: 3
|
||||
tools: Cutter
|
||||
recipe:
|
||||
input: Tin Ingot
|
||||
pattern: ... .0. ...
|
||||
@@ -735,10 +732,10 @@ group: Machine Parts
|
||||
|
||||
item: Bronze Item Casing
|
||||
recipe:
|
||||
tools: Forge Hammer
|
||||
input: Bronze Plate
|
||||
pattern: ... .0. ...
|
||||
quantity: 2
|
||||
tools: Forge Hammer
|
||||
recipe:
|
||||
input: Bronze Plate
|
||||
pattern: ... .0. ...
|
||||
@@ -747,9 +744,9 @@ group: Machine Parts
|
||||
|
||||
item: Bronze Plate
|
||||
recipe:
|
||||
tools: Forge Hammer
|
||||
input: Bronze Ingot
|
||||
pattern: ... .0. ...
|
||||
tools: Forge Hammer
|
||||
recipe:
|
||||
input: Bronze Ingot
|
||||
pattern: ... .0. ...
|
||||
@@ -786,10 +783,10 @@ group: Machine Parts
|
||||
|
||||
item: Copper Item Casing
|
||||
recipe:
|
||||
tools: Forge Hammer
|
||||
input: Copper Plate
|
||||
pattern: ... .0. ...
|
||||
quantity: 2
|
||||
tools: Forge Hammer
|
||||
recipe:
|
||||
input: Copper Plate
|
||||
pattern: ... .0. ...
|
||||
@@ -798,9 +795,9 @@ group: Machine Parts
|
||||
|
||||
item: Copper Plate
|
||||
recipe:
|
||||
tools: Forge Hammer
|
||||
input: Copper Ingot
|
||||
pattern: ... .0. ...
|
||||
tools: Forge Hammer
|
||||
recipe:
|
||||
input: Copper Ingot
|
||||
pattern: ... .0. ...
|
||||
@@ -909,10 +906,10 @@ group: Machine Parts
|
||||
|
||||
item: Gold Item Casing
|
||||
recipe:
|
||||
tools: Forge Hammer
|
||||
input: Gold Plate
|
||||
pattern: ... .0. ...
|
||||
quantity: 2
|
||||
tools: Forge Hammer
|
||||
recipe:
|
||||
input: Gold Plate
|
||||
pattern: ... .0. ...
|
||||
@@ -921,9 +918,9 @@ group: Machine Parts
|
||||
|
||||
item: Gold Plate
|
||||
recipe:
|
||||
tools: Forge Hammer
|
||||
input: Gold Ingot
|
||||
pattern: ... .0. ...
|
||||
tools: Forge Hammer
|
||||
recipe:
|
||||
input: Gold Ingot
|
||||
pattern: ... .0. ...
|
||||
@@ -941,10 +938,10 @@ group: Machine Parts
|
||||
|
||||
item: Iron Item Casing
|
||||
recipe:
|
||||
tools: Forge Hammer
|
||||
input: Iron Plate
|
||||
pattern: ... .0. ...
|
||||
quantity: 2
|
||||
tools: Forge Hammer
|
||||
recipe:
|
||||
input: Iron Plate
|
||||
pattern: ... .0. ...
|
||||
@@ -953,9 +950,9 @@ group: Machine Parts
|
||||
|
||||
item: Iron Plate
|
||||
recipe:
|
||||
tools: Forge Hammer
|
||||
input: Iron Ingot
|
||||
pattern: ... .0. ...
|
||||
tools: Forge Hammer
|
||||
recipe:
|
||||
input: Iron Ingot
|
||||
pattern: ... .0. ...
|
||||
@@ -1012,11 +1009,6 @@ group: Machine Parts
|
||||
pattern: ... .0. ...
|
||||
quantity: 9
|
||||
tools: Block Cutting Machine
|
||||
recipe:
|
||||
input: Lapis Lazuli Block
|
||||
pattern: ... .0. ...
|
||||
quantity: 9
|
||||
tools: Block Cutting Machine
|
||||
|
||||
item: Lapotron Crystal
|
||||
recipe:
|
||||
@@ -1026,10 +1018,10 @@ group: Machine Parts
|
||||
|
||||
item: Lead Item Casing
|
||||
recipe:
|
||||
tools: Forge Hammer
|
||||
input: Lead Plate
|
||||
pattern: ... .0. ...
|
||||
quantity: 2
|
||||
tools: Forge Hammer
|
||||
recipe:
|
||||
input: Lead Plate
|
||||
pattern: ... .0. ...
|
||||
@@ -1038,9 +1030,9 @@ group: Machine Parts
|
||||
|
||||
item: Lead Plate
|
||||
recipe:
|
||||
tools: Forge Hammer
|
||||
input: Lead Ingot
|
||||
pattern: ... .0. ...
|
||||
tools: Forge Hammer
|
||||
recipe:
|
||||
input: Lead Ingot
|
||||
pattern: ... .0. ...
|
||||
@@ -1068,11 +1060,6 @@ group: Machine Parts
|
||||
input: Obsidian Dust
|
||||
pattern: ... .0. ...
|
||||
tools: Compressor
|
||||
recipe:
|
||||
input: Obsidian
|
||||
pattern: ... .0. ...
|
||||
quantity: 9
|
||||
tools: Block Cutting Machine
|
||||
|
||||
item: Overclocker Upgrade
|
||||
recipe:
|
||||
@@ -1230,10 +1217,10 @@ group: Machine Parts
|
||||
|
||||
item: Tin Item Casing
|
||||
recipe:
|
||||
tools: Forge Hammer
|
||||
input: Tin Plate
|
||||
pattern: ... .0. ...
|
||||
quantity: 2
|
||||
tools: Forge Hammer
|
||||
recipe:
|
||||
input: Tin Plate
|
||||
pattern: ... .0. ...
|
||||
@@ -1242,9 +1229,9 @@ group: Machine Parts
|
||||
|
||||
item: Tin Plate
|
||||
recipe:
|
||||
tools: Forge Hammer
|
||||
input: Tin Ingot
|
||||
pattern: ... .0. ...
|
||||
tools: Forge Hammer
|
||||
recipe:
|
||||
input: Tin Ingot
|
||||
pattern: ... .0. ...
|
||||
@@ -2549,8 +2536,8 @@ group: Nuclear Reactor
|
||||
|
||||
item: Coolant Cell
|
||||
recipe:
|
||||
input: Distilled Water, Lapis Lazuli Dust, Empty Cell
|
||||
pattern: .0. .1. .2.
|
||||
input: Distilled Water, Empty Cell, Lapis Lazuli Dust
|
||||
pattern: .0. .2. .1.
|
||||
tools: Fluid/Solid Canning Machine
|
||||
|
||||
item: Dual Fuel Rod (Depleted MOX)
|
||||
@@ -3102,10 +3089,12 @@ update: Iron Ingot
|
||||
input: Crushed Iron Ore, furnace fuel
|
||||
pattern: .0. ... .1.
|
||||
tools: Furnace
|
||||
|
||||
recipe:
|
||||
input: Purified Crushed Iron Ore, furnace fuel
|
||||
pattern: .0. ... .1.
|
||||
tools: Furnace
|
||||
|
||||
recipe:
|
||||
input: Iron Dust, furnace fuel
|
||||
pattern: .0. ... .1.
|
||||
@@ -3115,4 +3104,4 @@ update: Diamond
|
||||
recipe:
|
||||
input: Coal Chunk
|
||||
pattern: ... .0. ...
|
||||
tools: Compressor
|
||||
tools: Compressor
|
||||
@@ -95,9 +95,9 @@ module.exports = class Mod extends BaseModel
|
||||
return unless @_activeModVersion?
|
||||
@_activeModVersion.findName itemSlug
|
||||
|
||||
findRecipes: (itemSlug, result=[])->
|
||||
findRecipes: (itemSlug, result=[], options={})->
|
||||
return result unless @_activeModVersion?
|
||||
@_activeModVersion.findRecipes itemSlug, result
|
||||
@_activeModVersion.findRecipes itemSlug, result, options
|
||||
|
||||
# Property Methods #############################################################################
|
||||
|
||||
|
||||
@@ -81,12 +81,12 @@ module.exports = class ModPack extends BaseModel
|
||||
|
||||
return null
|
||||
|
||||
findRecipes: (itemSlug, result=[])->
|
||||
findRecipes: (itemSlug, result=[], options={})->
|
||||
return null unless itemSlug?
|
||||
|
||||
for mod in @_mods
|
||||
continue unless mod.enabled
|
||||
mod.findRecipes itemSlug, result
|
||||
mod.findRecipes itemSlug, result, options
|
||||
|
||||
result.sort (a, b)-> Recipe.compareFor a, b, itemSlug
|
||||
|
||||
|
||||
@@ -117,23 +117,24 @@ module.exports = class ModVersion extends BaseModel
|
||||
|
||||
addRecipe: (recipe)->
|
||||
recipe.modVersion = this
|
||||
|
||||
for stack in recipe.output
|
||||
recipeList = @_recipes[stack.itemSlug.item]
|
||||
if not recipeList?
|
||||
recipeList = @_recipes[stack.itemSlug.item] = []
|
||||
recipeList.push recipe
|
||||
|
||||
if @_recipes[recipe.slug]? then throw new Error "duplicate recipe: #{recipe.slug}"
|
||||
@_recipes[recipe.slug] = recipe
|
||||
return this
|
||||
|
||||
eachRecipe: (callback)->
|
||||
for itemSlugText, recipeList of @_recipes
|
||||
for recipe in recipeList
|
||||
callback recipe
|
||||
recipes = _.values(@_recipes).sort (a, b)-> a.compareTo b
|
||||
for recipe in recipes
|
||||
callback recipe
|
||||
return this
|
||||
|
||||
findRecipes: (itemSlug, result=[])->
|
||||
for k, recipeList of @_recipes
|
||||
for recipe in recipeList
|
||||
findRecipes: (itemSlug, result=[], options={})->
|
||||
options.onlyPrimary ?= false
|
||||
|
||||
for k, recipe of @_recipes
|
||||
if options.onlyPrimary
|
||||
if recipe.itemSlug.matches itemSlug
|
||||
result.push recipe
|
||||
else
|
||||
if recipe.produces itemSlug
|
||||
result.push recipe
|
||||
|
||||
@@ -141,20 +142,19 @@ module.exports = class ModVersion extends BaseModel
|
||||
|
||||
findExternalRecipes: ->
|
||||
result = {}
|
||||
for itemSlug in @_slugs
|
||||
continue if itemSlug.isQualified
|
||||
recipes = @_recipes[itemSlug.item]
|
||||
continue unless recipes? and recipes.length > 0
|
||||
for k, recipe of @_recipes
|
||||
continue if recipe.itemSlug.isQualified
|
||||
|
||||
resultList = result[itemSlug] = []
|
||||
for recipe in recipes
|
||||
resultList.push recipe
|
||||
recipeList = result[recipe.itemSlug]
|
||||
if not recipeList then recipeList = result[recipe.itemSlug] = []
|
||||
|
||||
recipeList.push recipe
|
||||
|
||||
return result
|
||||
|
||||
hasRecipes: (itemSlug)->
|
||||
recipeList = @_recipes[itemSlug.item]
|
||||
return true if recipeList? and recipeList.length > 0
|
||||
for k, recipe of @_recipes
|
||||
return true if recipe.produces itemSlug
|
||||
return false
|
||||
|
||||
# Backbone.Model Overrides #####################################################################
|
||||
|
||||
@@ -215,8 +215,9 @@ module.exports = class ModVersionParserV1 extends CommandParserVersionBase
|
||||
builder
|
||||
.line 'update: ', modVersion.findName ItemSlug.slugify(itemSlugText)
|
||||
.indent()
|
||||
.loop(recipeList, delimiter:'\n\n', onEach:(b, r)=> @_unparseRecipe(b, r))
|
||||
.loop(recipeList, delimiter:'\n', onEach:(b, r)=> @_unparseRecipe(b, r))
|
||||
.outdent()
|
||||
.line()
|
||||
|
||||
_unparseGroup: (builder, modVersion, group)->
|
||||
if group isnt Item.Group.Other
|
||||
@@ -233,7 +234,7 @@ module.exports = class ModVersionParserV1 extends CommandParserVersionBase
|
||||
builder.outdent()
|
||||
|
||||
_unparseItem: (builder, modVersion, item)->
|
||||
recipes = modVersion.findRecipes item.slug
|
||||
recipes = modVersion.findRecipes item.slug, [], onlyPrimary:true
|
||||
|
||||
builder
|
||||
.line 'item: ', item.name
|
||||
|
||||
@@ -6,6 +6,7 @@ All rights reserved.
|
||||
###
|
||||
|
||||
BaseModel = require './base_model'
|
||||
{Event} = require '../constants'
|
||||
Stack = require './stack'
|
||||
StringBuilder = require './string_builder'
|
||||
|
||||
@@ -32,6 +33,8 @@ module.exports = class Recipe extends BaseModel
|
||||
options.logEvents ?= false
|
||||
super attributes, options
|
||||
|
||||
@on Event.change + ':modVersion', => @_slug = null
|
||||
|
||||
# Class Methods ################################################################################
|
||||
|
||||
@compareFor: (a, b, itemSlug)->
|
||||
|
||||
@@ -40,7 +40,7 @@ module.exports = class StringBuilder
|
||||
return this
|
||||
|
||||
line: (args...)->
|
||||
@push.apply this, args
|
||||
@push.apply(this, args) if args.length > 0
|
||||
@push '\n'
|
||||
|
||||
loop: (list, options={})->
|
||||
|
||||
Reference in New Issue
Block a user