refactoring
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
local private, public = {}, {}
|
||||
Aux.disenchant = public
|
||||
local m, private, public = Aux.module'disenchant'
|
||||
|
||||
function public.source(item_id)
|
||||
|
||||
@@ -68,7 +67,7 @@ local UNCOMMON, RARE, EPIC = 2, 3, 4
|
||||
|
||||
function public.value(slot, quality, level)
|
||||
local expectation
|
||||
for _, event in public.distribution(slot, quality, level) do
|
||||
for _, event in m.distribution(slot, quality, level) do
|
||||
local value = Aux.history.value(event.item_id..':'..0)
|
||||
if not value then
|
||||
return
|
||||
|
||||
+22
-23
@@ -1,5 +1,4 @@
|
||||
local private, public = {}, {}
|
||||
Aux.history = public
|
||||
local m, private, public = Aux.module'history'
|
||||
|
||||
local history_schema = {'record', '#', {next_push='number'}, {daily_min_buyout='number'}, {daily_max_price='number'}, {data_points={'list', ';', {'record', '@', {market_value='number'}, {time='number'}}}}}
|
||||
private.value_cache = {}
|
||||
@@ -11,7 +10,7 @@ function private.next_push()
|
||||
end
|
||||
|
||||
function private.new_record()
|
||||
return { next_push = private.next_push(), data_points = {} }
|
||||
return { next_push = m.next_push(), data_points = {} }
|
||||
end
|
||||
|
||||
function private.load_data()
|
||||
@@ -21,31 +20,31 @@ function private.load_data()
|
||||
end
|
||||
|
||||
function private.read_record(item_key)
|
||||
local data = private.load_data()
|
||||
local data = m.load_data()
|
||||
|
||||
local record
|
||||
if data[item_key] then
|
||||
record = Aux.persistence.read(history_schema, data[item_key])
|
||||
else
|
||||
record = private.new_record()
|
||||
record = m.new_record()
|
||||
end
|
||||
|
||||
if record.next_push <= time() then
|
||||
private.push_record(record)
|
||||
private.write_record(item_key, record)
|
||||
m.push_record(record)
|
||||
m.write_record(item_key, record)
|
||||
end
|
||||
|
||||
return record
|
||||
end
|
||||
|
||||
function private.write_record(item_key, record)
|
||||
private.value_cache[item_key] = nil
|
||||
local data = private.load_data()
|
||||
m.value_cache[item_key] = nil
|
||||
local data = m.load_data()
|
||||
data[item_key] = Aux.persistence.write(history_schema, record)
|
||||
end
|
||||
|
||||
function public.process_auction(auction_record)
|
||||
local item_record = private.read_record(auction_record.item_key)
|
||||
local item_record = m.read_record(auction_record.item_key)
|
||||
|
||||
local unit_bid_price = ceil(auction_record.bid_price / auction_record.aux_quantity)
|
||||
local unit_buyout_price = ceil(auction_record.buyout_price / auction_record.aux_quantity)
|
||||
@@ -56,17 +55,17 @@ function public.process_auction(auction_record)
|
||||
|
||||
item_record.daily_max_price = max(item_record.daily_max_price or 0, unit_buyout_price, unit_bid_price)
|
||||
|
||||
private.write_record(auction_record.item_key, item_record)
|
||||
m.write_record(auction_record.item_key, item_record)
|
||||
end
|
||||
|
||||
function public.price_data(item_key)
|
||||
local item_record = private.read_record(item_key)
|
||||
local item_record = m.read_record(item_key)
|
||||
return item_record.daily_min_buyout, item_record.daily_max_price, item_record.data_points
|
||||
end
|
||||
|
||||
function public.value(item_key)
|
||||
if not private.value_cache[item_key] or private.value_cache[item_key].next_push <= time() then
|
||||
local item_record = private.read_record(item_key)
|
||||
if not m.value_cache[item_key] or m.value_cache[item_key].next_push <= time() then
|
||||
local item_record = m.read_record(item_key)
|
||||
|
||||
local value
|
||||
if getn(item_record.data_points) > 0 then
|
||||
@@ -81,23 +80,23 @@ function public.value(item_key)
|
||||
weighted_value.weight = weighted_value.weight / total_weight
|
||||
end
|
||||
|
||||
value = private.weighted_median(weighted_values)
|
||||
value = m.weighted_median(weighted_values)
|
||||
else
|
||||
value = private.market_value(item_record)
|
||||
value = m.calculate_market_value(item_record)
|
||||
end
|
||||
|
||||
private.value_cache[item_key] = {value=value, next_push=item_record.next_push}
|
||||
m.value_cache[item_key] = {value=value, next_push=item_record.next_push}
|
||||
end
|
||||
|
||||
return private.value_cache[item_key].value
|
||||
return m.value_cache[item_key].value
|
||||
end
|
||||
|
||||
function public.market_value(item_key)
|
||||
local item_record = private.read_record(item_key)
|
||||
return private.market_value(item_record)
|
||||
local item_record = m.read_record(item_key)
|
||||
return m.calculate_market_value(item_record)
|
||||
end
|
||||
|
||||
function private.market_value(item_record)
|
||||
function private.calculate_market_value(item_record)
|
||||
return item_record.daily_min_buyout and min(ceil(item_record.daily_min_buyout * 1.15), item_record.daily_max_price)
|
||||
end
|
||||
|
||||
@@ -119,7 +118,7 @@ end
|
||||
|
||||
function private.push_record(item_record)
|
||||
|
||||
local market_value = private.market_value(item_record)
|
||||
local market_value = m.calculate_market_value(item_record)
|
||||
if market_value then
|
||||
tinsert(item_record.data_points, 1, { market_value = market_value, time = item_record.next_push })
|
||||
while getn(item_record.data_points) > 11 do
|
||||
@@ -129,5 +128,5 @@ function private.push_record(item_record)
|
||||
|
||||
item_record.daily_min_buyout = nil
|
||||
item_record.daily_max_price = nil
|
||||
item_record.next_push = private.next_push()
|
||||
item_record.next_push = m.next_push()
|
||||
end
|
||||
+3
-3
@@ -1,7 +1,7 @@
|
||||
local m = {}
|
||||
local m, private, public = Aux.module'completion'
|
||||
Aux.completion = m
|
||||
|
||||
function m:complete()
|
||||
function public:complete()
|
||||
if IsControlKeyDown() then -- TODO problem is ctrl-v, maybe find a better solution
|
||||
return
|
||||
end
|
||||
@@ -23,7 +23,7 @@ function m:complete()
|
||||
end
|
||||
end
|
||||
|
||||
function m.completor(options)
|
||||
function public.completor(options)
|
||||
return function(self)
|
||||
if IsControlKeyDown() then -- TODO problem is ctrl-v, maybe find a better solution
|
||||
return
|
||||
|
||||
+28
-29
@@ -1,7 +1,6 @@
|
||||
local private, public = {}, {}
|
||||
Aux.util = public
|
||||
local m, private, public = Aux.module'util'
|
||||
|
||||
function Aux.util.pass()
|
||||
function public.pass()
|
||||
end
|
||||
|
||||
function public.id(object)
|
||||
@@ -109,21 +108,21 @@ function Aux_PluralizeIf(word, count)
|
||||
end
|
||||
end
|
||||
|
||||
function Aux.util.without_errors(f)
|
||||
function public.without_errors(f)
|
||||
local orig = UIErrorsFrame.AddMessage
|
||||
UIErrorsFrame.AddMessage = Aux.util.pass
|
||||
UIErrorsFrame.AddMessage = m.pass
|
||||
f()
|
||||
UIErrorsFrame.AddMessage = orig
|
||||
end
|
||||
|
||||
function Aux.util.without_sound(f)
|
||||
function public.without_sound(f)
|
||||
local orig = GetCVar('MasterSoundEffects')
|
||||
SetCVar('MasterSoundEffects', 0)
|
||||
f()
|
||||
SetCVar('MasterSoundEffects', orig)
|
||||
end
|
||||
|
||||
function Aux.util.iter(array)
|
||||
function public.iter(array)
|
||||
local with_index = ipairs(array)
|
||||
return function()
|
||||
local _, value = with_index
|
||||
@@ -131,19 +130,19 @@ function Aux.util.iter(array)
|
||||
end
|
||||
end
|
||||
|
||||
function Aux.util.set_add(set, key)
|
||||
function public.set_add(set, key)
|
||||
set[key] = true
|
||||
end
|
||||
|
||||
function Aux.util.set_remove(set, key)
|
||||
function public.set_remove(set, key)
|
||||
set[key] = nil
|
||||
end
|
||||
|
||||
function Aux.util.set_contains(set, key)
|
||||
function public.set_contains(set, key)
|
||||
return set[key] ~= nil
|
||||
end
|
||||
|
||||
function Aux.util.set_size(set)
|
||||
function public.set_size(set)
|
||||
local size = 0
|
||||
for _,_ in pairs(set) do
|
||||
size = size + 1
|
||||
@@ -151,7 +150,7 @@ function Aux.util.set_size(set)
|
||||
return size
|
||||
end
|
||||
|
||||
function Aux.util.set_to_array(set)
|
||||
function public.set_to_array(set)
|
||||
local array = {}
|
||||
for element, _ in pairs(set) do
|
||||
tinsert(array, element)
|
||||
@@ -159,34 +158,34 @@ function Aux.util.set_to_array(set)
|
||||
return array
|
||||
end
|
||||
|
||||
function Aux.util.any(xs, p)
|
||||
holds = false
|
||||
function public.any(xs, p)
|
||||
local holds = false
|
||||
for _, x in ipairs(xs) do
|
||||
holds = holds or p(x)
|
||||
end
|
||||
return holds
|
||||
end
|
||||
|
||||
function Aux.util.all(xs, p)
|
||||
holds = true
|
||||
function public.all(xs, p)
|
||||
local holds = true
|
||||
for _, x in ipairs(xs) do
|
||||
holds = holds and p(x)
|
||||
end
|
||||
return holds
|
||||
end
|
||||
|
||||
function Aux.util.set_filter(xs, p)
|
||||
ys = {}
|
||||
function public.set_filter(xs, p)
|
||||
local ys = {}
|
||||
for x, _ in pairs(xs) do
|
||||
if p(x) then
|
||||
Aux.util.set_add(ys, x)
|
||||
m.set_add(ys, x)
|
||||
end
|
||||
end
|
||||
return ys
|
||||
end
|
||||
|
||||
function Aux.util.filter(xs, p)
|
||||
ys = {}
|
||||
function public.filter(xs, p)
|
||||
local ys = {}
|
||||
for _, x in ipairs(xs) do
|
||||
if p(x) then
|
||||
tinsert(ys, x)
|
||||
@@ -195,16 +194,16 @@ function Aux.util.filter(xs, p)
|
||||
return ys
|
||||
end
|
||||
|
||||
function Aux.util.map(xs, f)
|
||||
ys = {}
|
||||
function public.map(xs, f)
|
||||
local ys = {}
|
||||
for _, x in ipairs(xs) do
|
||||
tinsert(ys, f(x))
|
||||
end
|
||||
return ys
|
||||
end
|
||||
|
||||
function Aux.util.take(n, xs)
|
||||
ys = {}
|
||||
function public.take(n, xs)
|
||||
local ys = {}
|
||||
for i=1,n do
|
||||
if xs[i] then
|
||||
tinsert(ys, xs[i])
|
||||
@@ -213,7 +212,7 @@ function Aux.util.take(n, xs)
|
||||
return ys
|
||||
end
|
||||
|
||||
function Aux.util.index_of(value, array)
|
||||
function public.index_of(value, array)
|
||||
for i, item in ipairs(array) do
|
||||
if item == value then
|
||||
return i
|
||||
@@ -234,7 +233,7 @@ local GSC_3N = "|cff"..GSC_RED.."(|cff"..GSC_GOLD.."%d|cff000000.|cff"..GSC_SILV
|
||||
local GSC_2N = "|cff"..GSC_RED.."(|cff"..GSC_SILVER.."%d|cff000000.|cff"..GSC_COPPER.."%02d|cff"..GSC_RED..")|r"
|
||||
local GSC_1N = "|cff"..GSC_RED.."(|cff"..GSC_COPPER.."%d|cff"..GSC_RED..")|r"
|
||||
|
||||
function Aux.util.money_string(money)
|
||||
function public.money_string(money)
|
||||
money = floor(tonumber(money) or 0)
|
||||
local negative = money < 0
|
||||
money = abs(money)
|
||||
@@ -266,7 +265,7 @@ function Aux.util.money_string(money)
|
||||
end
|
||||
end
|
||||
|
||||
function Aux.util.group_by(tables, equal)
|
||||
function public.group_by(tables, equal)
|
||||
local groups = {}
|
||||
for _, table in ipairs(tables) do
|
||||
local found_group
|
||||
@@ -283,7 +282,7 @@ function Aux.util.group_by(tables, equal)
|
||||
return groups
|
||||
end
|
||||
|
||||
function Aux.util.set()
|
||||
function public.set()
|
||||
local self = {}
|
||||
|
||||
local data = {}
|
||||
|
||||
+25
-26
@@ -1,7 +1,6 @@
|
||||
local TOOLTIP_LENGTH = 30
|
||||
local m, private, public = Aux.module'info'
|
||||
|
||||
local private, public = {}, {}
|
||||
Aux.info = public
|
||||
local TOOLTIP_LENGTH = 30
|
||||
|
||||
function public.inventory_index(slot)
|
||||
local inventory_index_map = {
|
||||
@@ -41,13 +40,13 @@ function public.container_item(bag, slot)
|
||||
return
|
||||
end
|
||||
|
||||
local item_id, suffix_id, unique_id, enchant_id = public.parse_hyperlink(hyperlink)
|
||||
local item_info = public.item(item_id, suffix_id, unique_id, enchant_id)
|
||||
local item_id, suffix_id, unique_id, enchant_id = m.parse_hyperlink(hyperlink)
|
||||
local item_info = m.item(item_id, suffix_id, unique_id, enchant_id)
|
||||
|
||||
local texture, count, locked, quality, readable, lootable = GetContainerItemInfo(bag, slot) -- quality not working?
|
||||
local tooltip = public.tooltip(function(tt) tt:SetBagItem(bag, slot) end)
|
||||
local max_charges = private.max_item_charges(item_id)
|
||||
local charges = max_charges and private.item_charges(tooltip)
|
||||
local tooltip = m.tooltip(function(tt) tt:SetBagItem(bag, slot) end)
|
||||
local max_charges = m.max_item_charges(item_id)
|
||||
local charges = max_charges and m.item_charges(tooltip)
|
||||
local aux_quantity = charges or count
|
||||
|
||||
return {
|
||||
@@ -87,8 +86,8 @@ function public.auction_sell_item()
|
||||
if name then
|
||||
|
||||
local unit_vendor_price = vendor_price / count
|
||||
local tooltip = public.tooltip(function(tt) tt:SetAuctionSellItem() end)
|
||||
local charges = private.item_charges(tooltip)
|
||||
local tooltip = m.tooltip(function(tt) tt:SetAuctionSellItem() end)
|
||||
local charges = m.item_charges(tooltip)
|
||||
local aux_quantity = charges > 1 and charges or count
|
||||
|
||||
return {
|
||||
@@ -115,15 +114,15 @@ function public.auction(index, query_type)
|
||||
return
|
||||
end
|
||||
|
||||
local item_id, suffix_id, unique_id, enchant_id = public.parse_hyperlink(hyperlink)
|
||||
local item_info = public.item(item_id, suffix_id, unique_id, enchant_id)
|
||||
local item_id, suffix_id, unique_id, enchant_id = m.parse_hyperlink(hyperlink)
|
||||
local item_info = m.item(item_id, suffix_id, unique_id, enchant_id)
|
||||
|
||||
local name, texture, count, quality, usable, level, start_price, min_increment, buyout_price, high_bid, high_bidder, owner, sale_status = GetAuctionItemInfo(query_type, index)
|
||||
|
||||
local duration = GetAuctionItemTimeLeft(query_type, index)
|
||||
local tooltip = public.tooltip(function(tt) tt:SetAuctionItem(query_type, index) end)
|
||||
local max_charges = private.max_item_charges(item_id)
|
||||
local charges = max_charges and private.item_charges(tooltip)
|
||||
local tooltip = m.tooltip(function(tt) tt:SetAuctionItem(query_type, index) end)
|
||||
local max_charges = m.max_item_charges(item_id)
|
||||
local charges = max_charges and m.item_charges(tooltip)
|
||||
local aux_quantity = charges or count
|
||||
local blizzard_bid = high_bid > 0 and high_bid or start_price
|
||||
local bid_price = high_bid > 0 and (high_bid + min_increment) or start_price
|
||||
@@ -189,17 +188,17 @@ function public.set_tooltip(itemstring, owner, anchor)
|
||||
end
|
||||
|
||||
function public.set_shopping_tooltip(slot)
|
||||
local index1, index2 = public.inventory_index(slot)
|
||||
local index1, index2 = m.inventory_index(slot)
|
||||
|
||||
local tooltips = {}
|
||||
if index1 then
|
||||
local tooltip = public.tooltip(function(tt) tt:SetInventoryItem('player', index1) end)
|
||||
local tooltip = m.tooltip(function(tt) tt:SetInventoryItem('player', index1) end)
|
||||
if getn(tooltip) > 0 then
|
||||
tinsert(tooltips, tooltip)
|
||||
end
|
||||
end
|
||||
if index2 then
|
||||
local tooltip = public.tooltip(function(tt) tt:SetInventoryItem('player', index2) end)
|
||||
local tooltip = m.tooltip(function(tt) tt:SetInventoryItem('player', index2) end)
|
||||
if getn(tooltip) > 0 then
|
||||
tinsert(tooltips, tooltip)
|
||||
end
|
||||
@@ -209,7 +208,7 @@ function public.set_shopping_tooltip(slot)
|
||||
tinsert(tooltips[1], 1, { left_text = 'Currently Equipped', left_color = { 0.5, 0.5, 0.5 } })
|
||||
|
||||
ShoppingTooltip1:SetOwner(GameTooltip, 'ANCHOR_BOTTOMRIGHT')
|
||||
public.load_tooltip(ShoppingTooltip1, tooltips[1])
|
||||
m.load_tooltip(ShoppingTooltip1, tooltips[1])
|
||||
ShoppingTooltip1:Show()
|
||||
ShoppingTooltip1:SetPoint('TOPLEFT', GameTooltip, 'TOPRIGHT', 0, -10)
|
||||
end
|
||||
@@ -218,7 +217,7 @@ function public.set_shopping_tooltip(slot)
|
||||
tinsert(tooltips[2], 1, { left_text = 'Currently Equipped', left_color = { 0.5, 0.5, 0.5 } })
|
||||
|
||||
ShoppingTooltip2:SetOwner(ShoppingTooltip1, 'ANCHOR_BOTTOMRIGHT')
|
||||
public.load_tooltip(ShoppingTooltip2, tooltips[2])
|
||||
m.load_tooltip(ShoppingTooltip2, tooltips[2])
|
||||
ShoppingTooltip2:Show()
|
||||
ShoppingTooltip2:SetPoint('TOPLEFT', ShoppingTooltip1, 'TOPRIGHT')
|
||||
end
|
||||
@@ -275,13 +274,13 @@ function public.display_name(item_id, plain, uncolored)
|
||||
end
|
||||
|
||||
function public.auctionable(tooltip, quality, lootable)
|
||||
local durability, max_durability = public.durability(tooltip)
|
||||
local durability, max_durability = m.durability(tooltip)
|
||||
return not lootable
|
||||
and (not quality or quality < 6)
|
||||
and not public.tooltip_match(ITEM_BIND_ON_PICKUP, tooltip)
|
||||
and not public.tooltip_match(ITEM_BIND_QUEST, tooltip)
|
||||
and not public.tooltip_match(ITEM_SOULBOUND, tooltip)
|
||||
and (not public.tooltip_match(ITEM_CONJURED, tooltip) or public.tooltip_find(ITEM_MIN_LEVEL, tooltip) > 1)
|
||||
and not m.tooltip_match(ITEM_BIND_ON_PICKUP, tooltip)
|
||||
and not m.tooltip_match(ITEM_BIND_QUEST, tooltip)
|
||||
and not m.tooltip_match(ITEM_SOULBOUND, tooltip)
|
||||
and (not m.tooltip_match(ITEM_CONJURED, tooltip) or m.tooltip_find(ITEM_MIN_LEVEL, tooltip) > 1)
|
||||
and not (durability and durability < max_durability)
|
||||
end
|
||||
|
||||
@@ -377,7 +376,7 @@ function public.durability(tooltip)
|
||||
end
|
||||
|
||||
function public.item_key(hyperlink)
|
||||
local item_id, suffix_id = public.parse_hyperlink(hyperlink)
|
||||
local item_id, suffix_id = m.parse_hyperlink(hyperlink)
|
||||
return item_id..':'..suffix_id
|
||||
end
|
||||
|
||||
|
||||
+6
-7
@@ -1,5 +1,4 @@
|
||||
local m = {}
|
||||
Aux.money = m
|
||||
local m, private, public = Aux.module'money'
|
||||
|
||||
local GOLD_TEXT = '|cffffd70ag|r'
|
||||
local SILVER_TEXT = '|cffc7c7cfs|r'
|
||||
@@ -9,19 +8,19 @@ do
|
||||
local COPPER_PER_SILVER = 100
|
||||
local COPPER_PER_GOLD = 10000
|
||||
|
||||
function m.to_GSC(money)
|
||||
function public.to_GSC(money)
|
||||
local gold = floor(money / COPPER_PER_GOLD)
|
||||
local silver = floor(mod(money, COPPER_PER_GOLD) / COPPER_PER_SILVER)
|
||||
local copper = mod(money, COPPER_PER_SILVER)
|
||||
return gold, silver, copper
|
||||
end
|
||||
|
||||
function m.from_GSC(gold, silver, copper)
|
||||
function public.from_GSC(gold, silver, copper)
|
||||
return gold * COPPER_PER_GOLD + silver * COPPER_PER_SILVER + copper
|
||||
end
|
||||
end
|
||||
|
||||
function m.to_string(money, pad, trim, decimal_points, color, no_color)
|
||||
function public.to_string(money, pad, trim, decimal_points, color, no_color)
|
||||
|
||||
local is_negative = money < 0
|
||||
money = abs(money)
|
||||
@@ -73,7 +72,7 @@ function m.to_string(money, pad, trim, decimal_points, color, no_color)
|
||||
return text
|
||||
end
|
||||
|
||||
function m.from_string(value)
|
||||
function public.from_string(value)
|
||||
value = strlower(value)
|
||||
|
||||
-- remove any colors
|
||||
@@ -94,7 +93,7 @@ function m.from_string(value)
|
||||
return m.from_GSC(gold or 0, silver or 0, copper or 0)
|
||||
end
|
||||
|
||||
function m.format_number(num, pad, decimal_padding, color)
|
||||
function public.format_number(num, pad, decimal_padding, color)
|
||||
|
||||
local padding = pad and 2 + (decimal_padding and decimal_padding + 1 or 0) or 0
|
||||
num = format('%0'..padding..'.0'..(decimal_padding or 0)..'f', num)
|
||||
|
||||
+11
-12
@@ -1,7 +1,6 @@
|
||||
local m = {}
|
||||
Aux.scan_util = m
|
||||
local m, private, public = Aux.module'scan_util'
|
||||
|
||||
function m.default_filter(str)
|
||||
function public.default_filter(str)
|
||||
return {
|
||||
arity = 0,
|
||||
test = function()
|
||||
@@ -14,7 +13,7 @@ function m.default_filter(str)
|
||||
}
|
||||
end
|
||||
|
||||
m.filters = {
|
||||
public.filters = {
|
||||
|
||||
['utilizable'] = {
|
||||
arity = 0,
|
||||
@@ -311,7 +310,7 @@ m.filters = {
|
||||
},
|
||||
}
|
||||
|
||||
function m.find(auction_record, status_bar, on_abort, on_failure, on_success)
|
||||
function public.find(auction_record, status_bar, on_abort, on_failure, on_success)
|
||||
|
||||
local function test(index)
|
||||
local auction_info = Aux.info.auction(index, auction_record.query_type)
|
||||
@@ -381,7 +380,7 @@ function m.find(auction_record, status_bar, on_abort, on_failure, on_success)
|
||||
}
|
||||
end
|
||||
|
||||
function m.filter_builder()
|
||||
function public.filter_builder()
|
||||
local filter = ''
|
||||
return {
|
||||
append = function(self, modifier)
|
||||
@@ -398,7 +397,7 @@ function m.filter_builder()
|
||||
}
|
||||
end
|
||||
|
||||
function m.item_query(item_id, first_page, last_page)
|
||||
function public.item_query(item_id, first_page, last_page)
|
||||
|
||||
local item_info = Aux.info.item(item_id)
|
||||
|
||||
@@ -411,7 +410,7 @@ function m.item_query(item_id, first_page, last_page)
|
||||
end
|
||||
end
|
||||
|
||||
function m.parse_filter_string(filter_string)
|
||||
function public.parse_filter_string(filter_string)
|
||||
local parts = Aux.util.split(filter_string, ';')
|
||||
|
||||
local filters = {}
|
||||
@@ -434,7 +433,7 @@ function m.parse_filter_string(filter_string)
|
||||
return filters
|
||||
end
|
||||
|
||||
function m.filter_from_string(filter_term)
|
||||
function public.filter_from_string(filter_term)
|
||||
local parts = Aux.util.map(Aux.util.split(filter_term, '/'), function(part) return strlower(Aux.util.trim(part)) end)
|
||||
|
||||
local blizzard_filter = {}
|
||||
@@ -608,7 +607,7 @@ function m.filter_from_string(filter_term)
|
||||
}, m.suggestions(blizzard_filter, getn(parts))
|
||||
end
|
||||
|
||||
function m.suggestions(blizzard_filter, num_parts)
|
||||
function public.suggestions(blizzard_filter, num_parts)
|
||||
|
||||
local suggestions = {}
|
||||
|
||||
@@ -676,7 +675,7 @@ function m.suggestions(blizzard_filter, num_parts)
|
||||
return suggestions
|
||||
end
|
||||
|
||||
function m.blizzard_query(filter)
|
||||
function public.blizzard_query(filter)
|
||||
|
||||
local item_info, class_index, subclass_index, slot_index
|
||||
if filter.exact then
|
||||
@@ -701,7 +700,7 @@ function m.blizzard_query(filter)
|
||||
}
|
||||
end
|
||||
|
||||
function m.validator(blizzard_filter, post_filter)
|
||||
function public.validator(blizzard_filter, post_filter)
|
||||
|
||||
return function(record)
|
||||
if blizzard_filter.exact and strlower(Aux.info.item(record.item_id).name) ~= blizzard_filter.name then
|
||||
|
||||
+4
-27
@@ -1,39 +1,16 @@
|
||||
local private, public = {}, {}
|
||||
Aux.sort = public
|
||||
local m, private, public = Aux.module'sort'
|
||||
|
||||
public.LT = {}
|
||||
public.EQ = {}
|
||||
public.GT = {}
|
||||
|
||||
function public.invert_order(ordering)
|
||||
if ordering == public.LT then
|
||||
return public.GT
|
||||
elseif ordering == public.GT then
|
||||
return public.LT
|
||||
else
|
||||
return public.EQ
|
||||
end
|
||||
end
|
||||
|
||||
function public.compare(a, b, desc)
|
||||
if a < b then
|
||||
return desc and public.GT or public.LT
|
||||
return desc and m.GT or m.LT
|
||||
elseif a > b then
|
||||
return desc and public.LT or public.GT
|
||||
return desc and m.LT or m.GT
|
||||
else
|
||||
return public.EQ
|
||||
end
|
||||
end
|
||||
|
||||
function public.compare_from_lt(lt)
|
||||
return function(a, b)
|
||||
if lt(a, b) then
|
||||
return public.LT
|
||||
elseif lt(b, a) then
|
||||
return public.GT
|
||||
else
|
||||
return public.EQ
|
||||
end
|
||||
return m.EQ
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user