# `item_count_add item_id value`
#
# Add value to the count in a item.
# - item_id: string: id of the item to apply
# - value: int: number to add
#
# @ESC
extends ESCBaseCommand
class_name ItemCountAddCommand


var item_count_manager = ESCItemCountManager.new()

# Return the descriptor of the arguments of this command
func configure() -> ESCCommandArgumentDescriptor:
  return ESCCommandArgumentDescriptor.new(
	  1,
	  [TYPE_STRING, TYPE_INT],
	  [null, 1]
  )


# Validate wether the given arguments match the command descriptor
func validate(arguments: Array):
	if not escoria.object_manager.has(arguments[0]):
		escoria.logger.error(
			self,
			"Object %s not registered" % arguments[0]
		)
		return false

	return .validate(arguments)


# Run the command
func run(command_params: Array) -> int:
	item_count_manager.add(command_params[0], command_params[1])
	
	return ESCExecution.RC_OK
