|
| 1 | +/datum/unit_test/mapping_standards/enforce_count |
| 2 | + abstract_type = /datum/unit_test/mapping_standards/enforce_count |
| 3 | + |
| 4 | + |
| 5 | + var/allowed_count = 1 |
| 6 | + |
| 7 | + /// Type to check. Includes subtypes. |
| 8 | + var/checked_type = null |
| 9 | + /// 'Friendly Name' used in fail messages. |
| 10 | + var/failed_name = "Bad Objects" |
| 11 | + |
| 12 | +/datum/unit_test/mapping_standards/enforce_count/proc/get_collection() |
| 13 | + TEST_FAIL("Missing Collection Setup, Bad Test!") |
| 14 | + |
| 15 | +/datum/unit_test/mapping_standards/enforce_count/Run() |
| 16 | + if(..()) |
| 17 | + return |
| 18 | + |
| 19 | + /// Turfs we've passed once. We don't fully count every tile. |
| 20 | + var/list/turf/checked_turfs = list() |
| 21 | + /// Tiles we've fully counted, If we reach these again, we can |
| 22 | + /// safely skip them. |
| 23 | + var/list/turf/counted_turfs = list() |
| 24 | + |
| 25 | + for(var/atom/checked_atom as anything in get_collection()) |
| 26 | + if(!istype(checked_atom, checked_type)) |
| 27 | + continue //Skip types we aren't checking. |
| 28 | + var/area/atom_area = get_area(checked_atom) |
| 29 | + if(!(atom_area.type in GLOB.the_station_areas)) |
| 30 | + continue //Not on station, Skip. |
| 31 | + |
| 32 | + var/turf/atom_turf = get_turf(checked_atom) |
| 33 | + if(atom_turf in checked_turfs) |
| 34 | + if(atom_turf in counted_turfs) |
| 35 | + continue //Already reported. |
| 36 | + counted_turfs.Add(atom_turf) |
| 37 | + var/atom_count = 0 |
| 38 | + for(var/_counter as anything in atom_turf) |
| 39 | + if(!istype(_counter, checked_type)) |
| 40 | + continue // Not of the type we care about. |
| 41 | + atom_count++ |
| 42 | + if(atom_count < allowed_count) |
| 43 | + continue //We've counted, but the count came up short. Not a failure. |
| 44 | + TEST_FAIL("[atom_count] [failed_name] on tile at [AREACOORD(atom_turf)]") |
| 45 | + continue //Already added to the checked list. |
| 46 | + //Else |
| 47 | + checked_turfs.Add(atom_turf) |
0 commit comments