trivia modified, started speedtyping
This commit is contained in:
parent
80077445f8
commit
a39edb1001
72
NadekoBot/Classes/SpeedTyping.cs
Normal file
72
NadekoBot/Classes/SpeedTyping.cs
Normal file
@ -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<ulong, TypingGame> runningContests;
|
||||
|
||||
public SpeedTyping() : base() {
|
||||
runningContests = new Dictionary<ulong, TypingGame>();
|
||||
}
|
||||
|
||||
public override Func<CommandEventArgs, Task> 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<CommandEventArgs,Task> 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());
|
||||
}
|
||||
}
|
||||
}
|
@ -137,11 +137,11 @@ namespace NadekoBot
|
||||
client.MessageReceived += PotentialGuess;
|
||||
|
||||
strictness = new List<Tuple<int, int>>();
|
||||
strictness.Add(new Tuple<int, int>(6, 0));
|
||||
strictness.Add(new Tuple<int, int>(9, 1));
|
||||
strictness.Add(new Tuple<int, int>(13, 2));
|
||||
strictness.Add(new Tuple<int, int>(16, 3));
|
||||
strictness.Add(new Tuple<int, int>(21, 4));
|
||||
strictness.Add(new Tuple<int, int>(5, 0));
|
||||
strictness.Add(new Tuple<int, int>(6, 1));
|
||||
strictness.Add(new Tuple<int, int>(8, 2));
|
||||
strictness.Add(new Tuple<int, int>(15, 3));
|
||||
strictness.Add(new Tuple<int, int>(22, 4));
|
||||
maxStringLength = 22;
|
||||
|
||||
timeout = new Timer();
|
||||
|
@ -12,6 +12,7 @@ namespace NadekoBot.Modules
|
||||
{
|
||||
public Games() : base() {
|
||||
commands.Add(new Trivia());
|
||||
commands.Add(new SpeedTyping());
|
||||
}
|
||||
|
||||
public override void Install(ModuleManager manager)
|
||||
|
Loading…
Reference in New Issue
Block a user