mirror of
https://github.com/barelyprofessional/KfChatDotNet.git
synced 2026-05-02 04:22:04 -04:00
Use Humanizer for enum
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using System.ComponentModel;
|
||||
using System.Reflection;
|
||||
using System.Text.RegularExpressions;
|
||||
using Humanizer;
|
||||
using KfChatDotNetBot.Extensions;
|
||||
using KfChatDotNetBot.Models;
|
||||
using KfChatDotNetBot.Models.DbModels;
|
||||
@@ -121,7 +122,7 @@ public class LegitCheckCommand : ICommand
|
||||
|
||||
if (luckiestGame != null)
|
||||
{
|
||||
var gameName = GetGameDisplayName(luckiestGame.Game);
|
||||
var gameName = luckiestGame.Game.Humanize();
|
||||
response +=
|
||||
$" | Luckiest: {gameName} ({luckiestGame.Rtp:F2}% RTP, {luckiestGame.WagerCount:N0} wagers, {await luckiestGame.TotalWagered.FormatKasinoCurrencyAsync()} wagered)";
|
||||
}
|
||||
@@ -129,18 +130,6 @@ public class LegitCheckCommand : ICommand
|
||||
await botInstance.SendChatMessageAsync(response, true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the display name for a WagerGame enum value.
|
||||
/// Uses the [Description] attribute if present (e.g., LambChop -> "Lambchop"),
|
||||
/// otherwise falls back to the enum name itself.
|
||||
/// </summary>
|
||||
private static string GetGameDisplayName(WagerGame game)
|
||||
{
|
||||
var memberInfo = typeof(WagerGame).GetMember(game.ToString()).FirstOrDefault();
|
||||
var descriptionAttribute = memberInfo?.GetCustomAttribute<DescriptionAttribute>();
|
||||
return descriptionAttribute?.Description ?? game.ToString();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Helper class to hold per-game statistics during calculation.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user