Skip to content

Commit

Permalink
Merge pull request #14 from Cjewett/bugfix/fix_processing_of_dks
Browse files Browse the repository at this point in the history
Bugfix/fix processing of dks
  • Loading branch information
Cjewett authored Nov 25, 2019
2 parents 29da12c + 779dadc commit 78e85d2
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 29 deletions.
14 changes: 8 additions & 6 deletions HonorAssist.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 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.6
## Version: 0.7
## SavedVariablesPerCharacter: HonorAssistData, HonorAssistLogging, HonorAssistTrackerFramePositionX, HonorAssistTrackerFramePositionY, HonorAssistShowTrackerUi

HonorAssist.lua
Expand Down
29 changes: 17 additions & 12 deletions HonorAssistChatMessage.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
22 changes: 12 additions & 10 deletions HonorAssistDatabase.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 78e85d2

Please sign in to comment.