John@73: local bsk=bsk John@73: local _G=_G John@73: local table=table John@73: local pairs=pairs John@73: local setmetatable=setmetatable John@73: local ipairs=ipairs John@73: local string=string John@73: local sformat=string.format John@73: local tostring=tostring John@73: local type=type John@73: local getn=getn John@73: John@73: local event = LibStub("AceEvent-3.0") John@73: John@73: setfenv(1,bsk) John@73: John@73: local isMasterLootEvent = false John@73: John@73: local function OpenMasterLootList() John@73: print("Open!") John@73: isMasterLootEvent = true John@73: end John@73: John@73: local function UpdateMasterLootList() John@73: print("Update MLL!") John@73: end John@73: John@73: local function LootClosed() John@73: print("Close!") John@73: if isMasterLootEvent then John@73: isMasterLootEvent = false -- end the event John@73: InitiateCloseLooting() John@73: end John@73: end John@73: John@73: local function LootOpened() John@73: print("Open loot!") John@73: isMasterLootEvent = false John@73: local n = _G.GetNumLootItems() John@73: for i = 1,n do John@73: _G.LootSlot(i) John@73: end John@73: local items = {} John@73: for i = 1,n do John@73: local link = _G.GetLootSlotLink(i) John@73: if link then John@78: table.insert(items,{link=link,mlid=i}) John@78: print("Item: ", link, i) John@73: end John@73: end John@73: if not isMasterLootEvent then return end John@73: John@73: print("Let's get started SKing") John@73: -- todo: check that I am ML and that I'm an admin! John@73: John@73: InitiateBeginLoot(items,stateactivelist) John@73: end John@73: John@76: function FreeLoot(item,person) John@76: PrintTable(item) John@76: PrintTable(person) John@76: for ci = 1, 40 do John@76: if _G.GetMasterLootCandidate(ci) == person.textPlain then John@78: print("GML",item.mlid,ci) John@78: _G.GiveMasterLoot(item.mlid, ci) John@76: return true John@76: end John@76: end John@76: John@76: print("Could not assign loot to ", person.textPlain) John@76: end John@76: John@76: function ExpensiveLoot(item,lref) John@76: if getn(statebids) > 0 then John@76: if FreeLoot(item,statebids[1]) then John@76: lref:SuicidePerson(statebids[1].value) John@76: else John@76: printf("Could not suicide %s for item; they are ineligible or offline",statebids[1].textPlain) John@76: end John@76: return John@76: end John@76: if getn(staterolls) > 0 then John@76: if FreeLoot(item,staterolls[1]) then John@76: lref:SuicidePerson(staterolls[1].value) John@76: else John@76: printf("Could not suicide %s for item; they are ineligible or offline",staterolls[1].textPlain) John@76: end John@76: return John@76: end John@76: _G.error("Trying to suicide+loot without bids or rolls") John@76: end John@76: John@78: function DirectSuicideLoot(item,person,lref) John@78: if FreeLoot(item,person) then John@78: lref:SuicidePerson(person.value) John@78: else John@78: printf("Could not suicide %s for item; they are ineligible or offline", person.textPlain) John@78: end John@78: end John@78: John@73: function InitializeLooting() John@73: event:RegisterEvent("OPEN_MASTER_LOOT_LIST",OpenMasterLootList) John@73: event:RegisterEvent("UPDATE_MASTER_LOOT_LIST",UpdateMasterLootList) John@73: event:RegisterEvent("LOOT_CLOSED",LootClosed) John@73: event:RegisterEvent("LOOT_OPENED",LootOpened) John@76: John@76: -- todo: what are these John@76: event:RegisterEvent("LOOT_SLOT_CLEARED",function() print("LSCleared") end) John@76: event:RegisterEvent("LOOT_SLOT_CHANGED",function() print("LSChanged") end) John@73: end John@73: