now using unit price in the post tab, allowing decimals to still be able to undercut by 1c

This commit is contained in:
Manuel Simon Hirsig
2016-02-06 17:23:41 +01:00
parent 17e7b840c3
commit 76fca97a40
6 changed files with 35 additions and 32 deletions
+1 -1
View File
@@ -1,7 +1,7 @@
## Interface: 11200 ## Interface: 11200
## Title: Aux ## Title: Aux
## Notes: A lightweight addon designed to help manage auctions ## Notes: A lightweight addon designed to help manage auctions
## SavedVariablesPerCharacter: aux_recent_searches, aux_favorite_searches, aux_scale ## SavedVariablesPerCharacter: aux_recent_searches, aux_favorite_searches, aux_price_per_unit, aux_scale
## SavedVariables: aux_database, aux_auctionable_items ## SavedVariables: aux_database, aux_auctionable_items
slash.lua slash.lua
+1 -1
View File
@@ -180,7 +180,7 @@ local methods = {
-- GetRowPrices = function(record, isPerUnit) return end, -- TODO -- GetRowPrices = function(record, isPerUnit) return end, -- TODO
GetRowPrices = function(record, per_unit) GetRowPrices = function(record, per_unit)
if per_unit then if per_unit then
return record.unit_bid_price, record.unit_buyout_price return ceil(record.unit_bid_price), ceil(record.unit_buyout_price)
else else
return record.bid_price, record.buyout_price return record.bid_price, record.buyout_price
end end
+1 -1
View File
@@ -1,4 +1,4 @@
AuxVersion = '2.4.12' AuxVersion = '2.4.13'
AuxAuthors = 'shirsig; Zerf; Zirco (Auctionator); Nimeral (Auctionator backport)' AuxAuthors = 'shirsig; Zerf; Zirco (Auctionator); Nimeral (Auctionator backport)'
Aux = { Aux = {
+3 -1
View File
@@ -13,7 +13,9 @@ function m.to_string(money, pad, trim, color, no_color)
money = abs(money) money = abs(money)
local gold = floor(money / COPPER_PER_GOLD) local gold = floor(money / COPPER_PER_GOLD)
local silver = floor(mod(money, COPPER_PER_GOLD) / COPPER_PER_SILVER) local silver = floor(mod(money, COPPER_PER_GOLD) / COPPER_PER_SILVER)
local copper = Aux.round(mod(money, COPPER_PER_SILVER)) -- local copper = Aux.round(mod(money, COPPER_PER_SILVER))
local copper = mod(money, COPPER_PER_SILVER)
local gold_text, silver_text, copper_text local gold_text, silver_text, copper_text
if no_color then if no_color then
gold_text, silver_text, copper_text = 'g', 's', 'c' gold_text, silver_text, copper_text = 'g', 's', 'c'
+1 -1
View File
@@ -82,7 +82,7 @@ function private.post_auction(slot, k)
ClickAuctionSellItemButton() ClickAuctionSellItemButton()
ClearCursor() ClearCursor()
local stack_size = Aux.info.container_item(slot.bag, slot.bag_slot).aux_quantity local stack_size = Aux.info.container_item(slot.bag, slot.bag_slot).aux_quantity
StartAuction(max(1, state.unit_start_price * stack_size), state.unit_buyout_price * stack_size, state.duration) StartAuction(ceil(state.unit_start_price * stack_size), ceil(state.unit_buyout_price * stack_size), state.duration)
controller().wait(function() return not GetContainerItemInfo(slot.bag, slot.bag_slot) end, function() controller().wait(function() return not GetContainerItemInfo(slot.bag, slot.bag_slot) end, function()
return k(stack_size) return k(stack_size)
end) end)
+28 -27
View File
@@ -52,7 +52,7 @@ function private.update_auction_listing()
{ value=auction_record.yours }, { value=auction_record.yours },
{ value=Aux.auction_listing.time_left(auction_record.duration) }, { value=Aux.auction_listing.time_left(auction_record.duration) },
{ value=stack_size }, { value=stack_size },
{ value=Aux.money.to_string(auction_record.unit_buyout_price, true, false) }, { value=Aux.money.to_string(tonumber(format('%.3f', auction_record.unit_buyout_price)), true, false) },
{ value=Aux.auction_listing.percentage_market(market_value and Aux.round(auction_record.unit_buyout_price/market_value * 100) or '---') }, { value=Aux.auction_listing.percentage_market(market_value and Aux.round(auction_record.unit_buyout_price/market_value * 100) or '---') },
}, },
record = auction_record, record = auction_record,
@@ -186,11 +186,11 @@ function public.on_load()
end) end)
slider.editbox:SetScript('OnTabPressed', function() slider.editbox:SetScript('OnTabPressed', function()
if IsShiftKeyDown() then if IsShiftKeyDown() then
private.buyout_price:SetFocus() private.unit_buyout_price:SetFocus()
elseif private.stack_count_slider.editbox:IsVisible() then elseif private.stack_count_slider.editbox:IsVisible() then
private.stack_count_slider.editbox:SetFocus() private.stack_count_slider.editbox:SetFocus()
else else
private.start_price:SetFocus() private.unit_start_price:SetFocus()
end end
end) end)
slider.editbox:SetWidth(50) slider.editbox:SetWidth(50)
@@ -241,7 +241,7 @@ function public.on_load()
if IsShiftKeyDown() then if IsShiftKeyDown() then
private.stack_size_slider.editbox:SetFocus() private.stack_size_slider.editbox:SetFocus()
else else
private.start_price:SetFocus() private.unit_start_price:SetFocus()
end end
end) end)
slider.editbox:SetWidth(50) slider.editbox:SetWidth(50)
@@ -310,7 +310,7 @@ function public.on_load()
elseif IsShiftKeyDown() then elseif IsShiftKeyDown() then
private.stack_size_slider.editbox:SetFocus() private.stack_size_slider.editbox:SetFocus()
else else
private.buyout_price:SetFocus() private.unit_buyout_price:SetFocus()
end end
end) end)
editbox:SetScript('OnEnterPressed', function() editbox:SetScript('OnEnterPressed', function()
@@ -327,12 +327,12 @@ function public.on_load()
end) end)
local label = Aux.gui.label(editbox, 13) local label = Aux.gui.label(editbox, 13)
label:SetPoint('BOTTOMLEFT', editbox, 'TOPLEFT', -2, 1) label:SetPoint('BOTTOMLEFT', editbox, 'TOPLEFT', -2, 1)
label:SetText('Starting Stack Price') label:SetText('Unit Starting Price')
private.start_price = editbox private.unit_start_price = editbox
end end
do do
local editbox = Aux.gui.editbox(AuxSellParameters) local editbox = Aux.gui.editbox(AuxSellParameters)
editbox:SetPoint('TOP', private.start_price, 'BOTTOM', 0, -25) editbox:SetPoint('TOP', private.unit_start_price, 'BOTTOM', 0, -25)
editbox:SetWidth(170) editbox:SetWidth(170)
editbox:SetScript('OnTextChanged', function() editbox:SetScript('OnTextChanged', function()
if selected_item then if selected_item then
@@ -344,7 +344,7 @@ function public.on_load()
end) end)
editbox:SetScript('OnTabPressed', function() editbox:SetScript('OnTabPressed', function()
if IsShiftKeyDown() then if IsShiftKeyDown() then
private.start_price:SetFocus() private.unit_start_price:SetFocus()
else else
private.stack_size_slider.editbox:SetFocus() private.stack_size_slider.editbox:SetFocus()
end end
@@ -363,12 +363,12 @@ function public.on_load()
end) end)
local label = Aux.gui.label(editbox, 13) local label = Aux.gui.label(editbox, 13)
label:SetPoint('BOTTOMLEFT', editbox, 'TOPLEFT', -2, 1) label:SetPoint('BOTTOMLEFT', editbox, 'TOPLEFT', -2, 1)
label:SetText('Buyout Stack Price') label:SetText('Unit Buyout Price')
private.buyout_price = editbox private.unit_buyout_price = editbox
end end
do do
local dropdown = Aux.gui.dropdown(AuxSellParameters) local dropdown = Aux.gui.dropdown(AuxSellParameters)
dropdown:SetPoint('TOPRIGHT', private.buyout_price, 'BOTTOMRIGHT', 0, -20) dropdown:SetPoint('TOPRIGHT', private.unit_buyout_price, 'BOTTOMRIGHT', 0, -20)
dropdown:SetWidth(120) dropdown:SetWidth(120)
dropdown:SetHeight(10) dropdown:SetHeight(10)
local label = Aux.gui.label(dropdown, 13) local label = Aux.gui.label(dropdown, 13)
@@ -385,8 +385,8 @@ end
function public.on_open() function public.on_open()
private.deposit:SetText('Deposit: '..Aux.money.to_string(0)) private.deposit:SetText('Deposit: '..Aux.money.to_string(0))
private.start_price:SetText(Aux.money.to_string(0)) private.unit_start_price:SetText(Aux.money.to_string(0))
private.buyout_price:SetText(Aux.money.to_string(0)) private.unit_buyout_price:SetText(Aux.money.to_string(0))
private.update_inventory_records() private.update_inventory_records()
@@ -401,8 +401,8 @@ end
function private.post_auctions() function private.post_auctions()
if selected_item then if selected_item then
local unit_start_price = Aux.money.from_string(private.start_price:GetText()) / private.stack_size_slider:GetValue() local unit_start_price = Aux.money.from_string(private.unit_start_price:GetText())
local unit_buyout_price = Aux.money.from_string(private.buyout_price:GetText()) / private.stack_size_slider:GetValue() local unit_buyout_price = Aux.money.from_string(private.unit_buyout_price:GetText())
local stack_size = private.stack_size_slider:GetValue() local stack_size = private.stack_size_slider:GetValue()
local stack_count local stack_count
if private.post_all_checkbox:GetChecked() and not selected_item.charges then if private.post_all_checkbox:GetChecked() and not selected_item.charges then
@@ -485,12 +485,12 @@ function private.validate_parameters()
return return
end end
if Aux.money.from_string(private.buyout_price:GetText()) > 0 and Aux.money.from_string(private.start_price:GetText()) > Aux.money.from_string(private.buyout_price:GetText()) then if Aux.money.from_string(private.unit_buyout_price:GetText()) > 0 and Aux.money.from_string(private.unit_start_price:GetText()) > Aux.money.from_string(private.unit_buyout_price:GetText()) then
private.post_button:Disable() private.post_button:Disable()
return return
end end
if Aux.money.from_string(private.start_price:GetText()) < 1 then if Aux.money.from_string(private.unit_start_price:GetText()) < 1 then
private.post_button:Disable() private.post_button:Disable()
return return
end end
@@ -513,8 +513,8 @@ function private.update_recommendation()
AuxSellParametersItemName:SetTextColor(1, 1, 1) AuxSellParametersItemName:SetTextColor(1, 1, 1)
AuxSellParametersItemName:SetText('No item selected') AuxSellParametersItemName:SetText('No item selected')
private.start_price:Hide() private.unit_start_price:Hide()
private.buyout_price:Hide() private.unit_buyout_price:Hide()
private.stack_size_slider:Hide() private.stack_size_slider:Hide()
private.post_all_checkbox:Hide() private.post_all_checkbox:Hide()
private.stack_count_slider:Hide() private.stack_count_slider:Hide()
@@ -523,8 +523,8 @@ function private.update_recommendation()
private.pricing_model_dropdown:Hide() private.pricing_model_dropdown:Hide()
private.hide_checkbox:Hide() private.hide_checkbox:Hide()
else else
private.start_price:Show() private.unit_start_price:Show()
private.buyout_price:Show() private.unit_buyout_price:Show()
private.stack_size_slider:Show() private.stack_size_slider:Show()
private.post_all_checkbox:Show() private.post_all_checkbox:Show()
if private.post_all_checkbox:GetChecked() then if private.post_all_checkbox:GetChecked() then
@@ -587,8 +587,8 @@ function private.update_recommendation()
end end
end end
private.start_price:SetText(Aux.money.to_string(start_price)) private.unit_start_price:SetText(Aux.money.to_string(tonumber(format('%.3f', start_price))))
private.buyout_price:SetText(Aux.money.to_string(buyout_price)) private.unit_buyout_price:SetText(Aux.money.to_string(tonumber(format('%.3f', buyout_price))))
end end
end end
@@ -598,12 +598,13 @@ function private.undercutting_suggestion()
if existing_auctions[selected_item.key].selected then if existing_auctions[selected_item.key].selected then
local price_suggestion = existing_auctions[selected_item.key].selected.unit_buyout_price * private.stack_size_slider:GetValue() local basis_price = existing_auctions[selected_item.key].selected.unit_buyout_price * private.stack_size_slider:GetValue()
if existing_auctions[selected_item.key].selected.yours == 0 then if existing_auctions[selected_item.key].selected.yours == 0 then
price_suggestion = private.undercut(price_suggestion) basis_price = private.undercut(basis_price)
end end
local price_suggestion = basis_price / private.stack_size_slider:GetValue()
return price_suggestion * 0.95, price_suggestion return price_suggestion * 0.95, price_suggestion
end end
end end
@@ -611,7 +612,7 @@ function private.undercutting_suggestion()
end end
function private.market_value_suggestion() function private.market_value_suggestion()
local price_suggestion = Aux.history.market_value(selected_item.key) and 1.2 * Aux.history.market_value(selected_item.key) * private.stack_size_slider:GetValue() local price_suggestion = Aux.history.market_value(selected_item.key) and 1.2 * Aux.history.market_value(selected_item.key)
if not price_suggestion then if not price_suggestion then
return 0, 0 return 0, 0
end end