remove some roles from draft in certain conditions

This commit is contained in:
Gurge44 committed 2026-01-25 12:09:25 +01:00
1 parent 71d41121e6
commit 9ed9b2069c
1 file changed
+15 -1
+15 -1
View File
@@ -1428,7 +1428,7 @@ internal static class ChatCommands
byte[] allPlayerIds = Main.AllPlayerControls.Select(x => x.PlayerId).ToArray();
bool rollSpawnChance = Options.DraftAffectedByRoleSpawnChances.GetBool();
List<CustomRoles> allRoles = Enum.GetValues<CustomRoles>().Where(x => x < CustomRoles.NotAssigned && x.IsEnable() && !x.IsForOtherGameMode() && !CustomHnS.AllHnSRoles.Contains(x) && !x.IsVanilla() && x is not CustomRoles.GM && (!rollSpawnChance || IRandom.Instance.Next(100) < x.GetMode())).Shuffle();
List<CustomRoles> allRoles = Enum.GetValues<CustomRoles>().Where(x => x < CustomRoles.NotAssigned && x.IsEnable() && !x.IsForOtherGameMode() && !CustomHnS.AllHnSRoles.Contains(x) && !x.IsVanilla() && x is not CustomRoles.GM && !ShouldNotSpawn(x) && (!rollSpawnChance || IRandom.Instance.Next(100) < x.GetMode())).Shuffle();
if (allRoles.Count < allPlayerIds.Length)
{
@@ -1478,6 +1478,20 @@ internal static class ChatCommands
if (DraftResult.Count >= DraftRoles.Count || !GameStates.IsLobby || GameStates.InGame) yield break;
}
}
static bool ShouldNotSpawn(CustomRoles role)
{
return role switch
{
CustomRoles.Ventriloquist when GameStates.CurrentServerType == GameStates.ServerType.Vanilla => true,
CustomRoles.Weatherman when Main.LIMap || GameStates.CurrentServerType == GameStates.ServerType.Vanilla => true,
CustomRoles.RoomRusher when Main.LIMap => true,
CustomRoles.Doctor when Options.EveryoneSeesDeathReasons.GetBool() => true,
CustomRoles.Commander when Main.NormalOptions.NumImpostors <= 1 && Commander.CannotSpawnAsSoloImp.GetBool() => true,
CustomRoles.Changeling when Changeling.GetAvailableRoles(true).Count == 0 => true,
_ => false
};
}
}
private static void DraftDescriptionCommand(PlayerControl player, string commandKey, string text, string[] args)