示例#1
0
        public async Task Start1024Game()
        {
            if (NewGame.UserIsPlaying(Context.User.Id))
            {
                await ReplyAsync(
                    "you are **already** playing, you need to finish what you started (well... or just use `*e2` command)");

                return;
            }

            var message = await Context.Channel.SendMessageAsync("**Please wait**");


            await message.AddReactionAsync(new Emoji("⬅"));

            await message.AddReactionAsync(new Emoji("➡"));

            await message.AddReactionAsync(new Emoji("⬆"));

            await message.AddReactionAsync(new Emoji("⬇"));

            await message.AddReactionAsync(new Emoji("🔃"));

            await message.AddReactionAsync(new Emoji("❌"));


            NewGame.CreateNewGame(Context.User.Id, message);

            var new2048Game =
                new Global.OctoGameMessAndUserTrack2048(message.Id, Context.User.Id, message, Context.User);

            Global.OctopusGameMessIdList2048.Add(new2048Game);
        }
        public static async Task ReactionAddedFor2048(Cacheable <IUserMessage, ulong> cash, ISocketMessageChannel channel,
                                                      SocketReaction reaction)
        {
            for (var i = 0; i < Global.OctopusGameMessIdList2048.Count; i++)
            {
                if (reaction.MessageId == Global.OctopusGameMessIdList2048[i].OctoGameMessIdToTrack2048 && reaction.UserId == Global.OctopusGameMessIdList2048[i].OctoGameUserIdToTrack2048 &&
                    reaction.UserId != 423593006436712458) //Id for bot
                {
                    switch (reaction.Emote.Name)
                    {
                    case "⬆":
                        NewGame.MakeMove(reaction.UserId, GameWork.MoveDirection.Up, Global.OctopusGameMessIdList2048[i].SocketMsg);
                        await Global.OctopusGameMessIdList2048[i].SocketMsg.RemoveReactionAsync(reaction.Emote, Global.OctopusGameMessIdList2048[i].Iuser, RequestOptions.Default);
                        break;

                    case "⬇":
                        NewGame.MakeMove(reaction.UserId, GameWork.MoveDirection.Down, Global.OctopusGameMessIdList2048[i].SocketMsg);
                        await Global.OctopusGameMessIdList2048[i].SocketMsg.RemoveReactionAsync(reaction.Emote, Global.OctopusGameMessIdList2048[i].Iuser, RequestOptions.Default);
                        break;

                    case "⬅":
                        NewGame.MakeMove(reaction.UserId, GameWork.MoveDirection.Left, Global.OctopusGameMessIdList2048[i].SocketMsg);
                        await Global.OctopusGameMessIdList2048[i].SocketMsg.RemoveReactionAsync(reaction.Emote, Global.OctopusGameMessIdList2048[i].Iuser, RequestOptions.Default);
                        break;

                    case "➡":
                        NewGame.MakeMove(reaction.UserId, GameWork.MoveDirection.Right, Global.OctopusGameMessIdList2048[i].SocketMsg);
                        await Global.OctopusGameMessIdList2048[i].SocketMsg.RemoveReactionAsync(reaction.Emote, Global.OctopusGameMessIdList2048[i].Iuser, RequestOptions.Default);
                        break;

                    case "❌":
                        NewGame.EndGame(reaction.UserId);
                        break;

                    case "🔃":
                        await cash.DownloadAsync().Result.RemoveAllReactionsAsync();

                        await cash.DownloadAsync().Result.AddReactionAsync(new Emoji("⬅"));

                        await cash.DownloadAsync().Result.AddReactionAsync(new Emoji("➡"));

                        await cash.DownloadAsync().Result.AddReactionAsync(new Emoji("⬆"));

                        await cash.DownloadAsync().Result.AddReactionAsync(new Emoji("⬇"));

                        await cash.DownloadAsync().Result.AddReactionAsync(new Emoji("🔃"));

                        await cash.DownloadAsync().Result.AddReactionAsync(new Emoji("❌"));

                        break;

                    default:
                        return;
                    }
                }
            }
            await Task.CompletedTask;
        }
示例#3
0
 public async Task End2048Gmae()
 {
     NewGame.EndGame(Context.User.Id);
     await Task.CompletedTask;
 }