From: Rainfey <11758391+Rainfey@users.noreply.github.com> Date: Mon, 1 Jan 2024 02:25:28 +0000 (+0000) Subject: Ensure correct number of thieves are selected (#23270) X-Git-Url: https://git.smokeofanarchy.ru/gitweb.cgi?a=commitdiff_plain;h=3ea7c5e4f776531518f2dc0d39ff06d924124763;p=space-station-14.git Ensure correct number of thieves are selected (#23270) Fix thief selection Co-authored-by: Rainfall --- diff --git a/Content.Server/GameTicking/Rules/ThiefRuleSystem.cs b/Content.Server/GameTicking/Rules/ThiefRuleSystem.cs index 27e0cb592d..11ce2314a1 100644 --- a/Content.Server/GameTicking/Rules/ThiefRuleSystem.cs +++ b/Content.Server/GameTicking/Rules/ThiefRuleSystem.cs @@ -81,11 +81,19 @@ public sealed class ThiefRuleSystem : GameRuleSystem var startThiefCount = Math.Min(component.MaxAllowThief, component.StartCandidates.Count); var thiefPool = _antagSelection.FindPotentialAntags(component.StartCandidates, component.ThiefPrototypeId); //TO DO: When voxes specifies are added, increase their chance of becoming a thief by 4 times >:) - var selectedThieves = _antagSelection.PickAntag(_random.Next(1, startThiefCount), thiefPool); - foreach(var thief in selectedThieves) + //Add 1, as Next() is exclusive of maxValue + var numberOfThievesToSelect = _random.Next(1, startThiefCount + 1); + + //While we dont have the correct number of thieves, and there are potential thieves remaining + while (component.ThievesMinds.Count < numberOfThievesToSelect && thiefPool.Count > 0) { - MakeThief(component, thief, component.PacifistThieves); + Log.Info($"{numberOfThievesToSelect} thieves required, {component.ThievesMinds.Count} currently chosen, {thiefPool.Count} potentials"); + var selectedThieves = _antagSelection.PickAntag(numberOfThievesToSelect - component.ThievesMinds.Count, thiefPool); + foreach (var thief in selectedThieves) + { + MakeThief(component, thief, component.PacifistThieves); + } } }