Files
Bubberstation/code/modules/unit_tests/armor_verification.dm
SkyratBot dfbaf63d71 [MIRROR] Fix underlying armor logic and fix bug with constructed ripleys having zero armor [MDB IGNORE] (#19310)
* Fix underlying armor logic and fix bug with constructed ripleys having zero armor (#73319)

## About The Pull Request

See title
## Why It's Good For The Game

Messed up one of the armor procs; it changed the given values but never
carried over existing values.
So you would end up with an armor of that one specific value and nothing
else.

This wasn't actually used anywhere other than mecha, lava burning, and
sentient viruses, so the issue isn't that bad.
It's still an issue however.
## Changelog
🆑
fix: Mechs no longer have zero armor when built.
/🆑

* Fix underlying armor logic and fix bug with constructed ripleys having zero armor

---------

Co-authored-by: Zephyr <12817816+ZephyrTFA@users.noreply.github.com>
2023-02-12 22:17:07 -08:00

34 lines
1.3 KiB
Plaintext

/// Verifies that armor procs are working as expected
/datum/unit_test/armor_verification
/datum/unit_test/armor_verification/Run()
var/obj/dummy = allocate(/obj)
dummy.set_armor(/datum/armor/none)
var/datum/armor/armor = dummy.get_armor()
TEST_ASSERT_NOTNULL(armor, "armor didn't populate correctly when needed")
TEST_ASSERT_EQUAL(armor_totals(armor), 0, "none armor type had armor values")
armor = armor.generate_new_with_specific(list(FIRE = 20))
TEST_ASSERT_EQUAL(armor_totals(armor), 20, "modified armor type had incorrect values")
armor = armor.generate_new_with_specific(list(ACID = 20))
TEST_ASSERT_EQUAL(armor_totals(armor), 40, "modified armor type had incorrect values")
armor = get_armor_by_type(/datum/armor/immune)
var/totals = armor_totals(armor)
armor = armor.generate_new_with_multipliers(list(ARMOR_ALL = 0))
TEST_ASSERT_EQUAL(armor_totals(armor), totals, "modified an immune armor type")
var/wanted = 40
dummy.set_armor(/datum/armor/none)
dummy.set_armor_rating(ENERGY, wanted * 0.5)
dummy.set_armor_rating(FIRE, wanted * 0.5)
TEST_ASSERT_EQUAL(armor_totals(dummy.get_armor()), wanted, "modified armor type had incorrect values")
/datum/unit_test/armor_verification/proc/armor_totals(datum/armor/armor)
var/total = 0
for(var/key in ARMOR_LIST_ALL())
total += armor.vars[key]
return total