.waifulb will no longer show #0000 discriminators, for real this time

This commit is contained in:
Toastie (DCS Team) 2024-10-08 14:03:38 +13:00
parent db8885739f
commit 9f97badfc7
Signed by: toastie_t0ast
GPG key ID: 27F3B6855AFD40A4
4 changed files with 23 additions and 21 deletions

View file

@ -252,18 +252,18 @@ public partial class Gambling
var claimer = "no one";
string status;
var waifuUsername = w.Username.TrimTo(20);
var claimerUsername = w.Claimer?.TrimTo(20);
var waifuUsername = w.WaifuName.TrimTo(20);
var claimerUsername = w.ClaimerName?.TrimTo(20);
if (w.Claimer is not null)
claimer = $"{claimerUsername}#{w.ClaimerDiscrim}";
if (w.ClaimerName is not null)
claimer = $"{claimerUsername}";
if (w.Affinity is null)
status = $"... but {waifuUsername}'s heart is empty";
else if (w.Affinity + w.AffinityDiscrim == w.Claimer + w.ClaimerDiscrim)
else if (w.Affinity == w.ClaimerName)
status = $"... and {waifuUsername} likes {claimerUsername} too <3";
else
status = $"... but {waifuUsername}'s heart belongs to {w.Affinity.TrimTo(20)}#{w.AffinityDiscrim}";
return $"**{waifuUsername}#{w.Discrim}** - claimed by **{claimer}**\n\t{status}";
status = $"... but {waifuUsername}'s heart belongs to {w.Affinity.TrimTo(20)}";
return $"**{waifuUsername}** - claimed by **{claimer}**\n\t{status}";
}
[Cmd]

View file

@ -40,12 +40,17 @@ public static class WaifuExtensions
.Take(count)
.Select(x => new WaifuLbResult
{
Affinity = x.Affinity == null ? null : x.Affinity.Username,
AffinityDiscrim = x.Affinity == null ? null : x.Affinity.Discriminator,
Claimer = x.Claimer == null ? null : x.Claimer.Username,
ClaimerDiscrim = x.Claimer == null ? null : x.Claimer.Discriminator,
Username = x.Waifu.Username,
Discrim = x.Waifu.Discriminator,
Affinity = x.Affinity == null
? null
: x.Affinity.Username
+ (x.Affinity.Discriminator != "0000" ? "#" + x.Affinity.Discriminator : ""),
ClaimerName =
x.Claimer == null
? null
: x.Claimer.Username
+ (x.Claimer.Discriminator != "0000" ? "#" + x.Claimer.Discriminator : ""),
WaifuName = x.Waifu.Username
+ (x.Waifu.Discriminator != "0000" ? "#" + x.Waifu.Discriminator : ""),
Price = x.Price
})
.ToListAsyncEF();

View file

@ -3,14 +3,11 @@ namespace EllieBot.Db.Models;
public class WaifuLbResult
{
public string Username { get; set; }
public string Discrim { get; set; }
public string WaifuName { get; set; }
public string Claimer { get; set; }
public string ClaimerDiscrim { get; set; }
public string ClaimerName { get; set; }
public string Affinity { get; set; }
public string AffinityDiscrim { get; set; }
public long Price { get; set; }
}

View file

@ -134,10 +134,10 @@ public sealed class OtherSvc : GrpcOther.GrpcOtherBase, IEService
var reply = new WaifuLbReply();
reply.Entries.AddRange(waifus.Select(x => new WaifuLbEntry()
{
ClaimedBy = x.Claimer ?? string.Empty,
IsMutual = x.Claimer == x.Affinity,
ClaimedBy = x.ClaimerName ?? string.Empty,
IsMutual = x.ClaimerName == x.Affinity,
Value = x.Price,
User = x.Username,
User = x.WaifuName,
}));
return reply;
}