From cd10808a1de9c26a240f6b9c914f2eca7ba5f835 Mon Sep 17 00:00:00 2001 From: Manuel Simon Hirsig Date: Sun, 7 Feb 2016 15:59:49 +0100 Subject: [PATCH] fix for decimal points/undercutting by 1c --- auction_listing.lua | 4 ++-- core.lua | 2 +- money.lua | 8 ++++++-- post.lua | 2 +- post_frame.lua | 10 +++++----- scan_util.lua | 2 +- 6 files changed, 16 insertions(+), 12 deletions(-) diff --git a/auction_listing.lua b/auction_listing.lua index a6976c5..6114afa 100644 --- a/auction_listing.lua +++ b/auction_listing.lua @@ -425,8 +425,8 @@ local methods = { row.cells[5]:SetText(TIME_LEFT_STRINGS[record.duration or 0] or '---') row.cells[6]:SetText(Aux.is_player(record.owner) and ('|cffffff00'..record.owner..'|r') or (record.owner or '---')) local bid, buyout, colorBid, colorBuyout = self.GetRowPrices(record, aux_price_per_unit) - row.cells[7]:SetText(bid > 0 and Aux.money.to_string(bid, true, false, colorBid) or '---') - row.cells[8]:SetText(buyout > 0 and Aux.money.to_string(buyout, true, false, colorBuyout) or '---') + row.cells[7]:SetText(bid > 0 and Aux.money.to_string(bid, true, false, nil, colorBid) or '---') + row.cells[8]:SetText(buyout > 0 and Aux.money.to_string(buyout, true, false, nil, colorBuyout) or '---') local pct, bidPct = self:GetRecordPercent(record) row.cells[9]:SetText((pct or bidPct) and public.percentage_market(pct or bidPct, not pct) or '---') end diff --git a/core.lua b/core.lua index d073ffc..5442a22 100644 --- a/core.lua +++ b/core.lua @@ -1,4 +1,4 @@ -AuxVersion = '2.4.16' +AuxVersion = '2.4.17' AuxAuthors = 'shirsig; Zerf; Zirco (Auctionator); Nimeral (Auctionator backport)' Aux = { diff --git a/money.lua b/money.lua index 1add680..51c3a1e 100644 --- a/money.lua +++ b/money.lua @@ -7,7 +7,7 @@ local COPPER_TEXT = '|cffeda55fc|r' local COPPER_PER_SILVER = 100 local COPPER_PER_GOLD = 10000 -function m.to_string(money, pad, trim, color, no_color) +function m.to_string(money, pad, trim, decimal_points, color, no_color) local is_negative = money < 0 money = abs(money) @@ -16,6 +16,10 @@ function m.to_string(money, pad, trim, color, no_color) -- local copper = Aux.round(mod(money, COPPER_PER_SILVER)) local copper = mod(money, COPPER_PER_SILVER) + if decimal_points then + copper = tonumber(format('%.'..decimal_points..'f', copper)) + end + local gold_text, silver_text, copper_text if no_color then gold_text, silver_text, copper_text = 'g', 's', 'c' @@ -78,7 +82,7 @@ function m.from_string(value) value = gsub(value, '%d*%.?%d+c', '', 1) if strfind(value, '%S') then return 0 end - return Aux.round(((gold or 0) * COPPER_PER_GOLD) + ((silver or 0) * COPPER_PER_SILVER) + (copper or 0)) + return ((gold or 0) * COPPER_PER_GOLD) + ((silver or 0) * COPPER_PER_SILVER) + (copper or 0) end function m.format_number(num, pad, color) diff --git a/post.lua b/post.lua index 23e5430..00358a4 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(ceil(state.unit_start_price * stack_size), ceil(state.unit_buyout_price * stack_size), state.duration) + StartAuction(max(1, Aux.round(state.unit_start_price * stack_size)), Aux.round(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 f9f4392..8a02208 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(tonumber(format('%.3f', auction_record.unit_buyout_price)), true, false) }, + { value=Aux.money.to_string(auction_record.unit_buyout_price, true, nil, 3) }, { value=Aux.auction_listing.percentage_market(market_value and Aux.round(auction_record.unit_buyout_price/market_value * 100) or '---') }, }, record = auction_record, @@ -587,8 +587,8 @@ function private.update_recommendation() end end - 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)))) + private.unit_start_price:SetText(Aux.money.to_string(start_price, nil, nil, settings.pricing_model ~= FIXED and 3)) + private.unit_buyout_price:SetText(Aux.money.to_string(buyout_price, nil, nil, settings.pricing_model ~= FIXED and 3)) end end @@ -598,13 +598,13 @@ function private.undercutting_suggestion() if existing_auctions[selected_item.key].selected then - local basis_price = 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 * existing_auctions[selected_item.key].selected.stack_size if existing_auctions[selected_item.key].selected.yours == 0 then basis_price = private.undercut(basis_price) end - local price_suggestion = basis_price / private.stack_size_slider:GetValue() + local price_suggestion = basis_price / existing_auctions[selected_item.key].selected.stack_size return price_suggestion * 0.95, price_suggestion end end diff --git a/scan_util.lua b/scan_util.lua index 1c6f695..2119e82 100644 --- a/scan_util.lua +++ b/scan_util.lua @@ -233,7 +233,7 @@ function m.filter_to_string(filter) end if filter.max_price then - add(Aux.money.to_string(filter.max_price, nil, true, nil, true)) + add(Aux.money.to_string(filter.max_price, nil, true, nil, nil, true)) end if filter.max_percent then