refactoring

This commit is contained in:
Manuel Simon Hirsig
2016-08-29 17:24:39 +02:00
parent da07e35976
commit fc347ed4cd
11 changed files with 85 additions and 84 deletions
+1 -1
View File
@@ -182,7 +182,7 @@ function scan_wdb(item_id)
if item_id <= MAX_ITEM_ID then
local t0 = GetTime()
thread(when, function() return GetTime() - t0 > 0.1 end, scan_wdb, item_id)
thread(when, function() return GetTime() - t0 > .1 end, scan_wdb, item_id)
else
sort(_G.aux_auctionable_items, function(a, b) return strlen(a) < strlen(b) or (strlen(a) == strlen(b) and a < b) end)
end
+34 -34
View File
@@ -96,68 +96,68 @@ function public.distribution(slot, quality, level)
if quality == UNCOMMON then
if level <= 10 then
return {
{item_id=10940, min_quantity=1, max_quantity=2, probability=p(0.8, 0.2)},
{item_id=10938, min_quantity=1, max_quantity=2, probability=p(0.2, 0.8)},
{item_id=10940, min_quantity=1, max_quantity=2, probability=p(.8, .2)},
{item_id=10938, min_quantity=1, max_quantity=2, probability=p(.2, .8)},
}
elseif level <= 15 then
return {
{item_id=10940, min_quantity=2, max_quantity=3, probability=p(0.75, 0.2)},
{item_id=10939, min_quantity=1, max_quantity=2, probability=p(0.2, 0.75)},
{item_id=10978, min_quantity=1, max_quantity=1, probability=0.05},
{item_id=10940, min_quantity=2, max_quantity=3, probability=p(.75, .2)},
{item_id=10939, min_quantity=1, max_quantity=2, probability=p(.2, .75)},
{item_id=10978, min_quantity=1, max_quantity=1, probability=.05},
}
elseif level <= 20 then
return {
{item_id=10940, min_quantity=4, max_quantity=6, probability=p(0.75, 0.15)},
{item_id=10998, min_quantity=1, max_quantity=2, probability=p(0.15, 0.75)},
{item_id=10978, min_quantity=1, max_quantity=1, probability=0.10},
{item_id=10940, min_quantity=4, max_quantity=6, probability=p(.75, .15)},
{item_id=10998, min_quantity=1, max_quantity=2, probability=p(.15, .75)},
{item_id=10978, min_quantity=1, max_quantity=1, probability=.10},
}
elseif level <= 25 then
return {
{item_id=11083, min_quantity=1, max_quantity=2, probability=p(0.75, 0.2)},
{item_id=11082, min_quantity=1, max_quantity=2, probability=p(0.2, 0.75)},
{item_id=11084, min_quantity=1, max_quantity=1, probability=0.05},
{item_id=11083, min_quantity=1, max_quantity=2, probability=p(.75, .2)},
{item_id=11082, min_quantity=1, max_quantity=2, probability=p(.2, .75)},
{item_id=11084, min_quantity=1, max_quantity=1, probability=.05},
}
elseif level <= 30 then
return {
{item_id=11083, min_quantity=2, max_quantity=5, probability=p(0.75, 0.2)},
{item_id=11134, min_quantity=1, max_quantity=2, probability=p(0.2, 0.75)},
{item_id=11138, min_quantity=1, max_quantity=1, probability=0.05},
{item_id=11083, min_quantity=2, max_quantity=5, probability=p(.75, .2)},
{item_id=11134, min_quantity=1, max_quantity=2, probability=p(.2, .75)},
{item_id=11138, min_quantity=1, max_quantity=1, probability=.05},
}
elseif level <= 35 then
return {
{item_id=11137, min_quantity=1, max_quantity=2, probability=p(0.75, 0.2)},
{item_id=11135, min_quantity=1, max_quantity=2, probability=p(0.2, 0.75)},
{item_id=11139, min_quantity=1, max_quantity=1, probability=0.05},
{item_id=11137, min_quantity=1, max_quantity=2, probability=p(.75, .2)},
{item_id=11135, min_quantity=1, max_quantity=2, probability=p(.2, .75)},
{item_id=11139, min_quantity=1, max_quantity=1, probability=.05},
}
elseif level <= 40 then
return {
{item_id=11137, min_quantity=2, max_quantity=5, probability=p(0.75, 0.2)},
{item_id=11174, min_quantity=1, max_quantity=2, probability=p(0.2, 0.75)},
{item_id=11177, min_quantity=1, max_quantity=1, probability=0.05},
{item_id=11137, min_quantity=2, max_quantity=5, probability=p(.75, .2)},
{item_id=11174, min_quantity=1, max_quantity=2, probability=p(.2, .75)},
{item_id=11177, min_quantity=1, max_quantity=1, probability=.05},
}
elseif level <= 45 then
return {
{item_id=11176, min_quantity=1, max_quantity=2, probability=p(0.75, 0.2)},
{item_id=11175, min_quantity=1, max_quantity=2, probability=p(0.2, 0.75)},
{item_id=11178, min_quantity=1, max_quantity=1, probability=0.05},
{item_id=11176, min_quantity=1, max_quantity=2, probability=p(.75, .2)},
{item_id=11175, min_quantity=1, max_quantity=2, probability=p(.2, .75)},
{item_id=11178, min_quantity=1, max_quantity=1, probability=.05},
}
elseif level <= 50 then
return {
{item_id=11176, min_quantity=2, max_quantity=5, probability=p(0.75, 0.22)},
{item_id=16202, min_quantity=1, max_quantity=2, probability=p(0.2, 0.75)},
{item_id=14343, min_quantity=1, max_quantity=1, probability=p(0.05, 0.03)},
{item_id=11176, min_quantity=2, max_quantity=5, probability=p(.75, .22)},
{item_id=16202, min_quantity=1, max_quantity=2, probability=p(.2, .75)},
{item_id=14343, min_quantity=1, max_quantity=1, probability=p(.05, .03)},
}
elseif level <= 55 then
return {
{item_id=16204, min_quantity=1, max_quantity=2, probability=p(0.75, 0.22)},
{item_id=16203, min_quantity=1, max_quantity=2, probability=p(0.2, 0.75)},
{item_id=14344, min_quantity=1, max_quantity=1, probability=p(0.05, 0.03)},
{item_id=16204, min_quantity=1, max_quantity=2, probability=p(.75, .22)},
{item_id=16203, min_quantity=1, max_quantity=2, probability=p(.2, .75)},
{item_id=14344, min_quantity=1, max_quantity=1, probability=p(.05, .03)},
}
elseif level <= 60 then
return {
{item_id=16204, min_quantity=2, max_quantity=5, probability=p(0.75, 0.22)},
{item_id=16203, min_quantity=2, max_quantity=3, probability=p(0.2, 0.75)},
{item_id=14344, min_quantity=1, max_quantity=1, probability=p(0.05, 0.03)},
{item_id=16204, min_quantity=2, max_quantity=5, probability=p(.75, .22)},
{item_id=16203, min_quantity=2, max_quantity=3, probability=p(.2, .75)},
{item_id=14344, min_quantity=1, max_quantity=1, probability=p(.05, .03)},
}
end
elseif quality == RARE then
@@ -176,9 +176,9 @@ function public.distribution(slot, quality, level)
elseif level <= 50 then
return {{item_id=14343, min_quantity=1, max_quantity=1, probability=1}}
elseif level <= 55 then
return {{item_id=14344, min_quantity=1, max_quantity=1, probability=0.995}, {item_id=20725, min_quantity=1, max_quantity=1, probability=0.005}}
return {{item_id=14344, min_quantity=1, max_quantity=1, probability=.995}, {item_id=20725, min_quantity=1, max_quantity=1, probability=.005}}
elseif level <= 60 then
return {{item_id=14344, min_quantity=1, max_quantity=1, probability=0.995}, {item_id=20725, min_quantity=1, max_quantity=1, probability=0.005}}
return {{item_id=14344, min_quantity=1, max_quantity=1, probability=.995}, {item_id=20725, min_quantity=1, max_quantity=1, probability=.005}}
end
elseif quality == EPIC then
if level <= 40 then
+31 -31
View File
@@ -55,14 +55,14 @@ end
public.search_config = {
{
title = 'Item',
width = 0.35,
width = .35,
init = item_column_init,
fill = function(cell, record, _, _, _, indented)
cell.icon:SetTexture(record.texture)
if indented then
cell.spacer:SetWidth(10)
cell.icon:SetAlpha(0.5)
cell:GetFontString():SetAlpha(0.7)
cell.icon:SetAlpha(.5)
cell:GetFontString():SetAlpha(.7)
else
cell.spacer:SetWidth(1)
cell.icon:SetAlpha(1)
@@ -76,7 +76,7 @@ public.search_config = {
},
{
title = 'Lvl',
width = 0.035,
width = .035,
align = 'CENTER',
fill = function(cell, record)
local display_level = max(record.level, 1)
@@ -89,7 +89,7 @@ public.search_config = {
},
{
title = 'Auctions',
width = 0.06,
width = .06,
align = 'CENTER',
fill = function(cell, record, count, own, expandable)
local numAuctionsText = expandable and color.link(count) or count
@@ -113,7 +113,7 @@ public.search_config = {
},
{
title = 'Stack Size',
width = 0.055,
width = .055,
align = 'CENTER',
fill = function(cell, record)
cell:SetText(record.aux_quantity)
@@ -124,7 +124,7 @@ public.search_config = {
},
{
title = 'Time Left',
width = 0.04,
width = .04,
align = 'CENTER',
fill = function(cell, record)
cell:SetText(TIME_LEFT_STRINGS[record.duration or 0] or '---')
@@ -135,7 +135,7 @@ public.search_config = {
},
{
title = 'Seller',
width = 0.13,
width = .13,
align = 'CENTER',
fill = function(cell, record)
cell:SetText(is_player(record.owner) and (color.yellow(record.owner)) or (record.owner or '---'))
@@ -154,7 +154,7 @@ public.search_config = {
},
{
title = {'Auction Bid\n(per item)', 'Auction Bid\n(per stack)'},
width = 0.125,
width = .125,
align = 'RIGHT',
isPrice = true,
fill = function(cell, record)
@@ -190,7 +190,7 @@ public.search_config = {
},
{
title = {'Auction Buyout\n(per item)', 'Auction Buyout\n(per stack)'},
width = 0.125,
width = .125,
align = 'RIGHT',
isPrice = true,
fill = function(cell, record)
@@ -208,7 +208,7 @@ public.search_config = {
},
{
title = '% Hist. Value',
width = 0.08,
width = .08,
align = 'CENTER',
fill = function(cell, record)
local pct, bidPct = record_percentage(record)
@@ -225,14 +225,14 @@ public.search_config = {
public.auctions_config = {
{
title = 'Item',
width = 0.35,
width = .35,
init = item_column_init,
fill = function(cell, record, _, _, _, indented)
cell.icon:SetTexture(record.texture)
if indented then
cell.spacer:SetWidth(10)
cell.icon:SetAlpha(0.5)
cell:GetFontString():SetAlpha(0.7)
cell.icon:SetAlpha(.5)
cell:GetFontString():SetAlpha(.7)
else
cell.spacer:SetWidth(1)
cell.icon:SetAlpha(1)
@@ -246,7 +246,7 @@ public.auctions_config = {
},
{
title = 'Lvl',
width = 0.035,
width = .035,
align = 'CENTER',
fill = function(cell, record)
local display_level = max(record.level, 1)
@@ -259,7 +259,7 @@ public.auctions_config = {
},
{
title = 'Auctions',
width = 0.06,
width = .06,
align = 'CENTER',
fill = function(cell, record, count, own, expandable)
local numAuctionsText = expandable and inline_color.link..count..FONT_COLOR_CODE_CLOSE or count
@@ -280,7 +280,7 @@ public.auctions_config = {
},
{
title = 'Stack Size',
width = 0.055,
width = .055,
align = 'CENTER',
fill = function(cell, record)
cell:SetText(record.aux_quantity)
@@ -291,7 +291,7 @@ public.auctions_config = {
},
{
title = 'Time Left',
width = 0.04,
width = .04,
align = 'CENTER',
fill = function(cell, record)
cell:SetText(TIME_LEFT_STRINGS[record.duration or 0] or '---')
@@ -302,7 +302,7 @@ public.auctions_config = {
},
{
title = {'Auction Bid\n(per item)', 'Auction Bid\n(per stack)'},
width = 0.125,
width = .125,
align = 'RIGHT',
isPrice = true,
fill = function(cell, record)
@@ -332,7 +332,7 @@ public.auctions_config = {
},
{
title = {'Auction Buyout\n(per item)', 'Auction Buyout\n(per stack)'},
width = 0.125,
width = .125,
align = 'RIGHT',
isPrice = true,
fill = function(cell, record)
@@ -350,7 +350,7 @@ public.auctions_config = {
},
{
title = 'High Bidder',
width = 0.21,
width = .21,
align = 'CENTER',
fill = function(cell, record)
cell:SetText(record.high_bidder or color.red 'No Bids')
@@ -372,14 +372,14 @@ public.auctions_config = {
public.bids_config = {
{
title = 'Item',
width = 0.35,
width = .35,
init = item_column_init,
fill = function(cell, record, _, _, _, indented)
cell.icon:SetTexture(record.texture)
if indented then
cell.spacer:SetWidth(10)
cell.icon:SetAlpha(0.5)
cell:GetFontString():SetAlpha(0.7)
cell.icon:SetAlpha(.5)
cell:GetFontString():SetAlpha(.7)
else
cell.spacer:SetWidth(1)
cell.icon:SetAlpha(1)
@@ -393,7 +393,7 @@ public.bids_config = {
},
{
title = 'Auctions',
width = 0.06,
width = .06,
align = 'CENTER',
fill = function(cell, record, count, own, expandable)
local numAuctionsText = expandable and inline_color.link..count..FONT_COLOR_CODE_CLOSE or count
@@ -414,7 +414,7 @@ public.bids_config = {
},
{
title = 'Stack Size',
width = 0.055,
width = .055,
align = 'CENTER',
fill = function(cell, record)
cell:SetText(record.aux_quantity)
@@ -425,7 +425,7 @@ public.bids_config = {
},
{
title = 'Time Left',
width = 0.04,
width = .04,
align = 'CENTER',
fill = function(cell, record)
cell:SetText(TIME_LEFT_STRINGS[record.duration or 0] or '---')
@@ -436,7 +436,7 @@ public.bids_config = {
},
{
title = 'Seller',
width = 0.13,
width = .13,
align = 'CENTER',
fill = function(cell, record)
cell:SetText(is_player(record.owner) and (color.yellow(record.owner)) or (record.owner or '---'))
@@ -455,7 +455,7 @@ public.bids_config = {
},
{
title = {'Auction Bid\n(per item)', 'Auction Bid\n(per stack)'},
width = 0.125,
width = .125,
align = 'RIGHT',
isPrice = true,
fill = function(cell, record)
@@ -485,7 +485,7 @@ public.bids_config = {
},
{
title = {'Auction Buyout\n(per item)', 'Auction Buyout\n(per stack)'},
width = 0.125,
width = .125,
align = 'RIGHT',
isPrice = true,
fill = function(cell, record)
@@ -503,7 +503,7 @@ public.bids_config = {
},
{
title = 'Status',
width = 0.115,
width = .115,
align = 'CENTER',
fill = function(cell, record)
local status
+3 -2
View File
@@ -28,7 +28,7 @@ function LOAD()
DropDownList1Backdrop:SetBackdrop{}
aux_border:Show()
aux_background:Show()
DropDownList1:SetWidth(dropdown:GetWidth() * 0.9)
DropDownList1:SetWidth(dropdown:GetWidth() * .9)
DropDownList1:SetHeight(DropDownList1:GetHeight() - 10)
DropDownList1:ClearAllPoints()
DropDownList1:SetPoint('TOPLEFT', dropdown, 'BOTTOMLEFT', -2, -2)
@@ -376,6 +376,7 @@ function public.editbox(parent)
cursor:SetText('|')
cursor:SetTextColor(color.text.enabled())
cursor:SetAlpha(0)
cursor.last_change = 0
editbox.cursor = cursor
editbox:SetAlignment('LEFT')
editbox:SetFontSize(font_size.medium)
@@ -507,7 +508,7 @@ function public.dropdown(parent)
local button = _G[dropdown:GetName()..'Button']
button:ClearAllPoints()
button:SetScale(0.9)
button:SetScale(.9)
button:SetPoint('RIGHT', dropdown, 0, 0)
dropdown.button = button
+1 -1
View File
@@ -79,7 +79,7 @@ function public.create(parent, on_click, selected)
end)
row.item = gui.item(row)
row.item:SetScale(0.9)
row.item:SetScale(.9)
row.item:SetPoint('LEFT', 2.5, 0)
row.item:SetPoint('RIGHT', -2.5, 0)
row.item.button:SetScript('OnEnter', function()
+2 -2
View File
@@ -314,8 +314,8 @@ local methods = {
local tex = col:CreateTexture()
tex:SetAllPoints()
tex:SetTexture([[Interface\Buttons\UI-Listbox-Highlight]])
tex:SetTexCoord(0.025, 0.957, 0.087, 0.931)
tex:SetAlpha(0.2)
tex:SetTexCoord(.025, .957, .087, .931)
tex:SetAlpha(.2)
col:SetHighlightTexture(tex)
tinsert(st.headCols, col)
+1 -1
View File
@@ -303,7 +303,7 @@ function update_item_configuration()
stack_count_slider.editbox:SetNumber(stack_count_slider:GetValue())
do
local deposit_factor = neutral_faction() and 0.25 or 0.05
local deposit_factor = neutral_faction() and .25 or .05
local stack_size, stack_count = stack_size_slider:GetValue(), stack_count_slider:GetValue()
local amount = floor(selected_item.unit_vendor_price * deposit_factor * (selected_item.max_charges and 1 or stack_size)) * stack_count * UIDropDownMenu_GetSelectedValue(duration_dropdown) / 120
deposit:SetText('Deposit: '..aux.money.to_string(amount, nil, nil, nil, inline_color.text.enabled))
+6 -6
View File
@@ -92,7 +92,7 @@ function update_form()
usable_checkbox:Enable()
end
if any(values('min_level', 'max_level', 'usable', 'class', 'subclass', 'slot', 'quality'), function(key) return blizzard_query[key] end) then
if any(list('min_level', 'max_level', 'usable', 'class', 'subclass', 'slot', 'quality'), function(key) return blizzard_query[key] end) then
exact_checkbox:Disable()
else
exact_checkbox:Enable()
@@ -120,10 +120,10 @@ function get_filter_builder_query()
add(blizzard_query.usable and 'usable')
for class in present(blizzard_query.class) do
local classes = temp-{GetAuctionItemClasses()}
local classes = temp-list(GetAuctionItemClasses())
add(strlower(classes[class]))
for subclass in present(blizzard_query.subclass) do
local subclasses = temp-{GetAuctionItemSubClasses(class)}
local subclasses = temp-list(GetAuctionItemSubClasses(class))
add(strlower(subclasses[subclass]))
add(blizzard_query.slot and strlower(_G[blizzard_query.slot]))
end
@@ -206,9 +206,9 @@ function public.formatted_post_filter(components)
elseif component[1] == 'filter' then
for parameter in present(component[3]) do
if component[2] == 'item' then
parameter = info.display_name(cache.item_id(parameter)) or '['..parameter..']'
parameter = aux.info.display_name(aux.cache.item_id(parameter)) or '['..parameter..']'
elseif filter_util.filters[component[2]].input_type == 'money' then
parameter = money.to_string(money.from_string(parameter), nil, true)
parameter = aux.money.to_string(aux.money.from_string(parameter), nil, true)
end
component_text = component_text..filter_color(': ')..parameter
end
@@ -344,7 +344,7 @@ function initialize_class_dropdown()
end
end
UIDropDownMenu_AddButton(T('text', ALL, 'value', 0, 'func', on_click))
for i, class in temp-{GetAuctionItemClasses()} do
for i, class in temp-list(GetAuctionItemClasses()) do
UIDropDownMenu_AddButton(T('text', class, 'value', i, 'func', on_click))
end
end
+1 -1
View File
@@ -233,7 +233,7 @@ function public.bounded(lower_bound, upper_bound, number)
return max(lower_bound, min(upper_bound, number))
end
function public.round(x) return floor(x + 0.5) end
function public.round(x) return floor(x + .5) end
function public.later(t0, t)
return function() return GetTime() - t0 > t end
+4 -4
View File
@@ -264,7 +264,7 @@ end
function parse_parameter(input_type, str)
if input_type == 'money' then
local money = money.from_string(str)
local money = aux.money.from_string(str)
return money and money > 0 and money or nil
elseif input_type == 'number' then
local number = tonumber(str)
@@ -426,8 +426,8 @@ function public.query_string(components)
elseif component[1] == 'filter' then
query_builder.append(component[2])
for parameter in present(component[3]) do
if filter.filters[component[2]].input_type == 'money' then
parameter = money.to_string(money.from_string(parameter), nil, true, nil, nil, true)
if aux.filter_util.filters[component[2]].input_type == 'money' then
parameter = aux.money.to_string(aux.money.from_string(parameter), nil, true, nil, nil, true)
end
query_builder.append(parameter)
end
@@ -464,7 +464,7 @@ function prettified_query_string(components)
prettified.append(info.display_name(aux.cache.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, nil, gui.inline_color.label.enabled))
prettified.append(aux.money.to_string(aux.money.from_string(parameter), nil, true, nil, gui.inline_color.label.enabled))
else
prettified.append(color.label.enabled(parameter))
end
+1 -1
View File
@@ -32,7 +32,7 @@ function public.to_string2(money, exact, color)
if not exact and money >= 10000 then
-- Round to nearest silver
money = floor(money / 100 + 0.5) * 100
money = floor(money / 100 + .5) * 100
end
local g, s, c = to_gsc(money)