vendor itemlink check
This commit is contained in:
+25
-22
@@ -30,31 +30,34 @@ function private.scan_merchant()
|
|||||||
-- TODO maybe more detail? zone or local merchant_name = UnitName('npc')
|
-- TODO maybe more detail? zone or local merchant_name = UnitName('npc')
|
||||||
local merchant_item_count = GetMerchantNumItems()
|
local merchant_item_count = GetMerchantNumItems()
|
||||||
for i=1,merchant_item_count do
|
for i=1,merchant_item_count do
|
||||||
local item_id = Aux.info.parse_hyperlink(GetMerchantItemLink(i))
|
local link = GetMerchantItemLink(i)
|
||||||
local _, _, price, count, stock = GetMerchantItemInfo(i)
|
if link then
|
||||||
local new_unit_price, new_limited = price / count, Aux.persistence.blizzard_boolean(stock >= 0)
|
local item_id = Aux.info.parse_hyperlink(link)
|
||||||
if aux_merchant_buy[item_id] then
|
local _, _, price, count, stock = GetMerchantItemInfo(i)
|
||||||
local fields = Aux.util.split(aux_merchant_buy[item_id], '#')
|
local new_unit_price, new_limited = price / count, Aux.persistence.blizzard_boolean(stock >= 0)
|
||||||
local old_unit_price, old_limited = tonumber(fields[1]), tonumber(fields[2])
|
if aux_merchant_buy[item_id] then
|
||||||
|
local fields = Aux.util.split(aux_merchant_buy[item_id], '#')
|
||||||
|
local old_unit_price, old_limited = tonumber(fields[1]), tonumber(fields[2])
|
||||||
|
|
||||||
local unit_price
|
local unit_price
|
||||||
if old_limited and not new_limited then
|
if old_limited and not new_limited then
|
||||||
unit_price = new_unit_price
|
unit_price = new_unit_price
|
||||||
elseif new_limited and not old_limited then
|
elseif new_limited and not old_limited then
|
||||||
unit_price = old_unit_price
|
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_limited or new_limited,
|
||||||
|
}, '#')
|
||||||
else
|
else
|
||||||
unit_price = min(old_unit_price, new_unit_price)
|
aux_merchant_buy[item_id] = Aux.util.join({
|
||||||
|
new_unit_price,
|
||||||
|
new_limited,
|
||||||
|
}, '#')
|
||||||
end
|
end
|
||||||
|
|
||||||
aux_merchant_buy[item_id] = Aux.util.join({
|
|
||||||
unit_price,
|
|
||||||
old_limited or new_limited,
|
|
||||||
}, '#')
|
|
||||||
else
|
|
||||||
aux_merchant_buy[item_id] = Aux.util.join({
|
|
||||||
new_unit_price,
|
|
||||||
new_limited,
|
|
||||||
}, '#')
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
Reference in New Issue
Block a user