[MIRROR] Robot offset unittest (#10433)

Co-authored-by: Cameron Lennox <killer65311@gmail.com>
Co-authored-by: Willburd <7099514+Willburd@users.noreply.github.com>
This commit is contained in:
CHOMPStation2StaffMirrorBot
2025-03-15 17:03:00 -07:00
committed by GitHub
parent 1000158323
commit 1ad7827d9d
14 changed files with 134 additions and 3 deletions

View File

@@ -10,6 +10,11 @@
if(!RS.name) // Parent type, ignore me
continue
if(!RS.sprite_icon)
log_unit_test("[RS.type]: Robots - Robot sprite \"[RS.name]\", missing sprite_icon.")
failed = TRUE
continue
var/list/checks = list(
"[ROBOT_HAS_SPEED_SPRITE]" = "-roll",
"[ROBOT_HAS_SHIELD_SPRITE]" = "-shield",
@@ -175,8 +180,24 @@
failed = TRUE
if(RS.has_dead_sprite_overlay) // Only one per dmi
if(!("wreck-overlay" in cached_icon_states(RS.sprite_icon)))
log_unit_test("[RS.type]: Robots - Robot sprite \"[RS.name]\", had wreck-overlay state enabled, but was missing icon_state wreck-overlay, in dmi \"[RS.sprite_icon]\".")
log_unit_test("[RS.type]: Robots - Robot sprite \"[RS.name]\", missing icon_state wreck-overlay, in dmi \"[RS.sprite_icon]\".")
failed = TRUE
// offset
var/icon/I = new(RS.sprite_icon)
if(RS.icon_x != I.Width())
log_unit_test("[RS.type]: Robots - Robot sprite \"[RS.name]\", icon_x \"[RS.icon_x]\" did not match dmi configured width \"[I.Width()]\"")
failed = TRUE
if(RS.icon_y != I.Height())
log_unit_test("[RS.type]: Robots - Robot sprite \"[RS.name]\", icon_y \"[RS.icon_y]\" did not match dmi configured height \"[I.Height()]\"")
failed = TRUE
if(RS.icon_y != RS.vis_height)
log_unit_test("[RS.type]: Robots - Robot sprite \"[RS.name]\", vis_height \"[RS.vis_height]\" did not match icon_y \"[RS.icon_y]\"")
failed = TRUE
var/legal_offset = (I.Width() - world.icon_size) / 2
if(RS.pixel_x != -legal_offset)
log_unit_test("[RS.type]: Robots - Robot sprite \"[RS.name]\", pixel_x \"[RS.pixel_x]\" did not have correct offset, should be \"[-legal_offset]\"")
failed = TRUE
qdel(I)
qdel(RS)
if(failed)
@@ -188,6 +209,6 @@
/datum/unit_test/all_robot_sprites_must_be_valid/proc/check_state(var/datum/robot_sprite/RS,var/append)
var/check_state = "[RS.sprite_icon_state][append]"
if(!(check_state in cached_icon_states(RS.sprite_icon)))
log_unit_test("[RS.type]: Robots - Robot sprite \"[RS.name]\", had [append] state enabled, but was missing icon_state \"[check_state]\", in dmi \"[RS.sprite_icon]\".")
log_unit_test("[RS.type]: Robots - Robot sprite \"[RS.name]\", enabled but missing icon_state \"[check_state]\", in dmi \"[RS.sprite_icon]\".")
return TRUE
return FALSE