Mercurial > wow > breuesk
comparison Lists.lua @ 13:e62cbf3a0c07
Disallowing adding a person a second time
author | John@Doomsday |
---|---|
date | Thu, 08 Mar 2012 08:30:24 -0500 |
parents | a6bc3f2d3207 |
children | 16b7e6390f42 |
comparison
equal
deleted
inserted
replaced
12:a6bc3f2d3207 | 13:e62cbf3a0c07 |
---|---|
329 | 329 |
330 function bsk:AddPersonToListEnd(name,list) | 330 function bsk:AddPersonToListEnd(name,list) |
331 -- require admin | 331 -- require admin |
332 local listIndex = bsk:GetListIndex(list) | 332 local listIndex = bsk:GetListIndex(list) |
333 local id = personsReverse[name] | 333 local id = personsReverse[name] |
334 if bsk:IdIsInList(id,bsk.lists[listIndex]) then | |
335 bsk:Print(sformat("Person %s is already on the reqeuested list",name)) | |
336 return | |
337 end | |
334 bsk:Print(sformat("Adding %s (%s) to list %s (%s)", name, id, list, listIndex)) | 338 bsk:Print(sformat("Adding %s (%s) to list %s (%s)", name, id, list, listIndex)) |
335 local change = {action="AddToListEnd",arg={id=id,listIndex=listIndex}} | 339 local change = {action="AddToListEnd",arg={id=id,listIndex=listIndex}} |
336 bsk:StartChange(change) | 340 bsk:StartChange(change) |
337 if bsk:DoAddPersonToListEnd(change) then | 341 if bsk:DoAddPersonToListEnd(change) then |
338 bsk:CommitChange(change) | 342 bsk:CommitChange(change) |
354 -- require admin | 358 -- require admin |
355 local listIndex = bsk:GetListIndex(list) | 359 local listIndex = bsk:GetListIndex(list) |
356 if bsk.lists[listIndex].closedRandom then | 360 if bsk.lists[listIndex].closedRandom then |
357 self:Print("Cannot add person to list by random roll because an add-to-end operation has already occurred") | 361 self:Print("Cannot add person to list by random roll because an add-to-end operation has already occurred") |
358 return false | 362 return false |
363 end | |
364 if bsk:IdIsInList(id,bsk.lists[listIndex]) then | |
365 bsk:Print(sformat("Person %s is already on the reqeuested list",name)) | |
366 return | |
359 end | 367 end |
360 local id = personsReverse[name] | 368 local id = personsReverse[name] |
361 local roll = math.random() | 369 local roll = math.random() |
362 bsk:Print(sformat("Adding %s (%s) to list %s (%s) with roll (%f)", name, id, list, listIndex, roll)) | 370 bsk:Print(sformat("Adding %s (%s) to list %s (%s) with roll (%f)", name, id, list, listIndex, roll)) |
363 local change = {action="AddToListRand",arg={id=id,listIndex=listIndex,roll=roll}} | 371 local change = {action="AddToListRand",arg={id=id,listIndex=listIndex,roll=roll}} |
557 bsk:PrintTable(ret) | 565 bsk:PrintTable(ret) |
558 bsk:Print("GSL") | 566 bsk:Print("GSL") |
559 return ret | 567 return ret |
560 end | 568 end |
561 | 569 |
570 function bsk:IdIsInList(id,listRef) | |
571 for i = 1,#listRef do | |
572 if id == listRef[i].id then | |
573 return true | |
574 end | |
575 end | |
576 return false | |
577 end | |
578 | |
562 -- returns true if the events in the list are in time order | 579 -- returns true if the events in the list are in time order |
563 function bsk:CheckListCausality() | 580 function bsk:CheckListCausality() |
564 local t = nil | 581 local t = nil |
565 for i,v in ipairs(bsk.db.profile.changes) do | 582 for i,v in ipairs(bsk.db.profile.changes) do |
566 if t ~= nil then | 583 if t ~= nil then |