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

Fix issue #309 #346

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 0 additions & 72 deletions Modules/AutoAward.lua

This file was deleted.

106 changes: 106 additions & 0 deletions Modules/AwardDKP.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
local _, core = ...;
local _G = _G;
local MonDKP = core.MonDKP;
local L = core.L;

local function GetEligibleGuildMembers(onlineOnly, sameZone, currZone)
f90 marked this conversation as resolved.
Show resolved Hide resolved
-- Get list of guild members, optionally filtered for only online members and/or members currently in zone currZone
-- Returns table playerTable where playerTable[playerName] is not nil iff playerName is eligible
local playerTable = {}
GuildRoster()
for playerIndex = 1, GetNumGuildMembers() do
f90 marked this conversation as resolved.
Show resolved Hide resolved
local name, _, _, _, _, zone, _, _, online, _, _, _, _, _, _, _ = GetGuildRosterInfo(playerIndex);
if ((not onlineOnly) or online) and ((not sameZone) or (zone == currZone)) then
playerTable[name] = 1
end
end
return playerTable
end

function MonDKP:AwardPlayer(name, amount)
local search = MonDKP:Table_Search(MonDKP_DKPTable, name, "player")
local player;

if search then
player = MonDKP_DKPTable[search[1][1]]
player.dkp = player.dkp + amount
player.lifetime_gained = player.lifetime_gained + amount;
end
end

function MonDKP:AwardRaid(includeRaid, includeStandby, amount, reason) -- includeStandby = True => Also awards to players on standby
local raidAwardList = ""; -- List of players in raid that are awarded DKP
local standbyAwardList = ""; -- List of players on standby that are awarded DKP
local curTime = time();
local curOfficer = UnitName("player")

if MonDKP:CheckRaidLeader() then -- only allows raid leader to disseminate DKP
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Disagree. This limits functionality. It should be officer from whitelist. RL doesn't need to be the one responsible for DKP. For us ML does it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For boss-kill DKP ("autoaward") this check is in place right now, see
https://github.com/Roeshambo/MonolithDKP/blob/0f5f77db5c19c8af192a0607f8d8da9cfb32cc19/Modules/AutoAward.lua

For time-based DKP (RaidTimer.lua), its also only given as raid-leader:

if IsInRaid() and MonDKP:CheckRaidLeader() and core.IsOfficer then

So basically nothing is changed with this pull request in this regard. Why it is like that in the first place, i am not sure but @Roeshambo should know?

We could think about changing it in the future though. But it might create problems with keeping the DKP tables in sync if multiple officers assign DKP instead of one of them that then keeps syncing changes to them.

if includeRaid then -- Award DKP to raid members
for i = 1, 40 do
local tempName, _, _, _, _, _, zone, online = GetRaidRosterInfo(i)
local search_DKP = MonDKP:Table_Search(MonDKP_DKPTable, tempName)
local isSameZone = (zone == GetRealZoneText())

if search_DKP and (not MonDKP_DB.modes.OnlineOnly or online) and (not MonDKP_DB.modes.SameZoneOnly or isSameZone) then
MonDKP:AwardPlayer(tempName, amount)
raidAwardList = raidAwardList .. tempName .. ",";
end
end
end

-- Potentially award DKP to standby list members
if #MonDKP_Standby > 0 and includeStandby then
-- Collect list of all current raid members
local raidParty = "";
for i = 1, 40 do
local tempName = GetRaidRosterInfo(i)
if tempName then
raidParty = raidParty .. tempName .. ","
end
end

-- Delete standby members from standby list if they are already in raid
local i = 1
while i <= #MonDKP_Standby do
if strfind(raidParty, MonDKP_Standby[i].player .. ",") == 1 then
table.remove(MonDKP_Standby, i)
else
i = i + 1
end
end

-- Get list of online/same-zone players in the guild
-- WARNING: Can not check if non-guild members are online/same-zone - these will be excluded from DKP if same-zone/only-online is active!
local standbyEligible = GetEligibleGuildMembers(MonDKP_DB.modes.OnlineOnly, MonDKP_DB.modes.SameZoneOnly, GetRealZoneText())

-- Now award standby members DKP (which are not in raid since they would have been deleted before otherwise)
for i = 1, #MonDKP_Standby do
if ((not MonDKP_DB.modes.OnlineOnly) and (not MonDKP_DB.modes.SameZoneOnly)) or (standbyEligible[MonDKP_Standby[i].player] ~= nil) then
MonDKP:AwardPlayer(MonDKP_Standby[i].player, amount)
standbyAwardList = standbyAwardList .. MonDKP_Standby[i].player .. ",";
end
end
end

-- List of players to award is prepared (raidAwardList, standbyAwardList) - now assign DKP to them!
if raidAwardList ~= "" then -- Raid Member DKP
local newIndex = curOfficer .. "-" .. curTime
tinsert(MonDKP_DKPHistory, 1, { players = raidAwardList, dkp = amount, reason = reason, date = curTime, index = newIndex })
MonDKP.Sync:SendData("MonDKPBCastMsg", L["RAIDDKPADJUSTBY"] .. " " .. amount .. " " .. L["FORREASON"] .. ": " .. reason)
MonDKP.Sync:SendData("MonDKPDKPDist", MonDKP_DKPHistory[1])
end
if standbyAwardList ~= "" then -- Standby DKP
local newIndex = curOfficer .. "-" .. curTime + 1
tinsert(MonDKP_DKPHistory, 1, { players = standbyAwardList, dkp = amount, reason = reason .. " (Standby)", date = curTime + 1, index = newIndex })
MonDKP.Sync:SendData("MonDKPBCastMsg", L["STANDBYADJUSTBY"] .. " " .. amount .. " " .. L["FORREASON"] .. ": " .. reason)
MonDKP.Sync:SendData("MonDKPDKPDist", MonDKP_DKPHistory[1])
end

if raidAwardList ~= "" or standbyAwardList ~= "" then -- If we made any changes at all, trigger update
if MonDKP.ConfigTab6.history and MonDKP.ConfigTab6:IsShown() then
MonDKP:DKPHistory_Update(true)
end
DKPTable_Update()
end
end
end
Loading