Mercurial > wow > breuesk
changeset 13:e62cbf3a0c07
Disallowing adding a person a second time
author | John@Doomsday |
---|---|
date | Thu, 08 Mar 2012 08:30:24 -0500 |
parents | a6bc3f2d3207 |
children | 030694ddc6c9 |
files | Lists.lua |
diffstat | 1 files changed, 17 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- 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