mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2026-08-24 04:27:35 +01:00
Adds new emote keybinds, and emote keybind unit tests (#19603)
* Adds a keybinding for *crack * Add new unit tests * Fix up unit tests * oops, this wasn't supposed to make it in * Update code/modules/unit_tests/emotes.dm Co-authored-by: SteelSlayer <42044220+SteelSlayer@users.noreply.github.com> Co-authored-by: SteelSlayer <42044220+SteelSlayer@users.noreply.github.com>
This commit is contained in:
@@ -1,5 +1,16 @@
|
||||
|
||||
|
||||
/datum/unit_test/emote/Run()
|
||||
|
||||
// Special cases that shouldn't need keybinds.
|
||||
var/list/ignored_emote_types = list(
|
||||
/datum/emote/living/simple_animal/slime, // The emotes are usable if you are a slime, but I don't think we need to flood the keybind list with them
|
||||
/datum/emote/help,
|
||||
/datum/emote/living/custom // This one's handled by its own set of keybinds
|
||||
)
|
||||
|
||||
var/list/keybound_emotes = get_emote_keybinds()
|
||||
|
||||
// be aware that some of these values (like message, message_param) are subject to being set at runtime.
|
||||
for(var/emote_type in subtypesof(/datum/emote))
|
||||
var/datum/emote/cur_emote = new emote_type()
|
||||
@@ -18,6 +29,10 @@
|
||||
if(isnull(cur_emote.emote_type))
|
||||
Fail("emote [cur_emote] has a null target type.")
|
||||
|
||||
// If we're at this point, we're definitely an emote that a user could use, and therefore ought to make sure it's bound to a keybind if possible.
|
||||
if(!is_type_in_list(cur_emote, keybound_emotes) && !is_type_in_list(cur_emote, ignored_emote_types))
|
||||
Fail("Emote [cur_emote] is usable, but not assigned a keybind.")
|
||||
|
||||
if(isnum(cur_emote.max_stat_allowed) && cur_emote.max_stat_allowed < cur_emote.stat_allowed)
|
||||
Fail("emote [cur_emote]'s max_stat_allowed is greater than its stat_allowed, and would be unusable.")
|
||||
|
||||
@@ -25,5 +40,13 @@
|
||||
Fail("emote [cur_emote]'s max_unintentional_stat_allowed is greater than its unintentional_stat_allowed, and would be unusable.")
|
||||
|
||||
|
||||
/datum/unit_test/emote/proc/has_punctuation(datum/emote/E, msg)
|
||||
return E.remove_ending_punctuation(msg) == msg
|
||||
|
||||
/datum/unit_test/emote/proc/get_emote_keybinds()
|
||||
var/list/bound_emotes = list()
|
||||
for(var/keybind in subtypesof(/datum/keybinding/emote))
|
||||
var/datum/keybinding/emote/E = new keybind()
|
||||
bound_emotes |= E.linked_emote
|
||||
|
||||
return bound_emotes
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user