student пре 3 недеља
родитељ
комит
e41447d973

+ 13 - 12
Kitty_Fall/Kitty_Fall/Kitty_Fall.Apis/Business/Game/GameBusinessImpl.cs

@@ -129,7 +129,8 @@ namespace Kitty_Fall.Apis.Business.Game
                     var rewardUnit = rewardLog?.RewardUnit ?? attempt.RewardUnit ?? "";
                     if (string.IsNullOrWhiteSpace(rewardType) && attempt.AwardedScore > 0)
                     {
-                        // Level thuong khong co reward option van phai hien thi diem base da cong.
+                        // Level thuong khong random reward option van phai hien thi
+                        // SCORE game da duoc server cong khi pass level.
                         rewardType = "SCORE";
                         rewardValue = attempt.AwardedScore;
                         rewardUnit = "POINT";
@@ -306,6 +307,7 @@ namespace Kitty_Fall.Apis.Business.Game
                             msisdn = msisdn,
                             picture = account.Picture ?? "",
                             totalTurn = totalTurn,
+                            // Point hien thi trong game chinh la SCORE dung cho xep hang.
                             totalPoint = currentScore.Value
                         },
                         items = items,
@@ -754,16 +756,16 @@ namespace Kitty_Fall.Apis.Business.Game
                 }
 
                 var clientScore = ClampScore(request.score, MaxAttemptScore);
