From 76fca97a4022600dadc85b5475436acc45902f8b Mon Sep 17 00:00:00 2001 From: Manuel Simon Hirsig Date: Sat, 6 Feb 2016 17:23:41 +0100 Subject: [PATCH] now using unit price in the post tab, allowing decimals to still be able to undercut by 1c --- Aux-AddOn.toc | 2 +- auction_listing.lua | 2 +- core.lua | 2 +- money.lua | 4 +++- post.lua | 2 +- post_frame.lua | 55 +++++++++++++++++++++++---------------------- 6 files changed, 35 insertions(+), 32 deletions(-) diff --git a/Aux-AddOn.toc b/Aux-AddOn.toc index ee3159c..e1747ac 100644 --- a/Aux-AddOn.toc +++ b/Aux-AddOn.toc @@ -1,7 +1,7 @@ ## Interface: 11200 ## Title: Aux ## 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 slash.lua diff --git a/auction_listing.lua b/auction_listing.lua index 7620423..8d998d4 100644 --- a/auction_listing.lua +++ b/auction_listing.lua @@ -180,7 +180,7 @@ local methods = { -- GetRowPrices = function(record, isPerUnit) return end, -- TODO GetRowPrices = function(record, per_unit) 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 return record.bid_price, record.buyout_price end diff --git a/core.lua b/core.lua index b6d0f87..f57e4d0 100644 --- a/core.lua +++ b/core.lua @@ -1,4 +1,4 @@ -AuxVersion = '2.4.12' +AuxVersion = '2.4.13' AuxAuthors = 'shirsig; Zerf; Zirco (Auctionator); Nimeral (Auctionator backport)' Aux = { diff --git a/money.lua b/money.lua index ac2b050..1add680 100644 --- a/money.lua +++ b/money.lua @@ -13,7 +13,9 @@ function m.to_string(money, pad, trim, color, no_color) money = abs(money) local gold = floor(money / COPPER_PER_GOLD) 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 if no_color then gold_text, silver_text, copper_text = 'g', 's', 'c' diff --git a/post.lua b/post.lua index 67d219a..23e5430 100644 --- a/post.lua +++ b/post.lua @@ -82,7 +82,7 @@ function private.post_auction(slot, k) ClickAuctionSellItemButton() ClearCursor() 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() return k(stack_size) end) diff --git a/post_frame.lua b/post_frame.lua index b17053a..f9f4392 100644 --- a/post_frame.lua +++ b/post_frame.lua @@ -52,7 +52,7 @@ function private.update_auction_listing() { value=auction_record.yours }, { value=Aux.auction_listing.time_left(auction_record.duration) }, { 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 '---') }, }, record = auction_record, @@ -186,11 +186,11 @@ function public.on_load() end) slider.editbox:SetScript('OnTabPressed', function() if IsShiftKeyDown() then - private.buyout_price:SetFocus() + private.unit_buyout_price:SetFocus() elseif private.stack_count_slider.editbox:IsVisible() then private.stack_count_slider.editbox:SetFocus() else - private.start_price:SetFocus() + private.unit_start_price:SetFocus() end end) slider.editbox:SetWidth(50) @@ -241,7 +241,7 @@ function public.on_load() if IsShiftKeyDown() then private.stack_size_slider.editbox:SetFocus() else - private.start_price:SetFocus() + private.unit_start_price:SetFocus() end end) slider.editbox:SetWidth(50) @@ -310,7 +310,7 @@ function public.on_load() elseif IsShiftKeyDown() then private.stack_size_slider.editbox:SetFocus() else - private.buyout_price:SetFocus() + private.unit_buyout_price:SetFocus() end end) editbox:SetScript('OnEnterPressed', function() @@ -327,12 +327,12 @@ function public.on_load() end) local label = Aux.gui.label(editbox, 13) label:SetPoint('BOTTOMLEFT', editbox, 'TOPLEFT', -2, 1) - label:SetText('Starting Stack Price') - private.start_price = editbox + label:SetText('Unit Starting Price') + private.unit_start_price = editbox end do 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:SetScript('OnTextChanged', function() if selected_item then @@ -344,7 +344,7 @@ function public.on_load() end) editbox:SetScript('OnTabPressed', function() if IsShiftKeyDown() then - private.start_price:SetFocus() + private.unit_start_price:SetFocus() else private.stack_size_slider.editbox:SetFocus() end @@ -363,12 +363,12 @@ function public.on_load() end) local label = Aux.gui.label(editbox, 13) label:SetPoint('BOTTOMLEFT', editbox, 'TOPLEFT', -2, 1) - label:SetText('Buyout Stack Price') - private.buyout_price = editbox + label:SetText('Unit Buyout Price') + private.unit_buyout_price = editbox end do 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:SetHeight(10) local label = Aux.gui.label(dropdown, 13) @@ -385,8 +385,8 @@ end function public.on_open() private.deposit:SetText('Deposit: '..Aux.money.to_string(0)) - private.start_price:SetText(Aux.money.to_string(0)) - private.buyout_price:SetText(Aux.money.to_string(0)) + private.unit_start_price:SetText(Aux.money.to_string(0)) + private.unit_buyout_price:SetText(Aux.money.to_string(0)) private.update_inventory_records() @@ -401,8 +401,8 @@ end function private.post_auctions() if selected_item then - local unit_start_price = Aux.money.from_string(private.start_price:GetText()) / private.stack_size_slider:GetValue() - local unit_buyout_price = Aux.money.from_string(private.buyout_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.unit_buyout_price:GetText()) local stack_size = private.stack_size_slider:GetValue() local stack_count if private.post_all_checkbox:GetChecked() and not selected_item.charges then @@ -485,12 +485,12 @@ function private.validate_parameters() return 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() return 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() return end @@ -513,8 +513,8 @@ function private.update_recommendation() AuxSellParametersItemName:SetTextColor(1, 1, 1) AuxSellParametersItemName:SetText('No item selected') - private.start_price:Hide() - private.buyout_price:Hide() + private.unit_start_price:Hide() + private.unit_buyout_price:Hide() private.stack_size_slider:Hide() private.post_all_checkbox:Hide() private.stack_count_slider:Hide() @@ -523,8 +523,8 @@ function private.update_recommendation() private.pricing_model_dropdown:Hide() private.hide_checkbox:Hide() else - private.start_price:Show() - private.buyout_price:Show() + private.unit_start_price:Show() + private.unit_buyout_price:Show() private.stack_size_slider:Show() private.post_all_checkbox:Show() if private.post_all_checkbox:GetChecked() then @@ -587,8 +587,8 @@ function private.update_recommendation() end end - private.start_price:SetText(Aux.money.to_string(start_price)) - private.buyout_price:SetText(Aux.money.to_string(buyout_price)) + private.unit_start_price:SetText(Aux.money.to_string(tonumber(format('%.3f', start_price)))) + private.unit_buyout_price:SetText(Aux.money.to_string(tonumber(format('%.3f', buyout_price)))) end end @@ -598,12 +598,13 @@ function private.undercutting_suggestion() 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 - price_suggestion = private.undercut(price_suggestion) + basis_price = private.undercut(basis_price) end + local price_suggestion = basis_price / private.stack_size_slider:GetValue() return price_suggestion * 0.95, price_suggestion end end @@ -611,7 +612,7 @@ function private.undercutting_suggestion() end 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 return 0, 0 end