Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add raid feature, cata #105

Merged
merged 9 commits into from
May 1, 2024
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# 0.21.0

- add raid roster history recording in prep of new raid feature
- update for Cataclysm (4.0.4)

# 0.20.2

- fix issue where only portion of raid shows in roster
Expand Down
4 changes: 2 additions & 2 deletions CalamityEPGP/CalamityEPGP.toc
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
## Title: CalamityEPGP
## Notes: EPGP addon for WOTLK
## Author: Kardiir-Atiesh
## Version: 0.20.2
## Interface: 30403
## Version: 0.21.0
## Interface: 40400
## SavedVariables: CalamityEPGP
## DefaultState: enabled
## OptionalDeps: Guild_Roster_Manager
Expand Down
1 change: 1 addition & 0 deletions CalamityEPGP/lib.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ ns.Lib = Lib
---@param o1 any|table First object to compare
---@param o2 any|table Second object to compare
---@param ignore_mt boolean True to ignore metatables (a recursive function to tests tables inside tables)
---@return boolean
function Lib.equals(o1, o2, ignore_mt)
if o1 == o2 then return true end
local o1Type = type(o1)
Expand Down
43 changes: 42 additions & 1 deletion CalamityEPGP/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ local dbDefaults = {
lmSettingsLastChange = -1,
benchedPlayers = {},
knownPlayers = {},
raid = {
rosterHistory = {},
},
}
}

Expand Down Expand Up @@ -283,6 +286,13 @@ function addon:init()
self.clearAwarded()
self.clearAwardedTimer = self:ScheduleRepeatingTimer(function() self.clearAwarded() end, 60)

self:housekeepRaidRosterHistory()
self.housekeepRaidRosterHistoryTimer = self:ScheduleRepeatingTimer(function() self:housekeepRaidRosterHistory() end, 600)

table.sort(ns.db.raid.rosterHistory, function(left, right)
return left[1] < right[1]
end)

self:RegisterChatCommand('ce', 'handleSlashCommand')
self:RegisterEvent('CHAT_MSG_SYSTEM', 'handleChatMsg')
self:RegisterEvent('CHAT_MSG_PARTY', 'handleChatMsg')
Expand Down Expand Up @@ -433,6 +443,8 @@ end


function addon:loadRaidRoster()
local prevPlayers = self.raidRoster:len()

self.raidRoster:clear()

if IsInRaid() then
Expand Down Expand Up @@ -461,6 +473,20 @@ function addon:loadRaidRoster()

ns.MainWindow:refresh()
ns.RaidWindow:refresh()

if ns.Lib.isOfficer() and prevPlayers ~= self.raidRoster:len() then
local ts = time()

local players = {}
for player in self.raidRoster:iter() do
ns.Lib.bininsert(players, player)
end

tinsert(ns.db.raid.rosterHistory, {ts, players})

ns.Sync:computeRaidRosterHistoryHashes()
ns.Sync:sendRosterHistoryEventToOfficers(ts, players)
end
end


Expand Down Expand Up @@ -840,6 +866,21 @@ function addon:housekeepPeers()
end


function addon:housekeepRaidRosterHistory()
local oneDayAgo = time() - 86400 -- 24 hours old

local newRaidRosterHistory = {}

for _, event in ipairs(ns.db.raid.rosterHistory) do
if event[1] > oneDayAgo then
tinsert(newRaidRosterHistory, event)
end
end

ns.db.raid.rosterHistory = newRaidRosterHistory
end


---@param players table
---@param mode 'ep' | 'gp'
---@param value number
Expand Down Expand Up @@ -919,7 +960,7 @@ function addon:modifyEpgp(players, mode, value, reason, percent)
ns.RaidWindow:refresh()
ns.HistoryWindow:refresh()

ns.Sync:computeIndices()
ns.Sync:computeIndices(false)
ns.Sync:sendEventsToGuild({event})
end

Expand Down
Loading
Loading