-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix: fix loadouts not spawning items inhands * Prevent SecretRule from picking invalid presets (#27456) * Prevent SecretRule from picking invalid presets * remove lonely semicolon --------- Co-authored-by: Nemanja <98561806+EmoGarbage404@users.noreply.github.com> * fix: fix makethief adminverb icon * fix antag selection being evil (#28197) * fix antag selection being evil * fix test * untroll the other tests * remove role timer troll * Allow tests to modify antag preferences * Fix antag selection * Misc test fixes * Add AntagPreferenceTest * Fix lazy mistakes * Test cleanup * Try stop players in lobbies from being assigned mid-round antags * ranting * I am going insane --------- Co-authored-by: deltanedas <@deltanedas:kde.org> Co-authored-by: ElectroJr <leonsfriedrich@gmail.com> # Conflicts: # Content.Server/Antag/AntagSelectionSystem.API.cs # Content.Server/Antag/AntagSelectionSystem.cs # Content.Server/Preferences/Managers/ServerPreferencesManager.cs * Fix under-selecting antags (#28327) Fix under selecting antags * fix: antag adminverbs now target actual target * fix: test --------- Co-authored-by: Leon Friedrich <60421075+ElectroJr@users.noreply.github.com> Co-authored-by: Nemanja <98561806+EmoGarbage404@users.noreply.github.com> Co-authored-by: deltanedas <39013340+deltanedas@users.noreply.github.com>
- Loading branch information
1 parent
2ea1619
commit 69f3452
Showing
16 changed files
with
391 additions
and
128 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
Content.IntegrationTests/Tests/GameRules/AntagPreferenceTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
#nullable enable | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using Content.Server.Antag; | ||
using Content.Server.Antag.Components; | ||
using Content.Server.GameTicking; | ||
using Content.Shared.GameTicking; | ||
using Robust.Shared.GameObjects; | ||
using Robust.Shared.Player; | ||
using Robust.Shared.Random; | ||
|
||
namespace Content.IntegrationTests.Tests.GameRules; | ||
|
||
// Once upon a time, players in the lobby weren't ever considered eligible for antag roles. | ||
// Lets not let that happen again. | ||
[TestFixture] | ||
public sealed class AntagPreferenceTest | ||
{ | ||
[Test] | ||
public async Task TestLobbyPlayersValid() | ||
{ | ||
await using var pair = await PoolManager.GetServerClient(new PoolSettings | ||
{ | ||
DummyTicker = false, | ||
Connected = true, | ||
InLobby = true | ||
}); | ||
|
||
var server = pair.Server; | ||
var client = pair.Client; | ||
var ticker = server.System<GameTicker>(); | ||
var sys = server.System<AntagSelectionSystem>(); | ||
|
||
// Initially in the lobby | ||
Assert.That(ticker.RunLevel, Is.EqualTo(GameRunLevel.PreRoundLobby)); | ||
Assert.That(client.AttachedEntity, Is.Null); | ||
Assert.That(ticker.PlayerGameStatuses[client.User!.Value], Is.EqualTo(PlayerGameStatus.NotReadyToPlay)); | ||
|
||
EntityUid uid = default; | ||
await server.WaitPost(() => uid = server.EntMan.Spawn("Traitor")); | ||
var rule = new Entity<AntagSelectionComponent>(uid, server.EntMan.GetComponent<AntagSelectionComponent>(uid)); | ||
var def = rule.Comp.Definitions.Single(); | ||
|
||
// IsSessionValid & IsEntityValid are preference agnostic and should always be true for players in the lobby. | ||
// Though maybe that will change in the future, but then GetPlayerPool() needs to be updated to reflect that. | ||
Assert.That(sys.IsSessionValid(rule, pair.Player, def), Is.True); | ||
Assert.That(sys.IsEntityValid(client.AttachedEntity, def), Is.True); | ||
|
||
// By default, traitor/antag preferences are disabled, so the pool should be empty. | ||
var sessions = new List<ICommonSession>{pair.Player!}; | ||
var pool = sys.GetPlayerPool(rule, sessions, def); | ||
Assert.That(pool.Count, Is.EqualTo(0)); | ||
|
||
// Opt into the traitor role. | ||
await pair.SetAntagPref("Traitor", true); | ||
|
||
Assert.That(sys.IsSessionValid(rule, pair.Player, def), Is.True); | ||
Assert.That(sys.IsEntityValid(client.AttachedEntity, def), Is.True); | ||
pool = sys.GetPlayerPool(rule, sessions, def); | ||
Assert.That(pool.Count, Is.EqualTo(1)); | ||
pool.TryPickAndTake(pair.Server.ResolveDependency<IRobustRandom>(), out var picked); | ||
Assert.That(picked, Is.EqualTo(pair.Player)); | ||
Assert.That(sessions.Count, Is.EqualTo(1)); | ||
|
||
// opt back out | ||
await pair.SetAntagPref("Traitor", false); | ||
|
||
Assert.That(sys.IsSessionValid(rule, pair.Player, def), Is.True); | ||
Assert.That(sys.IsEntityValid(client.AttachedEntity, def), Is.True); | ||
pool = sys.GetPlayerPool(rule, sessions, def); | ||
Assert.That(pool.Count, Is.EqualTo(0)); | ||
|
||
await server.WaitPost(() => server.EntMan.DeleteEntity(uid)); | ||
await pair.CleanReturnAsync(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.