From a0171fe2394b7d06d94ee12ccc13151d1d07e08d Mon Sep 17 00:00:00 2001 From: B3none Date: Fri, 22 Dec 2023 16:19:25 +0000 Subject: [PATCH] Continued updates to team swapping logic --- Modules/Managers/Game.cs | 28 +--------------------------- RetakesPlugin.cs | 10 +++++----- 2 files changed, 6 insertions(+), 32 deletions(-) diff --git a/Modules/Managers/Game.cs b/Modules/Managers/Game.cs index 925ec39..6695140 100644 --- a/Modules/Managers/Game.cs +++ b/Modules/Managers/Game.cs @@ -89,33 +89,7 @@ public void TerroristRoundWin() newTerrorists.AddRange(playersLeft.Take(numTerroristsNeeded - newTerrorists.Count)); } - if (newTerrorists.Count < numTerroristsNeeded) - { - Console.WriteLine($"{RetakesPlugin.MessagePrefix}Still not enough terrorists needed."); - var playersLeft = Helpers.Shuffle(sortedCounterTerroristPlayers.Except(newTerrorists).ToList()); - newTerrorists.AddRange(playersLeft.Take(numTerroristsNeeded - newTerrorists.Count)); - } - - var sortedTerroristPlayers = Queue.ActivePlayers - .Where(player => Helpers.IsValidPlayer(player) && player.TeamNum == (int)CsTeam.Terrorist) - .OrderByDescending(player => _playerRoundScores.GetValueOrDefault((int)player.UserId!, 0)) - .ToList(); - - Console.WriteLine($"{RetakesPlugin.MessagePrefix}Got {sortedTerroristPlayers.Count} sortedTerroristPlayers."); - - newTerrorists.AddRange(sortedCounterTerroristPlayers.Where(player => player.Score > 0).Take(numTerroristsNeeded - newTerrorists.Count).ToList()); - - Console.WriteLine($"{RetakesPlugin.MessagePrefix}{sortedTerroristPlayers.Where(player => player.Score > 0).ToList().Count} sortedTerroristPlayers with more than 0 score found."); - Console.WriteLine($"{RetakesPlugin.MessagePrefix}There are currently {newTerrorists.Count} new terrorists."); - - if (newTerrorists.Count < numTerroristsNeeded) - { - Console.WriteLine($"{RetakesPlugin.MessagePrefix}Still not enough terrorists needed."); - var playersLeft = Helpers.Shuffle(sortedCounterTerroristPlayers.Except(newTerrorists).ToList()); - newTerrorists.AddRange(playersLeft.Take(numTerroristsNeeded - newTerrorists.Count)); - } - - Console.WriteLine($"{RetakesPlugin.MessagePrefix}Swapping players to terrorist."); + Console.WriteLine($"{RetakesPlugin.MessagePrefix}Swapping player(s) to terrorist..."); foreach (var player in newTerrorists) { Console.WriteLine($"{RetakesPlugin.MessagePrefix}Swapping player {player.PlayerName} to terrorist."); diff --git a/RetakesPlugin.cs b/RetakesPlugin.cs index 919d0dc..6eef364 100644 --- a/RetakesPlugin.cs +++ b/RetakesPlugin.cs @@ -190,14 +190,14 @@ public HookResult OnRoundPreStart(EventRoundPrestart @event, GameEventInfo info) _gameManager.Queue.DebugQueues(false); // Handle team swaps at the start of the round - if (_didTerroristsWinLastRound) - { - _gameManager.TerroristRoundWin(); - } - else + if (!_didTerroristsWinLastRound) { _gameManager.CounterTerroristRoundWin(); + + return HookResult.Continue; } + + _gameManager.TerroristRoundWin(); return HookResult.Continue; }