Skip to content
This repository has been archived by the owner on Apr 27, 2024. It is now read-only.

Commit

Permalink
Fix Crime Assist incorrect entires and add a test (space-wizards#624)
Browse files Browse the repository at this point in the history
* Create CrimeassistTest.cs

* Fix invalid crimeasssist entries

* Clean up test code

(cherry picked from commit c66677797c44e6d6b6af976082ed977a7cdcb0b9)
  • Loading branch information
Peptide90 committed Feb 16, 2024
1 parent faca628 commit 0cbbc70
Show file tree
Hide file tree
Showing 2 changed files with 94 additions and 8 deletions.
79 changes: 79 additions & 0 deletions Content.IntegrationTests/Tests/DeltaV/CrimeassistTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
using System.Linq;
using Content.Shared.DeltaV.CartridgeLoader.Cartridges;
using Robust.Shared.GameObjects;
using Robust.Shared.Localization;
using Robust.Shared.Map;
using Robust.Shared.Prototypes;

namespace Content.IntegrationTests.Tests.DeltaV;

[TestFixture]
public sealed class CrimeAssistTest
{
[Test]
public async Task CrimeAssistValid()
{
await using var pair = await PoolManager.GetServerClient();
var server = pair.Server;
await server.WaitIdleAsync();

var prototypeManager = server.ResolveDependency<IPrototypeManager>();
var allProtos = prototypeManager.EnumeratePrototypes<CrimeAssistPage>().ToArray();

await server.WaitAssertion(() =>
{
foreach (var proto in allProtos)
{
if (proto.LocKey != null)
{
Assert.That(Loc.TryGetString(proto.LocKey, out var _),
$"CrimeAssistPage {proto.ID} has invalid LocKey {proto.LocKey}!");
}
if (proto.LocKeyTitle != null)
{
Assert.That(Loc.TryGetString(proto.LocKeyTitle, out var _),
$"CrimeAssistPage {proto.ID} has invalid LocKeyTitle {proto.LocKeyTitle}!");
}
if (proto.LocKeyDescription != null)
{
Assert.That(Loc.TryGetString(proto.LocKeyDescription, out var _),
$"CrimeAssistPage {proto.ID} has invalid LocKeyDescription {proto.LocKeyDescription}!");
}
if (proto.LocKeySeverity != null)
{
Assert.That(Loc.TryGetString(proto.LocKeySeverity, out var _),
$"CrimeAssistPage {proto.ID} has invalid LocKeySeverity {proto.LocKeySeverity}!");
}
if (proto.LocKeyPunishment != null)
{
Assert.That(Loc.TryGetString(proto.LocKeyPunishment, out var _),
$"CrimeAssistPage {proto.ID} has invalid LocKeyPunishment {proto.LocKeyPunishment}!");
}
if (proto.OnStart != null)
{
Assert.That(allProtos.Any(p => p.ID == proto.OnStart),
$"CrimeAssistPage {proto.ID} has invalid OnStart {proto.OnStart}!");
}
if (proto.OnYes != null)
{
Assert.That(allProtos.Any(p => p.ID == proto.OnYes),
$"CrimeAssistPage {proto.ID} has invalid OnYes {proto.OnYes}!");
}
if (proto.OnNo != null)
{
Assert.That(allProtos.Any(p => p.ID == proto.OnNo),
$"CrimeAssistPage {proto.ID} has invalid OnNo {proto.OnNo}!");
}
}
});

await pair.CleanReturnAsync();
}
}
23 changes: 15 additions & 8 deletions Resources/Prototypes/DeltaV/cartridges/crimeassistflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@
- type: crimeAssistPage
id: "questionWasCrimeSexualInNature"
locKey: "crime-assist-question-wascrimesexualinnature"
onYes: "resultSexualHarrassment"
onYes: "resultSexualHarassment"
onNo: "questionWasSuspectANuisance"

- type: crimeAssistPage
Expand Down Expand Up @@ -278,12 +278,19 @@
locKeySeverity: "crime-assist-crimetype-felony"
locKeyPunishment: "crime-assist-crimepunishment-contemptofcourt"

- type: crimeAssistPage
id: "resultBlackMarketeering"
locKeyTitle: "crime-assist-crime-blackmarketeering"
locKeyDescription: "crime-assist-crimedetail-blackmarketeering"
locKeySeverity: "crime-assist-crimetype-felony"
locKeyPunishment: "crime-assist-crimepunishment-blackmarketeering"

- type: crimeAssistPage
id: "resultPerjuryOrFalseReport"
locKeyTitle: "crime-assist-crime-perjuryorfalsereport"
locKeyDescription: "crime-assist-crimedetail-perjuryorfalsereport"
locKeyTitle: "crime-assist-crime-perjuryfalsereport"
locKeyDescription: "crime-assist-crimedetail-perjuryfalsereport"
locKeySeverity: "crime-assist-crimetype-felony"
locKeyPunishment: "crime-assist-crimepunishment-perjuryorfalsereport"
locKeyPunishment: "crime-assist-crimepunishment-perjuryfalsereport"

- type: crimeAssistPage
id: "resultObstructionOfJustice"
Expand Down Expand Up @@ -335,8 +342,8 @@
locKeyPunishment: "crime-assist-crimepunishment-sedition"

- type: crimeAssistPage
id: "resultSexualHarrassment"
locKeyTitle: "crime-assist-crime-sexualharrassment"
locKeyDescription: "crime-assist-crimedetail-sexualharrassment"
id: "resultSexualHarassment"
locKeyTitle: "crime-assist-crime-sexualharassment"
locKeyDescription: "crime-assist-crimedetail-sexualharassment"
locKeySeverity: "crime-assist-crimetype-capital"
locKeyPunishment: "crime-assist-crimepunishment-sexualharrassment"
locKeyPunishment: "crime-assist-crimepunishment-sexualharassment"

0 comments on commit 0cbbc70

Please sign in to comment.