Vote type delay, code comments.

Added doc comments to server side voting API.
There is now a 4 minute delay between creating votes of the same type.
Shuffled some code around.
Made a StandardVoteType enum instead of string IDs.
This commit is contained in:
Pieter-Jan Briers
2021-07-21 19:03:10 +02:00
parent 1187185b89
commit e9af56c7c3
13 changed files with 348 additions and 49 deletions

View File

@@ -1,16 +1,15 @@
using System;
using System.Linq;
using System.Text;
using Content.Server.Administration;
using Content.Server.Chat.Managers;
using Content.Server.Voting.Managers;
using Content.Shared.Administration;
using Content.Shared.Voting;
using Robust.Server.Player;
using Robust.Shared.Console;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
namespace Content.Server.Voting
{
[AnyCommand]
@@ -28,28 +27,21 @@ namespace Content.Server.Voting
return;
}
var type = args[0];
if (!Enum.TryParse<StandardVoteType>(args[0], ignoreCase: true, out var type))
{
shell.WriteError(Loc.GetString("create-vote-command-invalid-vote-type"));
return;
}
var mgr = IoCManager.Resolve<IVoteManager>();
if (shell.Player != null && !mgr.CanCallVote((IPlayerSession) shell.Player))
if (shell.Player != null && !mgr.CanCallVote((IPlayerSession) shell.Player, type))
{
shell.WriteError(Loc.GetString("create-vote-command-cannot-call-vote-now"));
return;
}
switch (type)
{
case "restart":
mgr.CreateRestartVote((IPlayerSession?) shell.Player);
break;
case "preset":
mgr.CreatePresetVote((IPlayerSession?) shell.Player);
break;
default:
shell.WriteError(Loc.GetString("create-vote-command-invalid-vote-type"));
break;
}
mgr.CreateStandardVote((IPlayerSession?) shell.Player, type);
}
}