Mercurial > wow > breuesk
diff Looting.lua @ 81:62805e6b46c5
Fleshing out the UI for those without the addon. Announcements in the raid, bidding via whisper.
author | John@Yosemite-PC |
---|---|
date | Fri, 13 Apr 2012 22:09:17 -0400 |
parents | 7b8fcea357d2 |
children | db7e4ee34dce |
line wrap: on
line diff
--- a/Looting.lua Fri Apr 13 00:02:56 2012 -0400 +++ b/Looting.lua Fri Apr 13 22:09:17 2012 -0400 @@ -54,6 +54,13 @@ -- todo: check that I am ML and that I'm an admin! InitiateBeginLoot(items,stateactivelist) + + local chan -- todo: idiom + if _G.GetNumRaidMembers() > 0 then chan = "RAID" else chan = "PARTY" end + _G.SendChatMessage("The following items are available -",chan) + for i,v in pairs(items) do + _G.SendChatMessage(v.link,chan) + end end function FreeLoot(item,person) @@ -73,7 +80,12 @@ function ExpensiveLoot(item,lref) if getn(statebids) > 0 then if FreeLoot(item,statebids[1]) then + local chan -- todo: idiom + if _G.GetNumRaidMembers() > 0 then chan = "RAID" else chan = "PARTY" end + _G.SendChatMessage(sformat("Awarding %s to %s!",item.link,statebids[1].textPlain),chan) + --_G.SendChatMessage(sformat("Awarding %s to %s!",item.link,statebids[1].textPlain),"GUILD") -- todo: enable lref:SuicidePerson(statebids[1].value) + InitiateCloseBidding() else printf("Could not suicide %s for item; they are ineligible or offline",statebids[1].textPlain) end @@ -81,7 +93,10 @@ end if getn(staterolls) > 0 then if FreeLoot(item,staterolls[1]) then - --lref:SuicidePerson(staterolls[1].value) + local chan -- todo: idiom + if _G.GetNumRaidMembers() > 0 then chan = "RAID" else chan = "PARTY" end + _G.SendChatMessage(sformat("Awarding %s to %s!",item.link,staterolls[1].textPlain),chan) + InitiateCloseBidding() else printf("Could not suicide %s for item; they are ineligible or offline",staterolls[1].textPlain) end @@ -98,6 +113,42 @@ end end +function WhisperReceived(...) + local _,message,sender = ... + local senderAction = function(func) + local le = PersonList:Select(sender) + if le then + local person = ConvertLe2Line(le) + if person then + func(person) + end + end + end + + if state == "bidding" and admin then -- todo: should only be ML + message = _G.strtrim(message) + message = _G.strlower(message) + if message == "bid" then + senderAction(InitiateBid) + elseif message == "retract" then + senderAction(InitiateRetract) + elseif message == "roll" then + senderAction(InitiateRollRequest) + end + end +end + +local statelistener = +{ + ["StateEvent"] = function(self) + if state == "bidding" then + event:RegisterEvent("CHAT_MSG_WHISPER", WhisperReceived) + else + --event:UnregisterEvent("CHAT_MSG_WHISPER") -- todo + end + end, +} + function InitializeLooting() event:RegisterEvent("OPEN_MASTER_LOOT_LIST",OpenMasterLootList) event:RegisterEvent("UPDATE_MASTER_LOOT_LIST",UpdateMasterLootList) @@ -107,5 +158,8 @@ -- todo: what are these event:RegisterEvent("LOOT_SLOT_CLEARED",function() print("LSCleared") end) event:RegisterEvent("LOOT_SLOT_CHANGED",function() print("LSChanged") end) + + RegisterListenerStateChange(statelistener) + statelistener:StateEvent() end