Switches to assoc lists

This commit is contained in:
AnturK
2016-07-25 22:42:06 +02:00
parent 69dcf5bd98
commit c6d9df04ba
4 changed files with 10 additions and 8 deletions

View File

@@ -397,14 +397,14 @@
return new /datum/projectile_data(src_x, src_y, time, distance, power_x, power_y, dest_x, dest_y) return new /datum/projectile_data(src_x, src_y, time, distance, power_x, power_y, dest_x, dest_y)
/proc/pollCandidates(var/Question, var/jobbanType, var/datum/game_mode/gametypeCheck, var/be_special_flag = 0, var/poll_time = 300, var/ignore_list = null) /proc/pollCandidates(var/Question, var/jobbanType, var/datum/game_mode/gametypeCheck, var/be_special_flag = 0, var/poll_time = 300, var/ignore_category = null)
var/list/mob/dead/observer/candidates = list() var/list/mob/dead/observer/candidates = list()
var/time_passed = world.time var/time_passed = world.time
if (!Question) if (!Question)
Question = "Would you like to be a special role?" Question = "Would you like to be a special role?"
for(var/mob/dead/observer/G in player_list) for(var/mob/dead/observer/G in player_list)
if(!G.key || !G.client || (ignore_list && G.ckey in ignore_list)) if(!G.key || !G.client || (ignore_category && G.ckey in poll_ignore[ignore_category]))
continue continue
if(be_special_flag) if(be_special_flag)
if(!(G.client.prefs) || !(be_special_flag in G.client.prefs.be_special)) if(!(G.client.prefs) || !(be_special_flag in G.client.prefs.be_special))
@@ -417,7 +417,7 @@
continue continue
spawn(0) spawn(0)
G << 'sound/misc/notice2.ogg' //Alerting them to their consideration G << 'sound/misc/notice2.ogg' //Alerting them to their consideration
switch(ignore_list ? askuser(G,Question,"Please answer in [poll_time/10] seconds!","Yes","No","Never for this round", StealFocus=0, Timeout=poll_time) : askuser(G,Question,"Please answer in [poll_time/10] seconds!","Yes","No", StealFocus=0, Timeout=poll_time)) switch(ignore_category ? askuser(G,Question,"Please answer in [poll_time/10] seconds!","Yes","No","Never for this round", StealFocus=0, Timeout=poll_time) : askuser(G,Question,"Please answer in [poll_time/10] seconds!","Yes","No", StealFocus=0, Timeout=poll_time))
if(1) if(1)
G << "<span class='notice'>Choice registered: Yes.</span>" G << "<span class='notice'>Choice registered: Yes.</span>"
if((world.time-time_passed)>poll_time) if((world.time-time_passed)>poll_time)
@@ -428,7 +428,7 @@
if(2) if(2)
G << "<span class='danger'>Choice registered: No.</span>" G << "<span class='danger'>Choice registered: No.</span>"
if(3) if(3)
ignore_list[G.ckey] = 1 poll_ignore[ignore_category] += G.ckey
G << "<span class='danger'>Choice registered: Never for this round.</span>" G << "<span class='danger'>Choice registered: Never for this round.</span>"
sleep(poll_time) sleep(poll_time)

View File

@@ -1,4 +1,6 @@
//Each lists stores ckeys for "Never for this round" option category //Each lists stores ckeys for "Never for this round" option category
var/list/sentience_potion_ignore = list() //sentience potion query #define POLL_IGNORE_PAI "pai"
var/list/pai_ignore = list() //pai's #define POLL_IGNORE_SENTIENCE_POTION "sentience_potion"
var/list/poll_ignore = list(POLL_IGNORE_PAI = list(),POLL_IGNORE_SENTIENCE_POTION = list())

View File

@@ -178,7 +178,7 @@ var/datum/subsystem/pai/SSpai
user << browse(dat, "window=findPai") user << browse(dat, "window=findPai")
/datum/subsystem/pai/proc/requestRecruits() /datum/subsystem/pai/proc/requestRecruits()
var/list/candidates = pollCandidates("Someone is requesting a pAI personality. Would you like to play as a personal AI?", ROLE_PAI, null, ROLE_PAI,300, ignore_list = pai_ignore) var/list/candidates = pollCandidates("Someone is requesting a pAI personality. Would you like to play as a personal AI?", ROLE_PAI, null, ROLE_PAI,300, ignore_category = POLL_IGNORE_PAI)
for(var/V in candidates) for(var/V in candidates)
recruitWindow(V) recruitWindow(V)
return return

View File

@@ -184,7 +184,7 @@
user << "<span class='notice'>You offer the sentience potion to [SM]...</span>" user << "<span class='notice'>You offer the sentience potion to [SM]...</span>"
being_used = 1 being_used = 1
var/list/mob/dead/observer/candidates = pollCandidates("Do you want to play as [SM.name]?", ROLE_ALIEN, null, ROLE_ALIEN, 50, sentience_potion_ignore) // see poll_ignore.dm var/list/mob/dead/observer/candidates = pollCandidates("Do you want to play as [SM.name]?", ROLE_ALIEN, null, ROLE_ALIEN, 50, POLL_IGNORE_SENTIENCE_POTION) // see poll_ignore.dm
var/mob/dead/observer/theghost = null var/mob/dead/observer/theghost = null
if(candidates.len) if(candidates.len)
theghost = pick(candidates) theghost = pick(candidates)