mirror of
https://github.com/Gurge44/EndlessHostRoles.git
synced 2026-10-20 01:46:25 +00:00
fix swapper & bm vote swap not visualized
This commit is contained in:
1 parent
b49582a843
commit
95bfc09ca4
4 files changed
+32
-10
No files matched your search
@@ -583,7 +583,7 @@ internal static class GameEndChecker
|
||||
|
||||
PlayerControl[] aapc = Main.AllAlivePlayerControls;
|
||||
|
||||
if (CustomRoles.Sunnyboy.RoleExist() && aapc.Length > 1) return false;
|
||||
if (CustomRoles.Sunnyboy.RoleExist() && aapc.Length > 1 && aapc.Any(x => x.CanUseKillButton() && !x.IsCrewmate())) return false;
|
||||
|
||||
if (CustomTeamManager.CheckCustomTeamGameEnd()) return true;
|
||||
|
||||
|
||||
@@ -202,11 +202,19 @@ public class NiceSwapper : RoleBase
|
||||
votingData[SwapTargets.Item2] = count1;
|
||||
|
||||
// Swap the votes visually
|
||||
List<MeetingHud.VoterState> votedFor1 = states.Where(x => x.VotedForId == SwapTargets.Item1).ToList();
|
||||
List<MeetingHud.VoterState> votedFor2 = states.Where(x => x.VotedForId == SwapTargets.Item2).ToList();
|
||||
votedFor1.ForEach(x => x.VotedForId = SwapTargets.Item2);
|
||||
votedFor2.ForEach(x => x.VotedForId = SwapTargets.Item1);
|
||||
|
||||
List<byte> votedFor1 = states.Where(x => x.VotedForId == SwapTargets.Item1).Select(x => x.VoterId).ToList();
|
||||
List<byte> votedFor2 = states.Where(x => x.VotedForId == SwapTargets.Item2).Select(x => x.VoterId).ToList();
|
||||
|
||||
for (var index = 0; index < states.Length; index++)
|
||||
{
|
||||
ref MeetingHud.VoterState state = ref states[index];
|
||||
|
||||
if (votedFor1.Contains(state.VoterId))
|
||||
state.VotedForId = SwapTargets.Item2;
|
||||
else if (votedFor2.Contains(state.VoterId))
|
||||
state.VotedForId = SwapTargets.Item1;
|
||||
}
|
||||
|
||||
Utils.SendMessage(string.Format(GetString("SwapVote"), SwapTargets.Item1.ColoredPlayerName(), SwapTargets.Item2.ColoredPlayerName()), title: Utils.ColorString(Utils.GetRoleColor(CustomRoles.NiceSwapper), GetString("SwapTitle")));
|
||||
}
|
||||
catch (Exception e) { Utils.ThrowException(e); }
|
||||
|
||||
@@ -75,14 +75,23 @@ internal class Blackmailer : RoleBase
|
||||
{
|
||||
try
|
||||
{
|
||||
if (state.MainRole != CustomRoles.Blackmailer || state.Role is not Blackmailer { IsEnable: true } bm || bm.BlackmailedPlayerIds.Count == 0 || !states.FindFirst(x => x.VoterId == id, out MeetingHud.VoterState vs)) continue;
|
||||
if (state.MainRole != CustomRoles.Blackmailer || state.Role is not Blackmailer { IsEnable: true } bm || bm.BlackmailedPlayerIds.Count == 0) continue;
|
||||
|
||||
int idx = Array.FindIndex(states, s => s.VoterId == id);
|
||||
if (idx == -1) continue;
|
||||
ref var vs = ref states[idx];
|
||||
|
||||
foreach (byte targetId in bm.BlackmailedPlayerIds)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!Main.PlayerStates.TryGetValue(targetId, out PlayerState ps) || ps.IsDead) continue;
|
||||
if (!states.FindFirst(x => x.VoterId == targetId, out MeetingHud.VoterState targetVs) || vs.VotedForId == targetVs.VotedForId) continue;
|
||||
|
||||
int targetIdx = Array.FindIndex(states, s => s.VoterId == targetId);
|
||||
if (targetIdx == -1) continue;
|
||||
ref var targetVs = ref states[targetIdx];
|
||||
|
||||
if (vs.VotedForId == targetVs.VotedForId) continue;
|
||||
|
||||
byte vote;
|
||||
|
||||
@@ -93,7 +102,12 @@ internal class Blackmailer : RoleBase
|
||||
else
|
||||
vote = vs.VotedForId;
|
||||
|
||||
votingData[targetVs.VotedForId]--;
|
||||
if (votingData.TryGetValue(targetVs.VotedForId, out int oldCount))
|
||||
{
|
||||
if (oldCount <= 1) votingData.Remove(targetVs.VotedForId);
|
||||
else votingData[targetVs.VotedForId] = oldCount - 1;
|
||||
}
|
||||
|
||||
targetVs.VotedForId = vote;
|
||||
|
||||
if (vote <= 253 && !votingData.TryAdd(vote, 1))
|
||||
|
||||
@@ -106,7 +106,7 @@ public class Patroller : RoleBase
|
||||
|
||||
pc.Notify(RoomBoosts.Any(x => x.Value == room)
|
||||
? string.Format(Translator.GetString("PatrollerNotify"), roomName, Translator.GetString($"PatrollerBoost.{RoomBoosts.First(x => x.Value == room).Key}"))
|
||||
: string.Format(Translator.GetString("PatrollerNotifyNoBoost"), roomName), 300f, overrideAll: true);
|
||||
: string.Format(Translator.GetString("PatrollerNotifyNoBoost"), roomName));
|
||||
}
|
||||
|
||||
pc.MarkDirtySettings();
|
||||
|
||||
Reference in new issue
Block a user