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/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 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 diff --git a/HonorAssistDatabase.lua b/HonorAssistDatabase.lua index 31fd8a3..83c0034 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 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