Add ghost role raffles (#26629)

* Add ghost role raffles

* GRR: Fix dialogue sizing, fix merge

* GRR: Add raffle deciders (winner picker)

* GRR: Make settings prototype based with option to override

* GRR: Use Raffles folder and namespace

* GRR: DataFieldify and TimeSpanify

* GRR: Don't actually DataFieldify HashSet<ICommonSession>s

* GRR: add GetGhostRoleCount() + docs

* update engine on branch

* Ghost role raffles: docs, fix window size, cleanup, etc

* GRR: Admin UI

* GRR: Admin UI: Display initial/max/ext of selected raffle settings proto

* GRR: Make a ton of roles raffled
This commit is contained in:
no
2024-05-07 03:48:16 +02:00
committed by GitHub
parent 6685146a1e
commit 630a7a78ed
44 changed files with 1138 additions and 51 deletions

View File

@@ -0,0 +1,58 @@
using Content.Server.Ghost.Roles.Raffles;
using Robust.Shared.Player;
namespace Content.Server.Ghost.Roles.Components;
/// <summary>
/// Indicates that a ghost role is currently being raffled, and stores data about the raffle in progress.
/// Raffles start when the first player joins a raffle.
/// </summary>
[RegisterComponent]
[Access(typeof(GhostRoleSystem))]
public sealed partial class GhostRoleRaffleComponent : Component
{
/// <summary>
/// Identifier of the <see cref="GhostRoleComponent">Ghost Role</see> this raffle is for.
/// </summary>
[ViewVariables(VVAccess.ReadOnly)]
[DataField]
public uint Identifier { get; set; }
/// <summary>
/// List of sessions that are currently in the raffle.
/// </summary>
[ViewVariables(VVAccess.ReadOnly)]
public HashSet<ICommonSession> CurrentMembers = [];
/// <summary>
/// List of sessions that are currently or were previously in the raffle.
/// </summary>
[ViewVariables(VVAccess.ReadOnly)]
public HashSet<ICommonSession> AllMembers = [];
/// <summary>
/// Time left in the raffle in seconds. This must be initialized to a positive value.
/// </summary>
[ViewVariables(VVAccess.ReadOnly)]
[DataField]
public TimeSpan Countdown = TimeSpan.MaxValue;
/// <summary>
/// The cumulative time, i.e. how much time the raffle will take in total. Added to when the time is extended
/// by someone joining the raffle.
/// Must be set to the same value as <see cref="Countdown"/> on initialization.
/// </summary>
[ViewVariables(VVAccess.ReadOnly)]
[DataField("cumulativeTime")]
public TimeSpan CumulativeTime = TimeSpan.MaxValue;
/// <inheritdoc cref="GhostRoleRaffleSettings.JoinExtendsDurationBy"/>
[ViewVariables(VVAccess.ReadOnly)]
[DataField("joinExtendsDurationBy")]
public TimeSpan JoinExtendsDurationBy { get; set; }
/// <inheritdoc cref="GhostRoleRaffleSettings.MaxDuration"/>
[ViewVariables(VVAccess.ReadOnly)]
[DataField("maxDuration")]
public TimeSpan MaxDuration { get; set; }
}