mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-21 10:47:04 +02:00
fix: some linting for new proto 2
This commit is contained in:
1 parent
94f67e30f1
commit
79bc259565
22 files changed
+183
-163
No files matched your search
@@ -1,6 +0,0 @@
|
||||
import { blitzStarsTankAverages } from '@blitzkit/core';
|
||||
import { NextResponse } from 'next/server';
|
||||
|
||||
export async function GET() {
|
||||
return NextResponse.json(await blitzStarsTankAverages);
|
||||
}
|
||||
@@ -1,15 +1,11 @@
|
||||
import {
|
||||
blitzStarsTankAverages,
|
||||
BlitzStats,
|
||||
calculateWN8,
|
||||
filterStats,
|
||||
getAccountInfo,
|
||||
getClanAccountInfo,
|
||||
getTankStats,
|
||||
getWN8Percentile,
|
||||
StatFilters,
|
||||
TankDefinition,
|
||||
tankDefinitions,
|
||||
} from '@blitzkit/core';
|
||||
import { Locale } from 'discord.js';
|
||||
import { chunk } from 'lodash-es';
|
||||
@@ -18,8 +14,11 @@ import { CommandWrapper } from '../../components/CommandWrapper';
|
||||
import { NoData } from '../../components/NoData';
|
||||
import { TitleBar } from '../../components/TitleBar';
|
||||
import { filtersToDescription } from '../../core/blitzkit/filtersToDescription';
|
||||
import { tankDefinitions } from '../../core/blitzkit/nonBlockingPromises';
|
||||
import { UserError } from '../../core/blitzkit/userError';
|
||||
import { filterStats, StatFilters } from '../../core/blitzstars/filterStats';
|
||||
import { getStatsInPeriod } from '../../core/blitzstars/getStatsInPeriod';
|
||||
import { blitzStarsTankAverages } from '../../core/blitzstars/tankAverages';
|
||||
import { ResolvedPeriod } from '../../core/discord/resolvePeriodFromCommand';
|
||||
import { ResolvedPlayer } from '../../core/discord/resolvePlayerFromCommand';
|
||||
import { translator } from '../../core/localization/translator';
|
||||
@@ -136,7 +135,7 @@ export async function renderBreakdown(
|
||||
children.push(
|
||||
<Breakdown.Row
|
||||
key={id}
|
||||
type="summary"
|
||||
displayType="summary"
|
||||
title={t`bot.commands.breakdown.body.total`}
|
||||
stats={[
|
||||
{
|
||||
@@ -176,7 +175,7 @@ export async function renderBreakdown(
|
||||
);
|
||||
|
||||
filteredOrder.forEach((id, index) => {
|
||||
const tankDefinition = awaitedTankDefinitions[id] as
|
||||
const tankDefinition = awaitedTankDefinitions.tanks[id] as
|
||||
| TankDefinition
|
||||
| undefined;
|
||||
const current = orderedCurrentStats[index];
|
||||
@@ -187,9 +186,9 @@ export async function renderBreakdown(
|
||||
children.push(
|
||||
<Breakdown.Row
|
||||
key={id}
|
||||
type="tank"
|
||||
tankType={tankDefinition?.class}
|
||||
treeType={tankDefinition?.treeType}
|
||||
displayType="tank"
|
||||
class={tankDefinition?.class}
|
||||
displayType={tankDefinition?.type}
|
||||
title={
|
||||
tankDefinition?.name ??
|
||||
translate('bot.commands.breakdown.body.unknown_tank', [`${id}`])
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import {
|
||||
Percentile,
|
||||
TankClass,
|
||||
TankType,
|
||||
TREE_TYPE_ICONS,
|
||||
TreeType,
|
||||
} from '@blitzkit/core';
|
||||
import { createColors } from 'bepaint';
|
||||
import {
|
||||
@@ -21,12 +21,12 @@ export interface RowStatItem {
|
||||
}
|
||||
|
||||
interface RowProps {
|
||||
type?: 'tank' | 'summary';
|
||||
displayType?: 'tank' | 'summary';
|
||||
naked?: boolean;
|
||||
title: string;
|
||||
minimized?: boolean;
|
||||
treeType?: TreeType;
|
||||
tankType?: TankClass;
|
||||
type?: TankType;
|
||||
class?: TankClass;
|
||||
color?: AccentColor | GrayColor;
|
||||
stats: (RowStatItem | undefined)[];
|
||||
}
|
||||
@@ -36,10 +36,10 @@ export function Row({
|
||||
stats,
|
||||
title,
|
||||
minimized,
|
||||
tankType,
|
||||
treeType,
|
||||
naked = false,
|
||||
class: tankClass,
|
||||
type,
|
||||
naked = false,
|
||||
displayType,
|
||||
}: RowProps) {
|
||||
const palette = PALETTES[`${color}Dark`];
|
||||
const theme = createColors(palette);
|
||||
@@ -70,10 +70,10 @@ export function Row({
|
||||
: theme.componentInteractive,
|
||||
}}
|
||||
>
|
||||
{type === 'tank' && tankType !== undefined && (
|
||||
{displayType === 'tank' && tankClass !== undefined && (
|
||||
<img
|
||||
alt={tankType}
|
||||
src={TREE_TYPE_ICONS[treeType ?? 'researchable'][tankType]}
|
||||
alt={TankClass[tankClass]}
|
||||
src={TREE_TYPE_ICONS[type ?? TankType.RESEARCHABLE][tankClass]}
|
||||
style={{ width: 16, height: 16 }}
|
||||
/>
|
||||
)}
|
||||
@@ -81,8 +81,8 @@ export function Row({
|
||||
<span
|
||||
style={{
|
||||
color:
|
||||
type === 'tank'
|
||||
? treeType === 'collector'
|
||||
displayType === 'tank'
|
||||
? type === TankType.COLLECTOR
|
||||
? theme.textLowContrast_blue
|
||||
: treeType === 'premium'
|
||||
? theme.textLowContrast_amber
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
import { blitzStarsTankAverages } from './tankAverages';
|
||||
import { TankClass, TankType } from '@blitzkit/core';
|
||||
import { SupplementaryStats } from '@blitzkit/core/src/blitz/getAccountInfo';
|
||||
import { tankDefinitions, TreeType } from '@blitzkit/core/src/blitzkit/tankDefinitions';
|
||||
import { calculateWN8 } from '@blitzkit/core/src/statistics/calculateWN8';
|
||||
import { BlitzStats } from '@blitzkit/core/src/statistics/compositeStats';
|
||||
import { sumAllStats } from '@blitzkit/core/src/statistics/sumAllStats';
|
||||
import { tankDefinitions } from '../blitzkit/nonBlockingPromises';
|
||||
import { blitzStarsTankAverages } from './tankAverages';
|
||||
|
||||
export interface StatFilters {
|
||||
nation?: string;
|
||||
tier?: number;
|
||||
tankType?: string;
|
||||
treeType?: TreeType;
|
||||
class?: TankClass;
|
||||
type?: TankType;
|
||||
tank?: number;
|
||||
}
|
||||
|
||||
@@ -23,18 +24,20 @@ export async function filterStats(
|
||||
const awaitedTankDefinitions = await tankDefinitions;
|
||||
const awaitedTankAverages = await blitzStarsTankAverages;
|
||||
const filteredOrder = order.filter((id) => {
|
||||
const entry = awaitedTankDefinitions[id];
|
||||
const entry = awaitedTankDefinitions.tanks[id];
|
||||
|
||||
return (
|
||||
entry &&
|
||||
(filters.nation === undefined || entry.nation === filters.nation) &&
|
||||
(filters.tier === undefined || entry.tier === filters.tier) &&
|
||||
(filters.tankType === undefined || entry.class === filters.tankType) &&
|
||||
(filters.treeType === undefined ||
|
||||
(filters.treeType === 'collector' && entry.treeType === 'collector') ||
|
||||
(filters.treeType === 'premium' && entry.treeType === 'premium') ||
|
||||
(filters.treeType === 'researchable' &&
|
||||
entry.treeType === 'researchable')) &&
|
||||
(filters.class === undefined || entry.class === filters.class) &&
|
||||
(filters.type === undefined ||
|
||||
(filters.type === TankType.COLLECTOR &&
|
||||
entry.type === TankType.COLLECTOR) ||
|
||||
(filters.type === TankType.PREMIUM &&
|
||||
entry.type === TankType.PREMIUM) ||
|
||||
(filters.type === TankType.RESEARCHABLE &&
|
||||
entry.type === TankType.RESEARCHABLE)) &&
|
||||
(filters.tank === undefined || entry.id === filters.tank)
|
||||
);
|
||||
});
|
||||
@@ -46,7 +49,9 @@ export async function filterStats(
|
||||
);
|
||||
const battlesOfTanksWithTankDefinition = filteredOrder.reduce<number>(
|
||||
(accumulator, id) =>
|
||||
awaitedTankDefinitions[id] ? accumulator + diff[id].battles : accumulator,
|
||||
awaitedTankDefinitions.tanks[id]
|
||||
? accumulator + diff[id].battles
|
||||
: accumulator,
|
||||
0,
|
||||
);
|
||||
const supplementary = {
|
||||
@@ -63,8 +68,9 @@ export async function filterStats(
|
||||
tier:
|
||||
filteredOrder.reduce<number>(
|
||||
(accumulator, id) =>
|
||||
awaitedTankDefinitions[id]
|
||||
? accumulator + awaitedTankDefinitions[id]!.tier * diff[id].battles
|
||||
awaitedTankDefinitions.tanks[id]
|
||||
? accumulator +
|
||||
awaitedTankDefinitions.tanks[id]!.tier * diff[id].battles
|
||||
: accumulator,
|
||||
0,
|
||||
) / battlesOfTanksWithTankDefinition,
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
import {
|
||||
BlitzStats,
|
||||
DiffedTankStats,
|
||||
emptyAllStats,
|
||||
Region,
|
||||
} from '@blitzkit/core';
|
||||
import { BlitzStats, emptyAllStats, Region } from '@blitzkit/core';
|
||||
import { Locale } from 'discord.js';
|
||||
import { DiffedTankStats } from './filterStats';
|
||||
import {
|
||||
getTankHistories,
|
||||
TankHistories,
|
||||
|
||||
@@ -52,17 +52,18 @@
|
||||
},
|
||||
|
||||
"tank_class_short": {
|
||||
"lightTank": "Light",
|
||||
"mediumTank": "Medium",
|
||||
"heavyTank": "Heavy",
|
||||
"AT-SPG": "TD"
|
||||
"0": "Light",
|
||||
"1": "Medium",
|
||||
"2": "Heavy",
|
||||
"3": "TD"
|
||||
},
|
||||
|
||||
"tank_class_medium": {
|
||||
"lightTank": "Light",
|
||||
"mediumTank": "Medium",
|
||||
"heavyTank": "Heavy",
|
||||
"AT-SPG": "Tank destroyer"
|
||||
"-1": "unrecognized",
|
||||
"0": "Light",
|
||||
"1": "Medium",
|
||||
"2": "Heavy",
|
||||
"3": "Tank destroyer"
|
||||
},
|
||||
|
||||
"tree_type": {
|
||||
|
||||
@@ -4,10 +4,10 @@ import { BlitzStats } from '../statistics';
|
||||
export const TREE_TYPES = ['researchable', 'premium', 'collector'] as const;
|
||||
|
||||
export const TANK_CLASSES = [
|
||||
TankClass.TANK_CLASS_LIGHT,
|
||||
TankClass.TANK_CLASS_MEDIUM,
|
||||
TankClass.TANK_CLASS_HEAVY,
|
||||
TankClass.TANK_CLASS_TANK_DESTROYER,
|
||||
TankClass.LIGHT,
|
||||
TankClass.MEDIUM,
|
||||
TankClass.HEAVY,
|
||||
TankClass.TANK_DESTROYER,
|
||||
TankClass.UNRECOGNIZED,
|
||||
] as const;
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ export interface DiscoveredIdsDefinitions {
|
||||
count: number;
|
||||
}
|
||||
|
||||
export const discoveredIdsDefinitions = fetch(asset('ids/manifest.json')).then(
|
||||
(response) => response.json() as Promise<DiscoveredIdsDefinitions>,
|
||||
);
|
||||
export async function fetchDiscoveredIdsDefinitions() {
|
||||
const response = await fetch(asset('ids/manifest.json'));
|
||||
return response.json() as Promise<DiscoveredIdsDefinitions>;
|
||||
}
|
||||
@@ -9,7 +9,7 @@ export * from './consumableDefinitions';
|
||||
// export * from './context';
|
||||
export * from './createDefaultSkills';
|
||||
export * from './degressiveStat';
|
||||
// export * from './discoveredIdDefinitions';
|
||||
export * from './discoveredIdDefinitions';
|
||||
// export * from './emblemURL';
|
||||
export * from './equipmentDefinitions';
|
||||
export * from './eventManager';
|
||||
|
||||
@@ -2,12 +2,15 @@ import { BoundingBox } from '@blitzkit/core';
|
||||
|
||||
export function unionBoundingBox(a: BoundingBox, b: BoundingBox) {
|
||||
return {
|
||||
// min: a.min.map((a, index) => Math.min(a, b.min[index])) as Vector3Tuple,
|
||||
// max: a.max.map((a, index) => Math.max(a, b.max[index])) as Vector3Tuple,
|
||||
min: {
|
||||
x: Math.min(a.min.x, b.min.x),
|
||||
y: Math.min(a.min.y, b.min.y),
|
||||
z: Math.min(a.min.z, b.min.z),
|
||||
},
|
||||
max: {
|
||||
x: Math.max(a.max.x, b.max.x),
|
||||
y: Math.max(a.max.y, b.max.y),
|
||||
z: Math.max(a.max.z, b.max.z),
|
||||
},
|
||||
} satisfies BoundingBox;
|
||||
}
|
||||
@@ -28,7 +28,7 @@ const files = filesRaw.filter((file) => file.endsWith('.proto'));
|
||||
const args = [
|
||||
`--plugin=./node_modules/.bin/protoc-gen-ts_proto${executableFileExtension}`,
|
||||
'--ts_proto_opt=esModuleInterop=true',
|
||||
'--ts_proto_opt=oneof=unions',
|
||||
'--ts_proto_opt=oneof=unions-value',
|
||||
'--ts_proto_opt=removeEnumPrefix=true',
|
||||
'--ts_proto_out=.',
|
||||
...files.map((file) => `${ROOT}/${file}`),
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { type TankDefinition, tankIcon } from '@blitzkit/core';
|
||||
import { type TankDefinition, tankIcon, TankType } from '@blitzkit/core';
|
||||
import { Link } from '@radix-ui/themes';
|
||||
import { classIcons } from './ClassIcon';
|
||||
import { ExperimentIcon } from './ExperimentIcon';
|
||||
@@ -32,13 +32,13 @@ export function TankRowHeaderCell({ tank }: TankRowHeaderCellProps) {
|
||||
|
||||
<Link
|
||||
color={
|
||||
tank.treeType === 'collector'
|
||||
tank.type === TankType.COLLECTOR
|
||||
? 'blue'
|
||||
: tank.treeType === 'premium'
|
||||
: tank.type === TankType.PREMIUM
|
||||
? 'amber'
|
||||
: 'gray'
|
||||
}
|
||||
highContrast={tank.treeType === 'researchable'}
|
||||
highContrast={tank.type === TankType.RESEARCHABLE}
|
||||
underline="hover"
|
||||
wrap="nowrap"
|
||||
href={`/tools/tankopedia/${tank.id}`}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import {
|
||||
asset,
|
||||
gameDefinitions,
|
||||
fetchGameDefinitions,
|
||||
TANK_CLASSES,
|
||||
TIER_ROMAN_NUMERALS,
|
||||
type Tier,
|
||||
@@ -10,7 +10,6 @@ import { useStore } from '@nanostores/react';
|
||||
import { ReloadIcon } from '@radix-ui/react-icons';
|
||||
import { Box, Flex, IconButton, Text, Tooltip } from '@radix-ui/themes';
|
||||
import { times } from 'lodash-es';
|
||||
import { useAwait } from '../../../hooks/useAwait';
|
||||
import { $tankFilters, initialTankFilters } from '../../../stores/tankFilters';
|
||||
import { classIcons } from '../../ClassIcon';
|
||||
import { ExperimentIcon } from '../../ExperimentIcon';
|
||||
@@ -22,8 +21,9 @@ interface FilterControlProps {
|
||||
compact?: boolean;
|
||||
}
|
||||
|
||||
const gameDefinitions = await fetchGameDefinitions();
|
||||
|
||||
export function FilterControl({ compact }: FilterControlProps) {
|
||||
const awaitedGameDefinitions = useAwait(gameDefinitions);
|
||||
const tankFilters = useStore($tankFilters);
|
||||
|
||||
return (
|
||||
@@ -126,8 +126,8 @@ export function FilterControl({ compact }: FilterControlProps) {
|
||||
style={{ borderRadius: 'var(--radius-5)' }}
|
||||
>
|
||||
<Flex direction={compact ? 'column' : { sm: 'row', initial: 'column' }}>
|
||||
{awaitedGameDefinitions.nations
|
||||
.slice(0, Math.ceil(awaitedGameDefinitions.nations.length / 2))
|
||||
{gameDefinitions.nations
|
||||
.slice(0, Math.ceil(gameDefinitions.nations.length / 2))
|
||||
.map((nation) => {
|
||||
const selected = tankFilters.nations?.includes(nation);
|
||||
|
||||
@@ -180,8 +180,8 @@ export function FilterControl({ compact }: FilterControlProps) {
|
||||
})}
|
||||
</Flex>
|
||||
<Flex direction={compact ? 'column' : { sm: 'row', initial: 'column' }}>
|
||||
{awaitedGameDefinitions.nations
|
||||
.slice(Math.ceil(awaitedGameDefinitions.nations.length / 2))
|
||||
{gameDefinitions.nations
|
||||
.slice(Math.ceil(gameDefinitions.nations.length / 2))
|
||||
.map((nation) => {
|
||||
const selected = tankFilters.nations?.includes(nation);
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import type { TreeType } from '@blitzkit/core';
|
||||
import { TankType } from '@blitzkit/core';
|
||||
|
||||
export const treeTypeOrder: TreeType[] = [
|
||||
'researchable',
|
||||
'premium',
|
||||
'collector',
|
||||
export const treeTypeOrder = [
|
||||
TankType.RESEARCHABLE,
|
||||
TankType.PREMIUM,
|
||||
TankType.COLLECTOR,
|
||||
];
|
||||
@@ -7,7 +7,6 @@ import {
|
||||
normalizeBoundingBox,
|
||||
resolveDpm,
|
||||
resolveGun,
|
||||
resolveNearPenetration,
|
||||
unionBoundingBox,
|
||||
type TankDefinition,
|
||||
} from '@blitzkit/core';
|
||||
@@ -96,7 +95,7 @@ export const TankSearch = memo<TankSearchProps>(
|
||||
case 'survivability.viewRange':
|
||||
sorted = filtered.sort(
|
||||
(a, b) =>
|
||||
a.turrets.at(-1)!.view_range - b.turrets.at(-1)!.view_range,
|
||||
a.turrets.at(-1)!.viewRange - b.turrets.at(-1)!.viewRange,
|
||||
);
|
||||
break;
|
||||
|
||||
@@ -153,8 +152,8 @@ export const TankSearch = memo<TankSearchProps>(
|
||||
|
||||
case 'survivability.length':
|
||||
sorted = filtered.sort((a, b) => {
|
||||
const aTankModelDefinition = modelDefinitions[a.id];
|
||||
const bTankModelDefinition = modelDefinitions[b.id];
|
||||
const aTankModelDefinition = modelDefinitions.models[a.id];
|
||||
const bTankModelDefinition = modelDefinitions.models[b.id];
|
||||
const aTurretModelDefinition =
|
||||
aTankModelDefinition.turrets[a.turrets.at(-1)!.id];
|
||||
const bTurretModelDefinition =
|
||||
@@ -183,11 +182,11 @@ export const TankSearch = memo<TankSearchProps>(
|
||||
(a, b) =>
|
||||
resolveDpm(
|
||||
a.turrets.at(-1)!.guns.at(-1)!,
|
||||
a.turrets.at(-1)!.guns.at(-1)!.shells[0],
|
||||
a.turrets.at(-1)!.guns.at(-1)!.gunType!.value.gun.shells[0],
|
||||
) -
|
||||
resolveDpm(
|
||||
b.turrets.at(-1)!.guns.at(-1)!,
|
||||
b.turrets.at(-1)!.guns.at(-1)!.shells[0],
|
||||
b.turrets.at(-1)!.guns.at(-1)!.gunType!.value.gun.shells[0],
|
||||
),
|
||||
);
|
||||
break;
|
||||
@@ -195,16 +194,18 @@ export const TankSearch = memo<TankSearchProps>(
|
||||
case 'fire.dpmPremium':
|
||||
sorted = filtered.sort(
|
||||
(a, b) =>
|
||||
(a.turrets.at(-1)!.guns.at(-1)!.shells[1]
|
||||
(a.turrets.at(-1)!.guns.at(-1)!.gunType!.value.gun.shells[1]
|
||||
? resolveDpm(
|
||||
a.turrets.at(-1)!.guns.at(-1)!,
|
||||
a.turrets.at(-1)!.guns.at(-1)!.shells[1],
|
||||
a.turrets.at(-1)!.guns.at(-1)!.gunType!.value.gun
|
||||
.shells[1],
|
||||
)
|
||||
: 0) -
|
||||
(b.turrets.at(-1)!.guns.at(-1)!.shells[1]
|
||||
(b.turrets.at(-1)!.guns.at(-1)!.gunType!.value.gun.shells[1]
|
||||
? resolveDpm(
|
||||
b.turrets.at(-1)!.guns.at(-1)!,
|
||||
b.turrets.at(-1)!.guns.at(-1)!.shells[1],
|
||||
b.turrets.at(-1)!.guns.at(-1)!.gunType!.value.gun
|
||||
.shells[1],
|
||||
)
|
||||
: 0),
|
||||
);
|
||||
@@ -221,112 +222,118 @@ export const TankSearch = memo<TankSearchProps>(
|
||||
case 'fire.caliber':
|
||||
sorted = filtered.sort(
|
||||
(a, b) =>
|
||||
a.turrets.at(-1)!.guns.at(-1)!.shells[0].caliber -
|
||||
b.turrets.at(-1)!.guns.at(-1)!.shells[0].caliber,
|
||||
a.turrets.at(-1)!.guns.at(-1)!.gunType!.value.gun.shells[0]
|
||||
.caliber -
|
||||
b.turrets.at(-1)!.guns.at(-1)!.gunType!.value.gun.shells[0]
|
||||
.caliber,
|
||||
);
|
||||
break;
|
||||
|
||||
case 'fire.standardPenetration':
|
||||
sorted = filtered.sort(
|
||||
(a, b) =>
|
||||
resolveNearPenetration(
|
||||
a.turrets.at(-1)!.guns.at(-1)!.shells[0].penetration,
|
||||
) -
|
||||
resolveNearPenetration(
|
||||
b.turrets.at(-1)!.guns.at(-1)!.shells[0].penetration,
|
||||
),
|
||||
a.turrets.at(-1)!.guns.at(-1)!.gunType!.value.gun.shells[0]
|
||||
.penetration.near -
|
||||
b.turrets.at(-1)!.guns.at(-1)!.gunType!.value.gun.shells[0]
|
||||
.penetration.near,
|
||||
);
|
||||
break;
|
||||
|
||||
case 'fire.premiumPenetration':
|
||||
sorted = filtered.sort(
|
||||
(a, b) =>
|
||||
resolveNearPenetration(
|
||||
a.turrets.at(-1)!.guns.at(-1)!.shells[1]?.penetration ?? 0,
|
||||
) -
|
||||
resolveNearPenetration(
|
||||
b.turrets.at(-1)!.guns.at(-1)!.shells[1]?.penetration ?? 0,
|
||||
),
|
||||
(a.turrets.at(-1)!.guns.at(-1)!.gunType!.value.gun.shells[1]
|
||||
?.penetration.near ?? 0) -
|
||||
(b.turrets.at(-1)!.guns.at(-1)!.gunType!.value.gun.shells[1]
|
||||
?.penetration.near ?? 0),
|
||||
);
|
||||
break;
|
||||
|
||||
case 'fire.damage':
|
||||
sorted = filtered.sort(
|
||||
(a, b) =>
|
||||
a.turrets.at(-1)!.guns.at(-1)!.shells[0].damage.armor -
|
||||
b.turrets.at(-1)!.guns.at(-1)!.shells[0].damage.armor,
|
||||
a.turrets.at(-1)!.guns.at(-1)!.gunType!.value.gun.shells[0]
|
||||
.armorDamage -
|
||||
b.turrets.at(-1)!.guns.at(-1)!.gunType!.value.gun.shells[0]
|
||||
.armorDamage,
|
||||
);
|
||||
break;
|
||||
|
||||
case 'fire.shellVelocity':
|
||||
sorted = filtered.sort(
|
||||
(a, b) =>
|
||||
a.turrets.at(-1)!.guns.at(-1)!.shells[0].speed -
|
||||
b.turrets.at(-1)!.guns.at(-1)!.shells[0].speed,
|
||||
a.turrets.at(-1)!.guns.at(-1)!.gunType!.value.gun.shells[0]
|
||||
.velocity -
|
||||
b.turrets.at(-1)!.guns.at(-1)!.gunType!.value.gun.shells[0]
|
||||
.velocity,
|
||||
);
|
||||
break;
|
||||
|
||||
case 'fire.aimTime':
|
||||
sorted = filtered.sort(
|
||||
(a, b) =>
|
||||
a.turrets.at(-1)!.guns.at(-1)!.aimTime -
|
||||
b.turrets.at(-1)!.guns.at(-1)!.aimTime,
|
||||
a.turrets.at(-1)!.guns.at(-1)!.gunType!.value.gun.aimTime -
|
||||
b.turrets.at(-1)!.guns.at(-1)!.gunType!.value.gun.aimTime,
|
||||
);
|
||||
break;
|
||||
|
||||
case 'fire.dispersionStill':
|
||||
sorted = filtered.sort(
|
||||
(a, b) =>
|
||||
a.turrets.at(-1)!.guns.at(-1)!.dispersion.base -
|
||||
b.turrets.at(-1)!.guns.at(-1)!.dispersion.base,
|
||||
a.turrets.at(-1)!.guns.at(-1)!.gunType!.value.gun
|
||||
.dispersionBase -
|
||||
b.turrets.at(-1)!.guns.at(-1)!.gunType!.value.gun
|
||||
.dispersionBase,
|
||||
);
|
||||
break;
|
||||
|
||||
case 'fire.dispersionMoving':
|
||||
sorted = filtered.sort(
|
||||
(a, b) =>
|
||||
a.tracks.at(-1)!.dispersion.move -
|
||||
b.tracks.at(-1)!.dispersion.move,
|
||||
a.tracks.at(-1)!.dispersionMove -
|
||||
b.tracks.at(-1)!.dispersionMove,
|
||||
);
|
||||
break;
|
||||
|
||||
case 'fire.gunDepression':
|
||||
sorted = filtered.sort(
|
||||
(a, b) =>
|
||||
modelDefinitions[a.id].turrets[a.turrets.at(-1)!.id].guns[
|
||||
a.turrets.at(-1)!.guns.at(-1)!.id
|
||||
].pitch.max +
|
||||
(modelDefinitions[a.id].turretRotation?.pitch ?? 0) -
|
||||
modelDefinitions[b.id].turrets[b.turrets.at(-1)!.id].guns[
|
||||
b.turrets.at(-1)!.guns.at(-1)!.id
|
||||
].pitch.max -
|
||||
(modelDefinitions[b.id].turretRotation?.pitch ?? 0),
|
||||
modelDefinitions.models[a.id].turrets[a.turrets.at(-1)!.id]
|
||||
.guns[a.turrets.at(-1)!.guns.at(-1)!.gunType!.value.gun.id]
|
||||
.pitch.max +
|
||||
(modelDefinitions.models[a.id].initialTurretRotation?.pitch ??
|
||||
0) -
|
||||
modelDefinitions.models[b.id].turrets[b.turrets.at(-1)!.id]
|
||||
.guns[b.turrets.at(-1)!.guns.at(-1)!.gunType!.value.gun.id]
|
||||
.pitch.max -
|
||||
(modelDefinitions.models[b.id].initialTurretRotation?.pitch ??
|
||||
0),
|
||||
);
|
||||
break;
|
||||
|
||||
case 'fire.gunElevation':
|
||||
sorted = filtered.sort(
|
||||
(a, b) =>
|
||||
modelDefinitions[b.id].turrets[b.turrets.at(-1)!.id].guns[
|
||||
b.turrets.at(-1)!.guns.at(-1)!.id
|
||||
].pitch.min +
|
||||
(modelDefinitions[b.id].turretRotation?.pitch ?? 0) -
|
||||
modelDefinitions[a.id].turrets[a.turrets.at(-1)!.id].guns[
|
||||
a.turrets.at(-1)!.guns.at(-1)!.id
|
||||
].pitch.min -
|
||||
(modelDefinitions[a.id].turretRotation?.pitch ?? 0),
|
||||
modelDefinitions.models[b.id].turrets[b.turrets.at(-1)!.id]
|
||||
.guns[b.turrets.at(-1)!.guns.at(-1)!.gunType!.value.gun.id]
|
||||
.pitch.min +
|
||||
(modelDefinitions.models[b.id].initialTurretRotation?.pitch ??
|
||||
0) -
|
||||
modelDefinitions.models[a.id].turrets[a.turrets.at(-1)!.id]
|
||||
.guns[a.turrets.at(-1)!.guns.at(-1)!.gunType!.value.gun.id]
|
||||
.pitch.min -
|
||||
(modelDefinitions.models[a.id].initialTurretRotation?.pitch ??
|
||||
0),
|
||||
);
|
||||
break;
|
||||
|
||||
case 'maneuverability.forwardsSpeed':
|
||||
sorted = filtered.sort(
|
||||
(a, b) => a.speed.forwards - b.speed.forwards,
|
||||
);
|
||||
sorted = filtered.sort((a, b) => a.speedForwards - b.speedForwards);
|
||||
break;
|
||||
|
||||
case 'maneuverability.backwardsSpeed':
|
||||
sorted = filtered.sort(
|
||||
(a, b) => a.speed.backwards - b.speed.backwards,
|
||||
(a, b) => a.speedBackwards - b.speedBackwards,
|
||||
);
|
||||
break;
|
||||
|
||||
@@ -344,13 +351,13 @@ export const TankSearch = memo<TankSearchProps>(
|
||||
a.engines.at(-1)!.weight +
|
||||
a.tracks.at(-1)!.weight +
|
||||
a.turrets.at(-1)!.weight +
|
||||
a.turrets.at(-1)!.guns.at(-1)!.weight) -
|
||||
a.turrets.at(-1)!.guns.at(-1)!.gunType!.value.gun.weight) -
|
||||
b.engines.at(-1)!.power /
|
||||
(b.weight +
|
||||
b.engines.at(-1)!.weight +
|
||||
b.tracks.at(-1)!.weight +
|
||||
b.turrets.at(-1)!.weight +
|
||||
b.turrets.at(-1)!.guns.at(-1)!.weight),
|
||||
b.turrets.at(-1)!.guns.at(-1)!.gunType!.value.gun.weight),
|
||||
);
|
||||
break;
|
||||
|
||||
@@ -361,12 +368,12 @@ export const TankSearch = memo<TankSearchProps>(
|
||||
a.engines.at(-1)!.weight +
|
||||
a.tracks.at(-1)!.weight +
|
||||
a.turrets.at(-1)!.weight +
|
||||
a.turrets.at(-1)!.guns.at(-1)!.weight -
|
||||
a.turrets.at(-1)!.guns.at(-1)!.gunType!.value.gun.weight -
|
||||
(b.weight +
|
||||
b.engines.at(-1)!.weight +
|
||||
b.tracks.at(-1)!.weight +
|
||||
b.turrets.at(-1)!.weight +
|
||||
b.turrets.at(-1)!.guns.at(-1)!.weight),
|
||||
b.turrets.at(-1)!.guns.at(-1)!.gunType!.value.gun.weight),
|
||||
);
|
||||
break;
|
||||
|
||||
@@ -386,7 +393,7 @@ export const TankSearch = memo<TankSearchProps>(
|
||||
keys: ['searchableName', 'searchableNameDeburr', 'camouflages'],
|
||||
});
|
||||
const searchedTanks = searchedRaw.map(
|
||||
(result) => tankDefinitions[result.obj.id],
|
||||
(result) => tankDefinitions.tanks[result.obj.id],
|
||||
);
|
||||
return searchedTanks;
|
||||
}
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
import { CompositeStatsKey } from '@blitzkit/core';
|
||||
import type { CompositeStatsKey } from '@blitzkit/core';
|
||||
import { grayA, grayDark, grayDarkA } from '@radix-ui/colors';
|
||||
import { ReactNode } from 'react';
|
||||
import type { ReactNode } from 'react';
|
||||
import {
|
||||
BreakdownPreview,
|
||||
compositeStatsKeysOptions,
|
||||
} from '../../../website-legacy/src/app/tools/embed/configurations/breakdown';
|
||||
import { EmbedConfig, ExtractEmbedConfigTypes } from '../../../website-legacy/src/stores/embedState';
|
||||
import { EmbedItemType } from '../../../website-legacy/src/stores/embedState/constants';
|
||||
import type {
|
||||
EmbedConfig,
|
||||
ExtractEmbedConfigTypes,
|
||||
} from '../stores/embedState';
|
||||
import { EmbedItemType } from '../stores/embedState/constants';
|
||||
|
||||
export const breakdownConfig = {
|
||||
width: { type: EmbedItemType.Slider, default: 320, min: 128, max: 640 },
|
||||
|
||||
@@ -6,7 +6,7 @@ export function filterTank(filters: TankFilters, tank: TankDefinition) {
|
||||
(filters.tiers.length === 0 || filters.tiers.includes(tank.tier)) &&
|
||||
(filters.nations.length === 0 || filters.nations.includes(tank.nation)) &&
|
||||
(filters.classes.length === 0 || filters.classes.includes(tank.class)) &&
|
||||
(filters.types.length === 0 || filters.types.includes(tank.treeType)) &&
|
||||
(filters.types.length === 0 || filters.types.includes(tank.type)) &&
|
||||
(filters.testing === 'include' ||
|
||||
(filters.testing === 'only' && tank.testing) ||
|
||||
(filters.testing === 'exclude' && !tank.testing))
|
||||
|
||||
@@ -1,13 +1,19 @@
|
||||
import type { GunDefinition } from '@blitzkit/core';
|
||||
|
||||
export function resolveReload(gun: GunDefinition) {
|
||||
if (gun.type === 'regular') {
|
||||
return gun.reload;
|
||||
} else if (gun.type === 'autoLoader') {
|
||||
return gun.reload + (gun.count - 1) * gun.intraClip;
|
||||
if (gun.gunType!.$case === 'regular') {
|
||||
return gun.gunType!.value.regular.reload;
|
||||
} else if (gun.gunType!.$case === 'autoLoader') {
|
||||
return (
|
||||
gun.gunType!.value.autoLoader.clipReload +
|
||||
(gun.gunType!.value.autoLoader.shellCount - 1) *
|
||||
gun.gunType!.value.autoLoader.intraClip
|
||||
);
|
||||
} else {
|
||||
return (
|
||||
gun.reload.reduce((a, b) => a + b, 0) + (gun.count - 1) * gun.intraClip
|
||||
gun.gunType!.value.autoReloader.shellReloads.reduce((a, b) => a + b, 0) +
|
||||
(gun.gunType!.value.autoReloader.shellCount - 1) *
|
||||
gun.gunType!.value.autoReloader.intraClip
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { ModelArmor } from '@blitzkit/core';
|
||||
import type { Armor } from '@blitzkit/core';
|
||||
|
||||
export function resolveArmor(armor: ModelArmor, index: number) {
|
||||
export function resolveArmor(armor: Armor, index: number) {
|
||||
const spaced = armor.spaced?.includes(index) ?? false;
|
||||
const thickness = index === -1 ? 0 : (armor.thickness[index] ?? 0);
|
||||
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import { EquipmentPreset } from '@blitzkit/core';
|
||||
import { EquipmentMatrix } from '../stores/duel';
|
||||
import type { EquipmentMatrix } from '../stores/duel';
|
||||
|
||||
export function useAppliedEquipments(
|
||||
matrix: EquipmentMatrix,
|
||||
preset: EquipmentPreset,
|
||||
) {
|
||||
const flatMatrix = matrix.flat();
|
||||
return preset
|
||||
.flat()
|
||||
.map((options, index) => options[flatMatrix[index] == 1 ? 1 : 0]);
|
||||
return preset.slots.map(
|
||||
(options, index) => options[flatMatrix[index] == 1 ? 'right' : 'left'],
|
||||
);
|
||||
}
|
||||
@@ -1,7 +1,10 @@
|
||||
import { averageDefinitions, discoveredIdsDefinitions } from '@blitzkit/core';
|
||||
import {
|
||||
fetchAverageDefinitions,
|
||||
fetchDiscoveredIdsDefinitions,
|
||||
} from '@blitzkit/core';
|
||||
|
||||
const awaitedDiscoveredIdsDefinitions = await discoveredIdsDefinitions;
|
||||
const awaitedAverageDefinitions = await averageDefinitions;
|
||||
const awaitedDiscoveredIdsDefinitions = await fetchDiscoveredIdsDefinitions();
|
||||
const awaitedAverageDefinitions = await fetchAverageDefinitions();
|
||||
|
||||
export function useAveragesExclusionRatio() {
|
||||
return (
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { equipmentDefinitions } from '@blitzkit/core';
|
||||
import { fetchEquipmentDefinitions } from '@blitzkit/core';
|
||||
import { useAwait } from './useAwait';
|
||||
|
||||
const equipmentDefinitions = useAwait(fetchEquipmentDefinitions());
|
||||
|
||||
export function useEquipmentPreset(preset: string) {
|
||||
const awaitedEquipmentDefinitions = useAwait(equipmentDefinitions);
|
||||
return awaitedEquipmentDefinitions.presets[preset];
|
||||
return equipmentDefinitions.presets[preset];
|
||||
}
|
||||
Reference in new issue
Block a user