annotate Classes/ContainerItem.class.lua @ 110:67bd5057ecb7

Implemented vendor restocking with the mover. Comitting so I can always review this working version, but I?ll be disabling all part of it as it is not going to work properly without seriously compromising the code structure. Debug messages are now appended with ?Inventorium? (my MailOpener addon was making stuff difficult). Now properly removing the refill window from the displayed static popup windows list so new popups won?t be aligned at odd locations. Changed ?CreateMoverFrame? to not contain any scenario-specific info. All settings can be set with SetFrameSettings. Items that belong to speciality bags are now put there. Other items now ignore spaciality bags. Implemented test code for mailbox refill support. It has been disabled due to some issues but may be introduced later. The guild withdrawal limit is now taken into consideration. Queue is now reset before scanning again.
author Zerotorescue
date Fri, 14 Jan 2011 23:25:05 +0100
parents 3bec0ea44607
children 41f0689dfda1
rev   line source
Zerotorescue@81 1 local addon = select(2, ...);
Zerotorescue@81 2
Zerotorescue@81 3 -- Define the class
Zerotorescue@81 4
Zerotorescue@81 5 addon.ContainerItem = {};
Zerotorescue@81 6 addon.ContainerItem.__index = addon.ContainerItem;
Zerotorescue@81 7
Zerotorescue@81 8 -- Construct
Zerotorescue@81 9 function addon.ContainerItem:New(id)
Zerotorescue@81 10 local self = {};
Zerotorescue@81 11
Zerotorescue@81 12 setmetatable(self, addon.ContainerItem);
Zerotorescue@81 13
Zerotorescue@81 14 -- Standard info everything needs
Zerotorescue@81 15 self.id = id;
Zerotorescue@81 16 self.totalCount = 0;
Zerotorescue@81 17 self.locations = {};
Zerotorescue@81 18
Zerotorescue@81 19 return self;
Zerotorescue@81 20 end
Zerotorescue@81 21
Zerotorescue@110 22 function addon.ContainerItem:AddLocation(container, slot, count, price)
Zerotorescue@81 23 table.insert(self.locations, {
Zerotorescue@110 24 ["container"] = container,
Zerotorescue@110 25 ["slot"] = slot,
Zerotorescue@110 26 ["count"] = count,
Zerotorescue@110 27 ["price"] = price,
Zerotorescue@81 28 });
Zerotorescue@81 29
Zerotorescue@110 30 -- -1 indicates unlimited supply
Zerotorescue@110 31 if self.totalCount ~= -1 then
Zerotorescue@110 32 if count == -1 then
Zerotorescue@110 33 self.totalCount = -1;
Zerotorescue@110 34 else
Zerotorescue@110 35 self.totalCount = (self.totalCount + count);
Zerotorescue@110 36 end
Zerotorescue@110 37 end
Zerotorescue@81 38
Zerotorescue@81 39 return true;
Zerotorescue@81 40 end
Zerotorescue@110 41
Zerotorescue@110 42 function addon.ContainerItem:GetVendorPrice()
Zerotorescue@110 43 for _, loc in pairs(self.locations) do
Zerotorescue@110 44 if loc.price then
Zerotorescue@110 45 return loc.price;
Zerotorescue@110 46 end
Zerotorescue@110 47 end
Zerotorescue@110 48 end