Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .idea/.idea.GitcgNetCord/.idea/dataSources.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 17 additions & 8 deletions src/GitcgNetCord.MainApp/Commands/Slash/CardSlashCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,21 +51,21 @@ await context.Interaction.SendResponseAsync(

var accountCommand = commands
.First(x => x.Name == "hoyolab-accounts");

await context.Interaction.ModifyResponseAsync(message =>
{
message.AddEmbeds(new EmbedProperties()
.WithTitle("Error")
.WithDescription(
$"""
You don't have an active Hoyolab account.
Please use the command {accountCommand} to set one up.
"""
You don't have an active Hoyolab account.
Please use the command {accountCommand} to set one up.
"""
)
.WithColor(new NetCord.Color(Color.Red.ToArgb()))
);
});

return;
}

Expand Down Expand Up @@ -103,14 +103,21 @@ await context.Interaction.ModifyResponseAsync(message =>
.GetApplicationEmojisAsync(context.Client.Id);
var emojis = appEmojis.ToImmutableDictionary(x => x.Name);

var winRate = data.CardList
var characters = data.CardList
.Where(x => x is
{
CardType: "CardTypeCharacter",
UseCount: > 0
}
&& x.UseCount > minUseCount
)
.ToImmutableArray();

var gameCount = characters.Sum(x => x.UseCount) / 3;
var winCount = characters.Sum(x => x.Proficiency) / 3;
var winRate = (float)winCount / gameCount;

var winRateList = characters
.Select(x => new
{
x.Id, x.Name, x.Proficiency, x.UseCount,
Expand All @@ -119,11 +126,11 @@ await context.Interaction.ModifyResponseAsync(message =>
.OrderByDescending(x => x.WinRate)
.ToImmutableArray();

var bestWinRate = winRate
var bestWinRate = winRateList
.Take(topWinRateCount)
.ToImmutableArray();

var lowestWinRate = winRate
var lowestWinRate = winRateList
.TakeLast(topWinRateCount)
.Reverse()
.ToImmutableArray();
Expand Down Expand Up @@ -200,6 +207,8 @@ await context.Interaction.ModifyResponseAsync(message =>
.WithColor(new NetCord.Color(Color.Purple.ToArgb()))
.WithTitle($"{data.Stats.Nickname}")
.AddFields(
new EmbedFieldProperties()
.WithName($"Win rate {winRate:P2} ({winCount}/{gameCount})"),
new EmbedFieldProperties()
.WithName("Best win rate")
.WithValue(bestWinRateStringBuilder.ToString())
Expand Down