Balance fixes to animal racing
This commit is contained in:
parent
4ecc66a3fe
commit
fc27e662d2
@ -29,7 +29,7 @@ namespace NadekoBot.Modules.Gambling
|
|||||||
var ar = new AnimalRace(channel.Guild.Id, channel);
|
var ar = new AnimalRace(channel.Guild.Id, channel);
|
||||||
|
|
||||||
if (ar.Fail)
|
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]
|
[NadekoCommand, Usage, Description, Aliases]
|
||||||
@ -45,7 +45,7 @@ namespace NadekoBot.Modules.Gambling
|
|||||||
AnimalRace ar;
|
AnimalRace ar;
|
||||||
if (!AnimalRaces.TryGetValue(channel.Guild.Id, out 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;
|
return;
|
||||||
}
|
}
|
||||||
await ar.JoinRace(umsg.Author as IGuildUser, amount);
|
await ar.JoinRace(umsg.Author as IGuildUser, amount);
|
||||||
@ -90,21 +90,29 @@ namespace NadekoBot.Modules.Gambling
|
|||||||
{
|
{
|
||||||
try
|
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);
|
var t = await Task.WhenAny(Task.Delay(20000, token), fullgame);
|
||||||
Started = true;
|
Started = true;
|
||||||
cancelSource.Cancel();
|
cancelSource.Cancel();
|
||||||
if (t == fullgame)
|
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)
|
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
|
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();
|
var p = participants.FirstOrDefault();
|
||||||
|
|
||||||
if (p != null && p.AmountBet > 0)
|
if (p != null && p.AmountBet > 0)
|
||||||
@ -141,19 +149,26 @@ namespace NadekoBot.Modules.Gambling
|
|||||||
participants.ForEach(p =>
|
participants.ForEach(p =>
|
||||||
{
|
{
|
||||||
p.Total += 1 + rng.Next(0, 10);
|
p.Total += 1 + rng.Next(0, 10);
|
||||||
if (p.Total > 60)
|
|
||||||
{
|
|
||||||
p.Total = 60;
|
|
||||||
if (winner == null)
|
|
||||||
{
|
|
||||||
winner = p;
|
|
||||||
}
|
|
||||||
if (p.Place == 0)
|
|
||||||
p.Place = place++;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
participants
|
||||||
|
.OrderByDescending(p => p.Total)
|
||||||
|
.ForEach(p =>
|
||||||
|
{
|
||||||
|
if (p.Total > 60)
|
||||||
|
{
|
||||||
|
if (winner == null)
|
||||||
|
{
|
||||||
|
winner = p;
|
||||||
|
}
|
||||||
|
p.Total = 60;
|
||||||
|
if (p.Place == 0)
|
||||||
|
p.Place = place++;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
//draw the state
|
//draw the state
|
||||||
|
|
||||||
var text = $@"|🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🔚|
|
var text = $@"|🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🔚|
|
||||||
@ -185,11 +200,11 @@ namespace NadekoBot.Modules.Gambling
|
|||||||
var wonAmount = winner.AmountBet * (participants.Count - 1);
|
var wonAmount = winner.AmountBet * (participants.Count - 1);
|
||||||
|
|
||||||
await CurrencyHandler.AddCurrencyAsync(winner.User, "Won a Race", wonAmount, false).ConfigureAwait(false);
|
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
|
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 = "";
|
var animal = "";
|
||||||
if (!animals.TryDequeue(out 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;
|
return;
|
||||||
}
|
}
|
||||||
var p = new Participant(u, animal, amount);
|
var p = new Participant(u, animal, amount);
|
||||||
if (participants.Contains(p))
|
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;
|
return;
|
||||||
}
|
}
|
||||||
if (Started)
|
if (Started)
|
||||||
{
|
{
|
||||||
await raceChannel.SendErrorAsync($"{u.Mention} `Race is already started`");
|
await raceChannel.SendErrorAsync($"{u.Mention} `Race is already started`").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (amount > 0)
|
if (amount > 0)
|
||||||
@ -239,7 +254,8 @@ namespace NadekoBot.Modules.Gambling
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
participants.Add(p);
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user