Add delaystart and forcepreset commands (#1163)

* Add extendroundstart message to extend lobby start timer

* Rename StartExtend to DelayStart

* Fix delaystart amounts above 59 not working

* Change delaystart seconds type from int to uint

* Change delaystart wrong args amount message

* Add forcegamepreset command

* Rename forcegamepreset to forcepreset and merged start and forcestart preset methods

* Fix index out of bounds exception when forcing suspicion to start

* Change game preset to match regardless of casing

* Add forcepreset unknown preset message

* Add and move in lobby checks

* Remove testing changes

* Change delaystart to pause/resume the timer when no seconds are specified

* Change pause message

* Remove testing code

* Change 0 seconds to not be a valid amount of seconds

* Replace MsgTickerLobbyCountdown Seconds with DateTime instead of uint

* Add one entire dot

* Replace Math.Min + Math.Max with Math.Clamp

Co-authored-by: ComicIronic <comicironic@gmail.com>

Co-authored-by: ComicIronic <comicironic@gmail.com>
This commit is contained in:
DrSmugleaf
2020-06-21 22:05:47 +02:00
committed by GitHub
parent 7b98f37f9a
commit d91a8c4925
13 changed files with 274 additions and 37 deletions

View File

@@ -12,7 +12,7 @@ namespace Content.Server.GameTicking.GamePresets
[Dependency] private readonly IGameTicker _gameTicker;
#pragma warning restore 649
public override bool Start(IReadOnlyList<IPlayerSession> readyPlayers)
public override bool Start(IReadOnlyList<IPlayerSession> readyPlayers, bool force = false)
{
_gameTicker.AddGameRule<RuleDeathMatch>();
return true;

View File

@@ -11,7 +11,7 @@ namespace Content.Server.GameTicking.GamePresets
[Dependency] private readonly ISandboxManager _sandboxManager;
#pragma warning restore 649
public override bool Start(IReadOnlyList<IPlayerSession> readyPlayers)
public override bool Start(IReadOnlyList<IPlayerSession> readyPlayers, bool force = false)
{
_sandboxManager.IsSandboxEnabled = true;
return true;

View File

@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Content.Server.GameTicking.GameRules;
using Content.Server.Interfaces.Chat;
using Content.Server.Interfaces.GameTicking;
@@ -28,16 +27,17 @@ namespace Content.Server.GameTicking.GamePresets
public int MinTraitors { get; set; } = 2;
public int PlayersPerTraitor { get; set; } = 5;
public override bool Start(IReadOnlyList<IPlayerSession> readyPlayers)
public override bool Start(IReadOnlyList<IPlayerSession> readyPlayers, bool force = false)
{
if (readyPlayers.Count < MinPlayers)
if (!force && readyPlayers.Count < MinPlayers)
{
_chatManager.DispatchServerAnnouncement($"Not enough players readied up for the game! There were {readyPlayers.Count} players readied up out of {MinPlayers} needed.");
return false;
}
var list = new List<IPlayerSession>(readyPlayers);
var numTraitors = Math.Max(readyPlayers.Count() % PlayersPerTraitor, MinTraitors);
var numTraitors = Math.Clamp(readyPlayers.Count % PlayersPerTraitor,
MinTraitors, readyPlayers.Count);
for (var i = 0; i < numTraitors; i++)
{