Fixes quick swapping suits creating illegal suit storage (#53272)

This commit is contained in:
Jared-Fogle
2020-09-01 01:03:25 -07:00
committed by GitHub
parent 09b9ad869e
commit fc2cea5955
3 changed files with 41 additions and 1 deletions
+2 -1
View File
@@ -8,7 +8,7 @@
/// Asserts that the two parameters passed are equal, fails otherwise
/// Optionally allows an additional message in the case of a failure
#define TEST_ASSERT_EQUAL(a, b, message) if ((a) != (b)) { return Fail("Expected [a] to be equal to [b].[message ? " [message]" : ""]") }
#define TEST_ASSERT_EQUAL(a, b, message) if ((a) != (b)) { return Fail("Expected [isnull(a) ? "null" : a] to be equal to [isnull(b) ? "null" : b].[message ? " [message]" : ""]") }
#include "anchored_mobs.dm"
#include "bespoke_id.dm"
@@ -23,6 +23,7 @@
#include "metabolizing.dm"
#include "outfit_sanity.dm"
#include "plantgrowth_tests.dm"
#include "quick_swap_sanity.dm"
#include "reagent_id_typos.dm"
#include "reagent_recipe_collisions.dm"
#include "resist.dm"
@@ -0,0 +1,31 @@
/// Test that quick swap correctly swaps items and invalidates suit storage
/datum/unit_test/quick_swap_sanity/Run()
// Create a human with a medical winter coat and a health analyzer in suit storage
var/mob/living/carbon/human/human = allocate(/mob/living/carbon/human)
var/obj/item/coat = allocate(/obj/item/clothing/suit/hooded/wintercoat/medical)
TEST_ASSERT(human.equip_to_slot_if_possible(coat, ITEM_SLOT_OCLOTHING), "Couldn't equip winter coat")
var/obj/item/analyzer = allocate(/obj/item/healthanalyzer)
TEST_ASSERT(human.equip_to_slot_if_possible(analyzer, ITEM_SLOT_SUITSTORE), "Couldn't equip health analyzer")
// Then, have them quick swap between the coat and a space suit
var/obj/item/hardsuit = allocate(/obj/item/clothing/suit/space/hardsuit)
TEST_ASSERT(human.equip_to_appropriate_slot(hardsuit, swap = TRUE), "Couldn't quick swap to hardsuit")
// Check if the human has the hardsuit on
TEST_ASSERT_EQUAL(human.wear_suit, hardsuit, "Human didn't equip the hardsuit")
// Make sure the health analyzer was dropped as part of the swap
// Since health analyzers are an invalid suit storage item
TEST_ASSERT_EQUAL(human.s_store, null, "Human didn't drop the health analyzer")
// Give the human an emergency oxygen tank
// This is valid suit storage for both the winter coat AND the hardsuit
var/obj/item/tank = allocate(/obj/item/tank/internals/emergency_oxygen)
TEST_ASSERT(human.equip_to_slot_if_possible(tank, ITEM_SLOT_SUITSTORE), "Couldn't equip emergency oxygen tank")
// Now, quick swap back to the coat
// Since the tank is a valid suit storage item, it should not be dropped
TEST_ASSERT(human.equip_to_appropriate_slot(coat, swap = TRUE), "Couldn't quick swap to coat")
TEST_ASSERT_EQUAL(human.s_store, tank, "Human dropped the oxygen tank, when it was a valid item to keep in suit storage")