mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-24 03:59:50 +02:00
idk bro
This commit is contained in:
1 parent
61fe8c7e7c
commit
78dce028d9
26 files changed
+135
-101
No files matched your search
@@ -1,8 +1,8 @@
|
|||||||
import {
|
import {
|
||||||
BlitzkitResponse,
|
BlitzkitResponse,
|
||||||
BlitzkitResponseError,
|
BlitzkitResponseError,
|
||||||
|
fetchTankDefinitions,
|
||||||
isValidBlitzId,
|
isValidBlitzId,
|
||||||
tankDefinitions,
|
|
||||||
TankVotes,
|
TankVotes,
|
||||||
usersDatabase,
|
usersDatabase,
|
||||||
} from '@blitzkit/core';
|
} from '@blitzkit/core';
|
||||||
@@ -13,9 +13,9 @@ export async function GET(
|
|||||||
{ params }: { params: { id: string } },
|
{ params }: { params: { id: string } },
|
||||||
) {
|
) {
|
||||||
const id = Number(params.id);
|
const id = Number(params.id);
|
||||||
const awaitedTankDefinitions = await tankDefinitions;
|
const tankDefinitions = await fetchTankDefinitions();
|
||||||
|
|
||||||
if (isNaN(id) || !awaitedTankDefinitions[id]) {
|
if (isNaN(id) || !tankDefinitions.tanks[id]) {
|
||||||
return NextResponse.json({
|
return NextResponse.json({
|
||||||
status: 'error',
|
status: 'error',
|
||||||
error: 'INVALID_TANK_ID',
|
error: 'INVALID_TANK_ID',
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
import {
|
import {
|
||||||
BlitzkitResponse,
|
BlitzkitResponse,
|
||||||
BlitzkitResponseError,
|
BlitzkitResponseError,
|
||||||
|
fetchTankDefinitions,
|
||||||
isValidBlitzId,
|
isValidBlitzId,
|
||||||
StarsInt,
|
StarsInt,
|
||||||
TANK_VOTE_CATEGORIES,
|
TANK_VOTE_CATEGORIES,
|
||||||
tankDefinitions,
|
|
||||||
TankVoteCategory,
|
TankVoteCategory,
|
||||||
usersDatabase,
|
usersDatabase,
|
||||||
} from '@blitzkit/core';
|
} from '@blitzkit/core';
|
||||||
@@ -15,9 +15,9 @@ export async function GET(
|
|||||||
{ params }: { params: { id: string } },
|
{ params }: { params: { id: string } },
|
||||||
) {
|
) {
|
||||||
const tankId = Number(params.id);
|
const tankId = Number(params.id);
|
||||||
const awaitedTankDefinitions = await tankDefinitions;
|
const tankDefinitions = await fetchTankDefinitions();
|
||||||
|
|
||||||
if (isNaN(tankId) || !awaitedTankDefinitions[tankId]) {
|
if (isNaN(tankId) || !tankDefinitions.tanks[tankId]) {
|
||||||
return NextResponse.json({
|
return NextResponse.json({
|
||||||
status: 'error',
|
status: 'error',
|
||||||
error: 'INVALID_TANK_ID',
|
error: 'INVALID_TANK_ID',
|
||||||
|
|||||||
@@ -1,12 +1,14 @@
|
|||||||
|
import { TankClass } from '../protos';
|
||||||
import { BlitzStats } from '../statistics';
|
import { BlitzStats } from '../statistics';
|
||||||
|
|
||||||
export const TREE_TYPES = ['researchable', 'premium', 'collector'] as const;
|
export const TREE_TYPES = ['researchable', 'premium', 'collector'] as const;
|
||||||
|
|
||||||
export const TANK_CLASSES = [
|
export const TANK_CLASSES = [
|
||||||
'lightTank',
|
TankClass.TANK_CLASS_LIGHT,
|
||||||
'mediumTank',
|
TankClass.TANK_CLASS_MEDIUM,
|
||||||
'heavyTank',
|
TankClass.TANK_CLASS_HEAVY,
|
||||||
'AT-SPG',
|
TankClass.TANK_CLASS_TANK_DESTROYER,
|
||||||
|
TankClass.UNRECOGNIZED,
|
||||||
] as const;
|
] as const;
|
||||||
|
|
||||||
export const emptyAllStats: BlitzStats = {
|
export const emptyAllStats: BlitzStats = {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
|
import { fetchPB } from '../../protobuf';
|
||||||
import { AverageDefinitions } from '../../protos';
|
import { AverageDefinitions } from '../../protos';
|
||||||
import { fetchPB } from '../../types';
|
|
||||||
import { asset } from '../asset';
|
import { asset } from '../asset';
|
||||||
|
|
||||||
export interface AverageDefinitionsManifest {
|
export interface AverageDefinitionsManifest {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
|
import { fetchPB } from '../protobuf';
|
||||||
import { CamouflageDefinitions } from '../protos';
|
import { CamouflageDefinitions } from '../protos';
|
||||||
import { fetchPB } from '../types';
|
|
||||||
import { asset } from './asset';
|
import { asset } from './asset';
|
||||||
|
|
||||||
export function fetchCamouflageDefinitions() {
|
export function fetchCamouflageDefinitions() {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
|
import { fetchPB } from '../protobuf';
|
||||||
import { ConsumableDefinitions } from '../protos';
|
import { ConsumableDefinitions } from '../protos';
|
||||||
import { fetchPB } from '../types';
|
|
||||||
import { asset } from './asset';
|
import { asset } from './asset';
|
||||||
|
|
||||||
export function fetchConsumableDefinitions() {
|
export function fetchConsumableDefinitions() {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
|
import { fetchPB } from '../protobuf';
|
||||||
import { EquipmentDefinitions } from '../protos';
|
import { EquipmentDefinitions } from '../protos';
|
||||||
import { fetchPB } from '../types';
|
|
||||||
import { asset } from './asset';
|
import { asset } from './asset';
|
||||||
|
|
||||||
export function fetchEquipmentDefinitions() {
|
export function fetchEquipmentDefinitions() {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
|
import { fetchPB } from '../protobuf';
|
||||||
import { GameDefinitions } from '../protos';
|
import { GameDefinitions } from '../protos';
|
||||||
import { fetchPB } from '../types';
|
|
||||||
import { asset } from './asset';
|
import { asset } from './asset';
|
||||||
|
|
||||||
export function fetchGameDefinitions() {
|
export function fetchGameDefinitions() {
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ export * from './degressiveStat';
|
|||||||
// export * from './emblemURL';
|
// export * from './emblemURL';
|
||||||
export * from './equipmentDefinitions';
|
export * from './equipmentDefinitions';
|
||||||
export * from './eventManager';
|
export * from './eventManager';
|
||||||
|
export * from './resolveGun';
|
||||||
// export * from './flagUserActivity';
|
// export * from './flagUserActivity';
|
||||||
export * from './gameDefinitions';
|
export * from './gameDefinitions';
|
||||||
// export * from './getArchivedLatestSeasonNumber';
|
// export * from './getArchivedLatestSeasonNumber';
|
||||||
@@ -40,7 +41,7 @@ export * from './tankIcon';
|
|||||||
export * from './tankNames';
|
export * from './tankNames';
|
||||||
export * from './unionBoundingBox';
|
export * from './unionBoundingBox';
|
||||||
export * from './uniqueGuns';
|
export * from './uniqueGuns';
|
||||||
// export * from './unwrapBlitzkitResponse';
|
export * from './unwrapBlitzkitResponse';
|
||||||
export * from './votes';
|
export * from './votes';
|
||||||
// export * from './withCORSProxy';
|
// export * from './withCORSProxy';
|
||||||
export * from './youtubers';
|
export * from './youtubers';
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
|
import { fetchPB } from '../protobuf';
|
||||||
import { MapDefinitions } from '../protos';
|
import { MapDefinitions } from '../protos';
|
||||||
import { fetchPB } from '../types';
|
|
||||||
import { asset } from './asset';
|
import { asset } from './asset';
|
||||||
|
|
||||||
export function fetchMapDefinitions() {
|
export function fetchMapDefinitions() {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
|
import { fetchPB } from '../protobuf';
|
||||||
import { ModelDefinitions } from '../protos';
|
import { ModelDefinitions } from '../protos';
|
||||||
import { fetchPB } from '../types';
|
|
||||||
import { asset } from './asset';
|
import { asset } from './asset';
|
||||||
|
|
||||||
export function fetchModelDefinitions() {
|
export function fetchModelDefinitions() {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
|
import { fetchPB } from '../protobuf';
|
||||||
import { ProvisionDefinitions } from '../protos';
|
import { ProvisionDefinitions } from '../protos';
|
||||||
import { fetchPB } from '../types';
|
|
||||||
import { asset } from './asset';
|
import { asset } from './asset';
|
||||||
|
|
||||||
export function fetchProvisionDefinitions() {
|
export function fetchProvisionDefinitions() {
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
import { GunDefinition } from '../protos';
|
||||||
|
|
||||||
|
export function resolveGun(gun: GunDefinition) {
|
||||||
|
if (gun.regular) return gun.regular;
|
||||||
|
else if (gun.autoLoader) return gun.autoLoader;
|
||||||
|
else if (gun.autoReloader) return gun.autoReloader;
|
||||||
|
|
||||||
|
throw new Error('Could not resolve gun');
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
|
import { fetchPB } from '../protobuf';
|
||||||
import { Reviews } from '../protos';
|
import { Reviews } from '../protos';
|
||||||
import { fetchPB } from '../types';
|
|
||||||
import { asset } from './asset';
|
import { asset } from './asset';
|
||||||
|
|
||||||
export function fetchReviews() {
|
export function fetchReviews() {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
|
import { fetchPB } from '../protobuf';
|
||||||
import { SkillDefinitions } from '../protos';
|
import { SkillDefinitions } from '../protos';
|
||||||
import { fetchPB } from '../types';
|
|
||||||
import { asset } from './asset';
|
import { asset } from './asset';
|
||||||
|
|
||||||
export function fetchSkillDefinitions() {
|
export function fetchSkillDefinitions() {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
|
import { fetchPB } from '../../protobuf';
|
||||||
import { TankDefinitions } from '../../protos';
|
import { TankDefinitions } from '../../protos';
|
||||||
import { fetchPB } from '../../types';
|
|
||||||
import { asset } from '../asset';
|
import { asset } from '../asset';
|
||||||
|
|
||||||
export function fetchTankDefinitions() {
|
export function fetchTankDefinitions() {
|
||||||
|
|||||||
@@ -1,14 +1,17 @@
|
|||||||
import { deburr } from 'lodash-es';
|
import { deburr } from 'lodash-es';
|
||||||
import { tankDefinitionsArray } from '.';
|
import { fetchCamouflageDefinitions } from './camouflageDefinitions';
|
||||||
import { camouflageDefinitions } from './camouflageDefinitions';
|
import { fetchTankDefinitions } from './tankDefinitions';
|
||||||
|
|
||||||
export const tankNames = Promise.all([
|
export async function fetchTankNames() {
|
||||||
tankDefinitionsArray,
|
const [tankDefinitions, camouflageDefinitions] = await Promise.all([
|
||||||
camouflageDefinitions,
|
fetchTankDefinitions(),
|
||||||
]).then(([tanks, camouflages]) =>
|
fetchCamouflageDefinitions(),
|
||||||
Promise.all(
|
]);
|
||||||
tanks.map(async (tank, index) => {
|
const tankDefinitionsArray = Object.values(tankDefinitions.tanks);
|
||||||
const { id } = (await tankDefinitionsArray)[index];
|
|
||||||
|
return await Promise.all(
|
||||||
|
tankDefinitionsArray.map(async (tank, index) => {
|
||||||
|
const { id } = tankDefinitionsArray[index];
|
||||||
|
|
||||||
return {
|
return {
|
||||||
id,
|
id,
|
||||||
@@ -17,10 +20,10 @@ export const tankNames = Promise.all([
|
|||||||
searchableName: tank.nameFull ?? tank.name,
|
searchableName: tank.nameFull ?? tank.name,
|
||||||
searchableNameDeburr: deburr(tank.nameFull ?? tank.name),
|
searchableNameDeburr: deburr(tank.nameFull ?? tank.name),
|
||||||
camouflages: tank.camouflages
|
camouflages: tank.camouflages
|
||||||
?.map((id) => camouflages[id].name)
|
?.map((id) => camouflageDefinitions.camouflages[id].name)
|
||||||
.join(' '),
|
.join(' '),
|
||||||
treeType: tank.treeType,
|
treeType: tank.type,
|
||||||
};
|
};
|
||||||
}),
|
}),
|
||||||
),
|
);
|
||||||
);
|
}
|
||||||
@@ -1,9 +1,13 @@
|
|||||||
import { BoundingBox } from '@blitzkit/core';
|
import { BoundingBox } from '@blitzkit/core';
|
||||||
import { Vector3Tuple } from 'three';
|
|
||||||
|
|
||||||
export function unionBoundingBox(a: BoundingBox, b: BoundingBox) {
|
export function unionBoundingBox(a: BoundingBox, b: BoundingBox) {
|
||||||
return {
|
return {
|
||||||
min: a.min.map((a, index) => Math.min(a, b.min[index])) as Vector3Tuple,
|
// 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,
|
// 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),
|
||||||
|
},
|
||||||
} satisfies BoundingBox;
|
} satisfies BoundingBox;
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
export function unwrapBlitzkitResponse<Data>(response: BlitzkitResponse<Data>) {
|
export function unwrapBlitzkitResponse<Data>(response: BlitzkitResponse<Data>) {
|
||||||
if (response.status === 'error') {
|
if (response.status === 'error') {
|
||||||
throw new Error(response.error, { cause: response.message });
|
throw new Error(response.error, { cause: response.message });
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ message ConsumableTankCategoryFilter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
enum ConsumableTankCategoryFilterCategory {
|
enum ConsumableTankCategoryFilterCategory {
|
||||||
TANK_CATEGORY_CLIP = 0;
|
CONSUMABLE_TANK_CATEGORY_FILTER_CATEGORY_CLIP = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
message ConsumableTankNationFilter {
|
message ConsumableTankNationFilter {
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
syntax = "proto3";
|
||||||
|
|
||||||
|
message Test {
|
||||||
|
Child child_b = 1;
|
||||||
|
uint32 child_a = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
message Child {
|
||||||
|
string value = 1;
|
||||||
|
}
|
||||||
@@ -9,7 +9,7 @@ const exec = promisify(execSync);
|
|||||||
|
|
||||||
let executableFileExtension: string;
|
let executableFileExtension: string;
|
||||||
|
|
||||||
if (existsSync('node_modules/.bin/protoc-gen-ts.exe')) {
|
if (existsSync('node_modules/.bin/protoc-gen-ts_proto.exe')) {
|
||||||
executableFileExtension = '.exe';
|
executableFileExtension = '.exe';
|
||||||
} else {
|
} else {
|
||||||
executableFileExtension = '';
|
executableFileExtension = '';
|
||||||
@@ -27,6 +27,12 @@ await Promise.all(
|
|||||||
const files = filesRaw.filter((file) => file.endsWith('.proto'));
|
const files = filesRaw.filter((file) => file.endsWith('.proto'));
|
||||||
const args = [
|
const args = [
|
||||||
`--plugin=./node_modules/.bin/protoc-gen-ts_proto${executableFileExtension}`,
|
`--plugin=./node_modules/.bin/protoc-gen-ts_proto${executableFileExtension}`,
|
||||||
|
'--ts_proto_opt=esModuleInterop=true',
|
||||||
|
'--ts_proto_opt=oneof=unions',
|
||||||
|
'--ts_proto_opt=removeEnumPrefix=true',
|
||||||
|
'--ts_proto_opt=snakeToCamel=false',
|
||||||
|
'--ts_proto_opt=useOptionals=none',
|
||||||
|
'--ts_proto_opt=noDefaultsForOptionals=true',
|
||||||
'--ts_proto_out=.',
|
'--ts_proto_out=.',
|
||||||
...files.map((file) => `${ROOT}/${file}`),
|
...files.map((file) => `${ROOT}/${file}`),
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
import {
|
import {
|
||||||
TANK_CLASSES,
|
TANK_CLASSES,
|
||||||
gameDefinitions,
|
fetchGameDefinitions,
|
||||||
modelDefinitions,
|
fetchModelDefinitions,
|
||||||
|
fetchTankDefinitions,
|
||||||
|
fetchTankNames,
|
||||||
normalizeBoundingBox,
|
normalizeBoundingBox,
|
||||||
resolveDpm,
|
resolveDpm,
|
||||||
|
resolveGun,
|
||||||
resolveNearPenetration,
|
resolveNearPenetration,
|
||||||
tankDefinitions,
|
|
||||||
tankDefinitionsArray,
|
|
||||||
tankNames,
|
|
||||||
unionBoundingBox,
|
unionBoundingBox,
|
||||||
type TankDefinition,
|
type TankDefinition,
|
||||||
} from '@blitzkit/core';
|
} from '@blitzkit/core';
|
||||||
@@ -44,20 +44,15 @@ type TankSearchProps = Omit<FlexProps, 'onSelect'> & {
|
|||||||
const PREVIEW_COUNT = 25;
|
const PREVIEW_COUNT = 25;
|
||||||
const DEFAULT_LOADED_CARDS = 75;
|
const DEFAULT_LOADED_CARDS = 75;
|
||||||
|
|
||||||
const awaitedGameDefinitions = await gameDefinitions;
|
const gameDefinitions = await fetchGameDefinitions();
|
||||||
const awaitedModelDefinitions = await modelDefinitions;
|
const modelDefinitions = await fetchModelDefinitions();
|
||||||
const awaitedTankDefinitions = await tankDefinitions;
|
const tankDefinitions = await fetchTankDefinitions();
|
||||||
const awaitedTanksDefinitionsArray = await tankDefinitionsArray;
|
const tankNames = await fetchTankNames();
|
||||||
const awaitedTankNames = await tankNames;
|
|
||||||
|
|
||||||
export const TankSearch = memo<TankSearchProps>(
|
export const TankSearch = memo<TankSearchProps>(
|
||||||
({ compact, onSelect, onSelectAll, ...props }) => {
|
({ compact, onSelect, onSelectAll, ...props }) => {
|
||||||
|
const awaitedTanksDefinitionsArray = Object.values(tankDefinitions.tanks);
|
||||||
const exempt = useAdExempt();
|
const exempt = useAdExempt();
|
||||||
// const awaitedGameDefinitions = useAwait(gameDefinitions);
|
|
||||||
// const awaitedModelDefinitions = useAwait(modelDefinitions);
|
|
||||||
// const awaitedTankDefinitions = useAwait(tankDefinitions);
|
|
||||||
// const awaitedTanksDefinitionsArray = useAwait(tankDefinitionsArray);
|
|
||||||
// const awaitedTankNames = useAwait(tankNames);
|
|
||||||
const tankFilters = useStore($tankFilters);
|
const tankFilters = useStore($tankFilters);
|
||||||
const tankopediaSort = useStore($tankopediaSort);
|
const tankopediaSort = useStore($tankopediaSort);
|
||||||
|
|
||||||
@@ -74,8 +69,7 @@ export const TankSearch = memo<TankSearchProps>(
|
|||||||
.sort((a, b) => b.tier - a.tier)
|
.sort((a, b) => b.tier - a.tier)
|
||||||
.sort(
|
.sort(
|
||||||
(a, b) =>
|
(a, b) =>
|
||||||
treeTypeOrder.indexOf(b.treeType) -
|
treeTypeOrder.indexOf(b.type) - treeTypeOrder.indexOf(a.type),
|
||||||
treeTypeOrder.indexOf(a.treeType),
|
|
||||||
)
|
)
|
||||||
.sort(
|
.sort(
|
||||||
(a, b) =>
|
(a, b) =>
|
||||||
@@ -83,8 +77,8 @@ export const TankSearch = memo<TankSearchProps>(
|
|||||||
)
|
)
|
||||||
.sort(
|
.sort(
|
||||||
(a, b) =>
|
(a, b) =>
|
||||||
awaitedGameDefinitions.nations.indexOf(b.nation) -
|
gameDefinitions.nations.indexOf(b.nation) -
|
||||||
awaitedGameDefinitions.nations.indexOf(a.nation),
|
gameDefinitions.nations.indexOf(a.nation),
|
||||||
)
|
)
|
||||||
.sort((a, b) => a.tier - b.tier);
|
.sort((a, b) => a.tier - b.tier);
|
||||||
break;
|
break;
|
||||||
@@ -102,36 +96,38 @@ export const TankSearch = memo<TankSearchProps>(
|
|||||||
case 'survivability.viewRange':
|
case 'survivability.viewRange':
|
||||||
sorted = filtered.sort(
|
sorted = filtered.sort(
|
||||||
(a, b) =>
|
(a, b) =>
|
||||||
a.turrets.at(-1)!.viewRange - b.turrets.at(-1)!.viewRange,
|
a.turrets.at(-1)!.view_range - b.turrets.at(-1)!.view_range,
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'survivability.camouflageStill':
|
case 'survivability.camouflageStill':
|
||||||
sorted = filtered.sort(
|
sorted = filtered.sort(
|
||||||
(a, b) => a.camouflage.still - b.camouflage.still,
|
(a, b) => a.camouflageStill - b.camouflageStill,
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'survivability.camouflageMoving':
|
case 'survivability.camouflageMoving':
|
||||||
sorted = filtered.sort(
|
sorted = filtered.sort(
|
||||||
(a, b) => a.camouflage.moving - b.camouflage.moving,
|
(a, b) => a.camouflageMoving - b.camouflageMoving,
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'survivability.camouflageShooting':
|
case 'survivability.camouflageShooting':
|
||||||
sorted = filtered.sort(
|
sorted = filtered.sort(
|
||||||
(a, b) =>
|
(a, b) =>
|
||||||
a.camouflage.still *
|
a.camouflageStill *
|
||||||
a.turrets.at(-1)!.guns.at(-1)!.camouflageLoss -
|
resolveGun(a.turrets.at(-1)!.guns.at(-1)!).gun!
|
||||||
b.camouflage.still *
|
.camouflageLoss -
|
||||||
b.turrets.at(-1)!.guns.at(-1)!.camouflageLoss,
|
b.camouflageStill *
|
||||||
|
resolveGun(b.turrets.at(-1)!.guns.at(-1)!).gun!
|
||||||
|
.camouflageLoss,
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'survivability.volume':
|
case 'survivability.volume':
|
||||||
sorted = filtered.sort((a, b) => {
|
sorted = filtered.sort((a, b) => {
|
||||||
const aTankModelDefinition = awaitedModelDefinitions[a.id];
|
const aTankModelDefinition = modelDefinitions.models[a.id];
|
||||||
const bTankModelDefinition = awaitedModelDefinitions[b.id];
|
const bTankModelDefinition = modelDefinitions.models[b.id];
|
||||||
const aTurretModelDefinition =
|
const aTurretModelDefinition =
|
||||||
aTankModelDefinition.turrets[a.turrets.at(-1)!.id];
|
aTankModelDefinition.turrets[a.turrets.at(-1)!.id];
|
||||||
const bTurretModelDefinition =
|
const bTurretModelDefinition =
|
||||||
@@ -157,8 +153,8 @@ export const TankSearch = memo<TankSearchProps>(
|
|||||||
|
|
||||||
case 'survivability.length':
|
case 'survivability.length':
|
||||||
sorted = filtered.sort((a, b) => {
|
sorted = filtered.sort((a, b) => {
|
||||||
const aTankModelDefinition = awaitedModelDefinitions[a.id];
|
const aTankModelDefinition = modelDefinitions[a.id];
|
||||||
const bTankModelDefinition = awaitedModelDefinitions[b.id];
|
const bTankModelDefinition = modelDefinitions[b.id];
|
||||||
const aTurretModelDefinition =
|
const aTurretModelDefinition =
|
||||||
aTankModelDefinition.turrets[a.turrets.at(-1)!.id];
|
aTankModelDefinition.turrets[a.turrets.at(-1)!.id];
|
||||||
const bTurretModelDefinition =
|
const bTurretModelDefinition =
|
||||||
@@ -297,24 +293,28 @@ export const TankSearch = memo<TankSearchProps>(
|
|||||||
case 'fire.gunDepression':
|
case 'fire.gunDepression':
|
||||||
sorted = filtered.sort(
|
sorted = filtered.sort(
|
||||||
(a, b) =>
|
(a, b) =>
|
||||||
awaitedModelDefinitions[a.id].turrets[a.turrets.at(-1)!.id]
|
modelDefinitions[a.id].turrets[a.turrets.at(-1)!.id].guns[
|
||||||
.guns[a.turrets.at(-1)!.guns.at(-1)!.id].pitch.max +
|
a.turrets.at(-1)!.guns.at(-1)!.id
|
||||||
(awaitedModelDefinitions[a.id].turretRotation?.pitch ?? 0) -
|
].pitch.max +
|
||||||
awaitedModelDefinitions[b.id].turrets[b.turrets.at(-1)!.id]
|
(modelDefinitions[a.id].turretRotation?.pitch ?? 0) -
|
||||||
.guns[b.turrets.at(-1)!.guns.at(-1)!.id].pitch.max -
|
modelDefinitions[b.id].turrets[b.turrets.at(-1)!.id].guns[
|
||||||
(awaitedModelDefinitions[b.id].turretRotation?.pitch ?? 0),
|
b.turrets.at(-1)!.guns.at(-1)!.id
|
||||||
|
].pitch.max -
|
||||||
|
(modelDefinitions[b.id].turretRotation?.pitch ?? 0),
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'fire.gunElevation':
|
case 'fire.gunElevation':
|
||||||
sorted = filtered.sort(
|
sorted = filtered.sort(
|
||||||
(a, b) =>
|
(a, b) =>
|
||||||
awaitedModelDefinitions[b.id].turrets[b.turrets.at(-1)!.id]
|
modelDefinitions[b.id].turrets[b.turrets.at(-1)!.id].guns[
|
||||||
.guns[b.turrets.at(-1)!.guns.at(-1)!.id].pitch.min +
|
b.turrets.at(-1)!.guns.at(-1)!.id
|
||||||
(awaitedModelDefinitions[b.id].turretRotation?.pitch ?? 0) -
|
].pitch.min +
|
||||||
awaitedModelDefinitions[a.id].turrets[a.turrets.at(-1)!.id]
|
(modelDefinitions[b.id].turretRotation?.pitch ?? 0) -
|
||||||
.guns[a.turrets.at(-1)!.guns.at(-1)!.id].pitch.min -
|
modelDefinitions[a.id].turrets[a.turrets.at(-1)!.id].guns[
|
||||||
(awaitedModelDefinitions[a.id].turretRotation?.pitch ?? 0),
|
a.turrets.at(-1)!.guns.at(-1)!.id
|
||||||
|
].pitch.min -
|
||||||
|
(modelDefinitions[a.id].turretRotation?.pitch ?? 0),
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -382,11 +382,11 @@ export const TankSearch = memo<TankSearchProps>(
|
|||||||
? sorted
|
? sorted
|
||||||
: sorted.reverse();
|
: sorted.reverse();
|
||||||
} else {
|
} else {
|
||||||
const searchedRaw = fuzzysort.go(tankFilters.search, awaitedTankNames, {
|
const searchedRaw = fuzzysort.go(tankFilters.search, tankNames, {
|
||||||
keys: ['searchableName', 'searchableNameDeburr', 'camouflages'],
|
keys: ['searchableName', 'searchableNameDeburr', 'camouflages'],
|
||||||
});
|
});
|
||||||
const searchedTanks = searchedRaw.map(
|
const searchedTanks = searchedRaw.map(
|
||||||
(result) => awaitedTankDefinitions[result.obj.id],
|
(result) => tankDefinitions[result.obj.id],
|
||||||
);
|
);
|
||||||
return searchedTanks;
|
return searchedTanks;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,20 +1,20 @@
|
|||||||
import { TankDefinition, tankDefinitions } from '@blitzkit/core';
|
import { fetchTankDefinitions, TankDefinition } from '@blitzkit/core';
|
||||||
import { sumBy } from 'lodash-es';
|
import { sumBy } from 'lodash-es';
|
||||||
import { useMemo } from 'react';
|
import { useMemo } from 'react';
|
||||||
import * as Duel from '../stores/duel';
|
import { Duel } from '../stores/duel';
|
||||||
|
|
||||||
export enum UseEccentricityMode {
|
export enum UseEccentricityMode {
|
||||||
Tier,
|
Tier,
|
||||||
Class,
|
Class,
|
||||||
}
|
}
|
||||||
|
|
||||||
const awaitedTankDefinitions = await tankDefinitions;
|
const tankDefinitions = await fetchTankDefinitions();
|
||||||
|
|
||||||
export function useEccentricity(mode: UseEccentricityMode) {
|
export function useEccentricity(mode: UseEccentricityMode) {
|
||||||
const tank = Duel.use((state) => state.protagonist.tank);
|
const tank = Duel.use((state) => state.protagonist.tank);
|
||||||
const similarTanks = useMemo(
|
const similarTanks = useMemo(
|
||||||
() =>
|
() =>
|
||||||
Object.values(awaitedTankDefinitions).filter(
|
Object.values(tankDefinitions).filter(
|
||||||
(tankB) =>
|
(tankB) =>
|
||||||
tank.tier === tankB.tier &&
|
tank.tier === tankB.tier &&
|
||||||
(mode === UseEccentricityMode.Class
|
(mode === UseEccentricityMode.Class
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
---
|
---
|
||||||
import { tankDefinitions } from '@blitzkit/core';
|
import { fetchTankDefinitions } from '@blitzkit/core';
|
||||||
import type { GetStaticPaths } from 'astro';
|
import type { GetStaticPaths } from 'astro';
|
||||||
import ToolLayout from '../../../../layouts/ToolLayout.astro';
|
import ToolLayout from '../../../../layouts/ToolLayout.astro';
|
||||||
import { Page } from './index';
|
import { Page } from './index';
|
||||||
|
|
||||||
export const getStaticPaths = (async () => {
|
export const getStaticPaths = (async () => {
|
||||||
const awaitedTankDefinitions = await tankDefinitions;
|
const tankDefinitions = await fetchTankDefinitions();
|
||||||
|
|
||||||
return Object.values(awaitedTankDefinitions).map((tank) => ({
|
return Object.values(tankDefinitions).map((tank) => ({
|
||||||
params: { id: tank.id },
|
params: { id: tank.id },
|
||||||
}));
|
}));
|
||||||
}) satisfies GetStaticPaths;
|
}) satisfies GetStaticPaths;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import {
|
import {
|
||||||
modelDefinitions,
|
fetchModelDefinitions,
|
||||||
provisionDefinitions,
|
fetchProvisionDefinitions,
|
||||||
tankDefinitions,
|
fetchTankDefinitions,
|
||||||
} from '@blitzkit/core';
|
} from '@blitzkit/core';
|
||||||
import { PageWrapper } from '../../../../components/PageWrapper';
|
import { PageWrapper } from '../../../../components/PageWrapper';
|
||||||
import { CalloutsSection } from '../../../../components/Tankopedia/CalloutsSection';
|
import { CalloutsSection } from '../../../../components/Tankopedia/CalloutsSection';
|
||||||
@@ -22,20 +22,20 @@ interface PageProps {
|
|||||||
id: number;
|
id: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
const awaitedTankDefinitions = await tankDefinitions;
|
const tankDefinitions = await fetchTankDefinitions();
|
||||||
const awaitedProvisionDefinitions = await provisionDefinitions;
|
const provisionDefinitions = await fetchProvisionDefinitions();
|
||||||
const awaitedModelDefinitions = await modelDefinitions;
|
const modelDefinitions = await fetchModelDefinitions();
|
||||||
|
|
||||||
export function Page({ id }: PageProps) {
|
export function Page({ id }: PageProps) {
|
||||||
const tank = awaitedTankDefinitions[id];
|
const tank = tankDefinitions.tanks[id];
|
||||||
const model = awaitedModelDefinitions[id];
|
const model = modelDefinitions.models[id];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<TankopediaEphemeral.Provider data={model}>
|
<TankopediaEphemeral.Provider data={model}>
|
||||||
<App.Provider>
|
<App.Provider>
|
||||||
<TankopediaPersistent.Provider>
|
<TankopediaPersistent.Provider>
|
||||||
<Duel.Provider
|
<Duel.Provider
|
||||||
data={{ tank, provisionDefinitions: awaitedProvisionDefinitions }}
|
data={{ tank, provisionDefinitions: provisionDefinitions }}
|
||||||
>
|
>
|
||||||
<PageWrapper p="0" noMaxWidth color="purple" size={1600} gap="9">
|
<PageWrapper p="0" noMaxWidth color="purple" size={1600} gap="9">
|
||||||
<HeroSection />
|
<HeroSection />
|
||||||
|
|||||||
Reference in new issue
Block a user