mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2026-08-25 13:07:46 +01:00
Merge pull request #1240 from tigercat2000/dfc3c4e9aad5292ed3ff655785b59dfe
Port -tg- shuffle helper proc
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user