Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MIRROR] Orbit Poll respects Preferences + Asks for Permission to Unghost #632

Merged
merged 1 commit into from
Nov 15, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 30 additions & 5 deletions code/datums/components/orbit_poll.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading