diff --git a/NadekoBot/Classes/BombermanGame.cs b/NadekoBot/Classes/BombermanGame.cs new file mode 100644 index 00000000..5b801e30 --- /dev/null +++ b/NadekoBot/Classes/BombermanGame.cs @@ -0,0 +1,8 @@ +namespace NadekoBot.Classes +{ + class BombermanGame + { + public ulong ChannelId { get; internal set; } + public bool Ended { get; internal set; } + } +} diff --git a/NadekoBot/Commands/Bomberman.cs b/NadekoBot/Commands/Bomberman.cs new file mode 100644 index 00000000..44d460e5 --- /dev/null +++ b/NadekoBot/Commands/Bomberman.cs @@ -0,0 +1,56 @@ +using Discord; +using Discord.Commands; +using NadekoBot.Classes; +using NadekoBot.Modules; +using System; + +namespace NadekoBot.Commands +{ + class Bomberman : DiscordCommand + { + public Bomberman(DiscordModule module) : base(module) + { + NadekoBot.Client.MessageReceived += async (s, e) => + { + if (e.Channel.Id != bombGame.ChannelId) return; + + var text = e.Message.Text; + await e.Message.Delete(); + HandleBombermanCommand(e.User, text); + }; + } + + private void HandleBombermanCommand(User user, string text) + { + throw new NotImplementedException(); + } + + //only one bomberman game can run at any one time + public static BombermanGame bombGame = null; + private readonly object locker = new object(); + internal override void Init(CommandGroupBuilder cgb) + { + cgb.CreateCommand($"{Module.Prefix}bmb") + .Description("Creates a bomberman game for this channel or join existing one." + + " If you are 4th player - Game will start. After game starts " + + " everything written in the channel will be autodeleted and treated as a bomberman command." + + " only one bomberman game can run at any one time per bot. Game will run at 1FPS." + + " You must have manage messages permissions in order to create the game.") + .Do(e => + { + lock (locker) + { + if (bombGame == null || bombGame.Ended) + { + if (!e.User.ServerPermissions.ManageMessages || + !e.Server.GetUser(NadekoBot.Client.CurrentUser.Id).ServerPermissions.ManageMessages) + { + e.Channel.SendMessage("Both you and Nadeko need manage messages permissions to start a new bomberman game.").Wait(); + } + + } + } + }); + } + } +}