# HG changeset patch # User John@Doomsday # Date 1331213424 18000 # Node ID e62cbf3a0c070b68cc2533546dd28dd88d10b1a7 # Parent a6bc3f2d320742cceeb6ea2dcb55d14c3b54df5a Disallowing adding a person a second time diff -r a6bc3f2d3207 -r e62cbf3a0c07 Lists.lua --- a/Lists.lua Wed Mar 07 23:01:33 2012 -0500 +++ b/Lists.lua Thu Mar 08 08:30:24 2012 -0500 @@ -331,6 +331,10 @@ -- require admin local listIndex = bsk:GetListIndex(list) local id = personsReverse[name] + if bsk:IdIsInList(id,bsk.lists[listIndex]) then + bsk:Print(sformat("Person %s is already on the reqeuested list",name)) + return + end bsk:Print(sformat("Adding %s (%s) to list %s (%s)", name, id, list, listIndex)) local change = {action="AddToListEnd",arg={id=id,listIndex=listIndex}} bsk:StartChange(change) @@ -357,6 +361,10 @@ self:Print("Cannot add person to list by random roll because an add-to-end operation has already occurred") return false end + if bsk:IdIsInList(id,bsk.lists[listIndex]) then + bsk:Print(sformat("Person %s is already on the reqeuested list",name)) + return + end local id = personsReverse[name] local roll = math.random() bsk:Print(sformat("Adding %s (%s) to list %s (%s) with roll (%f)", name, id, list, listIndex, roll)) @@ -559,6 +567,15 @@ return ret end +function bsk:IdIsInList(id,listRef) + for i = 1,#listRef do + if id == listRef[i].id then + return true + end + end + return false +end + -- returns true if the events in the list are in time order function bsk:CheckListCausality() local t = nil