-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProcessMatch.lua
More file actions
90 lines (74 loc) · 3.15 KB
/
Copy pathProcessMatch.lua
File metadata and controls
90 lines (74 loc) · 3.15 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
--=================================================================================================
--= Process match
--= ===============================================================================================
--= process a match from chat parsing
--=================================================================================================
import "LootLogsBeta.Utils.Functions"
-- process match ----------------------------------------------------------------------------------
function ProcessMatch(message, log, logIndex)
local logs = _G.Logs[_G.characterId].logs
local newEntry = nil
-- mark as done
if log.type == _G.EventTypes.Done then
local tod = _G.CalculateDeath(log)
if tod == nil then return end
newEntry = { value = "Done", timeOfDeath = tod }
-- quest / progress tracker: extract (X/Y) from message
elseif log.type == _G.EventTypes.ExtractValue then
local progress = string.match(message, "%((%d+/%d+)%)")
or string.match(message, "%.(%d+/%d+)%.")
local value
if progress then
local a, b = string.match(progress, "(%d+)/(%d+)")
value = (a == b) and "Done" or progress
else
value = "Done"
end
-- don't overwrite a "Done" entry with partial progress
if logs[logIndex] == nil or logs[logIndex].value ~= "Done" or value == "Done" then
local tod = _G.CalculateDeath(log)
if tod == nil then return end
newEntry = { value = value, timeOfDeath = tod }
end
-- instance chest with favoured / common / locked states
elseif log.type == _G.EventTypes.Completions then
local favCount = string.match(message, ": You have (%d+) favoured completion")
local comCount = not favCount and string.match(message, ": You have (%d+) completion")
local isReset = not favCount and not comCount and string.find(message, "resets in: ")
local value
if favCount then
value = favCount .. "f"
elseif comCount then
value = comCount .. "c"
elseif isReset then
value = "Locked"
end
if value then
local tod = _G.CalculateDeath(log)
if tod == nil then return end
newEntry = { value = value, timeOfDeath = tod }
end
end
if newEntry then
logs[logIndex] = newEntry
end
SaveLogs()
if newEntry then
local event = _G.Events[logIndex]
local instance = _G.Instances[event.instance]
local remaining = newEntry.timeOfDeath - Turbine.Engine.GetLocalTime()
_G.PrintAlert(
_G.CM("HOVER") .. "[" .. (instance and instance.name or "?") .. "]" .. _G.CMR ..
" " .. event.name ..
" " .. _G.CM("DIM") .. "(" .. event.tier .. ")" .. _G.CMR ..
" " .. newEntry.value ..
" " .. _G.CM("ACCENT") .. _G.FormatTimeSpan(remaining) .. _G.CMR
)
end
if _G.QuickLaunchBtn then
_G.QuickLaunchBtn:IncrementBadge()
end
if _G.Window and _G.Window.contentView then
_G.Window.contentView:UpdateContent()
end
end