-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
ExpTracker.lua
73 lines (65 loc) · 3.26 KB
/
ExpTracker.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
--[[
* Copyright (c) 2011-2020 by Adam Hellberg.
*
* This file is part of KillTrack.
*
* KillTrack is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* KillTrack is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with KillTrack. If not, see <http://www.gnu.org/licenses/>.
--]]
---@class KillTrack
local KT = select(2, ...)
---@class KillTrackExpTracker
local ET = {
---@type string[]
Strings = {
---@diagnostic disable: undefined-field
_G.COMBATLOG_XPGAIN_EXHAUSTION1, -- %s dies, you gain %d experience. (%s exp %s bonus)
_G.COMBATLOG_XPGAIN_EXHAUSTION1_GROUP, -- %s dies, you gain %d experience. (%s exp %s bonus, +%d group bonus)
_G.COMBATLOG_XPGAIN_EXHAUSTION1_RAID, -- %s dies, you gain %d experience. (%s exp %s bonus, -%d raid penalty)
_G.COMBATLOG_XPGAIN_EXHAUSTION2, -- %s dies, you gain %d experience. (%s exp %s bonus)
_G.COMBATLOG_XPGAIN_EXHAUSTION2_GROUP, -- %s dies, you gain %d experience. (%s exp %s bonus, +%d group bonus)
_G.COMBATLOG_XPGAIN_EXHAUSTION2_RAID, -- %s dies, you gain %d experience. (%s exp %s bonus, -%d raid penalty)
_G.COMBATLOG_XPGAIN_EXHAUSTION4, -- %s dies, you gain %d experience. (%s exp %s penalty)
_G.COMBATLOG_XPGAIN_EXHAUSTION4_GROUP, -- %s dies, you gain %d experience. (%s exp %s penalty, +%d group bonus)
_G.COMBATLOG_XPGAIN_EXHAUSTION4_RAID, -- %s dies, you gain %d experience. (%s exp %s penalty, -%d raid penalty)
_G.COMBATLOG_XPGAIN_EXHAUSTION5, -- %s dies, you gain %d experience. (%s exp %s penalty)
_G.COMBATLOG_XPGAIN_EXHAUSTION5_GROUP, -- %s dies, you gain %d experience. (%s exp %s penalty, +%d group bonus)
_G.COMBATLOG_XPGAIN_EXHAUSTION5_RAID, -- %s dies, you gain %d experience. (%s exp %s penalty, -%d raid penalty)
_G.COMBATLOG_XPGAIN_FIRSTPERSON, -- %s dies, you gain %d experience.
_G.COMBATLOG_XPGAIN_FIRSTPERSON_GROUP, -- %s dies, you gain %d experience. (+%d group bonus)
_G.COMBATLOG_XPGAIN_FIRSTPERSON_RAID -- %s dies, you gain %d experience. (-%d raid penalty)
---@diagnostic enable: undefined-field
}
}
KT.ExpTracker = ET
local initialized = false
local function Initialize()
for i = 1, #ET.Strings do
ET.Strings[i] = ET.Strings[i]:gsub("([%(%)])", "%%%1"):gsub("%%%d?$?s", "(.-)"):gsub("%%%d?$?d", "(%%d+)")
end
initialized = true
end
---@param message string
function ET:CheckMessage(message)
if not initialized then Initialize() end
local name, exp
for i = 1, #self.Strings do
local str = self.Strings[i]
name, exp = message:match(str)
if name and exp then break end
end
exp = tonumber(exp)
if type(name) == "string" and name ~= "" and type(exp) == "number" then
KT:SetExp(name, exp)
end
end