acrophobia finalized

This commit is contained in:
Kwoth 2016-12-22 12:29:56 +01:00
parent 4d7fc8402b
commit 9b887b7688
3 changed files with 16 additions and 17 deletions

View File

@ -110,7 +110,7 @@ namespace NadekoBot.Modules.Games
-- --
{this.submissions.Aggregate("", (agg, cur) => agg + $"`{++i}.` **{cur.Key.ToLowerInvariant().ToTitleCase()}**\n")} {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() public async Task Run()
@ -229,24 +229,23 @@ namespace NadekoBot.Modules.Games
} }
IGuildUser usr; IGuildUser usr;
if (submissions.TryGetValue(input, out usr) && usr.Id != guildUser.Id) //if (submissions.TryGetValue(input, out usr) && usr.Id != guildUser.Id)
{ //{
if (!usersWhoVoted.Add(guildUser.Id)) // if (!usersWhoVoted.Add(guildUser.Id))
return; // return;
votes.AddOrUpdate(input, 1, (key, old) => ++old); // votes.AddOrUpdate(input, 1, (key, old) => ++old);
await channel.SendConfirmAsync("Acrophobia", $"{guildUser.Mention} cast their vote!").ConfigureAwait(false); // await channel.SendConfirmAsync("Acrophobia", $"{guildUser.Mention} cast their vote!").ConfigureAwait(false);
await msg.DeleteAsync().ConfigureAwait(false); // await msg.DeleteAsync().ConfigureAwait(false);
return; // return;
} //}
int num; 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; usr = kvp.Value;
if (usr.Id == guildUser.Id) //can't vote for yourself, can't vote multiple times
return; if (usr.Id == guildUser.Id || !usersWhoVoted.Add(guildUser.Id))
if (!usersWhoVoted.Add(guildUser.Id))
return; return;
votes.AddOrUpdate(kvp.Key, 1, (key, old) => ++old); votes.AddOrUpdate(kvp.Key, 1, (key, old) => ++old);
await channel.SendConfirmAsync("Acrophobia", $"{guildUser.Mention} cast their vote!").ConfigureAwait(false); await channel.SendConfirmAsync("Acrophobia", $"{guildUser.Mention} cast their vote!").ConfigureAwait(false);

View File

@ -87,7 +87,7 @@ namespace NadekoBot.Resources {
} }
/// <summary> /// <summary>
/// Looks up a localized string similar to acro. /// Looks up a localized string similar to acrophobia acro.
/// </summary> /// </summary>
public static string acro_cmd { public static string acro_cmd {
get { get {

View File

@ -2791,7 +2791,7 @@
<value>`{0}ow us Battletag#1337` or `{0}overwatch eu Battletag#2016`</value> <value>`{0}ow us Battletag#1337` or `{0}overwatch eu Battletag#2016`</value>
</data> </data>
<data name="acro_cmd" xml:space="preserve"> <data name="acro_cmd" xml:space="preserve">
<value>acro</value> <value>acrophobia acro</value>
</data> </data>
<data name="acro_desc" xml:space="preserve"> <data name="acro_desc" xml:space="preserve">
<value>Starts an Acrophobia game. Second argment is optional round length in seconds. (default is 60)</value> <value>Starts an Acrophobia game. Second argment is optional round length in seconds. (default is 60)</value>