feat: filter strings

This commit is contained in:
TrèsAbhi committed 2024-03-07 13:49:38 -06:00
1 parent 935c578ef6
commit b60f8bfd57
12 files changed
+187 -128

No files matched your search

@@ -136,12 +136,12 @@ export function Characteristics() {
]);
const enginePowerCoefficient = coefficient(
[
hasEngineAccelerator && (tank.type === 'light' || tank.type === 'medium'),
hasEngineAccelerator && (tank.type === 'lightTank' || tank.type === 'mediumTank'),
0.05,
],
[
hasEngineAccelerator &&
(tank.type === 'heavy' || tank.type === 'tankDestroyer'),
(tank.type === 'heavyTank' || tank.type === 'AT-SPG'),
0.07,
],
[hasEnginePowerBoost, 0.2],
@@ -163,7 +163,7 @@ export function Characteristics() {
const viewRangeCoefficient =
coefficient([
hasImprovedOptics,
tank.type === 'tankDestroyer' ? 0.05 : tank.type === 'heavy' ? 0.07 : 0.1,
tank.type === 'AT-SPG' ? 0.05 : tank.type === 'heavyTank' ? 0.07 : 0.1,
]) * coefficient([true, progressiveStat(commanderMastery)]);
const fireChanceCoefficient = coefficient([hasProtectiveKit, -0.2]);
@@ -180,17 +180,17 @@ export function Characteristics() {
const camouflageSumMoving = sum(
[
hasCamouflageNet,
tank.type === 'heavy'
tank.type === 'heavyTank'
? 0.03
: tank.type === 'tankDestroyer'
: tank.type === 'AT-SPG'
? 0.07
: 0.05,
],
[
camouflage,
tank.type === 'tankDestroyer'
tank.type === 'AT-SPG'
? 0.04
: tank.type === 'heavy'
: tank.type === 'heavyTank'
? 0.03
: 0.02,
],
@@ -199,17 +199,17 @@ export function Characteristics() {
[
hasCamouflageNet,
2 *
(tank.type === 'heavy'
(tank.type === 'heavyTank'
? 0.03
: tank.type === 'tankDestroyer'
: tank.type === 'AT-SPG'
? 0.07
: 0.05),
],
[
camouflage,
tank.type === 'tankDestroyer'
tank.type === 'AT-SPG'
? 0.04
: tank.type === 'heavy'
: tank.type === 'heavyTank'
? 0.03
: 0.02,
],
@@ -15,7 +15,7 @@ import {
} from '@radix-ui/themes';
import { go } from 'fuzzysort';
import { use, useEffect, useMemo, useRef, useState } from 'react';
import { TankType, TreeType } from '../../../../../components/Tanks';
import { TANK_TYPES, TreeType } from '../../../../../components/Tanks';
import { resolveNearPenetration } from '../../../../../core/blitz/resolveNearPenetration';
import { asset } from '../../../../../core/blitzkrieg/asset';
import { modelDefinitions } from '../../../../../core/blitzkrieg/modelDefinitions';
@@ -49,7 +49,6 @@ interface TankSearchProps {
onSelect?: (tank: TankDefinition) => void;
}
const tankTypeOrder: TankType[] = ['light', 'medium', 'heavy', 'tankDestroyer'];
const treeTypeOrder: TreeType[] = ['researchable', 'premium', 'collector'];
export function TankSearch({ compact, onSelect = () => {} }: TankSearchProps) {
@@ -70,7 +69,7 @@ export function TankSearch({ compact, onSelect = () => {} }: TankSearchProps) {
)
.sort(
(a, b) =>
(tankTypeOrder.indexOf(a.type) - tankTypeOrder.indexOf(b.type)) *
(TANK_TYPES.indexOf(a.type) - TANK_TYPES.indexOf(b.type)) *
(sort.direction === 'descending' ? -1 : 1),
)
.sort(