Skip to content

Commit

Permalink
Merge pull request #11 from Cjewett/feature/alter_existing_wow_honor_…
Browse files Browse the repository at this point in the history
…gained_message

Instead of having own log message change the WoW chat message for hon…
  • Loading branch information
mplachter authored Nov 22, 2019
2 parents bf75b04 + 2810629 commit 29da12c
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 15 deletions.
11 changes: 2 additions & 9 deletions HonorAssist.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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))
Expand All @@ -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
3 changes: 2 additions & 1 deletion HonorAssist.toc
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -12,3 +12,4 @@ HonorAssistHourlyCalculator.lua
HonorAssistTrackerUi.lua
HonorAssistToolTipUtils.lua
HonorAssistToolTip.lua
HonorAssistChatMessage.lua
22 changes: 22 additions & 0 deletions HonorAssistChatMessage.lua
Original file line number Diff line number Diff line change
@@ -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)
4 changes: 0 additions & 4 deletions HonorAssistDailyCalculator.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 4 additions & 1 deletion HonorAssistUtils.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
local addonName, addonTable = ...
HonorAssist = addonTable


function HonorAssist:GetCurrentTimeUtc()
return '' .. date("!%x") .. ' ' .. date("!%X")
end
Expand Down Expand Up @@ -81,4 +80,8 @@ function HonorAssist:SplitString(slashCommand, delimiter)
end

return result
end

function HonorAssist:Trim(s)
return (s:gsub("^%s*(.-)%s*$", "%1"))
end

0 comments on commit 29da12c

Please sign in to comment.