diff --git a/code/datums/components/orbit_poll.dm b/code/datums/components/orbit_poll.dm index 91b27d4b667..dda7207ed45 100644 --- a/code/datums/components/orbit_poll.dm +++ b/code/datums/components/orbit_poll.dm @@ -85,22 +85,47 @@ return for(var/mob/dead/observer/ghost as anything in orbiter_comp.orbiter_list) - if(QDELETED(ghost) || isnull(ghost.client)) + var/client/ghost_client = ghost.client + + if(QDELETED(ghost) || isnull(ghost_client)) continue + if(is_banned_from(ghost.ckey, job_bans)) continue + var/datum/preferences/ghost_prefs = ghost_client.prefs + if(isnull(ghost_prefs)) + candidates += ghost // we'll assume they wanted to be picked despite prefs being null for whatever fucked up reason + continue + + if(!ghost_prefs.read_preference(/datum/preference/toggle/ghost_roles)) + continue + if(!isnull(ghost_client.holder) && !ghost_prefs.read_preference(/datum/preference/toggle/ghost_roles_as_admin)) + continue + candidates += ghost - if(!length(candidates)) + pick_and_offer(candidates) + +/// Takes a list, picks a candidate, and offers the role to them. +/datum/component/orbit_poll/proc/pick_and_offer(list/volunteers) + if(length(volunteers) <= 0) phone_home() return - var/mob/dead/observer/chosen = pick(candidates) + var/mob/dead/observer/chosen = pick(volunteers) + + if(isnull(chosen)) + phone_home() + return - if(chosen) - deadchat_broadcast("[key_name(chosen, include_name = FALSE)] was selected for the role ([title]).", "Ghost Poll: ", parent) + SEND_SOUND(chosen, 'sound/misc/notice2.ogg') + var/response = tgui_alert(chosen, "Do you want to assume the role of [title]?", "Orbit Polling", list("Yes", "No"), 10 SECONDS) + if(response != "Yes") + var/reusable_list = volunteers - chosen + return pick_and_offer(reusable_list) + deadchat_broadcast("[key_name(chosen, include_name = FALSE)] was selected for the role ([title]).", "Ghost Poll: ", parent) phone_home(chosen) /// Make sure to call your parents my dude