From ce715cd6b04749a3a04157f2c9a13254acdc6a64 Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Tue, 11 Nov 2025 01:03:26 +0800 Subject: [PATCH] :necktie: Check in algo v3 --- .../Account/AccountEventService.cs | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/DysonNetwork.Pass/Account/AccountEventService.cs b/DysonNetwork.Pass/Account/AccountEventService.cs index 7dda20a..ffe9f7f 100644 --- a/DysonNetwork.Pass/Account/AccountEventService.cs +++ b/DysonNetwork.Pass/Account/AccountEventService.cs @@ -137,7 +137,7 @@ public class AccountEventService( } } - if (cacheMissUserIds.Count != 0) + if (cacheMissUserIds.Count == 0) return results; { var now = SystemClock.Instance.GetCurrentInstant(); var statusesFromDb = await db.AccountStatuses @@ -160,7 +160,7 @@ public class AccountEventService( } var usersWithoutStatus = cacheMissUserIds.Except(foundUserIds).ToList(); - if (usersWithoutStatus.Any()) + if (usersWithoutStatus.Count == 0) return results; { foreach (var userId in usersWithoutStatus) { @@ -339,11 +339,17 @@ public class AccountEventService( })); // The 5 is specialized, keep it alone. - var sum = 0; - var maxLevel = Enum.GetValues().Length - 1; - for (var i = 0; i < 5; i++) - sum += Random.Next(maxLevel); - var checkInLevel = (CheckInResultLevel)(sum / 5); + // 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)