Refactor ModVersion into Mod and ModVersion
* Remove V1 of the mod version parser and shift V2 up to be V1 * Add a parser for mod.cg files, and refactor the the mod-version.cg files to push the appropriate content up to the mod.cg * Remove the concept of "silent" from BaseModel along with logging each event as they are fired (which is what really prompted the need for it in the first place) * Move use of the Storage class to be completely the province of the controllers most closely related to models affected * Convert the ModVersionController to the ModController and have it take on responsibility for choosing the mod version * Update BaseModel to support simple accessors for the current state * Update CraftingPlan to be able to remove uncraftable items * Implement the Mod model
This commit is contained in:
@@ -23,29 +23,26 @@ module.exports = class CraftingPlan extends BaseModel
|
||||
@need = new Inventory
|
||||
@result = new Inventory
|
||||
|
||||
@clear silent:true
|
||||
@clear()
|
||||
|
||||
@have.on Event.change, => @craft()
|
||||
@want.on Event.change, => @craft()
|
||||
@modPack.on Event.add, => @craft()
|
||||
@modPack.on Event.change, => @craft()
|
||||
|
||||
@on Event.change + ':includingTools', => @craft()
|
||||
|
||||
# Public Methods ###############################################################################
|
||||
|
||||
clear: (options={})->
|
||||
options.silent ?= false
|
||||
|
||||
@steps = []
|
||||
@need.clear()
|
||||
@result.clear()
|
||||
|
||||
@trigger 'change', this unless options.silent
|
||||
@trigger 'change', this
|
||||
return this
|
||||
|
||||
craft: ->
|
||||
@clear silent:true
|
||||
@need.silent = @result.silent = true
|
||||
@clear()
|
||||
|
||||
@result.addInventory @have
|
||||
|
||||
@@ -59,11 +56,19 @@ module.exports = class CraftingPlan extends BaseModel
|
||||
@_removeExtraSteps()
|
||||
@result.addInventory @want
|
||||
|
||||
@need.silent = @result.silent = false
|
||||
@need.trigger 'change', @need
|
||||
@result.trigger 'change', @result
|
||||
@trigger 'change', this
|
||||
|
||||
removeUncraftableItems: ->
|
||||
toRemove = []
|
||||
@want.each (stack)=>
|
||||
item = @modPack.findItem stack.slug
|
||||
if not item? then toRemove.push stack.slug
|
||||
|
||||
for slug in toRemove
|
||||
@want.remove slug
|
||||
|
||||
# Event Methods ################################################################################
|
||||
|
||||
onIncludingToolsChanged: ->
|
||||
|
||||
Reference in New Issue
Block a user