diff Looting.lua @ 76:39be9328acd0

Turning bidding admin buttons into state responders Starting to integrate master looting along with the bids
author John@Yosemite-PC
date Tue, 10 Apr 2012 23:50:07 -0400
parents 7eb2963eea7d
children 5b507f4125d4
line wrap: on
line diff
--- a/Looting.lua	Mon Apr 09 09:40:53 2012 -0400
+++ b/Looting.lua	Tue Apr 10 23:50:07 2012 -0400
@@ -60,10 +60,49 @@
 
 end
 
+function FreeLoot(item,person)
+    PrintTable(item)
+    PrintTable(person)
+    for ci = 1, 40 do
+        if _G.GetMasterLootCandidate(ci) == person.textPlain then
+            print("GML",item.value,ci)
+            _G.GiveMasterLoot(item.value, ci)
+            return true
+        end
+    end
+    
+    print("Could not assign loot to ", person.textPlain)
+end
+
+function ExpensiveLoot(item,lref)
+    local person
+    if getn(statebids) > 0 then
+        if FreeLoot(item,statebids[1]) then
+            lref:SuicidePerson(statebids[1].value)
+        else
+            printf("Could not suicide %s for item; they are ineligible or offline",statebids[1].textPlain)
+        end
+        return
+    end
+    if getn(staterolls) > 0 then
+        if FreeLoot(item,staterolls[1]) then
+            lref:SuicidePerson(staterolls[1].value)
+        else
+            printf("Could not suicide %s for item; they are ineligible or offline",staterolls[1].textPlain)
+        end
+        return
+    end
+    _G.error("Trying to suicide+loot without bids or rolls")
+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)
+
+    -- todo: what are these
+    event:RegisterEvent("LOOT_SLOT_CLEARED",function() print("LSCleared") end)
+    event:RegisterEvent("LOOT_SLOT_CHANGED",function() print("LSChanged") end)
 end