annotate Looting.lua @ 77:0a3f590f69e6

Update todo list Helper function to print list status
author John@Yosemite-PC
date Thu, 12 Apr 2012 22:18:05 -0400
parents 39be9328acd0
children 5b507f4125d4
rev   line source
John@73 1 local bsk=bsk
John@73 2 local _G=_G
John@73 3 local table=table
John@73 4 local pairs=pairs
John@73 5 local setmetatable=setmetatable
John@73 6 local ipairs=ipairs
John@73 7 local string=string
John@73 8 local sformat=string.format
John@73 9 local tostring=tostring
John@73 10 local type=type
John@73 11 local getn=getn
John@73 12
John@73 13 local event = LibStub("AceEvent-3.0")
John@73 14
John@73 15 setfenv(1,bsk)
John@73 16
John@73 17 local isMasterLootEvent = false
John@73 18
John@73 19 local function OpenMasterLootList()
John@73 20 print("Open!")
John@73 21 isMasterLootEvent = true
John@73 22 end
John@73 23
John@73 24 local function UpdateMasterLootList()
John@73 25 print("Update MLL!")
John@73 26 end
John@73 27
John@73 28 local function LootClosed()
John@73 29 print("Close!")
John@73 30 if isMasterLootEvent then
John@73 31 isMasterLootEvent = false -- end the event
John@73 32 InitiateCloseLooting()
John@73 33 end
John@73 34 end
John@73 35
John@73 36 local function LootOpened()
John@73 37 print("Open loot!")
John@73 38 isMasterLootEvent = false
John@73 39 local n = _G.GetNumLootItems()
John@73 40 for i = 1,n do
John@73 41 _G.LootSlot(i)
John@73 42 end
John@73 43 local items = {}
John@73 44 for i = 1,n do
John@73 45 local link = _G.GetLootSlotLink(i)
John@73 46 if link then
John@73 47 table.insert(items,link)
John@73 48 print("Item: ", link)
John@73 49 end
John@73 50 end
John@73 51 if not isMasterLootEvent then return end
John@73 52
John@73 53 print("Let's get started SKing")
John@73 54 -- todo: check that I am ML and that I'm an admin!
John@73 55
John@73 56 -- make state: gather all item links, transmit them plus the new looting
John@73 57 -- state
John@73 58 --
John@73 59 InitiateBeginLoot(items,stateactivelist)
John@73 60
John@73 61 end
John@73 62
John@76 63 function FreeLoot(item,person)
John@76 64 PrintTable(item)
John@76 65 PrintTable(person)
John@76 66 for ci = 1, 40 do
John@76 67 if _G.GetMasterLootCandidate(ci) == person.textPlain then
John@76 68 print("GML",item.value,ci)
John@76 69 _G.GiveMasterLoot(item.value, ci)
John@76 70 return true
John@76 71 end
John@76 72 end
John@76 73
John@76 74 print("Could not assign loot to ", person.textPlain)
John@76 75 end
John@76 76
John@76 77 function ExpensiveLoot(item,lref)
John@76 78 local person
John@76 79 if getn(statebids) > 0 then
John@76 80 if FreeLoot(item,statebids[1]) then
John@76 81 lref:SuicidePerson(statebids[1].value)
John@76 82 else
John@76 83 printf("Could not suicide %s for item; they are ineligible or offline",statebids[1].textPlain)
John@76 84 end
John@76 85 return
John@76 86 end
John@76 87 if getn(staterolls) > 0 then
John@76 88 if FreeLoot(item,staterolls[1]) then
John@76 89 lref:SuicidePerson(staterolls[1].value)
John@76 90 else
John@76 91 printf("Could not suicide %s for item; they are ineligible or offline",staterolls[1].textPlain)
John@76 92 end
John@76 93 return
John@76 94 end
John@76 95 _G.error("Trying to suicide+loot without bids or rolls")
John@76 96 end
John@76 97
John@73 98 function InitializeLooting()
John@73 99 event:RegisterEvent("OPEN_MASTER_LOOT_LIST",OpenMasterLootList)
John@73 100 event:RegisterEvent("UPDATE_MASTER_LOOT_LIST",UpdateMasterLootList)
John@73 101 event:RegisterEvent("LOOT_CLOSED",LootClosed)
John@73 102 event:RegisterEvent("LOOT_OPENED",LootOpened)
John@76 103
John@76 104 -- todo: what are these
John@76 105 event:RegisterEvent("LOOT_SLOT_CLEARED",function() print("LSCleared") end)
John@76 106 event:RegisterEvent("LOOT_SLOT_CHANGED",function() print("LSChanged") end)
John@73 107 end
John@73 108