Added (experimental) Recount support.
Peter Eliasson [01-18-15 - 17:30]
Added (experimental) Recount support.
diff --git a/src/parse_modules/parse_modules_include.xml b/src/parse_modules/parse_modules_include.xml
index 747f042..01eb3b4 100644
--- a/src/parse_modules/parse_modules_include.xml
+++ b/src/parse_modules/parse_modules_include.xml
@@ -1,4 +1,5 @@
<Ui xsi:schemaLocation="http://www.blizzard.com/wow/ui/ ..\..\FrameXML\UI.xsd">
<Script file="parse_modules_core.lua"/>
<Script file="skada.lua"/>
+ <Script file="recount.lua"/>
</Ui>
\ No newline at end of file
diff --git a/src/parse_modules/recount.lua b/src/parse_modules/recount.lua
new file mode 100644
index 0000000..cc4bff5
--- /dev/null
+++ b/src/parse_modules/recount.lua
@@ -0,0 +1,120 @@
+local addonName, addonTable = ...
+local addon = addonTable[1];
+local pmc = addon.parseModulesCore;
+
+local mod = pmc:NewModule("Recount", "AceHook-3.0");
+if not mod then return end;
+
+-- Global functions
+local wipe = wipe;
+local tinsert = tinsert;
+
+
+function mod:IsActivatable()
+ return IsAddOnLoaded("Recount");
+end
+
+
+function mod:GetPlayersFromLastFight()
+ local players = {};
+ -- Pets are not included in player's damage, so keep track
+ -- and manually merge them afterwards
+ local pets = {};
+
+ local fightData;
+ for name, combatant in pairs(Recount.db2.combatants) do
+ fightData = combatant.Fights.LastFightData;
+ local damage = (fightData and fightData.Damage) or 0;
+ local healing = (fightData and fightData.Healing) or 0;
+
+ -- Since Recount groups by combatant instead of fights
+ -- we have to verify that the combatant was part of the fight.
+ if fightData and (damage > 0 or healing > 0) then
+ if combatant.type == "Pet" then
+ pets[name] = {damage = damage, healing = healing};
+ elseif combatant.type == "Grouped" or combatant.type == "Self" then
+ if self:ShouldIncludePlayer(combatant.GUID, combatant.Name) then
+ local playerData = {
+ id = combatant.GUID,
+ name = combatant.Name,
+ damage = damage,
+ healing = healing,
+ pets = combatant.Pet
+ };
+ tinsert(players, playerData);
+ end
+ end
+ end
+ end
+
+ -- Merge pets and players
+ for _, playerData in ipairs(players) do
+ if playerData.pets then
+ for _, petName in ipairs(playerData.pets) do
+ if pets[petName] then
+ playerData.damage = playerData.damage + pets[petName].damage;
+ playerData.healing = playerData.healing + pets[petName].healing;
+ end
+ end
+ playerData.pets = nil;
+ end
+ end
+
+ return players;
+end
+
+function mod:ProcessParseRequest(encounter, callback)
+ -- Look at the most recent one, as previous ones might
+ -- be wipes at the same boss
+ if not Recount.FightingWho or Recount.FightingWho ~= encounter.name then
+ self:Debug("No Recount fight found for boss");
+ return callback(false);
+ end
+
+ -- CombatTimes is an object {startTime, endTime, formatStart, formatEnd, name}
+ -- where the times are from GetTime() and not time(). Because of that
+ -- we have to calculate our own unix timestamp for startTime.
+ local combatInfo = Recount.db2.CombatTimes[#Recount.db2.CombatTimes];
+ local duration = combatInfo[2] - combatInfo[1];
+ local startTime = floor(time() - duration);
+
+ local playerParses = self:GetPlayersFromLastFight();
+
+ return callback(true, startTime, duration, playerParses);
+end
+
+
+function mod:GetParsesForEncounter(encounter, callback)
+ -- If recount hasn't finished the fight, wait for it
+ if Recount.InCombat then
+ tinsert(self.pendingParseRequests, {encounter = encounter, callback = callback});
+ else
+ self:ProcessParseRequest(encounter, callback);
+ end
+end
+
+function mod:LeaveCombat()
+ self:Debug("Recount: LeaveCombat")
+
+ -- If we have requests waiting for LeaveCombat, process them now.
+ if #self.pendingParseRequests then
+ for _, pendingRequest in ipairs(self.pendingParseRequests) do
+ local encounter = pendingRequest.encounter;
+ local callback = pendingRequest.callback;
+ self:ProcessParseRequest(encounter, callback);
+ end
+ wipe(self.pendingParseRequests);
+ end
+end
+
+function mod:OnEnable()
+ self.pendingParseRequests = {};
+
+ self:SecureHook(Recount, "LeaveCombat");
+end
+
+function mod:OnDisable()
+ wipe(self.pendingParseRequests);
+
+ self:UnHook(Recount, "LeaveCombat");
+end