From 6502b173567eed80610a93dff36ad14d0dc43aa0 Mon Sep 17 00:00:00 2001 From: "soroush.asadi" Date: Mon, 15 Jun 2026 11:28:08 +0330 Subject: [PATCH] balance(achievements): strictly-escalating milestone coin rewards MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The old reward formula rounded (40+6g)/50 on the raw goal, so adjacent milestones could pay the same (e.g. "1 win" and "5 wins" both 50) and the curve was lumpy — not a standard escalating-reward ladder. Reward now scales by tier index: 50, 150, 250 … capped at 1500, strictly increasing per milestone. Mirrored client (gamification.ts) + server (Gamification.cs) so live grants match. Co-Authored-By: Claude Opus 4.8 --- server/src/Hokm.Server/Profiles/Gamification.cs | 5 +++-- src/lib/online/gamification.ts | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/server/src/Hokm.Server/Profiles/Gamification.cs b/server/src/Hokm.Server/Profiles/Gamification.cs index 20a105e..323e9d3 100644 --- a/server/src/Hokm.Server/Profiles/Gamification.cs +++ b/server/src/Hokm.Server/Profiles/Gamification.cs @@ -56,12 +56,13 @@ public static class Gamification // metric: wins|kotsFor|bestWinStreak|shutoutWins|games|tricks|level ; ratingFloor>0 = rank ach. private record AchDef(string Id, string? Metric, int RatingFloor, int Goal, int Coin, string NameFa, string NameEn, string Icon); // Mirrors src/lib/online/gamification.ts (same ids/goals/coins/metrics). - private static int Coin(int g) => Math.Min(1500, Math.Max(50, (int)Math.Floor((40.0 + g * 6) / 50.0 + 0.5) * 50)); + // Reward escalates strictly per milestone tier (50, 150, 250 … capped 1500). + private static int CoinAt(int i) => Math.Min(1500, 50 + i * 100); private static string Fa(int n) => new string(n.ToString().Select(c => c is >= '0' and <= '9' ? "۰۱۲۳۴۵۶۷۸۹"[c - '0'] : c).ToArray()); private static AchDef[] Tier(string metric, string prefix, string icon, int[] goals, Func faName, Func enName) - => goals.Select(g => new AchDef($"{prefix}_{g}", metric, 0, g, Coin(g), faName(g), enName(g), icon)).ToArray(); + => goals.Select((g, i) => new AchDef($"{prefix}_{g}", metric, 0, g, CoinAt(i), faName(g), enName(g), icon)).ToArray(); private static readonly AchDef[] Achs = BuildAchs(); private static AchDef[] BuildAchs() diff --git a/src/lib/online/gamification.ts b/src/lib/online/gamification.ts index fb237c4..539c411 100644 --- a/src/lib/online/gamification.ts +++ b/src/lib/online/gamification.ts @@ -253,12 +253,13 @@ function tier( faDesc: (g: string) => string, enDesc: (g: number) => string ): AchievementDef[] { - return goals.map((g) => ({ + return goals.map((g, i) => ({ id: `${prefix}_${g}`, category, metric, goal: g, - coinReward: Math.min(1500, Math.max(50, Math.round((40 + g * 6) / 50) * 50)), + // Reward escalates strictly per milestone tier (50, 150, 250 … capped 1500). + coinReward: Math.min(1500, 50 + i * 100), icon, nameFa: faName(faNum(g)), nameEn: enName(g),