diff --git a/HonorAssist.lua b/HonorAssist.lua index 8bd4658..cdc6518 100644 --- a/HonorAssist.lua +++ b/HonorAssist.lua @@ -77,9 +77,8 @@ end SLASH_HONORASSIST1 = "/honorassist" SLASH_HONORASSIST2 = "/honorassist help" -SLASH_HONORASSIST3 = "/honorassist log" -SLASH_HONORASSIST4 = "/honorassist show" -SLASH_HONORASSIST5 = "/honorassist hide" +SLASH_HONORASSIST3 = "/honorassist show" +SLASH_HONORASSIST4 = "/honorassist hide" SLASH_HONORASSIST5 = "/honorassist debug" SlashCmdList["HONORASSIST"] = function(msg) if HonorAssist:StringIsNullOrEmpty(msg) then @@ -93,11 +92,6 @@ SlashCmdList["HONORASSIST"] = function(msg) HonorAssist:PrintHelpInformation() end - if subCommand == "log" then - HonorAssistLogging = not HonorAssistLogging - print('HonorAssist logging = ' .. '|cFF00FFFF'.. tostring(HonorAssistLogging)) - end - if subCommand == "debug" then HonorAssistDEBUG = not HonorAssistDEBUG print('HonorAssist DEBUG = ' .. '|cFF00FFFF' .. tostring(HonorAssistDEBUG)) @@ -115,7 +109,6 @@ end function HonorAssist:PrintHelpInformation() print("HonorAssist Help Information") print("/honorassist, /honorassist help -- Displays help information for HonorAssist addon.") - print("/honorassist log -- Enables and disablesdetailed messages to chat about how much honor a kill was worth based on diminishing returns.") print("/honorassist show -- Shows the Honor Assist (Daily) tracker.") print("/honorassist hide -- Hides the Honor Assist (Daily) tracker.") end diff --git a/HonorAssist.toc b/HonorAssist.toc index fbbaeee..d1850aa 100644 --- a/HonorAssist.toc +++ b/HonorAssist.toc @@ -1,7 +1,7 @@ ## Interface: 11302 ## Title: HonorAssist ## Author: Eulav, CptMerlot -## Version: 0.5 +## Version: 0.6 ## SavedVariablesPerCharacter: HonorAssistData, HonorAssistLogging, HonorAssistTrackerFramePositionX, HonorAssistTrackerFramePositionY, HonorAssistShowTrackerUi HonorAssist.lua @@ -12,3 +12,4 @@ HonorAssistHourlyCalculator.lua HonorAssistTrackerUi.lua HonorAssistToolTipUtils.lua HonorAssistToolTip.lua +HonorAssistChatMessage.lua \ No newline at end of file diff --git a/HonorAssistChatMessage.lua b/HonorAssistChatMessage.lua new file mode 100644 index 0000000..f50bf28 --- /dev/null +++ b/HonorAssistChatMessage.lua @@ -0,0 +1,22 @@ +local addonName, addonTable = ... +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 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, "(%(.+)") .. '.' + + return false, text, ... +end) \ No newline at end of file diff --git a/HonorAssistDailyCalculator.lua b/HonorAssistDailyCalculator.lua index 323a0d7..2c969c8 100644 --- a/HonorAssistDailyCalculator.lua +++ b/HonorAssistDailyCalculator.lua @@ -32,10 +32,6 @@ function HonorAssist:AddKillToDailyDatabase(playerKilled, estimatedHonorGained, HonorAssist:UpdateDailyTrackerAverage(totalKills, totalHonor) - if printResult then - print('Realistic Honor: You have killed ' .. playerKilled .. ' ' .. timesKilled + 1 .. ' times. This kill granted ' .. percentage * 100 .. '% value for ' .. realisticHonor .. ' honor.') - end - return realisticHonor end diff --git a/HonorAssistUtils.lua b/HonorAssistUtils.lua index 95bdbf3..be83aa9 100644 --- a/HonorAssistUtils.lua +++ b/HonorAssistUtils.lua @@ -1,7 +1,6 @@ local addonName, addonTable = ... HonorAssist = addonTable - function HonorAssist:GetCurrentTimeUtc() return '' .. date("!%x") .. ' ' .. date("!%X") end @@ -81,4 +80,8 @@ function HonorAssist:SplitString(slashCommand, delimiter) end return result +end + +function HonorAssist:Trim(s) + return (s:gsub("^%s*(.-)%s*$", "%1")) end \ No newline at end of file