mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-21 18:57:03 +02:00
feat: breakdown locale
This commit is contained in:
1 parent
6197642d5e
commit
796aca21cf
4 files changed
+35
-15
No files matched your search
+15
-10
@@ -33,6 +33,7 @@ import resolvePlayerFromButton from '../core/discord/resolvePlayerFromButton';
|
||||
import resolvePlayerFromCommand, {
|
||||
ResolvedPlayer,
|
||||
} from '../core/discord/resolvePlayerFromCommand';
|
||||
import { translator } from '../core/localization/translator';
|
||||
import calculateWN8 from '../core/statistics/calculateWN8';
|
||||
import { StatFilters, filterStats } from '../core/statistics/filterStats';
|
||||
import getWN8Percentile from '../core/statistics/getWN8Percentile';
|
||||
@@ -47,6 +48,7 @@ export async function renderBreakdown(
|
||||
filters: StatFilters,
|
||||
locale: Locale,
|
||||
) {
|
||||
const { t, translate } = translator(locale);
|
||||
const awaitedTankDefinitions = await tankDefinitions;
|
||||
const awaitedTankAverages = await tankAverages;
|
||||
const statsInPeriod = await getStatsInPeriod(region, id, start, end);
|
||||
@@ -146,21 +148,21 @@ export async function renderBreakdown(
|
||||
<Breakdown.Row
|
||||
key={id}
|
||||
type="summary"
|
||||
title="Total"
|
||||
title={t`bot.commands.breakdown.body.total`}
|
||||
stats={[
|
||||
{
|
||||
title: 'Battles',
|
||||
title: t`bot.commands.breakdown.body.battles`,
|
||||
current: currentBattles,
|
||||
career: careerBattles,
|
||||
},
|
||||
{
|
||||
title: 'Winrate',
|
||||
title: t`bot.commands.breakdown.body.winrate`,
|
||||
current: `${(100 * currentWinrate).toFixed(2)}%`,
|
||||
career: `${(100 * careerWinrate).toFixed(2)}%`,
|
||||
delta: currentWinrate - careerWinrate,
|
||||
},
|
||||
{
|
||||
title: 'WN8',
|
||||
title: t`bot.commands.breakdown.body.wn8`,
|
||||
current:
|
||||
currentWN8 === undefined
|
||||
? undefined
|
||||
@@ -175,7 +177,7 @@ export async function renderBreakdown(
|
||||
: getWN8Percentile(currentWN8),
|
||||
},
|
||||
{
|
||||
title: 'Damage',
|
||||
title: t`bot.commands.breakdown.body.damage`,
|
||||
current: Math.round(currentDamage).toLocaleString(),
|
||||
career: Math.round(careerDamage).toLocaleString(),
|
||||
delta: currentDamage - careerDamage,
|
||||
@@ -199,15 +201,18 @@ export async function renderBreakdown(
|
||||
type="tank"
|
||||
tankType={tankDefinition?.type}
|
||||
treeType={tankDefinition?.treeType}
|
||||
title={tankDefinition?.name ?? `Unknown tank ${id}`}
|
||||
title={
|
||||
tankDefinition?.name ??
|
||||
translate('bot.commands.breakdown.body.unknown_tank', [`${id}`])
|
||||
}
|
||||
stats={[
|
||||
{
|
||||
title: 'Battles',
|
||||
title: t`bot.commands.breakdown.body.battles`,
|
||||
current: current.battles.toLocaleString(),
|
||||
career: career.battles.toLocaleString(),
|
||||
},
|
||||
{
|
||||
title: 'Winrate',
|
||||
title: t`bot.commands.breakdown.body.winrate`,
|
||||
current: `${(100 * (current.wins / current.battles)).toFixed(
|
||||
2,
|
||||
)}%`,
|
||||
@@ -216,7 +221,7 @@ export async function renderBreakdown(
|
||||
current.wins / current.battles - career.wins / career.battles,
|
||||
},
|
||||
{
|
||||
title: 'WN8',
|
||||
title: t`bot.commands.breakdown.body.wn8`,
|
||||
current:
|
||||
currentWN8 === undefined
|
||||
? undefined
|
||||
@@ -231,7 +236,7 @@ export async function renderBreakdown(
|
||||
: getWN8Percentile(currentWN8),
|
||||
},
|
||||
{
|
||||
title: 'Damage',
|
||||
title: t`bot.commands.breakdown.body.damage`,
|
||||
current: Math.round(
|
||||
current.damage_dealt / current.battles,
|
||||
).toLocaleString(),
|
||||
|
||||
@@ -1,8 +1,16 @@
|
||||
import { SlashCommandStringOption } from 'discord.js';
|
||||
import { Locale, SlashCommandStringOption } from 'discord.js';
|
||||
import { translator } from '../localization/translator';
|
||||
import { localizationObject } from './localizationObject';
|
||||
|
||||
export default function addUsernameChoices(option: SlashCommandStringOption) {
|
||||
const { t } = translator(Locale.EnglishUS);
|
||||
|
||||
return option
|
||||
.setName('username')
|
||||
.setDescription('The username you use in Blitz')
|
||||
.setName(t`bot.common.options.username`)
|
||||
.setNameLocalizations(localizationObject('bot.common.options.username'))
|
||||
.setDescription(t`bot.common.options.username.description`)
|
||||
.setDescriptionLocalizations(
|
||||
localizationObject('bot.common.options.username.description'),
|
||||
)
|
||||
.setAutocomplete(true);
|
||||
}
|
||||
@@ -9,7 +9,7 @@ export function buttonRefresh(
|
||||
interaction.appPermissions?.has('ReadMessageHistory') &&
|
||||
interaction.appPermissions?.has('ViewChannel')
|
||||
) {
|
||||
return buttonPrimary(path, 'Refresh', '🔄️');
|
||||
return buttonPrimary(path, 'Refresh');
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
+8
-1
@@ -91,6 +91,11 @@
|
||||
"description": "The tank to get stats for"
|
||||
},
|
||||
|
||||
"username": {
|
||||
"$": "username",
|
||||
"description": "The Blitz username of the player"
|
||||
},
|
||||
|
||||
"filters": {
|
||||
"nation": {
|
||||
"$": "nation",
|
||||
@@ -166,8 +171,10 @@
|
||||
"body": {
|
||||
"total": "Total",
|
||||
"battles": "Battles",
|
||||
"wn8": "WN8",
|
||||
"winrate": "Winrate",
|
||||
"damage": "Damage"
|
||||
"damage": "Damage",
|
||||
"unknown_tank": "Unknown tank %s"
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
Reference in new issue
Block a user