2023-04-25 20:23:14 -04:00
|
|
|
|
using System.Linq;
|
2022-09-03 18:40:00 -07:00
|
|
|
|
using Content.Server.GameTicking;
|
|
|
|
|
|
using Robust.Shared.GameObjects;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Content.IntegrationTests.Tests.GameRules;
|
|
|
|
|
|
|
|
|
|
|
|
[TestFixture]
|
|
|
|
|
|
public sealed class SecretStartsTest
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Tests that when secret is started, all of the game rules it successfully adds are also started.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
[Test]
|
|
|
|
|
|
public async Task TestSecretStarts()
|
|
|
|
|
|
{
|
2023-08-25 02:56:51 +02:00
|
|
|
|
await using var pair = await PoolManager.GetServerClient(new PoolSettings { Dirty = true });
|
2022-09-03 18:40:00 -07:00
|
|
|
|
|
2023-08-25 02:56:51 +02:00
|
|
|
|
var server = pair.Server;
|
2022-09-03 18:40:00 -07:00
|
|
|
|
await server.WaitIdleAsync();
|
2024-04-24 21:31:45 -04:00
|
|
|
|
var entMan = server.ResolveDependency<IEntityManager>();
|
2022-09-03 18:40:00 -07:00
|
|
|
|
var gameTicker = server.ResolveDependency<IEntitySystemManager>().GetEntitySystem<GameTicker>();
|
|
|
|
|
|
|
|
|
|
|
|
await server.WaitAssertion(() =>
|
|
|
|
|
|
{
|
2024-01-30 22:52:35 -07:00
|
|
|
|
// this mimics roundflow:
|
|
|
|
|
|
// rules added, then round starts
|
|
|
|
|
|
gameTicker.AddGameRule("Secret");
|
|
|
|
|
|
gameTicker.StartGamePresetRules();
|
2022-09-03 18:40:00 -07:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
// Wait three ticks for any random update loops that might happen
|
|
|
|
|
|
await server.WaitRunTicks(3);
|
|
|
|
|
|
|
|
|
|
|
|
await server.WaitAssertion(() =>
|
|
|
|
|
|
{
|
2024-04-24 21:31:45 -04:00
|
|
|
|
Assert.That(gameTicker.GetAddedGameRules().Count(), Is.GreaterThan(1), $"No additional rules started by secret rule.");
|
2022-09-03 18:40:00 -07:00
|
|
|
|
|
|
|
|
|
|
// End all rules
|
|
|
|
|
|
gameTicker.ClearGameRules();
|
|
|
|
|
|
});
|
|
|
|
|
|
|
2023-08-25 02:56:51 +02:00
|
|
|
|
await pair.CleanReturnAsync();
|
2022-09-03 18:40:00 -07:00
|
|
|
|
}
|
|
|
|
|
|
}
|