Skip to content

Commit

Permalink
Update cs2rtv.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
LaplaceTor committed Jun 18, 2024
1 parent 872ab59 commit 0682ae8
Showing 1 changed file with 43 additions and 40 deletions.
83 changes: 43 additions & 40 deletions cs2rtv/cs2rtv.cs
Original file line number Diff line number Diff line change
Expand Up @@ -628,54 +628,57 @@ public void StartRtv()
foreach (var player in IsPlayer())
MenuManager.OpenChatMenu(player, votemenu);

_rtvtimer = AddTimer(30f, () =>
Server.NextFrame(()=>
{
if (!isrtving) return;
if (totalvotes == 0)
{
nextmap = mapnominatelist[random.Next(0, mapnominatelist.Count - 1)];
Server.PrintToChatAll("地图投票已结束");
rtvwin = true;
}
else if (votes.Select(x => x.Value).Max() > (totalvotes * 0.5f))
_rtvtimer = AddTimer(30f, () =>
{
votes = votes.OrderByDescending(x => x.Value).ToDictionary(x => x.Key, y => y.Value);
nextmap = votes.First().Key;
Server.PrintToChatAll("地图投票已结束");
rtvwin = true;
}
else if (votes.Select(x => x.Value).Max() <= (totalvotes * 0.5f) && votemaplist.Count >= 4 && totalvotes > 2)
{
Server.PrintToChatAll("本轮投票未有地图投票比例超过50%,将进行下一轮投票");
votes = votes.OrderByDescending(x => x.Value).ToDictionary(x => x.Key, y => y.Value);
var y = votemaplist.Count();
votemaplist.Clear();
var x = 0;
while (x < (y * 0.5f))
if (!isrtving) return;
if (totalvotes == 0)
{
nextmap = mapnominatelist[random.Next(0, mapnominatelist.Count - 1)];
Server.PrintToChatAll("地图投票已结束");
rtvwin = true;
}
else if (votes.Select(x => x.Value).Max() > (totalvotes * 0.5f))
{
votes = votes.OrderByDescending(x => x.Value).ToDictionary(x => x.Key, y => y.Value);
nextmap = votes.First().Key;
Server.PrintToChatAll("地图投票已结束");
rtvwin = true;
}
else if (votes.Select(x => x.Value).Max() <= (totalvotes * 0.5f) && votemaplist.Count >= 4 && totalvotes > 2)
{
if (votes.ElementAt(x).Key != null)
Server.PrintToChatAll("本轮投票未有地图投票比例超过50%,将进行下一轮投票");
votes = votes.OrderByDescending(x => x.Value).ToDictionary(x => x.Key, y => y.Value);
var y = votemaplist.Count();
votemaplist.Clear();
var x = 0;
while (x < (y * 0.5f))
{
if(votes.ElementAt(x).Value != 0)
if (votes.ElementAt(x).Key != null)
{
votemaplist!.Add(votes.ElementAt(x).Key);
x++;
}else
if(votes.ElementAt(x).Value != 0)
{
votemaplist!.Add(votes.ElementAt(x).Key);
x++;
}else
break;
}
else
break;
}
else
break;
}
}
else if (votes.Select(x => x.Value).Max() <= (totalvotes * 0.5f) && (votemaplist.Count < 4 || totalvotes <= 2))
{
votes = votes.OrderByDescending(x => x.Value).ToDictionary(x => x.Key, y => y.Value);
nextmap = votes.First().Key;
if(votes.ContainsKey(Server.MapName) && votes.First().Value <= (votes.GetValueOrDefault(Server.MapName)+1))
nextmap = Server.MapName;
Server.PrintToChatAll("地图投票已结束");
rtvwin = true;
}
VoteEnd(nextmap);
else if (votes.Select(x => x.Value).Max() <= (totalvotes * 0.5f) && (votemaplist.Count < 4 || totalvotes <= 2))
{
votes = votes.OrderByDescending(x => x.Value).ToDictionary(x => x.Key, y => y.Value);
nextmap = votes.First().Key;
if(votes.ContainsKey(Server.MapName) && votes.First().Value <= (votes.GetValueOrDefault(Server.MapName)+1))
nextmap = Server.MapName;
Server.PrintToChatAll("地图投票已结束");
rtvwin = true;
}
VoteEnd(nextmap);
});
});
}

Expand Down

0 comments on commit 0682ae8

Please sign in to comment.