Skip to content
This repository has been archived by the owner on Aug 3, 2023. It is now read-only.

Commit

Permalink
Force to update players info on challenge start
Browse files Browse the repository at this point in the history
  • Loading branch information
onechiporenko committed Oct 31, 2020
1 parent 7cdf5df commit b1a196a
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 12 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
### v1.2.0

* Force to update players info on challenge start
* #24 Show each party member's race
* #23 Add filters for challenges table
* #22 Add date for challenge details title
Expand Down
19 changes: 19 additions & 0 deletions Challenge.lua
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,25 @@ function MyDungeonsBook:ParseUnitInfoFromDetailsAddon(detailsUnitName)
return details;
end

--[[--
@param[type=GUID] guid
]]
function MyDungeonsBook:UpdateUnitInfo(guid)
local id = self.db.char.activeChallengeId;
if (not id) then
return false;
end
local unit = self:GetPartyUnitByGuid(guid);
if (not unit) then
self:DebugPrint(string.format("Unit with guid %s not found", guid));
return false;
end
local unitInfo = self:ParseUnitInfoWithWowApi(unit);
self.db.char.challenges[id].players[unit] = self:MergeTables(self.db.char.challenges[id].players[unit], unitInfo);
self:DebugPrint(string.format("Info about %s is stored", unit));
return true;
end

--[[--
Delete info about challenge from local DB
Expand Down
17 changes: 5 additions & 12 deletions Events.lua
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,9 @@ function MyDungeonsBook:CHALLENGE_MODE_START()
self:DebugPrint(string.format("affixesKey is %s", affixesKey));

self.db.char.challenges[id].players.player = self:ParseUnitInfoWithWowApi("player");
for _, unitId in pairs(self:GetPartyRoster()) do
self:UpdateUnitInfo(UnitGUID(unitId));
end
NotifyInspect("player");
for i = 1, 4 do
self:ScheduleTimer(function()
Expand Down Expand Up @@ -255,19 +258,9 @@ Its request is sent in the `MyDungeonsBook:CHALLENGE_MODE_START`
@param[type=GUID] guid
]]
function MyDungeonsBook:INSPECT_READY(_, guid)
local id = self.db.char.activeChallengeId;
if (not id) then
return;
end
local unit = self:GetPartyUnitByGuid(guid);
if (not unit) then
self:DebugPrint(string.format("Unit with guid %s not found", guid));
return;
if (self:UpdateUnitInfo(guid)) then
ClearInspectPlayer(guid);
end
local unitInfo = self:ParseUnitInfoWithWowApi(unit);
self.db.char.challenges[id].players[unit] = self:MergeTables(self.db.char.challenges[id].players[unit], unitInfo);
self:DebugPrint(string.format("Info about %s is stored", unit));
ClearInspectPlayer(guid);
end

--[[--
Expand Down

0 comments on commit b1a196a

Please sign in to comment.