mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-23 19:49:50 +02:00
fix: some linting for new proto 3
This commit is contained in:
1 parent
79bc259565
commit
f14ca394b5
29 files changed
+522
-418
No files matched your search
+28
-21
@@ -2,10 +2,11 @@ import {
|
||||
asset,
|
||||
coefficient,
|
||||
CREW_MEMBER_NAMES,
|
||||
equipmentDefinitions,
|
||||
CrewType,
|
||||
fetchEquipmentDefinitions,
|
||||
fetchProvisionDefinitions,
|
||||
GUN_TYPE_NAMES,
|
||||
isExplosive,
|
||||
provisionDefinitions,
|
||||
resolvePenetrationCoefficient,
|
||||
} from '@blitzkit/core';
|
||||
import { AccessibilityIcon, InfoCircledIcon } from '@radix-ui/react-icons';
|
||||
@@ -34,8 +35,8 @@ import { Ad, AdType } from '../../../../Ad';
|
||||
import { Info } from './components/Info';
|
||||
import { InfoWithDelta } from './components/InfoWithDelta';
|
||||
|
||||
const awaitedEquipmentDefinitions = await equipmentDefinitions;
|
||||
const awaitedProvisionDefinitions = await provisionDefinitions;
|
||||
const equipmentDefinitions = await fetchEquipmentDefinitions();
|
||||
const provisionDefinitions = await fetchProvisionDefinitions();
|
||||
|
||||
export function Characteristics() {
|
||||
const mutateDuel = Duel.useMutation();
|
||||
@@ -53,8 +54,8 @@ export function Characteristics() {
|
||||
const provisionCrewBonus =
|
||||
provisions.reduce(
|
||||
(total, provision) =>
|
||||
awaitedProvisionDefinitions[provision].crew
|
||||
? total + awaitedProvisionDefinitions[provision].crew! / 100
|
||||
provisionDefinitions.provisions[provision].crew
|
||||
? total + provisionDefinitions.provisions[provision].crew! / 100
|
||||
: total,
|
||||
0,
|
||||
) + (hasImprovedVentilation ? 0.08 : 0);
|
||||
@@ -73,7 +74,8 @@ export function Characteristics() {
|
||||
const stockGun = stockTurret.guns[0];
|
||||
const tankModelDefinition = useTankModelDefinition();
|
||||
const turretModelDefinition = tankModelDefinition.turrets[turret.id];
|
||||
const gunModelDefinition = turretModelDefinition.guns[gun.id];
|
||||
const gunModelDefinition =
|
||||
turretModelDefinition.guns[gun.gunType!.value.base.id];
|
||||
const stats = tankCharacteristics(
|
||||
{
|
||||
tank,
|
||||
@@ -98,8 +100,8 @@ export function Characteristics() {
|
||||
},
|
||||
{
|
||||
tankModelDefinition,
|
||||
equipmentDefinitions: awaitedEquipmentDefinitions,
|
||||
provisionDefinitions: awaitedProvisionDefinitions,
|
||||
equipmentDefinitions: equipmentDefinitions,
|
||||
provisionDefinitions: provisionDefinitions,
|
||||
},
|
||||
);
|
||||
|
||||
@@ -146,7 +148,7 @@ export function Characteristics() {
|
||||
<Heading size="5">Firepower</Heading>
|
||||
|
||||
<Flex>
|
||||
{gun.shells.map((thisShell, shellIndex) => (
|
||||
{gun.gunType!.value.base.shells.map((thisShell, shellIndex) => (
|
||||
<Tooltip content={thisShell.name} key={thisShell.id}>
|
||||
<IconButton
|
||||
color={thisShell.id === shell.id ? undefined : 'gray'}
|
||||
@@ -155,9 +157,13 @@ export function Characteristics() {
|
||||
borderTopLeftRadius: shellIndex === 0 ? undefined : 0,
|
||||
borderBottomLeftRadius: shellIndex === 0 ? undefined : 0,
|
||||
borderTopRightRadius:
|
||||
shellIndex === gun.shells.length - 1 ? undefined : 0,
|
||||
shellIndex === gun.gunType!.value.base.shells.length - 1
|
||||
? undefined
|
||||
: 0,
|
||||
borderBottomRightRadius:
|
||||
shellIndex === gun.shells.length - 1 ? undefined : 0,
|
||||
shellIndex === gun.gunType!.value.base.shells.length - 1
|
||||
? undefined
|
||||
: 0,
|
||||
marginLeft: shellIndex === 0 ? 0 : -1,
|
||||
}}
|
||||
onClick={() => {
|
||||
@@ -177,11 +183,11 @@ export function Characteristics() {
|
||||
))}
|
||||
</Flex>
|
||||
</Flex>
|
||||
<Info name="Gun type">{GUN_TYPE_NAMES[gun.type]}</Info>
|
||||
<Info name="Gun type">{GUN_TYPE_NAMES[gun.gunType!.$case]}</Info>
|
||||
<InfoWithDelta name="DPM" decimals={0} unit="hp / min">
|
||||
{stats.dpm}
|
||||
</InfoWithDelta>
|
||||
{gun.type === 'autoReloader' && (
|
||||
{gun.gunType!.$case === 'autoReloader' && (
|
||||
<InfoWithDelta
|
||||
decimals={0}
|
||||
indent
|
||||
@@ -191,10 +197,10 @@ export function Characteristics() {
|
||||
{stats.dpmEffective!}
|
||||
</InfoWithDelta>
|
||||
)}
|
||||
{gun.type !== 'regular' && (
|
||||
{gun.gunType!.$case !== 'regular' && (
|
||||
<InfoWithDelta name="Shells">{stats.shells}</InfoWithDelta>
|
||||
)}
|
||||
{gun.type === 'autoReloader' ? (
|
||||
{gun.gunType!.$case === 'autoReloader' ? (
|
||||
<>
|
||||
<Info indent name="Most optimal shell index">
|
||||
{stats.mostOptimalShellIndex! + 1}
|
||||
@@ -222,7 +228,8 @@ export function Characteristics() {
|
||||
{stats.shellReload!}
|
||||
</InfoWithDelta>
|
||||
)}
|
||||
{(gun.type === 'autoLoader' || gun.type === 'autoReloader') && (
|
||||
{(gun.gunType!.$case === 'autoLoader' ||
|
||||
gun.gunType!.$case === 'autoReloader') && (
|
||||
<InfoWithDelta
|
||||
indent
|
||||
decimals={2}
|
||||
@@ -244,8 +251,8 @@ export function Characteristics() {
|
||||
name={`At ${penetrationDistance}m`}
|
||||
>
|
||||
{lerp(
|
||||
shell.penetration[0],
|
||||
shell.penetration[1],
|
||||
shell.penetration.near,
|
||||
shell.penetration.far,
|
||||
(penetrationDistance *
|
||||
penetrationLossOverDistanceCoefficient) /
|
||||
500,
|
||||
@@ -293,7 +300,7 @@ export function Characteristics() {
|
||||
<InfoWithDelta name="Damage" unit="hp" decimals={0}>
|
||||
{stats.damage}
|
||||
</InfoWithDelta>
|
||||
{gun.type !== 'regular' && (
|
||||
{gun.gunType!.$case !== 'regular' && (
|
||||
<InfoWithDelta name="Clipping potential" indent>
|
||||
{stats.clipDamage!}
|
||||
</InfoWithDelta>
|
||||
@@ -471,7 +478,7 @@ export function Characteristics() {
|
||||
unit="%"
|
||||
decimals={0}
|
||||
>
|
||||
{(member.type === 'commander'
|
||||
{(member.type === CrewType.COMMANDER
|
||||
? commanderMastery
|
||||
: commanderMastery * 1.1) * 100}
|
||||
</InfoWithDelta>
|
||||
|
||||
+4
-5
@@ -1,6 +1,5 @@
|
||||
import {} from '@blitzkit/core';
|
||||
import { fetchConsumableDefinitions } from '@blitzkit/core';
|
||||
import { checkConsumableProvisionInclusivity } from '@blitzkit/core/src/blitzkit/checkConsumableProvisionInclusivity';
|
||||
import { consumableDefinitions } from '@blitzkit/core/src/blitzkit/consumableDefinitions';
|
||||
import { InfoCircledIcon } from '@radix-ui/react-icons';
|
||||
import {
|
||||
Button,
|
||||
@@ -15,13 +14,13 @@ import { Duel } from '../../../../stores/duel';
|
||||
import { ConsumablesManager } from '../../../ConsumablesManager';
|
||||
import { ConfigurationChildWrapper } from './ConfigurationChildWrapper';
|
||||
|
||||
const awaitedConsumableDefinitions = await consumableDefinitions;
|
||||
const consumableDefinitions = await fetchConsumableDefinitions();
|
||||
|
||||
export function Consumables() {
|
||||
const mutateDuel = Duel.useMutation();
|
||||
const protagonist = Duel.use((state) => state.protagonist);
|
||||
const consumables = Duel.use((state) => state.protagonist.consumables);
|
||||
const consumablesList = Object.values(awaitedConsumableDefinitions).filter(
|
||||
const consumablesList = Object.values(consumableDefinitions).filter(
|
||||
(consumable) =>
|
||||
checkConsumableProvisionInclusivity(
|
||||
consumable,
|
||||
@@ -74,7 +73,7 @@ export function Consumables() {
|
||||
consumables={consumablesList}
|
||||
selected={consumables}
|
||||
cooldownBooster={cooldownBooster}
|
||||
disabled={protagonist.tank.consumables === consumables.length}
|
||||
disabled={protagonist.tank.maxConsumables === consumables.length}
|
||||
hasConsumableDeliverySystem={hasConsumableDeliverySystem}
|
||||
hasHighEndConsumables={hasHighEndConsumables}
|
||||
timers
|
||||
|
||||
+88
-55
@@ -1,11 +1,14 @@
|
||||
import {
|
||||
asset,
|
||||
EngineDefinition,
|
||||
fetchTankDefinitions,
|
||||
formatCompact,
|
||||
tankDefinitions,
|
||||
GunDefinition,
|
||||
ModuleType,
|
||||
tankIcon,
|
||||
TIER_ROMAN_NUMERALS,
|
||||
type ModuleDefinition,
|
||||
type ModuleType,
|
||||
TrackDefinition,
|
||||
TurretDefinition,
|
||||
type TankDefinition,
|
||||
type Tier,
|
||||
type Unlock,
|
||||
@@ -19,8 +22,25 @@ import {
|
||||
Link,
|
||||
Text,
|
||||
} from '@radix-ui/themes';
|
||||
import { ConfigurationChildWrapper } from './ConfigurationChildWrapper';
|
||||
import { Duel } from '../../../../stores/duel';
|
||||
import { ConfigurationChildWrapper } from './ConfigurationChildWrapper';
|
||||
|
||||
type ModuleDefinition =
|
||||
| TurretDefinition
|
||||
| GunDefinition
|
||||
| TrackDefinition
|
||||
| EngineDefinition;
|
||||
|
||||
function extractModule(raw: ModuleDefinition | TankDefinition) {
|
||||
if ('gunType' in raw) {
|
||||
return raw.gunType!.value.base;
|
||||
} else
|
||||
return raw as Exclude<ModuleDefinition | TankDefinition, GunDefinition>;
|
||||
}
|
||||
|
||||
interface ModuleWithUnlocks {
|
||||
unlocks: Unlock[];
|
||||
}
|
||||
|
||||
function ModuleButton({
|
||||
tier,
|
||||
@@ -35,7 +55,7 @@ function ModuleButton({
|
||||
top: boolean;
|
||||
onClick: () => void;
|
||||
}) {
|
||||
const isTank = unlock.type === 'vehicle';
|
||||
const isTank = unlock.type === ModuleType.VEHICLE;
|
||||
const button = (
|
||||
<IconButton
|
||||
size="4"
|
||||
@@ -89,7 +109,7 @@ function ModuleButton({
|
||||
)}
|
||||
|
||||
<img
|
||||
alt={unlock.type}
|
||||
alt={ModuleType[unlock.type]}
|
||||
src={
|
||||
isTank
|
||||
? tankIcon(unlock.id)
|
||||
@@ -111,7 +131,7 @@ function ModuleButton({
|
||||
);
|
||||
}
|
||||
|
||||
const awaitedTankDefinitions = await tankDefinitions;
|
||||
const tankDefinitions = await fetchTankDefinitions();
|
||||
|
||||
export function Modules() {
|
||||
const mutateDuel = Duel.useMutation();
|
||||
@@ -136,44 +156,48 @@ export function Modules() {
|
||||
|
||||
function setByUnlock(unlock: Unlock) {
|
||||
mutateDuel((draft) => {
|
||||
if (unlock.type === 'turret') {
|
||||
if (unlock.type === ModuleType.TURRET) {
|
||||
draft.protagonist.turret = draft.protagonist.tank.turrets.find(
|
||||
(turret) => turret.id === unlock.id,
|
||||
)!;
|
||||
|
||||
if (
|
||||
!draft.protagonist.turret.guns.some(
|
||||
(gun) => gun.id === draft.protagonist.gun.id,
|
||||
(gun) =>
|
||||
gun.gunType!.value.base.id ===
|
||||
draft.protagonist.gun.gunType!.value.base.id,
|
||||
)
|
||||
) {
|
||||
draft.protagonist.gun = draft.protagonist.turret.guns.at(-1)!;
|
||||
draft.protagonist.shell = draft.protagonist.gun.shells[0];
|
||||
draft.protagonist.shell =
|
||||
draft.protagonist.gun.gunType!.value.base.shells[0];
|
||||
}
|
||||
} else if (unlock.type === 'gun') {
|
||||
} else if (unlock.type === ModuleType.GUN) {
|
||||
const gunInTurret = draft.protagonist.turret.guns.find(
|
||||
(gun) => gun.id === unlock.id,
|
||||
(gun) => gun.gunType!.value.base.id === unlock.id,
|
||||
);
|
||||
if (gunInTurret) {
|
||||
draft.protagonist.gun = gunInTurret;
|
||||
draft.protagonist.shell = gunInTurret.shells[0];
|
||||
draft.protagonist.shell = gunInTurret.gunType!.value.base.shells[0];
|
||||
} else {
|
||||
// TODO: warn somehow?
|
||||
const suitableTurret = draft.protagonist.tank.turrets.find((turret) =>
|
||||
turret.guns.some((gun) => gun.id === unlock.id),
|
||||
turret.guns.some((gun) => gun.gunType!.value.base.id === unlock.id),
|
||||
)!;
|
||||
const gunInSuitableTurret = suitableTurret.guns.find(
|
||||
(gun) => gun.id === unlock.id,
|
||||
(gun) => gun.gunType!.value.base.id === unlock.id,
|
||||
)!;
|
||||
|
||||
draft.protagonist.turret = suitableTurret;
|
||||
draft.protagonist.gun = gunInSuitableTurret;
|
||||
draft.protagonist.shell = gunInSuitableTurret.shells[0];
|
||||
draft.protagonist.shell =
|
||||
gunInSuitableTurret.gunType!.value.base.shells[0];
|
||||
}
|
||||
} else if (unlock.type === 'engine') {
|
||||
} else if (unlock.type === ModuleType.ENGINE) {
|
||||
draft.protagonist.engine = draft.protagonist.tank.engines.find(
|
||||
(engine) => engine.id === unlock.id,
|
||||
)!;
|
||||
} else if (unlock.type === 'chassis') {
|
||||
} else if (unlock.type === ModuleType.TRACKS) {
|
||||
draft.protagonist.track = draft.protagonist.tank.tracks.find(
|
||||
(track) => track.id === unlock.id,
|
||||
)!;
|
||||
@@ -190,20 +214,22 @@ export function Modules() {
|
||||
const central = !first && !last;
|
||||
let module: ModuleDefinition | TankDefinition | undefined = undefined;
|
||||
|
||||
if (unlock.type === 'chassis') {
|
||||
if (unlock.type === ModuleType.TRACKS) {
|
||||
module = tank.tracks.find((track) => track.id === unlock.id)!;
|
||||
} else if (unlock.type === 'engine') {
|
||||
} else if (unlock.type === ModuleType.ENGINE) {
|
||||
module = tank.engines.find((engine) => engine.id === unlock.id)!;
|
||||
} else if (unlock.type === 'turret') {
|
||||
} else if (unlock.type === ModuleType.TURRET) {
|
||||
module = tank.turrets.find((turret) => turret.id === unlock.id)!;
|
||||
} else if (unlock.type === 'gun') {
|
||||
} else if (unlock.type === ModuleType.GUN) {
|
||||
module = tank.turrets
|
||||
.find((turret) =>
|
||||
turret.guns.some((gun) => gun.id === unlock.id),
|
||||
turret.guns.some(
|
||||
(gun) => gun.gunType!.value.base.id === unlock.id,
|
||||
),
|
||||
)!
|
||||
.guns.find((gun) => gun.id === unlock.id)!;
|
||||
} else if (unlock.type === 'vehicle') {
|
||||
module = awaitedTankDefinitions[unlock.id];
|
||||
.guns.find((gun) => gun.gunType!.value.base.id === unlock.id)!;
|
||||
} else if (unlock.type === ModuleType.VEHICLE) {
|
||||
module = tankDefinitions.tanks[unlock.id];
|
||||
}
|
||||
|
||||
if (module === undefined) return null;
|
||||
@@ -259,34 +285,36 @@ export function Modules() {
|
||||
|
||||
<ModuleButton
|
||||
unlock={unlock}
|
||||
tier={module.tier}
|
||||
tier={extractModule(module).tier}
|
||||
selected={
|
||||
(unlock.type === 'turret'
|
||||
(unlock.type === ModuleType.TURRET
|
||||
? turret.id
|
||||
: unlock.type === 'gun'
|
||||
? gun.id
|
||||
: unlock.type === 'engine'
|
||||
: unlock.type === ModuleType.GUN
|
||||
? gun.gunType!.value.base.id
|
||||
: unlock.type === ModuleType.ENGINE
|
||||
? engine.id
|
||||
: unlock.type === 'chassis'
|
||||
: unlock.type === ModuleType.TRACKS
|
||||
? track.id
|
||||
: -1) === unlock.id
|
||||
}
|
||||
top={
|
||||
unlock.type === 'turret'
|
||||
? module.id == topTurret.id
|
||||
: unlock.type === 'gun'
|
||||
? module.id === topGun.id
|
||||
: unlock.type === 'engine'
|
||||
? module.id === topEngine.id
|
||||
: unlock.type === 'chassis'
|
||||
? module.id === topTrack.id
|
||||
unlock.type === ModuleType.TURRET
|
||||
? extractModule(module).id == topTurret.id
|
||||
: unlock.type === ModuleType.GUN
|
||||
? extractModule(module).id ===
|
||||
topGun.gunType!.value.base.id
|
||||
: unlock.type === ModuleType.ENGINE
|
||||
? extractModule(module).id === topEngine.id
|
||||
: unlock.type === ModuleType.TRACKS
|
||||
? extractModule(module).id === topTrack.id
|
||||
: false
|
||||
}
|
||||
onClick={() => setByUnlock(unlock)}
|
||||
/>
|
||||
|
||||
{(module as ModuleDefinition).unlocks &&
|
||||
(module as ModuleDefinition).unlocks!.length > 1 && (
|
||||
{(extractModule(module) as ModuleWithUnlocks).unlocks &&
|
||||
(extractModule(module) as ModuleWithUnlocks).unlocks!.length >
|
||||
1 && (
|
||||
<div
|
||||
style={{
|
||||
backgroundColor: 'currentcolor',
|
||||
@@ -297,8 +325,11 @@ export function Modules() {
|
||||
/>
|
||||
)}
|
||||
|
||||
{(module as ModuleDefinition).unlocks &&
|
||||
tree(type, (module as ModuleDefinition).unlocks!)}
|
||||
{(extractModule(module) as ModuleWithUnlocks).unlocks &&
|
||||
tree(
|
||||
type,
|
||||
(extractModule(module) as ModuleWithUnlocks).unlocks!,
|
||||
)}
|
||||
</Flex>
|
||||
);
|
||||
})}
|
||||
@@ -320,7 +351,8 @@ export function Modules() {
|
||||
mutateDuel((draft) => {
|
||||
draft.protagonist.turret = draft.protagonist.tank.turrets[0];
|
||||
draft.protagonist.gun = draft.protagonist.turret.guns[0];
|
||||
draft.protagonist.shell = draft.protagonist.gun.shells[0];
|
||||
draft.protagonist.shell =
|
||||
draft.protagonist.gun.gunType!.value.base.shells[0];
|
||||
draft.protagonist.engine = draft.protagonist.tank.engines[0];
|
||||
draft.protagonist.track = draft.protagonist.tank.tracks[0];
|
||||
});
|
||||
@@ -335,7 +367,8 @@ export function Modules() {
|
||||
draft.protagonist.turret =
|
||||
draft.protagonist.tank.turrets.at(-1)!;
|
||||
draft.protagonist.gun = draft.protagonist.turret.guns.at(-1)!;
|
||||
draft.protagonist.shell = draft.protagonist.gun.shells[0];
|
||||
draft.protagonist.shell =
|
||||
draft.protagonist.gun.gunType!.value.base.shells[0];
|
||||
draft.protagonist.engine =
|
||||
draft.protagonist.tank.engines.at(-1)!;
|
||||
draft.protagonist.track =
|
||||
@@ -350,32 +383,32 @@ export function Modules() {
|
||||
</Flex>
|
||||
|
||||
<Flex gap="2" wrap="wrap" gapY="6">
|
||||
{tree('engine', [
|
||||
{tree(ModuleType.ENGINE, [
|
||||
{
|
||||
cost: { type: 'xp', value: 0 },
|
||||
id: engine0.id,
|
||||
type: 'engine',
|
||||
type: ModuleType.ENGINE,
|
||||
},
|
||||
])}
|
||||
{tree('chassis', [
|
||||
{tree(ModuleType.TRACKS, [
|
||||
{
|
||||
cost: { type: 'xp', value: 0 },
|
||||
id: track0.id,
|
||||
type: 'chassis',
|
||||
type: ModuleType.TRACKS,
|
||||
},
|
||||
])}
|
||||
{tree('turret', [
|
||||
{tree(ModuleType.TURRET, [
|
||||
{
|
||||
cost: { type: 'xp', value: 0 },
|
||||
id: turret0.id,
|
||||
type: 'turret',
|
||||
type: ModuleType.TURRET,
|
||||
},
|
||||
])}
|
||||
{tree('gun', [
|
||||
{tree(ModuleType.GUN, [
|
||||
{
|
||||
cost: { type: 'xp', value: 0 },
|
||||
id: gun0.id,
|
||||
type: 'gun',
|
||||
id: gun0.gunType!.value.base.id,
|
||||
type: ModuleType.GUN,
|
||||
},
|
||||
])}
|
||||
</Flex>
|
||||
|
||||
+4
-8
@@ -1,20 +1,16 @@
|
||||
import { availableProvisions, provisionDefinitions } from '@blitzkit/core';
|
||||
import { availableProvisions, fetchProvisionDefinitions } from '@blitzkit/core';
|
||||
import { Button, Flex, Heading } from '@radix-ui/themes';
|
||||
import { Duel } from '../../../../stores/duel';
|
||||
import { ProvisionsManager } from '../../../ProvisionsManager';
|
||||
import { ConfigurationChildWrapper } from './ConfigurationChildWrapper';
|
||||
|
||||
const awaitedProvisionDefinitions = await provisionDefinitions;
|
||||
const provisionDefinitions = await fetchProvisionDefinitions();
|
||||
|
||||
export function Provisions() {
|
||||
const mutateDuel = Duel.useMutation();
|
||||
const { tank, gun } = Duel.use((state) => state.protagonist);
|
||||
const provisions = Duel.use((state) => state.protagonist.provisions);
|
||||
const provisionsList = availableProvisions(
|
||||
tank,
|
||||
gun,
|
||||
awaitedProvisionDefinitions,
|
||||
);
|
||||
const provisionsList = availableProvisions(tank, gun, provisionDefinitions);
|
||||
|
||||
return (
|
||||
<ConfigurationChildWrapper>
|
||||
@@ -36,7 +32,7 @@ export function Provisions() {
|
||||
<ProvisionsManager
|
||||
provisions={provisionsList.map((provision) => provision.id)}
|
||||
selected={provisions}
|
||||
disabled={tank.provisions === provisions.length}
|
||||
disabled={tank.maxProvisions === provisions.length}
|
||||
onChange={(provisions) => {
|
||||
mutateDuel((draft) => {
|
||||
draft.protagonist.provisions = provisions;
|
||||
|
||||
+3
-3
@@ -1,4 +1,4 @@
|
||||
import { createDefaultSkills, skillDefinitions } from '@blitzkit/core';
|
||||
import { createDefaultSkills, fetchSkillDefinitions } from '@blitzkit/core';
|
||||
import { InfoCircledIcon } from '@radix-ui/react-icons';
|
||||
import {
|
||||
Button,
|
||||
@@ -13,7 +13,7 @@ import { TankopediaEphemeral } from '../../../../stores/tankopediaEphemeral';
|
||||
import { CrewSkillManager } from '../../../CrewSkillManager';
|
||||
import { ConfigurationChildWrapper } from './ConfigurationChildWrapper';
|
||||
|
||||
const awaitedSkillDefinitions = await skillDefinitions;
|
||||
const skillDefinitions = await fetchSkillDefinitions();
|
||||
|
||||
export function Skills() {
|
||||
const skillLevels = TankopediaEphemeral.use((state) => state.skills);
|
||||
@@ -21,7 +21,7 @@ export function Skills() {
|
||||
|
||||
if (Object.keys(skillLevels).length === 0) {
|
||||
mutateTankopediaTemporary((draft) => {
|
||||
draft.skills = createDefaultSkills(awaitedSkillDefinitions);
|
||||
draft.skills = createDefaultSkills(skillDefinitions);
|
||||
});
|
||||
|
||||
return null;
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
import {
|
||||
asset,
|
||||
consumableDefinitions,
|
||||
gameDefinitions,
|
||||
provisionDefinitions,
|
||||
fetchConsumableDefinitions,
|
||||
fetchGameDefinitions,
|
||||
fetchProvisionDefinitions,
|
||||
} from '@blitzkit/core';
|
||||
import { Box, Flex, Heading, Text } from '@radix-ui/themes';
|
||||
import { Duel } from '../../stores/duel';
|
||||
|
||||
const awaitedGameDefinitions = await gameDefinitions;
|
||||
const awaitedConsumableDefinitions = await consumableDefinitions;
|
||||
const awaitedProvisionDefinitions = await provisionDefinitions;
|
||||
const gameDefinitions = await fetchGameDefinitions();
|
||||
const consumableDefinitions = await fetchConsumableDefinitions();
|
||||
const provisionDefinitions = await fetchProvisionDefinitions();
|
||||
|
||||
export function GameModeSection() {
|
||||
const tank = Duel.use((state) => state.protagonist.tank);
|
||||
@@ -24,7 +24,7 @@ export function GameModeSection() {
|
||||
<Flex justify="center" gap="4" wrap="wrap" px="4">
|
||||
{roles.map(([key, value]) => {
|
||||
const id = Number(key);
|
||||
const gameMode = awaitedGameDefinitions.gameModes[id];
|
||||
const gameMode = gameDefinitions.gameModes[id];
|
||||
|
||||
return (
|
||||
<Flex
|
||||
@@ -70,8 +70,8 @@ export function GameModeSection() {
|
||||
</Text>
|
||||
|
||||
<Flex direction="column">
|
||||
{awaitedGameDefinitions.roles[value].provisions.map((id) => {
|
||||
const provisions = awaitedProvisionDefinitions[id];
|
||||
{gameDefinitions.roles[value].provisions.map((id) => {
|
||||
const provisions = provisionDefinitions.provisions[id];
|
||||
|
||||
return (
|
||||
<Text color="gray" wrap="nowrap" key={id}>
|
||||
@@ -90,8 +90,8 @@ export function GameModeSection() {
|
||||
</Text>
|
||||
);
|
||||
})}
|
||||
{awaitedGameDefinitions.roles[value].consumables.map((id) => {
|
||||
const consumable = awaitedConsumableDefinitions[id];
|
||||
{gameDefinitions.roles[value].consumables.map((id) => {
|
||||
const consumable = consumableDefinitions.consumables[id];
|
||||
|
||||
return (
|
||||
<Text color="gray" wrap="nowrap" key={id}>
|
||||
|
||||
+2
-2
@@ -28,8 +28,8 @@ export function DynamicArmorSwitcher() {
|
||||
draft.protagonist.consumables =
|
||||
draft.protagonist.consumables.filter((id) => id !== 73);
|
||||
} else {
|
||||
if (draft.protagonist.consumables.length === tank.consumables) {
|
||||
draft.protagonist.consumables[tank.consumables - 1] = 73;
|
||||
if (draft.protagonist.consumables.length === tank.maxConsumables) {
|
||||
draft.protagonist.consumables[tank.maxConsumables - 1] = 73;
|
||||
} else {
|
||||
draft.protagonist.consumables.push(73);
|
||||
}
|
||||
|
||||
+5
-3
@@ -20,8 +20,9 @@ export function QuickInputs() {
|
||||
const tankModelDefinition = useTankModelDefinition();
|
||||
const turretModelDefinition =
|
||||
tankModelDefinition.turrets[protagonist.turret.id];
|
||||
const gunModelDefinition = turretModelDefinition.guns[protagonist.gun.id];
|
||||
const initialGunPitch = tankModelDefinition.turretRotation?.pitch ?? 0;
|
||||
const gunModelDefinition =
|
||||
turretModelDefinition.guns[protagonist.gun.gunType!.value.base.id];
|
||||
const initialGunPitch = tankModelDefinition.initialTurretRotation?.pitch ?? 0;
|
||||
const hasImprovedVerticalStabilizer = useEquipment(122);
|
||||
|
||||
useEffect(() => {
|
||||
@@ -43,7 +44,8 @@ export function QuickInputs() {
|
||||
if (!pitchInput.current || !yawInput.current) return;
|
||||
|
||||
pitchInput.current.value = (
|
||||
-radToDeg(pitch) + (tankModelDefinition.turretRotation?.pitch ?? 0)
|
||||
-radToDeg(pitch) +
|
||||
(tankModelDefinition.initialTurretRotation?.pitch ?? 0)
|
||||
).toFixed(1);
|
||||
|
||||
if (yaw === undefined) return;
|
||||
|
||||
+51
-37
@@ -1,7 +1,6 @@
|
||||
import {
|
||||
asset,
|
||||
imgur,
|
||||
resolveNearPenetration,
|
||||
resolvePenetrationCoefficient,
|
||||
TIER_ROMAN_NUMERALS,
|
||||
uniqueGuns,
|
||||
@@ -105,7 +104,7 @@ export function Options({ thicknessRange, canvas }: OptionsProps) {
|
||||
resolvePenetrationCoefficient(
|
||||
hasCalibratedShells,
|
||||
antagonistShell.type,
|
||||
) * resolveNearPenetration(antagonistShell.penetration)
|
||||
) * antagonistShell.penetration.near
|
||||
).toFixed(0)}
|
||||
mm
|
||||
</Text>
|
||||
@@ -130,7 +129,11 @@ export function Options({ thicknessRange, canvas }: OptionsProps) {
|
||||
mr="2"
|
||||
mb="1"
|
||||
>
|
||||
{TIER_ROMAN_NUMERALS[antagonistGun.tier]}
|
||||
{
|
||||
TIER_ROMAN_NUMERALS[
|
||||
antagonistGun.gunType!.value.base.tier
|
||||
]
|
||||
}
|
||||
</Text>
|
||||
|
||||
<img
|
||||
@@ -149,19 +152,25 @@ export function Options({ thicknessRange, canvas }: OptionsProps) {
|
||||
<Flex gap="2">
|
||||
{[...antagonistUniqueGuns]
|
||||
.reverse()
|
||||
.map(({ gun, turret }, index) => (
|
||||
.map(({ gun, turret }) => (
|
||||
<ModuleButton
|
||||
module="gun"
|
||||
key={gun.id}
|
||||
key={gun.gunType!.value.base.id}
|
||||
onClick={() =>
|
||||
mutateDuel((draft) => {
|
||||
draft.antagonist.turret = turret;
|
||||
draft.antagonist.gun = gun;
|
||||
draft.antagonist.shell = gun.shells[0];
|
||||
draft.antagonist.shell =
|
||||
gun.gunType!.value.base.shells[0];
|
||||
})
|
||||
}
|
||||
selected={gun.id === antagonistGun.id}
|
||||
discriminator={TIER_ROMAN_NUMERALS[gun.tier]}
|
||||
selected={
|
||||
gun.gunType!.value.base.id ===
|
||||
antagonistGun.gunType!.value.base.id
|
||||
}
|
||||
discriminator={
|
||||
TIER_ROMAN_NUMERALS[gun.gunType!.value.base.tier]
|
||||
}
|
||||
/>
|
||||
))}
|
||||
</Flex>
|
||||
@@ -175,36 +184,40 @@ export function Options({ thicknessRange, canvas }: OptionsProps) {
|
||||
}}
|
||||
overflow="hidden"
|
||||
>
|
||||
{antagonistGun.shells.map((thisShell, shellIndex) => (
|
||||
<IconButton
|
||||
color={thisShell.id === antagonistShell.id ? undefined : 'gray'}
|
||||
variant="soft"
|
||||
key={thisShell.id}
|
||||
size={{ initial: '2', sm: '3' }}
|
||||
radius="none"
|
||||
style={{
|
||||
marginTop: shellIndex === 0 ? 0 : -1,
|
||||
}}
|
||||
onClick={() => {
|
||||
invalidate();
|
||||
mutateDuel((draft) => {
|
||||
draft.antagonist.shell = thisShell;
|
||||
});
|
||||
mutateTankopediaEphemeral((draft) => {
|
||||
draft.shot = undefined;
|
||||
});
|
||||
}}
|
||||
>
|
||||
<img
|
||||
alt={thisShell.name}
|
||||
src={asset(`icons/shells/${thisShell.icon}.webp`)}
|
||||
{antagonistGun.gunType!.value.base.shells.map(
|
||||
(thisShell, shellIndex) => (
|
||||
<IconButton
|
||||
color={
|
||||
thisShell.id === antagonistShell.id ? undefined : 'gray'
|
||||
}
|
||||
variant="soft"
|
||||
key={thisShell.id}
|
||||
size={{ initial: '2', sm: '3' }}
|
||||
radius="none"
|
||||
style={{
|
||||
width: '50%',
|
||||
height: '50%',
|
||||
marginTop: shellIndex === 0 ? 0 : -1,
|
||||
}}
|
||||
/>
|
||||
</IconButton>
|
||||
))}
|
||||
onClick={() => {
|
||||
invalidate();
|
||||
mutateDuel((draft) => {
|
||||
draft.antagonist.shell = thisShell;
|
||||
});
|
||||
mutateTankopediaEphemeral((draft) => {
|
||||
draft.shot = undefined;
|
||||
});
|
||||
}}
|
||||
>
|
||||
<img
|
||||
alt={thisShell.name}
|
||||
src={asset(`icons/shells/${thisShell.icon}.webp`)}
|
||||
style={{
|
||||
width: '50%',
|
||||
height: '50%',
|
||||
}}
|
||||
/>
|
||||
</IconButton>
|
||||
),
|
||||
)}
|
||||
</Flex>
|
||||
|
||||
<Flex
|
||||
@@ -318,7 +331,8 @@ export function Options({ thicknessRange, canvas }: OptionsProps) {
|
||||
draft.antagonist.turret = tank.turrets.at(-1)!;
|
||||
draft.antagonist.gun =
|
||||
draft.antagonist.turret.guns.at(-1)!;
|
||||
draft.antagonist.shell = draft.antagonist.gun.shells[0];
|
||||
draft.antagonist.shell =
|
||||
draft.antagonist.gun.gunType!.value.base.shells[0];
|
||||
});
|
||||
setAntagonistSelectorOpen(false);
|
||||
}}
|
||||
|
||||
+6
-6
@@ -1,4 +1,4 @@
|
||||
import { modelDefinitions } from '@blitzkit/core';
|
||||
import { fetchModelDefinitions } from '@blitzkit/core';
|
||||
import { OrbitControls } from '@react-three/drei';
|
||||
import { useThree } from '@react-three/fiber';
|
||||
import { useEffect, useRef, useState } from 'react';
|
||||
@@ -7,7 +7,6 @@ import { OrbitControls as OrbitControlsClass } from 'three-stdlib';
|
||||
import { applyPitchYawLimits } from '../../../../../../core/blitz/applyPitchYawLimits';
|
||||
import { hasEquipment } from '../../../../../../core/blitzkit/hasEquipment';
|
||||
import { Pose, poseEvent } from '../../../../../../core/blitzkit/pose';
|
||||
import { useAwait } from '../../../../../../hooks/useAwait';
|
||||
import { Duel } from '../../../../../../stores/duel';
|
||||
import { TankopediaEphemeral } from '../../../../../../stores/tankopediaEphemeral';
|
||||
|
||||
@@ -18,20 +17,21 @@ const poseDistances: Record<Pose, number> = {
|
||||
[Pose.Default]: -1,
|
||||
};
|
||||
|
||||
const modelDefinitions = await fetchModelDefinitions();
|
||||
|
||||
export function Controls() {
|
||||
const duelStore = Duel.useStore();
|
||||
const tankopediaEphemeralStore = TankopediaEphemeral.useStore();
|
||||
const camera = useThree((state) => state.camera);
|
||||
const canvas = useThree((state) => state.gl.domElement);
|
||||
const orbitControls = useRef<OrbitControlsClass>(null);
|
||||
const awaitedModelDefinitions = useAwait(modelDefinitions);
|
||||
const protagonist = Duel.use((state) => state.protagonist);
|
||||
const antagonist = Duel.use((state) => state.antagonist);
|
||||
const protagonistModelDefinition =
|
||||
awaitedModelDefinitions[protagonist.tank.id];
|
||||
modelDefinitions.models[protagonist.tank.id];
|
||||
const protagonistTrackModelDefinition =
|
||||
awaitedModelDefinitions[protagonist.tank.id].tracks[protagonist.track.id];
|
||||
const antagonistModelDefinition = awaitedModelDefinitions[antagonist.tank.id];
|
||||
modelDefinitions.models[protagonist.tank.id].tracks[protagonist.track.id];
|
||||
const antagonistModelDefinition = modelDefinitions.models[antagonist.tank.id];
|
||||
const protagonistTurretModelDefinition =
|
||||
protagonistModelDefinition.turrets[protagonist.turret.id];
|
||||
const antagonistTurretModelDefinition =
|
||||
|
||||
Reference in new issue
Block a user