Skip to content
Closed
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions maplestation.dme
Original file line number Diff line number Diff line change
Expand Up @@ -6567,6 +6567,7 @@
#include "maplestation_modules\code\modules\clothing\under\jobs\security.dm"
#include "maplestation_modules\code\modules\events\resource_drift.dm"
#include "maplestation_modules\code\modules\events\resource_pods.dm"
#include "maplestation_modules\code\modules\events\secretsanta.dm"
#include "maplestation_modules\code\modules\events\solar_flare.dm"
#include "maplestation_modules\code\modules\flavor_text\flavor_examine.dm"
#include "maplestation_modules\code\modules\flavor_text\flavor_helpers.dm"
Expand Down
109 changes: 109 additions & 0 deletions maplestation_modules/code/modules/events/secretsanta.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
/datum/round_event_control/secretsanta
name = "Secret Santa"
holidayID = FESTIVE_SEASON
typepath = /datum/round_event/secretsanta
weight = -1 //forces it to be called, regardless of weight
max_occurrences = 1
earliest_start = 5 MINUTES
category = EVENT_CATEGORY_HOLIDAY
description = "Gives everyone a secret santa to gift something to! \
You can execute this multiple times per round to include latejoiners."
min_players = 3

/datum/round_event/secretsanta
fakeable = FALSE
/// Only announce once
var/static/announced = FALSE

/datum/round_event/secretsanta/start()
var/list/mob/living/candidates = list()
for(var/mob/living/candidate as anything in GLOB.mob_living_list)
if(is_candidate(candidate))
candidates += candidate

if(length(candidates) < 2)
return // shouldn't happen due to players_amt, but just in case

var/mob/living/first_gifter = pick_n_take(candidates)
var/mob/living/last_gifter = first_gifter

while(length(candidates))
var/mob/living/next_gifter = pick_n_take(candidates)
assign_secret_santa(next_gifter, last_gifter)
last_gifter = next_gifter

assign_secret_santa(first_gifter, last_gifter)

/datum/round_event/secretsanta/proc/is_candidate(mob/living/some_mob)
if(isnull(some_mob.mind))
return FALSE
if(some_mob.mind.has_antag_datum(/datum/antagonist/secret_santa))
return FALSE
var/turf/some_turf = get_turf(some_mob)
// admin characters need not apply, you can spawn whatever you want for christmas
if(is_centcom_level(some_turf.z))
return FALSE
// crew secret santa
if(some_mob.mind.assigned_role.job_flags & JOB_CREW_MEMBER)
return TRUE
// sure, we can include silicons in on this. just don't grab ones in deep space i guess
if(issilicon(some_mob) && (is_station_level(some_turf.z) || is_mining_level(some_turf.z)))
return TRUE
return FALSE

/datum/round_event/secretsanta/proc/assign_secret_santa(mob/living/gifter, mob/living/recipient)
var/datum/antagonist/secret_santa/secret = gifter.mind.add_antag_datum(__IMPLIED_TYPE__)
secret.recipient = recipient.mind
to_chat(gifter, examine_block(span_green("[span_big("You are <b>[secret.recipient.name]</b>'s Secret Santa!")]<br><br>\
Come up with an appropriate gift and wait for the festivities to begin!<br>\
(If you need help coming up with an idea, try asking their co-workers and friends, or even <i>pray</i> for inspiration!)")))

/datum/round_event/secretsanta/announce(fake)
if(fake || announced)
return

announced = TRUE
priority_announce("Ho ho ho! The annual Nanotrasen™ Secret Santa is starting! Everyone has been assigned a Secret Santa of another crew member.<br><br>\
When and where you decide to exchange gifts is up to you all to decide - just remember to keep your assignment a secret!<br>Happy holidays!", encode_text = FALSE)

/datum/antagonist/secret_santa
name = "\improper Secret Santa"
roundend_category = "secret santa"
show_in_antagpanel = FALSE
prevent_roundtype_conversion = FALSE
ui_name = null
silent = TRUE
/// Keep track who we're giving a gift to
var/datum/mind/recipient

/datum/antagonist/secret_santa/roundend_report()
return "&bull; [owner.name] had [recipient.name] as [owner.p_their()] Secret Santa recipient."

/datum/antagonist/secret_santa/apply_innate_effects(mob/living/mob_override)
var/mob/living/target = mob_override || owner.current
var/datum/action/secret_santa_reminder/reminder = new(src)
reminder.Grant(target)

/datum/antagonist/secret_santa/remove_innate_effects(mob/living/mob_override)
var/mob/living/target = mob_override || owner.current
for(var/datum/action/secret_santa_reminder/reminder in target.actions)
qdel(reminder)

/datum/action/secret_santa_reminder
name = "Secret Santa Reminder"
desc = "Reminds you of who your Secret Santa recipient is."
button_icon_state = "round_end"
show_to_observers = FALSE

/datum/action/secret_santa_reminder/Trigger(trigger_flags)
. = ..()
if(!.)
return

var/datum/antagonist/secret_santa/secret = target
if(!istype(secret))
return

to_chat(usr, examine_block(span_green("[span_big("You are <b>[secret.recipient.name]</b>'s Secret Santa!")]<br><br>\
Come up with an appropriate gift and wait for the festivities to begin!<br>\
(If you need help coming up with an idea, try asking their co-workers and friends, or even <i>pray</i> for inspiration!)")))
Loading