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