From d2feee9a61ba5f3b2abe74231abdc98489a650d6 Mon Sep 17 00:00:00 2001 From: Gurge44 Date: Mon, 4 Mar 2024 19:46:25 +0100 Subject: [PATCH] fix incorrect win conditions & optimize --- Modules/CustomRolesHelper.cs | 3 ++- Patches/CheckGameEndPatch.cs | 25 ++++++++++++++----------- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/Modules/CustomRolesHelper.cs b/Modules/CustomRolesHelper.cs index a9c8b36b8..757cf60c2 100644 --- a/Modules/CustomRolesHelper.cs +++ b/Modules/CustomRolesHelper.cs @@ -1351,8 +1351,9 @@ internal static class CustomRolesHelper CustomRoles.Refugee => CountTypes.Impostor, CustomRoles.Glitch => CountTypes.Glitch, CustomRoles.Spiritcaller => CountTypes.Spiritcaller, + CustomRoles.DarkHide => DarkHide.SnatchesWin.GetBool() ? CountTypes.Crew : CountTypes.DarkHide, - _ => role.IsImpostorTeam() ? CountTypes.Impostor : CountTypes.Crew, + _ => role.Is(Team.Impostor) ? CountTypes.Impostor : CountTypes.Crew }; public static bool HasSubRole(this PlayerControl pc) => Main.PlayerStates[pc.PlayerId].SubRoles.Count > 0; diff --git a/Patches/CheckGameEndPatch.cs b/Patches/CheckGameEndPatch.cs index 7daed4858..815825b23 100644 --- a/Patches/CheckGameEndPatch.cs +++ b/Patches/CheckGameEndPatch.cs @@ -344,7 +344,7 @@ class GameEndChecker foreach (var role in EnumHelper.GetAllValues()) { - if (!role.IsNK() || role.IsMadmate() || role is CustomRoles.Sidekick || (role == CustomRoles.Arsonist && !Options.ArsonistCanIgniteAnytime.GetBool())) continue; + if (!role.IsNK() || role.IsMadmate() || role is CustomRoles.Sidekick || (role == CustomRoles.Arsonist && !Options.ArsonistCanIgniteAnytime.GetBool()) || (role == CustomRoles.DarkHide && DarkHide.SnatchesWin.GetBool())) continue; CustomRoles? keyRole = role.IsRecruitingRole() ? null : role; CustomWinner keyWinner = (CustomWinner)role; @@ -353,17 +353,20 @@ class GameEndChecker roleCounts[(keyRole, keyWinner)] = value; } - foreach (PlayerControl x in Main.AllAlivePlayerControls) + if (CustomRoles.DualPersonality.IsEnable()) { - CustomRoles role = x.GetCustomRole(); - if ((x.Is(CustomRoles.Madmate) && x.Is(CustomRoles.DualPersonality)) || - (role.IsImpostor() && x.Is(CustomRoles.DualPersonality))) Imp++; - if (role.IsCrewmate() && x.Is(CustomRoles.DualPersonality)) Crew++; - if (x.Is(CustomRoles.Charmed) && x.Is(CustomRoles.DualPersonality)) roleCounts[(null, CustomWinner.Succubus)]++; - if (x.Is(CustomRoles.Undead) && x.Is(CustomRoles.DualPersonality)) roleCounts[(null, CustomWinner.Necromancer)]++; - if (x.Is(CustomRoles.Sidekick) && x.Is(CustomRoles.DualPersonality)) roleCounts[(null, CustomWinner.Jackal)]++; - if (x.Is(CustomRoles.Recruit) && x.Is(CustomRoles.DualPersonality)) roleCounts[(null, CustomWinner.Jackal)]++; - if (x.Is(CustomRoles.Contagious) && x.Is(CustomRoles.DualPersonality)) roleCounts[(null, CustomWinner.Virus)]++; + foreach (PlayerControl x in Main.AllAlivePlayerControls) + { + CustomRoles role = x.GetCustomRole(); + if ((x.Is(CustomRoles.Madmate) && x.Is(CustomRoles.DualPersonality)) || + (role.IsImpostor() && x.Is(CustomRoles.DualPersonality))) Imp++; + if (role.IsCrewmate() && x.Is(CustomRoles.DualPersonality)) Crew++; + if (x.Is(CustomRoles.Charmed) && x.Is(CustomRoles.DualPersonality)) roleCounts[(null, CustomWinner.Succubus)]++; + if (x.Is(CustomRoles.Undead) && x.Is(CustomRoles.DualPersonality)) roleCounts[(null, CustomWinner.Necromancer)]++; + if (x.Is(CustomRoles.Sidekick) && x.Is(CustomRoles.DualPersonality)) roleCounts[(null, CustomWinner.Jackal)]++; + if (x.Is(CustomRoles.Recruit) && x.Is(CustomRoles.DualPersonality)) roleCounts[(null, CustomWinner.Jackal)]++; + if (x.Is(CustomRoles.Contagious) && x.Is(CustomRoles.DualPersonality)) roleCounts[(null, CustomWinner.Virus)]++; + } } int totalNKAlive = roleCounts.Values.Sum();