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:
Luc
2022-11-25 23:01:31 -06:00
committed by GitHub
co-authored by SteelSlayer
parent 72ee2f2488
commit 1490f60819
2 changed files with 41 additions and 2 deletions
+16
View File
@@ -141,6 +141,10 @@
linked_emote = /datum/emote/living/snore
name = "Snore"
/datum/keybinding/emote/nightmare
linked_emote = /datum/emote/living/nightmare
name = "Nightmare"
/datum/keybinding/emote/stare
linked_emote = /datum/emote/living/stare
name = "Stare"
@@ -263,6 +267,10 @@
linked_emote = /datum/emote/living/carbon/faint
name = "Faint"
/datum/keybinding/emote/carbon/sign
linked_emote = /datum/emote/living/carbon/sign
name = "Sign"
/datum/keybinding/emote/carbon/alien
category = KB_CATEGORY_EMOTE_ALIEN
@@ -377,6 +385,10 @@
linked_emote = /datum/emote/living/carbon/human/salute
name = "Salute"
/datum/keybinding/emote/carbon/human/sign/signal
linked_emote = /datum/emote/living/carbon/sign/signal
name = "Signal"
/datum/keybinding/emote/carbon/human/shrug
linked_emote = /datum/emote/living/carbon/human/shrug
name = "Shrug"
@@ -413,6 +425,10 @@
linked_emote = /datum/emote/living/carbon/human/snap
name = "Snap"
/datum/keybinding/emote/carbon/human/crack
linked_emote = /datum/emote/living/carbon/human/crack
name = "Crack"
/datum/keybinding/emote/carbon/human/fart
linked_emote = /datum/emote/living/carbon/human/fart
name = "Fart"
+25 -2
View File
@@ -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