Merge pull request #1240 from tigercat2000/dfc3c4e9aad5292ed3ff655785b59dfe

Port -tg- shuffle helper proc
This commit is contained in:
ZomgPonies
2015-06-01 15:21:22 -04:00
3 changed files with 10 additions and 11 deletions
+8 -9
View File
@@ -155,16 +155,15 @@ proc/listclearnulls(list/list)
return output
//Randomize: Return the list in a random order
/proc/shuffle(var/list/shufflelist)
if(!shufflelist)
/proc/shuffle(var/list/L)
if(!L)
return
var/list/new_list = list()
var/list/old_list = shufflelist.Copy()
while(old_list.len)
var/item = pick(old_list)
new_list += item
old_list -= item
return new_list
L = L.Copy()
for(var/i=1, i<L.len, ++i)
L.Swap(i,rand(i,L.len))
return L
//Return a list with no duplicate entries
/proc/uniquelist(var/list/L)
+1 -1
View File
@@ -94,7 +94,7 @@
making_mage = 0
return
else
shuffle(candidates)
candidates = shuffle(candidates)
for(var/mob/i in candidates)
if(!i || !i.client) continue //Dont bother removing them from the list since we only grab one wizard
+1 -1
View File
@@ -167,7 +167,7 @@ client/proc/one_click_antag()
sleep(300)
if(candidates.len)
shuffle(candidates)
candidates = shuffle(candidates)
for(var/mob/i in candidates)
if(!i || !i.client) continue //Dont bother removing them from the list since we only grab one wizard