mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-07-11 08:06:33 +01:00
21b4095dfd
Upstream 04/17/2026 fixes https://github.com/Bubberstation/Bubberstation/issues/5549 --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: tgstation-ci[bot] <179393467+tgstation-ci[bot]@users.noreply.github.com> Co-authored-by: ArcaneMusic <41715314+ArcaneMusic@users.noreply.github.com> Co-authored-by: MrMelbert <51863163+MrMelbert@users.noreply.github.com> Co-authored-by: Rhials <28870487+Rhials@users.noreply.github.com> Co-authored-by: rageguy505 <54517726+rageguy505@users.noreply.github.com> Co-authored-by: LemonInTheDark <58055496+LemonInTheDark@users.noreply.github.com> Co-authored-by: John Willard <53777086+JohnFulpWillard@users.noreply.github.com> Co-authored-by: Aliceee2ch <160794176+Aliceee2ch@users.noreply.github.com> Co-authored-by: Time-Green <7501474+Time-Green@users.noreply.github.com> Co-authored-by: Tsar-Salat <62388554+Tsar-Salat@users.noreply.github.com> Co-authored-by: SmArtKar <44720187+SmArtKar@users.noreply.github.com> Co-authored-by: Maxipat <108554989+Maxipat112@users.noreply.github.com> Co-authored-by: SyncIt21 <110812394+SyncIt21@users.noreply.github.com> Co-authored-by: deltanedas <39013340+deltanedas@users.noreply.github.com> Co-authored-by: SimplyLogan <47579821+loganuk@users.noreply.github.com> Co-authored-by: loganuk <fakeemail123@aol.com> Co-authored-by: Leland Kemble <70413276+lelandkemble@users.noreply.github.com> Co-authored-by: FalloutFalcon <86381784+FalloutFalcon@users.noreply.github.com> Co-authored-by: Roxy <75404941+TealSeer@users.noreply.github.com> Co-authored-by: Lucy <lucy@absolucy.moe> Co-authored-by: siliconOpossum <138069572+siliconOpossum@users.noreply.github.com> Co-authored-by: Isratosh <Isratosh@hotmail.com> Co-authored-by: TheRyeGuyWhoWillNowDie <70169560+TheRyeGuyWhoWillNowDie@users.noreply.github.com> Co-authored-by: Neocloudy <88008002+Neocloudy@users.noreply.github.com> Co-authored-by: Alexander V. <volas@ya.ru> Co-authored-by: ElGitificador <168473461+ElGitificador@users.noreply.github.com> Co-authored-by: Twaticus <46540570+Twaticus@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Bloop <13398309+vinylspiders@users.noreply.github.com> Co-authored-by: Cameron Lennox <killer65311@gmail.com> Co-authored-by: Tim <timothymtorres@gmail.com> Co-authored-by: Iamgoofball <iamgoofball@gmail.com> Co-authored-by: Layzu666 <121319428+Layzu666@users.noreply.github.com> Co-authored-by: Arturlang <24881678+Arturlang@users.noreply.github.com> Co-authored-by: _0Steven <42909981+00-Steven@users.noreply.github.com> Co-authored-by: mrmanlikesbt <99309552+mrmanlikesbt@users.noreply.github.com> Co-authored-by: Ben10Omintrix <138636438+Ben10Omintrix@users.noreply.github.com> Co-authored-by: John F. Kennedy <54908920+MacaroniCritter@users.noreply.github.com> Co-authored-by: Cursor <102828457+theselfish@users.noreply.github.com> Co-authored-by: Josh <josh.adam.powell@gmail.com> Co-authored-by: Josh Powell <josh.powell@softwire.com> Co-authored-by: Yobrocharlie <Charliemiller5617@gmail.com> Co-authored-by: Hardly3D <66234359+Hardly3D@users.noreply.github.com> Co-authored-by: shayoki <96078776+shayoki@users.noreply.github.com> Co-authored-by: LT3 <83487515+lessthnthree@users.noreply.github.com>
111 lines
4.0 KiB
Plaintext
111 lines
4.0 KiB
Plaintext
SUBSYSTEM_DEF(pai)
|
|
name = "pAI"
|
|
ss_flags = SS_NO_INIT|SS_NO_FIRE
|
|
|
|
/// List of pAI candidates, including those not submitted.
|
|
var/list/candidates = list()
|
|
/// All pAI cards on the map.
|
|
var/list/pai_card_list = list()
|
|
/// Prevents a pAI from submitting itself repeatedly and sounding an alert.
|
|
var/submit_spam = FALSE
|
|
|
|
/datum/controller/subsystem/pai/ui_interact(mob/user, datum/tgui/ui)
|
|
. = ..()
|
|
ui = SStgui.try_update_ui(user, src, ui)
|
|
if(!ui)
|
|
ui = new(user, src, "PaiSubmit")
|
|
ui.open()
|
|
ui.set_autoupdate(FALSE)
|
|
|
|
/datum/controller/subsystem/pai/Recover()
|
|
. = ..()
|
|
candidates = SSpai.candidates
|
|
pai_card_list = SSpai.pai_card_list
|
|
|
|
/datum/controller/subsystem/pai/ui_state(mob/user)
|
|
return GLOB.observer_state
|
|
|
|
/datum/controller/subsystem/pai/ui_static_data(mob/user)
|
|
. = ..()
|
|
var/list/data = list()
|
|
var/datum/pai_candidate/candidate = candidates[user.ckey]
|
|
if(isnull(candidate))
|
|
return data
|
|
data["comments"] = candidate.comments
|
|
data["description"] = candidate.description
|
|
data["name"] = candidate.name
|
|
return data
|
|
|
|
/datum/controller/subsystem/pai/ui_act(action, list/params, datum/tgui/ui)
|
|
. = ..()
|
|
if(.)
|
|
return TRUE
|
|
var/mob/user = ui.user
|
|
var/datum/pai_candidate/candidate = candidates[user.ckey]
|
|
if(is_banned_from(user.ckey, ROLE_PAI))
|
|
to_chat(user, span_warning("You are banned from playing pAI!"))
|
|
ui.close()
|
|
return FALSE
|
|
if(isnull(candidate))
|
|
to_chat(user, span_warning("There was an error. Please resubmit."))
|
|
ui.close()
|
|
return FALSE
|
|
switch(action)
|
|
if("submit")
|
|
candidate.comments = reject_bad_name(params["comments"], allow_numbers = TRUE, max_length = MAX_BROADCAST_LEN, strict = TRUE, cap_after_symbols = FALSE) || "Unknown"
|
|
candidate.description = reject_bad_name(params["description"], allow_numbers = TRUE, max_length = MAX_BROADCAST_LEN, strict = TRUE, cap_after_symbols = FALSE) || "Unknown"
|
|
candidate.name = reject_bad_name(params["name"], allow_numbers = TRUE, max_length = MAX_NAME_LEN, strict = TRUE, cap_after_symbols = FALSE) || "Unknown"
|
|
candidate.ckey = user.ckey
|
|
candidate.ready = TRUE
|
|
ui.close()
|
|
submit_alert(user)
|
|
return TRUE
|
|
if("save")
|
|
candidate.comments = reject_bad_name(params["comments"], allow_numbers = TRUE, max_length = MAX_BROADCAST_LEN, strict = TRUE, cap_after_symbols = FALSE) || "Unknown"
|
|
candidate.description = reject_bad_name(params["description"], allow_numbers = TRUE, max_length = MAX_BROADCAST_LEN, strict = TRUE, cap_after_symbols = FALSE) || "Unknown"
|
|
candidate.name = reject_bad_name(params["name"], allow_numbers = TRUE, max_length = MAX_NAME_LEN, strict = TRUE, cap_after_symbols = FALSE) || "Unknown"
|
|
candidate.savefile_save(user)
|
|
return TRUE
|
|
if("load")
|
|
candidate.savefile_load(user)
|
|
ui.send_full_update()
|
|
return TRUE
|
|
if("withdraw")
|
|
if(!candidate.ready)
|
|
to_chat(user, span_warning("You need to submit an application before you can withdraw one."))
|
|
return FALSE
|
|
candidate.ready = FALSE
|
|
to_chat(user, span_notice("Your pAI candidacy has been withdrawn."))
|
|
return TRUE
|
|
return FALSE
|
|
|
|
/**
|
|
* This is the primary window proc when the pAI candidate
|
|
* hud menu is pressed by observers.
|
|
*
|
|
* @params {mob} user The ghost doing the pressing.
|
|
*/
|
|
/datum/controller/subsystem/pai/proc/recruit_window(mob/user)
|
|
/// Searches for a previous candidate upon opening the menu
|
|
var/datum/pai_candidate/candidate = candidates[user.ckey]
|
|
if(isnull(candidate))
|
|
candidate = new(user.ckey)
|
|
candidates[user.ckey] = candidate
|
|
ui_interact(user)
|
|
|
|
|
|
/**
|
|
* Pings all pAI cards on the station that new candidates are available.
|
|
*/
|
|
/datum/controller/subsystem/pai/proc/submit_alert(mob/user)
|
|
if(submit_spam)
|
|
to_chat(user, span_warning("Your candidacy has been submitted, but pAI cards have been alerted too recently."))
|
|
return FALSE
|
|
submit_spam = TRUE
|
|
for(var/obj/item/pai_card/pai_card as anything in pai_card_list)
|
|
if(!pai_card.pai)
|
|
pai_card.alert_update()
|
|
to_chat(user, span_notice("Your pAI candidacy has been submitted!"))
|
|
addtimer(VARSET_CALLBACK(src, submit_spam, FALSE), PAI_SPAM_TIME, TIMER_UNIQUE|TIMER_DELETE_ME)
|
|
return TRUE
|