view Looting.lua @ 74:15844864a5f7

Admin mode
author John@Doomsday
date Mon, 09 Apr 2012 09:40:14 -0400
parents 7eb2963eea7d
children 39be9328acd0
line wrap: on
line source
local bsk=bsk
local _G=_G
local table=table 
local pairs=pairs
local setmetatable=setmetatable
local ipairs=ipairs
local string=string
local sformat=string.format
local tostring=tostring
local type=type
local getn=getn

local event = LibStub("AceEvent-3.0")

setfenv(1,bsk)

local isMasterLootEvent = false

local function OpenMasterLootList()
    print("Open!")
    isMasterLootEvent = true
end

local function UpdateMasterLootList()
    print("Update MLL!")
end

local function LootClosed()
    print("Close!")
    if isMasterLootEvent then
        isMasterLootEvent = false -- end the event
        InitiateCloseLooting()
    end
end

local function LootOpened()
    print("Open loot!")
    isMasterLootEvent = false
    local n = _G.GetNumLootItems()
    for i = 1,n do
        _G.LootSlot(i)
    end
    local items = {}
    for i = 1,n do
        local link = _G.GetLootSlotLink(i)
        if link then
            table.insert(items,link)
            print("Item: ", link)
        end
    end
    if not isMasterLootEvent then return end

    print("Let's get started SKing")
    -- todo: check that I am ML and that I'm an admin!

    -- make state: gather all item links, transmit them plus the new looting
    -- state
    --
    InitiateBeginLoot(items,stateactivelist)

end

function InitializeLooting()
    event:RegisterEvent("OPEN_MASTER_LOOT_LIST",OpenMasterLootList)
    event:RegisterEvent("UPDATE_MASTER_LOOT_LIST",UpdateMasterLootList)
    event:RegisterEvent("LOOT_CLOSED",LootClosed)
    event:RegisterEvent("LOOT_OPENED",LootOpened)
end