module refactoring
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
module 'aux.util.completion'
|
||||
|
||||
include 'T'
|
||||
include 'aux'
|
||||
|
||||
local filter_util = require 'aux.util.filter'
|
||||
|
||||
+45
-45
@@ -1,12 +1,12 @@
|
||||
module 'aux.util.filter'
|
||||
|
||||
include 'T'
|
||||
include 'aux'
|
||||
|
||||
local T = require 'T'
|
||||
|
||||
local info = require 'aux.util.info'
|
||||
local money = require 'aux.util.money'
|
||||
local filter_util = require 'aux.util.filter'
|
||||
local cache = require 'aux.core.cache'
|
||||
local history = require 'aux.core.history'
|
||||
local disenchant = require 'aux.core.disenchant'
|
||||
|
||||
@@ -51,7 +51,7 @@ M.filters = {
|
||||
},
|
||||
|
||||
['left'] = {
|
||||
input_type = A('30m', '2h', '8h', '24h'),
|
||||
input_type = T.list('30m', '2h', '8h', '24h'),
|
||||
validator = function(index)
|
||||
return function(auction_record)
|
||||
return auction_record.duration == index
|
||||
@@ -60,7 +60,7 @@ M.filters = {
|
||||
},
|
||||
|
||||
['rarity'] = {
|
||||
input_type = A('poor', 'common', 'uncommon', 'rare', 'epic'),
|
||||
input_type = T.list('poor', 'common', 'uncommon', 'rare', 'epic'),
|
||||
validator = function(index)
|
||||
return function(auction_record)
|
||||
return auction_record.quality == index - 1
|
||||
@@ -166,7 +166,7 @@ M.filters = {
|
||||
input_type = 'money',
|
||||
validator = function(amount)
|
||||
return function(auction_record)
|
||||
local vendor_price = cache.merchant_info(auction_record.item_id)
|
||||
local vendor_price = info.merchant_info(auction_record.item_id)
|
||||
return vendor_price and vendor_price * auction_record.aux_quantity - auction_record.bid_price >= amount
|
||||
end
|
||||
end
|
||||
@@ -176,7 +176,7 @@ M.filters = {
|
||||
input_type = 'money',
|
||||
validator = function(amount)
|
||||
return function(auction_record)
|
||||
local vendor_price = cache.merchant_info(auction_record.item_id)
|
||||
local vendor_price = info.merchant_info(auction_record.item_id)
|
||||
return auction_record.buyout_price > 0 and vendor_price and vendor_price * auction_record.aux_quantity - auction_record.buyout_price >= amount
|
||||
end
|
||||
end
|
||||
@@ -184,12 +184,12 @@ M.filters = {
|
||||
}
|
||||
|
||||
function operator(str)
|
||||
local operator = str == 'not' and A('operator', 'not', 1)
|
||||
for name in pairs(temp-S('and', 'or')) do
|
||||
local operator = str == 'not' and T.list('operator', 'not', 1)
|
||||
for name in pairs(T.temp-T.set('and', 'or')) do
|
||||
local arity = select(3, strfind(str, '^' .. name .. '(%d*)$'))
|
||||
if arity then
|
||||
arity = tonumber(arity)
|
||||
operator = not (arity and arity < 2) and A('operator', name, arity)
|
||||
operator = not (arity and arity < 2) and T.list('operator', name, arity)
|
||||
end
|
||||
end
|
||||
return operator or nil
|
||||
@@ -206,41 +206,41 @@ do
|
||||
local number = tonumber(select(3, strfind(str, '^(%d+)$')))
|
||||
if number then
|
||||
if number >= 1 and number <= 60 then
|
||||
for _, key in ipairs(temp-A('min_level', 'max_level')) do
|
||||
for _, key in ipairs(T.temp-T.list('min_level', 'max_level')) do
|
||||
if not self[key] then
|
||||
self[key] = A(str, number)
|
||||
return A('blizzard', key, str, number)
|
||||
self[key] = T.list(str, number)
|
||||
return T.list('blizzard', key, str, number)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
for _, parser in pairs(temp-A(
|
||||
temp-A('class', info.item_class_index),
|
||||
temp-A('subclass', vararg-function(arg) return info.item_subclass_index(index(self.class, 2) or 0, unpack(arg)) end),
|
||||
temp-A('slot', vararg-function(arg) return info.item_slot_index(index(self.class, 2) == 2 and 2 or 0, index(self.subclass, 2) or 0, unpack(arg)) end),
|
||||
temp-A('quality', info.item_quality_index)
|
||||
for _, parser in pairs(T.temp-T.list(
|
||||
T.temp-T.list('class', info.item_class_index),
|
||||
T.temp-T.list('subclass', T.vararg-function(arg) return info.item_subclass_index(index(self.class, 2) or 0, unpack(arg)) end),
|
||||
T.temp-T.list('slot', T.vararg-function(arg) return info.item_slot_index(index(self.class, 2) == 2 and 2 or 0, index(self.subclass, 2) or 0, unpack(arg)) end),
|
||||
T.temp-T.list('quality', info.item_quality_index)
|
||||
)) do
|
||||
if not self[parser[1]] then
|
||||
tinsert(parser, str)
|
||||
local index, label = parser[2](select(3, unpack(parser)))
|
||||
if index then
|
||||
self[parser[1]] = A(label, index)
|
||||
return A('blizzard', parser[1], label, index)
|
||||
self[parser[1]] = T.list(label, index)
|
||||
return T.list('blizzard', parser[1], label, index)
|
||||
end
|
||||
end
|
||||
end
|
||||
if not self[str] and (str == 'usable' or str == 'exact' and self.name and size(self) == 1) then
|
||||
self[str] = A(str, 1)
|
||||
return A('blizzard', str, str, 1)
|
||||
self[str] = T.list(str, 1)
|
||||
return T.list('blizzard', str, str, 1)
|
||||
elseif i == 1 and strlen(str) <= 63 then
|
||||
self.name = unquote(str)
|
||||
return A('blizzard', 'name', unquote(str), str)
|
||||
return T.list('blizzard', 'name', unquote(str), str)
|
||||
-- return nil, 'The name filter must not be longer than 63 characters' TODO
|
||||
end
|
||||
end,
|
||||
}
|
||||
function blizzard_filter_parser()
|
||||
return setmetatable(T, mt)
|
||||
return setmetatable(T.acquire(), mt)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -259,10 +259,10 @@ function parse_parameter(input_type, str)
|
||||
end
|
||||
|
||||
function M.parse_filter_string(str)
|
||||
local filter, post_filter = T, T
|
||||
local filter, post_filter = T.acquire(), T.acquire()
|
||||
local blizzard_filter_parser = blizzard_filter_parser()
|
||||
|
||||
local parts = str and map(split(str, '/'), function(part) return strlower(trim(part)) end) or T
|
||||
local parts = str and map(split(str, '/'), function(part) return strlower(trim(part)) end) or T.acquire()
|
||||
|
||||
local i = 1
|
||||
while parts[i] do
|
||||
@@ -282,10 +282,10 @@ function M.parse_filter_string(str)
|
||||
return nil, 'Invalid input for ' .. parts[i] .. '. Expecting: ' .. input_type
|
||||
end
|
||||
end
|
||||
tinsert(post_filter, A('filter', parts[i], parts[i + 1]))
|
||||
tinsert(post_filter, T.list('filter', parts[i], parts[i + 1]))
|
||||
i = i + 1
|
||||
else
|
||||
tinsert(post_filter, A('filter', parts[i]))
|
||||
tinsert(post_filter, T.list('filter', parts[i]))
|
||||
end
|
||||
tinsert(filter, post_filter[getn(post_filter)])
|
||||
else
|
||||
@@ -293,7 +293,7 @@ function M.parse_filter_string(str)
|
||||
if part then
|
||||
tinsert(filter, part)
|
||||
elseif parts[i] ~= '' then
|
||||
tinsert(post_filter, A('filter', 'tooltip', parts[i]))
|
||||
tinsert(post_filter, T.list('filter', 'tooltip', parts[i]))
|
||||
tinsert(filter, post_filter[getn(post_filter)])
|
||||
else
|
||||
return nil, 'Empty modifier'
|
||||
@@ -302,14 +302,14 @@ function M.parse_filter_string(str)
|
||||
i = i + 1
|
||||
end
|
||||
|
||||
return O('components', filter, 'blizzard', blizzard_filter_parser(), 'post', post_filter)
|
||||
return T.map('components', filter, 'blizzard', blizzard_filter_parser(), 'post', post_filter)
|
||||
end
|
||||
|
||||
function M.query(filter_string)
|
||||
local filter, error, suggestions = parse_filter_string(filter_string)
|
||||
|
||||
if not filter then
|
||||
return nil, suggestions or T, error
|
||||
return nil, suggestions or T.acquire(), error
|
||||
end
|
||||
|
||||
local polish_notation_counter = 0
|
||||
@@ -323,7 +323,7 @@ function M.query(filter_string)
|
||||
end
|
||||
|
||||
if polish_notation_counter > 0 then
|
||||
local suggestions = T
|
||||
local suggestions = T.acquire()
|
||||
for key in pairs(filters) do
|
||||
tinsert(suggestions, strlower(key))
|
||||
end
|
||||
@@ -342,7 +342,7 @@ end
|
||||
|
||||
function M.queries(filter_string)
|
||||
local parts = split(filter_string, ';')
|
||||
local queries = T
|
||||
local queries = T.acquire()
|
||||
for _, str in ipairs(parts) do
|
||||
local query, _, error = query(str)
|
||||
if not query then
|
||||
@@ -355,7 +355,7 @@ function M.queries(filter_string)
|
||||
end
|
||||
|
||||
function suggestions(filter)
|
||||
local suggestions = T
|
||||
local suggestions = T.acquire()
|
||||
|
||||
if filter.blizzard.name and size(filter.blizzard) == 1 then tinsert(suggestions, 'exact') end
|
||||
|
||||
@@ -365,19 +365,19 @@ function suggestions(filter)
|
||||
|
||||
-- classes
|
||||
if not filter.blizzard.class then
|
||||
for _, class in ipairs(temp-A(GetAuctionItemClasses())) do tinsert(suggestions, class) end
|
||||
for _, class in ipairs(T.temp-T.list(GetAuctionItemClasses())) do tinsert(suggestions, class) end
|
||||
end
|
||||
|
||||
-- subclasses
|
||||
if not filter.blizzard.subclass then
|
||||
for _, subclass in ipairs(temp-A(GetAuctionItemSubClasses(index(filter.blizzard.class, 2) or 0))) do
|
||||
for _, subclass in ipairs(T.temp-T.list(GetAuctionItemSubClasses(index(filter.blizzard.class, 2) or 0))) do
|
||||
tinsert(suggestions, subclass)
|
||||
end
|
||||
end
|
||||
|
||||
-- slots
|
||||
if not filter.blizzard.slot then
|
||||
for _, invtype in ipairs(temp-A(GetAuctionInvTypes(index(filter.blizzard.class, 2) == 2 and 2 or 0, index(filter.blizzard.subclass, 2) or 0))) do
|
||||
for _, invtype in ipairs(T.temp-T.list(GetAuctionInvTypes(index(filter.blizzard.class, 2) == 2 and 2 or 0, index(filter.blizzard.subclass, 2) or 0))) do
|
||||
tinsert(suggestions, _G[invtype])
|
||||
end
|
||||
end
|
||||
@@ -427,7 +427,7 @@ function prettified_filter_string(filter)
|
||||
if component[1] == 'blizzard' then
|
||||
if component[2] == 'name' then
|
||||
if filter.blizzard.exact then
|
||||
prettified.append(info.display_name(cache.item_id(component[3])) or color.orange('[' .. component[3] .. ']'))
|
||||
prettified.append(info.display_name(info.item_id(component[3])) or color.orange('[' .. component[3] .. ']'))
|
||||
elseif component[3] ~= '' then
|
||||
prettified.append(color.label.enabled(component[3]))
|
||||
end
|
||||
@@ -443,7 +443,7 @@ function prettified_filter_string(filter)
|
||||
local parameter = component[3]
|
||||
if parameter then
|
||||
if component[2] == 'item' then
|
||||
prettified.append(info.display_name(cache.item_id(parameter)) or color.label.enabled('[' .. parameter .. ']'))
|
||||
prettified.append(info.display_name(info.item_id(parameter)) or color.label.enabled('[' .. parameter .. ']'))
|
||||
else
|
||||
if filters[component[2]].input_type == 'money' then
|
||||
prettified.append(money.to_string(money.from_string(parameter), nil, true, color.label.enabled))
|
||||
@@ -471,9 +471,9 @@ end
|
||||
|
||||
function blizzard_query(filter)
|
||||
local filters = filter.blizzard
|
||||
local query = O('name', filters.name)
|
||||
local query = T.map('name', filters.name)
|
||||
local item_info, class_index, subclass_index, slot_index
|
||||
local item_id = filters.name and cache.item_id(filters.name)
|
||||
local item_id = filters.name and info.item_id(filters.name)
|
||||
item_info = item_id and info.item(item_id)
|
||||
if filters.exact and item_info then
|
||||
class_index = info.item_class_index(item_info.class)
|
||||
@@ -489,7 +489,7 @@ function blizzard_query(filter)
|
||||
query.slot = slot_index
|
||||
query.quality = item_info.quality
|
||||
else
|
||||
for key in pairs(temp-S('min_level', 'max_level', 'class', 'subclass', 'slot', 'usable', 'quality')) do
|
||||
for key in pairs(T.temp-T.set('min_level', 'max_level', 'class', 'subclass', 'slot', 'usable', 'quality')) do
|
||||
query[key] = index(filters[key], 2)
|
||||
end
|
||||
end
|
||||
@@ -497,7 +497,7 @@ function blizzard_query(filter)
|
||||
end
|
||||
|
||||
function validator(filter)
|
||||
local validators = T
|
||||
local validators = T.acquire()
|
||||
for i, component in pairs(filter.post) do
|
||||
local type, name, param = unpack(component)
|
||||
if type == 'filter' then
|
||||
@@ -508,11 +508,11 @@ function validator(filter)
|
||||
if filter.blizzard.exact and strlower(info.item(record.item_id).name) ~= filter.blizzard.name then
|
||||
return false
|
||||
end
|
||||
local stack = temp-T
|
||||
local stack = T.temp-T.acquire()
|
||||
for i = getn(filter.post), 1, -1 do
|
||||
local type, name, param = unpack(filter.post[i])
|
||||
if type == 'operator' then
|
||||
local args = temp-T
|
||||
local args = T.temp-T.acquire()
|
||||
while (not param or param > 0) and getn(stack) > 0 do
|
||||
tinsert(args, tremove(stack))
|
||||
param = param and param - 1
|
||||
@@ -534,7 +534,7 @@ end
|
||||
|
||||
function M.query_builder()
|
||||
local filter
|
||||
return O(
|
||||
return T.map(
|
||||
'append', function(part)
|
||||
filter = not filter and part or filter .. '/' .. part
|
||||
end,
|
||||
|
||||
+24
-25
@@ -1,9 +1,8 @@
|
||||
module 'aux.util.info'
|
||||
|
||||
include 'T'
|
||||
include 'aux'
|
||||
|
||||
local cache = require 'aux.core.cache'
|
||||
local T = require 'T'
|
||||
|
||||
CreateFrame('GameTooltip', 'AuxTooltip', nil, 'GameTooltipTemplate')
|
||||
AuxTooltip:SetScript('OnTooltipAddMoney', function()
|
||||
@@ -38,7 +37,7 @@ do
|
||||
INVTYPE_TABARD = {19},
|
||||
}
|
||||
function M.inventory_index(slot)
|
||||
return unpack(inventory_index_map[slot] or temp-T)
|
||||
return unpack(inventory_index_map[slot] or T.temp-T.acquire())
|
||||
end
|
||||
end
|
||||
|
||||
@@ -46,14 +45,14 @@ function M.container_item(bag, slot)
|
||||
local link = GetContainerItemLink(bag, slot)
|
||||
if link then
|
||||
local item_id, suffix_id, unique_id, enchant_id = parse_link(link)
|
||||
local item_info = temp-item(item_id, suffix_id, unique_id, enchant_id)
|
||||
local item_info = T.temp-item(item_id, suffix_id, unique_id, enchant_id)
|
||||
|
||||
local texture, count, locked, quality, readable, lootable = GetContainerItemInfo(bag, slot) -- quality not working?
|
||||
local tooltip, tooltip_money = tooltip('bag', bag, slot)
|
||||
local max_charges = max_item_charges(item_id)
|
||||
local charges = max_charges and item_charges(tooltip)
|
||||
local aux_quantity = charges or count
|
||||
return O(
|
||||
return T.map(
|
||||
'item_id', item_id,
|
||||
'suffix_id', suffix_id,
|
||||
'unique_id', unique_id,
|
||||
@@ -88,7 +87,7 @@ end
|
||||
|
||||
function M.auction_sell_item()
|
||||
for name, texture, count, quality, usable, vendor_price in GetAuctionSellItemInfo do
|
||||
return O(
|
||||
return T.map(
|
||||
'name', name,
|
||||
'texture', texture,
|
||||
'quality', quality,
|
||||
@@ -105,7 +104,7 @@ function M.auction(index, query_type)
|
||||
local link = GetAuctionItemLink(query_type, index)
|
||||
if link then
|
||||
local item_id, suffix_id, unique_id, enchant_id = parse_link(link)
|
||||
local item_info = temp-item(item_id, suffix_id, unique_id, enchant_id)
|
||||
local item_info = T.temp-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)
|
||||
|
||||
@@ -117,7 +116,7 @@ function M.auction(index, query_type)
|
||||
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
|
||||
|
||||
return O(
|
||||
return T.map(
|
||||
'item_id', item_id,
|
||||
'suffix_id', suffix_id,
|
||||
'unique_id', unique_id,
|
||||
@@ -126,8 +125,8 @@ function M.auction(index, query_type)
|
||||
'link', link,
|
||||
'itemstring', item_info.itemstring,
|
||||
'item_key', item_id .. ':' .. suffix_id,
|
||||
'search_signature', join(temp-A(item_id, suffix_id, enchant_id, start_price, buyout_price, bid_price, aux_quantity, duration, query_type == 'owner' and high_bidder or (high_bidder and 1 or 0), aux_ignore_owner and (cache.is_player(owner) and 0 or 1) or (owner or '?')), ':'),
|
||||
'sniping_signature', join(temp-A(item_id, suffix_id, enchant_id, start_price, buyout_price, aux_quantity, aux_ignore_owner and (cache.is_player(owner) and 0 or 1) or (owner or '?')), ':'),
|
||||
'search_signature', join(T.temp-T.list(item_id, suffix_id, enchant_id, start_price, buyout_price, bid_price, aux_quantity, duration, query_type == 'owner' and high_bidder or (high_bidder and 1 or 0), aux_ignore_owner and (is_player(owner) and 0 or 1) or (owner or '?')), ':'),
|
||||
'sniping_signature', join(T.temp-T.list(item_id, suffix_id, enchant_id, start_price, buyout_price, aux_quantity, aux_ignore_owner and (is_player(owner) and 0 or 1) or (owner or '?')), ':'),
|
||||
|
||||
'name', name,
|
||||
'texture', texture,
|
||||
@@ -171,7 +170,7 @@ function M.bid_update(auction_record)
|
||||
auction_record.unit_blizzard_bid = auction_record.blizzard_bid / auction_record.aux_quantity
|
||||
auction_record.unit_bid_price = auction_record.bid_price / auction_record.aux_quantity
|
||||
auction_record.high_bidder = 1
|
||||
auction_record.search_signature = join(temp-A(auction_record.item_id, auction_record.suffix_id, auction_record.enchant_id, auction_record.start_price, auction_record.buyout_price, auction_record.bid_price, auction_record.aux_quantity, auction_record.duration, 1, aux_ignore_owner and (cache.is_player(auction_record.owner) and 0 or 1) or (auction_record.owner or '?')), ':')
|
||||
auction_record.search_signature = join(T.temp-T.list(auction_record.item_id, auction_record.suffix_id, auction_record.enchant_id, auction_record.start_price, auction_record.buyout_price, auction_record.bid_price, auction_record.aux_quantity, auction_record.duration, 1, aux_ignore_owner and (is_player(auction_record.owner) and 0 or 1) or (auction_record.owner or '?')), ':')
|
||||
end
|
||||
|
||||
function M.set_tooltip(itemstring, owner, anchor)
|
||||
@@ -181,7 +180,7 @@ end
|
||||
|
||||
function M.set_shopping_tooltip(slot)
|
||||
local index1, index2 = inventory_index(slot)
|
||||
local tooltips = temp-T
|
||||
local tooltips = T.temp-T.acquire()
|
||||
if index1 then
|
||||
local tooltip = tooltip('inventory', 'player', index1)
|
||||
if getn(tooltip) > 0 then
|
||||
@@ -196,14 +195,14 @@ function M.set_shopping_tooltip(slot)
|
||||
end
|
||||
|
||||
if tooltips[1] then
|
||||
tinsert(tooltips[1], 1, temp-O('left_text', 'Currently Equipped', 'left_color', temp-A(.5, .5, .5)))
|
||||
tinsert(tooltips[1], 1, T.temp-T.map('left_text', 'Currently Equipped', 'left_color', T.temp-T.list(.5, .5, .5)))
|
||||
ShoppingTooltip1:SetOwner(GameTooltip, 'ANCHOR_NONE')
|
||||
ShoppingTooltip1:SetPoint('TOPLEFT', GameTooltip, 'TOPRIGHT', 0, -10)
|
||||
load_tooltip(ShoppingTooltip1, tooltips[1])
|
||||
end
|
||||
|
||||
if tooltips[2] then
|
||||
tinsert(tooltips[2], 1, temp-O('left_text', 'Currently Equipped', 'left_color', temp-A(.5, .5, .5)))
|
||||
tinsert(tooltips[2], 1, T.temp-T.map('left_text', 'Currently Equipped', 'left_color', T.temp-T.list(.5, .5, .5)))
|
||||
ShoppingTooltip2:SetOwner(ShoppingTooltip1, 'ANCHOR_NONE')
|
||||
ShoppingTooltip2:SetPoint('TOPLEFT', ShoppingTooltip1, 'TOPRIGHT')
|
||||
load_tooltip(ShoppingTooltip2, tooltips[2])
|
||||
@@ -284,13 +283,13 @@ function M.tooltip(setter, arg1, arg2)
|
||||
elseif setter == 'link' then
|
||||
AuxTooltip:SetHyperlink(arg1)
|
||||
end
|
||||
local tooltip = T
|
||||
local tooltip = T.acquire()
|
||||
for i = 1, AuxTooltip:NumLines() do
|
||||
tinsert(tooltip, O(
|
||||
tinsert(tooltip, T.map(
|
||||
'left_text', _G['AuxTooltipTextLeft' .. i]:GetText(),
|
||||
'left_color', A(_G['AuxTooltipTextLeft' .. i]:GetTextColor()),
|
||||
'left_color', T.list(_G['AuxTooltipTextLeft' .. i]:GetTextColor()),
|
||||
'right_text', _G['AuxTooltipTextRight' .. i]:IsVisible() and _G['AuxTooltipTextRight' .. i]:GetText(),
|
||||
'right_color', A(_G['AuxTooltipTextRight' .. i]:GetTextColor())
|
||||
'right_color', T.list(_G['AuxTooltipTextRight' .. i]:GetTextColor())
|
||||
))
|
||||
end
|
||||
return tooltip, AuxTooltip.money
|
||||
@@ -372,7 +371,7 @@ end
|
||||
function M.item(item_id, suffix_id)
|
||||
local itemstring = 'item:' .. (item_id or 0) .. ':0:' .. (suffix_id or 0) .. ':0'
|
||||
local name, itemstring, quality, level, class, subclass, max_stack, slot, texture = GetItemInfo(itemstring)
|
||||
return name and O(
|
||||
return name and T.map(
|
||||
'name', name,
|
||||
'itemstring', itemstring,
|
||||
'quality', quality,
|
||||
@@ -382,11 +381,11 @@ function M.item(item_id, suffix_id)
|
||||
'slot', slot,
|
||||
'max_stack', max_stack,
|
||||
'texture', texture
|
||||
) or cache.item_info(item_id)
|
||||
) or item_info(item_id)
|
||||
end
|
||||
|
||||
function M.item_class_index(item_class)
|
||||
for i, class in pairs(temp-A(GetAuctionItemClasses())) do
|
||||
for i, class in pairs(T.temp-T.list(GetAuctionItemClasses())) do
|
||||
if strupper(class) == strupper(item_class) then
|
||||
return i, class
|
||||
end
|
||||
@@ -394,7 +393,7 @@ function M.item_class_index(item_class)
|
||||
end
|
||||
|
||||
function M.item_subclass_index(class_index, item_subclass)
|
||||
for i, subclass in pairs(temp-A(GetAuctionItemSubClasses(class_index))) do
|
||||
for i, subclass in pairs(T.temp-T.list(GetAuctionItemSubClasses(class_index))) do
|
||||
if strupper(subclass) == strupper(item_subclass) then
|
||||
return i, subclass
|
||||
end
|
||||
@@ -402,7 +401,7 @@ function M.item_subclass_index(class_index, item_subclass)
|
||||
end
|
||||
|
||||
function M.item_slot_index(class_index, subclass_index, slot_name)
|
||||
for i, slot in pairs(temp-A(GetAuctionInvTypes(class_index, subclass_index))) do
|
||||
for i, slot in pairs(T.temp-T.list(GetAuctionInvTypes(class_index, subclass_index))) do
|
||||
if strupper(_G[slot]) == strupper(slot_name) then
|
||||
return i, _G[slot]
|
||||
end
|
||||
@@ -418,7 +417,7 @@ function M.item_quality_index(item_quality)
|
||||
end
|
||||
end
|
||||
|
||||
function M.get.inventory()
|
||||
function M.inventory()
|
||||
local bag, slot = 0, 0
|
||||
return function()
|
||||
if not GetBagName(bag) or slot >= GetContainerNumSlots(bag) then
|
||||
@@ -427,7 +426,7 @@ function M.get.inventory()
|
||||
else
|
||||
slot = slot + 1
|
||||
end
|
||||
if bag <= 4 then return A(bag, slot), bag_type(bag) end
|
||||
if bag <= 4 then return T.list(bag, slot), bag_type(bag) end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
+3
-2
@@ -1,8 +1,9 @@
|
||||
module 'aux.util.money'
|
||||
|
||||
include 'T'
|
||||
include 'aux'
|
||||
|
||||
local T = require 'T'
|
||||
|
||||
M.GOLD_TEXT = '|cffffd70ag|r'
|
||||
M.SILVER_TEXT = '|cffc7c7cfs|r'
|
||||
M.COPPER_TEXT = '|cffeda55fc|r'
|
||||
@@ -72,7 +73,7 @@ function M.to_string(money, pad, trim, color, no_color)
|
||||
|
||||
local text
|
||||
if trim then
|
||||
local parts = temp-T
|
||||
local parts = T.temp-T.acquire()
|
||||
if gold > 0 then
|
||||
tinsert(parts, format_number(gold, false, color) .. gold_text)
|
||||
end
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
module 'aux.util.persistence'
|
||||
|
||||
include 'T'
|
||||
include 'aux'
|
||||
|
||||
local T = require 'T'
|
||||
|
||||
function M.read(schema, str)
|
||||
if schema == 'string' then
|
||||
return str
|
||||
@@ -11,9 +12,9 @@ function M.read(schema, str)
|
||||
elseif schema == 'number' then
|
||||
return tonumber(str)
|
||||
elseif type(schema) == 'table' and schema[1] == 'list' then
|
||||
return temp-read_list(schema, str)
|
||||
return T.temp-read_list(schema, str)
|
||||
elseif type(schema) == 'table' and schema[1] == 'tuple' then
|
||||
return temp-read_tuple(schema, str)
|
||||
return T.temp-read_tuple(schema, str)
|
||||
else
|
||||
error('Invalid schema.', 2)
|
||||
end
|
||||
@@ -36,7 +37,7 @@ function M.write(schema, obj)
|
||||
end
|
||||
|
||||
function read_list(schema, str)
|
||||
if str == '' then return T end
|
||||
if str == '' then return T.acquire() end
|
||||
local separator = schema[2]
|
||||
local element_type = schema[3]
|
||||
return map(split(str, separator), function(part)
|
||||
@@ -47,7 +48,7 @@ end
|
||||
function write_list(schema, list)
|
||||
local separator = schema[2]
|
||||
local element_type = schema[3]
|
||||
local parts = map(temp-copy(list), function(element)
|
||||
local parts = map(T.temp-copy(list), function(element)
|
||||
return write(element_type, element)
|
||||
end)
|
||||
return join(parts, separator)
|
||||
@@ -55,8 +56,8 @@ end
|
||||
|
||||
function read_tuple(schema, str)
|
||||
local separator = schema[2]
|
||||
local tuple = T
|
||||
local parts = temp-split(str, separator)
|
||||
local tuple = T.acquire()
|
||||
local parts = T.temp-split(str, separator)
|
||||
for i = 3, getn(schema) do
|
||||
local key, type = next(schema[i])
|
||||
tuple[key] = read(type, parts[i - 2])
|
||||
@@ -66,7 +67,7 @@ end
|
||||
|
||||
function write_tuple(schema, tuple)
|
||||
local separator = schema[2]
|
||||
local parts = temp-T
|
||||
local parts = T.temp-T.acquire()
|
||||
for i = 3, getn(schema) do
|
||||
local key, type = next(schema[i])
|
||||
tinsert(parts, write(type, tuple[key]))
|
||||
|
||||
+7
-6
@@ -1,32 +1,33 @@
|
||||
module 'aux.util.scan'
|
||||
|
||||
include 'T'
|
||||
include 'aux'
|
||||
|
||||
local T = require 'T'
|
||||
|
||||
local info = require 'aux.util.info'
|
||||
local filter_util = require 'aux.util.filter'
|
||||
local scan = require 'aux.core.scan'
|
||||
|
||||
function M.test(record, index)
|
||||
local auction_record = temp-info.auction(index, record.query_type)
|
||||
local auction_record = T.temp-info.auction(index, record.query_type)
|
||||
return auction_record and auction_record.search_signature == record.search_signature
|
||||
end
|
||||
|
||||
function M.find(auction_record, status_bar, on_abort, on_failure, on_success)
|
||||
|
||||
local queries = A(T)
|
||||
local queries = T.list(T.acquire())
|
||||
|
||||
if auction_record.blizzard_query then
|
||||
local blizzard_query1 = copy(auction_record.blizzard_query)
|
||||
blizzard_query1.first_page = auction_record.page
|
||||
blizzard_query1.last_page = auction_record.page
|
||||
tinsert(queries, O('blizzard_query', blizzard_query1))
|
||||
tinsert(queries, T.map('blizzard_query', blizzard_query1))
|
||||
|
||||
if auction_record.page > 0 then
|
||||
local blizzard_query2 = copy(auction_record.blizzard_query)
|
||||
blizzard_query2.first_page = auction_record.page - 1
|
||||
blizzard_query2.last_page = auction_record.page - 1
|
||||
tinsert(queries, O('blizzard_query', blizzard_query2))
|
||||
tinsert(queries, T.map('blizzard_query', blizzard_query2))
|
||||
end
|
||||
|
||||
local item_query = item_query(auction_record.item_id, 0, 0)
|
||||
@@ -78,6 +79,6 @@ function M.item_query(item_id, first_page, last_page)
|
||||
local query = filter_util.query(item_info.name .. '/exact')
|
||||
query.blizzard_query.first_page = first_page
|
||||
query.blizzard_query.last_page = last_page
|
||||
return O('validator', query.validator, 'blizzard_query', query.blizzard_query)
|
||||
return T.map('validator', query.validator, 'blizzard_query', query.blizzard_query)
|
||||
end
|
||||
end
|
||||
+3
-2
@@ -1,8 +1,9 @@
|
||||
module 'aux.util.sort'
|
||||
|
||||
include 'T'
|
||||
include 'aux'
|
||||
|
||||
local T = require 'T'
|
||||
|
||||
M.EQ = 0
|
||||
M.LT = 1
|
||||
M.GT = 2
|
||||
@@ -17,7 +18,7 @@ function M.compare(a, b, desc)
|
||||
end
|
||||
end
|
||||
|
||||
M.multi_lt = vararg-function(arg)
|
||||
M.multi_lt = T.vararg-function(arg)
|
||||
for i = 1, getn(arg), 2 do
|
||||
if arg[i] and arg[i + 1] and arg[i] ~= arg[i + 1] then
|
||||
return arg[i] < arg[i + 1]
|
||||
|
||||
Reference in New Issue
Block a user