using System.Collections.Generic;
using System.Text;
using Content.Client.Implants;
using Content.IntegrationTests.Tests.Interaction;
using Content.Shared.Clothing;
using Content.Shared.Implants;
using Content.Shared.Preferences.Loadouts;
using Content.Shared.Roles;
using Robust.Shared.Prototypes;
namespace Content.IntegrationTests.Tests.Chameleon;
///
/// Ensures all round "round start jobs" have an associated chameleon loadout.
///
public sealed class ChameleonJobLoadoutTest : InteractionTest
{
private readonly List> JobBlacklist =
[
];
[Test]
public async Task CheckAllJobs()
{
var alljobs = ProtoMan.EnumeratePrototypes();
// Job -> number of references
Dictionary, int> validJobs = new();
// Only add stuff that actually has clothing! We don't want stuff like AI or borgs.
foreach (var job in alljobs)
{
if (!IsProbablyRoundStartJob(job) || JobBlacklist.Contains(job.ID))
continue;
validJobs.Add(job.ID, 0);
}
var chameleons = ProtoMan.EnumeratePrototypes();
foreach (var chameleon in chameleons)
{
if (chameleon.Job == null || !validJobs.ContainsKey(chameleon.Job.Value))
continue;
validJobs[chameleon.Job.Value] += 1;
}
var errorMessage = new StringBuilder();
errorMessage.AppendLine("The following job(s) have no chameleon prototype(s):");
var invalid = false;
// All round start jobs have a chameleon loadout
foreach (var job in validJobs)
{
if (job.Value != 0)
continue;
errorMessage.AppendLine(job.Key + " has no chameleonOutfit prototype.");
invalid = true;
}
if (!invalid)
return;
Assert.Fail(errorMessage.ToString());
}
///
/// Best guess at what a "round start" job is.
///
private bool IsProbablyRoundStartJob(JobPrototype job)
{
return job.StartingGear != null && ProtoMan.HasIndex(LoadoutSystem.GetJobPrototype(job.ID));
}
}