87 lines
2.2 KiB
Lua
87 lines
2.2 KiB
Lua
aura_env.me = UnitName("player")
|
|
aura_env.reading = false
|
|
aura_env.fullMessage = {}
|
|
aura_env.displayString = ""
|
|
|
|
if not WeakAurasSaved.Cyka then WeakAurasSaved.Cyka = {} end
|
|
if not WeakAurasSaved.Cyka.MData then WeakAurasSaved.Cyka.MData = {} end
|
|
|
|
---@class Key
|
|
---@field name string
|
|
---@field role string
|
|
---@field level string
|
|
---@field time string
|
|
---@field score string
|
|
Key = {
|
|
---@return Key
|
|
---@param name string
|
|
---@param role string
|
|
---@param level string
|
|
---@param time string
|
|
---@param score string
|
|
new = function(name, role, level, time, score)
|
|
local self = setmetatable({}, {
|
|
__index = Key,
|
|
__tostring = function(self)
|
|
return string.format("%-30s %-8s %-8s %-10s %-10s", self.name, self.role, self.level, self.time, self.score)
|
|
end,
|
|
})
|
|
self.name = name
|
|
self.role = role
|
|
self.level = level
|
|
self.time = time
|
|
self.score = score
|
|
return self
|
|
end,
|
|
---@return string
|
|
hash = function(self)
|
|
return table.concat({ self.name, self.role, self.level, self.time, self.score }, "/")
|
|
end,
|
|
|
|
---@param self Key
|
|
---@param other Key
|
|
---@return boolean
|
|
compareTo = function(self, other)
|
|
if not self then return true end
|
|
if not other then return false end
|
|
if self.name <= other.name then
|
|
return true
|
|
end
|
|
return false
|
|
end
|
|
}
|
|
|
|
---@param keys Key[]
|
|
local function render(keys)
|
|
local str = {}
|
|
for k, v in ipairs(keys) do
|
|
str[#str + 1] = tostring(v)
|
|
end
|
|
aura_env.displayString = table.concat(str, "\n")
|
|
end
|
|
|
|
function aura_env.Process()
|
|
---@type Key[]
|
|
local keys = {}
|
|
for k, msg in ipairs(aura_env.fullMessage) do
|
|
local key, role, level, time, score = string.match(msg, "^->([^/]+)/([^/]+)/([^/]+)/([^/]+)/(.+)$")
|
|
|
|
key = string.gsub(key, "^%s+", "")
|
|
key = string.gsub(key, "%s+$", "")
|
|
role = string.gsub(role, "%s+", "")
|
|
level = string.gsub(level, "%s+", "")
|
|
time = string.gsub(time, "%s+", "")
|
|
score = string.gsub(score, "%s+", "")
|
|
|
|
local keyObj = Key.new(key, role, level, time, score)
|
|
if key then
|
|
keys[#keys + 1] = keyObj
|
|
end
|
|
WeakAurasSaved.Cyka.MData[keyObj:hash()] = keyObj
|
|
end
|
|
table.sort(keys, Key.compareTo)
|
|
render(keys)
|
|
end
|
|
|
|
-- /run WeakAurasSaved.Cyka.MData = {}
|