-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathData.lua
More file actions
72 lines (60 loc) · 2.06 KB
/
Data.lua
File metadata and controls
72 lines (60 loc) · 2.06 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
--------------------------------------------------------------------------------
-- BadPet @project-version@
-- File: Data.lua
-- Author: @project-author@
-- License: LICENSE.txt
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
-- History tracking, used to suppress noisy warnings
--------------------------------------------------------------------------------
--- Get or create a spell history table
local function SpellHistory(history, spell)
if type(spell) == "table" then
return history[spell.id];
else
local spellTable = { time = 0, count = 0 }
history[spell] = spellTable;
return spellTable;
end
end
local SpellHistoryMeta = { __index = SpellHistory };
--- Get or create a pet history table
local function PetHistory(history, pet)
if type(pet) == "table" then
return history[pet.id];
else
local spellTable = setmetatable({}, SpellHistoryMeta);
history[pet] = spellTable;
return spellTable;
end
end
local PetHistoryMeta = { __index = PetHistory };
local function NewHistory()
return setmetatable({ reset = date() }, PetHistoryMeta);
end
BadPet.history = NewHistory();
--------------------------------------------------------------------------------
-- Report Queue, used to synchronize sending reports to prevent duplicates
--------------------------------------------------------------------------------
local function SpellQueue(queue, spell)
if type(spell) == "table" then
return queue(spell.id)
else
return nil;
end
end
local SpellQueueMeta = { __index = SpellQueue };
local function PetQueue(queue, pet)
if type(pet) == "table" then
return queue[pet.id];
else
local spellTable = setmetatable({}, SpellQueueMeta);
queue[pet] = spellTable;
return spellTable;
end
end
local PetQueueMeta = { __index = PetQueue };
local function NewQueue()
return setmetatable({}, PetQueueMeta);
end
BadPet.queue = NewQueue();