Шанс на запуск голосования за режим - 50%

This commit is contained in:
Vigers Ray 2024-12-16 00:07:22 +03:00
parent 7e0a8f4747
commit ee47475c69
2 changed files with 7 additions and 1 deletions

View file

@ -5,6 +5,7 @@ using Content.Shared._Sunrise.SunriseCCVars;
using Content.Shared.Voting;
using Robust.Shared.Timing;
using Robust.Shared.Configuration;
using Robust.Shared.Random;
namespace Content.Server._Sunrise.RoundEndVote;
@ -14,6 +15,7 @@ public sealed class RoundEndVoteSystem : EntitySystem
[Dependency] private readonly IGameTiming _gameTiming = default!;
[Dependency] private readonly IVoteManager _voteManager = default!;
[Dependency] private readonly IConfigurationManager _cfg = default!;
[Dependency] private readonly IRobustRandom _random = default!;
private TimeSpan? _voteStartTime;
@ -55,7 +57,9 @@ public sealed class RoundEndVoteSystem : EntitySystem
if (_cfg.GetCVar(SunriseCCVars.RunMapVoteAfterRestart))
_voteManager.CreateStandardVote(null, StandardVoteType.Map);
if (_cfg.GetCVar(SunriseCCVars.RunPresetVoteAfterRestart))
var presetVoteChance = _cfg.GetCVar(SunriseCCVars.ChancePresetVoteAfterRestart);
if (_cfg.GetCVar(SunriseCCVars.RunPresetVoteAfterRestart) && _random.Prob(presetVoteChance))
_voteManager.CreateStandardVote(null, StandardVoteType.Preset);
}
}

View file

@ -275,6 +275,8 @@ public sealed class SunriseCCVars
public static readonly CVarDef<bool> RunPresetVoteAfterRestart = CVarDef.Create("vote.run_preset_vote_after_restart", false);
public static readonly CVarDef<float> ChancePresetVoteAfterRestart = CVarDef.Create("vote.chance_preset_vote_after_restart", 0.5f);
public static readonly CVarDef<int> VotingsDelay = CVarDef.Create("vote.votings_delay", 60);
public static readonly CVarDef<int> MapVotingCount = CVarDef.Create("vote.map_voting_count", 3);