diff --git a/Modules/AutoAward.lua b/Modules/AutoAward.lua deleted file mode 100644 index 39d8041e..00000000 --- a/Modules/AutoAward.lua +++ /dev/null @@ -1,72 +0,0 @@ -local _, core = ...; -local _G = _G; -local MonDKP = core.MonDKP; -local L = core.L; - -function MonDKP:AutoAward(phase, amount, reason) -- phase identifies who to award (1=just raid, 2=just standby, 3=both) - local tempList = ""; - local tempList2 = ""; - local curTime = time(); - local curOfficer = UnitName("player") - - if MonDKP:CheckRaidLeader() then -- only allows raid leader to disseminate DKP - if phase == 1 or phase == 3 then - for i=1, 40 do - local tempName, _rank, _subgroup, _level, _class, _fileName, zone, online = GetRaidRosterInfo(i) - local search_DKP = MonDKP:Table_Search(MonDKP_DKPTable, tempName) - local OnlineOnly = MonDKP_DB.modes.OnlineOnly - local limitToZone = MonDKP_DB.modes.SameZoneOnly - local isSameZone = zone == GetRealZoneText() - - if search_DKP and (not OnlineOnly or online) and (not limitToZone or isSameZone) then - MonDKP:AwardPlayer(tempName, amount) - tempList = tempList..tempName..","; - end - end - end - - if #MonDKP_Standby > 0 and MonDKP_DB.DKPBonus.AutoIncStandby and (phase == 2 or phase == 3) then - local raidParty = ""; - for i=1, 40 do - local tempName = GetRaidRosterInfo(i) - if tempName then - raidParty = raidParty..tempName.."," - end - end - for i=1, #MonDKP_Standby do - if strfind(raidParty, MonDKP_Standby[i].player..",") ~= 1 and not strfind(raidParty, ","..MonDKP_Standby[i].player..",") then - MonDKP:AwardPlayer(MonDKP_Standby[i].player, amount) - tempList2 = tempList2..MonDKP_Standby[i].player..","; - end - end - local i = 1 - while i <= #MonDKP_Standby do - if MonDKP_Standby[i] and (strfind(raidParty, MonDKP_Standby[i].player..",") == 1 or strfind(raidParty, ","..MonDKP_Standby[i].player..",")) then - table.remove(MonDKP_Standby, i) - else - i=i+1 - end - end - end - - if tempList ~= "" or tempList2 ~= "" then - if (phase == 1 or phase == 3) and tempList ~= "" then - local newIndex = curOfficer.."-"..curTime - tinsert(MonDKP_DKPHistory, 1, {players=tempList, 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 (phase == 2 or phase == 3) and tempList2 ~= "" then - local newIndex = curOfficer.."-"..curTime+1 - tinsert(MonDKP_DKPHistory, 1, {players=tempList2, 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 MonDKP.ConfigTab6.history and MonDKP.ConfigTab6:IsShown() then - MonDKP:DKPHistory_Update(true) - end - DKPTable_Update() - end - end -end \ No newline at end of file diff --git a/Modules/AwardDKP.lua b/Modules/AwardDKP.lua new file mode 100644 index 00000000..e3cddf5f --- /dev/null +++ b/Modules/AwardDKP.lua @@ -0,0 +1,106 @@ +local _, core = ...; +local _G = _G; +local MonDKP = core.MonDKP; +local L = core.L; + +local function GetEligibleGuildMembers(onlineOnly, sameZone, currZone) + -- 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 + 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 + 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 diff --git a/Modules/Award.lua b/Modules/AwardItem.lua similarity index 97% rename from Modules/Award.lua rename to Modules/AwardItem.lua index 55fa4ca9..87fa1da9 100644 --- a/Modules/Award.lua +++ b/Modules/AwardItem.lua @@ -1,470 +1,470 @@ -local _, core = ...; -local _G = _G; -local MonDKP = core.MonDKP; -local L = core.L; - -local function AwardItem(player, cost, boss, zone, loot, reassign) - local cost = cost; - local winner = player; - local curTime = time(); - local curZone = zone; - local curBoss = boss; - local loot = loot; - local BidsEntry = {}; - local mode = MonDKP_DB.modes.mode; - local curOfficer = UnitName("player") - local bids; - local search_reassign; - - MonDKP:StatusVerify_Update() - - if core.IsOfficer then - if MonDKP_DB.modes.costvalue == "Percent" then - local search = MonDKP:Table_Search(MonDKP_DKPTable, winner); - - if MonDKP_DB.modes.mode == "Roll Based Bidding" then - if search then - cost = MonDKP_DKPTable[search[1][1]].dkp * (cost / 100) - cost = MonDKP_round(cost, MonDKP_DB.modes.rounding); - else - print(L["ERROR"]) - end - else - cost = MonDKP_DKPTable[search[1][1]].dkp * (cost / 100) - cost = MonDKP_round(cost, MonDKP_DB.modes.rounding); - end - else - cost = MonDKP_round(cost, MonDKP_DB.modes.rounding) - end - - if cost > 0 then - cost = cost * -1 - end - - if reassign then - search_reassign = MonDKP:Table_Search(MonDKP_Loot, reassign, "index") - - if search_reassign then - local deleted = CopyTable(MonDKP_Loot[search_reassign[1][1]]) - local reimburse = MonDKP:Table_Search(MonDKP_DKPTable, deleted.player, "player") - local newIndex = curOfficer.."-"..curTime-2 - deleted.cost = deleted.cost * -1 - deleted.deletes = reassign - deleted.index = newIndex - deleted.date = curTime-2 - if deleted.bids then - bids = CopyTable(deleted.bids); - deleted.bids = nil; - end - MonDKP_Loot[search_reassign[1][1]].deletedby = newIndex - MonDKP_DKPTable[reimburse[1][1]].dkp = MonDKP_DKPTable[reimburse[1][1]].dkp + deleted.cost - MonDKP_DKPTable[reimburse[1][1]].lifetime_spent = MonDKP_DKPTable[reimburse[1][1]].lifetime_spent + deleted.cost - table.insert(MonDKP_Loot, 1, deleted) - MonDKP.Sync:SendData("MonDKPDelLoot", MonDKP_Loot[1]) - end - end - - if MonDKP_DB.modes.StoreBids and not reassign then - local Bids_Submitted = MonDKP:BidsSubmitted_Get(); - local newIndex = curOfficer.."-"..curTime - - for i=1, #Bids_Submitted do - if Bids_Submitted[i].bid then - BidsEntry[Bids_Submitted[i].player] = Bids_Submitted[i].bid; - elseif Bids_Submitted[i].dkp then - BidsEntry[Bids_Submitted[i].player] = Bids_Submitted[i].dkp; - elseif Bids_Submitted[i].roll then - BidsEntry[Bids_Submitted[i].player] = Bids_Submitted[i].roll..Bids_Submitted[i].range; - end - end - if Bids_Submitted[1] then - if Bids_Submitted[1].bid then - tinsert(MonDKP_Loot, 1, {player=winner, loot=loot, zone=curZone, date=curTime, boss=curBoss, cost=cost, index=newIndex, bids={ }}) - for k,v in pairs(BidsEntry) do - table.insert(MonDKP_Loot[1].bids, {bidder=k, bid=v}); - end - elseif Bids_Submitted[1].dkp then - tinsert(MonDKP_Loot, 1, {player=winner, loot=loot, zone=curZone, date=curTime, boss=curBoss, cost=cost, index=newIndex, dkp={ }}) - for k,v in pairs(BidsEntry) do - table.insert(MonDKP_Loot[1].dkp, {bidder=k, dkp=v}); - end - elseif Bids_Submitted[1].roll then - tinsert(MonDKP_Loot, 1, {player=winner, loot=loot, zone=curZone, date=curTime, boss=curBoss, cost=cost, index=newIndex, rolls={ }}) - for k,v in pairs(BidsEntry) do - table.insert(MonDKP_Loot[1].rolls, {bidder=k, roll=v}); - end - end - else - tinsert(MonDKP_Loot, 1, {player=winner, loot=loot, zone=curZone, date=curTime, boss=curBoss, cost=cost, index=newIndex}) - end - else - local newIndex = curOfficer.."-"..curTime - tinsert(MonDKP_Loot, 1, {player=winner, loot=loot, zone=curZone, date=curTime, boss=curBoss, cost=cost, index=newIndex}) - if reassign then - local search = MonDKP:Table_Search(MonDKP_Loot, reassign, "index") - - if search and MonDKP_Loot[search[1][1]].player ~= winner then - MonDKP_Loot[1].reassigned = true - end - end - if type(bids) == "table" then - MonDKP_Loot[1].bids = bids - end - end - - MonDKP:BidsSubmitted_Clear() - MonDKP.Sync:SendData("MonDKPLootDist", MonDKP_Loot[1]) - MonDKP:DKPTable_Set(winner, "dkp", MonDKP_round(cost, MonDKP_DB.modes.rounding), true) - MonDKP:LootHistory_Reset(); - MonDKP:LootHistory_Update(L["NOFILTER"]) - - if core.BiddingWindow and core.BiddingWindow:IsShown() then -- runs below if award is through bidding window (update minbids and zerosum bank) - if _G["MonDKPBiddingStartBiddingButton"] then - _G["MonDKPBiddingStartBiddingButton"]:SetText(L["STARTBIDDING"]) - _G["MonDKPBiddingStartBiddingButton"]:SetScript("OnClick", function (self) - ToggleTimerBtn(self) - end) - timerToggle = 0; - end - - core.BidInProgress = false; - MonDKP:BroadcastStopBidTimer() - - SendChatMessage(L["CONGRATS"].." "..winner.." "..L["ON"].." "..loot.." @ "..-cost.." "..L["DKP"], "RAID_WARNING") - if MonDKP_DB.modes.AnnounceAward then - SendChatMessage(L["CONGRATS"].." "..winner.." "..L["ON"].." "..loot.." @ "..-cost.." "..L["DKP"], "GUILD") - end - - - if mode == "Static Item Values" or mode == "Roll Based Bidding" or (mode == "Zero Sum" and MonDKP_DB.modes.ZeroSumBidType == "Static") then - local search = MonDKP:Table_Search(MonDKP_MinBids, core.BiddingWindow.itemName:GetText()) - local val = MonDKP:GetMinBid(loot); - - if not search and core.BiddingWindow.cost:GetNumber() ~= tonumber(val) then - tinsert(MonDKP_MinBids, {item=core.BiddingWindow.itemName:GetText(), minbid=core.BiddingWindow.cost:GetNumber()}) - core.BiddingWindow.CustomMinBid:SetShown(true); - core.BiddingWindow.CustomMinBid:SetChecked(true); - elseif search and core.BiddingWindow.cost:GetNumber() ~= tonumber(val) and core.BiddingWindow.CustomMinBid:GetChecked() == true then - if MonDKP_MinBids[search[1][1]].minbid ~= core.BiddingWindow.cost:GetText() then - MonDKP_MinBids[search[1][1]].minbid = MonDKP_round(core.BiddingWindow.cost:GetNumber(), MonDKP_DB.modes.rounding); - core.BiddingWindow.CustomMinBid:SetShown(true); - core.BiddingWindow.CustomMinBid:SetChecked(true); - end - end - - if search and core.BiddingWindow.CustomMinBid:GetChecked() == false then - table.remove(MonDKP_MinBids, search[1][1]) - core.BiddingWindow.CustomMinBid:SetShown(false); - end - end - - if mode == "Zero Sum" and not reassign then - MonDKP_DB.modes.ZeroSumBank.balance = MonDKP_DB.modes.ZeroSumBank.balance + -tonumber(cost) - table.insert(MonDKP_DB.modes.ZeroSumBank, { loot = loot, cost = -tonumber(cost) }) - MonDKP:ZeroSumBank_Update() - MonDKP.Sync:SendData("MonDKPZSumBank", MonDKP_DB.modes.ZeroSumBank) - end - core.BiddingWindow:Hide() - ClearBidWindow() - end - end -end - -local function AwardConfirm_Create() - local f = CreateFrame("Frame", "MonDKP_AwardWindowConfirm", UIParent, "ShadowOverlaySmallTemplate"); - - f:SetPoint("TOP", UIParent, "TOP", 0, -200); - f:SetSize(400, 230); - f:SetClampedToScreen(true) - f:SetBackdrop( { - bgFile = "Textures\\white.blp", tile = true, -- White backdrop allows for black background with 1.0 alpha on low alpha containers - edgeFile = "Interface\\AddOns\\MonolithDKP\\Media\\Textures\\edgefile.tga", tile = true, tileSize = 1, edgeSize = 3, - insets = { left = 0, right = 0, top = 0, bottom = 0 } - }); - f:SetBackdropColor(0,0,0,0.9); - f:SetBackdropBorderColor(1,1,1,1) - f:SetFrameStrata("DIALOG") - f:SetFrameLevel(15) - f:Hide() - - f.confirmHeader = f:CreateFontString(nil, "OVERLAY") - f.confirmHeader:SetFontObject("MonDKPLargeRight"); - f.confirmHeader:SetScale(0.9) - f.confirmHeader:SetPoint("TOPLEFT", f, "TOPLEFT", 15, -15); - f.confirmHeader:SetText(L["CONFAWARD"]) - - f.playerHeader = f:CreateFontString(nil, "OVERLAY") - f.playerHeader:SetFontObject("MonDKPLargeRight"); - f.playerHeader:SetScale(0.7) - f.playerHeader:SetPoint("TOPLEFT", f, "TOPLEFT", 120, -60); - f.playerHeader:SetText(L["PLAYER"]..":") - - f.player = CreateFrame("FRAME", "MonDKPAwardConfirmPlayerDropDown", f, "MonolithDKPUIDropDownMenuTemplate") - f.player:SetPoint("LEFT", f.playerHeader, "RIGHT", -15, 0) - UIDropDownMenu_SetWidth(f.player, 150) - UIDropDownMenu_JustifyText(f.player, "LEFT") - - - --[[f.player = f:CreateFontString(nil, "OVERLAY") - f.player:SetFontObject("MonDKPNormalLeft"); - f.player:SetPoint("LEFT", f.playerHeader, "RIGHT", 5, 1); - f.player:SetSize(200, 28);--]] - - f.lootHeader = f:CreateFontString(nil, "OVERLAY") - f.lootHeader:SetFontObject("MonDKPLargeRight"); - f.lootHeader:SetScale(0.7) - f.lootHeader:SetPoint("TOPRIGHT", f.playerHeader, "BOTTOMRIGHT", 0, -10); - f.lootHeader:SetText(L["ITEM"]..":") - - f.lootIcon = f:CreateTexture(nil, "OVERLAY", nil); - f.lootIcon:SetPoint("LEFT", f.lootHeader, "RIGHT", 5, 0); - f.lootIcon:SetColorTexture(0, 0, 0, 1) - f.lootIcon:SetSize(20, 20); - - f.loot = f:CreateFontString(nil, "OVERLAY") - f.loot:SetFontObject("MonDKPNormalLeft"); - f.loot:SetPoint("LEFT", f.lootIcon, "RIGHT", 5, 1); - f.loot:SetSize(200, 28); - - f.costHeader = f:CreateFontString(nil, "OVERLAY") - f.costHeader:SetFontObject("MonDKPLargeRight"); - f.costHeader:SetScale(0.7) - f.costHeader:SetPoint("TOPRIGHT", f.lootHeader, "BOTTOMRIGHT", 0, -10); - f.costHeader:SetText(L["ITEMCOST"]..":") - - f.cost = CreateFrame("EditBox", nil, f) - f.cost:SetAutoFocus(false) - f.cost:SetMultiLine(false) - f.cost:SetPoint("LEFT", f.costHeader, "RIGHT", 5, 0) - f.cost:SetSize(50, 22) - f.cost:SetBackdrop({ - bgFile = "Textures\\white.blp", tile = true, - edgeFile = "Interface\\ChatFrame\\ChatFrameBackground", tile = true, tileSize = 1, edgeSize = 2, - }); - f.cost:SetBackdropColor(0,0,0,0.9) - f.cost:SetBackdropBorderColor(0.12, 0.12, 0.34, 1) - f.cost:SetMaxLetters(10) - f.cost:SetTextColor(1, 1, 1, 1) - f.cost:SetFontObject("MonDKPSmallRight") - f.cost:SetTextInsets(10,10,0,0) - f.cost:SetScript("OnEscapePressed", function(self) -- clears focus on esc - self:ClearFocus() - end) - f.cost:SetScript("OnTabPressed", function(self) -- clears focus on tab - self:ClearFocus() - end) - f.cost:SetScript("OnEnterPressed", function(self) -- clears focus on enter - self:ClearFocus() - end) - - f.costFooter = f:CreateFontString(nil, "OVERLAY") - f.costFooter:SetFontObject("MonDKPNormalLeft"); - f.costFooter:SetPoint("LEFT", f.cost, "RIGHT", 5, 0); - f.costFooter:SetSize(200, 28); - - f.bossHeader = f:CreateFontString(nil, "OVERLAY") - f.bossHeader:SetFontObject("MonDKPLargeRight"); - f.bossHeader:SetScale(0.7) - f.bossHeader:SetPoint("TOPRIGHT", f.costHeader, "BOTTOMRIGHT", 0, -10); - f.bossHeader:SetText(L["BOSS"]..":") - - f.bossDropDown = CreateFrame("FRAME", "MonDKPAwardConfirmBossDropDown", f, "MonolithDKPUIDropDownMenuTemplate") - f.bossDropDown:SetPoint("LEFT", f.bossHeader, "RIGHT", -15, -2) - UIDropDownMenu_SetWidth(f.bossDropDown, 150) - UIDropDownMenu_JustifyText(f.bossDropDown, "LEFT") - - f.zoneHeader = f:CreateFontString(nil, "OVERLAY") - f.zoneHeader:SetFontObject("MonDKPLargeRight"); - f.zoneHeader:SetScale(0.7) - f.zoneHeader:SetPoint("TOPRIGHT", f.bossHeader, "BOTTOMRIGHT", 0, -10); - f.zoneHeader:SetText(L["ZONE"]..":") - - f.zoneDropDown = CreateFrame("FRAME", "MonDKPAwardConfirmBossDropDown", f, "MonolithDKPUIDropDownMenuTemplate") - f.zoneDropDown:SetPoint("LEFT", f.zoneHeader, "RIGHT", -15, -2) - UIDropDownMenu_SetWidth(f.zoneDropDown, 150) - UIDropDownMenu_JustifyText(f.zoneDropDown, "LEFT") - - f.yesButton = MonDKP:CreateButton("BOTTOMLEFT", f, "BOTTOMLEFT", 20, 15, L["CONFIRM"]); - f.noButton = MonDKP:CreateButton("BOTTOMRIGHT", f, "BOTTOMRIGHT", -20, 15, L["CANCEL"]); - - return f; -end - -function MonDKP:AwardConfirm(player, cost, boss, zone, loot, reassign) - local _,itemLink,_,_,_,_,_,_,_,itemIcon = GetItemInfo(loot) - local curBoss, curZone, player, cost = boss, zone, player, cost - local class, search; - local PlayerList = {}; - local curSelected = 0; - - if cost == 0 then - cost = MonDKP:GetMinBid(itemLink) - end - - if player then - search = MonDKP:Table_Search(MonDKP_DKPTable, player) - class = MonDKP:GetCColors(MonDKP_DKPTable[search[1][1]].class) - end - - for i=1, #MonDKP_DKPTable do - table.insert(PlayerList, MonDKP_DKPTable[i].player) - end - table.sort(PlayerList, function(a, b) - return a < b - end) - - PlaySound(850) - core.AwardConfirm = core.AwardConfirm or AwardConfirm_Create() - core.AwardConfirm:SetShown(not core.AwardConfirm:IsShown()) - - --core.AwardConfirm.player:SetText("|cff"..class.hex..player.."|r") - core.AwardConfirm.lootIcon:SetTexture(itemIcon) - core.AwardConfirm.loot:SetText(loot) - core.AwardConfirm.cost:SetNumber(cost) - core.AwardConfirm.cost:SetScript("OnKeyUp", function(self) - cost = self:GetNumber(); - end) - core.AwardConfirm.costFooter:SetText("DKP") - --core.AwardConfirm.boss:SetText(boss.." in "..zone) - - if player then - UIDropDownMenu_SetText(core.AwardConfirm.player, "|cff"..class.hex..player.."|r") - else - UIDropDownMenu_SetText(core.AwardConfirm.player, "") - end - - UIDropDownMenu_Initialize(core.AwardConfirm.player, function(self, level, menuList) - local filterName = UIDropDownMenu_CreateInfo() - local ranges = {1} - - while ranges[#ranges] < #PlayerList do - table.insert(ranges, ranges[#ranges]+20) - end - - if (level or 1) == 1 then - local numSubs = ceil(#PlayerList/20) - filterName.func = self.SetValue - - for i=1, numSubs do - local max = i*20; - if max > #PlayerList then max = #PlayerList end - filterName.text, filterName.checked, filterName.menuList, filterName.hasArrow = strsub(PlayerList[((i*20)-19)], 1, 1).."-"..strsub(PlayerList[max], 1, 1), curSelected >= (i*20)-19 and curSelected <= i*20, i, true - UIDropDownMenu_AddButton(filterName) - end - - else - filterName.func = self.SetValue - for i=ranges[menuList], ranges[menuList]+19 do - if PlayerList[i] then - local classSearch = MonDKP:Table_Search(MonDKP_DKPTable, PlayerList[i]) - local c; - - if classSearch then - c = MonDKP:GetCColors(MonDKP_DKPTable[classSearch[1][1]].class) - else - c = { hex="444444" } - end - filterName.text, filterName.arg1, filterName.arg2, filterName.checked, filterName.isNotRadio = "|cff"..c.hex..PlayerList[i].."|r", PlayerList[i], "|cff"..c.hex..PlayerList[i].."|r", PlayerList[i] == player, true - UIDropDownMenu_AddButton(filterName, level) - end - end - end - end) - - UIDropDownMenu_SetText(core.AwardConfirm.bossDropDown, curBoss) - UIDropDownMenu_Initialize(core.AwardConfirm.bossDropDown, function(self, level, menuList) -- BOSS dropdown - UIDropDownMenu_SetAnchor(core.AwardConfirm.bossDropDown, 10, 10, "TOPLEFT", core.AwardConfirm.bossDropDown, "BOTTOMLEFT") - --UIDropDownMenu_JustifyText(core.AwardConfirm.bossDropDown, "LEFT") - local reason = UIDropDownMenu_CreateInfo() - local tempNPCs = {}; - - table.insert(tempNPCs, core.LastKilledBoss) - - for k,v in pairs(core.LastKilledNPC) do -- eliminates duplicate zones - if not MonDKP:Table_Search(tempNPCs, v) then - table.insert(tempNPCs, v) - end - end - - reason.func = self.SetValue - - if not MonDKP:Table_Search(tempNPCs, curBoss) then - reason.text, reason.arg1, reason.checked, reason.isNotRadio = curBoss, curBoss, curBoss == curBoss, true - UIDropDownMenu_AddButton(reason) - end - - for i=1, #tempNPCs do - reason.text, reason.arg1, reason.checked, reason.isNotRadio = tempNPCs[i], tempNPCs[i], tempNPCs[i] == curBoss, true - UIDropDownMenu_AddButton(reason) - end - end) - - UIDropDownMenu_SetText(core.AwardConfirm.zoneDropDown, curZone) - UIDropDownMenu_Initialize(core.AwardConfirm.zoneDropDown, function(self, level, menuList) -- ZONE dropdown - UIDropDownMenu_SetAnchor(core.AwardConfirm.zoneDropDown, 10, 10, "TOPLEFT", core.AwardConfirm.zoneDropDown, "BOTTOMLEFT") - --UIDropDownMenu_JustifyText(core.AwardConfirm.bossDropDown, "LEFT") - local reason = UIDropDownMenu_CreateInfo() - local tempZones = {}; - - table.insert(tempZones, core.CurrentRaidZone) - - for k,v in pairs(core.RecentZones) do -- eliminates duplicate zones - if not MonDKP:Table_Search(tempZones, v) then - table.insert(tempZones, v) - end - end - - reason.func = self.SetValue - - for i=1, #tempZones do - reason.text, reason.arg1, reason.checked, reason.isNotRadio = tempZones[i], tempZones[i], tempZones[i] == curZone, true - UIDropDownMenu_AddButton(reason) - end - end) - - function core.AwardConfirm.player:SetValue(newValue, arg2) ---- PLAYER dropdown function - if player ~= newValue then player = newValue end - UIDropDownMenu_SetText(core.AwardConfirm.player, arg2) - CloseDropDownMenus() - end - - function core.AwardConfirm.bossDropDown:SetValue(newValue) ---- BOSS dropdown function - UIDropDownMenu_SetText(core.AwardConfirm.bossDropDown, newValue) - curBoss = newValue; - CloseDropDownMenus() - end - - function core.AwardConfirm.zoneDropDown:SetValue(newValue) ---- ZONE dropdown function - UIDropDownMenu_SetText(core.AwardConfirm.zoneDropDown, newValue) - curZone = newValue; - CloseDropDownMenus() - end - - core.AwardConfirm.yesButton:SetScript("OnClick", function() -- Run when "Yes" is clicked - if not player then - StaticPopupDialogs["AWARD_VALIDATE"] = { - text = L["PLAYERVALIDATE"], - button1 = L["OK"], - timeout = 0, - whileDead = true, - hideOnEscape = true, - preferredIndex = 3, - } - StaticPopup_Show ("AWARD_VALIDATE") - else - if reassign then - AwardItem(player, cost, curBoss, curZone, loot, reassign) - else - AwardItem(player, cost, curBoss, curZone, loot) - end - - core.AwardConfirm:SetShown(false) - end - - PlaySound(851) - end) - core.AwardConfirm.noButton:SetScript("OnClick", function() -- Run when "No" is clicked - PlaySound(851) - core.AwardConfirm:SetShown(false) - end) +local _, core = ...; +local _G = _G; +local MonDKP = core.MonDKP; +local L = core.L; + +local function AwardItem(player, cost, boss, zone, loot, reassign) + local cost = cost; + local winner = player; + local curTime = time(); + local curZone = zone; + local curBoss = boss; + local loot = loot; + local BidsEntry = {}; + local mode = MonDKP_DB.modes.mode; + local curOfficer = UnitName("player") + local bids; + local search_reassign; + + MonDKP:StatusVerify_Update() + + if core.IsOfficer then + if MonDKP_DB.modes.costvalue == "Percent" then + local search = MonDKP:Table_Search(MonDKP_DKPTable, winner); + + if MonDKP_DB.modes.mode == "Roll Based Bidding" then + if search then + cost = MonDKP_DKPTable[search[1][1]].dkp * (cost / 100) + cost = MonDKP_round(cost, MonDKP_DB.modes.rounding); + else + print(L["ERROR"]) + end + else + cost = MonDKP_DKPTable[search[1][1]].dkp * (cost / 100) + cost = MonDKP_round(cost, MonDKP_DB.modes.rounding); + end + else + cost = MonDKP_round(cost, MonDKP_DB.modes.rounding) + end + + if cost > 0 then + cost = cost * -1 + end + + if reassign then + search_reassign = MonDKP:Table_Search(MonDKP_Loot, reassign, "index") + + if search_reassign then + local deleted = CopyTable(MonDKP_Loot[search_reassign[1][1]]) + local reimburse = MonDKP:Table_Search(MonDKP_DKPTable, deleted.player, "player") + local newIndex = curOfficer.."-"..curTime-2 + deleted.cost = deleted.cost * -1 + deleted.deletes = reassign + deleted.index = newIndex + deleted.date = curTime-2 + if deleted.bids then + bids = CopyTable(deleted.bids); + deleted.bids = nil; + end + MonDKP_Loot[search_reassign[1][1]].deletedby = newIndex + MonDKP_DKPTable[reimburse[1][1]].dkp = MonDKP_DKPTable[reimburse[1][1]].dkp + deleted.cost + MonDKP_DKPTable[reimburse[1][1]].lifetime_spent = MonDKP_DKPTable[reimburse[1][1]].lifetime_spent + deleted.cost + table.insert(MonDKP_Loot, 1, deleted) + MonDKP.Sync:SendData("MonDKPDelLoot", MonDKP_Loot[1]) + end + end + + if MonDKP_DB.modes.StoreBids and not reassign then + local Bids_Submitted = MonDKP:BidsSubmitted_Get(); + local newIndex = curOfficer.."-"..curTime + + for i=1, #Bids_Submitted do + if Bids_Submitted[i].bid then + BidsEntry[Bids_Submitted[i].player] = Bids_Submitted[i].bid; + elseif Bids_Submitted[i].dkp then + BidsEntry[Bids_Submitted[i].player] = Bids_Submitted[i].dkp; + elseif Bids_Submitted[i].roll then + BidsEntry[Bids_Submitted[i].player] = Bids_Submitted[i].roll..Bids_Submitted[i].range; + end + end + if Bids_Submitted[1] then + if Bids_Submitted[1].bid then + tinsert(MonDKP_Loot, 1, {player=winner, loot=loot, zone=curZone, date=curTime, boss=curBoss, cost=cost, index=newIndex, bids={ }}) + for k,v in pairs(BidsEntry) do + table.insert(MonDKP_Loot[1].bids, {bidder=k, bid=v}); + end + elseif Bids_Submitted[1].dkp then + tinsert(MonDKP_Loot, 1, {player=winner, loot=loot, zone=curZone, date=curTime, boss=curBoss, cost=cost, index=newIndex, dkp={ }}) + for k,v in pairs(BidsEntry) do + table.insert(MonDKP_Loot[1].dkp, {bidder=k, dkp=v}); + end + elseif Bids_Submitted[1].roll then + tinsert(MonDKP_Loot, 1, {player=winner, loot=loot, zone=curZone, date=curTime, boss=curBoss, cost=cost, index=newIndex, rolls={ }}) + for k,v in pairs(BidsEntry) do + table.insert(MonDKP_Loot[1].rolls, {bidder=k, roll=v}); + end + end + else + tinsert(MonDKP_Loot, 1, {player=winner, loot=loot, zone=curZone, date=curTime, boss=curBoss, cost=cost, index=newIndex}) + end + else + local newIndex = curOfficer.."-"..curTime + tinsert(MonDKP_Loot, 1, {player=winner, loot=loot, zone=curZone, date=curTime, boss=curBoss, cost=cost, index=newIndex}) + if reassign then + local search = MonDKP:Table_Search(MonDKP_Loot, reassign, "index") + + if search and MonDKP_Loot[search[1][1]].player ~= winner then + MonDKP_Loot[1].reassigned = true + end + end + if type(bids) == "table" then + MonDKP_Loot[1].bids = bids + end + end + + MonDKP:BidsSubmitted_Clear() + MonDKP.Sync:SendData("MonDKPLootDist", MonDKP_Loot[1]) + MonDKP:DKPTable_Set(winner, "dkp", MonDKP_round(cost, MonDKP_DB.modes.rounding), true) + MonDKP:LootHistory_Reset(); + MonDKP:LootHistory_Update(L["NOFILTER"]) + + if core.BiddingWindow and core.BiddingWindow:IsShown() then -- runs below if award is through bidding window (update minbids and zerosum bank) + if _G["MonDKPBiddingStartBiddingButton"] then + _G["MonDKPBiddingStartBiddingButton"]:SetText(L["STARTBIDDING"]) + _G["MonDKPBiddingStartBiddingButton"]:SetScript("OnClick", function (self) + ToggleTimerBtn(self) + end) + timerToggle = 0; + end + + core.BidInProgress = false; + MonDKP:BroadcastStopBidTimer() + + SendChatMessage(L["CONGRATS"].." "..winner.." "..L["ON"].." "..loot.." @ "..-cost.." "..L["DKP"], "RAID_WARNING") + if MonDKP_DB.modes.AnnounceAward then + SendChatMessage(L["CONGRATS"].." "..winner.." "..L["ON"].." "..loot.." @ "..-cost.." "..L["DKP"], "GUILD") + end + + + if mode == "Static Item Values" or mode == "Roll Based Bidding" or (mode == "Zero Sum" and MonDKP_DB.modes.ZeroSumBidType == "Static") then + local search = MonDKP:Table_Search(MonDKP_MinBids, core.BiddingWindow.itemName:GetText()) + local val = MonDKP:GetMinBid(loot); + + if not search and core.BiddingWindow.cost:GetNumber() ~= tonumber(val) then + tinsert(MonDKP_MinBids, {item=core.BiddingWindow.itemName:GetText(), minbid=core.BiddingWindow.cost:GetNumber()}) + core.BiddingWindow.CustomMinBid:SetShown(true); + core.BiddingWindow.CustomMinBid:SetChecked(true); + elseif search and core.BiddingWindow.cost:GetNumber() ~= tonumber(val) and core.BiddingWindow.CustomMinBid:GetChecked() == true then + if MonDKP_MinBids[search[1][1]].minbid ~= core.BiddingWindow.cost:GetText() then + MonDKP_MinBids[search[1][1]].minbid = MonDKP_round(core.BiddingWindow.cost:GetNumber(), MonDKP_DB.modes.rounding); + core.BiddingWindow.CustomMinBid:SetShown(true); + core.BiddingWindow.CustomMinBid:SetChecked(true); + end + end + + if search and core.BiddingWindow.CustomMinBid:GetChecked() == false then + table.remove(MonDKP_MinBids, search[1][1]) + core.BiddingWindow.CustomMinBid:SetShown(false); + end + end + + if mode == "Zero Sum" and not reassign then + MonDKP_DB.modes.ZeroSumBank.balance = MonDKP_DB.modes.ZeroSumBank.balance + -tonumber(cost) + table.insert(MonDKP_DB.modes.ZeroSumBank, { loot = loot, cost = -tonumber(cost) }) + MonDKP:ZeroSumBank_Update() + MonDKP.Sync:SendData("MonDKPZSumBank", MonDKP_DB.modes.ZeroSumBank) + end + core.BiddingWindow:Hide() + ClearBidWindow() + end + end +end + +local function AwardConfirm_Create() + local f = CreateFrame("Frame", "MonDKP_AwardWindowConfirm", UIParent, "ShadowOverlaySmallTemplate"); + + f:SetPoint("TOP", UIParent, "TOP", 0, -200); + f:SetSize(400, 230); + f:SetClampedToScreen(true) + f:SetBackdrop( { + bgFile = "Textures\\white.blp", tile = true, -- White backdrop allows for black background with 1.0 alpha on low alpha containers + edgeFile = "Interface\\AddOns\\MonolithDKP\\Media\\Textures\\edgefile.tga", tile = true, tileSize = 1, edgeSize = 3, + insets = { left = 0, right = 0, top = 0, bottom = 0 } + }); + f:SetBackdropColor(0,0,0,0.9); + f:SetBackdropBorderColor(1,1,1,1) + f:SetFrameStrata("DIALOG") + f:SetFrameLevel(15) + f:Hide() + + f.confirmHeader = f:CreateFontString(nil, "OVERLAY") + f.confirmHeader:SetFontObject("MonDKPLargeRight"); + f.confirmHeader:SetScale(0.9) + f.confirmHeader:SetPoint("TOPLEFT", f, "TOPLEFT", 15, -15); + f.confirmHeader:SetText(L["CONFAWARD"]) + + f.playerHeader = f:CreateFontString(nil, "OVERLAY") + f.playerHeader:SetFontObject("MonDKPLargeRight"); + f.playerHeader:SetScale(0.7) + f.playerHeader:SetPoint("TOPLEFT", f, "TOPLEFT", 120, -60); + f.playerHeader:SetText(L["PLAYER"]..":") + + f.player = CreateFrame("FRAME", "MonDKPAwardConfirmPlayerDropDown", f, "MonolithDKPUIDropDownMenuTemplate") + f.player:SetPoint("LEFT", f.playerHeader, "RIGHT", -15, 0) + UIDropDownMenu_SetWidth(f.player, 150) + UIDropDownMenu_JustifyText(f.player, "LEFT") + + + --[[f.player = f:CreateFontString(nil, "OVERLAY") + f.player:SetFontObject("MonDKPNormalLeft"); + f.player:SetPoint("LEFT", f.playerHeader, "RIGHT", 5, 1); + f.player:SetSize(200, 28);--]] + + f.lootHeader = f:CreateFontString(nil, "OVERLAY") + f.lootHeader:SetFontObject("MonDKPLargeRight"); + f.lootHeader:SetScale(0.7) + f.lootHeader:SetPoint("TOPRIGHT", f.playerHeader, "BOTTOMRIGHT", 0, -10); + f.lootHeader:SetText(L["ITEM"]..":") + + f.lootIcon = f:CreateTexture(nil, "OVERLAY", nil); + f.lootIcon:SetPoint("LEFT", f.lootHeader, "RIGHT", 5, 0); + f.lootIcon:SetColorTexture(0, 0, 0, 1) + f.lootIcon:SetSize(20, 20); + + f.loot = f:CreateFontString(nil, "OVERLAY") + f.loot:SetFontObject("MonDKPNormalLeft"); + f.loot:SetPoint("LEFT", f.lootIcon, "RIGHT", 5, 1); + f.loot:SetSize(200, 28); + + f.costHeader = f:CreateFontString(nil, "OVERLAY") + f.costHeader:SetFontObject("MonDKPLargeRight"); + f.costHeader:SetScale(0.7) + f.costHeader:SetPoint("TOPRIGHT", f.lootHeader, "BOTTOMRIGHT", 0, -10); + f.costHeader:SetText(L["ITEMCOST"]..":") + + f.cost = CreateFrame("EditBox", nil, f) + f.cost:SetAutoFocus(false) + f.cost:SetMultiLine(false) + f.cost:SetPoint("LEFT", f.costHeader, "RIGHT", 5, 0) + f.cost:SetSize(50, 22) + f.cost:SetBackdrop({ + bgFile = "Textures\\white.blp", tile = true, + edgeFile = "Interface\\ChatFrame\\ChatFrameBackground", tile = true, tileSize = 1, edgeSize = 2, + }); + f.cost:SetBackdropColor(0,0,0,0.9) + f.cost:SetBackdropBorderColor(0.12, 0.12, 0.34, 1) + f.cost:SetMaxLetters(10) + f.cost:SetTextColor(1, 1, 1, 1) + f.cost:SetFontObject("MonDKPSmallRight") + f.cost:SetTextInsets(10,10,0,0) + f.cost:SetScript("OnEscapePressed", function(self) -- clears focus on esc + self:ClearFocus() + end) + f.cost:SetScript("OnTabPressed", function(self) -- clears focus on tab + self:ClearFocus() + end) + f.cost:SetScript("OnEnterPressed", function(self) -- clears focus on enter + self:ClearFocus() + end) + + f.costFooter = f:CreateFontString(nil, "OVERLAY") + f.costFooter:SetFontObject("MonDKPNormalLeft"); + f.costFooter:SetPoint("LEFT", f.cost, "RIGHT", 5, 0); + f.costFooter:SetSize(200, 28); + + f.bossHeader = f:CreateFontString(nil, "OVERLAY") + f.bossHeader:SetFontObject("MonDKPLargeRight"); + f.bossHeader:SetScale(0.7) + f.bossHeader:SetPoint("TOPRIGHT", f.costHeader, "BOTTOMRIGHT", 0, -10); + f.bossHeader:SetText(L["BOSS"]..":") + + f.bossDropDown = CreateFrame("FRAME", "MonDKPAwardConfirmBossDropDown", f, "MonolithDKPUIDropDownMenuTemplate") + f.bossDropDown:SetPoint("LEFT", f.bossHeader, "RIGHT", -15, -2) + UIDropDownMenu_SetWidth(f.bossDropDown, 150) + UIDropDownMenu_JustifyText(f.bossDropDown, "LEFT") + + f.zoneHeader = f:CreateFontString(nil, "OVERLAY") + f.zoneHeader:SetFontObject("MonDKPLargeRight"); + f.zoneHeader:SetScale(0.7) + f.zoneHeader:SetPoint("TOPRIGHT", f.bossHeader, "BOTTOMRIGHT", 0, -10); + f.zoneHeader:SetText(L["ZONE"]..":") + + f.zoneDropDown = CreateFrame("FRAME", "MonDKPAwardConfirmBossDropDown", f, "MonolithDKPUIDropDownMenuTemplate") + f.zoneDropDown:SetPoint("LEFT", f.zoneHeader, "RIGHT", -15, -2) + UIDropDownMenu_SetWidth(f.zoneDropDown, 150) + UIDropDownMenu_JustifyText(f.zoneDropDown, "LEFT") + + f.yesButton = MonDKP:CreateButton("BOTTOMLEFT", f, "BOTTOMLEFT", 20, 15, L["CONFIRM"]); + f.noButton = MonDKP:CreateButton("BOTTOMRIGHT", f, "BOTTOMRIGHT", -20, 15, L["CANCEL"]); + + return f; +end + +function MonDKP:AwardConfirm(player, cost, boss, zone, loot, reassign) + local _,itemLink,_,_,_,_,_,_,_,itemIcon = GetItemInfo(loot) + local curBoss, curZone, player, cost = boss, zone, player, cost + local class, search; + local PlayerList = {}; + local curSelected = 0; + + if cost == 0 then + cost = MonDKP:GetMinBid(itemLink) + end + + if player then + search = MonDKP:Table_Search(MonDKP_DKPTable, player) + class = MonDKP:GetCColors(MonDKP_DKPTable[search[1][1]].class) + end + + for i=1, #MonDKP_DKPTable do + table.insert(PlayerList, MonDKP_DKPTable[i].player) + end + table.sort(PlayerList, function(a, b) + return a < b + end) + + PlaySound(850) + core.AwardConfirm = core.AwardConfirm or AwardConfirm_Create() + core.AwardConfirm:SetShown(not core.AwardConfirm:IsShown()) + + --core.AwardConfirm.player:SetText("|cff"..class.hex..player.."|r") + core.AwardConfirm.lootIcon:SetTexture(itemIcon) + core.AwardConfirm.loot:SetText(loot) + core.AwardConfirm.cost:SetNumber(cost) + core.AwardConfirm.cost:SetScript("OnKeyUp", function(self) + cost = self:GetNumber(); + end) + core.AwardConfirm.costFooter:SetText("DKP") + --core.AwardConfirm.boss:SetText(boss.." in "..zone) + + if player then + UIDropDownMenu_SetText(core.AwardConfirm.player, "|cff"..class.hex..player.."|r") + else + UIDropDownMenu_SetText(core.AwardConfirm.player, "") + end + + UIDropDownMenu_Initialize(core.AwardConfirm.player, function(self, level, menuList) + local filterName = UIDropDownMenu_CreateInfo() + local ranges = {1} + + while ranges[#ranges] < #PlayerList do + table.insert(ranges, ranges[#ranges]+20) + end + + if (level or 1) == 1 then + local numSubs = ceil(#PlayerList/20) + filterName.func = self.SetValue + + for i=1, numSubs do + local max = i*20; + if max > #PlayerList then max = #PlayerList end + filterName.text, filterName.checked, filterName.menuList, filterName.hasArrow = strsub(PlayerList[((i*20)-19)], 1, 1).."-"..strsub(PlayerList[max], 1, 1), curSelected >= (i*20)-19 and curSelected <= i*20, i, true + UIDropDownMenu_AddButton(filterName) + end + + else + filterName.func = self.SetValue + for i=ranges[menuList], ranges[menuList]+19 do + if PlayerList[i] then + local classSearch = MonDKP:Table_Search(MonDKP_DKPTable, PlayerList[i]) + local c; + + if classSearch then + c = MonDKP:GetCColors(MonDKP_DKPTable[classSearch[1][1]].class) + else + c = { hex="444444" } + end + filterName.text, filterName.arg1, filterName.arg2, filterName.checked, filterName.isNotRadio = "|cff"..c.hex..PlayerList[i].."|r", PlayerList[i], "|cff"..c.hex..PlayerList[i].."|r", PlayerList[i] == player, true + UIDropDownMenu_AddButton(filterName, level) + end + end + end + end) + + UIDropDownMenu_SetText(core.AwardConfirm.bossDropDown, curBoss) + UIDropDownMenu_Initialize(core.AwardConfirm.bossDropDown, function(self, level, menuList) -- BOSS dropdown + UIDropDownMenu_SetAnchor(core.AwardConfirm.bossDropDown, 10, 10, "TOPLEFT", core.AwardConfirm.bossDropDown, "BOTTOMLEFT") + --UIDropDownMenu_JustifyText(core.AwardConfirm.bossDropDown, "LEFT") + local reason = UIDropDownMenu_CreateInfo() + local tempNPCs = {}; + + table.insert(tempNPCs, core.LastKilledBoss) + + for k,v in pairs(core.LastKilledNPC) do -- eliminates duplicate zones + if not MonDKP:Table_Search(tempNPCs, v) then + table.insert(tempNPCs, v) + end + end + + reason.func = self.SetValue + + if not MonDKP:Table_Search(tempNPCs, curBoss) then + reason.text, reason.arg1, reason.checked, reason.isNotRadio = curBoss, curBoss, curBoss == curBoss, true + UIDropDownMenu_AddButton(reason) + end + + for i=1, #tempNPCs do + reason.text, reason.arg1, reason.checked, reason.isNotRadio = tempNPCs[i], tempNPCs[i], tempNPCs[i] == curBoss, true + UIDropDownMenu_AddButton(reason) + end + end) + + UIDropDownMenu_SetText(core.AwardConfirm.zoneDropDown, curZone) + UIDropDownMenu_Initialize(core.AwardConfirm.zoneDropDown, function(self, level, menuList) -- ZONE dropdown + UIDropDownMenu_SetAnchor(core.AwardConfirm.zoneDropDown, 10, 10, "TOPLEFT", core.AwardConfirm.zoneDropDown, "BOTTOMLEFT") + --UIDropDownMenu_JustifyText(core.AwardConfirm.bossDropDown, "LEFT") + local reason = UIDropDownMenu_CreateInfo() + local tempZones = {}; + + table.insert(tempZones, core.CurrentRaidZone) + + for k,v in pairs(core.RecentZones) do -- eliminates duplicate zones + if not MonDKP:Table_Search(tempZones, v) then + table.insert(tempZones, v) + end + end + + reason.func = self.SetValue + + for i=1, #tempZones do + reason.text, reason.arg1, reason.checked, reason.isNotRadio = tempZones[i], tempZones[i], tempZones[i] == curZone, true + UIDropDownMenu_AddButton(reason) + end + end) + + function core.AwardConfirm.player:SetValue(newValue, arg2) ---- PLAYER dropdown function + if player ~= newValue then player = newValue end + UIDropDownMenu_SetText(core.AwardConfirm.player, arg2) + CloseDropDownMenus() + end + + function core.AwardConfirm.bossDropDown:SetValue(newValue) ---- BOSS dropdown function + UIDropDownMenu_SetText(core.AwardConfirm.bossDropDown, newValue) + curBoss = newValue; + CloseDropDownMenus() + end + + function core.AwardConfirm.zoneDropDown:SetValue(newValue) ---- ZONE dropdown function + UIDropDownMenu_SetText(core.AwardConfirm.zoneDropDown, newValue) + curZone = newValue; + CloseDropDownMenus() + end + + core.AwardConfirm.yesButton:SetScript("OnClick", function() -- Run when "Yes" is clicked + if not player then + StaticPopupDialogs["AWARD_VALIDATE"] = { + text = L["PLAYERVALIDATE"], + button1 = L["OK"], + timeout = 0, + whileDead = true, + hideOnEscape = true, + preferredIndex = 3, + } + StaticPopup_Show ("AWARD_VALIDATE") + else + if reassign then + AwardItem(player, cost, curBoss, curZone, loot, reassign) + else + AwardItem(player, cost, curBoss, curZone, loot) + end + + core.AwardConfirm:SetShown(false) + end + + PlaySound(851) + end) + core.AwardConfirm.noButton:SetScript("OnClick", function() -- Run when "No" is clicked + PlaySound(851) + core.AwardConfirm:SetShown(false) + end) end \ No newline at end of file diff --git a/Modules/RaidTimer.lua b/Modules/RaidTimer.lua index 5e740f5c..c211efe8 100644 --- a/Modules/RaidTimer.lua +++ b/Modules/RaidTimer.lua @@ -32,71 +32,6 @@ function SecondsToClock(seconds) end end -function MonDKP:AwardPlayer(name, amount) - local search = MonDKP:Table_Search(MonDKP_DKPTable, name, "player") - local path; - - if search then - path = MonDKP_DKPTable[search[1][1]] - path.dkp = path.dkp + amount - path.lifetime_gained = path.lifetime_gained + amount; - end -end - -local function AwardRaid(amount, reason) - if UnitAffectingCombat("player") then - C_Timer.After(5, function() AwardRaid(amount, reason) end) - return; - end - - local tempName - local tempList = ""; - local curTime = time(); - local curOfficer = UnitName("player") - - for i=1, 40 do - local tempName, _rank, _subgroup, _level, _class, _fileName, zone, online = GetRaidRosterInfo(i) - local search_DKP = MonDKP:Table_Search(MonDKP_DKPTable, tempName) - local OnlineOnly = MonDKP_DB.modes.OnlineOnly - local limitToZone = MonDKP_DB.modes.SameZoneOnly - local isSameZone = zone == GetRealZoneText() - - if search_DKP and (not OnlineOnly or online) and (not limitToZone or isSameZone) then - MonDKP:AwardPlayer(tempName, amount) - tempList = tempList..tempName..","; - end - end - - if #MonDKP_Standby > 0 and MonDKP_DB.DKPBonus.IncStandby then - local i = 1 - - while i <= #MonDKP_Standby do - if strfind(tempList, MonDKP_Standby[i].player) then - table.remove(MonDKP_Standby, i) - else - MonDKP:AwardPlayer(MonDKP_Standby[i].player, amount) - tempList = tempList..MonDKP_Standby[i].player..","; - i=i+1 - end - end - end - - if tempList ~= "" then - local newIndex = curOfficer.."-"..curTime - tinsert(MonDKP_DKPHistory, 1, {players=tempList, dkp=amount, reason=reason, date=curTime, index=newIndex}) - - if MonDKP.ConfigTab6.history and MonDKP.ConfigTab6:IsShown() then - MonDKP:DKPHistory_Update(true) - end - DKPTable_Update() - - MonDKP.Sync:SendData("MonDKPDKPDist", MonDKP_DKPHistory[1]) - - MonDKP.Sync:SendData("MonDKPBCastMsg", L["RAIDDKPADJUSTBY"].." "..amount.." "..L["FORREASON"]..": "..reason) - MonDKP:Print(L["RAIDDKPADJUSTBY"].." "..amount.." "..L["FORREASON"]..": "..reason) - end -end - function MonDKP:StopRaidTimer() if MonDKP.RaidTimer then MonDKP.RaidTimer:SetScript("OnUpdate", nil) @@ -118,7 +53,7 @@ function MonDKP:StopRaidTimer() if IsInRaid() and MonDKP:CheckRaidLeader() and core.IsOfficer then if MonDKP_DB.DKPBonus.GiveRaidEnd then -- Award Raid Completion Bonus - AwardRaid(MonDKP_DB.DKPBonus.CompletionBonus, L["RAIDCOMPLETIONBONUS"]) + MonDKP:AwardRaid(true, MonDKP_DB.DKPBonus.IncStandby, MonDKP_DB.DKPBonus.CompletionBonus, L["RAIDCOMPLETIONBONUS"]) totalAwarded = totalAwarded + tonumber(MonDKP_DB.DKPBonus.CompletionBonus); MonDKP.ConfigTab2.RaidTimerContainer.Bonus:SetText("|cff00ff00"..totalAwarded.."|r") end @@ -170,7 +105,7 @@ function MonDKP:StartRaidTimer(pause, syncTimer, syncSecondCount, syncMinuteCoun if IsInRaid() and MonDKP:CheckRaidLeader() and not pause and core.IsOfficer then if not StartAwarded and MonDKP_DB.DKPBonus.GiveRaidStart then -- Award On Time Bonus - AwardRaid(MonDKP_DB.DKPBonus.OnTimeBonus, L["ONTIMEBONUS"]) + MonDKP:AwardRaid(true, MonDKP_DB.DKPBonus.IncStandby, MonDKP_DB.DKPBonus.OnTimeBonus, L["ONTIMEBONUS"]) StartBonus = MonDKP_DB.DKPBonus.OnTimeBonus; StartAwarded = true; end @@ -236,7 +171,7 @@ function MonDKP:StartRaidTimer(pause, syncTimer, syncSecondCount, syncMinuteCoun MonDKP.ConfigTab2.RaidTimerContainer.Bonus:SetText("|cff00ff00"..totalAwarded.."|r"); if IsInRaid() and MonDKP:CheckRaidLeader() then - AwardRaid(MonDKP_DB.DKPBonus.IntervalBonus, L["TIMEINTERVALBONUS"]) + MonDKP:AwardRaid(true, MonDKP_DB.DKPBonus.IncStandby, MonDKP_DB.DKPBonus.IntervalBonus, L["TIMEINTERVALBONUS"]) end end end) diff --git a/Modules/Standby.lua b/Modules/Standby.lua index f6243b2a..fa109e8b 100644 --- a/Modules/Standby.lua +++ b/Modules/Standby.lua @@ -24,7 +24,7 @@ function MonDKP_Standby_Announce(bossName) if MonDKP:CheckRaidLeader() then SendChatMessage(L["STANDBYOPTINEND"]..bossName, "GUILD") -- only raid leader announces if MonDKP_DB.DKPBonus.AutoIncStandby then - MonDKP:AutoAward(2, MonDKP_DB.DKPBonus.BossKillBonus, MonDKP_DB.bossargs.CurrentRaidZone..": "..MonDKP_DB.bossargs.LastKilledBoss) + MonDKP:AwardRaid(false, true, MonDKP_DB.DKPBonus.BossKillBonus, MonDKP_DB.bossargs.CurrentRaidZone..": "..MonDKP_DB.bossargs.LastKilledBoss) end end end) diff --git a/MonolithDKP.toc b/MonolithDKP.toc index 71489bea..7bbe28ef 100644 --- a/MonolithDKP.toc +++ b/MonolithDKP.toc @@ -21,13 +21,13 @@ Modules\comm.lua Modules\Standby.lua Modules\Bidding.lua MonolithDKP.lua -Modules\AutoAward.lua +Modules\AwardItem.lua init.lua Localization\Localization.lua Modules\LootHistory.lua Modules\DKPHistory.lua ConfigMenuTabs.lua -Modules\Award.lua +Modules\AwardDKP.lua Modules\AdjustDKP.lua Modules\ManageEntries.lua Modules\ClassGraph.lua diff --git a/init.lua b/init.lua index b2ee9203..2df13357 100644 --- a/init.lua +++ b/init.lua @@ -196,10 +196,10 @@ function MonDKP_OnEvent(self, event, arg1, ...) end if MonDKP_DB.modes.AutoAward then - if not MonDKP_DB.modes.StandbyOptIn and MonDKP_DB.DKPBonus.IncStandby then - MonDKP:AutoAward(3, MonDKP_DB.DKPBonus.BossKillBonus, MonDKP_DB.bossargs.CurrentRaidZone..": "..MonDKP_DB.bossargs.LastKilledBoss) + if not MonDKP_DB.modes.StandbyOptIn and MonDKP_DB.DKPBonus.AutoIncStandby then + MonDKP:AwardRaid(true, true, MonDKP_DB.DKPBonus.BossKillBonus, MonDKP_DB.bossargs.CurrentRaidZone..": "..MonDKP_DB.bossargs.LastKilledBoss) else - MonDKP:AutoAward(1, MonDKP_DB.DKPBonus.BossKillBonus, MonDKP_DB.bossargs.CurrentRaidZone..": "..MonDKP_DB.bossargs.LastKilledBoss) + MonDKP:AwardRaid(true, false, MonDKP_DB.DKPBonus.BossKillBonus, MonDKP_DB.bossargs.CurrentRaidZone..": "..MonDKP_DB.bossargs.LastKilledBoss) end end else