* works, still has testing values, im sure I did stupid shit. * shitvent crapfactor * snap extra word out of existence * shit I died of old * remove useless inaccurate design comments * Oopsie, handle requirement params in RandomRuleSystem too * I'm a slash slinging hasher * Address reviews, add admin alerts I forgor * EntityMan saves the day * address reviews 1 * eh, I actually don't care about the cargo gifts thing. * started * Do reviews * you actually meant 1.2 lmao * dependency inheritance is a fickle bitch * I have no idea. * Threads are for sheets not computers. * fix traitor rule test * fix round type tattling * break things * It worky * Toolshed makes we want to drink depresso. * Finished? * remove debug values * timings * use defaults * alphabetize * bobby drop tables * Float required fr fr * continue * more continence * uno mas * obsolution * cleanup and documentations * Yell at self * use the right value defaults * housekeeping
72 lines
2.8 KiB
C#
72 lines
2.8 KiB
C#
using Content.Server.GameTicking;
|
|
using Content.Server.GameTicking.Rules;
|
|
using Content.Server.GameTicking.Rules.Components;
|
|
using Content.Shared.GameTicking.Components;
|
|
using Robust.Shared.GameObjects;
|
|
using Robust.Shared.Timing;
|
|
|
|
namespace Content.IntegrationTests.Tests.GameRules
|
|
{
|
|
[TestFixture]
|
|
[TestOf(typeof(MaxTimeRestartRuleSystem))]
|
|
public sealed class RuleMaxTimeRestartTest
|
|
{
|
|
[Test]
|
|
public async Task RestartTest()
|
|
{
|
|
await using var pair = await PoolManager.GetServerClient(new PoolSettings { InLobby = true });
|
|
var server = pair.Server;
|
|
|
|
Assert.That(server.EntMan.Count<GameRuleComponent>(), Is.Zero);
|
|
Assert.That(server.EntMan.Count<ActiveGameRuleComponent>(), Is.Zero);
|
|
|
|
var entityManager = server.ResolveDependency<IEntityManager>();
|
|
var sGameTicker = server.ResolveDependency<IEntitySystemManager>().GetEntitySystem<GameTicker>();
|
|
var sGameTiming = server.ResolveDependency<IGameTiming>();
|
|
|
|
MaxTimeRestartRuleComponent maxTime = null;
|
|
await server.WaitPost(() =>
|
|
{
|
|
sGameTicker.StartGameRule("MaxTimeRestart", out var ruleEntity);
|
|
Assert.That(entityManager.TryGetComponent<MaxTimeRestartRuleComponent>(ruleEntity, out maxTime));
|
|
});
|
|
|
|
Assert.That(server.EntMan.Count<GameRuleComponent>(), Is.EqualTo(1));
|
|
Assert.That(server.EntMan.Count<ActiveGameRuleComponent>(), Is.EqualTo(1));
|
|
|
|
await server.WaitAssertion(() =>
|
|
{
|
|
Assert.That(sGameTicker.RunLevel, Is.EqualTo(GameRunLevel.PreRoundLobby));
|
|
maxTime.RoundMaxTime = TimeSpan.FromSeconds(3);
|
|
sGameTicker.StartRound();
|
|
});
|
|
|
|
Assert.That(server.EntMan.Count<GameRuleComponent>(), Is.EqualTo(1));
|
|
Assert.That(server.EntMan.Count<ActiveGameRuleComponent>(), Is.EqualTo(1));
|
|
|
|
await server.WaitAssertion(() =>
|
|
{
|
|
Assert.That(sGameTicker.RunLevel, Is.EqualTo(GameRunLevel.InRound));
|
|
});
|
|
|
|
var ticks = sGameTiming.TickRate * (int) Math.Ceiling(maxTime.RoundMaxTime.TotalSeconds * 1.1f);
|
|
await pair.RunTicksSync(ticks);
|
|
|
|
await server.WaitAssertion(() =>
|
|
{
|
|
Assert.That(sGameTicker.RunLevel, Is.EqualTo(GameRunLevel.PostRound));
|
|
});
|
|
|
|
ticks = sGameTiming.TickRate * (int) Math.Ceiling(maxTime.RoundEndDelay.TotalSeconds * 1.1f);
|
|
await pair.RunTicksSync(ticks);
|
|
|
|
await server.WaitAssertion(() =>
|
|
{
|
|
Assert.That(sGameTicker.RunLevel, Is.EqualTo(GameRunLevel.PreRoundLobby));
|
|
});
|
|
|
|
await pair.CleanReturnAsync();
|
|
}
|
|
}
|
|
}
|