0
-local dewdrop = AceLibrary("Dewdrop-2.0")
0
-local tablet = AceLibrary("Tablet-2.0")
0
-local colorneed, colorgreed, colorpass = "|cffff0000", "|cffffff00", "|cffdddddd"
0
-local tokens, rolls, openrolls = {}, {}, 0
0
- greens = {"ahnqirajscarab", "zulgurubcoin"},
0
- blues = {"ahnqirajidol20", "ahnqirajidol40", "zulgurubbijou"},
0
- ["Ruins of Ahn'Qiraj"] = true,
0
-local _, _, _, qualgreen = GetItemQualityColor(2)
0
-local _, _, _, qualblue = GetItemQualityColor(3)
0
-local tokenformat1 = qualgreen.. "%s/%s ".. qualblue.. "%s/%s|r | "
0
-local tokenformat2 = string.format("%sGreen Tokens: %s|r", qualgreen, "%s/%s")
0
-local tokenformat3 = string.format("%sBlue Tokens: %s|r", qualblue, "%s/%s")
0
- pass = "passed on: (.+)",
0
- greed = "has selected Greed for: (.+)",
0
- need = "has selected Need for: (.+)",
0
- selfpass = "You passed on: (.+)",
0
- selfgreed = "You have selected Greed for: (.+)",
0
- selfneed = "You have selected Need for: (.+)",
0
- allpass = "Everyone passed on: (.+)",
0
- won = "(.+) won: (.+)",
0
- receive = "(.+) receives? loot: (.+).",
0
- [strings.pass] = "pass",
0
- [strings.greed] = "greed",
0
- [strings.need] = "need",
0
- [strings.selfpass] = "pass",
0
- [strings.selfgreed] = "greed",
0
- [strings.selfneed] = "need",
0
-FuBar_GreedBeacon = AceLibrary("AceAddon-2.0"):new("AceHook-2.1", "AceEvent-2.0", "AceConsole-2.0", "AceDB-2.0", "AceDebug-2.0", "FuBarPlugin-2.0")
0
-FuBar_GreedBeacon.tooltipHiddenWhenEmpty = true
0
-FuBar_GreedBeacon:RegisterDB("FuBar_GreedBeaconDB")
0
-FuBar_GreedBeacon:RegisterDefaults("profile", {chat = false})
0
-function FuBar_GreedBeacon:OnEnable()
0
- self:RegisterEvent("CHAT_MSG_LOOT")
0
- self:SecureHook("GroupLootFrame_OpenNewFrame")
0
- self:SecureHook("RollOnLoot")
0
-function FuBar_GreedBeacon:RollOnLoot(rollid, roll)
0
- openrolls = openrolls - 1
0
-function FuBar_GreedBeacon:GroupLootFrame_OpenNewFrame(rollid, rollTime)
0
- openrolls = openrolls + 1
0
- table.insert(rolls, 1, {id = rollid, link = GetLootRollItemLink(rollid), greed = 0, need = 0, pass = 0})
0
-local gii = GetItemInfo
0
-local GetItemInfo = function(id)
0
- if type(id) == "number" then return gii(id)
0
- elseif type(id) == "string" then
0
- local i = tonumber(id)
0
- if i then return gii(i) end
0
- local _, _, itemid = string.find(id, "item:(%d+)")
0
- if itemid then return gii(itemid) end
0
+local colorneed, colorgreed = "|cffff0000", "|cffffff00"
0
+local coloredwords = {Greed = colorgreed.."Greed", Need = colorneed.."Need"}
0
-function FuBar_GreedBeacon:FindRollIndex(itemlink, hasWinner, allpass)
0
- for i,val in ipairs(rolls) do
0
- if (val.link == itemlink) and ((hasWinner and val.winner) or (hasWinner == false and not val.winner) or (hasWinner == nil)) then
0
- for i,val in ipairs(rolls) do
0
- if (val.link == itemlink) and val.winner and val.winner == "Pass" then
0
+local function FindRoll(link, player, hasselected, hasrolled)
0
+ for i,roll in ipairs(rolls) do
0
+ if roll._link == link and not roll._winner and (not roll[player] or hasselected) then return roll, i end
0
+ local newroll = {_link = link}
0
+ table.insert(rolls, newroll)
0
+ return newroll, #rolls
0
-function FuBar_GreedBeacon:CHAT_MSG_LOOT(msg)
0
- local itemname, winner = self:ParseLootPickup(msg)
0
- if itemname and winner then return self:StoreWinner(itemname, winner)
0
- local itemname, rolltype = self:ParseRollChoice(msg)
0
- if itemname and rolltype then
0
- local i = self:FindRollIndex(itemname, false)
0
- if not i then return end
0
- rolls[i][rolltype] = rolls[i][rolltype] + 1
0
+local function FindUnprintedRoll(link, player)
0
+ for i,roll in ipairs(rolls) do
0
+ if roll._link == link and roll[player] and (roll._printed or 0) < 7 then
0
+ roll._printed = (roll._printed or 0) + 1
0
-function FuBar_GreedBeacon:ParseRollChoice(msg)
0
- for i,v in pairs(rollpairs) do
0
- local _, _, itemname = string.find(msg, i)
0
- if itemname then return itemname, v end
0
-function FuBar_GreedBeacon:ParseLootPickup(msg)
0
- if GetNumPartyMembers() == 0 and GetNumRaidMembers() == 0 then return end
0
- local _, _, itemname = string.find(msg, strings.allpass)
0
- if itemname then return itemname, "Pass" end
0
- _, _, playername, itemname = string.find(msg, strings.receive)
0
- if playername and itemname then
0
- playername = (playername == "You" and UnitName("player")) or playername
0
- local _, _, qual = GetItemInfo(itemname)
0
- if qual and qual >= GetLootThreshold() then return itemname, playername end
0
-function FuBar_GreedBeacon:StoreWinner(itemname, winner)
0
- local i = self:FindRollIndex(itemname, false, true)
0
- table.insert(rolls, 1, {winner = winner, need = 0, greed = 0, pass = 0, link = itemname})
0
+local f = CreateFrame("Frame")
0
+f:RegisterEvent("CHAT_MSG_LOOT")
0
+f:SetScript("OnEvent", function(self, event, msg)
0
+ local rolltype, rollval, link, player = msg:match("(.+) Roll %- (%d+) for (.+) by (.+)")
0
+ local roll, i = FindRoll(link, player, true)
0
+ roll[player] = (rolltype == "Need" and colorneed or colorgreed)..rollval
0
- if PeriodicTable:ItemInSet(itemname, tokensets.greens) then
0
- tokens.greentotal = (tokens.greentotal or 0) + 1
0
- if winner == UnitName("player") then tokensgreenme = (tokensgreenme or 0) + 1 end
0
- elseif PeriodicTable:ItemInSet(itemname, tokensets.blues) then
0
- tokens.bluetotal = (tokens.bluetotal or 0) + 1
0
- if winner == UnitName("player") then tokens.blueme = (tokens.blueme or 0) + 1 end
0
+ local player, selection, link = msg:match("(.*) has selected (.+) for: (.+)")
0
+ FindRoll(link, player)[player] = coloredwords[selection]
0
- rolls[i].winner = winner
0
-function FuBar_GreedBeacon:UseTokenData()
0
- return self.db.profile.showtokentracker and rolls[1] and tokenzones[GetRealZoneText()]
0
-function FuBar_GreedBeacon:OnTextUpdate()
0
- for i,val in ipairs(rolls) do
0
- if not idx and not val.winner then idx = i end
0
- if not idx and rolls[1] then idx = 1 end
0
- local toks = self:UseTokenData() and string.format(tokenformat1, (tokensgreenme or 0), (tokens.greentotal or 0), (tokens.blueme or 0), (tokens.bluetotal or 0)) or ""
0
- local val = rolls[idx]
0
- local color = ((val.need > 0) and colorneed or (val.greed > 0) and colorgreed or colorpass)
0
- str = string.format("%s%s %s%s", toks, self.db.profile.supressitem and "" or val.link, color, val.winner)
0
- str = string.format("%s%s %s%d %s%d %s%d", toks, self.db.profile.supressitem and "" or val.link, colorneed, val.need, colorgreed, val.greed, colorpass, val.pass)
0
+ local player, link = msg:match("(.*) won: (.+)")
0
+ local roll, i = FindRoll(link, player, true, true)
0
- self:SetText(str or "No Item")
0
-function FuBar_GreedBeacon:OnTooltipUpdate()
0
- local det = self:IsTooltipDetached()
0
- if openrolls < 1 and det then return end
0
- local cat = tablet:AddCategory("columns", 2)
0
- if self:UseTokenData() then
0
- local gtoks = string.format(tokenformat2, (tokensgreenme or 0), (tokens.greentotal or 0))
0
- local btoks = string.format(tokenformat3, (tokens.blueme or 0), (tokens.bluetotal or 0))
0
- cat:AddLine("text", gtoks, "text2", btoks)
0
+local orig1 = ChatFrame_MessageEventHandler
0
+function ChatFrame_MessageEventHandler(event, ...)
0
+ if event == "CHAT_MSG_LOOT" then
0
+--~ if arg1:match(" has selected .+ for: ") or (arg1:match(" passed on: ") and not arg1:match("Everyone passed on: ")) then return end
0
- cat = tablet:AddCategory("columns", 4)
0
- for _,val in ipairs(rolls) do
0
- if not det or not val.winner then
0
- local color = val.winner and ((val.need > 0) and colorneed or (val.greed > 0) and colorgreed or colorpass) or ""
0
- cat:AddLine("text", val.id or "--", "text2", val.link, "text3", color..(val.winner or ""),
0
- "text4", string.format("%s%d %s%d %s%d", colorneed, val.need, colorgreed, val.greed, colorpass, val.pass))
0
+ local player, link = arg1:match("(.*) won: (.+)")
0
+ local roll, i = FindUnprintedRoll(link, player, true, true)
0
+ arg1 = string.format("%s|Hgreedbeacon:%d|h[%s roll]|h|r %s won %s ", roll._type == "Need" and colorneed or colorgreed, 1, roll._type, player, link)
0
+ return orig1(event, ...)
0
-function FuBar_GreedBeacon:MenuSettings()
0
- dewdrop:AddLine("text", "Clear list","func", function()
0
- rolls, tokens = {}, {}
0
+local orig2 = SetItemRef
0
+function SetItemRef(link, text, button)
0
+ local id = link:match("greedbeacon:(%d+)")
0
+ ShowUIPanel(ItemRefTooltip)
0
+ if not ItemRefTooltip:IsShown() then ItemRefTooltip:SetOwner(UIParent, "ANCHOR_PRESERVE") end
0
- dewdrop:AddLine("text", "Use token tracker", "func", function() self:ToggleOption("showtokentracker") end, "checked", self.db.profile.showtokentracker)
0
- dewdrop:AddLine("text", "Show item on bar", "func", function() self:ToggleOption("supressitem") end, "checked", not self.db.profile.supressitem)
0
+ local i = tonumber(id)
0
+ ItemRefTooltip:ClearLines()
0
+ ItemRefTooltip:AddLine(coloredwords[val._type].." roll|r - "..val._link)
0
+ ItemRefTooltip:AddDoubleLine("Winner:", "|cffffffff"..val._winner)
0
+ for i,v in pairs(val) do if string.sub(i, 1, 1) ~= "_" then ItemRefTooltip:AddDoubleLine(i, v) end end
0
+ else return orig2(link, text, button) end
0
-function FuBar_GreedBeacon:ToggleOption(var)
0
- self.db.profile[var] = not self.db.profile[var]
0
+--~ local oe = f:GetScript("OnEvent")
0
+--~ local function e(event, a1)
0
+--~ this, event, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9 = ChatFrame1, event, a1, nil, nil, ""
0
+--~ ChatFrame_MessageEventHandler(event)
0
+--~ local name, link = GetItemInfo(6948)
0
+--~ e("CHAT_MSG_LOOT", "Bob has selected Greed for: "..link)
0
+--~ e("CHAT_MSG_LOOT", "Joe has selected Need for: "..link)
0
+--~ e("CHAT_MSG_LOOT", "Mary has selected Need for: "..link)
0
+--~ e("CHAT_MSG_LOOT", "Jane passed on: "..link)
0
+--~ e("CHAT_MSG_LOOT", "Need Roll - 56 for "..link.." by Joe")
0
+--~ e("CHAT_MSG_LOOT", "Need Roll - 5 for "..link.." by Mary")
0
+--~ e("CHAT_MSG_LOOT", "Joe won: "..link)
Comments
No one has commented yet.