public async Task VoteAsync() { GuildData g_data = GuildCenter.GetGuild(Context.Guild.Id); // if id == 0 then the guild's info doesnt exist if (g_data.Id != 0 && g_data.werdData.gameStarted) // check for condition stated above { if (g_data.werdData.votes >= g_data.werdData.players.Count / 3 * 2) { // if 2/3 of the players vote to end the game it can end without admin intervention g_data.werdData.gameStarted = false; await ReplyAsync($"The vote to end the game has passed."); await ReplyAsync("Game over.", true); // experimental return; } else { g_data.werdData.votes++; } } else { await ReplyAsync($"{Context.User.Mention} ... erm... You can't vote to end a match that doesn't exist...\n" + $"My faith in mankind has just lowered considerably :face_palm:"); } }
public async Task DefaultChannelAsync(SocketChannel channel) { GuildData g_data = GuildCenter.GetGuild(Context.Guild.Id); if (g_data.Id == 0) { g_data = new GuildData(Context.Guild.Id, Context.Guild.Name); } g_data.defaultChannel = channel.Id; GuildCenter.Guilds.Add(g_data); GuildCenter.SaveGuilds(); await ReplyAsync(Context.User.Mention + ", guild settings updated."); }
public async Task StartAsync() { GuildData g_data = GuildCenter.GetGuild(Context.Guild.Id); if (g_data.Id == 0) // check to make sure the guild exists in memory { GuildCenter.Guilds.Add(new GuildData(Context.Guild.Id, Context.Guild.Name)); g_data = GuildCenter.GetGuild(Context.Guild.Id); // no need to check this time } g_data.werdData = new WerdData(guildId: Context.Guild.Id, werd: GenerateWerd()); g_data.werdData.gameStarted = true; await ReplyAsync("A five letter word has been selected! ``$rules`` to learn how to play. " + "Guess away.... :smile:"); }
public async Task GuessAsync(string guess_) { string guess = guess_.ToLower(); GuildData g_data = GuildCenter.GetGuild(Context.Guild.Id); if (g_data.werdData.gameStarted) { bool notYetEncountered = false; foreach (var user in g_data.werdData.players) { if (user.Id == Context.User.Id) { notYetEncountered = false; break; } else { notYetEncountered = true; } } if (notYetEncountered) { g_data.werdData.players.Add(Context.User); } if (guess.Length != 5) { await ReplyAsync("It's a *five* letter werd! Get it, *got it?*, **good.**"); } else if (g_data.werdData.werd == guess) { g_data.werdData.gameStarted = false; await ReplyAsync($"{Context.User.Mention} guessed the word! Now, I can take a nap... :smirk:"); } else if (!IsRealWerd(guess)) { await ReplyAsync($"{Context.User.Mention} that's not even a word bruh." + $" Don't f**k with me. *Wastin' my time.....*"); } else { await ReplyAsync($"{Context.User.Mention}, your guess earned {Werd.CalculatePoints(guess, g_data.werdData)} points. *Next.*"); } } else { await ReplyAsync("A game is not in progress in this guild. You have to start one before you can play. :expressionless:"); } }
public async Task SettingsAsync() { GuildData g_data = GuildCenter.GetGuild(Context.Guild.Id); if (g_data.Id == 0) { await ReplyAsync(Context.User.Mention + " no server settings saved."); } else { var builder = new EmbedBuilder(); builder.WithTitle("$AVAGE Bot settings for: " + Context.Guild.Name); builder.AddField("Default Channel", (g_data.defaultChannel == 0?"Not set.": Context.Guild.GetChannel(g_data.defaultChannel).Id.ToString())); builder.WithThumbnailUrl(Context.Guild.IconUrl); await Context.Channel.SendMessageAsync("", false, builder); } }
public async Task EndAsync() { GuildCenter.GetGuild(Context.Guild.Id).werdData.gameStarted = false; await ReplyAsync("The game has ended."); }
public async Task SaveAsync() { GuildCenter.SaveGuilds(); await ReplyAsync(Context.User.Mention + " guild settings have been saved."); }