-                var awardedScore = clientScore > session.TotalScore
-                    ? clientScore - session.TotalScore
-                    : clientScore;
-                if (awardedScore <= 0) awardedScore = levelConfig.BaseScore;
-                awardedScore = Math.Min(awardedScore, MaxAttemptScore);
+                // Score game do server cap theo BASE_SCORE cau hinh; clientScore chi
+                // luu de doi soat, khong dung lam so diem cong vao ranking.
+                long awardedScore = Math.Max(0, levelConfig.BaseScore);
 
                 GameLevelRewardOption? rewardOption = null;
                 if (levelConfig.IsMilestone == true)
                 {
-                    // Chi level duoc danh dau IS_MILESTONE moi random 1 trong cac option thuong.
+                    // Level moc (5/10/15/...) chi nhan dung 1 trong 3 loai thuong
+                    // DATA/LOYALTY/SCORE. Khong cong them score client tai level moc.
+                    awardedScore = 0;
                     var rewardOptions = await dbContext.GameLevelRewardOptions.AsNoTracking()
                         .Where(x => x.ModeId == mode.ModeId && x.LevelNo == levelNo.Value && x.Status != false)
                         .OrderByDescending(x => x.IsDefault == true)
@@ -848,7 +850,6 @@ namespace Kitty_Fall.Apis.Business.Game
                         rewardScoreDelta = (long)rewardOption.RewardValue;
                         session.TotalRewardScore += rewardScoreDelta;
                         session.TotalScore = ClampScore(session.TotalScore + rewardScoreDelta, MaxTotalScore);
-                        responsePoint = FormatPrizeValue(rewardOption.RewardValue);
 
                         dbContext.GameScoreLedgers.Add(new GameScoreLedger
                         {
@@ -875,8 +876,8 @@ namespace Kitty_Fall.Apis.Business.Game
                     }
                     else if (string.Equals(rewardOption.RewardType, "LOYALTY", StringComparison.OrdinalIgnoreCase))
                     {
-                        session.TotalLoyalty += rewardOption.RewardValue;
-                        responsePoint = FormatPrizeValue(rewardOption.RewardValue);
+                        // LOYALTY la point cua he thong ngoai game. Chi tao reward log
+                        // de worker cong ben ngoai va luu lich su, khong cong vao score/ranking.
                     }
 
                     var waitWorkerPayout = string.Equals(rewardOption.RewardType, "DATA", StringComparison.OrdinalIgnoreCase)
@@ -1252,8 +1253,8 @@ namespace Kitty_Fall.Apis.Business.Game
             return (rewardType ?? "").ToUpperInvariant() switch
             {
                 "DATA" => string.IsNullOrWhiteSpace(rewardUnit) ? "MB 5G" : $"{rewardUnit} 5G",
-                "LOYALTY" => "Points",
-                "SCORE" => "Scores",
+                "LOYALTY" => "LOYALTY",
+                "SCORE" => "SCORE",
                 "MONEY" => string.IsNullOrWhiteSpace(rewardUnit) ? "MMK" : rewardUnit,
                 _ => rewardUnit ?? ""
             };

+ 2 - 0
Kitty_Fall/Kitty_Fall/Kitty_Fall.Apis/Business/User/UserBusinessImpl.cs

@@ -341,6 +341,8 @@ namespace Kitty_Fall.Apis.Business.User
                     .Where(x => x.Msisdn == msisdn)
                     .SumAsync(x => (int?)((x.Added ?? 0) - (x.Used ?? 0))) ?? 0;
                 totalTurn = Math.Max(0, totalTurn);
+                // Point hien thi trong website la SCORE game cua thang hien tai.
+                // LOYALTY la thuong ben he thong ngoai, chi luu trong GAME_REWARD_LOG.
                 var totalPoint = await dbContext.GameMonthlyRankings.AsNoTracking()
                     .Where(x => x.Msisdn == msisdn && x.MonthKey == monthKey)
                     .Select(x => (long?)x.TotalScore)

+ 2 - 2
Kitty_Fall/Kitty_Fall/Kitty_Fall.Website/Views/Play/Index.cshtml

@@ -125,8 +125,8 @@
                     <strong data-game-over-data>0</strong>
                 </div>
                 <div>
-                    <span>@Lang.Points</span>
-                    <strong data-game-over-point>0</strong>
+                    <span>LOYALTY</span>
+                    <strong data-game-over-loyalty>0</strong>
                 </div>
             </div>
             <a class="game-over-play-button" href="@Url.Action("Index", "Play")">

+ 5 - 5
Kitty_Fall/Kitty_Fall/Kitty_Fall.Website/wwwroot/kitty/js/all.min.js

@@ -259,7 +259,7 @@ const initKittyFall = () => {
         const gameOverClose = playGameRoot.querySelector("[data-game-over-close]");
         const gameOverScore = playGameRoot.querySelector("[data-game-over-score]");
         const gameOverData = playGameRoot.querySelector("[data-game-over-data]");
-        const gameOverPoint = playGameRoot.querySelector("[data-game-over-point]");
+        const gameOverLoyalty = playGameRoot.querySelector("[data-game-over-loyalty]");
         let selectedLevel = playGameRoot.querySelector("[data-level].is-selected")?.dataset.level
             || levelButtons[0]?.dataset.level
             || "Easy";
@@ -283,7 +283,7 @@ const initKittyFall = () => {
         let runRewards = {
             score: 0,
             data: 0,
-            point: 0
+            loyalty: 0
         };
 
         const setSelectedLevel = (button) => {
@@ -299,7 +299,7 @@ const initKittyFall = () => {
             runRewards = {
                 score: 0,
                 data: 0,
-                point: 0
+                loyalty: 0
             };
         };
 
@@ -317,7 +317,7 @@ const initKittyFall = () => {
 
             runRewards.score = Math.max(runRewards.score, toNumber(data?.score));
             if (rewardType === "DATA") runRewards.data += rewardValue;
-            if (rewardType === "LOYALTY" || rewardType === "SCORE") runRewards.point += rewardValue;
+            if (rewardType === "LOYALTY") runRewards.loyalty += rewardValue;
         };
 
         const closeEmbeddedGame = () => {
@@ -330,7 +330,7 @@ const initKittyFall = () => {
         const showGameOverSummary = () => {
             if (gameOverScore) gameOverScore.textContent = formatNumber(runRewards.score);
             if (gameOverData) gameOverData.textContent = `${formatNumber(runRewards.data)} MB`;
-            if (gameOverPoint) gameOverPoint.textContent = formatNumber(runRewards.point);
+            if (gameOverLoyalty) gameOverLoyalty.textContent = formatNumber(runRewards.loyalty);
             gameOverModal?.classList.add("is-open");
             gameOverModal?.setAttribute("aria-hidden", "false");
         };

+ 5 - 5
Kitty_Fall/Kitty_Fall/Kitty_Fall.Website/wwwroot/kitty/js/input.js

@@ -259,7 +259,7 @@ const initKittyFall = () => {
         const gameOverClose = playGameRoot.querySelector("[data-game-over-close]");
         const gameOverScore = playGameRoot.querySelector("[data-game-over-score]");
         const gameOverData = playGameRoot.querySelector("[data-game-over-data]");
-        const gameOverPoint = playGameRoot.querySelector("[data-game-over-point]");
+        const gameOverLoyalty = playGameRoot.querySelector("[data-game-over-loyalty]");
         let selectedLevel = playGameRoot.querySelector("[data-level].is-selected")?.dataset.level
             || levelButtons[0]?.dataset.level
             || "Easy";
@@ -283,7 +283,7 @@ const initKittyFall = () => {
         let runRewards = {
             score: 0,
             data: 0,
-            point: 0
+            loyalty: 0
         };
 
         const setSelectedLevel = (button) => {
@@ -299,7 +299,7 @@ const initKittyFall = () => {
             runRewards = {
                 score: 0,
                 data: 0,
-                point: 0
+                loyalty: 0
             };
         };
 
@@ -317,7 +317,7 @@ const initKittyFall = () => {
 
             runRewards.score = Math.max(runRewards.score, toNumber(data?.score));
             if (rewardType === "DATA") runRewards.data += rewardValue;
-            if (rewardType === "LOYALTY" || rewardType === "SCORE") runRewards.point += rewardValue;
+            if (rewardType === "LOYALTY") runRewards.loyalty += rewardValue;
         };
 
         const closeEmbeddedGame = () => {
@@ -330,7 +330,7 @@ const initKittyFall = () => {
         const showGameOverSummary = () => {
             if (gameOverScore) gameOverScore.textContent = formatNumber(runRewards.score);
             if (gameOverData) gameOverData.textContent = `${formatNumber(runRewards.data)} MB`;
-            if (gameOverPoint) gameOverPoint.textContent = formatNumber(runRewards.point);
+            if (gameOverLoyalty) gameOverLoyalty.textContent = formatNumber(runRewards.loyalty);
             gameOverModal?.classList.add("is-open");
             gameOverModal?.setAttribute("aria-hidden", "false");
         };