Fix misc. bugs caused by refactoring
This commit is contained in:
@@ -2442,22 +2442,6 @@ group: Minerals: Dusts
|
||||
tools: Macerator
|
||||
|
||||
item: Tiny Pile of Copper Dust
|
||||
recipe:
|
||||
extras: Purified Crushed Copper Ore, Stone Dust
|
||||
input: Crushed Copper Ore, Water
|
||||
pattern: ... .0. .1.
|
||||
quantity: 2
|
||||
tools: Ore Washing Plant
|
||||
recipe:
|
||||
extras: Lead Dust
|
||||
input: Purified Crushed Lead Ore
|
||||
pattern: ... .0. ...
|
||||
tools: Thermal Centrifuge
|
||||
recipe:
|
||||
extras: Lead Dust, Stone Dust
|
||||
input: Crushed Lead Ore
|
||||
pattern: ... .0. ...
|
||||
tools: Thermal Centrifuge
|
||||
recipe:
|
||||
input: Copper Plate
|
||||
pattern: ... .0. ...
|
||||
@@ -2465,27 +2449,6 @@ group: Minerals: Dusts
|
||||
tools: Macerator
|
||||
|
||||
item: Tiny Pile of Gold Dust
|
||||
recipe:
|
||||
extras: Purified Crushed Gold Ore, Stone Dust
|
||||
input: Crushed Gold Ore, Water
|
||||
pattern: ... .0. .1.
|
||||
quantity: 2
|
||||
tools: Ore Washing Plant
|
||||
recipe:
|
||||
extras: Iron Dust
|
||||
input: Purified Crushed Iron Ore
|
||||
pattern: ... .0. ...
|
||||
tools: Thermal Centrifuge
|
||||
recipe:
|
||||
extras: Iron Dust, Stone Dust
|
||||
input: Crushed Iron Ore
|
||||
pattern: ... .0. ...
|
||||
tools: Thermal Centrifuge
|
||||
recipe:
|
||||
extras: 5 Coal Dust
|
||||
input: Slag
|
||||
pattern: ... .0. ...
|
||||
tools: Thermal Centrifuge
|
||||
recipe:
|
||||
input: Gold Plate
|
||||
pattern: ... .0. ...
|
||||
@@ -2493,22 +2456,6 @@ group: Minerals: Dusts
|
||||
tools: Macerator
|
||||
|
||||
item: Tiny Pile of Iron Dust
|
||||
recipe:
|
||||
extras: Purified Crushed Iron Ore, Stone Dust
|
||||
input: Crushed Iron Ore, Water
|
||||
pattern: ... .0. .1.
|
||||
quantity: 2
|
||||
tools: Ore Washing Plant
|
||||
recipe:
|
||||
extras: Tin Dust
|
||||
input: Purified Crushed Tin Ore
|
||||
pattern: ... .0. ...
|
||||
tools: Thermal Centrifuge
|
||||
recipe:
|
||||
extras: Tin Dust, Stone Dust
|
||||
input: Crushed Tin Ore
|
||||
pattern: ... .0. ...
|
||||
tools: Thermal Centrifuge
|
||||
recipe:
|
||||
input: Iron Plate
|
||||
pattern: ... .0. ...
|
||||
@@ -2523,17 +2470,6 @@ group: Minerals: Dusts
|
||||
tools: Macerator
|
||||
|
||||
item: Tiny Pile of Lead Dust
|
||||
recipe:
|
||||
extras: Purified Crushed Uranium Ore, Stone Dust
|
||||
input: Crushed Uranium Ore, Water
|
||||
pattern: ... .0. .1.
|
||||
quantity: 2
|
||||
tools: Ore Washing Plant
|
||||
recipe:
|
||||
extras: Silver Dust
|
||||
input: Purified Crushed Silver Ore
|
||||
pattern: ... .0. ...
|
||||
tools: Thermal Centrifuge
|
||||
recipe:
|
||||
input: Lead Plate
|
||||
pattern: ... .0. ...
|
||||
@@ -2554,78 +2490,16 @@ group: Minerals: Dusts
|
||||
tools: Macerator
|
||||
|
||||
item: Tiny Pile of Plutonium
|
||||
recipe:
|
||||
extras: 16 Uranium 238, 6 Iron Dust
|
||||
input: Quad Fuel Rod (Depleted Uranium)
|
||||
pattern: ... .0. ...
|
||||
quantity: 4
|
||||
tools: Thermal Centrifuge
|
||||
recipe:
|
||||
extras: 12 Plutonium, 6 Iron Dust
|
||||
input: Quad Fuel Rod (Depleted MOX)
|
||||
pattern: ... .0. ...
|
||||
quantity: 4
|
||||
tools: Thermal Centrifuge
|
||||
recipe:
|
||||
extras: 8 Uranium 238, 3 Iron Dust
|
||||
input: Dual Fuel Rod (Depleted Uranium)
|
||||
pattern: ... .0. ...
|
||||
quantity: 2
|
||||
tools: Thermal Centrifuge
|
||||
recipe:
|
||||
extras: 6 Plutonium, 3 Iron Ingot
|
||||
input: Dual Fuel Rod (Depleted MOX)
|
||||
pattern: ... .0. ...
|
||||
quantity: 2
|
||||
tools: Thermal Centrifuge
|
||||
recipe:
|
||||
extras: 4 Uranium 238, Iron Dust
|
||||
input: Fuel Rod (Depleted Uranium)
|
||||
pattern: ... .0. ...
|
||||
tools: Thermal Centrifuge
|
||||
recipe:
|
||||
extras: 3 Plutonium, Iron Ingot
|
||||
input: Fuel Rod (Depleted MOX)
|
||||
pattern: ... .0. ...
|
||||
tools: Thermal Centrifuge
|
||||
recipe:
|
||||
input: Plutonium
|
||||
pattern: ... .0. ...
|
||||
quantity: 9
|
||||
|
||||
item: Tiny Pile of Silver Dust
|
||||
recipe:
|
||||
extras: Purified Crushed Silver Ore, Stone Dust
|
||||
input: Crushed Silver Ore, Water
|
||||
pattern: ... .0. .1.
|
||||
quantity: 2
|
||||
tools: Ore Washing Plant
|
||||
|
||||
item: Tiny Pile of Sulfur Dust
|
||||
recipe:
|
||||
extras: Purified Crushed Lead Ore, Stone Dust
|
||||
input: Crushed Lead Ore, Water
|
||||
pattern: ... .0. .1.
|
||||
quantity: 3
|
||||
tools: Ore Washing Plant
|
||||
|
||||
item: Tiny Pile of Tin Dust
|
||||
recipe:
|
||||
extras: Purified Crushed Tin Ore, Stone Dust
|
||||
input: Crushed Tin Ore, Water
|
||||
pattern: ... .0. .1.
|
||||
quantity: 2
|
||||
tools: Ore Washing Plant
|
||||
recipe:
|
||||
extras: Copper Dust
|
||||
input: Purified Crushed Copper Ore
|
||||
pattern: ... .0. ...
|
||||
tools: Thermal Centrifuge
|
||||
recipe:
|
||||
extras: Copper Dust, Stone Dust
|
||||
input: Crushed Copper Ore
|
||||
pattern: ... .0. ...
|
||||
tools: Thermal Centrifuge
|
||||
recipe:
|
||||
input: Tin Plate
|
||||
pattern: ... .0. ...
|
||||
@@ -2633,17 +2507,6 @@ group: Minerals: Dusts
|
||||
tools: Macerator
|
||||
|
||||
item: Tiny Pile of Uranium 235
|
||||
recipe:
|
||||
extras: 5 Uranium 238
|
||||
input: Purified Crushed Uranium Ore
|
||||
pattern: ... .0. ...
|
||||
quantity: 2
|
||||
tools: Thermal Centrifuge
|
||||
recipe:
|
||||
extras: 4 Uranium 238, Stone Dust
|
||||
input: Crushed Uranium Ore
|
||||
pattern: ... .0. ...
|
||||
tools: Thermal Centrifuge
|
||||
recipe:
|
||||
input: Uranium 235
|
||||
pattern: ... .0. ...
|
||||
|
||||
@@ -42,7 +42,8 @@ module.exports = class CraftingPageController extends BaseController
|
||||
|
||||
onWillRender: ->
|
||||
@_storage.register 'crafting-plan', @model.plan, 'includingTools'
|
||||
@_parser.parse @_storage.load('crafting-plan:have'), @model.plan.have
|
||||
@model.plan.have.clear()
|
||||
@model.plan.have.parse @_storage.load('crafting-plan:have')
|
||||
super
|
||||
|
||||
onDidRender: ->
|
||||
@@ -104,9 +105,9 @@ module.exports = class CraftingPageController extends BaseController
|
||||
# Private Methods ##############################################################################
|
||||
|
||||
_saveHaveInventory: ->
|
||||
@_storage.store 'crafting-plan:have', @_parser.unparse @model.plan.have
|
||||
@_storage.store 'crafting-plan:have', @model.plan.have.unparse()
|
||||
|
||||
_updateLocation: ->
|
||||
text = @_parser.unparse @model.plan.want
|
||||
text = @model.plan.want.unparse()
|
||||
url = Url.crafting inventoryText:text
|
||||
router.navigate url
|
||||
|
||||
@@ -43,7 +43,7 @@ module.exports = class InventoryController extends BaseController
|
||||
item = @modPack.findItemByName @$nameField.val()
|
||||
return unless item?
|
||||
|
||||
@model.add item.qualifiedSlug, parseInt(@$quantityField.val())
|
||||
@model.add item.slug, parseInt(@$quantityField.val())
|
||||
@$nameField.val ''
|
||||
@$quantityField.val '1'
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ module.exports = class ItemController extends BaseController
|
||||
super
|
||||
|
||||
refresh: ->
|
||||
display = @_modPack.findItemDisplay @model.qualifiedSlug
|
||||
display = @_modPack.findItemDisplay @model.slug
|
||||
|
||||
@$icon.attr 'src', display.iconUrl
|
||||
@$name.html display.itemName
|
||||
|
||||
@@ -52,15 +52,18 @@ module.exports = class ItemGroupController extends BaseController
|
||||
|
||||
# Private Methods ##############################################################################
|
||||
|
||||
_createItemController: (item)->
|
||||
_createItemController: (item, delay)->
|
||||
controller = new ItemController model:item, modPack:@_modPack
|
||||
@_itemControllers.push controller
|
||||
|
||||
attachController = =>
|
||||
controller.render()
|
||||
controller.$el.hide()
|
||||
@$items.append controller.$el
|
||||
controller.$el.fadeIn duration:Duration.fast
|
||||
|
||||
_.delay attachController, delay
|
||||
|
||||
_refreshItems: ->
|
||||
controllerIndex = 0
|
||||
delay = 0
|
||||
@@ -69,7 +72,7 @@ module.exports = class ItemGroupController extends BaseController
|
||||
for item in @model
|
||||
controller = @_itemControllers[controllerIndex]
|
||||
if not controller?
|
||||
_.delay ((i)=> return => @_createItemController i)(item), delay
|
||||
@_createItemController item, delay
|
||||
delay += @_delayStep
|
||||
else
|
||||
controller.model = item
|
||||
|
||||
@@ -54,11 +54,11 @@ module.exports = class ItemPageController extends BaseController
|
||||
super
|
||||
|
||||
refresh: ->
|
||||
$('title').html if @model.item? then "#{@model.item.name} | #{Text.title}" else Text.title
|
||||
$('title').html if @model.item? then "#{@model.item?.name} | #{Text.title}" else Text.title
|
||||
@_resolveItemSlug()
|
||||
|
||||
display = @_modPack.findItemDisplay @model.item?.qualifiedSlug
|
||||
if display?
|
||||
if @model.item?
|
||||
display = @_modPack.findItemDisplay @model.item.slug
|
||||
@$craftingPlanLink.attr href:display.craftingUrl
|
||||
@$craftingPlanLink.fadeIn duration:Duration.normal
|
||||
@_imageLoader.load display.iconUrl, @$titleImage
|
||||
|
||||
@@ -43,7 +43,7 @@ module.exports = class StackController extends BaseController
|
||||
super
|
||||
|
||||
refresh: ->
|
||||
display = @modPack.findItemDisplay @model.slug
|
||||
display = @modPack.findItemDisplay @model.itemSlug
|
||||
|
||||
@_imageLoader.load display.iconUrl, @$image
|
||||
@$nameLink.html display.itemName
|
||||
|
||||
@@ -43,7 +43,8 @@ module.exports = class CraftingPlan extends BaseModel
|
||||
|
||||
craft: ->
|
||||
toolsMessage = if @includingTools then ' (including tools)' else ''
|
||||
logger.info => "crafting #{@want}#{toolsMessage} starting with #{@have}"
|
||||
haveMessage = if @have.isEmpty then '' else " starting with #{@have.unparse()}"
|
||||
logger.info => "crafting #{@want.unparse()}#{toolsMessage}#{haveMessage}"
|
||||
|
||||
@clear()
|
||||
@have.localize()
|
||||
@@ -103,7 +104,7 @@ module.exports = class CraftingPlan extends BaseModel
|
||||
|
||||
_chooseRecipe: (item)->
|
||||
recipes = @modPack.findRecipes item.slug
|
||||
return null unless recipes?
|
||||
return null unless recipes? and recipes.length > 0
|
||||
return recipes[0]
|
||||
|
||||
_findSteps: (itemSlug)->
|
||||
@@ -145,8 +146,9 @@ module.exports = class CraftingPlan extends BaseModel
|
||||
for i in [@steps.length-1..0] by -1
|
||||
step = @steps[i]
|
||||
recipe = step.recipe
|
||||
stepItemSlug = @_qualifyItemSlug step.recipe.itemSlug
|
||||
|
||||
step.multiplier = Math.ceil(@need.quantityOf(recipe.itemSlug) / recipe.output[0].quantity)
|
||||
step.multiplier = Math.ceil(@need.quantityOf(stepItemSlug) / recipe.output[0].quantity)
|
||||
|
||||
if @includingTools
|
||||
for stack in recipe.tools
|
||||
|
||||
@@ -144,14 +144,14 @@ module.exports = class Inventory extends BaseModel
|
||||
|
||||
return this
|
||||
|
||||
unparse: ->
|
||||
unparse: (options={})->
|
||||
parts = []
|
||||
@each (stack)=>
|
||||
slugText = stack.itemSlug.qualified
|
||||
slugText = stack.itemSlug.item
|
||||
if @modPack?
|
||||
item = @modPack.findItem stack.itemSlug.item
|
||||
if item?
|
||||
slugText = if item.slug isnt stack.itemSlug then item.slug.qualified
|
||||
item = @modPack.findItem ItemSlug.slugify slugText
|
||||
if item? and item.slug.qualified isnt stack.itemSlug.qualified
|
||||
slugText = item.slug.qualified
|
||||
|
||||
if stack.quantity is 1
|
||||
parts.push slugText
|
||||
|
||||
@@ -32,14 +32,16 @@ module.exports = class ItemPage extends BaseModel
|
||||
return null unless @item?
|
||||
|
||||
result = {}
|
||||
@modPack.eachMod (mod)->
|
||||
mod.eachRecipe (recipe)->
|
||||
if recipe.produces @item.slug
|
||||
result[item.slug] = item
|
||||
@modPack.eachMod (mod)=>
|
||||
mod.eachRecipe (recipe)=>
|
||||
if recipe.requires @item.slug
|
||||
outputItem = @modPack.findItem recipe.itemSlug
|
||||
result[outputItem.slug] = outputItem
|
||||
|
||||
result = _.values(result).sort (a, b)-> a.compareTo b
|
||||
result = _.values result
|
||||
return null unless result.length > 0
|
||||
return result
|
||||
|
||||
return result.sort (a, b)-> a.compareTo b
|
||||
|
||||
findSimilarItems: ->
|
||||
return null unless @item?.modVersion?
|
||||
@@ -61,7 +63,7 @@ module.exports = class ItemPage extends BaseModel
|
||||
@_plan.clear()
|
||||
|
||||
if @item?
|
||||
@_plan.want.add @item.qualifiedSlug
|
||||
@_plan.want.add @item.slug
|
||||
@_plan.craft()
|
||||
|
||||
if @_plan.steps.length > 0
|
||||
|
||||
@@ -59,6 +59,9 @@ module.exports = class ItemSlug
|
||||
|
||||
# Public Methods ###############################################################################
|
||||
|
||||
compareTo: (that)->
|
||||
return ItemSlug.compare this, that
|
||||
|
||||
matches: (slug, options={exact:false})->
|
||||
return false unless slug?.constructor?.name is 'ItemSlug'
|
||||
|
||||
|
||||
@@ -65,6 +65,10 @@ module.exports = class Mod extends BaseModel
|
||||
return unless @_activeModVersion?
|
||||
@_activeModVersion.eachName callback
|
||||
|
||||
eachRecipe: (callback)->
|
||||
return unless @_activeModVersion?
|
||||
@_activeModVersion.eachRecipe callback
|
||||
|
||||
findItem: (slug, options={})->
|
||||
options.includeDisabled ?= false
|
||||
options.enableAsNeeded ?= false
|
||||
|
||||
@@ -6,9 +6,10 @@ All rights reserved.
|
||||
###
|
||||
|
||||
BaseModel = require './base_model'
|
||||
{DefaultModVersions} = require '../constants'
|
||||
{Event} = require '../constants'
|
||||
ModVersionParser = require './mod_version_parser'
|
||||
{DefaultModVersions} = require '../constants'
|
||||
Recipe = require './recipe'
|
||||
{Url} = require '../constants'
|
||||
|
||||
########################################################################################################################
|
||||
@@ -50,7 +51,7 @@ module.exports = class ModPack extends BaseModel
|
||||
return null
|
||||
|
||||
findItemDisplay: (itemSlug)->
|
||||
if not itemSlug? then return null
|
||||
if not itemSlug? then throw new Error 'itemSlug is required'
|
||||
|
||||
result = {}
|
||||
item = @findItem itemSlug, includeDisabled:true
|
||||
@@ -81,16 +82,19 @@ module.exports = class ModPack extends BaseModel
|
||||
return null
|
||||
|
||||
findRecipes: (itemSlug, result=[])->
|
||||
return null unless itemSlug?
|
||||
|
||||
if itemSlug.isQualified
|
||||
mod = @getMod itemSlug.mod
|
||||
if mod?
|
||||
mod.findRecipes itemSlug, result
|
||||
return result if result.length > 0
|
||||
if mod? then mod.findRecipes itemSlug, result
|
||||
|
||||
if result.length is 0
|
||||
for mod in @_mods
|
||||
continue unless mod.enabled
|
||||
mod.findRecipes itemSlug, result
|
||||
|
||||
result.sort (a, b)-> Recipe.compareFor a, b, itemSlug
|
||||
|
||||
return if result.length > 0 then result else null
|
||||
|
||||
# Property Methods #############################################################################
|
||||
|
||||
@@ -101,7 +101,7 @@ module.exports = class ModVersion extends BaseModel
|
||||
|
||||
eachName: (callback)->
|
||||
for slug in @_slugs
|
||||
callback @_names[slug.item]
|
||||
callback @_names[slug.item], slug
|
||||
return this
|
||||
|
||||
findName: (itemSlug)->
|
||||
@@ -126,6 +126,11 @@ module.exports = class ModVersion extends BaseModel
|
||||
|
||||
return this
|
||||
|
||||
eachRecipe: (callback)->
|
||||
for itemSlugText, recipeList of @_recipes
|
||||
for recipe in recipeList
|
||||
callback recipe
|
||||
|
||||
findRecipes: (itemSlug, result=[])->
|
||||
recipeList = @_recipes[itemSlug.item]
|
||||
if recipeList?
|
||||
|
||||
@@ -62,10 +62,10 @@ module.exports = class NameFinder
|
||||
@modPack.eachMod (mod)=>
|
||||
return unless mod.enabled or @includeDisabledMods
|
||||
|
||||
mod.eachName (name, slug)=>
|
||||
mod.eachName (name, itemSlug)=>
|
||||
return if nameMap[name]
|
||||
|
||||
item = mod.findItem slug
|
||||
item = mod.findItem itemSlug
|
||||
if not @includeGatherable
|
||||
return unless item? and item.isCraftable
|
||||
|
||||
|
||||
@@ -31,8 +31,40 @@ module.exports = class Recipe extends BaseModel
|
||||
options.logEvents ?= false
|
||||
super attributes, options
|
||||
|
||||
# Class Methods ################################################################################
|
||||
|
||||
@compareFor: (a, b, itemSlug)->
|
||||
aValue = a.itemSlug.matches itemSlug
|
||||
bValue = b.itemSlug.matches itemSlug
|
||||
if aValue isnt bValue
|
||||
return -1 if aValue
|
||||
return +1 if bValue
|
||||
|
||||
aValue = a.getQuantityProducedOf itemSlug
|
||||
bValue = b.getQuantityProducedOf itemSlug
|
||||
if aValue isnt bValue
|
||||
return if aValue < bValue then -1 else +1
|
||||
|
||||
aValue = a.getInputCount()
|
||||
bValue = b.getInputCount()
|
||||
if aValue isnt bValue
|
||||
return if aValue < bValue then -1 else +1
|
||||
|
||||
aValue = a.getOutputCount()
|
||||
bValue = b.getOutputCount()
|
||||
if aValue isnt bValue
|
||||
return if aValue > bValue then -1 else +1
|
||||
|
||||
return 0
|
||||
|
||||
# Public Methods ###############################################################################
|
||||
|
||||
getInputCount: ->
|
||||
result = 0
|
||||
for stack in @input
|
||||
result += stack.quantity
|
||||
return result
|
||||
|
||||
getItemSlugAt: (patternSlot)->
|
||||
trueIndex = 0:0, 1:1, 2:2, 3:4, 4:5, 5:6, 6:8, 7:9, 8:10
|
||||
patternDigit = @pattern[trueIndex[patternSlot]]
|
||||
@@ -44,6 +76,19 @@ module.exports = class Recipe extends BaseModel
|
||||
|
||||
return stack.itemSlug
|
||||
|
||||
getOutputCount: ->
|
||||
result = 0
|
||||
for stack in @output
|
||||
result += stack.quantity
|
||||
return result
|
||||
|
||||
getQuantityProducedOf: (itemSlug)->
|
||||
for stack in @output
|
||||
if stack.itemSlug.matches itemSlug
|
||||
return stack.quantity
|
||||
|
||||
return 0
|
||||
|
||||
produces: (itemSlug)->
|
||||
for stack in @output
|
||||
if stack.itemSlug.matches itemSlug
|
||||
@@ -51,6 +96,12 @@ module.exports = class Recipe extends BaseModel
|
||||
|
||||
return false
|
||||
|
||||
requires: (itemSlug)->
|
||||
for stack in @input
|
||||
if stack.itemSlug.matches itemSlug
|
||||
return true
|
||||
return false
|
||||
|
||||
# Object Overrides #############################################################################
|
||||
|
||||
toString: ->
|
||||
|
||||
Reference in New Issue
Block a user