diff --git a/NadekoBot/Modules/Games/Commands/Trivia/TriviaGame.cs b/NadekoBot/Modules/Games/Commands/Trivia/TriviaGame.cs index 55ac9c20..0d90acce 100644 --- a/NadekoBot/Modules/Games/Commands/Trivia/TriviaGame.cs +++ b/NadekoBot/Modules/Games/Commands/Trivia/TriviaGame.cs @@ -34,11 +34,12 @@ namespace NadekoBot.Modules.Games.Commands.Trivia public int WinRequirement { get; } = 10; - public TriviaGame(CommandEventArgs e, bool showHints) + public TriviaGame(CommandEventArgs e, bool showHints, int winReq = 10) { ShowHints = showHints; server = e.Server; channel = e.Channel; + WinRequirement = winReq; Task.Run(StartGame); } diff --git a/NadekoBot/Modules/Games/Commands/TriviaCommand.cs b/NadekoBot/Modules/Games/Commands/TriviaCommand.cs index 15d29e07..57cc4a4a 100644 --- a/NadekoBot/Modules/Games/Commands/TriviaCommand.cs +++ b/NadekoBot/Modules/Games/Commands/TriviaCommand.cs @@ -1,6 +1,7 @@ using Discord.Commands; using NadekoBot.Classes; using NadekoBot.Modules.Games.Commands.Trivia; +using System; using System.Collections.Concurrent; using System.Linq; @@ -18,8 +19,8 @@ namespace NadekoBot.Modules.Games.Commands { cgb.CreateCommand(Module.Prefix + "t") .Description($"Starts a game of trivia. You can add nohint to prevent hints." + - "First player to get to 10 points wins. 30 seconds per question." + - $"\n**Usage**:`{Module.Prefix}t nohint`") + "First player to get to 10 points wins by default. You can specify a different number. 30 seconds per question." + + $"\n**Usage**:`{Module.Prefix}t nohint` or `{Module.Prefix}t 5 nohint`") .Parameter("args", ParameterType.Multiple) .Do(async e => { @@ -27,9 +28,16 @@ namespace NadekoBot.Modules.Games.Commands if (!RunningTrivias.TryGetValue(e.Server.Id, out trivia)) { var showHints = !e.Args.Contains("nohint"); - var triviaGame = new TriviaGame(e, showHints); + var number = e.Args.Select(s => + { + int num; + return new Tuple(int.TryParse(s, out num), num); + }).Where(t => t.Item1).Select(t => t.Item2).FirstOrDefault(); + if (number < 0) + return; + var triviaGame = new TriviaGame(e, showHints, number == 0 ? 10 : number); if (RunningTrivias.TryAdd(e.Server.Id, triviaGame)) - await e.Channel.SendMessage("**Trivia game started!**").ConfigureAwait(false); + await e.Channel.SendMessage($"**Trivia game started! {triviaGame.WinRequirement} points needed to win.**").ConfigureAwait(false); else await triviaGame.StopGame().ConfigureAwait(false); }