some scan/manage work
This commit is contained in:
@@ -4,6 +4,7 @@ AuxAuthors = "shirsig; Zerf; Zirco (Auctionator); Nimeral (Auctionator backport)
|
||||
local lastRightClickAction = GetTime()
|
||||
|
||||
Aux = {
|
||||
blizzard_ui_shown = false,
|
||||
loaded = false,
|
||||
orig = {},
|
||||
elements = {},
|
||||
@@ -37,9 +38,7 @@ end
|
||||
|
||||
function Aux_OnAddonLoaded()
|
||||
if string.lower(arg1) == "blizzard_auctionui" then
|
||||
AuxButton:SetParent("AuctionFrame")
|
||||
AuxButton:SetPoint("TOPRIGHT", "AuctionFrame", "TOPRIGHT", -26, -12)
|
||||
|
||||
AuctionFrame:SetScript('OnHide', nil)
|
||||
Aux_SetupHookFunctions()
|
||||
end
|
||||
end
|
||||
@@ -96,26 +95,17 @@ end
|
||||
|
||||
function Aux_SetupHookFunctions()
|
||||
|
||||
AuctionsButton1:RegisterForClicks("LeftButtonUp", "RightButtonDown")
|
||||
AuctionsButton1:SetScript("OnMouseDown", Aux_AuctionsButton_OnMouseDown)
|
||||
AuctionsButton2:RegisterForClicks("LeftButtonUp", "RightButtonDown")
|
||||
AuctionsButton2:SetScript("OnMouseDown", Aux_AuctionsButton_OnMouseDown)
|
||||
AuctionsButton3:RegisterForClicks("LeftButtonUp", "RightButtonDown")
|
||||
AuctionsButton3:SetScript("OnMouseDown", Aux_AuctionsButton_OnMouseDown)
|
||||
AuctionsButton4:RegisterForClicks("LeftButtonUp", "RightButtonDown")
|
||||
AuctionsButton4:SetScript("OnMouseDown", Aux_AuctionsButton_OnMouseDown)
|
||||
AuctionsButton5:RegisterForClicks("LeftButtonUp", "RightButtonDown")
|
||||
AuctionsButton5:SetScript("OnMouseDown", Aux_AuctionsButton_OnMouseDown)
|
||||
AuctionsButton6:RegisterForClicks("LeftButtonUp", "RightButtonDown")
|
||||
AuctionsButton6:SetScript("OnMouseDown", Aux_AuctionsButton_OnMouseDown)
|
||||
AuctionsButton7:RegisterForClicks("LeftButtonUp", "RightButtonDown")
|
||||
AuctionsButton7:SetScript("OnMouseDown", Aux_AuctionsButton_OnMouseDown)
|
||||
AuctionsButton8:RegisterForClicks("LeftButtonUp", "RightButtonDown")
|
||||
AuctionsButton8:SetScript("OnMouseDown", Aux_AuctionsButton_OnMouseDown)
|
||||
AuctionsButton9:RegisterForClicks("LeftButtonUp", "RightButtonDown")
|
||||
AuctionsButton9:SetScript("OnMouseDown", Aux_AuctionsButton_OnMouseDown)
|
||||
Aux.orig.AuctionFrame_OnShow = AuctionFrame_OnShow
|
||||
-- TODO for some reason this breaks the auction house functionality
|
||||
AuctionFrame_OnShow = function()
|
||||
if not Aux.blizzard_ui_shown then
|
||||
HideUIPanel(AuctionFrame)
|
||||
else
|
||||
return Aux.orig.AuctionFrame_OnShow()
|
||||
end
|
||||
end
|
||||
|
||||
Aux.orig.PickupContainerItem = PickupContainerItem
|
||||
Aux.orig.PickupContainerItem = PickupContainerItem
|
||||
PickupContainerItem = Aux.PickupContainerItem
|
||||
|
||||
Aux.orig.ContainerFrameItemButton_OnClick = ContainerFrameItemButton_OnClick
|
||||
@@ -134,7 +124,6 @@ end
|
||||
|
||||
function Aux_OnAuctionHouseShow()
|
||||
|
||||
AuxButton:Show()
|
||||
AuxFrame:Show()
|
||||
|
||||
Aux.on_tab_click(1)
|
||||
@@ -173,6 +162,7 @@ function Aux.on_tab_click(index)
|
||||
AuxSellFrame:Hide()
|
||||
AuxBuyFrame:Hide()
|
||||
AuxHistoryFrame:Hide()
|
||||
AuxManageFrame:Hide()
|
||||
|
||||
if index == 1 then
|
||||
AuxBuyFrame:Show()
|
||||
@@ -181,6 +171,7 @@ function Aux.on_tab_click(index)
|
||||
AuxSellFrame:Show()
|
||||
Aux.sell.on_open()
|
||||
elseif index == 3 then
|
||||
AuxManageFrame:Show()
|
||||
Aux.manage_frame.on_open()
|
||||
elseif index == 4 then
|
||||
AuxHistoryFrame:Show()
|
||||
|
||||
@@ -262,19 +262,6 @@
|
||||
</Scripts>
|
||||
<HighlightTexture alphaMode="ADD" file="Interface\Buttons\ButtonHilight-Square"/>
|
||||
</Frame>
|
||||
|
||||
<Button name="AuxButton" inherits="UIPanelButtonTemplate" text="Aux" hidden="true">
|
||||
<Size><AbsDimension x="50" y="22"/></Size>
|
||||
<Scripts>
|
||||
<OnClick>
|
||||
if AuxFrame:IsVisible() then
|
||||
AuxFrame:Hide()
|
||||
else
|
||||
AuxFrame:Show()
|
||||
end
|
||||
</OnClick>
|
||||
</Scripts>
|
||||
</Button>
|
||||
|
||||
<Frame name="AuxFrame" toplevel="true" movable="true" enableMouse="true" hidden="true" parent="UIParent">
|
||||
<Size>
|
||||
@@ -288,6 +275,13 @@
|
||||
this:SetBackdropBorderColor(0.4, 0.4, 0.4)
|
||||
this:RegisterForDrag('LeftButton')
|
||||
</OnLoad>
|
||||
<OnShow>
|
||||
PlaySound('AuctionWindowOpen')
|
||||
</OnShow>
|
||||
<OnHide>
|
||||
PlaySound('AuctionWindowClose')
|
||||
CloseAuctionHouse()
|
||||
</OnHide>
|
||||
<OnDragStart>
|
||||
this:StartMoving()
|
||||
</OnDragStart>
|
||||
@@ -325,6 +319,21 @@
|
||||
</OnClick>
|
||||
</Scripts>
|
||||
</Button>
|
||||
<Button name="AuxAuctionFrameButton" inherits="UIPanelButtonTemplate" text="Default UI">
|
||||
<Size><AbsDimension x="120" y="26"/></Size>
|
||||
<Anchors><Anchor point="RIGHT" relativePoint="LEFT" relativeTo="AuxCloseButtonBottom"><Offset><AbsDimension x="-5" y="0"/></Offset></Anchor></Anchors>
|
||||
<Scripts>
|
||||
<OnClick>
|
||||
if AuctionFrame:IsVisible() then
|
||||
Aux.blizzard_ui_shown = false
|
||||
HideUIPanel(AuctionFrame)
|
||||
else
|
||||
Aux.blizzard_ui_shown = true
|
||||
ShowUIPanel(AuctionFrame)
|
||||
end
|
||||
</OnClick>
|
||||
</Scripts>
|
||||
</Button>
|
||||
<Button name="AuxTab1" inherits="AuxTabTemplate" id="1">
|
||||
<Anchors>
|
||||
<Anchor point="BOTTOMLEFT" relativePoint="TOPLEFT">
|
||||
|
||||
+37
-29
@@ -1,3 +1,5 @@
|
||||
local private, public = {}, {}
|
||||
|
||||
local on_open, on_close
|
||||
|
||||
local bid_records, auction_records, create_bid_record, create_auction_record, update_bid_records, update_auction_records, wait_for_bids, wait_for_auctions, create_record
|
||||
@@ -25,7 +27,7 @@ local bid_listing_config = {
|
||||
cell_initializer = Aux.sheet.default_cell_initializer('RIGHT'),
|
||||
cell_setter = function(cell, datum)
|
||||
cell.text:SetText(datum.stack_size)
|
||||
auction_alpha_setter(cell, datum)
|
||||
private.auction_alpha_setter(cell, datum)
|
||||
end,
|
||||
},
|
||||
{
|
||||
@@ -73,7 +75,7 @@ local bid_listing_config = {
|
||||
cell.text:SetText('['..datum.tooltip[1][1].text..']')
|
||||
local color = ITEM_QUALITY_COLORS[datum.quality]
|
||||
cell.text:SetTextColor(color.r, color.g, color.b)
|
||||
auction_alpha_setter(cell, datum)
|
||||
private.auction_alpha_setter(cell, datum)
|
||||
end,
|
||||
},
|
||||
{
|
||||
@@ -90,7 +92,7 @@ local bid_listing_config = {
|
||||
text = level
|
||||
end
|
||||
cell.text:SetText(text)
|
||||
auction_alpha_setter(cell, datum)
|
||||
private.auction_alpha_setter(cell, datum)
|
||||
end,
|
||||
},
|
||||
{
|
||||
@@ -110,7 +112,7 @@ local bid_listing_config = {
|
||||
text = '24h'
|
||||
end
|
||||
cell.text:SetText(text)
|
||||
auction_alpha_setter(cell, datum)
|
||||
private.auction_alpha_setter(cell, datum)
|
||||
end,
|
||||
},
|
||||
{
|
||||
@@ -120,7 +122,7 @@ local bid_listing_config = {
|
||||
cell_initializer = Aux.sheet.default_cell_initializer('LEFT'),
|
||||
cell_setter = function(cell, datum)
|
||||
cell.text:SetText(datum.owner)
|
||||
auction_alpha_setter(cell, datum)
|
||||
private.auction_alpha_setter(cell, datum)
|
||||
end,
|
||||
},
|
||||
{
|
||||
@@ -130,7 +132,7 @@ local bid_listing_config = {
|
||||
cell_initializer = Aux.sheet.default_cell_initializer('RIGHT'),
|
||||
cell_setter = function(cell, datum)
|
||||
cell.text:SetText(Aux.util.money_string(datum.bid_per_unit))
|
||||
auction_alpha_setter(cell, datum)
|
||||
private.auction_alpha_setter(cell, datum)
|
||||
end,
|
||||
},
|
||||
{
|
||||
@@ -140,7 +142,7 @@ local bid_listing_config = {
|
||||
cell_initializer = Aux.sheet.default_cell_initializer('RIGHT'),
|
||||
cell_setter = function(cell, datum)
|
||||
cell.text:SetText(Aux.util.money_string(datum.buyout_price_per_unit))
|
||||
auction_alpha_setter(cell, datum)
|
||||
private.auction_alpha_setter(cell, datum)
|
||||
end,
|
||||
},
|
||||
{
|
||||
@@ -150,7 +152,7 @@ local bid_listing_config = {
|
||||
cell_initializer = Aux.sheet.default_cell_initializer('RIGHT'),
|
||||
cell_setter = function(cell, datum)
|
||||
cell.text:SetText(Aux.util.money_string(datum.bid))
|
||||
auction_alpha_setter(cell, datum)
|
||||
private.auction_alpha_setter(cell, datum)
|
||||
end,
|
||||
},
|
||||
{
|
||||
@@ -160,7 +162,7 @@ local bid_listing_config = {
|
||||
cell_initializer = Aux.sheet.default_cell_initializer('RIGHT'),
|
||||
cell_setter = function(cell, datum)
|
||||
cell.text:SetText(Aux.util.money_string(datum.buyout_price))
|
||||
auction_alpha_setter(cell, datum)
|
||||
private.auction_alpha_setter(cell, datum)
|
||||
end,
|
||||
},
|
||||
},
|
||||
@@ -188,7 +190,7 @@ local auction_listing_config = {
|
||||
cell_initializer = Aux.sheet.default_cell_initializer('RIGHT'),
|
||||
cell_setter = function(cell, datum)
|
||||
cell.text:SetText(datum.stack_size)
|
||||
auction_alpha_setter(cell, datum)
|
||||
private.auction_alpha_setter(cell, datum)
|
||||
end,
|
||||
},
|
||||
{
|
||||
@@ -236,7 +238,7 @@ local auction_listing_config = {
|
||||
cell.text:SetText('['..datum.tooltip[1][1].text..']')
|
||||
local color = ITEM_QUALITY_COLORS[datum.quality]
|
||||
cell.text:SetTextColor(color.r, color.g, color.b)
|
||||
auction_alpha_setter(cell, datum)
|
||||
private.auction_alpha_setter(cell, datum)
|
||||
end,
|
||||
},
|
||||
{
|
||||
@@ -253,7 +255,7 @@ local auction_listing_config = {
|
||||
text = level
|
||||
end
|
||||
cell.text:SetText(text)
|
||||
auction_alpha_setter(cell, datum)
|
||||
private.auction_alpha_setter(cell, datum)
|
||||
end,
|
||||
},
|
||||
{
|
||||
@@ -273,7 +275,7 @@ local auction_listing_config = {
|
||||
text = '24h'
|
||||
end
|
||||
cell.text:SetText(text)
|
||||
auction_alpha_setter(cell, datum)
|
||||
private.auction_alpha_setter(cell, datum)
|
||||
end,
|
||||
},
|
||||
{
|
||||
@@ -283,7 +285,7 @@ local auction_listing_config = {
|
||||
cell_initializer = Aux.sheet.default_cell_initializer('LEFT'),
|
||||
cell_setter = function(cell, datum)
|
||||
cell.text:SetText(datum.owner)
|
||||
auction_alpha_setter(cell, datum)
|
||||
private.auction_alpha_setter(cell, datum)
|
||||
end,
|
||||
},
|
||||
{
|
||||
@@ -293,7 +295,7 @@ local auction_listing_config = {
|
||||
cell_initializer = Aux.sheet.default_cell_initializer('RIGHT'),
|
||||
cell_setter = function(cell, datum)
|
||||
cell.text:SetText(Aux.util.money_string(datum.bid_per_unit))
|
||||
auction_alpha_setter(cell, datum)
|
||||
private.auction_alpha_setter(cell, datum)
|
||||
end,
|
||||
},
|
||||
{
|
||||
@@ -303,7 +305,7 @@ local auction_listing_config = {
|
||||
cell_initializer = Aux.sheet.default_cell_initializer('RIGHT'),
|
||||
cell_setter = function(cell, datum)
|
||||
cell.text:SetText(Aux.util.money_string(datum.buyout_price_per_unit))
|
||||
auction_alpha_setter(cell, datum)
|
||||
private.auction_alpha_setter(cell, datum)
|
||||
end,
|
||||
},
|
||||
{
|
||||
@@ -313,7 +315,7 @@ local auction_listing_config = {
|
||||
cell_initializer = Aux.sheet.default_cell_initializer('RIGHT'),
|
||||
cell_setter = function(cell, datum)
|
||||
cell.text:SetText(Aux.util.money_string(datum.bid))
|
||||
auction_alpha_setter(cell, datum)
|
||||
private.auction_alpha_setter(cell, datum)
|
||||
end,
|
||||
},
|
||||
{
|
||||
@@ -323,7 +325,7 @@ local auction_listing_config = {
|
||||
cell_initializer = Aux.sheet.default_cell_initializer('RIGHT'),
|
||||
cell_setter = function(cell, datum)
|
||||
cell.text:SetText(Aux.util.money_string(datum.buyout_price))
|
||||
auction_alpha_setter(cell, datum)
|
||||
private.auction_alpha_setter(cell, datum)
|
||||
end,
|
||||
},
|
||||
},
|
||||
@@ -331,6 +333,9 @@ local auction_listing_config = {
|
||||
}
|
||||
|
||||
function on_open()
|
||||
Aux.list.populate(AuxManageBidsListing.sheet, {})
|
||||
Aux.list.populate(AuxManageAuctionsListing.sheet, {})
|
||||
|
||||
update_bid_records(function()
|
||||
update_auction_records(function()
|
||||
end)
|
||||
@@ -340,6 +345,10 @@ end
|
||||
function on_close()
|
||||
end
|
||||
|
||||
function private.auction_alpha_setter(cell, auction)
|
||||
cell:SetAlpha(auction.gone and 0.3 or 1)
|
||||
end
|
||||
|
||||
function update_bid_records(k)
|
||||
bid_records = {}
|
||||
Aux.scan.start{
|
||||
@@ -353,10 +362,10 @@ function update_bid_records(k)
|
||||
position = 'bids#'..page
|
||||
end,
|
||||
on_read_auction = function(i)
|
||||
snipe.log('bids#'..i)
|
||||
create_bid_record(i)
|
||||
end,
|
||||
on_complete = function()
|
||||
-- Aux.list.populate(AuxManageBidsListing.sheet, bid_records)
|
||||
Aux.list.populate(AuxManageBidsListing.sheet, bid_records)
|
||||
return k()
|
||||
end,
|
||||
on_abort = function()
|
||||
@@ -383,10 +392,10 @@ function update_auction_records(k)
|
||||
position = 'auctions#'..page
|
||||
end,
|
||||
on_read_auction = function(i)
|
||||
snipe.log('auctions#'..i)
|
||||
create_auction_record(i)
|
||||
end,
|
||||
on_complete = function()
|
||||
-- Aux.list.populate(AuxManageAuctionsListing.sheet, auction_records)
|
||||
Aux.list.populate(AuxManageAuctionsListing.sheet, auction_records)
|
||||
return k()
|
||||
end,
|
||||
on_abort = function()
|
||||
@@ -400,12 +409,12 @@ function update_auction_records(k)
|
||||
}
|
||||
end
|
||||
|
||||
function create_record(auction_item, current_page)
|
||||
function create_record(auction_item)
|
||||
|
||||
local stack_size = auction_item.charges or auction_item.count
|
||||
local bid = (auction_item.current_bid > 0 and auction_item.current_bid or auction_item.min_bid) + auction_item.min_increment
|
||||
local buyout_price = auction_item.buyout_price > 0 and auction_item.buyout_price or nil
|
||||
local buyout_price_per_unit = buyout_price and Aux_Round(auction_item.buyout_price/stack_size)
|
||||
local buyout_price_per_unit = buyout_price and Aux_Round(auction_item.buyout_price / stack_size)
|
||||
local status
|
||||
if auction_item.current_bid == 0 then
|
||||
status = 'No Bid'
|
||||
@@ -429,7 +438,6 @@ function create_record(auction_item, current_page)
|
||||
quality = auction_item.quality,
|
||||
hyperlink = auction_item.hyperlink,
|
||||
itemstring = auction_item.itemstring,
|
||||
page = current_page,
|
||||
bid = bid,
|
||||
bid_per_unit = Aux_Round(bid/stack_size),
|
||||
owner = auction_item.owner,
|
||||
@@ -443,16 +451,16 @@ function create_record(auction_item, current_page)
|
||||
end
|
||||
|
||||
function create_auction_record(index)
|
||||
local auction_item = Aux.info.auction_item(i, 'owner')
|
||||
local auction_item = Aux.info.auction_item(index, 'owner')
|
||||
if auction_item then
|
||||
tinsert(auction_records, create_record(auction_item, i))
|
||||
tinsert(auction_records, create_record(auction_item))
|
||||
end
|
||||
end
|
||||
|
||||
function create_bid_record(index)
|
||||
local auction_item = Aux.info.auction_item(i, 'bidder')
|
||||
local auction_item = Aux.info.auction_item(index, 'bidder')
|
||||
if auction_item then
|
||||
tinsert(auction_records, create_record(auction_item, i))
|
||||
tinsert(auction_records, create_record(auction_item))
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
+3
-3
@@ -14,7 +14,7 @@
|
||||
<Frames>
|
||||
<Frame name="AuxManageBids" inherits="AuxFrameBoxTemplate">
|
||||
<Size>
|
||||
<AbsDimension x="655" y="326"/>
|
||||
<AbsDimension x="400" y="326"/>
|
||||
</Size>
|
||||
<Anchors><Anchor point="TOPLEFT"><Offset><AbsDimension x="5" y="-35"/></Offset></Anchor></Anchors>
|
||||
<Scripts>
|
||||
@@ -25,7 +25,7 @@
|
||||
</OnLoad>
|
||||
</Scripts>
|
||||
<Frames>
|
||||
<Frame name="$parentListing" hidden="true">
|
||||
<Frame name="$parentListing">
|
||||
<Anchors>
|
||||
<Anchor point="TOPLEFT"><Offset><AbsDimension x="0" y="0"/></Offset></Anchor>
|
||||
<Anchor point="BOTTOMRIGHT"><Offset><AbsDimension x="-40" y="0"/></Offset></Anchor>
|
||||
@@ -117,7 +117,7 @@
|
||||
</OnLoad>
|
||||
</Scripts>
|
||||
<Frames>
|
||||
<Frame name="$parentListing" hidden="true">
|
||||
<Frame name="$parentListing">
|
||||
<Anchors>
|
||||
<Anchor point="TOPLEFT"><Offset><AbsDimension x="0" y="0"/></Offset></Anchor>
|
||||
<Anchor point="BOTTOMRIGHT"><Offset><AbsDimension x="-40" y="0"/></Offset></Anchor>
|
||||
|
||||
+29
-114
@@ -1,19 +1,20 @@
|
||||
local on_load, load_dataset, new_dataset, get_dataset_key, get_snapshot, load_item_record, store_item_record, load_item_history, add_historical_point
|
||||
local encode_median_list, decode_median_list, serialize, deserialize
|
||||
|
||||
local DATABASE_VERSION = 0
|
||||
|
||||
local private, public = {}, {}
|
||||
Aux.persistence = public
|
||||
|
||||
aux_database = {}
|
||||
|
||||
function on_load()
|
||||
function public.on_load()
|
||||
perform_migration(aux_database)
|
||||
aux_database.version = DATABASE_VERSION
|
||||
end
|
||||
|
||||
function get_dataset_key()
|
||||
function private.get_dataset_key()
|
||||
local realm = GetCVar('realmName')
|
||||
local zone = GetMinimapZoneText()
|
||||
local faction
|
||||
-- TODO use UnitFactionGroup(unit) or race with auctioneer instead to work for all locales
|
||||
if zone == 'Gadgetzan' or zone == 'Everlook' or zone == 'Booty Bay' then
|
||||
faction = 'Neutral'
|
||||
else
|
||||
@@ -22,114 +23,36 @@ function get_dataset_key()
|
||||
return realm..'|'..faction
|
||||
end
|
||||
|
||||
function new_dataset()
|
||||
return {
|
||||
snapshot = {},
|
||||
item_data = {},
|
||||
item_history = {}
|
||||
}
|
||||
end
|
||||
|
||||
function load_dataset()
|
||||
local dataset_key = get_dataset_key()
|
||||
aux_database[dataset_key] = aux_database[dataset_key] or new_dataset()
|
||||
function private.load_dataset()
|
||||
local dataset_key = private.get_dataset_key()
|
||||
aux_database[dataset_key] = aux_database[dataset_key] or {}
|
||||
return aux_database[dataset_key]
|
||||
end
|
||||
|
||||
function get_snapshot()
|
||||
local dataset = load_dataset()
|
||||
local snapshot = Aux.util.set()
|
||||
snapshot.set_data(dataset.snapshot)
|
||||
return snapshot
|
||||
end
|
||||
function public.load_scan_records(item_key)
|
||||
local dataset = private.load_dataset()
|
||||
|
||||
function load_item_history(item_key)
|
||||
local dataset = load_dataset()
|
||||
|
||||
local serialized_points = deserialize(dataset.item_history(item_key) or '', ';')
|
||||
return Aux.util.map(serialized_points, function(serialized_point)
|
||||
local time, market_price = deserialize(serialized_point, '#')
|
||||
return { time=time, market_price=market_price }
|
||||
local serialized_records = private.deserialize(dataset[item_key] or '', ';')
|
||||
return Aux.util.map(serialized_records, function(serialized_record)
|
||||
local time, count, min_price, accumulated_price = private.deserialize(serialized_record, '#')
|
||||
return {
|
||||
time = time,
|
||||
count = count,
|
||||
min_price = min_price,
|
||||
accumulated_price = accumulated_price,
|
||||
}
|
||||
end)
|
||||
end
|
||||
|
||||
function add_historical_point(item_key)
|
||||
local dataset = load_dataset()
|
||||
local serialized_historical_point = serialize({time(), Aux.history.get_market_value(item_key) }, '#')
|
||||
local serialized_history = dataset.item_history[item_key] or ''
|
||||
serialized_history = (serialized_history == '' and serialized_history..';' or '')..serialized_historical_point
|
||||
dataset.item_history[item_key] = serialized_history
|
||||
function public.store_scan_record(item_key, record)
|
||||
local dataset = private.load_dataset()
|
||||
local serialized_record = private.serialize({ record.time, record.count, record.min_price, record.accumulated_price }, '#')
|
||||
local serialized_records = dataset[item_key] or ''
|
||||
serialized_records = serialized_records..(serialized_records == '' and '' or ';')..serialized_record
|
||||
dataset[item_key] = serialized_records
|
||||
end
|
||||
|
||||
function load_item_record(item_key)
|
||||
local dataset = load_dataset()
|
||||
|
||||
if dataset.item_data[item_key] then
|
||||
local serialized_record = dataset.item_data[item_key]
|
||||
local count, accumulated_price, encoded_median_list = unpack(deserialize(serialized_record, '|'))
|
||||
assert(count and accumulated_price and encode_median_list)
|
||||
local median_list = decode_median_list(encoded_median_list)
|
||||
|
||||
return {
|
||||
count = count,
|
||||
accumulated_price = accumulated_price,
|
||||
median_list = median_list
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
function store_item_record(item_key, record)
|
||||
local dataset = load_dataset()
|
||||
|
||||
local encoded_median_list = encode_median_list(record.median_list)
|
||||
local serialized_record = serialize({record.count, record.accumulated_price, encoded_median_list}, '|')
|
||||
|
||||
dataset.item_data[item_key] = serialized_record
|
||||
end
|
||||
|
||||
function encode_median_list(list)
|
||||
local encoded_list = ''
|
||||
local function extend(value, count)
|
||||
if count == 1 then
|
||||
encoded_list = encoded_list == '' and value or string.format('%s:%d', encoded_list, value)
|
||||
elseif count > 1 then
|
||||
encoded_list = encoded_list == '' and string.format('%dx%d', value, count) or string.format('%s:%dx%d', encoded_list, value, count)
|
||||
end
|
||||
end
|
||||
local n = 0
|
||||
local last = 0
|
||||
for i, price in pairs(list) do
|
||||
if i == 1 then
|
||||
last = price
|
||||
elseif price ~= last then
|
||||
extend(last, n)
|
||||
last = price
|
||||
n = 0
|
||||
end
|
||||
n = n + 1
|
||||
end
|
||||
extend(last, n)
|
||||
return encoded_list
|
||||
end
|
||||
|
||||
function decode_median_list(encoded_list)
|
||||
local array = {}
|
||||
for part, separator in string.gfind(encoded_list, '([^%:]*)(%:?)') do
|
||||
local _, _, value, count = strfind(part, '(%d*)x(%d*)')
|
||||
if not count then
|
||||
tinsert(array, tonumber(part))
|
||||
else
|
||||
for i = 1,count do
|
||||
tinsert(array, tonumber(value))
|
||||
end
|
||||
end
|
||||
if separator == '' then break end
|
||||
end
|
||||
return array
|
||||
end
|
||||
|
||||
function serialize(data, separator)
|
||||
assert(getn(data) == 3)
|
||||
function private.serialize(data, separator)
|
||||
local data_string = ''
|
||||
for i, datum in ipairs(data) do
|
||||
data_string = data_string..(i == 1 and '' or separator)..datum
|
||||
@@ -137,7 +60,7 @@ function serialize(data, separator)
|
||||
return data_string
|
||||
end
|
||||
|
||||
function deserialize(data_string, separator)
|
||||
function private.deserialize(data_string, separator)
|
||||
if data_string == '' then
|
||||
return {}
|
||||
end
|
||||
@@ -153,12 +76,4 @@ function deserialize(data_string, separator)
|
||||
return data
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Aux.persistence = {
|
||||
load_item_record = load_item_record,
|
||||
store_item_record = store_item_record,
|
||||
load_item_history = load_item_history,
|
||||
add_historical_point = add_historical_point,
|
||||
get_snapshot = get_snapshot,
|
||||
}
|
||||
end
|
||||
+1
-1
@@ -265,7 +265,7 @@
|
||||
</Frame>
|
||||
<Button name="AuxSellRefreshButton" inherits="UIPanelButtonTemplate" text="Refresh">
|
||||
<Size><AbsDimension x="90" y="26"/></Size>
|
||||
<Anchors><Anchor point="RIGHT" relativePoint="LEFT" relativeTo="AuxCloseButtonBottom"><Offset><AbsDimension x="-25" y="0"/></Offset></Anchor></Anchors>
|
||||
<Anchors><Anchor point="RIGHT" relativePoint="LEFT" relativeTo="AuxAuctionFrameButton"><Offset><AbsDimension x="-25" y="0"/></Offset></Anchor></Anchors>
|
||||
<Scripts>
|
||||
<OnClick>
|
||||
AuxSellRefreshButton_OnClick()
|
||||
|
||||
@@ -137,6 +137,7 @@ end
|
||||
function submit_query(k)
|
||||
if state.page then
|
||||
controller().wait(function() return state.job.type ~= 'list' or CanSendAuctionQuery() end, function()
|
||||
snipe.log('kek')
|
||||
if state.job.on_submit_query then
|
||||
state.job.on_submit_query()
|
||||
end
|
||||
@@ -144,7 +145,7 @@ function submit_query(k)
|
||||
--wait_for_owner_data(function()
|
||||
local _, total_count = GetNumAuctionItems(state.job.type)
|
||||
state.total_pages = math.ceil(total_count / PAGE_SIZE)
|
||||
if total_pages >= state.page + 1 then
|
||||
if state.total_pages >= state.page + 1 then
|
||||
wait_for_callback{state.job.on_page_loaded, state.page, state.total_pages, function()
|
||||
return k()
|
||||
end}
|
||||
@@ -155,7 +156,6 @@ function submit_query(k)
|
||||
end)
|
||||
if state.job.type == 'bidder' then
|
||||
GetBidderAuctionItems(state.page)
|
||||
snipe.log('kek'..state.page)
|
||||
elseif state.job.type == 'owner' then
|
||||
GetOwnerAuctionItems(state.page)
|
||||
else
|
||||
|
||||
+21
-192
@@ -7,7 +7,7 @@ Aux.history = {}
|
||||
local process_auction, balanced_list, update_snapshot
|
||||
local get_market_price, get_usable_median, get_historical_median, get_median, get_percentile
|
||||
|
||||
local price_cache
|
||||
local auction_cache
|
||||
|
||||
function Aux.history.on_close()
|
||||
|
||||
@@ -26,7 +26,7 @@ function Aux.history.start_scan()
|
||||
AuxHistoryScanButton:Hide()
|
||||
AuxHistoryStopButton:Show()
|
||||
|
||||
price_cache = {}
|
||||
auction_cache = {}
|
||||
|
||||
Aux.log('Scanning auctions ...')
|
||||
Aux.scan.start{
|
||||
@@ -39,12 +39,14 @@ function Aux.history.start_scan()
|
||||
process_auction(i)
|
||||
end,
|
||||
on_complete = function()
|
||||
process_scanned_prices()
|
||||
process_scanned_auctions()
|
||||
|
||||
AuxHistoryStopButton:Hide()
|
||||
AuxHistoryScanButton:Show()
|
||||
end,
|
||||
on_abort = function()
|
||||
process_scanned_auctions()
|
||||
|
||||
AuxHistoryStopButton:Hide()
|
||||
AuxHistoryScanButton:Show()
|
||||
end,
|
||||
@@ -59,8 +61,20 @@ function Aux.history.start_scan()
|
||||
}
|
||||
end
|
||||
|
||||
function process_scanned_prices()
|
||||
for item_key, item_data in price_cache do
|
||||
function process_scanned_auctions()
|
||||
local time = time()
|
||||
for item_key, auctions in pairs(auction_cache) do
|
||||
local min_price, accumulated_price
|
||||
for _, auction in ipairs(auctions) do
|
||||
min_price = min_price and min(min_price, auction.price) or auction.price
|
||||
accumulated_price = (accumulated_price or 0) + auction.price
|
||||
end
|
||||
Aux.persistence.store_scan_record(item_key, {
|
||||
time = time,
|
||||
count = getn(auctions),
|
||||
min_price = min_price,
|
||||
accumulated_price = accumulated_price,
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
@@ -76,192 +90,7 @@ function process_auction(index)
|
||||
local price = ceil(buyout_price / aux_quantity)
|
||||
local item_key = auction_info.item_signature
|
||||
|
||||
local signature = Aux.info.auction_signature(index)
|
||||
scanned_signatures.add(signature)
|
||||
|
||||
local snapshot = Aux.persistence.get_snapshot()
|
||||
if not snapshot.contains(signature) then
|
||||
snapshot.add(signature)
|
||||
|
||||
local item_record = Aux.persistence.load_item_record(item_key)
|
||||
|
||||
item_record = item_record or {
|
||||
count = 0,
|
||||
accumulated_price = 0,
|
||||
median_list = {},
|
||||
}
|
||||
|
||||
local median_list = balanced_list(MAX_HISTORY_SIZE)
|
||||
median_list.add_all(item_record.median_list)
|
||||
median_list.add(price)
|
||||
|
||||
Aux.persistence.store_item_record(item_key, {
|
||||
count = item_record.count + 1,
|
||||
accumulated_price = item_record.accumulated_price + price,
|
||||
median_list = median_list.values(),
|
||||
})
|
||||
end
|
||||
auction_cache[item_key] = auction_cache[item_key] or {}
|
||||
tinsert(auction_cache[item_key], { price=price })
|
||||
end
|
||||
end
|
||||
|
||||
function Aux.history.get_market_price(item_key)
|
||||
local market_price
|
||||
|
||||
local item_record = Aux.persistence.load_item_record(item_key)
|
||||
|
||||
if item_record then
|
||||
local median = get_usable_median(item_record.median_list)
|
||||
|
||||
if median then
|
||||
market_price = median
|
||||
elseif item_record.count > 0 then
|
||||
market_price = item_record.accumulated_price / item_record.count
|
||||
end
|
||||
end
|
||||
|
||||
return market_price
|
||||
end
|
||||
|
||||
function get_usable_median(values)
|
||||
|
||||
local median, count = get_median(values)
|
||||
if count >= MIN_SEEN then
|
||||
return median, count
|
||||
end
|
||||
end
|
||||
|
||||
function get_median(values)
|
||||
return get_percentile(values, 0.5)
|
||||
end
|
||||
|
||||
-- Return weighted average percentile such that returned value
|
||||
-- is larger than or equal to (100*pct)% of the table values
|
||||
-- 0 <= pct <= 1
|
||||
function get_percentile(values, pct)
|
||||
|
||||
local _percentile = function(sorted_values, pct, first, last)
|
||||
local f = (last - first) * pct + first
|
||||
local i1, i2 = floor(f), ceil(f)
|
||||
f = f - i1
|
||||
|
||||
return sorted_values[i1] * (1 - f) + sorted_values[i2] * f
|
||||
end
|
||||
|
||||
local n = getn(values)
|
||||
|
||||
if n == 0 then
|
||||
return 0, 0 -- if there is an empty table, returns median = 0, count = 0
|
||||
elseif n == 1 then
|
||||
return tonumber(values[1]), 1
|
||||
end
|
||||
|
||||
-- The following calculations require a sorted table
|
||||
table.sort(values)
|
||||
|
||||
-- Skip IQR calculations if table is too small to have outliers
|
||||
if n <= 4 then
|
||||
return _percentile(values, pct, 1, n), n
|
||||
end
|
||||
|
||||
-- REWORK by Karavirs to use IQR*1.5 to ignore outliers
|
||||
-- q1 is median 1st quartile q2 is median of set q3 is median of 3rd quartile iqr is q3 - q1
|
||||
local q1 = _percentile(values, 0.25, 1, n)
|
||||
local q3 = _percentile(values, 0.75, 1, n)
|
||||
|
||||
local iqr = (q3 - q1) * 1.5
|
||||
local iqlow, iqhigh = q1 - iqr, q3 + iqr
|
||||
|
||||
-- Find first and last index to include in median calculation
|
||||
local first, last = 1, n
|
||||
|
||||
-- Skip low outliers
|
||||
while values[first] < iqlow do
|
||||
first = first + 1
|
||||
end
|
||||
|
||||
-- Skip high outliers
|
||||
while values[last] > iqhigh do
|
||||
last = last - 1
|
||||
end
|
||||
|
||||
return _percentile(values, pct, first, last), last - first + 1
|
||||
end
|
||||
|
||||
function balanced_list(max_size, cmp)
|
||||
local self = {}
|
||||
|
||||
local values = {}
|
||||
|
||||
cmp = cmp or Aux.util.compare
|
||||
|
||||
function self.add(value)
|
||||
|
||||
local left = 1
|
||||
local right = getn(values)
|
||||
local middle_value
|
||||
local middle
|
||||
|
||||
local destination
|
||||
while left <= right do
|
||||
middle = floor((right - left) / 2) + left
|
||||
middle_value = values[middle]
|
||||
if cmp(value, middle_value) == Aux.util.LT then
|
||||
right = middle - 1
|
||||
elseif cmp(value, middle_value) == Aux.util.GT then
|
||||
left = middle + 1
|
||||
else
|
||||
destination = middle
|
||||
break
|
||||
end
|
||||
end
|
||||
destination = destination or left
|
||||
|
||||
tinsert(values, destination, value)
|
||||
|
||||
if max_size and getn(values) > max_size then
|
||||
if destination <= floor(max_size / 2) + 1 then
|
||||
tremove(values)
|
||||
else
|
||||
tremove(values, 1)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function self.add_all(array)
|
||||
self.clear()
|
||||
for _, value in ipairs(array) do
|
||||
self.add(value)
|
||||
end
|
||||
end
|
||||
|
||||
function self.clear()
|
||||
values = {}
|
||||
end
|
||||
|
||||
function self.values()
|
||||
local result = {}
|
||||
for _, value in ipairs(values) do
|
||||
tinsert(result, value)
|
||||
end
|
||||
return result
|
||||
end
|
||||
|
||||
function self.size()
|
||||
return getn(values)
|
||||
end
|
||||
|
||||
function self.get(index)
|
||||
return values[index]
|
||||
end
|
||||
|
||||
function self.max_size()
|
||||
return max_size
|
||||
end
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
function Aux.history.get_price_suggestion(key, quantity)
|
||||
local market_price = Aux.history.get_market_price(key)
|
||||
return market_price and market_price * quantity * UNDERCUT_FACTOR or 0
|
||||
end
|
||||
|
||||
+2
-2
@@ -14,7 +14,7 @@
|
||||
<Frames>
|
||||
<Button name="AuxHistoryScanButton" inherits="UIPanelButtonTemplate" text="Scan">
|
||||
<Size><AbsDimension x="90" y="26"/></Size>
|
||||
<Anchors><Anchor point="RIGHT" relativePoint="LEFT" relativeTo="AuxCloseButtonBottom"><Offset><AbsDimension x="-25" y="0"/></Offset></Anchor></Anchors>
|
||||
<Anchors><Anchor point="RIGHT" relativePoint="LEFT" relativeTo="AuxAuctionFrameButton"><Offset><AbsDimension x="-25" y="0"/></Offset></Anchor></Anchors>
|
||||
<Scripts>
|
||||
<OnClick>
|
||||
Aux.history.start_scan()
|
||||
@@ -24,7 +24,7 @@
|
||||
|
||||
<Button name="AuxHistoryStopButton" inherits="UIPanelButtonTemplate" text="Stop" hidden="true">
|
||||
<Size><AbsDimension x="90" y="26"/></Size>
|
||||
<Anchors><Anchor point="RIGHT" relativePoint="LEFT" relativeTo="AuxCloseButtonBottom"><Offset><AbsDimension x="-25" y="0"/></Offset></Anchor></Anchors>
|
||||
<Anchors><Anchor point="RIGHT" relativePoint="LEFT" relativeTo="AuxAuctionFrameButton"><Offset><AbsDimension x="-25" y="0"/></Offset></Anchor></Anchors>
|
||||
<Scripts>
|
||||
<OnClick>
|
||||
Aux.history.stop_scan()
|
||||
|
||||
+2
-19
@@ -1,6 +1,6 @@
|
||||
Aux.buy = {}
|
||||
|
||||
local create_auction_record, show_dialog, find_auction, hide_sheet, update_sheet, auction_alpha_setter, group_alpha_setter
|
||||
local create_auction_record, show_dialog, find_auction, hide_sheet, update_sheet, auction_alpha_setter, group_alpha_setter, create_auction_record
|
||||
local auctions
|
||||
local search_query
|
||||
local tooltip_patterns = {}
|
||||
@@ -45,7 +45,7 @@ Aux.buy.modes = {
|
||||
},
|
||||
{
|
||||
title = 'Auction Item',
|
||||
width = 312,
|
||||
width = 342,
|
||||
comparator = function(group1, group2) return Aux.util.compare(group1[1].name, group2[1].name, Aux.util.GT) end,
|
||||
cell_initializer = function(cell)
|
||||
local icon = CreateFrame('Button', nil, cell)
|
||||
@@ -121,23 +121,6 @@ Aux.buy.modes = {
|
||||
group_alpha_setter(cell, group)
|
||||
end,
|
||||
},
|
||||
{
|
||||
title = 'Pct',
|
||||
width = 30,
|
||||
comparator = function(group1, group2)
|
||||
local market_price1 = Aux.history.get_market_price(group1[1].key)
|
||||
local market_price2 = Aux.history.get_market_price(group2[1].key)
|
||||
local factor1 = market_price1 and group1[1].buyout_price_per_unit / market_price1
|
||||
local factor2 = market_price2 and group2[1].buyout_price_per_unit / market_price2
|
||||
return Aux.util.compare(factor1, factor2, Aux.util.GT)
|
||||
end,
|
||||
cell_initializer = Aux.sheet.default_cell_initializer('RIGHT'),
|
||||
cell_setter = function(cell, group)
|
||||
local market_price = Aux.history.get_market_price(group[1].key)
|
||||
cell.text:SetText(market_price and ceil(100 / group[1].buyout_price_per_unit * market_price)..'%' or 'N/A')
|
||||
group_alpha_setter(cell, group)
|
||||
end,
|
||||
},
|
||||
},
|
||||
sort_order = {{column = 2, order = 'ascending' }, {column = 4, order = 'ascending'}},
|
||||
},
|
||||
|
||||
+2
-2
@@ -399,7 +399,7 @@
|
||||
</Frame>
|
||||
<Button name="AuxBuySearchButton" inherits="UIPanelButtonTemplate" text="Search">
|
||||
<Size><AbsDimension x="90" y="26"/></Size>
|
||||
<Anchors><Anchor point="RIGHT" relativePoint="LEFT" relativeTo="AuxCloseButtonBottom"><Offset><AbsDimension x="-25" y="0"/></Offset></Anchor></Anchors>
|
||||
<Anchors><Anchor point="RIGHT" relativePoint="LEFT" relativeTo="AuxAuctionFrameButton"><Offset><AbsDimension x="-25" y="0"/></Offset></Anchor></Anchors>
|
||||
<Scripts>
|
||||
<OnClick>
|
||||
Aux.buy.SearchButton_onclick()
|
||||
@@ -409,7 +409,7 @@
|
||||
|
||||
<Button name="AuxBuyStopButton" inherits="UIPanelButtonTemplate" text="Stop" hidden="true">
|
||||
<Size><AbsDimension x="90" y="26"/></Size>
|
||||
<Anchors><Anchor point="RIGHT" relativePoint="LEFT" relativeTo="AuxCloseButtonBottom"><Offset><AbsDimension x="-25" y="0"/></Offset></Anchor></Anchors>
|
||||
<Anchors><Anchor point="RIGHT" relativePoint="LEFT" relativeTo="AuxAuctionFrameButton"><Offset><AbsDimension x="-25" y="0"/></Offset></Anchor></Anchors>
|
||||
<Scripts>
|
||||
<OnClick>
|
||||
Aux.buy.StopButton_onclick()
|
||||
|
||||
Reference in New Issue
Block a user