refactoring
This commit is contained in:
+4
-4
@@ -77,7 +77,7 @@ function merchant_loaded()
|
||||
return true
|
||||
end
|
||||
|
||||
function public.merchant_info(item_id)
|
||||
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])
|
||||
@@ -85,7 +85,7 @@ function public.merchant_info(item_id)
|
||||
return aux_merchant_sell[item_id], buy_info and buy_info.unit_price, buy_info and buy_info.limited
|
||||
end
|
||||
|
||||
function public.item_info(item_id)
|
||||
function M.item_info(item_id)
|
||||
local data_string = aux_items[item_id]
|
||||
if data_string then
|
||||
local cached_data = persistence.read(items_schema, data_string)
|
||||
@@ -103,7 +103,7 @@ function public.item_info(item_id)
|
||||
end
|
||||
end
|
||||
|
||||
function public.item_id(item_name)
|
||||
function M.item_id(item_name)
|
||||
return aux_item_ids[strlower(item_name)]
|
||||
end
|
||||
|
||||
@@ -189,7 +189,7 @@ function scan_wdb(item_id)
|
||||
end
|
||||
end
|
||||
|
||||
function public.populate_wdb(item_id)
|
||||
function M.populate_wdb(item_id)
|
||||
item_id = item_id or MIN_ITEM_ID
|
||||
if item_id > MAX_ITEM_ID then
|
||||
print'Cache populated.'
|
||||
|
||||
+3
-3
@@ -38,7 +38,7 @@ do
|
||||
20725, A('CRYSTAL', '51+')
|
||||
)
|
||||
|
||||
function public.source(item_id)
|
||||
function M.source(item_id)
|
||||
return unpack(data[item_id] or empty)
|
||||
end
|
||||
end
|
||||
@@ -71,7 +71,7 @@ local WEAPON = S(
|
||||
'INVTYPE_RANGEDRIGHT'
|
||||
)
|
||||
|
||||
function public.value(slot, quality, level)
|
||||
function M.value(slot, quality, level)
|
||||
local expectation
|
||||
for _, event in distribution(slot, quality, level) do
|
||||
local value = history.value(event.item_id .. ':' .. 0)
|
||||
@@ -84,7 +84,7 @@ function public.value(slot, quality, level)
|
||||
return expectation
|
||||
end
|
||||
|
||||
function public.distribution(slot, quality, level)
|
||||
function M.distribution(slot, quality, level)
|
||||
if not ARMOR[slot] and not WEAPON[slot] or level == 0 then
|
||||
return t
|
||||
end
|
||||
|
||||
+4
-4
@@ -51,7 +51,7 @@ function write_record(item_key, record)
|
||||
data[item_key] = persistence.write(history_schema, record)
|
||||
end
|
||||
|
||||
function public.process_auction(auction_record)
|
||||
function M.process_auction(auction_record)
|
||||
local item_record = 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)
|
||||
@@ -69,12 +69,12 @@ function public.process_auction(auction_record)
|
||||
write_record(auction_record.item_key, item_record)
|
||||
end
|
||||
|
||||
function public.price_data(item_key)
|
||||
function M.price_data(item_key)
|
||||
local item_record = 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)
|
||||
function M.value(item_key)
|
||||
if not value_cache[item_key] or value_cache[item_key].next_push <= time() then
|
||||
local item_record, value
|
||||
item_record = read_record(item_key)
|
||||
@@ -97,7 +97,7 @@ function public.value(item_key)
|
||||
return value_cache[item_key].value
|
||||
end
|
||||
|
||||
function public.market_value(item_key)
|
||||
function M.market_value(item_key)
|
||||
return calculate_market_value(read_record(item_key))
|
||||
end
|
||||
|
||||
|
||||
+2
-2
@@ -60,7 +60,7 @@ function post_auction(slot, k)
|
||||
end
|
||||
end
|
||||
|
||||
function public.stop()
|
||||
function M.stop()
|
||||
if state then
|
||||
kill_thread(state.thread_id)
|
||||
|
||||
@@ -75,7 +75,7 @@ function public.stop()
|
||||
end
|
||||
end
|
||||
|
||||
function public.start(item_key, stack_size, duration, unit_start_price, unit_buyout_price, count, callback)
|
||||
function M.start(item_key, stack_size, duration, unit_start_price, unit_buyout_price, count, callback)
|
||||
stop()
|
||||
state = {
|
||||
thread_id = thread(process),
|
||||
|
||||
+2
-2
@@ -11,7 +11,7 @@ local PAGE_SIZE = 50
|
||||
do
|
||||
local scan_states = t
|
||||
|
||||
function public.start(params)
|
||||
function M.start(params)
|
||||
for old_state in present(scan_states[params.type]) do
|
||||
abort(old_state.id)
|
||||
end
|
||||
@@ -23,7 +23,7 @@ do
|
||||
return thread_id
|
||||
end
|
||||
|
||||
function public.abort(scan_id)
|
||||
function M.abort(scan_id)
|
||||
local aborted = t
|
||||
for type, state in scan_states do
|
||||
if not scan_id or state.id == scan_id then
|
||||
|
||||
+2
-2
@@ -106,7 +106,7 @@ function process()
|
||||
return stop()
|
||||
end
|
||||
|
||||
function public.stop()
|
||||
function M.stop()
|
||||
if state then
|
||||
kill_thread(state.thread_id)
|
||||
local callback, slot = state.callback, state.target_slot
|
||||
@@ -116,7 +116,7 @@ function public.stop()
|
||||
end
|
||||
end
|
||||
|
||||
function public.start(item_key, size, callback)
|
||||
function M.start(item_key, size, callback)
|
||||
stop()
|
||||
state = {
|
||||
thread_id = thread(process),
|
||||
|
||||
Reference in New Issue
Block a user