Rename RecipeBook to ModVersion

This commit is contained in:
Andrew Miner
2015-01-01 20:12:27 -08:00
parent 5d4bf92948
commit f28a763b13
11 changed files with 42 additions and 42 deletions
+56
View File
@@ -0,0 +1,56 @@
###
Crafting Guide - mod_version.coffee
Copyright (c) 2014 by Redwood Labs
All rights reserved.
###
BaseModel = require './base_model'
{RequiredMods} = require '../constants'
########################################################################################################################
module.exports = class ModVersion extends BaseModel
constructor: (attributes={}, options={})->
if _.isEmpty(attributes.modName) then throw new Error 'modName cannot be empty'
if _.isEmpty(attributes.modVersion) then throw new Error 'modVersion cannot be empty'
attributes.description ?= ''
attributes.rawMaterials ?= []
attributes.recipes ?= []
attributes.enabled ?= attributes.modName in RequiredMods
super attributes, options
# Public Methods ###############################################################################
gatherNames: (result)->
for recipe in @recipes
continue if result[recipe.name]
result[recipe.name] = value:recipe.name, label:"#{recipe.name} (from #{@modName} #{@modVersion})"
return result
gatherRecipes: (name, result)->
for recipe in @recipes
if recipe.name is name
result.push recipe
return result
isRawMaterial: (name)->
return name in @rawMaterials
hasRecipe: (name)->
for recipe in @recipes
return true if recipe.name is name
return false
# Object Overrides #############################################################################
toString: ->
return "ModVersion (#{@cid}) {
enabled:#{@enabled},
modName:#{@modName},
modVersion:#{@modVersion},
recipes:#{@recipes.length} items}"