// Adds prefixed reactions to the embed. public async Task AddReactions(DiscordMessage embed) { foreach (DiscordEmoji discordEmoji in GameEmoji.OneThroughNine()) { await embed.CreateReactionAsync(discordEmoji); } }
// Captures the users selected emoji returns it. private async Task <InteractivityResult <MessageReactionAddEventArgs> > InteractivityResult(ulong id, DiscordMessage embed) { var interactivity = ctx.Client.GetInteractivity(); return(await interactivity.WaitForReactionAsync( x => x.Message == embed && x.User.Id == id && GameEmoji.OneThroughNine().Contains(x.Emoji)).ConfigureAwait(false)); }
// Converts the bots move to an emoji and returns it. private DiscordEmoji ConvertAiMove() { int aiMove = aiLogic.MakeMove(grid.GameGrid, ai.Difficulty, Turn); if (aiMove == -1) { ctx.Channel.SendMessageAsync("The bot couldn't figure out a move."); GameActive = false; } return(GameEmoji.OneThroughNine()[aiMove]); }
// Updates the grid with Emoji and value. public async Task UpdateField(List <Field> grid, DiscordMessage embed, DiscordEmoji demoji, DiscordEmoji playerEmoji, int playerValue) { for (int i = 0; i < 9; i++) { if (demoji == GameEmoji.OneThroughNine()[i]) { grid[i].FieldEmoji = playerEmoji; grid[i].FieldValue = playerValue; } } await embed.ModifyAsync(embed : new Optional <DiscordEmbed>(CreatePlayField(grid))).ConfigureAwait(false); }
public async Task TicTacToeGame(CommandContext ctx, string userMention, string difficulty = "") { DiscordMember playerTwo = null; List <DiscordMember> dmList = await GetMemberList(ctx); await Task.WhenAny(GetMemberList(ctx)); GameEmoji.InitEmoji(ctx); // Checks if the member that has been @'d is a member of the channel and if it is a bot. foreach (DiscordMember discordMember in dmList) { if (userMention.Contains(discordMember.Id.ToString()) && discordMember.IsBot) { playerTwo = discordMember; if (string.IsNullOrEmpty(difficulty)) { await ctx.Channel.SendMessageAsync( "Trying to play against the AI? Make sure to include the difficulty.\nFormat: \"!ttt @DiscordBot difficulty\"\nThere are currently 3 difficulties: Easy, Medium & Hard"); } else { difficulty = difficulty.ToLower(); SingleplayerGame sp = new SingleplayerGame(ctx, playerTwo, difficulty); await sp.BeginSingleplayerGame(); } } else if (userMention.Contains(discordMember.Id.ToString())) { playerTwo = discordMember; MultiplayerGame mp = new MultiplayerGame(ctx, playerTwo); await mp.BeginMultiplayerGame(); } } if (playerTwo == null) { await ctx.Channel.SendMessageAsync("The requested player could not be found. Please try again with another user."); } }