forked from Auctionator/Auctionator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
AuctionatorQuery.lua
executable file
·123 lines (90 loc) · 3.1 KB
/
AuctionatorQuery.lua
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
local addonName, addonTable = ...;
local ZT = addonTable.ztt.ZT;
local zc = addonTable.zc;
local zz = zc.md;
local _
AtrQuery = {};
AtrQuery.__index = AtrQuery;
function Atr_NewQuery ()
local query = {};
setmetatable (query, AtrQuery);
query.curPageInfo = nil;
query.prvPageInfo = nil;
query.numDupPages = 0;
_, query.totalAuctions = -1;
return query;
end
-----------------------------------------
--
-- Capture the page info once so we don't have to make multiple calls to the Blizz API
--
function AtrQuery:CapturePageInfo( pagenum )
self.curPageInfo = {}
self.curPageInfo.pagenum = pagenum
self.curPageInfo.auctionInfo = {};
self.curPageInfo.numOnPage, self.totalAuctions = Atr_GetNumAuctionItems("list");
local auctionInfo = {};
local x;
for x = 1, self.curPageInfo.numOnPage do
auctionInfo = {};
auctionInfo.name,
auctionInfo.texture,
auctionInfo.count,
auctionInfo.quality,
auctionInfo.canUse,
auctionInfo.level,
auctionInfo.huh,
auctionInfo.minBid,
auctionInfo.minIncrement,
auctionInfo.buyoutPrice,
auctionInfo.bidAmount,
auctionInfo.highBidder,
auctionInfo.bidderFullName,
auctionInfo.owner,
auctionInfo.ownerFullName = GetAuctionItemInfo("list", x);
auctionInfo.itemLink = GetAuctionItemLink("list", x);
self.curPageInfo.auctionInfo[x] = auctionInfo;
end
end
-----------------------------------------
local function AuctionItemsAreDifferent( item1, item2 )
return item1.name ~= item2.name or
item1.count ~= item2.count or
item1.minBid ~= item2.minBid or
item1.buyoutPrice ~= item2.buyoutPrice or
item1.bidAmount ~= item2.bidAmount
end
-----------------------------------------
function AtrQuery:CheckForDuplicatePage (pagenum)
local x;
local dupPageFound = false;
if (self.prvPageInfo) then
if (self.prvPageInfo.numOnPage == self.curPageInfo.numOnPage) then
local allItemsIdentical = true;
dupPageFound = true;
for x = 1, self.curPageInfo.numOnPage do
if (allItemsIdentical and x > 1 and AuctionItemsAreDifferent (self.curPageInfo.auctionInfo[x], self.curPageInfo.auctionInfo[x-1])) then
allItemsIdentical = false;
end
if (AuctionItemsAreDifferent (self.curPageInfo.auctionInfo[x], self.prvPageInfo.auctionInfo[x])) then
dupPageFound = false
break
end
end
if (allItemsIdentical and dupPageFound) then -- handle those numnuts who post 200 identical auctions
zz ("ALL ITEMS IDENTICAL: ", self.prvPageInfo.pagenum, self.curPageInfo.pagenum);
dupPageFound = false
end
end
end
if (dupPageFound) then
self.numDupPages = self.numDupPages + 1
zz ("DUPLICATE PAGE FOUND: ", self.prvPageInfo.pagenum, self.curPageInfo.pagenum);
end
self.prvPageInfo = {}
zc.CopyDeep (self.prvPageInfo, self.curPageInfo);
return dupPageFound
end
function AtrQuery:IsLastPage (pagenum)
return (((pagenum + 1) * 50) >= self.totalAuctions);
end