Fixed timely on different shards
.race will now have 82-94% payout rate based on the number of players playign (1-12, x0.01 per player). Any player over 12 won't increase payout
This commit is contained in:
parent
e7cfd3a752
commit
fae15a9e0a
5 changed files with 69 additions and 25 deletions
|
@ -6,6 +6,10 @@ namespace EllieBot.Modules.Gambling.Common.AnimalRacing;
|
||||||
|
|
||||||
public sealed class AnimalRace : IDisposable
|
public sealed class AnimalRace : IDisposable
|
||||||
{
|
{
|
||||||
|
public const double BASE_MULTIPLIER = 0.82;
|
||||||
|
public const double MAX_MULTIPLIER = 0.94;
|
||||||
|
public const double MULTI_PER_USER = 0.01;
|
||||||
|
|
||||||
public enum Phase
|
public enum Phase
|
||||||
{
|
{
|
||||||
WaitingForPlayers,
|
WaitingForPlayers,
|
||||||
|
@ -100,7 +104,7 @@ public sealed class AnimalRace : IDisposable
|
||||||
foreach (var user in _users)
|
foreach (var user in _users)
|
||||||
{
|
{
|
||||||
if (user.Bet > 0)
|
if (user.Bet > 0)
|
||||||
await _currency.AddAsync(user.UserId, user.Bet, new("animalrace", "refund"));
|
await _currency.AddAsync(user.UserId, (long)(user.Bet + BASE_MULTIPLIER), new("animalrace", "refund"));
|
||||||
}
|
}
|
||||||
|
|
||||||
_ = OnStartingFailed?.Invoke(this);
|
_ = OnStartingFailed?.Invoke(this);
|
||||||
|
@ -131,8 +135,10 @@ public sealed class AnimalRace : IDisposable
|
||||||
|
|
||||||
if (FinishedUsers[0].Bet > 0)
|
if (FinishedUsers[0].Bet > 0)
|
||||||
{
|
{
|
||||||
|
Multi = FinishedUsers.Count
|
||||||
|
* Math.Min(MAX_MULTIPLIER, BASE_MULTIPLIER + (MULTI_PER_USER * FinishedUsers.Count));
|
||||||
await _currency.AddAsync(FinishedUsers[0].UserId,
|
await _currency.AddAsync(FinishedUsers[0].UserId,
|
||||||
FinishedUsers[0].Bet * (_users.Count - 1),
|
(long)(FinishedUsers[0].Bet * Multi),
|
||||||
new("animalrace", "win"));
|
new("animalrace", "win"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -140,6 +146,8 @@ public sealed class AnimalRace : IDisposable
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public double Multi { get; set; } = BASE_MULTIPLIER;
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
CurrentPhase = Phase.Ended;
|
CurrentPhase = Phase.Ended;
|
||||||
|
|
|
@ -74,10 +74,14 @@ public partial class Gambling
|
||||||
if (race.FinishedUsers[0].Bet > 0)
|
if (race.FinishedUsers[0].Bet > 0)
|
||||||
{
|
{
|
||||||
return Response()
|
return Response()
|
||||||
.Confirm(GetText(strs.animal_race),
|
.Embed(_sender.CreateEmbed()
|
||||||
GetText(strs.animal_race_won_money(Format.Bold(winner.Username),
|
.WithOkColor()
|
||||||
|
.WithTitle(GetText(strs.animal_race))
|
||||||
|
.WithDescription(GetText(strs.animal_race_won_money(
|
||||||
|
Format.Bold(winner.Username),
|
||||||
winner.Animal.Icon,
|
winner.Animal.Icon,
|
||||||
(race.FinishedUsers[0].Bet * (race.Users.Count - 1)) + CurrencySign)))
|
N(race.FinishedUsers[0].Bet * race.Multi))))
|
||||||
|
.WithFooter($"x{race.Multi:F2}"))
|
||||||
.SendAsync();
|
.SendAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -291,7 +291,6 @@ public partial class Gambling : GamblingModule<GamblingService>
|
||||||
{
|
{
|
||||||
_ = captcha.DeleteAsync();
|
_ = captcha.DeleteAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
await ClaimTimely();
|
await ClaimTimely();
|
||||||
|
@ -326,22 +325,19 @@ public partial class Gambling : GamblingModule<GamblingService>
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var guild = await ((IDiscordClient)_client).GetGuildAsync(gid);
|
var guild = await _client.Rest.GetGuildAsync(gid, false);
|
||||||
if (guild is null)
|
var user = await _client.Rest.GetGuildUserAsync(gid, ctx.User.Id);
|
||||||
return null;
|
return (guild, user);
|
||||||
|
|
||||||
var user = await guild.GetUserAsync(ctx.User.Id);
|
|
||||||
return user;
|
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
return null;
|
return default;
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.WhenAll();
|
.WhenAll();
|
||||||
|
|
||||||
var boostGuildUser = guildUsers.FirstOrDefault(x => x?.PremiumSince is not null);
|
var userInfo = guildUsers.FirstOrDefault(x => x.user?.PremiumSince is not null);
|
||||||
var booster = boostGuildUser is not null;
|
var booster = userInfo != default;
|
||||||
|
|
||||||
if (booster)
|
if (booster)
|
||||||
val += Config.BoostBonus.BaseTimelyBonus;
|
val += Config.BoostBonus.BaseTimelyBonus;
|
||||||
|
@ -360,7 +356,7 @@ public partial class Gambling : GamblingModule<GamblingService>
|
||||||
{
|
{
|
||||||
var msg = GetText(strs.timely(N(val), period))
|
var msg = GetText(strs.timely(N(val), period))
|
||||||
+ "\n\n"
|
+ "\n\n"
|
||||||
+ $"*+{N(Config.BoostBonus.BaseTimelyBonus)} bonus for boosting {boostGuildUser.Guild}!*";
|
+ $"*+{N(Config.BoostBonus.BaseTimelyBonus)} bonus for boosting {userInfo.guild}!*";
|
||||||
|
|
||||||
await Response().Confirm(msg).Interaction(inter).SendAsync();
|
await Response().Confirm(msg).Interaction(inter).SendAsync();
|
||||||
}
|
}
|
||||||
|
|
|
@ -147,7 +147,7 @@ public class PlantPickService : IEService, IExecNoCommand
|
||||||
pass = pass.TrimTo(10, true).ToLowerInvariant();
|
pass = pass.TrimTo(10, true).ToLowerInvariant();
|
||||||
using var img = Image.Load<Rgba32>(curImg);
|
using var img = Image.Load<Rgba32>(curImg);
|
||||||
// choose font size based on the image height, so that it's visible
|
// choose font size based on the image height, so that it's visible
|
||||||
var font = _fonts.NotoSans.CreateFont(img.Height / 12.0f, FontStyle.Bold);
|
var font = _fonts.NotoSans.CreateFont(img.Height / 11.0f, FontStyle.Bold);
|
||||||
img.Mutate(x =>
|
img.Mutate(x =>
|
||||||
{
|
{
|
||||||
// measure the size of the text to be drawing
|
// measure the size of the text to be drawing
|
||||||
|
@ -159,7 +159,7 @@ public class PlantPickService : IEService, IExecNoCommand
|
||||||
|
|
||||||
// fill the background with black, add 5 pixels on each side to make it look better
|
// fill the background with black, add 5 pixels on each side to make it look better
|
||||||
x.FillPolygon(Color.ParseHex("00000080"),
|
x.FillPolygon(Color.ParseHex("00000080"),
|
||||||
new PointF(0, 0),
|
new PointF(1, 1),
|
||||||
new PointF(size.Width + 5, 0),
|
new PointF(size.Width + 5, 0),
|
||||||
new PointF(size.Width + 5, size.Height + 10),
|
new PointF(size.Width + 5, size.Height + 10),
|
||||||
new PointF(0, size.Height + 10));
|
new PointF(0, size.Height + 10));
|
||||||
|
|
|
@ -2758,11 +2758,29 @@
|
||||||
"Gambling": [
|
"Gambling": [
|
||||||
{
|
{
|
||||||
"Aliases": [
|
"Aliases": [
|
||||||
".betstats"
|
".betstats",
|
||||||
|
".bs"
|
||||||
|
],
|
||||||
|
"Description": "Shows the current bet stats for yourself, or the targetted user.\nYou may optionally specify the game to show stats for.\nSupported games right now are: bf, br, bd, lula, slot, race",
|
||||||
|
"Usage": [
|
||||||
|
".betstats",
|
||||||
|
".betstats @someone",
|
||||||
|
".betstats @someone lula",
|
||||||
|
".betstats bd"
|
||||||
|
],
|
||||||
|
"Submodule": "Gambling",
|
||||||
|
"Module": "Gambling",
|
||||||
|
"Options": null,
|
||||||
|
"Requirements": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Aliases": [
|
||||||
|
".gamblestats",
|
||||||
|
".gs"
|
||||||
],
|
],
|
||||||
"Description": "Shows the total stats of several gambling features.\nUpdates once an hour.",
|
"Description": "Shows the total stats of several gambling features.\nUpdates once an hour.",
|
||||||
"Usage": [
|
"Usage": [
|
||||||
".betstats"
|
".gamblestats"
|
||||||
],
|
],
|
||||||
"Submodule": "Gambling",
|
"Submodule": "Gambling",
|
||||||
"Module": "Gambling",
|
"Module": "Gambling",
|
||||||
|
@ -6160,6 +6178,24 @@
|
||||||
"Options": null,
|
"Options": null,
|
||||||
"Requirements": []
|
"Requirements": []
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"Aliases": [
|
||||||
|
".translateflags",
|
||||||
|
".trfl",
|
||||||
|
".fltr",
|
||||||
|
".transflags"
|
||||||
|
],
|
||||||
|
"Description": "Toggles translate flags on the current channel.\nReacting with a country flag will translate the message to that country's language.",
|
||||||
|
"Usage": [
|
||||||
|
".translateflags"
|
||||||
|
],
|
||||||
|
"Submodule": "TranslateCommands",
|
||||||
|
"Module": "Searches",
|
||||||
|
"Options": null,
|
||||||
|
"Requirements": [
|
||||||
|
"ManageChannels Channel Permission"
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"Aliases": [
|
"Aliases": [
|
||||||
".xkcd"
|
".xkcd"
|
||||||
|
|
Loading…
Reference in a new issue