From d3c90ab59fc4e8a2a74d7b678249c98ac3ac494d Mon Sep 17 00:00:00 2001 From: Toastie <toastie@toastiet0ast.com> Date: Tue, 1 Apr 2025 13:24:46 +1300 Subject: [PATCH 1/2] fishlb will now compare unique fish caught, instead of total catches --- src/EllieBot/Modules/Games/Fish/FishService.cs | 9 +++++---- src/EllieBot/Modules/Games/Fish/FishingCommands.cs | 8 +++++++- src/EllieBot/strings/responses/responses.en-US.json | 1 + 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/EllieBot/Modules/Games/Fish/FishService.cs b/src/EllieBot/Modules/Games/Fish/FishService.cs index 09deb17..90fc2e9 100644 --- a/src/EllieBot/Modules/Games/Fish/FishService.cs +++ b/src/EllieBot/Modules/Games/Fish/FishService.cs @@ -469,22 +469,23 @@ public sealed class FishService( return catches; } - public async Task<IReadOnlyCollection<(ulong UserId, int Catches)>> GetFishLbAsync(int page) + public async Task<IReadOnlyCollection<(ulong UserId, int Catches, int Unique)>> GetFishLbAsync(int page) { await using var ctx = db.GetDbContext(); var result = await ctx.GetTable<FishCatch>() .GroupBy(x => x.UserId) - .OrderByDescending(x => x.Sum(x => x.Count)) + .OrderByDescending(x => x.Count()) .Skip(page * 10) .Take(10) .Select(x => new { UserId = x.Key, - Catches = x.Sum(x => x.Count) + Catches = x.Sum(x => x.Count), + Unique = x.Count() }) .ToListAsyncLinqToDB() - .Fmap(x => x.Map(y => (y.UserId, y.Catches))); + .Fmap(x => x.Map(y => (y.UserId, y.Catches, y.Unique)).ToList()); return result; } diff --git a/src/EllieBot/Modules/Games/Fish/FishingCommands.cs b/src/EllieBot/Modules/Games/Fish/FishingCommands.cs index eb62b9f..fadf4bf 100644 --- a/src/EllieBot/Modules/Games/Fish/FishingCommands.cs +++ b/src/EllieBot/Modules/Games/Fish/FishingCommands.cs @@ -235,8 +235,14 @@ public partial class Games ? ud.ToString() : data.UserId.ToString(); + var text = + $""" + {GetText(strs.fish_unique(Format.Bold(data.Unique.ToString())))} + *{GetText(strs.fish_catches(data.Catches))}* + """; + eb.AddField("#" + (page * 9 + i + 1) + " | " + user, - GetText(strs.fish_catches(Format.Bold(data.Catches.ToString()))), + text, false); } diff --git a/src/EllieBot/strings/responses/responses.en-US.json b/src/EllieBot/strings/responses/responses.en-US.json index fea5dad..74d556e 100644 --- a/src/EllieBot/strings/responses/responses.en-US.json +++ b/src/EllieBot/strings/responses/responses.en-US.json @@ -1260,5 +1260,6 @@ "fish_inv_title": "Fishing Inventory", "fish_cant_uneq_potion": "You can't unequip a potion.", "fish_lb_title": "Fishing Leaderboard", + "fish_unique": "Caught {0} unique fish", "fish_catches": "{0} catches" } \ No newline at end of file From 68e736ceb820e60bf2cf360fba556af7ca6f3dd8 Mon Sep 17 00:00:00 2001 From: Toastie <toastie@toastiet0ast.com> Date: Tue, 1 Apr 2025 13:26:17 +1300 Subject: [PATCH 2/2] .fishlb will now use totalcatches as a tiebreaker --- src/EllieBot/Modules/Games/Fish/FishService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/EllieBot/Modules/Games/Fish/FishService.cs b/src/EllieBot/Modules/Games/Fish/FishService.cs index 90fc2e9..934aecc 100644 --- a/src/EllieBot/Modules/Games/Fish/FishService.cs +++ b/src/EllieBot/Modules/Games/Fish/FishService.cs @@ -475,7 +475,7 @@ public sealed class FishService( var result = await ctx.GetTable<FishCatch>() .GroupBy(x => x.UserId) - .OrderByDescending(x => x.Count()) + .OrderByDescending(x => x.Count()).ThenByDescending(x => x.Sum(x => x.Count)) .Skip(page * 10) .Take(10) .Select(x => new