From 9b887b76882192b58f6c681abefad5e4e5478c6c Mon Sep 17 00:00:00 2001 From: Kwoth Date: Thu, 22 Dec 2016 12:29:56 +0100 Subject: [PATCH] acrophobia finalized --- .../Modules/Games/Commands/Acropobia.cs | 29 +++++++++---------- .../Resources/CommandStrings.Designer.cs | 2 +- src/NadekoBot/Resources/CommandStrings.resx | 2 +- 3 files changed, 16 insertions(+), 17 deletions(-) diff --git a/src/NadekoBot/Modules/Games/Commands/Acropobia.cs b/src/NadekoBot/Modules/Games/Commands/Acropobia.cs index 2a16fdc7..795c0f63 100644 --- a/src/NadekoBot/Modules/Games/Commands/Acropobia.cs +++ b/src/NadekoBot/Modules/Games/Commands/Acropobia.cs @@ -110,7 +110,7 @@ namespace NadekoBot.Modules.Games -- {this.submissions.Aggregate("", (agg, cur) => agg + $"`{++i}.` **{cur.Key.ToLowerInvariant().ToTitleCase()}**\n")} --") - .WithFooter(efb => efb.WithText("Vote by retyping one of the submissions")); + .WithFooter(efb => efb.WithText("Vote by typing a number of the submission")); } public async Task Run() @@ -229,24 +229,23 @@ namespace NadekoBot.Modules.Games } IGuildUser usr; - if (submissions.TryGetValue(input, out usr) && usr.Id != guildUser.Id) - { - if (!usersWhoVoted.Add(guildUser.Id)) - return; - votes.AddOrUpdate(input, 1, (key, old) => ++old); - await channel.SendConfirmAsync("Acrophobia", $"{guildUser.Mention} cast their vote!").ConfigureAwait(false); - await msg.DeleteAsync().ConfigureAwait(false); - return; - } + //if (submissions.TryGetValue(input, out usr) && usr.Id != guildUser.Id) + //{ + // if (!usersWhoVoted.Add(guildUser.Id)) + // return; + // votes.AddOrUpdate(input, 1, (key, old) => ++old); + // await channel.SendConfirmAsync("Acrophobia", $"{guildUser.Mention} cast their vote!").ConfigureAwait(false); + // await msg.DeleteAsync().ConfigureAwait(false); + // return; + //} int num; - if (int.TryParse(input, out num) && num >= 0 && num < submissions.Count) + if (int.TryParse(input, out num) && num > 0 && num <= submissions.Count) { - var kvp = submissions.Skip(num).First(); + var kvp = submissions.Skip(num - 1).First(); usr = kvp.Value; - if (usr.Id == guildUser.Id) - return; - if (!usersWhoVoted.Add(guildUser.Id)) + //can't vote for yourself, can't vote multiple times + if (usr.Id == guildUser.Id || !usersWhoVoted.Add(guildUser.Id)) return; votes.AddOrUpdate(kvp.Key, 1, (key, old) => ++old); await channel.SendConfirmAsync("Acrophobia", $"{guildUser.Mention} cast their vote!").ConfigureAwait(false); diff --git a/src/NadekoBot/Resources/CommandStrings.Designer.cs b/src/NadekoBot/Resources/CommandStrings.Designer.cs index e7f12432..d4e2eeda 100644 --- a/src/NadekoBot/Resources/CommandStrings.Designer.cs +++ b/src/NadekoBot/Resources/CommandStrings.Designer.cs @@ -87,7 +87,7 @@ namespace NadekoBot.Resources { } /// - /// Looks up a localized string similar to acro. + /// Looks up a localized string similar to acrophobia acro. /// public static string acro_cmd { get { diff --git a/src/NadekoBot/Resources/CommandStrings.resx b/src/NadekoBot/Resources/CommandStrings.resx index ec4a51f0..0b6c7881 100644 --- a/src/NadekoBot/Resources/CommandStrings.resx +++ b/src/NadekoBot/Resources/CommandStrings.resx @@ -2791,7 +2791,7 @@ `{0}ow us Battletag#1337` or `{0}overwatch eu Battletag#2016` - acro + acrophobia acro Starts an Acrophobia game. Second argment is optional round length in seconds. (default is 60)