vendor filters

This commit is contained in:
Manuel Simon Hirsig
2016-03-20 19:20:54 +01:00
parent 83c9ba5bdb
commit 0a4b9c4eb6
7 changed files with 70 additions and 18 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
## Interface: 11200
## Title: Aux
## SavedVariablesPerCharacter: aux_recent_searches, aux_favorite_searches, aux_post_mode, aux_price_per_unit, aux_tooltip_daily, aux_tooltip_disenchant_value, aux_tooltip_disenchant_distribution, aux_tooltip_disenchant_source
## SavedVariablesPerCharacter: aux_recent_searches, aux_favorite_searches, aux_post_mode, aux_price_per_unit, aux_tooltip_daily, aux_tooltip_vendor_buy, aux_tooltip_vendor_sell, aux_tooltip_disenchant_value, aux_tooltip_disenchant_distribution, aux_tooltip_disenchant_source
## SavedVariables: aux_datasets, aux_items, aux_auctionable_items, aux_merchant_buy, aux_merchant_sell
slash.lua
+4 -4
View File
@@ -99,8 +99,8 @@ function Aux.on_addon_loaded()
for i=1,reagent_count do
local item_id, suffix_id = Aux.info.parse_hyperlink(GetCraftReagentItemLink(id, i))
local count = ({GetCraftReagentInfo(id, i)})[3]
local _, price, unlimited = Aux.merchant.info(item_id)
local value = price and unlimited and price or Aux.history.value(item_id..':'..suffix_id)
local _, price, limited = Aux.merchant.info(item_id)
local value = price and not limited and price or Aux.history.value(item_id..':'..suffix_id)
if not value then
total_cost = nil
break
@@ -126,8 +126,8 @@ function Aux.on_addon_loaded()
for i=1,reagent_count do
local item_id, suffix_id = Aux.info.parse_hyperlink(GetTradeSkillReagentItemLink(id, i))
local count = ({GetTradeSkillReagentInfo(id, i)})[3]
local _, price, unlimited = Aux.merchant.info(item_id)
local value = price and unlimited and price or Aux.history.value(item_id..':'..suffix_id)
local _, price, limited = Aux.merchant.info(item_id)
local value = price and not limited and price or Aux.history.value(item_id..':'..suffix_id)
if not value then
total_cost = nil
break
+10 -10
View File
@@ -8,13 +8,13 @@ function public.on_load()
end
function public.info(item_id)
local unit_price, unlimited
local unit_price, limited
if aux_merchant_buy[item_id] then
local buy_fields = Aux.util.split(aux_merchant_buy[item_id], '#')
unit_price, unlimited = tonumber(buy_fields[1]), not not tonumber(buy_fields[2])
unit_price, limited = tonumber(buy_fields[1]), not not tonumber(buy_fields[2])
end
return aux_merchant_sell[item_id], unit_price, unlimited
return aux_merchant_sell[item_id], unit_price, limited
end
function private.scan_merchant()
@@ -30,28 +30,28 @@ function private.scan_merchant()
for i=1,merchant_item_count do
local item_id = Aux.info.parse_hyperlink(GetMerchantItemLink(i))
local _, _, price, count, stock = GetMerchantItemInfo(i)
local new_unit_price, new_unlimited = price / count, Aux.persistence.blizzard_boolean(stock == -1)
local new_unit_price, new_limited = price / count, Aux.persistence.blizzard_boolean(stock >= 0)
if aux_merchant_buy[item_id] then
local fields = Aux.util.split(aux_merchant_buy[item_id], '#')
local old_unit_price, old_unlimited = tonumber(fields[1]), tonumber(fields[2])
local old_unit_price, old_limited = tonumber(fields[1]), tonumber(fields[2])
local unit_price
if old_unlimited and not new_unlimited then
unit_price = old_unit_price
elseif new_unlimited and not old_unlimited then
if old_limited and not new_limited then
unit_price = new_unit_price
elseif new_limited and not old_limited then
unit_price = old_unit_price
else
unit_price = min(old_unit_price, new_unit_price)
end
aux_merchant_buy[item_id] = Aux.util.join({
unit_price,
old_unlimited or new_unlimited,
old_limited or new_limited,
}, '#')
else
aux_merchant_buy[item_id] = Aux.util.join({
new_unit_price,
new_unlimited,
new_limited,
}, '#')
end
end
+2 -2
View File
@@ -12,8 +12,8 @@ function private.get_dataset_key()
return private.realm..'|'..private.faction
end
function public.blizzard_boolean(bool)
return bool and 1 or nil
function public.blizzard_boolean(boolean)
return boolean and 1 or nil
end
function public.load_dataset()
+30
View File
@@ -271,6 +271,36 @@ m.filters = {
end
},
['bid-vendor-profit'] = {
arity = 1,
test = function(amount)
amount = Aux.money.from_string(amount or '') or 0
if amount > 0 then
return function(auction_record)
local vendor_price = Aux.merchant.info(auction_record.item_id)
return vendor_price and vendor_price * auction_record.aux_quantity - auction_record.bid_price >= amount
end
else
return false, {}, 'Erroneous Bid Vendor Profit Modifier'
end
end
},
['buyout-vendor-profit'] = {
arity = 1,
test = function(amount)
amount = Aux.money.from_string(amount or '') or 0
if amount > 0 then
return function(auction_record)
local vendor_price = Aux.merchant.info(auction_record.item_id)
return vendor_price and vendor_price * auction_record.aux_quantity - auction_record.buyout_price >= amount
end
else
return false, {}, 'Erroneous Buyout Vendor Profit Modifier'
end
end
},
['discard'] = {
arity = 0,
test = function()
+6
View File
@@ -24,6 +24,12 @@ function SlashCmdList.AUX(parameter)
elseif parameter == 'tooltip daily' then
aux_tooltip_daily = not aux_tooltip_daily
Aux.log('Market value in tooltip '..(aux_tooltip_daily and 'enabled' or 'disabled')..'.')
elseif parameter == 'tooltip vendor buy' then
aux_tooltip_vendor_buy = not aux_tooltip_vendor_buy
Aux.log('Vendor buy price in tooltip '..(aux_tooltip_vendor_buy and 'enabled' or 'disabled')..'.')
elseif parameter == 'tooltip vendor sell' then
aux_tooltip_vendor_sell = not aux_tooltip_vendor_sell
Aux.log('Vendor sell price in tooltip '..(aux_tooltip_vendor_sell and 'enabled' or 'disabled')..'.')
elseif parameter == 'tooltip disenchant value' then
aux_tooltip_disenchant_value = not aux_tooltip_disenchant_value
Aux.log('Disenchant value in tooltip '..(aux_tooltip_disenchant_value and 'enabled' or 'disabled')..'.')
+17 -1
View File
@@ -62,7 +62,6 @@ function private.extend_tooltip(tooltip, hyperlink, quantity)
end
local item_info = Aux.info.item(item_id)
if item_info then
local distribution = Aux.disenchant.distribution(item_info.slot, item_info.quality, item_info.level)
@@ -87,6 +86,23 @@ function private.extend_tooltip(tooltip, hyperlink, quantity)
end
end
if aux_tooltip_vendor_buy then
local color = {r=0.8, g=0.5, b=0.1}
local _, price, limited = Aux.merchant.info(item_id)
if price then
tooltip:AddLine('Vendor Buy '..(limited and '(limited): ' or ': ')..Aux.util.format_money(price), color.r, color.g, color.b)
end
end
if aux_tooltip_vendor_sell then
local color = {r=0.8, g=0.5, b=0.1}
local price = Aux.merchant.info(item_id)
if price then
tooltip:AddLine('Vendor Sell: '..Aux.util.format_money(price), color.r, color.g, color.b)
end
end
local item_key = (item_id or 0)..':'..(suffix_id or 0)
local value = Aux.history.value(item_key)