Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Секрет в голосовании за карту. Автоматическое голосование в конце раунда #36

Merged
merged 3 commits into from
Jun 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Content.Client/Voting/UI/VoteCallMenu.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ public static readonly (string name, StandardVoteType type, (string name, string
{
("ui-vote-type-restart", StandardVoteType.Restart, null),
("ui-vote-type-gamemode", StandardVoteType.Preset, null),
("ui-vote-type-map", StandardVoteType.Map, null)
//("ui-vote-type-map", StandardVoteType.Map, null)
// Sunrise-edit: Голосование за карту автоматическое после конца раунда.
};

public VoteCallMenu()
Expand Down
29 changes: 23 additions & 6 deletions Content.Server/Voting/Managers/VoteManager.DefaultVotes.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Collections.Specialized;
using System.Linq;
using Content.Server.GameTicking;
using Content.Server.GameTicking.Presets;
Expand Down Expand Up @@ -57,7 +58,7 @@ private void CreateRestartVote(ICommonSession? initiator)

var ghostVotePercentageRequirement = _cfg.GetCVar(CCVars.VoteRestartGhostPercentage);
var ghostCount = 0;

foreach (var player in _playerManager.Sessions)
{
_playerManager.UpdateState(player);
Expand Down Expand Up @@ -212,7 +213,13 @@ private void CreatePresetVote(ICommonSession? initiator)

private void CreateMapVote(ICommonSession? initiator)
{
var maps = _gameMapManager.CurrentlyEligibleMaps().ToDictionary(map => map, map => map.MapName);
var maps = new Dictionary<string, GameMapPrototype>();
var eligibleMaps = _gameMapManager.CurrentlyEligibleMaps().ToList();
maps.Add(Loc.GetString("ui-vote-secret-map"), _random.Pick(eligibleMaps));
foreach (var map in eligibleMaps)
{
maps.Add(map.MapName, map);
}

var alone = _playerManager.PlayerCount == 1 && initiator != null;
var options = new VoteOptions
Expand All @@ -228,7 +235,7 @@ private void CreateMapVote(ICommonSession? initiator)

foreach (var (k, v) in maps)
{
options.Options.Add((v, k));
options.Options.Add((k, v));
}

WirePresetVoteInitiator(options, initiator);
Expand All @@ -238,17 +245,27 @@ private void CreateMapVote(ICommonSession? initiator)
vote.OnFinished += (_, args) =>
{
GameMapPrototype picked;
string title;
if (args.Winner == null)
{
picked = (GameMapPrototype) _random.Pick(args.Winners);
title = maps.FirstOrDefault(x => x.Value == picked).Key;
_chatManager.DispatchServerAnnouncement(
Loc.GetString("ui-vote-map-tie", ("picked", maps[picked])));
Loc.GetString("ui-vote-map-tie", ("picked", title)));
}
else
{
picked = (GameMapPrototype) args.Winner;
_chatManager.DispatchServerAnnouncement(
Loc.GetString("ui-vote-map-win", ("winner", maps[picked])));
title = maps.FirstOrDefault(x => x.Value == picked).Key;
}
if (title == Loc.GetString("ui-vote-secret-map"))
{
_chatManager.DispatchServerAnnouncement(Loc.GetString("ui-vote-secret-win"));
}
else
{
_chatManager.DispatchServerAnnouncement(Loc.GetString("ui-vote-map-win",
("winner", title)));
}

_adminLogger.Add(LogType.Vote, LogImpact.Medium, $"Map vote finished: {picked.MapName}");
Expand Down
30 changes: 30 additions & 0 deletions Content.Server/_Sunrise/RoundEndVote/RoundEndVoteSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using Content.Server.GameTicking;
using Content.Server.RoundEnd;
using Content.Server.Voting.Managers;
using Content.Shared.Voting;

namespace Content.Server._Sunrise.RoundEndVote;

public sealed class RoundEndVoteSystem : EntitySystem
{
[Dependency] private readonly GameTicker _gameTicker = default!;
[Dependency] private readonly IVoteManager _voteManager = default!;

public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<RoundEndSystemChangedEvent>(OnRoundEndSystemChange);
}

private void OnRoundEndSystemChange(RoundEndSystemChangedEvent args)
{
if (_gameTicker.RunLevel != GameRunLevel.PreRoundLobby)
return;

// Очень жаль
//_voteManager.CreateStandardVote(null, StandardVoteType.Preset);
_voteManager.CreateStandardVote(null, StandardVoteType.Map);
_gameTicker.SetGamePreset("Secret");
}
}
23 changes: 18 additions & 5 deletions Resources/Changelog/ChangelogSunrise.yml
Original file line number Diff line number Diff line change
Expand Up @@ -259,12 +259,12 @@ Entries:
- author: Odleer
changes:
- message: "\u0420\u0435\u0434\u0438\u0437\u0430\u0439\u0434 \u0441\u043F\u0440\u0430\
\u0439\u0442\u043E\u0432 \u0448\u043B\u044E\u0437\u043E\u0432, \u043F\u043B\
\u0438\u0442\u043A\u0438, \u0441\u0442\u0435\u043D \u0438 \u043C\u043D\u043E\
\u0433\u043E\u0433\u043E \u0434\u0440\u0443\u0433\u043E\u0433\u043E."
\u0439\u0442\u043E\u0432 \u0448\u043B\u044E\u0437\u043E\u0432, \u043F\u043B\u0438\
\u0442\u043A\u0438, \u0441\u0442\u0435\u043D \u0438 \u043C\u043D\u043E\u0433\
\u043E\u0433\u043E \u0434\u0440\u0443\u0433\u043E\u0433\u043E."
type: Tweak
- message: "\u0412 \u043F\u0443\u043B\u043B\u0435 \u043A\u0430\u0440\u0442 marathon,
fland, delta, cluster, box."
- message: "\u0412 \u043F\u0443\u043B\u043B\u0435 \u043A\u0430\u0440\u0442 marathon,\
\ fland, delta, cluster, box."
type: Tweak
- message: "\u0412\u043E\u0437\u0432\u0440\u0430\u0449\u0435\u043D\u0438\u0435 \u0438\
\u0437\u043C\u0435\u043D\u0451\u043D\u043D\u043E\u0439 \u0441\u0442\u0430\u043D\
Expand All @@ -291,3 +291,16 @@ Entries:
type: Add
id: 25
time: '2024-06-06T15:19:19.017263+00:00'
- author: VigersRay
changes:
- message: "\u0414\u043E\u0431\u0430\u0432\u043B\u0435\u043D \u0441\u0435\u043A\u0440\
\u0435\u0442 \u0432 \u0433\u043E\u043B\u043E\u0441\u043E\u0432\u0430\u043D\u0438\
\u0435 \u0437\u0430 \u0441\u0442\u0430\u043D\u0446\u0438\u044E."
type: Tweak
- message: "\u0413\u043E\u043B\u043E\u0441\u043E\u0432\u0430\u043D\u0438\u0435 \u0437\
\u0430 \u0441\u0442\u0430\u043D\u0446\u0438\u044E \u0430\u0432\u0442\u043E\u043C\
\u0430\u0442\u0438\u0447\u0435\u0441\u043A\u043E\u0435 \u0432 \u043A\u043E\u043D\
\u0446\u0435 \u0440\u0430\u0443\u043D\u0434\u0430."
type: Tweak
id: 26
time: '2024-06-07T08:24:40.104466+00:00'
3 changes: 3 additions & 0 deletions Resources/Locale/ru-RU/voting/managers/vote-manager.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,6 @@ ui-vote-map-tie = Ничья при голосовании за карту! Вы
ui-vote-map-win = { $winner } выиграла голосование о выборе карты!
ui-vote-map-notlobby = Голосование о выборе карты действует только в предраундовом лобби!
ui-vote-map-notlobby-time = Голосование о выборе карты действует только в предраундовом лобби, когда осталось { $time }!

ui-vote-secret-map = Секрет
ui-vote-secret-win = Следующая карта будет выбрана случайным образом.
Loading