From a7f4173df786a102ef8be1b1e789603a0c36b7a2 Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Thu, 27 Nov 2025 21:49:25 +0800 Subject: [PATCH] :sparkles: Special birthday check in tips --- .../Account/AccountEventService.cs | 96 +++-- .../AccountEventResource.Designer.cs | 338 ++++++++++++++---- .../Localization/AccountEventResource.resx | 6 + .../AccountEventResource.zh-hans.resx | 6 + DysonNetwork.sln.DotSettings.user | 2 +- 5 files changed, 332 insertions(+), 116 deletions(-) diff --git a/DysonNetwork.Pass/Account/AccountEventService.cs b/DysonNetwork.Pass/Account/AccountEventService.cs index 9983ca7..33ae420 100644 --- a/DysonNetwork.Pass/Account/AccountEventService.cs +++ b/DysonNetwork.Pass/Account/AccountEventService.cs @@ -313,44 +313,6 @@ public class AccountEventService( CultureInfo.CurrentCulture = cultureInfo; CultureInfo.CurrentUICulture = cultureInfo; - // Generate 2 positive tips - var positiveIndices = Enumerable.Range(1, FortuneTipCount) - .OrderBy(_ => Random.Next()) - .Take(2) - .ToList(); - var tips = positiveIndices.Select(index => new CheckInFortuneTip - { - IsPositive = true, - Title = localizer[$"FortuneTipPositiveTitle_{index}"].Value, - Content = localizer[$"FortuneTipPositiveContent_{index}"].Value - }).ToList(); - - // Generate 2 negative tips - var negativeIndices = Enumerable.Range(1, FortuneTipCount) - .Except(positiveIndices) - .OrderBy(_ => Random.Next()) - .Take(2) - .ToList(); - tips.AddRange(negativeIndices.Select(index => new CheckInFortuneTip - { - IsPositive = false, - Title = localizer[$"FortuneTipNegativeTitle_{index}"].Value, - Content = localizer[$"FortuneTipNegativeContent_{index}"].Value - })); - - // The 5 is specialized, keep it alone. - // Use weighted random distribution to make all levels reasonably achievable - // Weights: Worst: 10%, Worse: 20%, Normal: 40%, Better: 20%, Best: 10% - var randomValue = Random.Next(100); - var checkInLevel = randomValue switch - { - < 10 => CheckInResultLevel.Worst, // 0-9: 10% chance - < 30 => CheckInResultLevel.Worse, // 10-29: 20% chance - < 70 => CheckInResultLevel.Normal, // 30-69: 40% chance - < 90 => CheckInResultLevel.Better, // 70-89: 20% chance - _ => CheckInResultLevel.Best // 90-99: 10% chance - }; - var accountBirthday = await db.AccountProfiles .Where(x => x.AccountId == user.Id) .Select(x => x.Birthday) @@ -358,8 +320,64 @@ public class AccountEventService( var now = SystemClock.Instance.GetCurrentInstant().InUtc().Date; var birthdayDate = accountBirthday?.InUtc().Date; - if (birthdayDate.HasValue && birthdayDate.Value.Month == now.Month && birthdayDate.Value.Day == now.Day) + var isBirthday = birthdayDate.HasValue && birthdayDate.Value.Month == now.Month && birthdayDate.Value.Day == now.Day; + + List tips; + CheckInResultLevel checkInLevel; + + if (isBirthday) + { + // Skip random logic and tips generation for birthday checkInLevel = CheckInResultLevel.Special; + tips = [ + new CheckInFortuneTip() + { + IsPositive = true, + Title = localizer["FortuneTipSpecialTitle_Birthday"].Value, + Content = localizer["FortuneTipSpecialContent_Birthday", user.Nick].Value, + } + ]; + } + else + { + // Generate 2 positive tips + var positiveIndices = Enumerable.Range(1, FortuneTipCount) + .OrderBy(_ => Random.Next()) + .Take(2) + .ToList(); + tips = positiveIndices.Select(index => new CheckInFortuneTip + { + IsPositive = true, + Title = localizer[$"FortuneTipPositiveTitle_{index}"].Value, + Content = localizer[$"FortuneTipPositiveContent_{index}"].Value + }).ToList(); + + // Generate 2 negative tips + var negativeIndices = Enumerable.Range(1, FortuneTipCount) + .Except(positiveIndices) + .OrderBy(_ => Random.Next()) + .Take(2) + .ToList(); + tips.AddRange(negativeIndices.Select(index => new CheckInFortuneTip + { + IsPositive = false, + Title = localizer[$"FortuneTipNegativeTitle_{index}"].Value, + Content = localizer[$"FortuneTipNegativeContent_{index}"].Value + })); + + // The 5 is specialized, keep it alone. + // Use weighted random distribution to make all levels reasonably achievable + // Weights: Worst: 10%, Worse: 20%, Normal: 40%, Better: 20%, Best: 10% + var randomValue = Random.Next(100); + checkInLevel = randomValue switch + { + < 10 => CheckInResultLevel.Worst, // 0-9: 10% chance + < 30 => CheckInResultLevel.Worse, // 10-29: 20% chance + < 70 => CheckInResultLevel.Normal, // 30-69: 40% chance + < 90 => CheckInResultLevel.Better, // 70-89: 20% chance + _ => CheckInResultLevel.Best // 90-99: 10% chance + }; + } var result = new SnCheckInResult { diff --git a/DysonNetwork.Pass/Resources/Localization/AccountEventResource.Designer.cs b/DysonNetwork.Pass/Resources/Localization/AccountEventResource.Designer.cs index ca66bdb..c9e71ee 100644 --- a/DysonNetwork.Pass/Resources/Localization/AccountEventResource.Designer.cs +++ b/DysonNetwork.Pass/Resources/Localization/AccountEventResource.Designer.cs @@ -57,18 +57,6 @@ namespace DysonNetwork.Sphere.Resources { } } - internal static string FortuneTipNegativeTitle_1 { - get { - return ResourceManager.GetString("FortuneTipNegativeTitle_1", resourceCulture); - } - } - - internal static string FortuneTipNegativeContent_1 { - get { - return ResourceManager.GetString("FortuneTipNegativeContent_1", resourceCulture); - } - } - internal static string FortuneTipPositiveTitle_2 { get { return ResourceManager.GetString("FortuneTipPositiveTitle_2", resourceCulture); @@ -81,18 +69,6 @@ namespace DysonNetwork.Sphere.Resources { } } - internal static string FortuneTipNegativeTitle_2 { - get { - return ResourceManager.GetString("FortuneTipNegativeTitle_2", resourceCulture); - } - } - - internal static string FortuneTipNegativeContent_2 { - get { - return ResourceManager.GetString("FortuneTipNegativeContent_2", resourceCulture); - } - } - internal static string FortuneTipPositiveTitle_3 { get { return ResourceManager.GetString("FortuneTipPositiveTitle_3", resourceCulture); @@ -105,18 +81,6 @@ namespace DysonNetwork.Sphere.Resources { } } - internal static string FortuneTipNegativeTitle_3 { - get { - return ResourceManager.GetString("FortuneTipNegativeTitle_3", resourceCulture); - } - } - - internal static string FortuneTipNegativeContent_3 { - get { - return ResourceManager.GetString("FortuneTipNegativeContent_3", resourceCulture); - } - } - internal static string FortuneTipPositiveTitle_4 { get { return ResourceManager.GetString("FortuneTipPositiveTitle_4", resourceCulture); @@ -129,18 +93,6 @@ namespace DysonNetwork.Sphere.Resources { } } - internal static string FortuneTipNegativeTitle_4 { - get { - return ResourceManager.GetString("FortuneTipNegativeTitle_4", resourceCulture); - } - } - - internal static string FortuneTipNegativeContent_4 { - get { - return ResourceManager.GetString("FortuneTipNegativeContent_4", resourceCulture); - } - } - internal static string FortuneTipPositiveTitle_5 { get { return ResourceManager.GetString("FortuneTipPositiveTitle_5", resourceCulture); @@ -153,18 +105,6 @@ namespace DysonNetwork.Sphere.Resources { } } - internal static string FortuneTipNegativeTitle_5 { - get { - return ResourceManager.GetString("FortuneTipNegativeTitle_5", resourceCulture); - } - } - - internal static string FortuneTipNegativeContent_5 { - get { - return ResourceManager.GetString("FortuneTipNegativeContent_5", resourceCulture); - } - } - internal static string FortuneTipPositiveTitle_6 { get { return ResourceManager.GetString("FortuneTipPositiveTitle_6", resourceCulture); @@ -177,18 +117,6 @@ namespace DysonNetwork.Sphere.Resources { } } - internal static string FortuneTipNegativeTitle_6 { - get { - return ResourceManager.GetString("FortuneTipNegativeTitle_6", resourceCulture); - } - } - - internal static string FortuneTipNegativeContent_6 { - get { - return ResourceManager.GetString("FortuneTipNegativeContent_6", resourceCulture); - } - } - internal static string FortuneTipPositiveTitle_7 { get { return ResourceManager.GetString("FortuneTipPositiveTitle_7", resourceCulture); @@ -201,6 +129,162 @@ namespace DysonNetwork.Sphere.Resources { } } + internal static string FortuneTipPositiveTitle_8 { + get { + return ResourceManager.GetString("FortuneTipPositiveTitle_8", resourceCulture); + } + } + + internal static string FortuneTipPositiveContent_8 { + get { + return ResourceManager.GetString("FortuneTipPositiveContent_8", resourceCulture); + } + } + + internal static string FortuneTipPositiveTitle_9 { + get { + return ResourceManager.GetString("FortuneTipPositiveTitle_9", resourceCulture); + } + } + + internal static string FortuneTipPositiveContent_9 { + get { + return ResourceManager.GetString("FortuneTipPositiveContent_9", resourceCulture); + } + } + + internal static string FortuneTipPositiveTitle_10 { + get { + return ResourceManager.GetString("FortuneTipPositiveTitle_10", resourceCulture); + } + } + + internal static string FortuneTipPositiveContent_10 { + get { + return ResourceManager.GetString("FortuneTipPositiveContent_10", resourceCulture); + } + } + + internal static string FortuneTipPositiveTitle_11 { + get { + return ResourceManager.GetString("FortuneTipPositiveTitle_11", resourceCulture); + } + } + + internal static string FortuneTipPositiveContent_11 { + get { + return ResourceManager.GetString("FortuneTipPositiveContent_11", resourceCulture); + } + } + + internal static string FortuneTipPositiveTitle_12 { + get { + return ResourceManager.GetString("FortuneTipPositiveTitle_12", resourceCulture); + } + } + + internal static string FortuneTipPositiveContent_12 { + get { + return ResourceManager.GetString("FortuneTipPositiveContent_12", resourceCulture); + } + } + + internal static string FortuneTipPositiveTitle_13 { + get { + return ResourceManager.GetString("FortuneTipPositiveTitle_13", resourceCulture); + } + } + + internal static string FortuneTipPositiveContent_13 { + get { + return ResourceManager.GetString("FortuneTipPositiveContent_13", resourceCulture); + } + } + + internal static string FortuneTipPositiveTitle_14 { + get { + return ResourceManager.GetString("FortuneTipPositiveTitle_14", resourceCulture); + } + } + + internal static string FortuneTipPositiveContent_14 { + get { + return ResourceManager.GetString("FortuneTipPositiveContent_14", resourceCulture); + } + } + + internal static string FortuneTipNegativeTitle_1 { + get { + return ResourceManager.GetString("FortuneTipNegativeTitle_1", resourceCulture); + } + } + + internal static string FortuneTipNegativeContent_1 { + get { + return ResourceManager.GetString("FortuneTipNegativeContent_1", resourceCulture); + } + } + + internal static string FortuneTipNegativeTitle_2 { + get { + return ResourceManager.GetString("FortuneTipNegativeTitle_2", resourceCulture); + } + } + + internal static string FortuneTipNegativeContent_2 { + get { + return ResourceManager.GetString("FortuneTipNegativeContent_2", resourceCulture); + } + } + + internal static string FortuneTipNegativeTitle_3 { + get { + return ResourceManager.GetString("FortuneTipNegativeTitle_3", resourceCulture); + } + } + + internal static string FortuneTipNegativeContent_3 { + get { + return ResourceManager.GetString("FortuneTipNegativeContent_3", resourceCulture); + } + } + + internal static string FortuneTipNegativeTitle_4 { + get { + return ResourceManager.GetString("FortuneTipNegativeTitle_4", resourceCulture); + } + } + + internal static string FortuneTipNegativeContent_4 { + get { + return ResourceManager.GetString("FortuneTipNegativeContent_4", resourceCulture); + } + } + + internal static string FortuneTipNegativeTitle_5 { + get { + return ResourceManager.GetString("FortuneTipNegativeTitle_5", resourceCulture); + } + } + + internal static string FortuneTipNegativeContent_5 { + get { + return ResourceManager.GetString("FortuneTipNegativeContent_5", resourceCulture); + } + } + + internal static string FortuneTipNegativeTitle_6 { + get { + return ResourceManager.GetString("FortuneTipNegativeTitle_6", resourceCulture); + } + } + + internal static string FortuneTipNegativeContent_6 { + get { + return ResourceManager.GetString("FortuneTipNegativeContent_6", resourceCulture); + } + } + internal static string FortuneTipNegativeTitle_7 { get { return ResourceManager.GetString("FortuneTipNegativeTitle_7", resourceCulture); @@ -213,15 +297,117 @@ namespace DysonNetwork.Sphere.Resources { } } - internal static string FortuneTipNegativeTitle_1_ { + internal static string FortuneTipNegativeTitle_8 { get { - return ResourceManager.GetString("FortuneTipNegativeTitle_1 ", resourceCulture); + return ResourceManager.GetString("FortuneTipNegativeTitle_8", resourceCulture); } } - internal static string FortuneTipPositiveContent_14 { + internal static string FortuneTipNegativeContent_8 { get { - return ResourceManager.GetString("FortuneTipPositiveContent_14", resourceCulture); + return ResourceManager.GetString("FortuneTipNegativeContent_8", resourceCulture); + } + } + + internal static string FortuneTipNegativeTitle_9 { + get { + return ResourceManager.GetString("FortuneTipNegativeTitle_9", resourceCulture); + } + } + + internal static string FortuneTipNegativeContent_9 { + get { + return ResourceManager.GetString("FortuneTipNegativeContent_9", resourceCulture); + } + } + + internal static string FortuneTipNegativeTitle_10 { + get { + return ResourceManager.GetString("FortuneTipNegativeTitle_10", resourceCulture); + } + } + + internal static string FortuneTipNegativeContent_10 { + get { + return ResourceManager.GetString("FortuneTipNegativeContent_10", resourceCulture); + } + } + + internal static string FortuneTipNegativeTitle_11 { + get { + return ResourceManager.GetString("FortuneTipNegativeTitle_11", resourceCulture); + } + } + + internal static string FortuneTipNegativeContent_11 { + get { + return ResourceManager.GetString("FortuneTipNegativeContent_11", resourceCulture); + } + } + + internal static string FortuneTipNegativeTitle_12 { + get { + return ResourceManager.GetString("FortuneTipNegativeTitle_12", resourceCulture); + } + } + + internal static string FortuneTipNegativeContent_12 { + get { + return ResourceManager.GetString("FortuneTipNegativeContent_12", resourceCulture); + } + } + + internal static string FortuneTipNegativeTitle_13 { + get { + return ResourceManager.GetString("FortuneTipNegativeTitle_13", resourceCulture); + } + } + + internal static string FortuneTipNegativeContent_13 { + get { + return ResourceManager.GetString("FortuneTipNegativeContent_13", resourceCulture); + } + } + + internal static string FortuneTipNegativeTitle_14 { + get { + return ResourceManager.GetString("FortuneTipNegativeTitle_14", resourceCulture); + } + } + + internal static string FortuneTipNegativeContent_14 { + get { + return ResourceManager.GetString("FortuneTipNegativeContent_14", resourceCulture); + } + } + + internal static string FortuneTipNegativeTitle_15 { + get { + return ResourceManager.GetString("FortuneTipNegativeTitle_15", resourceCulture); + } + } + + internal static string FortuneTipPositiveContent_15 { + get { + return ResourceManager.GetString("FortuneTipPositiveContent_15", resourceCulture); + } + } + + internal static string FortuneTipNegativeContent_15 { + get { + return ResourceManager.GetString("FortuneTipNegativeContent_15", resourceCulture); + } + } + + internal static string FortuneTipSpecialTitle_Birthday { + get { + return ResourceManager.GetString("FortuneTipSpecialTitle_Birthday", resourceCulture); + } + } + + internal static string FortuneTipSpecialContent_Birthday { + get { + return ResourceManager.GetString("FortuneTipSpecialContent_Birthday", resourceCulture); } } } diff --git a/DysonNetwork.Pass/Resources/Localization/AccountEventResource.resx b/DysonNetwork.Pass/Resources/Localization/AccountEventResource.resx index c7b95c0..11ff27e 100644 --- a/DysonNetwork.Pass/Resources/Localization/AccountEventResource.resx +++ b/DysonNetwork.Pass/Resources/Localization/AccountEventResource.resx @@ -195,4 +195,10 @@ “?Why is there still something in the box!“ + + Have a Birthday Party + + + Happy Birthday, {}! + diff --git a/DysonNetwork.Pass/Resources/Localization/AccountEventResource.zh-hans.resx b/DysonNetwork.Pass/Resources/Localization/AccountEventResource.zh-hans.resx index 0601cc3..22d7c78 100644 --- a/DysonNetwork.Pass/Resources/Localization/AccountEventResource.zh-hans.resx +++ b/DysonNetwork.Pass/Resources/Localization/AccountEventResource.zh-hans.resx @@ -248,4 +248,10 @@ “?暗盒里怎么还有!“ + + 过生日 + + + 生日快乐,{}! + diff --git a/DysonNetwork.sln.DotSettings.user b/DysonNetwork.sln.DotSettings.user index 8debb0d..881c65f 100644 --- a/DysonNetwork.sln.DotSettings.user +++ b/DysonNetwork.sln.DotSettings.user @@ -173,7 +173,7 @@ <SessionState ContinuousTestingMode="0" Name="All tests from Solution" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session"> <Solution /> </SessionState> - False + True True