From a39edb10019d933d5749f9790832d67100f7d45e Mon Sep 17 00:00:00 2001 From: Master Kwoth Date: Sat, 23 Jan 2016 10:18:00 +0100 Subject: [PATCH] trivia modified, started speedtyping --- NadekoBot/Classes/SpeedTyping.cs | 72 ++++++++++++++++++++++++++++++++ NadekoBot/Classes/Trivia.cs | 10 ++--- NadekoBot/Modules/Games.cs | 1 + 3 files changed, 78 insertions(+), 5 deletions(-) create mode 100644 NadekoBot/Classes/SpeedTyping.cs diff --git a/NadekoBot/Classes/SpeedTyping.cs b/NadekoBot/Classes/SpeedTyping.cs new file mode 100644 index 00000000..02244928 --- /dev/null +++ b/NadekoBot/Classes/SpeedTyping.cs @@ -0,0 +1,72 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Discord; +using Discord.Commands; +using NadekoBot.Extensions; + +namespace NadekoBot.Classes { + + public class TypingGame { + private Channel channel; + + public TypingGame(Channel channel) { + this.channel = channel; + } + + public Channel Channell { get; internal set; } + + internal bool Stop() { + throw new NotImplementedException(); + } + + internal void Start() { + throw new NotImplementedException(); + } + } + + class SpeedTyping : DiscordCommand { + + private static Dictionary runningContests; + + public SpeedTyping() : base() { + runningContests = new Dictionary(); + } + + public override Func DoFunc()=> + async e => { + if (runningContests.ContainsKey(e.User.Server.Id)) { + await e.Send($"Contest already running in { runningContests[e.User.Server.Id].Channell.Mention } channel."); + return; + } + var tg = new TypingGame(e.Channel); + runningContests.Add(e.Server.Id,tg); + await e.Send("Starting new typing contest!"); + tg.Start(); + }; + + private Func QuitFunc() => + async e => { + if (runningContests.ContainsKey(e.User.Server.Id) && + runningContests[e.User.Server.Id].Stop()) + { + runningContests.Remove(e.User.Server.Id); + await e.Send("Typing contest stopped"); + return; + } + await e.Send("No contest to stop on this channel."); + }; + + public override void Init(CommandGroupBuilder cgb) { + cgb.CreateCommand("typing contest") + .Description("Starts a typing contest.") + .Do(DoFunc()); + + cgb.CreateCommand("typing stop") + .Description("Stops a typing contest on the current channel.") + .Do(QuitFunc()); + } + } +} diff --git a/NadekoBot/Classes/Trivia.cs b/NadekoBot/Classes/Trivia.cs index de9a7bef..b6cdae69 100644 --- a/NadekoBot/Classes/Trivia.cs +++ b/NadekoBot/Classes/Trivia.cs @@ -137,11 +137,11 @@ namespace NadekoBot client.MessageReceived += PotentialGuess; strictness = new List>(); - strictness.Add(new Tuple(6, 0)); - strictness.Add(new Tuple(9, 1)); - strictness.Add(new Tuple(13, 2)); - strictness.Add(new Tuple(16, 3)); - strictness.Add(new Tuple(21, 4)); + strictness.Add(new Tuple(5, 0)); + strictness.Add(new Tuple(6, 1)); + strictness.Add(new Tuple(8, 2)); + strictness.Add(new Tuple(15, 3)); + strictness.Add(new Tuple(22, 4)); maxStringLength = 22; timeout = new Timer(); diff --git a/NadekoBot/Modules/Games.cs b/NadekoBot/Modules/Games.cs index 987eec3e..7c949bd1 100644 --- a/NadekoBot/Modules/Games.cs +++ b/NadekoBot/Modules/Games.cs @@ -12,6 +12,7 @@ namespace NadekoBot.Modules { public Games() : base() { commands.Add(new Trivia()); + commands.Add(new SpeedTyping()); } public override void Install(ModuleManager manager)