mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2025-12-10 01:34:01 +00:00
Security officers will now be paired up together in the same department, across departments. This means that, instead of 4 officers being split across 4 departments, there'll now be 2 groups of 2. Late-join officers will be put into any department with only 1 officer. If none exist, the least populous department will be chosen, with their preference having priority. Updates the maps to have more spawns for departmental officers. Delta previously had none, and now has some. Fixed a bug where MetaStation's security departmental officer was a supply one instead. Removes the "random" departmental preference. All security officers are now given a department. The "none" preference still exists, but just to show that you don't care which department you're put into. Updates the config to comment out SEC_START_BRIG. This is what the configuration was already on live servers. This is something that should likely be test merged, but it mucks with savefiles. Luckily, the only damage it does is changing random departments to none, so if a TM is reverted, only that will have to be changed.
102 lines
3.9 KiB
Plaintext
102 lines
3.9 KiB
Plaintext
#define SECURITY_OFFICER_DEPARTMENTS list("a", "b", "c", "d")
|
|
|
|
/// Test that security officers with specific distributions get their departments.
|
|
/datum/unit_test/security_officer_roundstart_distribution
|
|
|
|
/datum/unit_test/security_officer_roundstart_distribution/proc/test(
|
|
list/preferences,
|
|
list/expected,
|
|
)
|
|
var/list/outcome = get_officer_departments(preferences, SECURITY_OFFICER_DEPARTMENTS)
|
|
var/failure_message = "Tested with [json_encode(preferences)] and expected [json_encode(expected)], got [json_encode(outcome)]"
|
|
|
|
if (outcome.len == expected.len)
|
|
for (var/index in 1 to outcome.len)
|
|
if (outcome[index] != expected[index])
|
|
Fail(failure_message)
|
|
return
|
|
else
|
|
Fail(failure_message)
|
|
|
|
/datum/unit_test/security_officer_roundstart_distribution/Run()
|
|
test_distributions()
|
|
test_with_mock_players()
|
|
|
|
/datum/unit_test/security_officer_roundstart_distribution/proc/test_distributions()
|
|
test(list("a"), list("a"))
|
|
test(list("a", "b"), list("a", "a"))
|
|
test(list("a", "b", "c"), list("a", "a", "a"))
|
|
test(list("a", "a", "b"), list("a", "a", "a"))
|
|
test(list("a", "a", "b", "b"), list("a", "a", "b", "b"))
|
|
test(list("a", "a", "a", "b"), list("a", "a", "b", "b"))
|
|
test(list("a", "b", "c", "d"), list("a", "b", "b", "a"))
|
|
test(list(SEC_DEPT_NONE), list("d"))
|
|
test(list("a", SEC_DEPT_NONE), list("a", "a"))
|
|
test(list(SEC_DEPT_NONE, SEC_DEPT_NONE, SEC_DEPT_NONE, SEC_DEPT_NONE), list("d", "d", "c", "c"))
|
|
|
|
/datum/unit_test/security_officer_roundstart_distribution/proc/test_with_mock_players()
|
|
var/mob/dead/new_player/officer_a = create_officer("a")
|
|
var/mob/dead/new_player/officer_b = create_officer("b")
|
|
var/mob/dead/new_player/officer_c = create_officer("c")
|
|
var/mob/dead/new_player/officer_d = create_officer("d")
|
|
|
|
var/list/outcome = SSticker.decide_security_officer_departments(
|
|
list(officer_a, officer_b, officer_c, officer_d),
|
|
SECURITY_OFFICER_DEPARTMENTS,
|
|
)
|
|
|
|
TEST_ASSERT_EQUAL(outcome[REF(officer_a.new_character)], "a", "Officer A's department outcome was incorrect.")
|
|
TEST_ASSERT_EQUAL(outcome[REF(officer_b.new_character)], "b", "Officer B's department outcome was incorrect.")
|
|
TEST_ASSERT_EQUAL(outcome[REF(officer_c.new_character)], "b", "Officer C's department outcome was incorrect.")
|
|
TEST_ASSERT_EQUAL(outcome[REF(officer_d.new_character)], "a", "Officer D's department outcome was incorrect.")
|
|
|
|
/datum/unit_test/security_officer_roundstart_distribution/proc/create_officer(preference)
|
|
var/mob/dead/new_player/new_player = allocate(/mob/dead/new_player)
|
|
var/datum/client_interface/mock_client = new
|
|
|
|
mock_client.prefs = new
|
|
mock_client.prefs.prefered_security_department = preference
|
|
|
|
var/mob/living/carbon/human/new_character = allocate(/mob/living/carbon/human)
|
|
new_character.mind_initialize()
|
|
new_character.mind.assigned_role = "Security Officer"
|
|
|
|
new_player.new_character = new_character
|
|
new_player.mock_client = mock_client
|
|
return new_player
|
|
|
|
/// Test that latejoin security officers are put into the correct department
|
|
/datum/unit_test/security_officer_latejoin_distribution
|
|
|
|
/datum/unit_test/security_officer_latejoin_distribution/proc/test(
|
|
preference,
|
|
list/preferences_of_others,
|
|
expected,
|
|
)
|
|
var/list/distribution = list()
|
|
|
|
for (var/officer_preference in preferences_of_others)
|
|
var/mob/officer = allocate(/mob/living/carbon/human)
|
|
distribution[officer] = officer_preference
|
|
|
|
var/result = get_new_officer_distribution_from_late_join(
|
|
preference,
|
|
SECURITY_OFFICER_DEPARTMENTS,
|
|
distribution,
|
|
)
|
|
|
|
var/failure_message = "Latejoin distribution was incorrect (preference = [preference], preferences_of_others = [json_encode(preferences_of_others)])."
|
|
|
|
TEST_ASSERT_EQUAL(result, expected, failure_message)
|
|
|
|
/datum/unit_test/security_officer_latejoin_distribution/Run()
|
|
test("a", list(), "a")
|
|
test("b", list(), "b")
|
|
test("a", list("b"), "b")
|
|
test("a", list("a", "a"), "b")
|
|
test("a", list("a", "a", "b"), "b")
|
|
test("a", list("a", "a", "b", "b"), "c")
|
|
test("a", list("a", "a", "b", "b", "c", "c", "d", "d"), "a")
|
|
|
|
#undef SECURITY_OFFICER_DEPARTMENTS
|