Files
Bubberstation/code/modules/unit_tests/spell_names.dm
san7890 66d070a586 Wraps all instances of invoking Fail() into the TEST_FAIL Macro (#73407)
We shouldn't really be invoking the proc itself because then we don't
pass along the failing line/file to our consumers, let's use the macro
in all instances that really need it.

I noticed people were invoking the `Fail()` proc directly rather than
using `TEST_FAIL` instead, so they weren't getting those neat
annotations on their failing code because we never passed along the
failing line/file to actually apply those annotations. That's silly. We
don't even return on `TEST_FAIL` either, so there's no reason to not do
this (only upsides wahoo).
2023-02-16 21:54:04 +00:00

33 lines
1.1 KiB
Plaintext

/**
* Validates that all spells have a different name.
*
* Spell names are used for debugging in some places
* as well as an option for admins giving out spells,
* so every spell should have a distinct name.
*
* If you're making a subtype with only one or two big changes,
* consider adding an adjective to the name.
*
* "Lesser Fireball" for a subtype of Fireball with a shorter cooldown.
* "Deadly Magic Missile" for a subtype of Magic Missile that does damage, etc.
*/
/datum/unit_test/spell_names
/datum/unit_test/spell_names/Run()
var/list/types_to_test = typesof(/datum/action/cooldown/spell)
var/list/existing_names = list()
for(var/datum/action/cooldown/spell/spell_type as anything in types_to_test)
var/spell_name = initial(spell_type.name)
if(spell_name == "Spell")
continue
if(spell_name in existing_names)
TEST_FAIL("Spell: [spell_name] ([spell_type]) had a name identical to another spell. \
This can cause confusion for admins giving out spells, and while debugging. \
Consider giving the name an adjective if it's a subtype. (\"Greater\", \"Lesser\", \"Deadly\".)")
continue
existing_names += spell_name