-
Notifications
You must be signed in to change notification settings - Fork 566
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
# About the pull request Adds a unit test for xeno strains. I could have included this in #5542, but I thought it would be better in its own PR in order to keep the checks and everything separate. The removed sprites for the Trapper, Charger, Gardener, and Watcher strains are (as far as I'm able to tell) completely identical to that of the base caste, and are only there in order to make the old system work properly. Currently, this includes the following tests: - Checking that the `caste_type` variable on each `/mob/living/carbon/xenomorph` subtype has a corresponding entry in `GLOB.xeno_datum_list`. (Not really strain related but I figured no harm in including it) - Checking that each `/datum/xeno_strain` subtype has its own `name` and `description`. - Making sure that each strain's `actions_to_add` and `actions_to_remove` lists are added and removed from the xeno properly. (Taking into account any which are re-added.) - Making sure that the strain's `behavior_delegate_type` is successfully added to the xeno. - If the strain doesn't have an `icon_state_prefix`, going through the xeno's `icon` file and double checking that there aren't strain sprites in there (That is, sprites beginning with the strain's name). If there are any, then `icon_state_prefix` should probably be set to use them. - If the strain *does* have an `icon_state_prefix`, making sure that the xeno's sprite actually got changed to the strain version. # Explain why it's good for the game More unit tests! (woo) # Testing Photographs and Procedure <details> <summary>Screenshots & Videos</summary> Put screenshots and videos here with an empty line between the screenshots and the `<details>` tags. </details> # Changelog :cl: code: Added a unit test for xeno strains. /:cl:
- Loading branch information
Showing
10 changed files
with
73 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/datum/unit_test/xeno_strains | ||
|
||
/datum/unit_test/xeno_strains/Run() | ||
for(var/mob/living/carbon/xenomorph/caste_mob as anything in subtypesof(/mob/living/carbon/xenomorph)) | ||
var/datum/caste_datum/caste_datum = GLOB.xeno_datum_list[initial(caste_mob.caste_type)] | ||
if(!caste_datum) | ||
// not really strain related but may as well have this in here | ||
TEST_FAIL("[caste_mob] has no `/datum/caste_datum`! (Possible mismatch of `caste_type`)") | ||
continue | ||
|
||
for(var/datum/xeno_strain/strain_path as anything in caste_datum.available_strains) | ||
// Check for these, but test the strain either way. | ||
if(!initial(strain_path.name)) | ||
TEST_FAIL("[strain_path] has no name!") | ||
if(!initial(strain_path.description)) | ||
TEST_FAIL("[strain_path] has no description!") | ||
|
||
test_strain(caste_mob, strain_path) | ||
|
||
/datum/unit_test/xeno_strains/proc/test_strain(mob_path, strain_path) | ||
var/mob/living/carbon/xenomorph/fred = allocate(mob_path) | ||
var/datum/xeno_strain/strain = new strain_path() | ||
|
||
strain._add_to_xeno(fred) | ||
|
||
// Actions which should have been removed. | ||
var/list/removed_actions = strain.actions_to_remove | ||
// Exclude any actions which are in both strain lists (re-added afterwards). | ||
removed_actions -= (removed_actions & strain.actions_to_add) | ||
|
||
// Actions which should have been added. | ||
var/list/added_actions = strain.actions_to_add.Copy() | ||
|
||
for(var/datum/action/action as anything in fred.actions) | ||
if(action.type in removed_actions) | ||
TEST_FAIL("[strain.type] failed to remove [action.type] when added to a Xenomorph!") | ||
if(action.type in added_actions) | ||
// Remove this action from `added_actions`. | ||
added_actions -= action.type | ||
// If there's anything left in `added_actions`, then something wasn't given to the xeno. | ||
if(length(added_actions)) | ||
TEST_FAIL("[strain.type] failed to give the following actions when added to a Xenomorph: [json_encode(added_actions)]") | ||
|
||
// If the strain has a `/datum/behavior_delegate`, but it wasn't applied to the xeno. | ||
if(strain.behavior_delegate_type && !istype(fred.behavior_delegate, strain.behavior_delegate_type)) | ||
TEST_FAIL("[strain.type]'s behavior_delegate was not applied when added to a Xenomorph!") | ||
|
||
// If the strain doesn't have a custom icon state set. | ||
if(!strain.icon_state_prefix) | ||
// Check if any of the sprites in the xeno's .dmi file belong to this strain. | ||
// If there are any, it probably means that someone just forgot to add an `icon_state_prefix` to the strain. | ||
for(var/icon_state in icon_states(fred.icon)) | ||
if(string_starts_with(icon_state, strain.name)) // (This won't catch everything, but it should get the easy ones.) | ||
TEST_FAIL("[fred.icon] contains sprites for [strain.type] that aren't being used!") | ||
break | ||
|
||
// If the strain *does* have a custom icon state set, but the xeno's sprite wasn't changed to it. | ||
else if(!string_starts_with(fred.icon_state, strain.icon_state_prefix)) | ||
TEST_FAIL("[strain.type]'s icon_state_prefix was not applied when added to a Xenomorph!") |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.