Skip to content

Commit

Permalink
[MIRROR] Orbit Poll respects Preferences + Asks for Permission to Ung…
Browse files Browse the repository at this point in the history
…host [MDB IGNORE] (#632)

* Orbit Poll respects Preferences + Asks for Permission to Unghost (#79712)

---------

Co-authored-by: SkyratBot <[email protected]>
Co-authored-by: san7890 <[email protected]>
  • Loading branch information
3 people authored Nov 15, 2023
1 parent 85664b3 commit 577b6b9
Showing 1 changed file with 30 additions and 5 deletions.
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

0 comments on commit 577b6b9

Please sign in to comment.