view Classes/ContainerItem.class.lua @ 111:41f0689dfda1

This implementation of vendor buying did not work well. Too many customizations were needed that made the code hard to read and understand and eventually it was found that vendor buying should be based on refill target, not local stock. The mover/refiller is not meant for this, we should just do this somewhere else.
author Zerotorescue
date Fri, 14 Jan 2011 23:31:12 +0100
parents 67bd5057ecb7
children 239e25a058c7
line wrap: on
line source
local addon = select(2, ...);

-- Define the class

addon.ContainerItem = {};
addon.ContainerItem.__index = addon.ContainerItem;

-- Construct
function addon.ContainerItem:New(id)
	local self = {};
	
	setmetatable(self, addon.ContainerItem);
	
	-- Standard info everything needs
	self.id = id;
	self.totalCount = 0;
	self.locations = {};
	
	return self;
end

function addon.ContainerItem:AddLocation(container, slot, count)
	table.insert(self.locations, {
		["container"] = container,
		["slot"] = slot,
		["count"] = count,
	});
	
	-- -1 indicates unlimited supply
	if self.totalCount ~= -1 then
		if count == -1 then
			self.totalCount = -1;
		else
			self.totalCount = (self.totalCount + count);
		end
	end
	
	return true;
end