refactoring and default auction duration setting (this update will delete the history)

This commit is contained in:
Simon Hirsig
2019-03-27 13:22:57 +01:00
parent 5d3c20efb1
commit aa5daaf292
17 changed files with 132 additions and 113 deletions
+19 -25
View File
@@ -10,12 +10,6 @@ local MAX_ITEM_ID = 30000
local items_schema = {'tuple', '#', {name='string'}, {quality='number'}, {level='number'}, {class='string'}, {subclass='string'}, {slot='string'}, {max_stack='number'}, {texture='string'}}
local merchant_buy_schema = {'tuple', '#', {unit_price='number'}, {limited='boolean'}}
_G.aux_items = {}
_G.aux_item_ids = {}
_G.aux_auctionable_items = {}
_G.aux_merchant_buy = {}
_G.aux_merchant_sell = {}
function aux.handle.LOAD()
scan_wdb()
@@ -31,19 +25,19 @@ function aux.handle.LOAD()
if data then
local item_id = item_id(data.name)
if item_id then
aux_merchant_sell[item_id] = data.vendor_price / (max_item_charges(item_id) or data.count)
aux.account_data.merchant_sell[item_id] = data.vendor_price / (max_item_charges(item_id) or data.count)
end
end
end)
end
do
local characters = T.empty
local characters = {}
function M.is_player(name)
return not not characters[name]
end
function aux.handle.LOAD2()
characters = aux.realm_data'characters'
function aux.handle.LOAD()
characters = aux.realm_data.characters
for k, v in characters do
if GetTime() > v + 60 * 60 * 24 * 30 then
characters[k] = nil
@@ -92,14 +86,14 @@ end
function M.merchant_info(item_id)
local buy_info
if aux_merchant_buy[item_id] then
buy_info = persistence.read(merchant_buy_schema, aux_merchant_buy[item_id])
if aux.account_data.merchant_buy[item_id] then
buy_info = persistence.read(merchant_buy_schema, aux.account_data.merchant_buy[item_id])
end
return aux_merchant_sell[item_id], buy_info and buy_info.unit_price, buy_info and buy_info.limited
return aux.account_data.merchant_sell[item_id], buy_info and buy_info.unit_price, buy_info and buy_info.limited
end
function M.item_info(item_id)
local data_string = aux_items[item_id]
local data_string = aux.account_data.items[item_id]
if data_string then
local cached_data = persistence.read(items_schema, data_string)
return T.map(
@@ -117,7 +111,7 @@ function M.item_info(item_id)
end
function M.item_id(item_name)
return aux_item_ids[strlower(item_name)]
return aux.account_data.item_ids[strlower(item_name)]
end
function merchant_buy_scan()
@@ -128,8 +122,8 @@ function merchant_buy_scan()
if link then
local item_id = parse_link(link)
local new_unit_price, new_limited = price / count, stock >= 0
if aux_merchant_buy[item_id] then
local buy_info = persistence.read(merchant_buy_schema, aux_merchant_buy[item_id])
if aux.account_data.merchant_buy[item_id] then
local buy_info = persistence.read(merchant_buy_schema, aux.account_data.merchant_buy[item_id])
local unit_price
if buy_info.limited and not new_limited then
@@ -140,12 +134,12 @@ function merchant_buy_scan()
unit_price = min(buy_info.unit_price, new_unit_price)
end
aux_merchant_buy[item_id] = persistence.write(merchant_buy_schema, T.temp-T.map(
aux.account_data.merchant_buy[item_id] = persistence.write(merchant_buy_schema, T.temp-T.map(
'unit_price', unit_price,
'limited', buy_info.limited and new_limited
))
else
aux_merchant_buy[item_id] = persistence.write(merchant_buy_schema, T.temp-T.map(
aux.account_data.merchant_buy[item_id] = persistence.write(merchant_buy_schema, T.temp-T.map(
'unit_price', new_unit_price,
'limited', new_limited
))
@@ -163,7 +157,7 @@ function merchant_sell_scan()
T.temp(slot)
local item_info = T.temp-container_item(unpack(slot))
if item_info then
aux_merchant_sell[item_info.item_id] = item_info.tooltip_money / item_info.aux_quantity
aux.account_data.merchant_sell[item_info.item_id] = item_info.tooltip_money / item_info.aux_quantity
end
end
end
@@ -175,9 +169,9 @@ function scan_wdb(item_id)
while processed <= 100 and item_id <= MAX_ITEM_ID do
local itemstring = 'item:' .. item_id
local name, _, quality, level, class, subclass, max_stack, slot, texture = GetItemInfo(itemstring)
if name and not aux_item_ids[strlower(name)] then
aux_item_ids[strlower(name)] = item_id
aux_items[item_id] = persistence.write(items_schema, T.temp-T.map(
if name and not aux.account_data.item_ids[strlower(name)] then
aux.account_data.item_ids[strlower(name)] = item_id
aux.account_data.items[item_id] = persistence.write(items_schema, T.temp-T.map(
'name', name,
'quality', quality,
'level', level,
@@ -189,7 +183,7 @@ function scan_wdb(item_id)
))
local tooltip = tooltip('link', itemstring)
if auctionable(tooltip, quality) then
tinsert(aux_auctionable_items, strlower(name))
tinsert(aux.account_data.auctionable_items, strlower(name))
end
processed = processed + 1
end
@@ -199,7 +193,7 @@ function scan_wdb(item_id)
if item_id <= MAX_ITEM_ID then
aux.thread(aux.when, aux.later(.5), scan_wdb, item_id)
else
sort(aux_auctionable_items, function(a, b) return strlen(a) < strlen(b) or (strlen(a) == strlen(b) and a < b) end)
sort(aux.account_data.auctionable_items, function(a, b) return strlen(a) < strlen(b) or (strlen(a) == strlen(b) and a < b) end)
end
end
+1 -1
View File
@@ -8,7 +8,7 @@ local history = require 'aux.core.history'
local search_tab = require 'aux.tabs.search'
function aux.handle.LOAD()
if not aux_crafting_cost then
if not aux.account_data.crafting_cost then
return
end
aux.event_listener('ADDON_LOADED', function()
+1 -1
View File
@@ -10,7 +10,7 @@ local history_schema = {'tuple', '#', {next_push='number'}, {daily_min_buyout='n
local value_cache = {}
function aux.handle.LOAD2()
data = aux.faction_data'history'
data = aux.faction_data.history
end
do
+2 -2
View File
@@ -139,7 +139,7 @@ function scan_page(i)
end
local auction_info = info.auction(i, get_state().params.type)
if auction_info and (auction_info.owner or get_state().params.ignore_owner or aux_ignore_owner) then
if auction_info and (auction_info.owner or get_state().params.ignore_owner or aux.account_data.ignore_owner) then
auction_info.index = i
auction_info.page = get_state().page
auction_info.blizzard_query = get_query().blizzard_query
@@ -198,7 +198,7 @@ function wait_for_list_results()
updated = true
end)
local timeout = aux.later(5, get_state().last_list_query)
local ignore_owner = get_state().params.ignore_owner or aux_ignore_owner
local ignore_owner = get_state().params.ignore_owner or aux.account_data.ignore_owner
return aux.when(function()
if not last_update and timeout() then
return true
+22 -23
View File
@@ -1,14 +1,9 @@
module 'aux.core.slash'
local T = require 'T'
local aux = require 'aux'
local info = require 'aux.util.info'
function aux.handle.LOAD2()
tooltip_settings = aux.character_data'tooltip'
end
_G.aux_ignore_owner = true
_G.aux_crafting_cost = true
local post = require 'aux.tabs.post'
function status(enabled)
return (enabled and aux.color.green'on' or aux.color.red'off')
@@ -18,20 +13,23 @@ _G.SLASH_AUX1 = '/aux'
function SlashCmdList.AUX(command)
if not command then return end
local arguments = aux.tokenize(command)
local tooltip_settings = aux.character_data.tooltip
if arguments[1] == 'scale' and tonumber(arguments[2]) then
local scale = tonumber(arguments[2])
aux.frame:SetScale(scale)
_G.aux_scale = scale
aux.account_data.scale = scale
elseif arguments[1] == 'ignore' and arguments[2] == 'owner' then
_G.aux_ignore_owner = not aux_ignore_owner
aux.print('ignore owner ' .. status(aux_ignore_owner))
aux.account_data.ignore_owner = not aux.account_data.ignore_owner
aux.print('ignore owner ' .. status(aux.account_data.ignore_owner))
elseif arguments[1] == 'post' and arguments[2] == 'bid' then
_G.aux_post_bid = not aux_post_bid
aux.print('post bid ' .. status(aux_post_bid))
elseif arguments[1] == 'crafting' and arguments[2] == 'cost' then
_G.aux_crafting_cost = not aux_crafting_cost
aux.print('crafting cost ' .. status(aux_crafting_cost))
aux.account_data.post_bid = not aux.account_data.post_bid
aux.print('post bid ' .. status(aux.account_data.post_bid))
elseif arguments[1] == 'post' and arguments[2] == 'duration' and T.map('2', post.DURATION_2, '8', post.DURATION_8, '24', post.DURATION_24)[arguments[3]] then
aux.account_data.post_duration = T.map('2', post.DURATION_2, '8', post.DURATION_8, '24', post.DURATION_24)[arguments[3]]
aux.print('post duration ' .. aux.color.blue(aux.account_data.post_duration / 60 .. 'h'))
elseif arguments[1] == 'crafting' and arguments[2] == 'cost' then
aux.account_data.crafting_cost = not aux.account_data.crafting_cost
aux.print('crafting cost ' .. status(aux.account_data.crafting_cost))
elseif arguments[1] == 'tooltip' and arguments[2] == 'value' then
tooltip_settings.value = not tooltip_settings.value
aux.print('tooltip value ' .. status(tooltip_settings.value))
@@ -51,18 +49,19 @@ function SlashCmdList.AUX(command)
tooltip_settings.disenchant_distribution = not tooltip_settings.disenchant_distribution
aux.print('tooltip disenchant distribution ' .. status(tooltip_settings.disenchant_distribution))
elseif arguments[1] == 'clear' and arguments[2] == 'item' and arguments[3] == 'cache' then
_G.aux_items = {}
_G.aux_item_ids = {}
_G.aux_auctionable_items = {}
aux.account_data.items = {}
aux.account_data.item_ids = {}
aux.account_data.auctionable_items = {}
aux.print('Item cache cleared.')
elseif arguments[1] == 'populate' and arguments[2] == 'wdb' then
info.populate_wdb()
else
aux.print('Usage:')
aux.print('- scale [' .. aux.color.blue(aux_scale) .. ']')
aux.print('- ignore owner [' .. status(aux_ignore_owner) .. ']')
aux.print('- post bid [' .. status(aux_post_bid) .. ']')
aux.print('- crafting cost [' .. status(aux_crafting_cost) .. ']')
aux.print('- scale [' .. aux.color.blue(aux.account_data.scale) .. ']')
aux.print('- ignore owner [' .. status(aux.account_data.ignore_owner) .. ']')
aux.print('- post bid [' .. status(aux.account_data.post_bid) .. ']')
aux.print('- post duration [' .. aux.color.blue(aux.account_data.post_duration / 60 .. 'h') .. ']')
aux.print('- crafting cost [' .. status(aux.account_data.crafting_cost) .. ']')
aux.print('- tooltip value [' .. status(tooltip_settings.value) .. ']')
aux.print('- tooltip daily [' .. status(tooltip_settings.daily) .. ']')
aux.print('- tooltip merchant buy [' .. status(tooltip_settings.merchant_buy) .. ']')
+1 -1
View File
@@ -13,7 +13,7 @@ local UNKNOWN = GRAY_FONT_COLOR_CODE .. '?' .. FONT_COLOR_CODE_CLOSE
local game_tooltip_hooks, game_tooltip_money = {}, 0
function aux.handle.LOAD()
settings = aux.character_data('tooltip', {value=true})
settings = aux.character_data.tooltip
do
local inside_hook = false
for name, f in game_tooltip_hooks do