annotate Looting.lua @ 80:40c882db34f8

Notes
author John@Yosemite-PC
date Fri, 13 Apr 2012 00:02:56 -0400
parents 7b8fcea357d2
children 62805e6b46c5
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@78 47 table.insert(items,{link=link,mlid=i})
John@78 48 print("Item: ", link, i)
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 InitiateBeginLoot(items,stateactivelist)
John@73 57 end
John@73 58
John@76 59 function FreeLoot(item,person)
John@76 60 PrintTable(item)
John@76 61 PrintTable(person)
John@76 62 for ci = 1, 40 do
John@76 63 if _G.GetMasterLootCandidate(ci) == person.textPlain then
John@78 64 print("GML",item.mlid,ci)
John@78 65 _G.GiveMasterLoot(item.mlid, ci)
John@76 66 return true
John@76 67 end
John@76 68 end
John@76 69
John@76 70 print("Could not assign loot to ", person.textPlain)
John@76 71 end
John@76 72
John@76 73 function ExpensiveLoot(item,lref)
John@76 74 if getn(statebids) > 0 then
John@76 75 if FreeLoot(item,statebids[1]) then
John@76 76 lref:SuicidePerson(statebids[1].value)
John@76 77 else
John@76 78 printf("Could not suicide %s for item; they are ineligible or offline",statebids[1].textPlain)
John@76 79 end
John@76 80 return
John@76 81 end
John@76 82 if getn(staterolls) > 0 then
John@76 83 if FreeLoot(item,staterolls[1]) then
John@79 84 --lref:SuicidePerson(staterolls[1].value)
John@76 85 else
John@76 86 printf("Could not suicide %s for item; they are ineligible or offline",staterolls[1].textPlain)
John@76 87 end
John@76 88 return
John@76 89 end
John@76 90 _G.error("Trying to suicide+loot without bids or rolls")
John@76 91 end
John@76 92
John@78 93 function DirectSuicideLoot(item,person,lref)
John@78 94 if FreeLoot(item,person) then
John@78 95 lref:SuicidePerson(person.value)
John@78 96 else
John@78 97 printf("Could not suicide %s for item; they are ineligible or offline", person.textPlain)
John@78 98 end
John@78 99 end
John@78 100
John@73 101 function InitializeLooting()
John@73 102 event:RegisterEvent("OPEN_MASTER_LOOT_LIST",OpenMasterLootList)
John@73 103 event:RegisterEvent("UPDATE_MASTER_LOOT_LIST",UpdateMasterLootList)
John@73 104 event:RegisterEvent("LOOT_CLOSED",LootClosed)
John@73 105 event:RegisterEvent("LOOT_OPENED",LootOpened)
John@76 106
John@76 107 -- todo: what are these
John@76 108 event:RegisterEvent("LOOT_SLOT_CLEARED",function() print("LSCleared") end)
John@76 109 event:RegisterEvent("LOOT_SLOT_CHANGED",function() print("LSChanged") end)
John@73 110 end
John@73 111