some work on scanning and the auctions/bids tab
This commit is contained in:
@@ -167,7 +167,7 @@ function Aux.on_tab_click(index)
|
||||
Aux.manage_frame.on_close()
|
||||
Aux.history.on_close()
|
||||
|
||||
for i=1,5 do
|
||||
for i=1,4 do
|
||||
getglobal('AuxTab'..i):SetAlpha(i == index and 1 or 0.5)
|
||||
end
|
||||
|
||||
|
||||
@@ -363,7 +363,7 @@
|
||||
</Anchors>
|
||||
<Scripts>
|
||||
<OnLoad>
|
||||
getglobal(this:GetName().."Text"):SetText('Auctions')
|
||||
getglobal(this:GetName().."Text"):SetText('Manage')
|
||||
</OnLoad>
|
||||
</Scripts>
|
||||
</Button>
|
||||
@@ -375,20 +375,6 @@
|
||||
</Offset>
|
||||
</Anchor>
|
||||
</Anchors>
|
||||
<Scripts>
|
||||
<OnLoad>
|
||||
getglobal(this:GetName().."Text"):SetText('Bids')
|
||||
</OnLoad>
|
||||
</Scripts>
|
||||
</Button>
|
||||
<Button name="AuxTab5" inherits="AuxTabTemplate" id="5">
|
||||
<Anchors>
|
||||
<Anchor point="LEFT" relativeTo="AuxTab4" relativePoint="RIGHT">
|
||||
<Offset>
|
||||
<AbsDimension x="0" y="0"/>
|
||||
</Offset>
|
||||
</Anchor>
|
||||
</Anchors>
|
||||
<Scripts>
|
||||
<OnLoad>
|
||||
getglobal(this:GetName().."Text"):SetText('Scan')
|
||||
|
||||
@@ -52,8 +52,10 @@ function Aux.info.auction_sell_item()
|
||||
end
|
||||
end
|
||||
|
||||
function Aux.info.auction_item(index)
|
||||
local hyperlink = GetAuctionItemLink('list', index)
|
||||
function Aux.info.auction_item(index, type)
|
||||
type = type or 'list'
|
||||
|
||||
local hyperlink = GetAuctionItemLink(type, index)
|
||||
|
||||
if not hyperlink then
|
||||
return
|
||||
@@ -62,8 +64,8 @@ function Aux.info.auction_item(index)
|
||||
local auction_item = hyperlink_item(hyperlink)
|
||||
auction_item.item_signature = item_signature(hyperlink)
|
||||
|
||||
local name, texture, count, quality, usable, level, min_bid, min_increment, buyout_price, current_bid, high_bidder, owner, sale_status, id = GetAuctionItemInfo("list", index)
|
||||
local duration = GetAuctionItemTimeLeft("list", index)
|
||||
local name, texture, count, quality, usable, level, min_bid, min_increment, buyout_price, current_bid, high_bidder, owner, sale_status, id = GetAuctionItemInfo(type, index)
|
||||
local duration = GetAuctionItemTimeLeft(type, index)
|
||||
|
||||
auction_item.texture = texture
|
||||
auction_item.count = count
|
||||
@@ -77,7 +79,7 @@ function Aux.info.auction_item(index)
|
||||
auction_item.id = id
|
||||
auction_item.duration = duration
|
||||
auction_item.usable = usable
|
||||
auction_item.tooltip = Aux.info.tooltip(function(tt) tt:SetAuctionItem("list", index) end)
|
||||
auction_item.tooltip = Aux.info.tooltip(function(tt) tt:SetAuctionItem(type, index) end)
|
||||
auction_item.charges = item_charges(auction_item.tooltip)
|
||||
|
||||
auction_item.EnhTooltip_info = {
|
||||
|
||||
+360
-128
@@ -1,11 +1,13 @@
|
||||
local on_open, on_close
|
||||
|
||||
local bid_records, auctions_records, create_maybe_bid_record, create_maybe_auction_record
|
||||
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
|
||||
|
||||
local position
|
||||
|
||||
local bid_listing_config = {
|
||||
on_cell_click = function (sheet, row_index, column_index)
|
||||
local data_index = row_index + FauxScrollFrame_GetOffset(sheet.scroll_frame)
|
||||
set_auction(sheet.data[data_index])
|
||||
AuxBuyEntry_OnClick(sheet.data[data_index])
|
||||
end,
|
||||
|
||||
on_cell_enter = function (sheet, row_index, column_index)
|
||||
@@ -13,34 +15,23 @@ local bid_listing_config = {
|
||||
end,
|
||||
|
||||
on_cell_leave = function (sheet, row_index, column_index)
|
||||
local data_index = row_index + FauxScrollFrame_GetOffset(sheet.scroll_frame)
|
||||
if not (current_auction and sheet.data[data_index] == current_auction) then
|
||||
sheet.rows[row_index].highlight:SetAlpha(0)
|
||||
end
|
||||
sheet.rows[row_index].highlight:SetAlpha(0)
|
||||
end,
|
||||
|
||||
row_setter = function(row, datum)
|
||||
if current_auction and datum == current_auction then
|
||||
row.highlight:SetAlpha(.5)
|
||||
else
|
||||
row.highlight:SetAlpha(0)
|
||||
end
|
||||
end,
|
||||
|
||||
columns = {
|
||||
{
|
||||
title = 'Qty',
|
||||
width = 23,
|
||||
comparator = function(datum1, datum2) return Aux.util.compare(datum1.aux_quantity, datum2.aux_quantity, Aux.util.LT) end,
|
||||
comparator = function(row1, row2) return Aux.util.compare(row1.stack_size, row2.stack_size, Aux.util.LT) end,
|
||||
cell_initializer = Aux.sheet.default_cell_initializer('RIGHT'),
|
||||
cell_setter = function(cell, datum)
|
||||
cell.text:SetText(datum.aux_quantity)
|
||||
cell.text:SetText(datum.stack_size)
|
||||
auction_alpha_setter(cell, datum)
|
||||
end,
|
||||
},
|
||||
{
|
||||
title = 'Item',
|
||||
width = 186,
|
||||
comparator = function(row1, row2) return Aux.util.compare(row1.name, row2.name, Aux.util.GT) end,
|
||||
title = 'Auction Item',
|
||||
width = 157,
|
||||
comparator = function(row1, row2) return Aux.util.compare(row1.tooltip[1][1].text, row2.tooltip[1][1].text, Aux.util.GT) end,
|
||||
cell_initializer = function(cell)
|
||||
local icon = CreateFrame('Button', nil, cell)
|
||||
local icon_texture = icon:CreateTexture(nil, 'BORDER')
|
||||
@@ -58,6 +49,8 @@ local bid_listing_config = {
|
||||
icon:SetNormalTexture('Interface\\Buttons\\UI-Quickslot2')
|
||||
icon:SetPushedTexture('Interface\\Buttons\\UI-Quickslot-Depress')
|
||||
icon:SetHighlightTexture('Interface\\Buttons\\ButtonHilight-Square')
|
||||
icon:SetScript('OnEnter', function() Aux.info.set_game_tooltip(this, cell.tooltip, 'ANCHOR_RIGHT', cell.EnhTooltip_info) end)
|
||||
icon:SetScript('OnLeave', function() GameTooltip:Hide() end)
|
||||
local text = cell:CreateFontString(nil, 'OVERLAY', 'GameFontHighlightSmall')
|
||||
text:SetPoint("LEFT", icon, "RIGHT", 1, 0)
|
||||
text:SetPoint('TOPRIGHT', cell)
|
||||
@@ -69,96 +62,95 @@ local bid_listing_config = {
|
||||
cell.icon = icon
|
||||
end,
|
||||
cell_setter = function(cell, datum)
|
||||
cell.tooltip = datum.tooltip
|
||||
cell.EnhTooltip_info = datum.EnhTooltip_info
|
||||
cell.icon.icon_texture:SetTexture(datum.texture)
|
||||
cell.text:SetText('['..datum.name..']')
|
||||
if not datum.usable then
|
||||
cell.icon.icon_texture:SetVertexColor(1.0, 0.1, 0.1)
|
||||
else
|
||||
cell.icon.icon_texture:SetVertexColor(1.0, 1.0, 1.0)
|
||||
end
|
||||
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)
|
||||
end,
|
||||
},
|
||||
},
|
||||
sort_order = {{column = 2, order = 'ascending' }},
|
||||
}
|
||||
|
||||
local auction_listing_config = {
|
||||
on_cell_click = function (sheet, row_index, column_index)
|
||||
local data_index = row_index + FauxScrollFrame_GetOffset(sheet.scroll_frame)
|
||||
AuxSellEntry_OnClick(sheet.data[data_index])
|
||||
end,
|
||||
|
||||
on_cell_enter = function (sheet, row_index, column_index)
|
||||
sheet.rows[row_index].highlight:SetAlpha(.5)
|
||||
end,
|
||||
|
||||
on_cell_leave = function (sheet, row_index, column_index)
|
||||
local data_index = row_index + FauxScrollFrame_GetOffset(sheet.scroll_frame)
|
||||
local datum = sheet.data[data_index]
|
||||
if not (datum and current_auction and Aux.util.safe_index{auxSellEntries, current_auction.name, 'selected', 'key'} == datum.key) then
|
||||
sheet.rows[row_index].highlight:SetAlpha(0)
|
||||
end
|
||||
end,
|
||||
|
||||
row_setter = function(row, datum)
|
||||
if datum and current_auction and Aux.util.safe_index{auxSellEntries, current_auction.name, 'selected', 'key'} == datum.key then
|
||||
row.highlight:SetAlpha(.5)
|
||||
else
|
||||
row.highlight:SetAlpha(0)
|
||||
end
|
||||
end,
|
||||
|
||||
columns = {
|
||||
{
|
||||
title = 'Avail',
|
||||
width = 40,
|
||||
comparator = function(row1, row2) return Aux.util.compare(row1.count, row2.count, Aux.util.LT) end,
|
||||
title = 'Lvl',
|
||||
width = 23,
|
||||
comparator = function(row1, row2) return Aux.util.compare(row1.level, row2.level, Aux.util.GT) end,
|
||||
cell_initializer = Aux.sheet.default_cell_initializer('RIGHT'),
|
||||
cell_setter = function(cell, row)
|
||||
cell.text:SetText(row.count)
|
||||
cell_setter = function(cell, datum)
|
||||
local level = max(1, datum.level)
|
||||
local text
|
||||
if level > UnitLevel('player') then
|
||||
text = RED_FONT_COLOR_CODE..level..FONT_COLOR_CODE_CLOSE
|
||||
else
|
||||
text = level
|
||||
end
|
||||
cell.text:SetText(text)
|
||||
auction_alpha_setter(cell, datum)
|
||||
end,
|
||||
},
|
||||
{
|
||||
title = 'Yours',
|
||||
width = 40,
|
||||
comparator = function(row1, row2) return Aux.util.compare(row1.yours, row2.yours, Aux.util.LT) end,
|
||||
cell_initializer = Aux.sheet.default_cell_initializer('RIGHT'),
|
||||
cell_setter = function(cell, row)
|
||||
cell.text:SetText(row.yours)
|
||||
end,
|
||||
},
|
||||
{
|
||||
title = 'Max Left',
|
||||
width = 55,
|
||||
comparator = function(row1, row2) return Aux.util.compare(row1.max_time_left, row2.max_time_left, Aux.util.GT) end,
|
||||
title = 'Left',
|
||||
width = 30,
|
||||
comparator = function(row1, row2) return Aux.util.compare(row1.duration, row2.duration, Aux.util.GT) end,
|
||||
cell_initializer = Aux.sheet.default_cell_initializer('CENTER'),
|
||||
cell_setter = function(cell, datum)
|
||||
local text
|
||||
if datum.max_time_left == 1 then
|
||||
if datum.duration == 1 then
|
||||
text = '30m'
|
||||
elseif datum.max_time_left == 2 then
|
||||
elseif datum.duration == 2 then
|
||||
text = '2h'
|
||||
elseif datum.max_time_left == 3 then
|
||||
elseif datum.duration == 3 then
|
||||
text = '8h'
|
||||
elseif datum.max_time_left == 4 then
|
||||
elseif datum.duration == 4 then
|
||||
text = '24h'
|
||||
end
|
||||
cell.text:SetText(text)
|
||||
auction_alpha_setter(cell, datum)
|
||||
end,
|
||||
},
|
||||
{
|
||||
title = 'Owner',
|
||||
width = 70,
|
||||
comparator = function(row1, row2) return Aux.util.compare(row1.owner, row2.owner, Aux.util.GT) end,
|
||||
cell_initializer = Aux.sheet.default_cell_initializer('LEFT'),
|
||||
cell_setter = function(cell, datum)
|
||||
cell.text:SetText(datum.owner)
|
||||
auction_alpha_setter(cell, datum)
|
||||
end,
|
||||
},
|
||||
{
|
||||
title = 'Bid/ea',
|
||||
width = 70,
|
||||
comparator = function(row1, row2) return Aux.util.compare(row1.bid_per_unit, row2.bid_per_unit, Aux.util.GT) end,
|
||||
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)
|
||||
end,
|
||||
},
|
||||
{
|
||||
title = 'Buy/ea',
|
||||
width = 70,
|
||||
comparator = function(row1, row2) return Aux.util.compare(row1.unit_buyout_price, row2.unit_buyout_price, Aux.util.GT) end,
|
||||
comparator = function(row1, row2) return Aux.util.compare(row1.buyout_price_per_unit, row2.buyout_price_per_unit, Aux.util.GT) end,
|
||||
cell_initializer = Aux.sheet.default_cell_initializer('RIGHT'),
|
||||
cell_setter = function(cell, row)
|
||||
cell.text:SetText(Aux.util.money_string(row.unit_buyout_price))
|
||||
cell_setter = function(cell, datum)
|
||||
cell.text:SetText(Aux.util.money_string(datum.buyout_price_per_unit))
|
||||
auction_alpha_setter(cell, datum)
|
||||
end,
|
||||
},
|
||||
{
|
||||
title = 'Qty',
|
||||
width = 23,
|
||||
comparator = function(row1, row2) return Aux.util.compare(row1.stack_size, row2.stack_size, Aux.util.LT) end,
|
||||
title = 'Bid',
|
||||
width = 70,
|
||||
comparator = function(row1, row2) return Aux.util.compare(row1.bid, row2.bid, Aux.util.GT) end,
|
||||
cell_initializer = Aux.sheet.default_cell_initializer('RIGHT'),
|
||||
cell_setter = function(cell, row)
|
||||
cell.text:SetText(row.stack_size)
|
||||
cell_setter = function(cell, datum)
|
||||
cell.text:SetText(Aux.util.money_string(datum.bid))
|
||||
auction_alpha_setter(cell, datum)
|
||||
end,
|
||||
},
|
||||
{
|
||||
@@ -166,56 +158,304 @@ local auction_listing_config = {
|
||||
width = 70,
|
||||
comparator = function(row1, row2) return Aux.util.compare(row1.buyout_price, row2.buyout_price, Aux.util.GT) end,
|
||||
cell_initializer = Aux.sheet.default_cell_initializer('RIGHT'),
|
||||
cell_setter = function(cell, row)
|
||||
cell.text:SetText(Aux.util.money_string(row.buyout_price))
|
||||
cell_setter = function(cell, datum)
|
||||
cell.text:SetText(Aux.util.money_string(datum.buyout_price))
|
||||
auction_alpha_setter(cell, datum)
|
||||
end,
|
||||
},
|
||||
},
|
||||
sort_order = {{column = 4, order = 'ascending' }, {column = 4, order = 'ascending'}},
|
||||
sort_order = {},
|
||||
}
|
||||
|
||||
local auction_listing_config = {
|
||||
on_cell_click = function (sheet, row_index, column_index)
|
||||
local data_index = row_index + FauxScrollFrame_GetOffset(sheet.scroll_frame)
|
||||
AuxBuyEntry_OnClick(sheet.data[data_index])
|
||||
end,
|
||||
|
||||
on_cell_enter = function (sheet, row_index, column_index)
|
||||
sheet.rows[row_index].highlight:SetAlpha(.5)
|
||||
end,
|
||||
|
||||
on_cell_leave = function (sheet, row_index, column_index)
|
||||
sheet.rows[row_index].highlight:SetAlpha(0)
|
||||
end,
|
||||
columns = {
|
||||
{
|
||||
title = 'Qty',
|
||||
width = 23,
|
||||
comparator = function(row1, row2) return Aux.util.compare(row1.stack_size, row2.stack_size, Aux.util.LT) end,
|
||||
cell_initializer = Aux.sheet.default_cell_initializer('RIGHT'),
|
||||
cell_setter = function(cell, datum)
|
||||
cell.text:SetText(datum.stack_size)
|
||||
auction_alpha_setter(cell, datum)
|
||||
end,
|
||||
},
|
||||
{
|
||||
title = 'Auction Item',
|
||||
width = 157,
|
||||
comparator = function(row1, row2) return Aux.util.compare(row1.tooltip[1][1].text, row2.tooltip[1][1].text, Aux.util.GT) end,
|
||||
cell_initializer = function(cell)
|
||||
local icon = CreateFrame('Button', nil, cell)
|
||||
local icon_texture = icon:CreateTexture(nil, 'BORDER')
|
||||
icon_texture:SetAllPoints(icon)
|
||||
icon.icon_texture = icon_texture
|
||||
local normal_texture = icon:CreateTexture(nil)
|
||||
normal_texture:SetPoint('CENTER', 0, 0)
|
||||
normal_texture:SetWidth(22)
|
||||
normal_texture:SetHeight(22)
|
||||
normal_texture:SetTexture('Interface\\Buttons\\UI-Quickslot2')
|
||||
icon:SetNormalTexture(normal_texture)
|
||||
icon:SetPoint('LEFT', cell)
|
||||
icon:SetWidth(12)
|
||||
icon:SetHeight(12)
|
||||
icon:SetNormalTexture('Interface\\Buttons\\UI-Quickslot2')
|
||||
icon:SetPushedTexture('Interface\\Buttons\\UI-Quickslot-Depress')
|
||||
icon:SetHighlightTexture('Interface\\Buttons\\ButtonHilight-Square')
|
||||
icon:SetScript('OnEnter', function() Aux.info.set_game_tooltip(this, cell.tooltip, 'ANCHOR_RIGHT', cell.EnhTooltip_info) end)
|
||||
icon:SetScript('OnLeave', function() GameTooltip:Hide() end)
|
||||
local text = cell:CreateFontString(nil, 'OVERLAY', 'GameFontHighlightSmall')
|
||||
text:SetPoint("LEFT", icon, "RIGHT", 1, 0)
|
||||
text:SetPoint('TOPRIGHT', cell)
|
||||
text:SetPoint('BOTTOMRIGHT', cell)
|
||||
text:SetJustifyV('TOP')
|
||||
text:SetJustifyH('LEFT')
|
||||
text:SetTextColor(0.8, 0.8, 0.8)
|
||||
cell.text = text
|
||||
cell.icon = icon
|
||||
end,
|
||||
cell_setter = function(cell, datum)
|
||||
cell.tooltip = datum.tooltip
|
||||
cell.EnhTooltip_info = datum.EnhTooltip_info
|
||||
cell.icon.icon_texture:SetTexture(datum.texture)
|
||||
if not datum.usable then
|
||||
cell.icon.icon_texture:SetVertexColor(1.0, 0.1, 0.1)
|
||||
else
|
||||
cell.icon.icon_texture:SetVertexColor(1.0, 1.0, 1.0)
|
||||
end
|
||||
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)
|
||||
end,
|
||||
},
|
||||
{
|
||||
title = 'Lvl',
|
||||
width = 23,
|
||||
comparator = function(row1, row2) return Aux.util.compare(row1.level, row2.level, Aux.util.GT) end,
|
||||
cell_initializer = Aux.sheet.default_cell_initializer('RIGHT'),
|
||||
cell_setter = function(cell, datum)
|
||||
local level = max(1, datum.level)
|
||||
local text
|
||||
if level > UnitLevel('player') then
|
||||
text = RED_FONT_COLOR_CODE..level..FONT_COLOR_CODE_CLOSE
|
||||
else
|
||||
text = level
|
||||
end
|
||||
cell.text:SetText(text)
|
||||
auction_alpha_setter(cell, datum)
|
||||
end,
|
||||
},
|
||||
{
|
||||
title = 'Left',
|
||||
width = 30,
|
||||
comparator = function(row1, row2) return Aux.util.compare(row1.duration, row2.duration, Aux.util.GT) end,
|
||||
cell_initializer = Aux.sheet.default_cell_initializer('CENTER'),
|
||||
cell_setter = function(cell, datum)
|
||||
local text
|
||||
if datum.duration == 1 then
|
||||
text = '30m'
|
||||
elseif datum.duration == 2 then
|
||||
text = '2h'
|
||||
elseif datum.duration == 3 then
|
||||
text = '8h'
|
||||
elseif datum.duration == 4 then
|
||||
text = '24h'
|
||||
end
|
||||
cell.text:SetText(text)
|
||||
auction_alpha_setter(cell, datum)
|
||||
end,
|
||||
},
|
||||
{
|
||||
title = 'Owner',
|
||||
width = 70,
|
||||
comparator = function(row1, row2) return Aux.util.compare(row1.owner, row2.owner, Aux.util.GT) end,
|
||||
cell_initializer = Aux.sheet.default_cell_initializer('LEFT'),
|
||||
cell_setter = function(cell, datum)
|
||||
cell.text:SetText(datum.owner)
|
||||
auction_alpha_setter(cell, datum)
|
||||
end,
|
||||
},
|
||||
{
|
||||
title = 'Bid/ea',
|
||||
width = 70,
|
||||
comparator = function(row1, row2) return Aux.util.compare(row1.bid_per_unit, row2.bid_per_unit, Aux.util.GT) end,
|
||||
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)
|
||||
end,
|
||||
},
|
||||
{
|
||||
title = 'Buy/ea',
|
||||
width = 70,
|
||||
comparator = function(row1, row2) return Aux.util.compare(row1.buyout_price_per_unit, row2.buyout_price_per_unit, Aux.util.GT) end,
|
||||
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)
|
||||
end,
|
||||
},
|
||||
{
|
||||
title = 'Bid',
|
||||
width = 70,
|
||||
comparator = function(row1, row2) return Aux.util.compare(row1.bid, row2.bid, Aux.util.GT) end,
|
||||
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)
|
||||
end,
|
||||
},
|
||||
{
|
||||
title = 'Buy',
|
||||
width = 70,
|
||||
comparator = function(row1, row2) return Aux.util.compare(row1.buyout_price, row2.buyout_price, Aux.util.GT) end,
|
||||
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)
|
||||
end,
|
||||
},
|
||||
},
|
||||
sort_order = {},
|
||||
}
|
||||
|
||||
function on_open()
|
||||
|
||||
if not bid_records then
|
||||
GetBidderAuctionItems()
|
||||
bid_records = {}
|
||||
local i = 0
|
||||
while true do
|
||||
local maybe_bid_record = create_maybe_bid_record(i)
|
||||
|
||||
if maybe_bid_record.present() then
|
||||
tinsert(auction_records, maybe_bid_record.get())
|
||||
else
|
||||
break
|
||||
end
|
||||
i = i + 1
|
||||
end
|
||||
end
|
||||
AuctionFrameBid.page = 0
|
||||
AuctionFrameBid_Update()
|
||||
|
||||
if not auctions_records then
|
||||
GetOwnerAuctionItems()
|
||||
auction_records = {}
|
||||
local i = 0
|
||||
while true do
|
||||
local maybe_auction_record = create_maybe_auction_record(i)
|
||||
|
||||
if maybe_auction_record.present() then
|
||||
tinsert(auction_records, maybe_auction_record.get())
|
||||
else
|
||||
break
|
||||
end
|
||||
i = i + 1
|
||||
end
|
||||
end
|
||||
AuctionFrameAuctions.page = 0
|
||||
AuctionFrameAuctions_Update()
|
||||
-- update_bid_records(function()
|
||||
update_auction_records(function()
|
||||
end)
|
||||
-- end)
|
||||
end
|
||||
|
||||
function on_close()
|
||||
end
|
||||
|
||||
function update_bid_records(k)
|
||||
bid_records = {}
|
||||
Aux.scan.start{
|
||||
type = 'bidder',
|
||||
page = 0,
|
||||
on_submit_query = function()
|
||||
position = nil
|
||||
end,
|
||||
on_page_loaded = function(page, total_pages)
|
||||
Aux.log('Scanning bid page '..(page+1)..' out of '..total_pages..' ...')
|
||||
position = 'bids#'..page
|
||||
end,
|
||||
on_read_auction = function(i)
|
||||
snipe.log('bids#'..i)
|
||||
end,
|
||||
on_complete = function()
|
||||
-- Aux.list.populate(AuxManageBidsListing.sheet, bid_records)
|
||||
return k()
|
||||
end,
|
||||
on_abort = function()
|
||||
end,
|
||||
next_page = function(page, total_pages)
|
||||
local last_page = max(total_pages - 1, 0)
|
||||
if page < last_page then
|
||||
return page + 1
|
||||
end
|
||||
end,
|
||||
}
|
||||
end
|
||||
|
||||
function update_auction_records(k)
|
||||
auction_records = {}
|
||||
Aux.scan.start{
|
||||
type = 'owner',
|
||||
page = 0,
|
||||
on_submit_query = function()
|
||||
position = nil
|
||||
end,
|
||||
on_page_loaded = function(page, total_pages)
|
||||
Aux.log('Scanning auction page '..(page+1)..' out of '..total_pages..' ...')
|
||||
position = 'auctions#'..page
|
||||
end,
|
||||
on_read_auction = function(i)
|
||||
snipe.log('auctions#'..i)
|
||||
end,
|
||||
on_complete = function()
|
||||
-- Aux.list.populate(AuxManageAuctionsListing.sheet, auction_records)
|
||||
return k()
|
||||
end,
|
||||
on_abort = function()
|
||||
end,
|
||||
next_page = function(page, total_pages)
|
||||
local last_page = max(total_pages - 1, 0)
|
||||
if page < last_page then
|
||||
return page + 1
|
||||
end
|
||||
end,
|
||||
}
|
||||
end
|
||||
|
||||
function create_record(auction_item, current_page)
|
||||
|
||||
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 status
|
||||
if auction_item.current_bid == 0 then
|
||||
status = 'No Bid'
|
||||
elseif auction_item.high_bidder then
|
||||
status = GREEN_FONT_COLOR_CODE..'Your Bid'..FONT_COLOR_CODE_CLOSE
|
||||
else
|
||||
status = RED_FONT_COLOR_CODE..'Other Bidder'..FONT_COLOR_CODE_CLOSE
|
||||
end
|
||||
|
||||
return {
|
||||
key = auction_item.item_signature,
|
||||
signature = Aux.auction_signature(auction_item.hyperlink, stack_size, bid, auction_item.buyout_price),
|
||||
|
||||
name = auction_item.name,
|
||||
level = auction_item.level,
|
||||
texture = auction_item.texture,
|
||||
tooltip = auction_item.tooltip,
|
||||
stack_size = stack_size,
|
||||
buyout_price = buyout_price,
|
||||
buyout_price_per_unit = buyout_price_per_unit,
|
||||
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,
|
||||
duration = auction_item.duration,
|
||||
usable = auction_item.usable,
|
||||
high_bidder = auction_item.high_bidder,
|
||||
status = status,
|
||||
|
||||
EnhTooltip_info = auction_item.EnhTooltip_info,
|
||||
}
|
||||
end
|
||||
|
||||
function create_auction_record(index)
|
||||
local auction_item = Aux.info.auction_item(i, 'owner')
|
||||
if auction_item then
|
||||
tinsert(auction_records, create_record(auction_item, i))
|
||||
end
|
||||
end
|
||||
|
||||
function create_bid_record(index)
|
||||
local auction_item = Aux.info.auction_item(i, 'bidder')
|
||||
if auction_item then
|
||||
tinsert(auction_records, create_record(auction_item, i))
|
||||
end
|
||||
end
|
||||
|
||||
Aux.manage_frame = {
|
||||
on_open = on_open,
|
||||
on_close = on_close,
|
||||
@@ -223,12 +463,4 @@ Aux.manage_frame = {
|
||||
auction_listing_config = auction_listing_config,
|
||||
}
|
||||
|
||||
function create_maybe_auction_record(index)
|
||||
GetAuctionItemInfo('owner', index)
|
||||
end
|
||||
|
||||
function create_maybe_bid_record(index)
|
||||
GetAuctionItemInfo('bidder', index)
|
||||
end
|
||||
|
||||
|
||||
|
||||
+53
-57
@@ -1,5 +1,5 @@
|
||||
local on_load, load_dataset, new_dataset, get_dataset_key, get_snapshot, save_snapshot, get_item_record, save_item_record
|
||||
local encode_median_list, decode_median_list, serialize, deserialize, deserializing_iterator
|
||||
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
|
||||
|
||||
@@ -24,9 +24,9 @@ end
|
||||
|
||||
function new_dataset()
|
||||
return {
|
||||
snapshot = '',
|
||||
scan_data = '',
|
||||
snapshot = {},
|
||||
item_data = {},
|
||||
item_history = {}
|
||||
}
|
||||
end
|
||||
|
||||
@@ -38,61 +38,62 @@ end
|
||||
|
||||
function get_snapshot()
|
||||
local dataset = load_dataset()
|
||||
local signatures = deserialize(dataset.snapshot, '#')
|
||||
local snapshot = Aux.util.set()
|
||||
snapshot.add_all(signatures)
|
||||
snapshot.set_data(dataset.snapshot)
|
||||
return snapshot
|
||||
end
|
||||
|
||||
function save_snapshot(snapshot)
|
||||
local dataset = load_dataset()
|
||||
dataset.snapshot = serialize(snapshot.values(), '#')
|
||||
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 }
|
||||
end)
|
||||
end
|
||||
|
||||
--function load_scan_data()
|
||||
--
|
||||
--end
|
||||
--
|
||||
--function store_scan_data()
|
||||
--
|
||||
--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
|
||||
end
|
||||
|
||||
function get_item_record(item_key)
|
||||
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_price_list = unpack(deserialize(serialized_record, '|'))
|
||||
local price_list = decode_median_list(encoded_price_list)
|
||||
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,
|
||||
price_list = price_list
|
||||
median_list = median_list
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
function save_item_record(item_key, record)
|
||||
function store_item_record(item_key, record)
|
||||
local dataset = load_dataset()
|
||||
|
||||
local encoded_price_list = encode_median_list(record.price_list)
|
||||
local serialized_record = serialize({record.count, record.acumulated_price, encoded_price_list}, '|')
|
||||
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
|
||||
|
||||
-- AuctionConfig.data[auctKey][itemKey] = string.format("%s|%s", iData.data, hist);
|
||||
-- AuctionConfig.info[itemKey] = string.format("%s|%s", iData.category, iData.name);
|
||||
-- Auctioneer.Storage.SetHistMed(auctKey, itemKey, Auctioneer.Statistic.GetMedian(iData.buyoutPricesHistoryList))
|
||||
|
||||
function encode_median_list(list)
|
||||
local encoded_list = ''
|
||||
local function extend(last, n)
|
||||
if n == 1 then
|
||||
encoded_list = encoded_list == '' and last or string.format('%s:%d', encoded_list, last)
|
||||
elseif n > 1 then
|
||||
encoded_list = encoded_list == '' and string.format('%dx%d', last, n) or string.format('%s:%dx%d', encoded_list, last, n)
|
||||
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
|
||||
@@ -111,58 +112,53 @@ function encode_median_list(list)
|
||||
return encoded_list
|
||||
end
|
||||
|
||||
function decode_median_list(str)
|
||||
function decode_median_list(encoded_list)
|
||||
local array = {}
|
||||
for x, c in string.gfind(str, '([^%:]*)(%:?)') do
|
||||
local _, _, y, n = strfind(x, '(%d*)x(%d*)')
|
||||
if y == nil then
|
||||
tinsert(array, tonumber(x))
|
||||
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,n do
|
||||
tinsert(array, tonumber(y))
|
||||
for i = 1,count do
|
||||
tinsert(array, tonumber(value))
|
||||
end
|
||||
end
|
||||
if c == '' then break end
|
||||
if separator == '' then break end
|
||||
end
|
||||
return array
|
||||
end
|
||||
|
||||
function serialize(data, separator)
|
||||
assert(getn(data) == 3)
|
||||
local data_string = ''
|
||||
for i, datum in ipairs(data) do
|
||||
data_string = data_string..(i == 1 and separator or '')..datum
|
||||
data_string = data_string..(i == 1 and '' or separator)..datum
|
||||
end
|
||||
return data_string
|
||||
end
|
||||
|
||||
function deserialize(data_string, separator)
|
||||
if data_string == '' then
|
||||
return {}
|
||||
end
|
||||
|
||||
local data = {}
|
||||
while true do
|
||||
local start_index, _ = strfind(data_string, separator, 1, true)
|
||||
if start_index then
|
||||
local datum = string.sub(data_string, 1, start_index - 1)
|
||||
tinsert(data, datum)
|
||||
tinsert(data, string.sub(data_string, 1, start_index - 1))
|
||||
data_string = string.sub(data_string, start_index + 1, strlen(data_string))
|
||||
else
|
||||
tinsert(data, string.sub(data_string, 1, strlen(data_string)))
|
||||
return data
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function deserializing_iterator(data_string, separator)
|
||||
return function()
|
||||
local start_index, _ = strfind(data_string, separator, 1, true)
|
||||
if start_index then
|
||||
local datum = string.sub(data_string, 1, start_index - 1)
|
||||
data_string = string.sub(data_string, start_index, strlen(data_string))
|
||||
return datum
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Aux.persistence = {
|
||||
get_item_record = get_item_record,
|
||||
save_item_record = save_item_record,
|
||||
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,
|
||||
save_snapshot = save_snapshot,
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
Aux.scan = {}
|
||||
|
||||
local AUCTIONS_PER_PAGE = 50
|
||||
local PAGE_SIZE = 50
|
||||
|
||||
local controller = (function()
|
||||
local controller
|
||||
@@ -12,12 +12,13 @@ end)()
|
||||
|
||||
local state, abort, new_job
|
||||
|
||||
local scan, scan_auctions, scan_auctions_helper, submit_query, wait_for_callback, wait_for_results, wait_for_complete_results, abort
|
||||
local scan, scan_auctions, scan_auctions_helper, submit_query, wait_for_callback, wait_for_results, wait_for_owner_data, abort
|
||||
|
||||
function Aux.scan.start(job)
|
||||
Aux.control.on_next_update(function()
|
||||
abort()
|
||||
state = {
|
||||
job.type = job.type or 'list'
|
||||
state = {
|
||||
job = job,
|
||||
page = job.page
|
||||
}
|
||||
@@ -45,16 +46,27 @@ end
|
||||
|
||||
function wait_for_results(k)
|
||||
local ok
|
||||
Aux.control.on_next_event('AUCTION_ITEM_LIST_UPDATE', function()
|
||||
ok = true
|
||||
end)
|
||||
ok = true
|
||||
if state.job.type == 'bidder' then
|
||||
Aux.control.on_next_event('AUCTION_BIDDER_LIST_UPDATE', function()
|
||||
ok = true
|
||||
end)
|
||||
elseif state.job.type == 'owner' then
|
||||
Aux.control.on_next_event('AUCTION_OWNED_LIST_UPDATE', function()
|
||||
ok = true
|
||||
end)
|
||||
else
|
||||
Aux.control.on_next_event('AUCTION_ITEM_LIST_UPDATE', function()
|
||||
ok = true
|
||||
end)
|
||||
end
|
||||
|
||||
return controller().wait(function() return ok end, k)
|
||||
end
|
||||
|
||||
function wait_for_complete_results(k)
|
||||
function wait_for_owner_data(k)
|
||||
return controller().wait(function()
|
||||
local count, _ = GetNumAuctionItems("list")
|
||||
local count, _ = GetNumAuctionItems(state.job.type)
|
||||
for i=1,count do
|
||||
local auction_item_info = Aux.info.auction_item(i)
|
||||
if auction_item_info and not auction_item_info.owner then
|
||||
@@ -90,22 +102,23 @@ function scan()
|
||||
|
||||
submit_query(function()
|
||||
|
||||
local count, _ = GetNumAuctionItems('list')
|
||||
|
||||
scan_auctions(count, function()
|
||||
|
||||
state.page = state.job.next_page and state.job.next_page(state.page, state.total_pages)
|
||||
|
||||
if state.page then
|
||||
return scan()
|
||||
else
|
||||
if state.job.on_complete then
|
||||
state.job.on_complete()
|
||||
end
|
||||
state = nil
|
||||
end
|
||||
|
||||
end)end)
|
||||
local count, _ = GetNumAuctionItems(state.job.type)
|
||||
|
||||
scan_auctions(count, function()
|
||||
|
||||
state.page = state.job.next_page and state.job.next_page(state.page, state.total_pages)
|
||||
|
||||
if state.page then
|
||||
return scan()
|
||||
else
|
||||
if state.job.on_complete then
|
||||
state.job.on_complete()
|
||||
end
|
||||
state = nil
|
||||
end
|
||||
|
||||
end)
|
||||
end)
|
||||
end
|
||||
|
||||
function scan_auctions(count, k)
|
||||
@@ -115,39 +128,48 @@ end
|
||||
function scan_auctions_helper(i, n, k)
|
||||
wait_for_callback{state.job.on_read_auction, i, function()
|
||||
|
||||
if i >= n then
|
||||
return k()
|
||||
else
|
||||
return scan_auctions_helper(i + 1, n, k)
|
||||
end
|
||||
if i >= n then
|
||||
return k()
|
||||
else
|
||||
return scan_auctions_helper(i + 1, n, k)
|
||||
end
|
||||
|
||||
end}
|
||||
end
|
||||
|
||||
function submit_query(k)
|
||||
if state.page then
|
||||
controller().wait(CanSendAuctionQuery, function()
|
||||
if state.job.on_submit_query then
|
||||
state.job.on_submit_query()
|
||||
end
|
||||
wait_for_results(function()
|
||||
--wait_for_complete_results(function()
|
||||
local _, total_count = GetNumAuctionItems('list')
|
||||
state.total_pages = math.ceil(total_count / AUCTIONS_PER_PAGE)
|
||||
wait_for_callback{state.job.on_page_loaded, state.page, state.total_pages, function()
|
||||
k()
|
||||
end}end)-- end)
|
||||
QueryAuctionItems(
|
||||
state.job.query.name,
|
||||
state.job.query.min_level,
|
||||
state.job.query.max_level,
|
||||
state.job.query.slot,
|
||||
state.job.query.class,
|
||||
state.job.query.subclass,
|
||||
state.page,
|
||||
state.job.query.usable,
|
||||
state.job.query.quality
|
||||
)
|
||||
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
|
||||
wait_for_results(function()
|
||||
--wait_for_owner_data(function()
|
||||
local _, total_count = GetNumAuctionItems(state.job.type)
|
||||
state.total_pages = math.ceil(total_count / PAGE_SIZE)
|
||||
wait_for_callback{state.job.on_page_loaded, state.page, state.total_pages, function()
|
||||
k()
|
||||
end}
|
||||
-- end)
|
||||
end)
|
||||
if state.job.type == 'bidder' then
|
||||
GetBidderAuctionItems(state.page)
|
||||
elseif state.job.type == 'owner' then
|
||||
GetOwnerAuctionItems(state.page)
|
||||
else
|
||||
QueryAuctionItems(
|
||||
state.job.query.name,
|
||||
state.job.query.min_level,
|
||||
state.job.query.max_level,
|
||||
state.job.query.slot,
|
||||
state.job.query.class,
|
||||
state.job.query.subclass,
|
||||
state.page,
|
||||
state.job.query.usable,
|
||||
state.job.query.quality
|
||||
)
|
||||
end
|
||||
end)
|
||||
else
|
||||
return k()
|
||||
|
||||
+42
-47
@@ -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 signature_cache
|
||||
local scanned_signatures
|
||||
|
||||
function Aux.history.on_close()
|
||||
|
||||
@@ -26,7 +26,7 @@ function Aux.history.start_scan()
|
||||
AuxHistoryScanButton:Hide()
|
||||
AuxHistoryStopButton:Show()
|
||||
|
||||
signature_cache = Aux.util.set()
|
||||
scanned_signatures = Aux.util.set()
|
||||
|
||||
Aux.log('Scanning auctions ...')
|
||||
Aux.scan.start{
|
||||
@@ -63,8 +63,11 @@ end
|
||||
|
||||
function update_snapshot()
|
||||
local snapshot = Aux.persistence.get_snapshot()
|
||||
snapshot.remove_all(signature_cache.values())
|
||||
Aux.persistence.save_snapshot(snapshot)
|
||||
for _, sig in ipairs(snapshot.values()) do
|
||||
if not scanned_signatures.contains(sig) then
|
||||
snapshot.remove(sig)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function Aux.history.stop_scan()
|
||||
@@ -80,67 +83,59 @@ function process_auction(index)
|
||||
local item_key = auction_info.item_signature
|
||||
|
||||
local signature = Aux.info.auction_signature(index)
|
||||
signature_cache.add(signature)
|
||||
scanned_signatures.add(signature)
|
||||
|
||||
local snapshot = Aux.persistence.get_snapshot()
|
||||
if not snapshot.contains(signature) then
|
||||
snapshot.add(signature)
|
||||
Aux.persistence.save_snapshot(snapshot)
|
||||
--
|
||||
-- local item_record = Aux.persistence.get_item_record(item_key)
|
||||
--
|
||||
-- item_record = item_record or {
|
||||
-- count = 0,
|
||||
-- accumulated_price = 0,
|
||||
-- price_list = {},
|
||||
-- }
|
||||
--
|
||||
-- local price_list = balanced_list(MAX_HISTORY_SIZE)
|
||||
-- price_list.add_all(item_record.price_list)
|
||||
-- price_list.add(price)
|
||||
--
|
||||
-- Aux.persistence.save_item_record(item_key, {
|
||||
-- count = item_record.count + 1,
|
||||
-- accumulated_price = item_record.accumulated_price + price,
|
||||
-- price_list = price_list.values(),
|
||||
-- })
|
||||
--
|
||||
|
||||
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
|
||||
end
|
||||
end
|
||||
|
||||
function Aux.history.get_market_price(key)
|
||||
local price
|
||||
function Aux.history.get_market_price(item_key)
|
||||
local market_price
|
||||
|
||||
local median = get_usable_median(key)
|
||||
-- local avgMin, avgBuy, avgBid, bidPct, buyPct, avgQty, meanCount = getMeans(key, realm)
|
||||
local item_record = Aux.persistence.load_item_record(item_key)
|
||||
|
||||
-- assign the best common buyout
|
||||
if median and median > 0 then
|
||||
price = median
|
||||
-- elseif meanCount and meanCount > 0 then
|
||||
-- -- if a usable median does not exist, use the average buyout instead
|
||||
-- price = avgBuy;
|
||||
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 price
|
||||
return market_price
|
||||
end
|
||||
|
||||
function get_usable_median(item_key)
|
||||
function get_usable_median(values)
|
||||
|
||||
local historical_median, historical_count = get_historical_median(item_key)
|
||||
|
||||
if historical_count >= MIN_SEEN then
|
||||
return historical_median, historical_count
|
||||
local median, count = get_median(values)
|
||||
if count >= MIN_SEEN then
|
||||
return median, count
|
||||
end
|
||||
end
|
||||
|
||||
function get_historical_median(item_key)
|
||||
local price_list = Aux.util.safe_index{Aux.persistence.get_item_record(item_key), 'price_list'}
|
||||
|
||||
return get_median(price_list or {})
|
||||
end
|
||||
|
||||
function get_median(values)
|
||||
return get_percentile(values, 0.5)
|
||||
end
|
||||
|
||||
@@ -356,45 +356,3 @@ function Aux.util.set()
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
function Aux.util.maybe(value)
|
||||
local self = {}
|
||||
|
||||
function self.join()
|
||||
if value == nil then
|
||||
return Aux.util.maybe()
|
||||
else
|
||||
return value
|
||||
end
|
||||
end
|
||||
|
||||
function self.map(f)
|
||||
if value == nil then
|
||||
return Aux.util.maybe()
|
||||
else
|
||||
return maybe(f(value))
|
||||
end
|
||||
end
|
||||
|
||||
function self.bind(f)
|
||||
return self.map(f).join()
|
||||
end
|
||||
|
||||
function self.get()
|
||||
return value
|
||||
end
|
||||
|
||||
function self.or_else(default_value)
|
||||
if value == nil then
|
||||
return default_value
|
||||
else
|
||||
return value
|
||||
end
|
||||
end
|
||||
|
||||
function self.present()
|
||||
return value ~= nil
|
||||
end
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user