mirror of
https://github.com/DeltaV-Station/Delta-v.git
synced 2026-09-29 23:57:29 +00:00
* Pass 1. * i'm FREE * Prevent hangups. * okay fine here's an attribute for settings, will polish later and prolly remove the overridable thing. * sigh. * fix singular trigger bug so LatheTest doesn't flake. * Remove SystemAttribute usage. * Poke * I used the shotgun. You know why? Cause the shot gun doesn’t miss, and unlike the shitty hybrid taser it stops a criminal in their tracks in two hits. Bang, bang, and they’re fucking done. I use four shots just to make damn sure. Because, once again, I’m not there to coddle a buncha criminal scum sucking f------, I’m there to 1) Survive the fucking round. 2) Guard the armory. So you can absolutely get fucked. If I get unbanned, which I won’t, you can guarantee I will continue to use the shotgun to apprehend criminals. Because it’s quick, clean and effective as fuck. Why in the seven hells would I fuck around with the disabler shots, which take half a clip just to bring someone down, or with the tazer bolts which are slow as balls, impossible to aim and do about next to jack shit, fuck all. The shotgun is the superior law enforcement weapon. Because it stops crime. And it stops crime by reducing the number of criminals roaming the fucking halls. * Change the faulty store test into two tests, one of which is ignored for failing.
161 lines
6.1 KiB
C#
161 lines
6.1 KiB
C#
using Content.IntegrationTests.Fixtures;
|
|
using Content.Server.GameTicking;
|
|
using Content.Server.RoundEnd;
|
|
using Content.Shared.CCVar;
|
|
using Robust.Shared.Configuration;
|
|
using Robust.Shared.GameObjects;
|
|
|
|
namespace Content.IntegrationTests.Tests
|
|
{
|
|
[TestFixture]
|
|
public sealed class RoundEndTest : GameTest
|
|
{
|
|
private sealed class RoundEndTestSystem : EntitySystem
|
|
{
|
|
public int RoundCount;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
SubscribeLocalEvent<RoundEndSystemChangedEvent>(OnRoundEnd);
|
|
}
|
|
|
|
private void OnRoundEnd(RoundEndSystemChangedEvent ev)
|
|
{
|
|
RoundCount += 1;
|
|
}
|
|
}
|
|
|
|
|
|
public override PoolSettings PoolSettings => new PoolSettings
|
|
{
|
|
DummyTicker = false,
|
|
Connected = true,
|
|
Dirty = true
|
|
};
|
|
|
|
[Test]
|
|
public async Task Test()
|
|
{
|
|
var pair = Pair;
|
|
|
|
var server = pair.Server;
|
|
|
|
var config = server.ResolveDependency<IConfigurationManager>();
|
|
var sysManager = server.ResolveDependency<IEntitySystemManager>();
|
|
var ticker = sysManager.GetEntitySystem<GameTicker>();
|
|
var roundEndSystem = sysManager.GetEntitySystem<RoundEndSystem>();
|
|
var sys = server.System<RoundEndTestSystem>();
|
|
sys.RoundCount = 0;
|
|
|
|
await server.WaitAssertion(() =>
|
|
{
|
|
config.SetCVar(CCVars.GameLobbyEnabled, true);
|
|
config.SetCVar(CCVars.EmergencyShuttleMinTransitTime, 1f);
|
|
config.SetCVar(CCVars.EmergencyShuttleDockTime, 1f);
|
|
config.SetCVar(CCVars.RoundRestartTime, 1f);
|
|
|
|
roundEndSystem.DefaultCooldownDuration = TimeSpan.FromMilliseconds(100);
|
|
roundEndSystem.DefaultCountdownDuration = TimeSpan.FromMilliseconds(300);
|
|
});
|
|
|
|
await server.WaitAssertion(() =>
|
|
{
|
|
|
|
// Press the shuttle call button
|
|
roundEndSystem.RequestRoundEnd();
|
|
Assert.Multiple(() =>
|
|
{
|
|
Assert.That(roundEndSystem.ExpectedCountdownEnd, Is.Not.Null, "Shuttle was called, but countdown time was not set");
|
|
Assert.That(roundEndSystem.CanCallOrRecall(), Is.False, "Started the shuttle, but didn't have to wait cooldown to press cancel button");
|
|
});
|
|
// Check that we can't recall the shuttle yet
|
|
roundEndSystem.CancelRoundEndCountdown();
|
|
Assert.That(roundEndSystem.ExpectedCountdownEnd, Is.Not.Null, "Shuttle was cancelled, even though the button was on cooldown");
|
|
});
|
|
|
|
await WaitForEvent(); // Wait for Cooldown
|
|
|
|
await server.WaitAssertion(() =>
|
|
{
|
|
Assert.Multiple(() =>
|
|
{
|
|
Assert.That(roundEndSystem.CanCallOrRecall(), Is.True, "We waited a while, but the cooldown is not expired");
|
|
Assert.That(roundEndSystem.ExpectedCountdownEnd, Is.Not.Null, "We were waiting for the cooldown, but the round also ended");
|
|
});
|
|
// Recall the shuttle, which should trigger the cooldown again
|
|
roundEndSystem.CancelRoundEndCountdown();
|
|
Assert.Multiple(() =>
|
|
{
|
|
Assert.That(roundEndSystem.ExpectedCountdownEnd, Is.Null, "Recalled shuttle, but countdown has not ended");
|
|
Assert.That(roundEndSystem.CanCallOrRecall(), Is.False, "Recalled shuttle, but cooldown has not been enabled");
|
|
});
|
|
});
|
|
|
|
await WaitForEvent(); // Wait for Cooldown
|
|
|
|
await server.WaitAssertion(() =>
|
|
{
|
|
Assert.That(roundEndSystem.CanCallOrRecall(), Is.True, "We waited a while, but the cooldown is not expired");
|
|
// Press the shuttle call button
|
|
roundEndSystem.RequestRoundEnd();
|
|
});
|
|
|
|
await WaitForEvent(); // Wait for Cooldown
|
|
|
|
await server.WaitAssertion(() =>
|
|
{
|
|
Assert.Multiple(() =>
|
|
{
|
|
Assert.That(roundEndSystem.CanCallOrRecall(), Is.True, "We waited a while, but the cooldown is not expired");
|
|
Assert.That(roundEndSystem.ExpectedCountdownEnd, Is.Not.Null, "The countdown ended, but we just wanted the cooldown to end");
|
|
});
|
|
});
|
|
|
|
await WaitForEvent(); // Wait for countdown to end round
|
|
|
|
await CheckRunLevel(GameRunLevel.PostRound);
|
|
|
|
await WaitForEvent(); // Wait for Restart
|
|
|
|
await CheckRunLevel(GameRunLevel.PreRoundLobby);
|
|
|
|
Task CheckRunLevel(GameRunLevel level)
|
|
{
|
|
return server.WaitAssertion(() =>
|
|
{
|
|
Assert.That(ticker.RunLevel, Is.EqualTo(level));
|
|
});
|
|
}
|
|
|
|
async Task WaitForEvent()
|
|
{
|
|
const int maxTicks = 60;
|
|
var currentCount = sys.RoundCount;
|
|
for (var i = 0; i < maxTicks; i++)
|
|
{
|
|
if (currentCount != sys.RoundCount)
|
|
return;
|
|
|
|
await pair.RunTicksSync(1);
|
|
}
|
|
|
|
throw new TimeoutException("Event took too long to trigger");
|
|
}
|
|
|
|
// Need to clean self up
|
|
await server.WaitAssertion(() =>
|
|
{
|
|
config.SetCVar(CCVars.GameLobbyEnabled, false);
|
|
config.SetCVar(CCVars.EmergencyShuttleMinTransitTime, CCVars.EmergencyShuttleMinTransitTime.DefaultValue);
|
|
config.SetCVar(CCVars.EmergencyShuttleDockTime, CCVars.EmergencyShuttleDockTime.DefaultValue);
|
|
config.SetCVar(CCVars.RoundRestartTime, CCVars.RoundRestartTime.DefaultValue);
|
|
|
|
roundEndSystem.DefaultCooldownDuration = TimeSpan.FromSeconds(30);
|
|
roundEndSystem.DefaultCountdownDuration = TimeSpan.FromMinutes(4);
|
|
ticker.RestartRound();
|
|
});
|
|
}
|
|
}
|
|
}
|