using System; using System.Collections.Generic; using Robust.Server.Player; using Robust.Shared.Localization; namespace Content.Server.Voting { /// /// Options for creating a vote. /// public sealed class VoteOptions { /// /// The text that is shown for "who called the vote". /// public string InitiatorText { get; set; } = ""; /// /// The player that started the vote. Used to keep track of player cooldowns to avoid vote spam. /// public IPlayerSession? InitiatorPlayer { get; set; } /// /// The shown title of the vote. /// public string Title { get; set; } = ""; /// /// How long the vote lasts. /// public TimeSpan Duration { get; set; } = TimeSpan.FromMinutes(1); /// /// How long the initiator should be timed out from calling votes. Defaults to duration * 2; /// public TimeSpan? InitiatorTimeout { get; set; } /// /// The options of the vote. Each entry is a tuple of the player-shown text, /// and a data object that can be used to keep track of options later. /// public List<(string text, object data)> Options { get; set; } = new(); /// /// Sets and /// by setting the latter to the player's name. /// public void SetInitiator(IPlayerSession player) { InitiatorPlayer = player; InitiatorText = player.Name; } public void SetInitiatorOrServer(IPlayerSession? player) { if (player != null) { SetInitiator(player); } else { InitiatorText = Loc.GetString("vote-options-server-initiator-text"); } } } }