Skip to content

Commit

Permalink
antag token notification improvements (#1476)
Browse files Browse the repository at this point in the history
* antag token improv

* remove old define
  • Loading branch information
Absolucy authored Mar 26, 2024
1 parent 1ea4111 commit 4f08c6e
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 6 deletions.
15 changes: 15 additions & 0 deletions code/__HELPERS/~monkestation-helpers/announcements.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/proc/send_formatted_admin_message(
text,
title = "Admin Alert",
sound_override = 'sound/effects/adminhelp.ogg',
color_override = "red"
)
if(isnull(text))
return
var/list/announcement_strings = list()
announcement_strings += SUBHEADER_ANNOUNCEMENT_TITLE(title)
announcement_strings += span_major_announcement_text(text)
var/finalized_announcement = create_announcement_div(jointext(announcement_strings, ""), color_override)
SEND_ADMINCHAT_MESSAGE(finalized_announcement)
if(sound_override)
SEND_ADMINS_NOTFICATION_SOUND(sound_override)
38 changes: 38 additions & 0 deletions monkestation/code/datums/meta_tokens.dm
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ GLOBAL_LIST_INIT(patreon_etoken_values, list(
var/event_token_month = 0
///what token event do we currently have queued
var/datum/twitch_event/queued_token_event
/// The timer for the antag token timeout
var/antag_timeout
/// The timer for the event token timeout
var/event_timeout

/datum/meta_token_holder/New(client/creator)
. = ..()
Expand Down Expand Up @@ -128,16 +132,34 @@ GLOBAL_LIST_INIT(patreon_etoken_values, list(
in_queue = null
in_queued_tier = null
queued_donor = FALSE
if(antag_timeout)
deltimer(antag_timeout)
antag_timeout = null

/datum/meta_token_holder/proc/reject_antag_token()
if(!in_queue)
return

to_chat(owner, span_boldwarning("Your request to play as [in_queue] has been denied."))
logger.Log(LOG_CATEGORY_META, "[owner]'s antag token for [in_queue] has been denied.")
SEND_SOUND(owner, sound('sound/misc/compiler-failure.ogg', volume = 50))
in_queue = null
in_queued_tier = null
queued_donor = FALSE
if(antag_timeout)
deltimer(antag_timeout)
antag_timeout = null

/datum/meta_token_holder/proc/timeout_antag_token()
if(!in_queue)
return
to_chat(owner, span_boldwarning("Your request to play as [in_queue] wasn't answered within 5 minutes. Better luck next time!"))
logger.Log(LOG_CATEGORY_META, "[owner]'s antag token for [in_queue] has timed out.")
SEND_SOUND(owner, sound('sound/misc/compiler-failure.ogg', volume = 50))
in_queue = null
in_queued_tier = null
queued_donor = FALSE
antag_timeout = null

/datum/meta_token_holder/proc/adjust_event_tokens(amount)
check_event_tokens(owner)
Expand All @@ -162,11 +184,27 @@ GLOBAL_LIST_INIT(patreon_etoken_values, list(
adjust_event_tokens(-queued_token_event.token_cost)
SStwitch.add_to_queue(initial(queued_token_event.id_tag))
queued_token_event = null
if(event_timeout)
deltimer(event_timeout)
event_timeout = null

/datum/meta_token_holder/proc/reject_token_event()
if(!queued_token_event)
return

to_chat(owner, span_boldwarning("Your request to trigger [queued_token_event] has been denied."))
logger.Log(LOG_CATEGORY_META, "[owner]'s event token for [queued_token_event] has been denied.")
SEND_SOUND(owner, sound('sound/misc/compiler-failure.ogg', volume = 50))
queued_token_event = null
if(event_timeout)
deltimer(event_timeout)
event_timeout = null

/datum/meta_token_holder/proc/timeout_event_token()
if(!queued_token_event)
return
logger.Log(LOG_CATEGORY_META, "[owner]'s event token for [queued_token_event] has timed out.")
to_chat(owner, span_boldwarning("Your request to trigger [queued_token_event] wasn't answered within 5 minutes. Better luck next time!"))
SEND_SOUND(owner, sound('sound/misc/compiler-failure.ogg', volume = 50))
queued_token_event = null
event_timeout = null
18 changes: 12 additions & 6 deletions monkestation/code/modules/client/verbs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,12 @@ GLOBAL_LIST_INIT(antag_token_config, load_antag_token_config())
client_token_holder.in_queue = new chosen_antagonist

to_chat(src, span_boldnotice("Your request has been sent to the admins."))
SEND_NOTFIED_ADMIN_MESSAGE('sound/items/bikehorn.ogg', "[span_admin("[span_prefix("ANTAG TOKEN:")] <EM>[key_name(src)]</EM> \
[ADMIN_APPROVE_ANTAG_TOKEN(src)] [ADMIN_REJECT_ANTAG_TOKEN(src)] | \
[src] has requested to use their antag token to be a [chosen_antagonist::name].")]")
send_formatted_admin_message( \
"[ADMIN_LOOKUPFLW(src)] has requested to use their antag token to be a [chosen_antagonist::name].\n\n[ADMIN_APPROVE_ANTAG_TOKEN(src)] | [ADMIN_REJECT_ANTAG_TOKEN(src)]", \
title = "Antag Token Request", \
color_override = "orange" \
)
client_token_holder.antag_timeout = addtimer(CALLBACK(client_token_holder, TYPE_PROC_REF(/datum/meta_token_holder, timeout_antag_token)), 5 MINUTES, TIMER_STOPPABLE | TIMER_UNIQUE | TIMER_OVERRIDE | TIMER_DELETE_ME)

/client/verb/trigger_token_event()
set category = "IC"
Expand Down Expand Up @@ -92,9 +95,12 @@ GLOBAL_LIST_INIT(antag_token_config, load_antag_token_config())
client_token_holder.queued_token_event = selected_event
to_chat(src, span_boldnotice("Your request has been sent."))
logger.Log(LOG_CATEGORY_META, "[usr] has requested to use their event tokens to trigger [selected_event.event_name]([selected_event]).")
SEND_NOTFIED_ADMIN_MESSAGE('sound/items/bikehorn.ogg', "[span_admin("[span_prefix("TOKEN EVENT:")] <EM>[key_name(src)]</EM> \
[ADMIN_APPROVE_TOKEN_EVENT(src)] [ADMIN_REJECT_TOKEN_EVENT(src)] | \
[src] has requested use their event tokens to trigger [selected_event.event_name]([selected_event]).")]")
send_formatted_admin_message( \
"[ADMIN_LOOKUPFLW(src)] has requested use their event tokens to trigger [selected_event.event_name]([selected_event]).\n\n[ADMIN_APPROVE_TOKEN_EVENT(src)] | [ADMIN_REJECT_TOKEN_EVENT(src)]", \
title = "Event Token Request", \
color_override = "orange" \
)
client_token_holder.event_timeout = addtimer(CALLBACK(client_token_holder, TYPE_PROC_REF(/datum/meta_token_holder, timeout_event_token)), 5 MINUTES, TIMER_STOPPABLE | TIMER_UNIQUE | TIMER_OVERRIDE | TIMER_DELETE_ME)
return
to_chat(src, "You dont have enough tokens to trigger this event.")

Expand Down
1 change: 1 addition & 0 deletions tgstation.dme
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,7 @@
#include "code\__HELPERS\sorts\InsertSort.dm"
#include "code\__HELPERS\sorts\MergeSort.dm"
#include "code\__HELPERS\sorts\TimSort.dm"
#include "code\__HELPERS\~monkestation-helpers\announcements.dm"
#include "code\__HELPERS\~monkestation-helpers\icon_smoothing.dm"
#include "code\__HELPERS\~monkestation-helpers\time.dm"
#include "code\__HELPERS\~monkestation-helpers\virology.dm"
Expand Down

0 comments on commit 4f08c6e

Please sign in to comment.