|
104 | 104 | if (target <= 0) return 0; |
105 | 105 | return Math.min(100, Math.round((current / target) * 100)); |
106 | 106 | } |
| 107 | +
|
| 108 | + function challengeDesc(metric, target, targetGames, fallback) { |
| 109 | + const g = targetGames ?? 5; |
| 110 | + const keyMap = { |
| 111 | + kills: 'challenges.desc_kills', |
| 112 | + gpm: 'challenges.desc_gpm', |
| 113 | + low_deaths: 'challenges.desc_low_deaths', |
| 114 | + hero_damage: 'challenges.desc_hero_damage', |
| 115 | + cs_at_10: 'challenges.desc_cs_at_10', |
| 116 | + kills_total: 'challenges.desc_kills_total', |
| 117 | + avg_gpm: 'challenges.desc_avg_gpm', |
| 118 | + low_deaths_games: 'challenges.desc_low_deaths_games', |
| 119 | + hero_damage_total: 'challenges.desc_hero_damage_total', |
| 120 | + cs_at_10_avg: 'challenges.desc_cs_at_10_avg', |
| 121 | + }; |
| 122 | + const key = keyMap[metric]; |
| 123 | + if (!key) return fallback; |
| 124 | + return $_( key, { values: { n: target, g } }); |
| 125 | + } |
107 | 126 | </script> |
108 | 127 |
|
109 | 128 | <div class="challenges-content"> |
|
129 | 148 | <div class="difficulty-badge" style="color: {difficultyColor(activeChallenge.challenge_type)}"> |
130 | 149 | {difficultyTKey(activeChallenge.challenge_type) ? $_(difficultyTKey(activeChallenge.challenge_type)) : activeChallenge.challenge_type} |
131 | 150 | </div> |
132 | | - <h2>{activeChallenge.challenge_description}</h2> |
| 151 | + <h2>{challengeDesc(activeChallenge.metric, activeChallenge.challenge_target, activeChallenge.challenge_target_games, activeChallenge.challenge_description)}</h2> |
133 | 152 | {#if activeChallenge.hero_id !== null} |
134 | 153 | <p class="hero-label">{$_('challenges.hero_label', { values: { name: getHeroName(activeChallenge.hero_id) } })}</p> |
135 | 154 | {/if} |
|
204 | 223 | </span> |
205 | 224 | <span class="option-type">{option.metric.replace(/_/g, ' ')}</span> |
206 | 225 | </div> |
207 | | - <p class="option-description">{option.challenge_description}</p> |
| 226 | + <p class="option-description">{challengeDesc(option.metric, option.challenge_target, option.challenge_target_games, option.challenge_description)}</p> |
208 | 227 | {#if option.hero_id !== null} |
209 | 228 | <p class="option-hero">{$_('challenges.hero_label', { values: { name: getHeroName(option.hero_id) } })}</p> |
210 | 229 | {/if} |
|
0 commit comments