changeset 18:bf3e94bc3bf5

Updated todos, lists using creation timestamp as keys
author John@Doomsday
date Fri, 09 Mar 2012 17:35:22 -0500
parents 71fc79846a5d
children cdca1f2ae605
files Core.lua Lists.lua
diffstat 2 files changed, 20 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/Core.lua	Fri Mar 09 13:26:56 2012 -0500
+++ b/Core.lua	Fri Mar 09 17:35:22 2012 -0500
@@ -8,10 +8,11 @@
 -- (_) all actions should reference the player list rather than player names
 -- ( ) player entries should persist as long as any list or change references
 -- ( ) convert slist entries down to a delimited string - much smaller
--- ( ) lists store number slots rather than flat indexing
+-- (*) lists store number slots rather than flat indexing
+-- ( ) limited communication - everyone trusts the loot master
 -- ( ) single user + admin gui (manual suicides)
 -- ( ) single user + admin gui (master loot)
--- ( ) communication and list trimming
+-- ( ) communication and list merging/trimming
 -- ( ) admins
 -- ( ) players gui
 -- ( ) crypto / protection against tampering
--- a/Lists.lua	Fri Mar 09 13:26:56 2012 -0500
+++ b/Lists.lua	Fri Mar 09 17:35:22 2012 -0500
@@ -10,7 +10,14 @@
 -- TODO: rename player
 -- TODO: list trimming
 -- TODO: collapse slists into delimited strings for space
--- TODO: list-of-lists must not use int indices. those will lead to peril.
+-- TODO: organize working state data a little more carefully - hard to keep
+-- track of all the arrays that are floating out there
+-- TODO: delete list
+-- TODO: rename list
+-- TODO: remove player from list
+-- TODO: (meta) remove player from all lists
+-- TODO: remove person (actually kinda tricky without casuality problems)
+
 -- holy crap long notes {{{
 -- notes on list storage:
 -- Using names as keys as I do now is atrocious.
@@ -57,6 +64,7 @@
 --                     * actually, fuck it. I'll give them an unlock command and
 --                     let them screw over their lists :)
 --}}}
+
 -- there are some dep chains here. for instance, to have a raidIdP value, a
 -- person must have a bsk.persons value which leads to a personName2id which
 -- leads to a raidIdP
@@ -104,7 +112,7 @@
 -- Debugging {{{
 function bsk:PrettyPrintList(listIndex)
     local list = bsk.lists[listIndex]
-    bsk:Print("List: " .. list.name .. " (" .. list.time .. ")")
+    bsk:Print("List: " .. list.name .. " (" .. list.id .. ") - last modified" .. date(list.time) .. " (",for)
     for i = 1,#list do
         bsk:Print("  " .. i .. " - " .. bsk.persons[list[i].id].main)
     end
@@ -320,15 +328,11 @@
 end
 
 function bsk:DoCreateList(change)
-    -- TODO: this segment will probably be useful as bsk:SearchForListByName
-    local lists = bsk.lists
-    for i,v in pairs(lists) do
-        if v.name == change.arg.name then
-            self:Print(sformat("List %s already exists",v.name))
-            return false
-        end
-    end
-    tinsert(lists,{name=change.arg.name,time=change.time})
+    --if bsk:GetListIndex(change.arg.name) then
+    --    self:Print(sformat("List %s already exists",v.name))
+    --    return false
+    --end
+    lists[change.arg.id]={name=change.arg.name,time=change.time}
     return true
 end
 
@@ -336,6 +340,7 @@
     -- require admin
     local change={action="CreateList",arg={name=name}}
     bsk:StartChange(change)
+    change.arg.id=change.time -- use the creation timestamp as the list's index. it's as unique as anything...
     self:Print("Creating ... " .. name)
     if bsk:DoCreateList(change) then
         bsk:CommitChange(change)
@@ -449,7 +454,7 @@
 
 function bsk:TrimLists(time)
     if not bsk:CheckListCausality() then
-        self:Print("Unable to trim lists due to violated causality")
+        self:Print("Unable to trim changelist due to violated causality")
         return false
     end