From 788ac7c2fa643daadd90d9f101089e3a332dc6d0 Mon Sep 17 00:00:00 2001 From: Benjamin Harris Date: Tue, 19 Dec 2017 11:34:17 -0500 Subject: [PATCH] hangman doesn't break build --- Commands/Hangman.cs | 14 +++++++++++--- Program.cs | 1 + Services/HangmanService.cs | 5 ++++- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/Commands/Hangman.cs b/Commands/Hangman.cs index 286d850..8ca9aa1 100644 --- a/Commands/Hangman.cs +++ b/Commands/Hangman.cs @@ -1,4 +1,5 @@ using Discord.Commands; +using dotbot.Services; using System.Collections.Generic; using System.IO; using System.Linq; @@ -10,15 +11,22 @@ namespace dotbot.Commands public class Hangman : ModuleBase { static internal string[] Gallows = File.ReadAllText("gallows.txt").Split('='); - public HangmanSession CurrentGames; + public Dictionary _games; + + + public Hangman(HangmanService hangman) + { + _games = hangman._activeGames; + } [Command] [Priority(0)] [Summary("start a game of hangman!")] public async Task StartGame([Remainder] string secret) { - CurrentGames = new HangmanSession(secret); - await ReplyAsync($"{CurrentGames}"); + var gameId = Context.Channel.Id; + _games.Add(gameId, new HangmanSession(secret)); + await ReplyAsync($"{_games[gameId]}"); } } diff --git a/Program.cs b/Program.cs index 51e3292..b1d53a6 100644 --- a/Program.cs +++ b/Program.cs @@ -41,6 +41,7 @@ namespace dotbot .AddSingleton() .AddSingleton() .AddSingleton() + .AddSingleton() .AddSingleton() .AddSingleton(_config); diff --git a/Services/HangmanService.cs b/Services/HangmanService.cs index acd18db..aefb46e 100644 --- a/Services/HangmanService.cs +++ b/Services/HangmanService.cs @@ -1,15 +1,18 @@ using Discord.WebSocket; +using dotbot.Commands; +using System.Collections.Generic; namespace dotbot.Services { public class HangmanService { private DiscordSocketClient _discord; - private Dictionary _activeGames; + public Dictionary _activeGames; public HangmanService(DiscordSocketClient discord) { _discord = discord; + _activeGames = new Dictionary(); } } }