From 3944c5421bcc545cfbe0b77a8a2333b11cc68c6b Mon Sep 17 00:00:00 2001 From: haiwwkes <49613070+rhailrake@users.noreply.github.com> Date: Sun, 13 Oct 2024 04:40:40 +0500 Subject: [PATCH] aaaaa (#733) --- .../Antag/AntagSelectionPlayerPool.cs | 26 ++++++---- Content.Server/Antag/AntagSelectionSystem.cs | 50 ++++++++++++++++--- .../_White/MeatyOre/MeatyOreStoreSystem.cs | 3 +- .../_White/Sponsors/MsgSponsorInfo.cs | 3 ++ 4 files changed, 65 insertions(+), 17 deletions(-) diff --git a/Content.Server/Antag/AntagSelectionPlayerPool.cs b/Content.Server/Antag/AntagSelectionPlayerPool.cs index 87873e96d1..3c61cb7e19 100644 --- a/Content.Server/Antag/AntagSelectionPlayerPool.cs +++ b/Content.Server/Antag/AntagSelectionPlayerPool.cs @@ -1,27 +1,35 @@ using System.Diagnostics.CodeAnalysis; -using System.Linq; using Robust.Shared.Player; using Robust.Shared.Random; namespace Content.Server.Antag; -public sealed class AntagSelectionPlayerPool (List> orderedPools) +public sealed class AntagSelectionPlayerPool { + private readonly List _premiumPool; + private readonly List _defaultPool; + + public AntagSelectionPlayerPool(List> orderedPools) + { + _premiumPool = orderedPools[0]; + _defaultPool = orderedPools[1]; + } + public bool TryPickAndTake(IRobustRandom random, [NotNullWhen(true)] out ICommonSession? session) { session = null; - foreach (var pool in orderedPools) + if (_premiumPool.Count > 0) { - if (pool.Count == 0) - continue; - - session = random.PickAndTake(pool); - break; + session = random.PickAndTake(_premiumPool); + } + else if (_defaultPool.Count > 0) + { + session = random.PickAndTake(_defaultPool); } return session != null; } - public int Count => orderedPools.Sum(p => p.Count); + public int Count => _premiumPool.Count + _defaultPool.Count; } diff --git a/Content.Server/Antag/AntagSelectionSystem.cs b/Content.Server/Antag/AntagSelectionSystem.cs index 5bbfff582e..fa49a9f59c 100644 --- a/Content.Server/Antag/AntagSelectionSystem.cs +++ b/Content.Server/Antag/AntagSelectionSystem.cs @@ -26,6 +26,7 @@ using Robust.Shared.Map; using Robust.Shared.Player; using Robust.Shared.Random; using Content.Server._Miracle.GulagSystem; +using Content.Server._White.Sponsors; using Content.Server.Inventory; using Robust.Shared.Utility; @@ -45,6 +46,7 @@ public sealed partial class AntagSelectionSystem : GameRuleSystem public AntagSelectionPlayerPool GetPlayerPool(Entity ent, IList sessions, AntagSelectionDefinition def) { - var preferredList = new List(); - var fallbackList = new List(); + var premiumPool = new List(); + var defaultPool = new List(); + foreach (var session in sessions) { if (!IsSessionValid(ent, session, def) || @@ -342,17 +345,36 @@ public sealed partial class AntagSelectionSystem : GameRuleSystem def.PrefRoles.Contains(p))) + var hasPreference = def.PrefRoles.Count != 0 && pref.AntagPreferences.Any(p => def.PrefRoles.Contains(p)); + var hasFallbackPreference = def.FallbackRoles.Count != 0 && pref.AntagPreferences.Any(p => def.FallbackRoles.Contains(p)); + + if (RobustRandom.Prob(GetPremiumPoolChance(session))) { - preferredList.Add(session); + if (hasPreference || hasFallbackPreference) + premiumPool.Add(session); } - else if (def.FallbackRoles.Count != 0 && pref.AntagPreferences.Any(p => def.FallbackRoles.Contains(p))) + else { - fallbackList.Add(session); + if (hasPreference) + defaultPool.Add(session); + else if (hasFallbackPreference) + defaultPool.Add(session); } } - return new AntagSelectionPlayerPool(new() { preferredList, fallbackList }); + + if (premiumPool.Count == 0 && defaultPool.Count == 0) + { + foreach (var session in sessions) + { + if (IsSessionValid(ent, session, def) && IsEntityValid(session.AttachedEntity, def)) + { + defaultPool.Add(session); + } + } + } + + return new AntagSelectionPlayerPool(new() { premiumPool, defaultPool }); } /// @@ -432,6 +454,20 @@ public sealed partial class AntagSelectionSystem : GameRuleSystem diff --git a/Content.Server/_White/MeatyOre/MeatyOreStoreSystem.cs b/Content.Server/_White/MeatyOre/MeatyOreStoreSystem.cs index 2eb9b7722a..f37b973bc5 100644 --- a/Content.Server/_White/MeatyOre/MeatyOreStoreSystem.cs +++ b/Content.Server/_White/MeatyOre/MeatyOreStoreSystem.cs @@ -73,7 +73,8 @@ public sealed class MeatyOreStoreSystem : EntitySystem SubscribeLocalEvent(OnPostRoundCleanup); SubscribeNetworkEvent(OnShopRequested); - SubscribeLocalEvent>(MeatyOreVerbs); + + // SubscribeLocalEvent>(MeatyOreVerbs); } private void MeatyOreVerbs(GetVerbsEvent ev) diff --git a/Content.Shared/_White/Sponsors/MsgSponsorInfo.cs b/Content.Shared/_White/Sponsors/MsgSponsorInfo.cs index 25f046a9ad..bf1967c3d4 100644 --- a/Content.Shared/_White/Sponsors/MsgSponsorInfo.cs +++ b/Content.Shared/_White/Sponsors/MsgSponsorInfo.cs @@ -36,6 +36,9 @@ public sealed class SponsorInfo [JsonPropertyName("MeatyOreCoin")] public int MeatyOreCoin { get; set; } + + [JsonPropertyName("antagChance")] + public int AntagChance { get; set; } } ///