feat: rename tank types to tank classes

This commit is contained in:
TrèsAbhi committed 2024-03-07 18:30:02 -06:00
1 parent 3325536bbc
commit 53174db351
18 files changed
+53 -64

No files matched your search

+2 -2
View File
@@ -2,7 +2,7 @@ import { readdir } from 'fs/promises';
import { parse as parsePath } from 'path'; import { parse as parsePath } from 'path';
import { Vector3Tuple } from 'three'; import { Vector3Tuple } from 'three';
import { parse as parseYaml } from 'yaml'; import { parse as parseYaml } from 'yaml';
import { TankType } from '../../src/components/Tanks'; import { TankClass } from '../../src/components/Tanks';
import { readXMLDVPL } from '../../src/core/blitz/readXMLDVPL'; import { readXMLDVPL } from '../../src/core/blitz/readXMLDVPL';
import { readYAMLDVPL } from '../../src/core/blitz/readYAMLDVPL'; import { readYAMLDVPL } from '../../src/core/blitz/readYAMLDVPL';
import { toUniqueId } from '../../src/core/blitz/toUniqueId'; import { toUniqueId } from '../../src/core/blitz/toUniqueId';
@@ -488,7 +488,7 @@ export async function definitions(production: boolean) {
? 'premium' ? 'premium'
: 'researchable', : 'researchable',
tier: tank.level as Tier, tier: tank.level as Tier,
type: tankTags[0] as TankType, class: tankTags[0] as TankClass,
testing: tankTags.includes('testTank') ? true : undefined, testing: tankTags.includes('testTank') ? true : undefined,
price: tankPrice, price: tankPrice,
camouflage: { camouflage: {
+1 -1
View File
@@ -311,7 +311,7 @@ export default function SessionPage({ naked = true }: SessionPageProps) {
tankDefinitions?.name ?? `Unknown tank ${stats.tank_id}` tankDefinitions?.name ?? `Unknown tank ${stats.tank_id}`
} }
type="tank" type="tank"
tankType={tankDefinitions?.type} tankType={tankDefinitions?.class}
treeType={tankDefinitions?.treeType} treeType={tankDefinitions?.treeType}
stats={session.customColumns.map((customColumn) => { stats={session.customColumns.map((customColumn) => {
const rowStat = rowStats[customColumn.display]; const rowStat = rowStats[customColumn.display];
@@ -136,12 +136,13 @@ export function Characteristics() {
]); ]);
const enginePowerCoefficient = coefficient( const enginePowerCoefficient = coefficient(
[ [
hasEngineAccelerator && (tank.type === 'lightTank' || tank.type === 'mediumTank'), hasEngineAccelerator &&
(tank.class === 'lightTank' || tank.class === 'mediumTank'),
0.05, 0.05,
], ],
[ [
hasEngineAccelerator && hasEngineAccelerator &&
(tank.type === 'heavyTank' || tank.type === 'AT-SPG'), (tank.class === 'heavyTank' || tank.class === 'AT-SPG'),
0.07, 0.07,
], ],
[hasEnginePowerBoost, 0.2], [hasEnginePowerBoost, 0.2],
@@ -163,7 +164,7 @@ export function Characteristics() {
const viewRangeCoefficient = const viewRangeCoefficient =
coefficient([ coefficient([
hasImprovedOptics, hasImprovedOptics,
tank.type === 'AT-SPG' ? 0.05 : tank.type === 'heavyTank' ? 0.07 : 0.1, tank.class === 'AT-SPG' ? 0.05 : tank.class === 'heavyTank' ? 0.07 : 0.1,
]) * coefficient([true, progressiveStat(commanderMastery)]); ]) * coefficient([true, progressiveStat(commanderMastery)]);
const fireChanceCoefficient = coefficient([hasProtectiveKit, -0.2]); const fireChanceCoefficient = coefficient([hasProtectiveKit, -0.2]);
@@ -180,38 +181,26 @@ export function Characteristics() {
const camouflageSumMoving = sum( const camouflageSumMoving = sum(
[ [
hasCamouflageNet, hasCamouflageNet,
tank.type === 'heavyTank' tank.class === 'heavyTank' ? 0.03 : tank.class === 'AT-SPG' ? 0.07 : 0.05,
? 0.03
: tank.type === 'AT-SPG'
? 0.07
: 0.05,
], ],
[ [
camouflage, camouflage,
tank.type === 'AT-SPG' tank.class === 'AT-SPG' ? 0.04 : tank.class === 'heavyTank' ? 0.03 : 0.02,
? 0.04
: tank.type === 'heavyTank'
? 0.03
: 0.02,
], ],
); );
const camouflageSumStill = sum( const camouflageSumStill = sum(
[ [
hasCamouflageNet, hasCamouflageNet,
2 * 2 *
(tank.type === 'heavyTank' (tank.class === 'heavyTank'
? 0.03 ? 0.03
: tank.type === 'AT-SPG' : tank.class === 'AT-SPG'
? 0.07 ? 0.07
: 0.05), : 0.05),
], ],
[ [
camouflage, camouflage,
tank.type === 'AT-SPG' tank.class === 'AT-SPG' ? 0.04 : tank.class === 'heavyTank' ? 0.03 : 0.02,
? 0.04
: tank.type === 'heavyTank'
? 0.03
: 0.02,
], ],
); );
@@ -30,7 +30,7 @@ export function Title() {
<img <img
src={ src={
TREE_TYPE_ICONS[protagonist.tank.treeType][ TREE_TYPE_ICONS[protagonist.tank.treeType][
protagonist.tank.type protagonist.tank.class
] ]
} }
style={{ style={{
@@ -5,7 +5,7 @@ import { Button, DropdownMenu, Flex } from '@radix-ui/themes';
import { use } from 'react'; import { use } from 'react';
import { Flag } from '../../../../../../../components/Flag'; import { Flag } from '../../../../../../../components/Flag';
import { import {
TANK_TYPES, TANK_CLASSES,
TREE_TYPES, TREE_TYPES,
TREE_TYPE_ICONS, TREE_TYPE_ICONS,
TREE_TYPE_IMAGES, TREE_TYPE_IMAGES,
@@ -121,7 +121,7 @@ export function Options() {
))} ))}
</Flex> </Flex>
<Flex> <Flex>
{[...TANK_TYPES].map((type, index) => ( {[...TANK_CLASSES].map((type, index) => (
<Button <Button
key={type} key={type}
color={filters.types.includes(type) ? undefined : 'gray'} color={filters.types.includes(type) ? undefined : 'gray'}
@@ -132,9 +132,9 @@ export function Options() {
borderTopLeftRadius: index === 0 ? undefined : 0, borderTopLeftRadius: index === 0 ? undefined : 0,
borderBottomLeftRadius: index === 0 ? undefined : 0, borderBottomLeftRadius: index === 0 ? undefined : 0,
borderTopRightRadius: borderTopRightRadius:
index === TANK_TYPES.length - 1 ? undefined : 0, index === TANK_CLASSES.length - 1 ? undefined : 0,
borderBottomRightRadius: borderBottomRightRadius:
index === TANK_TYPES.length - 1 ? undefined : 0, index === TANK_CLASSES.length - 1 ? undefined : 0,
}} }}
onClick={() => onClick={() =>
mutateTankopediaPersistent((draft) => { mutateTankopediaPersistent((draft) => {
@@ -15,7 +15,7 @@ import {
} from '@radix-ui/themes'; } from '@radix-ui/themes';
import { go } from 'fuzzysort'; import { go } from 'fuzzysort';
import { use, useEffect, useMemo, useRef, useState } from 'react'; import { use, useEffect, useMemo, useRef, useState } from 'react';
import { TANK_TYPES, TreeType } from '../../../../../components/Tanks'; import { TANK_CLASSES, TreeType } from '../../../../../components/Tanks';
import { resolveNearPenetration } from '../../../../../core/blitz/resolveNearPenetration'; import { resolveNearPenetration } from '../../../../../core/blitz/resolveNearPenetration';
import { asset } from '../../../../../core/blitzkrieg/asset'; import { asset } from '../../../../../core/blitzkrieg/asset';
import { modelDefinitions } from '../../../../../core/blitzkrieg/modelDefinitions'; import { modelDefinitions } from '../../../../../core/blitzkrieg/modelDefinitions';
@@ -69,7 +69,7 @@ export function TankSearch({ compact, onSelect = () => {} }: TankSearchProps) {
) )
.sort( .sort(
(a, b) => (a, b) =>
(TANK_TYPES.indexOf(a.type) - TANK_TYPES.indexOf(b.type)) * (TANK_CLASSES.indexOf(a.class) - TANK_CLASSES.indexOf(b.class)) *
(sort.direction === 'descending' ? -1 : 1), (sort.direction === 'descending' ? -1 : 1),
) )
.sort( .sort(
@@ -88,7 +88,7 @@ export function TankSearch({ compact, onSelect = () => {} }: TankSearchProps) {
: filters.tiers.includes(tank.tier)) && : filters.tiers.includes(tank.tier)) &&
(filters.types.length === 0 (filters.types.length === 0
? true ? true
: filters.types.includes(tank.type)) && : filters.types.includes(tank.class)) &&
(filters.treeTypes.length === 0 (filters.treeTypes.length === 0
? true ? true
: filters.treeTypes.includes(tank.treeType)) && : filters.treeTypes.includes(tank.treeType)) &&
@@ -843,7 +843,7 @@ export function TankSearch({ compact, onSelect = () => {} }: TankSearchProps) {
? TANK_ICONS_COLLECTOR ? TANK_ICONS_COLLECTOR
: tank.treeType === 'premium' : tank.treeType === 'premium'
? TANK_ICONS_PREMIUM ? TANK_ICONS_PREMIUM
: TANK_ICONS)[tank.type] : TANK_ICONS)[tank.class]
} }
style={{ width: '1em', height: '1em' }} style={{ width: '1em', height: '1em' }}
/> />
+1 -1
View File
@@ -199,7 +199,7 @@ export async function renderBreakdown(
<Breakdown.Row <Breakdown.Row
key={id} key={id}
type="tank" type="tank"
tankType={tankDefinition?.type} tankType={tankDefinition?.class}
treeType={tankDefinition?.treeType} treeType={tankDefinition?.treeType}
title={ title={
tankDefinition?.name ?? tankDefinition?.name ??
+2 -2
View File
@@ -98,7 +98,7 @@ export const ownedTanksCommand = new Promise<CommandRegistry>((resolve) => {
<Tanks.Item <Tanks.Item
key={tank.id} key={tank.id}
name={tank.name} name={tank.name}
tankType={tank.type} tankType={tank.class}
image={tankIcon(tank.id)} image={tankIcon(tank.id)}
treeType={tank.treeType} treeType={tank.treeType}
/> />
@@ -111,7 +111,7 @@ export const ownedTanksCommand = new Promise<CommandRegistry>((resolve) => {
<Tanks.Item <Tanks.Item
key={tank.id} key={tank.id}
name={tank.name} name={tank.name}
tankType={tank.type} tankType={tank.class}
image={tankIcon(tank.id)} image={tankIcon(tank.id)}
treeType={tank.treeType} treeType={tank.treeType}
/> />
+2 -2
View File
@@ -5,7 +5,7 @@ import {
GrayColor, GrayColor,
PALETTES, PALETTES,
} from '../../../constants/radixColors'; } from '../../../constants/radixColors';
import { TREE_TYPE_ICONS, TankType, TreeType } from '../../Tanks'; import { TREE_TYPE_ICONS, TankClass, TreeType } from '../../Tanks';
import { RowStat } from './RowStat'; import { RowStat } from './RowStat';
export interface RowStatItem { export interface RowStatItem {
@@ -22,7 +22,7 @@ interface RowProps {
title: string; title: string;
minimized?: boolean; minimized?: boolean;
treeType?: TreeType; treeType?: TreeType;
tankType?: TankType; tankType?: TankClass;
color?: AccentColor | GrayColor; color?: AccentColor | GrayColor;
stats: (RowStatItem | undefined)[]; stats: (RowStatItem | undefined)[];
} }
+4 -4
View File
@@ -5,7 +5,7 @@ import {
} from '../../../core/blitzkrieg/tankDefinitions'; } from '../../../core/blitzkrieg/tankDefinitions';
import { theme } from '../../../stitches.config'; import { theme } from '../../../stitches.config';
export const TANK_TYPES = [ export const TANK_CLASSES = [
'lightTank', 'lightTank',
'mediumTank', 'mediumTank',
'heavyTank', 'heavyTank',
@@ -14,7 +14,7 @@ export const TANK_TYPES = [
export const TREE_TYPES = ['researchable', 'premium', 'collector'] as const; export const TREE_TYPES = ['researchable', 'premium', 'collector'] as const;
export type TankType = (typeof TANK_TYPES)[number]; export type TankClass = (typeof TANK_CLASSES)[number];
export type TreeType = (typeof TREE_TYPES)[number]; export type TreeType = (typeof TREE_TYPES)[number];
// BIG TODO: REMOVE THIS AFTER LOCALIZATION // BIG TODO: REMOVE THIS AFTER LOCALIZATION
@@ -32,7 +32,7 @@ export const TREE_TYPE_IMAGES: Record<TreeType, string> = {
export interface ItemProps { export interface ItemProps {
image?: string; image?: string;
tankType?: TankType; tankType?: TankClass;
name: string; name: string;
treeType: TreeType; treeType: TreeType;
} }
@@ -43,7 +43,7 @@ const TREE_TYPE_COLOR = {
collector: '_blue', collector: '_blue',
} as const; } as const;
export const TREE_TYPE_ICONS: Record<TreeType, Record<TankType, string>> = { export const TREE_TYPE_ICONS: Record<TreeType, Record<TankClass, string>> = {
researchable: TANK_ICONS, researchable: TANK_ICONS,
premium: TANK_ICONS_PREMIUM, premium: TANK_ICONS_PREMIUM,
collector: TANK_ICONS_COLLECTOR, collector: TANK_ICONS_COLLECTOR,
+1 -1
View File
@@ -19,7 +19,7 @@ export async function filtersToDescription(
translate('bot.common.filters.tier', [TIER_ROMAN_NUMERALS[tier as Tier]]), translate('bot.common.filters.tier', [TIER_ROMAN_NUMERALS[tier as Tier]]),
); );
} }
if (tankType) info.push(translate(`common.tank_type_short.${tankType}`)); if (tankType) info.push(translate(`common.tank_class_short.${tankType}`));
if (treeType) info.push(translate(`common.tree_type.${treeType}`)); if (treeType) info.push(translate(`common.tree_type.${treeType}`));
return info.length === 0 return info.length === 0
+5 -5
View File
@@ -1,6 +1,6 @@
import { deburr } from 'lodash'; import { deburr } from 'lodash';
import { Vector2Tuple } from 'three'; import { Vector2Tuple } from 'three';
import { TankType, TreeType } from '../../components/Tanks'; import { TankClass, TreeType } from '../../components/Tanks';
import { asset } from './asset'; import { asset } from './asset';
import { fetchCdonLz4 } from './fetchCdonLz4'; import { fetchCdonLz4 } from './fetchCdonLz4';
@@ -44,7 +44,7 @@ export interface TankDefinition {
consumables: number; consumables: number;
provisions: number; provisions: number;
tier: Tier; tier: Tier;
type: TankType; class: TankClass;
testing?: boolean; testing?: boolean;
turrets: TurretDefinition[]; turrets: TurretDefinition[];
engines: EngineDefinition[]; engines: EngineDefinition[];
@@ -180,21 +180,21 @@ export const tankNames = tanksDefinitionsArray.then((tanks) =>
), ),
); );
export const TANK_ICONS: Record<TankType, string> = { export const TANK_ICONS: Record<TankClass, string> = {
'AT-SPG': 'https://i.imgur.com/BIHSEH0.png', 'AT-SPG': 'https://i.imgur.com/BIHSEH0.png',
lightTank: 'https://i.imgur.com/CSNha5V.png', lightTank: 'https://i.imgur.com/CSNha5V.png',
mediumTank: 'https://i.imgur.com/wvf3ltm.png', mediumTank: 'https://i.imgur.com/wvf3ltm.png',
heavyTank: 'https://i.imgur.com/ECeqlZa.png', heavyTank: 'https://i.imgur.com/ECeqlZa.png',
}; };
export const TANK_ICONS_PREMIUM: Record<TankType, string> = { export const TANK_ICONS_PREMIUM: Record<TankClass, string> = {
'AT-SPG': 'https://i.imgur.com/TCu3EdR.png', 'AT-SPG': 'https://i.imgur.com/TCu3EdR.png',
lightTank: 'https://i.imgur.com/zdkpTRb.png', lightTank: 'https://i.imgur.com/zdkpTRb.png',
mediumTank: 'https://i.imgur.com/3z7eHX6.png', mediumTank: 'https://i.imgur.com/3z7eHX6.png',
heavyTank: 'https://i.imgur.com/P3vbmyA.png', heavyTank: 'https://i.imgur.com/P3vbmyA.png',
}; };
export const TANK_ICONS_COLLECTOR: Record<TankType, string> = { export const TANK_ICONS_COLLECTOR: Record<TankClass, string> = {
'AT-SPG': 'https://i.imgur.com/WTjeirB.png', 'AT-SPG': 'https://i.imgur.com/WTjeirB.png',
lightTank: 'https://i.imgur.com/EwhtKkU.png', lightTank: 'https://i.imgur.com/EwhtKkU.png',
mediumTank: 'https://i.imgur.com/u8YDMBh.png', mediumTank: 'https://i.imgur.com/u8YDMBh.png',
+8 -8
View File
@@ -4,7 +4,7 @@ import {
SlashCommandBuilder, SlashCommandBuilder,
SlashCommandSubcommandBuilder, SlashCommandSubcommandBuilder,
} from 'discord.js'; } from 'discord.js';
import { TANK_TYPES, TREE_TYPES } from '../../components/Tanks'; import { TANK_CLASSES, TREE_TYPES } from '../../components/Tanks';
import { translator } from '../localization/translator'; import { translator } from '../localization/translator';
import addTankChoices from './addTankChoices'; import addTankChoices from './addTankChoices';
import addTierChoices from './addTierChoices'; import addTierChoices from './addTierChoices';
@@ -46,26 +46,26 @@ export function addFilterOptions<
.addStringOption((option) => addTierChoices(option).setRequired(false)) .addStringOption((option) => addTierChoices(option).setRequired(false))
.addStringOption((option) => .addStringOption((option) =>
option option
.setName(translate('bot.common.options.filters.tank_type')) .setName(translate('bot.common.options.filters.tank_class'))
.setNameLocalizations( .setNameLocalizations(
localizationObject('bot.common.options.filters.tank_type'), localizationObject('bot.common.options.filters.tank_class'),
) )
.setDescription( .setDescription(
translate('bot.common.options.filters.tank_type.description'), translate('bot.common.options.filters.tank_class.description'),
) )
.setDescriptionLocalizations( .setDescriptionLocalizations(
localizationObject( localizationObject(
'bot.common.options.filters.tank_type.description', 'bot.common.options.filters.tank_class.description',
), ),
) )
.addChoices( .addChoices(
...TANK_TYPES.map( ...TANK_CLASSES.map(
(tankType) => (tankType) =>
({ ({
value: tankType, value: tankType,
name: translate(`common.tank_type_short.${tankType}`), name: translate(`common.tank_class_short.${tankType}`),
name_localizations: localizationObject( name_localizations: localizationObject(
`common.tank_type_short.${tankType}`, `common.tank_class_short.${tankType}`,
), ),
}) satisfies APIApplicationCommandOptionChoice, }) satisfies APIApplicationCommandOptionChoice,
), ),
+1 -1
View File
@@ -8,7 +8,7 @@ export function getFiltersFromButton(interaction: ButtonInteraction) {
return { return {
nation: url.searchParams.get('nation') ?? undefined, nation: url.searchParams.get('nation') ?? undefined,
tank: parseInt(url.searchParams.get('tank') ?? '0') || undefined, tank: parseInt(url.searchParams.get('tank') ?? '0') || undefined,
tankType: url.searchParams.get('tank-type') ?? undefined, tankType: url.searchParams.get('tank-class') ?? undefined,
treeType: treeType:
(url.searchParams.get('tree-type') as TreeType | undefined) ?? undefined, (url.searchParams.get('tree-type') as TreeType | undefined) ?? undefined,
tier: parseInt(url.searchParams.get('tier') ?? '0') || undefined, tier: parseInt(url.searchParams.get('tier') ?? '0') || undefined,
+1 -1
View File
@@ -11,7 +11,7 @@ export async function getFiltersFromCommand(
return { return {
nation: interaction.options.getString('nation') ?? undefined, nation: interaction.options.getString('nation') ?? undefined,
tier: parseInt(interaction.options.getString('tier') ?? '0') || undefined, tier: parseInt(interaction.options.getString('tier') ?? '0') || undefined,
tankType: interaction.options.getString('tank-type') ?? undefined, tankType: interaction.options.getString('tank-class') ?? undefined,
treeType: treeType:
(interaction.options.getString('tree-type') as TreeType | undefined) ?? (interaction.options.getString('tree-type') as TreeType | undefined) ??
undefined, undefined,
+1 -1
View File
@@ -29,7 +29,7 @@ export async function filterStats(
entry && entry &&
(filters.nation === undefined || entry.nation === filters.nation) && (filters.nation === undefined || entry.nation === filters.nation) &&
(filters.tier === undefined || entry.tier === filters.tier) && (filters.tier === undefined || entry.tier === filters.tier) &&
(filters.tankType === undefined || entry.type === filters.tankType) && (filters.tankType === undefined || entry.class === filters.tankType) &&
(filters.treeType === undefined || (filters.treeType === undefined ||
(filters.treeType === 'collector' && entry.treeType === 'collector') || (filters.treeType === 'collector' && entry.treeType === 'collector') ||
(filters.treeType === 'premium' && entry.treeType === 'premium') || (filters.treeType === 'premium' && entry.treeType === 'premium') ||
+4 -4
View File
@@ -12,7 +12,7 @@
"other": "Hybrid nation" "other": "Hybrid nation"
}, },
"tank_type_short": { "tank_class_short": {
"lightTank": "Light", "lightTank": "Light",
"mediumTank": "Medium", "mediumTank": "Medium",
"heavyTank": "Heavy", "heavyTank": "Heavy",
@@ -122,9 +122,9 @@
"$": "nation", "$": "nation",
"description": "Nation" "description": "Nation"
}, },
"tank_type": { "tank_class": {
"$": "tank-type", "$": "tank-class",
"description": "Tank type" "description": "Tank class"
}, },
"tree_type": { "tree_type": {
"$": "tree-type", "$": "tree-type",
+2 -2
View File
@@ -5,7 +5,7 @@ import { create } from 'zustand';
import { persist, subscribeWithSelector } from 'zustand/middleware'; import { persist, subscribeWithSelector } from 'zustand/middleware';
import { ENVIRONMENTS } from '../app/tools/tankopedia/[id]/components/Lighting'; import { ENVIRONMENTS } from '../app/tools/tankopedia/[id]/components/Lighting';
import { ArmorType } from '../components/Armor/components/SpacedArmorScene'; import { ArmorType } from '../components/Armor/components/SpacedArmorScene';
import { TankType, TreeType } from '../components/Tanks'; import { TankClass, TreeType } from '../components/Tanks';
import { Tier } from '../core/blitzkrieg/tankDefinitions'; import { Tier } from '../core/blitzkrieg/tankDefinitions';
export type TankopediaSortBy = keyof typeof SORT_NAMES; export type TankopediaSortBy = keyof typeof SORT_NAMES;
@@ -31,7 +31,7 @@ export interface TankopediaPersistent {
}; };
filters: { filters: {
tiers: Tier[]; tiers: Tier[];
types: TankType[]; types: TankClass[];
treeTypes: TreeType[]; treeTypes: TreeType[];
nations: string[]; nations: string[];
test: TankopediaTestTankDisplay; test: TankopediaTestTankDisplay;