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