This commit is contained in:
Andrew Miner
2016-04-13 22:31:11 -07:00
parent 14278c81df
commit 31f6e12844
15 changed files with 386 additions and 297 deletions
@@ -11,6 +11,22 @@ ParserExtension = require '../parser_extension'
module.exports = class ItemParserExtensionV1 extends ParserExtension
constructor: (data)->
super data, 'item',
gatherable: @_command_gatherable
item: @_command_item
# ParserExtensions Overrides ###################################################################
assmeble: (entry)->
throw new Error "#{@constructor.name} must override the `assemble` method"
build: (entry)->
entry.instance = new
throw new Error "#{@constructor.name} must override the `build` method"
validate: (entry)-> # do nothing
# Command Methods ##############################################################################
_command_gatherable: (command)->
@@ -18,7 +34,7 @@ module.exports = class ItemParserExtensionV1 extends ParserExtension
return if @missingCurrent command, 'item'
item = @state.getCurrent 'item'
item = @data.getCurrent 'item'
return if @duplicateField command, 'gatherable', item
gatherable = @parseBoolean command, command.argText
@@ -31,10 +47,19 @@ module.exports = class ItemParserExtensionV1 extends ParserExtension
return if @missingCurrent command, 'modVersion'
return if @alreadyExists command, 'item', command.argText
item = @state.create command, 'item', command.argText
item = @data.create command, 'item', command.argText
item.name = command.argText
group = @state.getCurrent 'itemGroup'
group = @data.getCurrent 'itemGroup'
if group? then item.group = group
item.modVersion = @state.getCurrent 'modVersion'
item.modVersion = @data.getCurrent 'modVersion'
_command_video: (command)->
return if @missingArgs command
return if @missingCurrent command, 'item'
return if @tooFewArguments command, 2
item = @data.getCurrent 'item'
item.videos ?= []
item.videos.push youTubeId:command.args[0], caption:command.args[1..].join(', ')