Balance fixes to animal racing

This commit is contained in:
Kwoth 2016-12-25 13:35:59 +01:00
parent 4ecc66a3fe
commit fc27e662d2

View File

@ -29,7 +29,7 @@ namespace NadekoBot.Modules.Gambling
var ar = new AnimalRace(channel.Guild.Id, channel);
if (ar.Fail)
await channel.SendErrorAsync("🏁 `Failed starting a race. Another race is probably running.`");
await channel.SendErrorAsync("Animal Race", "Failed starting. Another race is probably running.").ConfigureAwait(false);
}
[NadekoCommand, Usage, Description, Aliases]
@ -45,7 +45,7 @@ namespace NadekoBot.Modules.Gambling
AnimalRace ar;
if (!AnimalRaces.TryGetValue(channel.Guild.Id, out ar))
{
await channel.SendErrorAsync("No race exists on this server");
await channel.SendErrorAsync("No race exists on this server").ConfigureAwait(false);
return;
}
await ar.JoinRace(umsg.Author as IGuildUser, amount);
@ -90,21 +90,29 @@ namespace NadekoBot.Modules.Gambling
{
try
{
try { await raceChannel.SendConfirmAsync($"🏁`Race is starting in 20 seconds or when the room is full. Type {NadekoBot.ModulePrefixes[typeof(Gambling).Name]}jr to join the race.`"); } catch (Exception ex) { _log.Warn(ex); }
try
{
await raceChannel.SendConfirmAsync("Animal Race", $"Starting in 20 seconds or when the room is full.",
footer: $"Type {NadekoBot.ModulePrefixes[typeof(Gambling).Name]}jr to join the race.");
}
catch (Exception ex)
{
_log.Warn(ex);
}
var t = await Task.WhenAny(Task.Delay(20000, token), fullgame);
Started = true;
cancelSource.Cancel();
if (t == fullgame)
{
try { await raceChannel.SendConfirmAsync("🏁`Race full, starting right now!`"); } catch (Exception ex) { _log.Warn(ex); }
try { await raceChannel.SendConfirmAsync("Animal Race", "Full! Starting immediately."); } catch (Exception ex) { _log.Warn(ex); }
}
else if (participants.Count > 1)
{
try { await raceChannel.SendConfirmAsync("🏁`Game starting with " + participants.Count + " participants.`"); } catch (Exception ex) { _log.Warn(ex); }
try { await raceChannel.SendConfirmAsync("Animal Race", "Starting with " + participants.Count + " participants."); } catch (Exception ex) { _log.Warn(ex); }
}
else
{
try { await raceChannel.SendErrorAsync("🏁`Race failed to start since there was not enough participants.`"); } catch (Exception ex) { _log.Warn(ex); }
try { await raceChannel.SendErrorAsync("Animal Race", "Failed to start since there was not enough participants."); } catch (Exception ex) { _log.Warn(ex); }
var p = participants.FirstOrDefault();
if (p != null && p.AmountBet > 0)
@ -141,13 +149,20 @@ namespace NadekoBot.Modules.Gambling
participants.ForEach(p =>
{
p.Total += 1 + rng.Next(0, 10);
});
participants
.OrderByDescending(p => p.Total)
.ForEach(p =>
{
if (p.Total > 60)
{
p.Total = 60;
if (winner == null)
{
winner = p;
}
p.Total = 60;
if (p.Place == 0)
p.Place = place++;
}
@ -185,11 +200,11 @@ namespace NadekoBot.Modules.Gambling
var wonAmount = winner.AmountBet * (participants.Count - 1);
await CurrencyHandler.AddCurrencyAsync(winner.User, "Won a Race", wonAmount, false).ConfigureAwait(false);
await raceChannel.SendConfirmAsync($"🏁 {winner.User.Mention} as {winner.Animal} **Won the race and {wonAmount}{CurrencySign}!**").ConfigureAwait(false);
await raceChannel.SendConfirmAsync("Animal Race", $"{winner.User.Mention} as {winner.Animal} **Won the race and {wonAmount}{CurrencySign}!**").ConfigureAwait(false);
}
else
{
await raceChannel.SendConfirmAsync($"🏁 {winner.User.Mention} as {winner.Animal} **Won the race!**");
await raceChannel.SendConfirmAsync("Animal Race", $"{winner.User.Mention} as {winner.Animal} **Won the race!**").ConfigureAwait(false);
}
}
@ -218,18 +233,18 @@ namespace NadekoBot.Modules.Gambling
var animal = "";
if (!animals.TryDequeue(out animal))
{
await raceChannel.SendErrorAsync($"{u.Mention} `There is no running race on this server.`");
await raceChannel.SendErrorAsync($"{u.Mention} `There is no running race on this server.`").ConfigureAwait(false);
return;
}
var p = new Participant(u, animal, amount);
if (participants.Contains(p))
{
await raceChannel.SendErrorAsync($"{u.Mention} `You already joined this race.`");
await raceChannel.SendErrorAsync($"{u.Mention} `You already joined this race.`").ConfigureAwait(false);
return;
}
if (Started)
{
await raceChannel.SendErrorAsync($"{u.Mention} `Race is already started`");
await raceChannel.SendErrorAsync($"{u.Mention} `Race is already started`").ConfigureAwait(false);
return;
}
if (amount > 0)
@ -239,7 +254,8 @@ namespace NadekoBot.Modules.Gambling
return;
}
participants.Add(p);
await raceChannel.SendConfirmAsync($"{u.Mention} **joined the race as a {p.Animal}" + (amount > 0 ? $" and bet {amount} {CurrencySign}!**" : "**"));
await raceChannel.SendConfirmAsync("Animal Race", $"{u.Mention} **joined as a {p.Animal}" + (amount > 0 ? $" and bet {amount} {CurrencySign}!**" : "**"))
.ConfigureAwait(false);
}
}