forked from TheMouseNest/Auctionator
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAuctionatorDatabase.lua
More file actions
executable file
·89 lines (58 loc) · 2.21 KB
/
AuctionatorDatabase.lua
File metadata and controls
executable file
·89 lines (58 loc) · 2.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
local addonName, addonTable = ...
local ZT = addonTable.ztt.ZT;
local zc = addonTable.zc
local zz = zc.md
local _
-----------------------------------------
AtrDB = {};
AtrDB.__index = AtrDB;
-----------------------------------------
function Build_itag (itemName, quality)
return itemName.."_"..quality
end
-----------------------------------------
function InitItemIfNeeded (db, itemName, quality)
local itag = Build_itag (itemName, quality)
if (db[itag] == nil) then
db[itag] = {}
end
return itag
end
-----------------------------------------
function AtrDB:SetItemInfo (itemName, quality, itemLink, itemClass, itemSubclass)
local itag = InitItemIfNeeded (self, itemName, quality)
local item_link = Auctionator.ItemLink:new({ item_link = itemLink })
self[itag]["fo"] = item_link:IdString() .. "_" .. itemClass .. "_" .. itemSubclass
end
-----------------------------------------
function AtrDB:UpdateItemPrice (itemName, quality, currentLowPrice)
if (currentLowPrice == nil) then
zz ("currentLowPrice in NIL!!!!!!")
return;
end
if (type(currentLowPrice) ~= "number") then
zz ("currentLowPrice in not a number !!!!!!", type(currentLowPrice))
return;
end
-- if (db == nil) then
-- db = gAtr_ScanDB;
-- end
local itag = InitItemIfNeeded (self, itemName, quality)
-- db[itag].mr = currentLowPrice;
local daysSinceZero = Atr_GetScanDay_Today();
local lowlow = db[itag]["L"..daysSinceZero];
local highlow = db[itag]["H"..daysSinceZero];
local olow = lowlow;
local ohigh = highlow;
if (highlow == nil or currentLowPrice > highlow) then
db[itag]["H"..daysSinceZero] = currentLowPrice;
highlow = currentLowPrice;
end
-- save memory by only saving lowlow when different from highlow
local isLowerThanLow = (lowlow ~= nil and currentLowPrice < lowlow);
local isNewAndDifferent = (lowlow == nil and currentLowPrice < highlow);
if (isLowerThanLow or isNewAndDifferent) then
db[itag]["L"..daysSinceZero] = currentLowPrice;
-- zz (itag, "currentLowPrice:", currentLowPrice, "highlow:", highlow, "lowlow:", lowlow, "ohigh:", ohigh, "olow:", olow);
end
end