From c970cf986dc215ccae646df086c129464893cba5 Mon Sep 17 00:00:00 2001 From: Matthew Plachter Date: Mon, 25 Nov 2019 16:51:28 -0500 Subject: [PATCH 1/4] add condiditon to process chat message only if it was a HK and print message red if it wasn't --- HonorAssistChatMessage.lua | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/HonorAssistChatMessage.lua b/HonorAssistChatMessage.lua index f50bf28..ef2f9a9 100644 --- a/HonorAssistChatMessage.lua +++ b/HonorAssistChatMessage.lua @@ -4,19 +4,24 @@ HonorAssist = addonTable -- This runs after HonorAssistDailyCalculator. That means the kill is already added to that database, so we can use the times killed from that service. -- When calculating realistic honor we need to decrease by 1 to get the real value of the kill. ChatFrame_AddMessageEventFilter("CHAT_MSG_COMBAT_HONOR_GAIN", function(self, event, text, ...) - local estimatedHonorGained = string.match(text, "%d+") - local playerKilled = string.match(text, "^([^%s]+)") - local playerRank = HonorAssist:Trim(string.match(text, "(Rank:.([^(]+))")) - local timesKilled = HonorAssist:GetTotalKillsDailyDatabase(playerKilled) - local percentage, realisticHonor = HonorAssist:CalculateRealisticHonor(timesKilled - 1, estimatedHonorGained) - local timeText = 'times' + if string.match(text, "dies, honorable kill") then + local estimatedHonorGained = string.match(text, "%d+") + local playerKilled = string.match(text, "^([^%s]+)") + local playerRank = HonorAssist:Trim(string.match(text, "(Rank:.([^(]+))")) + local timesKilled = HonorAssist:GetTotalKillsDailyDatabase(playerKilled) + local percentage, realisticHonor = HonorAssist:CalculateRealisticHonor(timesKilled - 1, estimatedHonorGained) + local timeText = 'times' - if timesKilled == 1 then - timeText = 'time' - end + if timesKilled == 1 then + timeText = 'time' + end - text = 'You have killed ' .. playerKilled .. ' (' .. playerRank .. ') ' .. timesKilled .. ' ' .. timeText - .. '. This kill granted ' .. percentage * 100 .. '% value for ' .. realisticHonor .. ' honor ' .. string.match(text, "(%(.+)") .. '.' + text = 'You have killed ' .. playerKilled .. ' (' .. playerRank .. ') ' .. timesKilled .. ' ' .. timeText + .. '. This kill granted ' .. percentage * 100 .. '% value for ' .. realisticHonor .. ' honor ' .. string.match(text, "(%(.+)") .. '.' - return false, text, ... + return false, text, ... + else + dkText = '|cFFFF0000' .. text + return false, dkText, ... + end end) \ No newline at end of file From 2963f7343545d19c872e63a035fba99d95d8418c Mon Sep 17 00:00:00 2001 From: Matthew Plachter Date: Mon, 25 Nov 2019 16:52:05 -0500 Subject: [PATCH 2/4] add check conditions to make sure HK was a HK as well as validate the data is not nil when processing the data --- HonorAssist.lua | 14 ++++++++------ HonorAssistDatabase.lua | 22 ++++++++++++---------- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/HonorAssist.lua b/HonorAssist.lua index cdc6518..719ecb4 100644 --- a/HonorAssist.lua +++ b/HonorAssist.lua @@ -39,12 +39,14 @@ function HonorAssist:Initialize() end function HonorAssist:ProcessChatMsgCombatHonorGain(honorGainedSummary) - local estimatedHonorGained = string.match(honorGainedSummary, "%d+") - local playerKilled = string.match(honorGainedSummary, "^([^%s]+)") - local eventTimeUtc = HonorAssist:GetCurrentTimeUtc() - HonorAssist:AddKillToMasterDatabase(playerKilled, estimatedHonorGained, eventTimeUtc) - local honorGained = HonorAssist:AddKillToDailyDatabase(playerKilled, estimatedHonorGained, eventTimeUtc, HonorAssistLogging) - HonorAssist:AddKillToHourlyDatabase(honorGained, eventTimeUtc) + if string.match(honorGainedSummary, "dies, honorable kill") then + local estimatedHonorGained = string.match(honorGainedSummary, "%d+") + local playerKilled = string.match(honorGainedSummary, "^([^%s]+)") + local eventTimeUtc = HonorAssist:GetCurrentTimeUtc() + HonorAssist:AddKillToMasterDatabase(playerKilled, estimatedHonorGained, eventTimeUtc) + local honorGained = HonorAssist:AddKillToDailyDatabase(playerKilled, estimatedHonorGained, eventTimeUtc, HonorAssistLogging) + HonorAssist:AddKillToHourlyDatabase(honorGained, eventTimeUtc) + end end function HonorAssist:OnUpdateTimer(timeSinceLastUpdate) diff --git a/HonorAssistDatabase.lua b/HonorAssistDatabase.lua index 31fd8a3..0f342aa 100644 --- a/HonorAssistDatabase.lua +++ b/HonorAssistDatabase.lua @@ -12,18 +12,20 @@ end function HonorAssist:LoadDataSinceDateTimeUtc(dailyStartTimeEpoch, hourlyStartTimeEpoch) for enemyName, enemyKills in pairs(HonorAssistData) do for index, honorGained in pairs(enemyKills) do - local percentage, realisticHonor = HonorAssist:CalculateRealisticHonor(index, honorGained.Honor) - local timeKilledEpoch = HonorAssist:DatabaseTimeUtcToLuaTime(honorGained.DateUtc) + if honorGained.Honor ~= nil and honorGained.DateUtc ~= nil then + local percentage, realisticHonor = HonorAssist:CalculateRealisticHonor(index, honorGained.Honor) + local timeKilledEpoch = HonorAssist:DatabaseTimeUtcToLuaTime(honorGained.DateUtc) - -- If the time we killed is greater than daily start time then add data to current day. - if (timeKilledEpoch > dailyStartTimeEpoch) then - local realisticHonorGained = HonorAssist:AddKillToDailyDatabase(enemyName, honorGained.Honor, honorGained.DateUtc, false) + -- If the time we killed is greater than daily start time then add data to current day. + if (timeKilledEpoch > dailyStartTimeEpoch) then + local realisticHonorGained = HonorAssist:AddKillToDailyDatabase(enemyName, honorGained.Honor, honorGained.DateUtc, false) - -- If the time we killed is greater than hourly start time then add data to current hour. - if (timeKilledEpoch > hourlyStartTimeEpoch) then - HonorAssist:AddKillToHourlyDatabase(realisticHonorGained, honorGained.DateUtc) - end - end + -- If the time we killed is greater than hourly start time then add data to current hour. + if (timeKilledEpoch > hourlyStartTimeEpoch) then + HonorAssist:AddKillToHourlyDatabase(realisticHonorGained, honorGained.DateUtc) + end + end + end end end end From 3bc0a8880ecaae8009c025b6c50deb81fc8a6488 Mon Sep 17 00:00:00 2001 From: Matthew Plachter Date: Mon, 25 Nov 2019 16:53:48 -0500 Subject: [PATCH 3/4] update release version --- HonorAssist.toc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/HonorAssist.toc b/HonorAssist.toc index d1850aa..0a03f54 100644 --- a/HonorAssist.toc +++ b/HonorAssist.toc @@ -1,7 +1,7 @@ ## Interface: 11302 ## Title: HonorAssist ## Author: Eulav, CptMerlot -## Version: 0.6 +## Version: 0.7 ## SavedVariablesPerCharacter: HonorAssistData, HonorAssistLogging, HonorAssistTrackerFramePositionX, HonorAssistTrackerFramePositionY, HonorAssistShowTrackerUi HonorAssist.lua From 779dadc62d4cac8341cf5cdec882b65a02751210 Mon Sep 17 00:00:00 2001 From: Matthew Plachter Date: Mon, 25 Nov 2019 16:58:58 -0500 Subject: [PATCH 4/4] removed utc for quick and dirty fix --- HonorAssistDatabase.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/HonorAssistDatabase.lua b/HonorAssistDatabase.lua index 0f342aa..83c0034 100644 --- a/HonorAssistDatabase.lua +++ b/HonorAssistDatabase.lua @@ -12,7 +12,7 @@ end function HonorAssist:LoadDataSinceDateTimeUtc(dailyStartTimeEpoch, hourlyStartTimeEpoch) for enemyName, enemyKills in pairs(HonorAssistData) do for index, honorGained in pairs(enemyKills) do - if honorGained.Honor ~= nil and honorGained.DateUtc ~= nil then + if honorGained.Honor ~= nil then local percentage, realisticHonor = HonorAssist:CalculateRealisticHonor(index, honorGained.Honor) local timeKilledEpoch = HonorAssist:DatabaseTimeUtcToLuaTime(honorGained.DateUtc)