refactoring

This commit is contained in:
Manuel Simon Hirsig
2016-11-06 14:58:06 +01:00
parent efbae0d433
commit 923aa5794b
22 changed files with 130 additions and 132 deletions
+2 -4
View File
@@ -9,10 +9,8 @@ local persistence = require 'aux.util.persistence'
local MIN_ITEM_ID = 1
local MAX_ITEM_ID = 30000
--items_schema = record '#' {name='string'} {quality='number'} {level='number'} {class='string'} {subclass='string'} {slot='string'} {max_stack='number'} {texture='string'} -- TODO
local items_schema = {'record', '#', {name='string'}, {quality='number'}, {level='number'}, {class='string'}, {subclass='string'}, {slot='string'}, {max_stack='number'}, {texture='string'}}
local merchant_buy_schema = {'record', '#', {unit_price='number'}, {limited='boolean'}}
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 = t
_G.aux_item_ids = t
+1 -1
View File
@@ -5,7 +5,7 @@ include 'aux'
local persistence = require 'aux.util.persistence'
local history_schema = {'record', '#', {next_push='number'}, {daily_min_buyout='number'}, {daily_max_price='number'}, {data_points={'list', ';', {'record', '@', {market_value='number'}, {time='number'}}}} }
local history_schema = {'tuple', '#', {next_push='number'}, {daily_min_buyout='number'}, {daily_max_price='number'}, {data_points={'list', ';', {'tuple', '@', {market_value='number'}, {time='number'}}}}}
local value_cache = t
+11 -11
View File
@@ -9,29 +9,29 @@ local cache = require 'aux.core.cache'
_G.aux_ignore_owner = true
_G.SLASH_AUX1 = '/aux'
function _G.SlashCmdList.AUX(command)
function SlashCmdList.AUX(command)
if not command then return end
local arguments = tokenize(command)
if arguments[1] == 'clear' and arguments[2] == 'history' then
persistence.dataset = nil
print'History cleared.'
persistence.dataset.history = nil
print('History cleared.')
elseif arguments[1] == 'clear' and arguments[2] == 'post' then
persistence.dataset.post = nil
print'Post settings cleared.'
print('Post settings cleared.')
elseif arguments[1] == 'clear' and arguments[2] == 'datasets' then
_G.aux_datasets = t
print'Datasets cleared.'
print('Datasets cleared.')
elseif arguments[1] == 'clear' and arguments[2] == 'merchant' and arguments[3] == 'buy' then
_G.aux_merchant_buy = t
print'Merchant buy prices cleared.'
print('Merchant buy prices cleared.')
elseif arguments[1] == 'clear' and arguments[2] == 'merchant' and arguments[3] == 'sell' then
_G.aux_merchant_sell = t
print'Merchant sell prices cleared.'
print('Merchant sell prices cleared.')
elseif arguments[1] == 'clear' and arguments[2] == 'item' and arguments[3] == 'cache' then
_G.aux_items = t
_G.aux_item_ids = t
_G.aux_auctionable_items = t
print'Item cache cleared.'
print('Item cache cleared.')
elseif arguments[1] == 'populate' and arguments[2] == 'wdb' then
cache.populate_wdb()
elseif arguments[1] == 'tooltip' and arguments[2] == 'value' then
@@ -59,7 +59,7 @@ function _G.SlashCmdList.AUX(command)
_G.aux_ignore_owner = not aux_ignore_owner
print('Ignoring of owner ' .. (aux_ignore_owner and 'enabled' or 'disabled') .. '.')
elseif arguments[1] == 'chars' and arguments[2] == 'add' then
local realm = GetCVar('realmName')
local realm = GetCVar'realmName'
aux_characters[realm] = aux_characters[realm] or t
for i = 3, getn(arguments) do
local name = gsub(strlower(arguments[i]), '^%l', strupper)
@@ -69,7 +69,7 @@ function _G.SlashCmdList.AUX(command)
end
end
elseif arguments[1] == 'chars' and arguments[2] == 'remove' then
local realm = GetCVar('realmName')
local realm = GetCVar'realmName'
if not aux_characters[realm] then
return
end
@@ -81,7 +81,7 @@ function _G.SlashCmdList.AUX(command)
end
end
elseif arguments[1] == 'chars' then
local realm = GetCVar('realmName')
local realm = GetCVar'realmName'
local chars = t
for name in aux_characters[realm] or t do
tinsert(chars, name)
+6 -6
View File
@@ -54,7 +54,7 @@ function extend_tooltip(tooltip, link, quantity)
local item_id, suffix_id = info.parse_link(link)
quantity = IsShiftKeyDown() and quantity or 1
if aux_tooltip_disenchant_source then
local color = { r=.7, g=.7, b=.7 }
local color = {r=.7, g=.7, b=.7}
local type, range = disenchant.source(item_id)
if type == 'CRYSTAL' then
tooltip:AddLine(format('Can disenchant from level %s |cffa335eeEpic|r and |cff0070ddRare|r items.', range), color.r, color.g, color.b, true)
@@ -71,7 +71,7 @@ function extend_tooltip(tooltip, link, quantity)
local distribution = disenchant.distribution(item_info.slot, item_info.quality, item_info.level)
if getn(distribution) > 0 then
if aux_tooltip_disenchant_distribution then
local color = { r=.8, g=.8, b=.2 }
local color = {r=.8, g=.8, b=.2}
tooltip:AddLine('Disenchants into:', color.r, color.g, color.b)
sort(distribution, function(a,b) return a.probability > b.probability end)
@@ -80,7 +80,7 @@ function extend_tooltip(tooltip, link, quantity)
end
end
if aux_tooltip_disenchant_value then
local color = { r=.1, g=.6, b=.6 }
local color = {r=.1, g=.6, b=.6}
local disenchant_value = disenchant.value(item_info.slot, item_info.quality, item_info.level)
tooltip:AddLine('Disenchant Value: ' .. (disenchant_value and money.to_string2(disenchant_value) or GRAY_FONT_COLOR_CODE .. '---' .. FONT_COLOR_CODE_CLOSE), color.r, color.g, color.b)
@@ -88,20 +88,20 @@ function extend_tooltip(tooltip, link, quantity)
end
end
if aux_tooltip_vendor_buy then
local color = { r=.8, g=.5, b=.1 }
local color = {r=.8, g=.5, b=.1}
local _, price, limited = cache.merchant_info(item_id)
if price then
tooltip:AddLine('Vendor Buy ' .. (limited and '(limited): ' or ': ') .. money.to_string2(price * quantity), color.r, color.g, color.b)
end
end
if aux_tooltip_vendor_sell then
local color = { r=.8, g=.5, b=.1 }
local color = {r=.8, g=.5, b=.1}
local price = cache.merchant_info(item_id)
if price ~= 0 then
tooltip:AddLine('Vendor Sell: ' .. (price and money.to_string2(price * quantity) or GRAY_FONT_COLOR_CODE .. '---' .. FONT_COLOR_CODE_CLOSE), color.r, color.g, color.b)
end
end
local color = { r=1, g=1, b=.6 }
local color = {r=1, g=1, b=.6}
local auctionable = not item_info or info.auctionable(info.tooltip(function(tooltip) tooltip:SetHyperlink(item_info.itemstring) end), item_info.quality)
local item_key = (item_id or 0) .. ':' .. (suffix_id or 0)
local value = history.value(item_key)