mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-21 02:37:05 +02:00
fix: some linting for new proto 4
This commit is contained in:
1 parent
f14ca394b5
commit
53a9c5f2de
22 files changed
+155
-133
No files matched your search
@@ -52,6 +52,7 @@
|
||||
},
|
||||
|
||||
"tank_class_short": {
|
||||
"-1": "unrecognized",
|
||||
"0": "Light",
|
||||
"1": "Medium",
|
||||
"2": "Heavy",
|
||||
@@ -67,9 +68,10 @@
|
||||
},
|
||||
|
||||
"tree_type": {
|
||||
"researchable": "Tech tree",
|
||||
"premium": "Premium",
|
||||
"collector": "Collector"
|
||||
"-1": "unrecognized",
|
||||
"0": "Tech tree",
|
||||
"1": "Premium",
|
||||
"2": "Collector"
|
||||
},
|
||||
|
||||
"regions": {
|
||||
|
||||
@@ -98,7 +98,8 @@ export function ArmorPlateDisplay() {
|
||||
const { protagonist } = duelStore.getState();
|
||||
const tank = draft.model;
|
||||
const turret = tank.turrets[protagonist.turret.id];
|
||||
const gun = turret.guns[protagonist.gun.id];
|
||||
const gun =
|
||||
turret.guns[protagonist.gun.gunType!.value.base.id];
|
||||
const track = tank.tracks[protagonist.track.id];
|
||||
|
||||
console.log(highlightArmor.name);
|
||||
@@ -152,8 +153,12 @@ export function ArmorPlateDisplay() {
|
||||
const turret = tank.turrets[protagonist.turret.id];
|
||||
const initialTurret =
|
||||
initialTank.turrets[protagonist.turret.id];
|
||||
const gun = turret.guns[protagonist.gun.id];
|
||||
const initialGun = initialTurret.guns[protagonist.gun.id];
|
||||
const gun =
|
||||
turret.guns[protagonist.gun.gunType!.value.base.id];
|
||||
const initialGun =
|
||||
initialTurret.guns[
|
||||
protagonist.gun.gunType!.value.base.id
|
||||
];
|
||||
const track = tank.tracks[protagonist.track.id];
|
||||
const initialTrack =
|
||||
initialTank.tracks[protagonist.track.id];
|
||||
|
||||
+4
-7
@@ -1,5 +1,4 @@
|
||||
import {
|
||||
resolveNearPenetration,
|
||||
resolvePenetrationCoefficient,
|
||||
type ShellDefinition,
|
||||
} from '@blitzkit/core';
|
||||
@@ -51,9 +50,7 @@ export function SpacedArmorSubExternal({
|
||||
|
||||
useEffect(() => {
|
||||
function handleShellChange(shell: ShellDefinition) {
|
||||
material.uniforms.penetration.value = resolveNearPenetration(
|
||||
shell.penetration,
|
||||
);
|
||||
material.uniforms.penetration.value = shell.penetration.near;
|
||||
}
|
||||
async function handleProtagonistEquipmentChange(
|
||||
equipment: EquipmentMatrix,
|
||||
@@ -61,7 +58,7 @@ export function SpacedArmorSubExternal({
|
||||
const duel = duelStore.getState();
|
||||
const hasEnhancedArmor = await hasEquipment(
|
||||
110,
|
||||
duel.protagonist.tank.equipment,
|
||||
duel.protagonist.tank.equipmentPreset,
|
||||
equipment,
|
||||
);
|
||||
material.uniforms.thickness.value = hasEnhancedArmor
|
||||
@@ -71,10 +68,10 @@ export function SpacedArmorSubExternal({
|
||||
async function handleAntagonistEquipmentChange(equipment: EquipmentMatrix) {
|
||||
const duel = duelStore.getState();
|
||||
const shell = duel.antagonist.shell;
|
||||
const penetration = resolveNearPenetration(shell.penetration);
|
||||
const penetration = shell.penetration.near;
|
||||
const hasCalibratedShells = await hasEquipment(
|
||||
103,
|
||||
duel.antagonist.tank.equipment,
|
||||
duel.antagonist.tank.equipmentPreset,
|
||||
equipment,
|
||||
);
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ export function Body({ stats }: BodyProps) {
|
||||
<StickyColumnHeaderCell key={key} top={137}>
|
||||
<Flex justify="center">
|
||||
<Flex>
|
||||
{gun.gunType!.value.gun.shells.map(
|
||||
{gun.gunType!.value.base.shells.map(
|
||||
(thisShell, shellIndex) => (
|
||||
<IconButton
|
||||
color={thisShell.id === shell.id ? undefined : 'gray'}
|
||||
@@ -43,12 +43,12 @@ export function Body({ stats }: BodyProps) {
|
||||
shellIndex === 0 ? undefined : 0,
|
||||
borderTopRightRadius:
|
||||
shellIndex ===
|
||||
gun.gunType!.value.gun.shells.length - 1
|
||||
gun.gunType!.value.base.shells.length - 1
|
||||
? undefined
|
||||
: 0,
|
||||
borderBottomRightRadius:
|
||||
shellIndex ===
|
||||
gun.gunType!.value.gun.shells.length - 1
|
||||
gun.gunType!.value.base.shells.length - 1
|
||||
? undefined
|
||||
: 0,
|
||||
marginLeft: shellIndex === 0 ? 0 : -1,
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import type { ConsumableEntry } from '@blitzkit/core/src/blitzkit/consumableDefinitions';
|
||||
import type { Consumable } from '@blitzkit/core';
|
||||
import { Flex, type FlexProps } from '@radix-ui/themes';
|
||||
import { ConsumableButton } from './ModuleButtons/ConsumableButton';
|
||||
|
||||
type ConsumablesManagerProps = FlexProps & {
|
||||
consumables: ConsumableEntry[];
|
||||
consumables: Consumable[];
|
||||
selected: number[];
|
||||
onConsumablesChange?: (consumables: number[]) => void;
|
||||
disabled?: boolean;
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { asset } from '@blitzkit/core';
|
||||
import { consumableDefinitions } from '@blitzkit/core/src/blitzkit/consumableDefinitions';
|
||||
import { asset, fetchConsumableDefinitions } from '@blitzkit/core';
|
||||
import { ClockIcon, ReloadIcon } from '@radix-ui/react-icons';
|
||||
import { Flex, Text } from '@radix-ui/themes';
|
||||
import { useDelta } from '../../hooks/useDelta';
|
||||
@@ -12,7 +11,7 @@ interface ConsumableButtonProps extends TankComponentButtonProps {
|
||||
cooldown?: number;
|
||||
}
|
||||
|
||||
const awaitedConsumableDefinitions = await consumableDefinitions;
|
||||
const consumableDefinitions = await fetchConsumableDefinitions();
|
||||
|
||||
export function ConsumableButton({
|
||||
consumable,
|
||||
@@ -26,7 +25,7 @@ export function ConsumableButton({
|
||||
return (
|
||||
<GenericTankComponentButton
|
||||
style={{ width: '6rem' }}
|
||||
tooltip={awaitedConsumableDefinitions[consumable].name}
|
||||
tooltip={consumableDefinitions.consumables[consumable].name}
|
||||
icon={asset(`icons/consumables/${consumable}.webp`)}
|
||||
{...props}
|
||||
>
|
||||
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
import { asset } from '@blitzkit/core';
|
||||
import { asset, TankType } from '@blitzkit/core';
|
||||
import { Flex, Heading, Slider, TextField } from '@radix-ui/themes';
|
||||
import { clamp, debounce } from 'lodash-es';
|
||||
import { useEffect, useMemo, useRef, useState } from 'react';
|
||||
@@ -78,7 +78,7 @@ export function Miscellaneous() {
|
||||
}}
|
||||
/>
|
||||
|
||||
{tank.treeType === 'researchable' && (
|
||||
{tank.type === TankType.RESEARCHABLE && (
|
||||
<Flex
|
||||
align="center"
|
||||
direction="column"
|
||||
|
||||
+16
-14
@@ -37,26 +37,28 @@ export function Controls() {
|
||||
const antagonistTurretModelDefinition =
|
||||
antagonistModelDefinition.turrets[antagonist.turret.id];
|
||||
const protagonistGunModelDefinition =
|
||||
protagonistTurretModelDefinition.guns[protagonist.gun.id];
|
||||
protagonistTurretModelDefinition.guns[
|
||||
protagonist.gun.gunType!.value.base.id
|
||||
];
|
||||
const protagonistHullOrigin = new Vector3(
|
||||
protagonistTrackModelDefinition.origin[0],
|
||||
protagonistTrackModelDefinition.origin[1],
|
||||
-protagonistTrackModelDefinition.origin[2],
|
||||
protagonistTrackModelDefinition.origin.x,
|
||||
protagonistTrackModelDefinition.origin.y,
|
||||
-protagonistTrackModelDefinition.origin.z,
|
||||
);
|
||||
const protagonistTurretOrigin = new Vector3(
|
||||
protagonistModelDefinition.turretOrigin[0],
|
||||
protagonistModelDefinition.turretOrigin[1],
|
||||
-protagonistModelDefinition.turretOrigin[2],
|
||||
protagonistModelDefinition.turretOrigin.x,
|
||||
protagonistModelDefinition.turretOrigin.y,
|
||||
-protagonistModelDefinition.turretOrigin.z,
|
||||
);
|
||||
const protagonistGunOrigin = new Vector3(
|
||||
protagonistTurretModelDefinition.gunOrigin[0],
|
||||
protagonistTurretModelDefinition.gunOrigin[1],
|
||||
-protagonistTurretModelDefinition.gunOrigin[2],
|
||||
protagonistTurretModelDefinition.gunOrigin.x,
|
||||
protagonistTurretModelDefinition.gunOrigin.y,
|
||||
-protagonistTurretModelDefinition.gunOrigin.z,
|
||||
);
|
||||
const antagonistGunHeight =
|
||||
protagonistTrackModelDefinition.origin[1] +
|
||||
antagonistModelDefinition.turretOrigin[1] +
|
||||
antagonistTurretModelDefinition.gunOrigin[1];
|
||||
protagonistTrackModelDefinition.origin.y +
|
||||
antagonistModelDefinition.turretOrigin.y +
|
||||
antagonistTurretModelDefinition.gunOrigin.y;
|
||||
const [autoRotate, setAutoRotate] = useState(true);
|
||||
|
||||
useEffect(() => {
|
||||
@@ -76,7 +78,7 @@ export function Controls() {
|
||||
const duel = duelStore.getState();
|
||||
const hasImprovedVerticalStabilizer = await hasEquipment(
|
||||
122,
|
||||
duel.protagonist.tank.equipment,
|
||||
duel.protagonist.tank.equipmentPreset,
|
||||
duel.protagonist.equipmentMatrix,
|
||||
);
|
||||
|
||||
|
||||
+6
-5
@@ -1,4 +1,4 @@
|
||||
import { BlitzkitResponse, StarsInt } from '@blitzkit/core';
|
||||
import type { BlitzkitResponse, StarsInt } from '@blitzkit/core';
|
||||
import { PaperPlaneIcon } from '@radix-ui/react-icons';
|
||||
import {
|
||||
AlertDialog,
|
||||
@@ -9,8 +9,9 @@ import {
|
||||
Text,
|
||||
} from '@radix-ui/themes';
|
||||
import { useState } from 'react';
|
||||
import * as App from '../../../../../../../../../../stores/app';
|
||||
import * as Duel from '../../../../../../../../../../stores/duel';
|
||||
import { App } from '../../../../../../stores/app';
|
||||
import { Duel } from '../../../../../../stores/duel';
|
||||
import { $wargamingLogin } from '../../../../../../stores/wargamingLogin';
|
||||
import { Stars } from '../../Stars';
|
||||
|
||||
export function VoteCaster() {
|
||||
@@ -98,9 +99,9 @@ export function VoteCaster() {
|
||||
survivability === null)
|
||||
}
|
||||
onClick={() => {
|
||||
const wargaming = appStore.getState().logins.wargaming;
|
||||
const wargaming = $wargamingLogin.get();
|
||||
|
||||
if (!wargaming) {
|
||||
if (!wargaming.token) {
|
||||
return setShowDialogue(false);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
import {
|
||||
assertSecret,
|
||||
asset,
|
||||
modelDefinitions,
|
||||
provisionDefinitions,
|
||||
fetchModelDefinitions,
|
||||
fetchProvisionDefinitions,
|
||||
TankPriceType,
|
||||
TankType,
|
||||
} from '@blitzkit/core';
|
||||
import strings from '@blitzkit/core/lang/en-US.json';
|
||||
import { ChevronLeftIcon, MixIcon, UpdateIcon } from '@radix-ui/react-icons';
|
||||
@@ -17,8 +19,8 @@ import { ScienceIcon } from '../../ScienceIcon';
|
||||
import { TankSearch } from '../../TankSearch';
|
||||
import { Listing } from './components/Listing';
|
||||
|
||||
const awaitedProvisionDefinitions = await provisionDefinitions;
|
||||
const awaitedModelDefinitions = await modelDefinitions;
|
||||
const provisionDefinitions = await fetchProvisionDefinitions();
|
||||
const modelDefinitions = await fetchModelDefinitions();
|
||||
|
||||
export function MetaSection() {
|
||||
const developerMode = App.useDeferred((state) => state.developerMode, false);
|
||||
@@ -78,12 +80,12 @@ export function MetaSection() {
|
||||
onSelect={(tank) => {
|
||||
setShowSwapDialog(false);
|
||||
mutateTankopediaEphemeral((draft) => {
|
||||
draft.model = awaitedModelDefinitions[tank.id];
|
||||
draft.model = modelDefinitions.models[tank.id];
|
||||
});
|
||||
mutateDuel((draft) => {
|
||||
draft.protagonist = tankToDuelMember(
|
||||
tank,
|
||||
awaitedProvisionDefinitions,
|
||||
provisionDefinitions,
|
||||
);
|
||||
});
|
||||
|
||||
@@ -130,14 +132,14 @@ export function MetaSection() {
|
||||
<Listing
|
||||
label="Type"
|
||||
color={
|
||||
protagonist.treeType === 'collector'
|
||||
protagonist.type === TankType.COLLECTOR
|
||||
? 'blue'
|
||||
: protagonist.treeType === 'premium'
|
||||
: protagonist.type === TankType.PREMIUM
|
||||
? 'amber'
|
||||
: undefined
|
||||
}
|
||||
>
|
||||
{strings.common.tree_type[protagonist.treeType]}
|
||||
{strings.common.tree_type[protagonist.type]}
|
||||
</Listing>
|
||||
</Flex>
|
||||
|
||||
@@ -147,7 +149,7 @@ export function MetaSection() {
|
||||
<Code>{protagonist.id}</Code>
|
||||
</Listing>
|
||||
)}
|
||||
{protagonist.treeType === 'premium' && (
|
||||
{protagonist.type === TankType.PREMIUM && (
|
||||
<Listing label="Purchase price">
|
||||
<Flex align="center" gap="1">
|
||||
{protagonist.price.value / 400}
|
||||
@@ -161,7 +163,7 @@ export function MetaSection() {
|
||||
)}
|
||||
<Listing
|
||||
label={`${
|
||||
protagonist.treeType === 'researchable'
|
||||
protagonist.type === TankType.RESEARCHABLE
|
||||
? 'Purchase'
|
||||
: 'Restoration'
|
||||
} price`}
|
||||
@@ -170,10 +172,12 @@ export function MetaSection() {
|
||||
{protagonist.price.value.toLocaleString()}
|
||||
<img
|
||||
style={{ width: '1em', height: '1em' }}
|
||||
alt={protagonist.price.type}
|
||||
alt={TankPriceType[protagonist.price.type]}
|
||||
src={asset(
|
||||
`icons/currencies/${
|
||||
protagonist.price.type === 'gold' ? 'gold' : 'silver'
|
||||
protagonist.price.type === TankPriceType.GOLD
|
||||
? 'gold'
|
||||
: 'silver'
|
||||
}.webp`,
|
||||
)}
|
||||
/>
|
||||
@@ -184,10 +188,12 @@ export function MetaSection() {
|
||||
{(protagonist.price.value / 2).toLocaleString()}
|
||||
<img
|
||||
style={{ width: '1em', height: '1em' }}
|
||||
alt={protagonist.price.type}
|
||||
alt={TankPriceType[protagonist.price.type]}
|
||||
src={asset(
|
||||
`icons/currencies/${
|
||||
protagonist.price.type === 'gold' ? 'gold' : 'silver'
|
||||
protagonist.price.type === TankPriceType.GOLD
|
||||
? 'gold'
|
||||
: 'silver'
|
||||
}.webp`,
|
||||
)}
|
||||
/>
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import {
|
||||
asset,
|
||||
averageDefinitions,
|
||||
fetchAverageDefinitions,
|
||||
fetchTankDefinitions,
|
||||
formatCompact,
|
||||
tankDefinitions,
|
||||
TIER_ROMAN_NUMERALS,
|
||||
} from '@blitzkit/core';
|
||||
import { Box, Flex, Link, Text } from '@radix-ui/themes';
|
||||
@@ -14,13 +14,13 @@ interface NodeProps {
|
||||
highlight?: boolean;
|
||||
}
|
||||
|
||||
const awaitedTankDefinitions = await tankDefinitions;
|
||||
const awaitedAverageDefinitions = await averageDefinitions;
|
||||
const tankDefinitions = await fetchTankDefinitions();
|
||||
const averageDefinitions = await fetchAverageDefinitions();
|
||||
|
||||
export function Node({ id, highlight, nextIds }: NodeProps) {
|
||||
const xpMultiplier = TankopediaEphemeral.use((state) => state.xpMultiplier);
|
||||
const tank = awaitedTankDefinitions[id];
|
||||
const nextTanks = nextIds?.map((id) => awaitedTankDefinitions[id]);
|
||||
const tank = tankDefinitions.tanks[id];
|
||||
const nextTanks = nextIds?.map((id) => tankDefinitions.tanks[id]);
|
||||
const thisTankXp =
|
||||
tank.xp === undefined || tank.tier === 1 ? 0 : tank.xp! / xpMultiplier;
|
||||
const nextTanksXp = nextTanks?.reduce(
|
||||
@@ -29,7 +29,7 @@ export function Node({ id, highlight, nextIds }: NodeProps) {
|
||||
(tank.xp === undefined || tank.tier === 1 ? 0 : tank.xp! / xpMultiplier),
|
||||
0,
|
||||
);
|
||||
const averages = awaitedAverageDefinitions.averages[tank.id]?.mu;
|
||||
const averages = averageDefinitions.averages[tank.id]?.mu;
|
||||
const averageXp = averages ? averages.xp / averages.battles : undefined;
|
||||
const games =
|
||||
averages && nextTanks ? Math.round(nextTanksXp! / averageXp!) : undefined;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { asset, imgur, tankDefinitions } from '@blitzkit/core';
|
||||
import { asset, fetchTankDefinitions, imgur, TankType } from '@blitzkit/core';
|
||||
import { CaretLeftIcon, CaretRightIcon, PlusIcon } from '@radix-ui/react-icons';
|
||||
import { Flex, Heading, IconButton, ScrollArea, Text } from '@radix-ui/themes';
|
||||
import { Fragment, useEffect, useMemo, useRef, useState } from 'react';
|
||||
@@ -9,7 +9,7 @@ import { Node } from './components/Node';
|
||||
|
||||
type Line = number[];
|
||||
|
||||
const awaitedTankDefinitions = await tankDefinitions;
|
||||
const tankDefinitions = await fetchTankDefinitions();
|
||||
|
||||
export const XP_MULTIPLIERS = [1, 2, 3, 4, 5, 10];
|
||||
|
||||
@@ -20,7 +20,7 @@ export function TechTreeSection() {
|
||||
const container = useRef<HTMLDivElement>(null);
|
||||
const lines = useMemo(() => {
|
||||
function extend(line: Line): Line[] {
|
||||
const root = awaitedTankDefinitions[line.at(-1)!];
|
||||
const root = tankDefinitions.tanks[line.at(-1)!];
|
||||
|
||||
if (root.ancestors === undefined || root.tier === 1) {
|
||||
return [line];
|
||||
@@ -28,7 +28,7 @@ export function TechTreeSection() {
|
||||
if (root.ancestors.length === 1 || root.tier === 2) {
|
||||
line.push(
|
||||
root.ancestors.find(
|
||||
(ancestor) => !awaitedTankDefinitions[ancestor].deprecated,
|
||||
(ancestor) => !tankDefinitions.tanks[ancestor].deprecated,
|
||||
) ?? root.ancestors[0],
|
||||
);
|
||||
return extend(line);
|
||||
@@ -53,14 +53,14 @@ export function TechTreeSection() {
|
||||
const totalXp = line.reduce(
|
||||
(xp, id) =>
|
||||
xp +
|
||||
(awaitedTankDefinitions[id].xp === undefined ||
|
||||
awaitedTankDefinitions[id].tier === 1
|
||||
(tankDefinitions.tanks[id].xp === undefined ||
|
||||
tankDefinitions.tanks[id].tier === 1
|
||||
? 0
|
||||
: awaitedTankDefinitions[id].xp),
|
||||
: tankDefinitions.tanks[id].xp),
|
||||
0,
|
||||
);
|
||||
const totalCredits = line.reduce(
|
||||
(credits, id) => credits + awaitedTankDefinitions[id].price.value,
|
||||
(credits, id) => credits + tankDefinitions.tanks[id].price.value,
|
||||
0,
|
||||
);
|
||||
|
||||
@@ -70,7 +70,7 @@ export function TechTreeSection() {
|
||||
});
|
||||
|
||||
if (
|
||||
master.treeType !== 'researchable' ||
|
||||
master.type !== TankType.RESEARCHABLE ||
|
||||
master.ancestors === undefined ||
|
||||
master.ancestors.length === 0
|
||||
) {
|
||||
@@ -163,7 +163,7 @@ export function TechTreeSection() {
|
||||
<Flex align="center" gap="2" justify="center" p="4">
|
||||
{line.map((id, index) => {
|
||||
const last = index === line.length - 1;
|
||||
const tank = awaitedTankDefinitions[id];
|
||||
const tank = tankDefinitions.tanks[id];
|
||||
|
||||
return (
|
||||
<Fragment key={id}>
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
import { reviews, youtubers } from '@blitzkit/core';
|
||||
import { fetchReviews, youtubers } from '@blitzkit/core';
|
||||
import { Box, Flex, Heading, Link, Text } from '@radix-ui/themes';
|
||||
import { Var } from '../../core/radix/var';
|
||||
import { Duel } from '../../stores/duel';
|
||||
import { PageWrapper } from '../PageWrapper';
|
||||
import { VerifiedIcon } from '../VerifiedIcon';
|
||||
|
||||
const awaitedReviews = await reviews;
|
||||
const reviews = await fetchReviews();
|
||||
|
||||
export function VideoSection() {
|
||||
const tank = Duel.use((state) => state.protagonist.tank);
|
||||
const videos = awaitedReviews.reviews[tank.id]?.videos;
|
||||
const videos = reviews.reviews[tank.id]?.videos;
|
||||
|
||||
if (!videos) return null;
|
||||
|
||||
|
||||
@@ -1,16 +1,18 @@
|
||||
import {
|
||||
CompositeStatsKey,
|
||||
previewCompositeStat,
|
||||
TankClass,
|
||||
TankDefinition,
|
||||
TankType,
|
||||
type CompositeStatsKey,
|
||||
} from '@blitzkit/core';
|
||||
import strings from '@blitzkit/core/lang/en-US.json';
|
||||
import { amberDark, blueDark } from '@radix-ui/colors';
|
||||
import { Flex, Text } from '@radix-ui/themes';
|
||||
import { times } from 'lodash-es';
|
||||
import { ReactNode } from 'react';
|
||||
import { toRadiusVar } from '../../../website-legacy/src/core/radix/utils';
|
||||
import { useEmbedStateCurry } from '../../../website-legacy/src/stores/embedState/utilities';
|
||||
import type { ReactNode } from 'react';
|
||||
import { breakdownConfig } from '../constants/embeds';
|
||||
import { toRadiusVar } from '../core/radix/utils';
|
||||
import { useEmbedStateCurry } from '../stores/embedState/utilities';
|
||||
import { ClassHeavy } from './ClassIcon/components/ClassHeavy';
|
||||
import { ClassLight } from './ClassIcon/components/ClassLight';
|
||||
import { ClassMedium } from './ClassIcon/components/ClassMedium';
|
||||
@@ -63,12 +65,12 @@ export function BreakdownEmbedCard({ tank }: BreakdownEmbedCardProps) {
|
||||
style:
|
||||
tank === null
|
||||
? undefined
|
||||
: tank.treeType === 'researchable' ||
|
||||
: tank.type === TankType.RESEARCHABLE ||
|
||||
!useState('cardTitleTypeColor')
|
||||
? undefined
|
||||
: {
|
||||
color:
|
||||
tank.treeType === 'premium'
|
||||
tank.type === TankType.PREMIUM
|
||||
? amberDark.amber11
|
||||
: blueDark.blue11,
|
||||
},
|
||||
@@ -77,16 +79,16 @@ export function BreakdownEmbedCard({ tank }: BreakdownEmbedCardProps) {
|
||||
<Flex align="center" gap="1">
|
||||
{useState('cardTitleClassIcon') && tank !== null && (
|
||||
<>
|
||||
{tank.class === 'lightTank' && (
|
||||
{tank.class === TankClass.LIGHT && (
|
||||
<ClassLight width="1em" height="1em" />
|
||||
)}
|
||||
{tank.class === 'mediumTank' && (
|
||||
{tank.class === TankClass.MEDIUM && (
|
||||
<ClassMedium width="1em" height="1em" />
|
||||
)}
|
||||
{tank.class === 'heavyTank' && (
|
||||
{tank.class === TankClass.HEAVY && (
|
||||
<ClassHeavy width="1em" height="1em" />
|
||||
)}
|
||||
{tank.class === 'AT-SPG' && (
|
||||
{tank.class === TankClass.TANK_DESTROYER && (
|
||||
<ClassTankDestroyer width="1em" height="1em" />
|
||||
)}
|
||||
</>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { Vector3, type Vector3Tuple } from 'three';
|
||||
import type { Vector3 as BlitzkitVector3 } from '@blitzkit/core';
|
||||
import { Vector3 as THREEVector3 } from 'three';
|
||||
import { rotateDavaVector } from './rotateDavaVector';
|
||||
|
||||
export function correctZYTuple(tuple: Vector3Tuple) {
|
||||
return rotateDavaVector(new Vector3(tuple[0], tuple[1], -tuple[2]));
|
||||
export function correctZYTuple(tuple: BlitzkitVector3) {
|
||||
return rotateDavaVector(new THREEVector3(tuple.x, tuple.y, -tuple.z));
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
import { equipmentDefinitions } from '@blitzkit/core';
|
||||
import { fetchEquipmentDefinitions } from '@blitzkit/core';
|
||||
import type { EquipmentMatrix } from '../../stores/duel';
|
||||
|
||||
export async function hasEquipment(
|
||||
@@ -6,14 +6,17 @@ export async function hasEquipment(
|
||||
equipmentPreset: string,
|
||||
equipmentMatrix: EquipmentMatrix,
|
||||
) {
|
||||
const awaitedEquipmentDefinitions = await equipmentDefinitions;
|
||||
const presetRows = awaitedEquipmentDefinitions.presets[equipmentPreset];
|
||||
return presetRows.some((equipmentRow, rowIndex) => {
|
||||
return equipmentRow.some((equipment, columnIndex) => {
|
||||
const choice = equipmentMatrix[rowIndex][columnIndex];
|
||||
if (choice === 0) return false;
|
||||
const equipped = equipment[choice === -1 ? 0 : 1];
|
||||
return equipped === id;
|
||||
});
|
||||
const equipmentDefinitions = await fetchEquipmentDefinitions();
|
||||
const preset = equipmentDefinitions.presets[equipmentPreset];
|
||||
return preset.slots.some((slot, index) => {
|
||||
const row = Math.floor(index / 3);
|
||||
const column = index % 3;
|
||||
const choice = equipmentMatrix[row][column];
|
||||
|
||||
if (choice === 0) return false;
|
||||
|
||||
const equipped = slot[choice === -1 ? 'left' : 'right'];
|
||||
|
||||
return equipped === id;
|
||||
});
|
||||
}
|
||||
@@ -2,18 +2,18 @@ import type { GunDefinition } from '@blitzkit/core';
|
||||
|
||||
export function resolveReload(gun: GunDefinition) {
|
||||
if (gun.gunType!.$case === 'regular') {
|
||||
return gun.gunType!.value.regular.reload;
|
||||
return gun.gunType!.value.extension.reload;
|
||||
} else if (gun.gunType!.$case === 'autoLoader') {
|
||||
return (
|
||||
gun.gunType!.value.autoLoader.clipReload +
|
||||
(gun.gunType!.value.autoLoader.shellCount - 1) *
|
||||
gun.gunType!.value.autoLoader.intraClip
|
||||
gun.gunType!.value.extension.clipReload +
|
||||
(gun.gunType!.value.extension.shellCount - 1) *
|
||||
gun.gunType!.value.extension.intraClip
|
||||
);
|
||||
} else {
|
||||
return (
|
||||
gun.gunType!.value.autoReloader.shellReloads.reduce((a, b) => a + b, 0) +
|
||||
(gun.gunType!.value.autoReloader.shellCount - 1) *
|
||||
gun.gunType!.value.autoReloader.intraClip
|
||||
gun.gunType!.value.extension.shellReloads.reduce((a, b) => a + b, 0) +
|
||||
(gun.gunType!.value.extension.shellCount - 1) *
|
||||
gun.gunType!.value.extension.intraClip
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -37,11 +37,11 @@ export function tankToDuelMember(
|
||||
infinityFallback(PROVISION_PREFERENCES.indexOf(b.id)),
|
||||
)
|
||||
.sort((a, b) => (b.crew ?? 0) - (a.crew ?? 0))
|
||||
.slice(0, tank.provisions)
|
||||
.slice(0, tank.maxProvisions)
|
||||
.map(({ id }) => id),
|
||||
engine: tank.engines.at(-1)!,
|
||||
gun,
|
||||
shell: tank.turrets.at(-1)!.guns.at(-1)!.shells[0],
|
||||
shell: tank.turrets.at(-1)!.guns.at(-1)!.gunType!.value.base.shells[0],
|
||||
tank,
|
||||
track: tank.tracks.at(-1)!,
|
||||
yaw: 0,
|
||||
|
||||
@@ -1,31 +1,31 @@
|
||||
import { equipmentDefinitions } from '@blitzkit/core';
|
||||
import { fetchEquipmentDefinitions } from '@blitzkit/core';
|
||||
import { useMemo } from 'react';
|
||||
import { Duel } from '../stores/duel';
|
||||
|
||||
const awaitedEquipmentDefinitions = await equipmentDefinitions;
|
||||
const equipmentDefinitions = await fetchEquipmentDefinitions();
|
||||
|
||||
export function useEquipment(id: number, antagonist = false) {
|
||||
const member = Duel.use(
|
||||
(state) => state[antagonist ? 'antagonist' : 'protagonist']!,
|
||||
);
|
||||
const equipmentRows =
|
||||
awaitedEquipmentDefinitions.presets[member.tank.equipment];
|
||||
const preset = equipmentDefinitions.presets[member.tank.equipmentPreset];
|
||||
const equipmentMatrix = Duel.use(
|
||||
(state) =>
|
||||
state[antagonist ? 'antagonist' : 'protagonist']!.equipmentMatrix,
|
||||
);
|
||||
const value = useMemo(
|
||||
() =>
|
||||
equipmentRows.some((equipmentRow, rowIndex) => {
|
||||
return equipmentRow.some((equipment, columnIndex) => {
|
||||
const choice = equipmentMatrix[rowIndex][columnIndex];
|
||||
if (choice === 0) return false;
|
||||
const equipped = equipment[choice === -1 ? 0 : 1];
|
||||
return equipped === id;
|
||||
});
|
||||
}),
|
||||
[equipmentMatrix, member.tank],
|
||||
);
|
||||
const value = useMemo(() => {
|
||||
return preset.slots.some((slot, index) => {
|
||||
const row = Math.floor(index / 3);
|
||||
const column = index % 3;
|
||||
const choice = equipmentMatrix[row][column];
|
||||
|
||||
if (choice === 0) return false;
|
||||
|
||||
const equipped = slot[choice === -1 ? 'left' : 'right'];
|
||||
|
||||
return equipped === id;
|
||||
});
|
||||
}, [equipmentMatrix, member.tank]);
|
||||
|
||||
return value;
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
import * as Duel from '../stores/duel';
|
||||
import { Duel } from '../stores/duel';
|
||||
|
||||
export function useProvision(id: number) {
|
||||
const provisions = Duel.use((state) => state.protagonist.provisions);
|
||||
|
||||
@@ -52,12 +52,16 @@ export function useTankTransform(
|
||||
.applyAxisAngle(new Vector3(0, 0, 1), yaw);
|
||||
turretRotation.set(0, 0, yaw);
|
||||
|
||||
if (tankModelDefinition.turretRotation) {
|
||||
if (tankModelDefinition.initialTurretRotation) {
|
||||
const initialPitch = -degToRad(
|
||||
tankModelDefinition.turretRotation.pitch,
|
||||
tankModelDefinition.initialTurretRotation.pitch,
|
||||
);
|
||||
const initialYaw = -degToRad(
|
||||
tankModelDefinition.initialTurretRotation.yaw,
|
||||
);
|
||||
const initialRoll = -degToRad(
|
||||
tankModelDefinition.initialTurretRotation.roll,
|
||||
);
|
||||
const initialYaw = -degToRad(tankModelDefinition.turretRotation.yaw);
|
||||
const initialRoll = -degToRad(tankModelDefinition.turretRotation.roll);
|
||||
|
||||
turretPosition
|
||||
.applyAxisAngle(I_HAT, initialPitch)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { persistentMap } from '@nanostores/persistent';
|
||||
|
||||
type PatreonLogin =
|
||||
type WargamingLogin =
|
||||
| {
|
||||
token: undefined;
|
||||
}
|
||||
@@ -10,6 +10,6 @@ type PatreonLogin =
|
||||
expires: string;
|
||||
};
|
||||
|
||||
export const $wargamingLogin = persistentMap<PatreonLogin>('wargaming:', {
|
||||
export const $wargamingLogin = persistentMap<WargamingLogin>('wargaming:', {
|
||||
token: undefined,
|
||||
});
|
||||
Reference in new issue
Block a user