mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-23 19:49:50 +02:00
feat: crew skills ui
This commit is contained in:
1 parent
d79129df91
commit
eaff26c8d9
5 files changed
+80
-7
No files matched your search
+2
-2
@@ -5,7 +5,7 @@ import { equipmentDefinitions } from '../../../../../../../core/blitzkrieg/equip
|
|||||||
import { mutateDuel, useDuel } from '../../../../../../../stores/duel';
|
import { mutateDuel, useDuel } from '../../../../../../../stores/duel';
|
||||||
import { ConfigurationChildWrapper } from './ConfigurationChildWrapper';
|
import { ConfigurationChildWrapper } from './ConfigurationChildWrapper';
|
||||||
|
|
||||||
export function Equipments() {
|
export function Equipment() {
|
||||||
const protagonist = useDuel((state) => state.protagonist!);
|
const protagonist = useDuel((state) => state.protagonist!);
|
||||||
const awaitedEquipmentDefinitions = use(equipmentDefinitions);
|
const awaitedEquipmentDefinitions = use(equipmentDefinitions);
|
||||||
const equipmentRows =
|
const equipmentRows =
|
||||||
@@ -14,7 +14,7 @@ export function Equipments() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<ConfigurationChildWrapper>
|
<ConfigurationChildWrapper>
|
||||||
<Heading size="4">Equipments</Heading>
|
<Heading size="4">Equipment</Heading>
|
||||||
|
|
||||||
<Flex direction="column" gap="2">
|
<Flex direction="column" gap="2">
|
||||||
{equipmentRows.map((equipmentRow, rowIndex) => (
|
{equipmentRows.map((equipmentRow, rowIndex) => (
|
||||||
@@ -0,0 +1,71 @@
|
|||||||
|
import { Flex, Heading } from '@radix-ui/themes';
|
||||||
|
import { use } from 'react';
|
||||||
|
import { GenericTankComponentButton } from '../../../../../../../components/ModuleButtons/GenericTankComponentButton';
|
||||||
|
import { asset } from '../../../../../../../core/blitzkrieg/asset';
|
||||||
|
import { skillDefinitions } from '../../../../../../../core/blitzkrieg/skillDefinitions';
|
||||||
|
import { Tier } from '../../../../../../../core/blitzkrieg/tankDefinitions';
|
||||||
|
import { TIER_ROMAN_NUMERALS } from '../../../../../../../core/blitzkrieg/tankDefinitions/constants';
|
||||||
|
import mutateTankopediaPersistent, {
|
||||||
|
useTankopediaPersistent,
|
||||||
|
} from '../../../../../../../stores/tankopedia';
|
||||||
|
import { ConfigurationChildWrapper } from './ConfigurationChildWrapper';
|
||||||
|
|
||||||
|
export function Skills() {
|
||||||
|
const awaitedSkillDefinitions = use(skillDefinitions);
|
||||||
|
const skillLevels = useTankopediaPersistent((state) => state.skills);
|
||||||
|
|
||||||
|
if (Object.keys(skillLevels).length === 0) {
|
||||||
|
mutateTankopediaPersistent((draft) => {
|
||||||
|
Object.values(awaitedSkillDefinitions.classes).forEach((skills) => {
|
||||||
|
skills.forEach((skill) => {
|
||||||
|
draft.skills[skill] = 0;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<ConfigurationChildWrapper>
|
||||||
|
<Heading size="4">Crew skills</Heading>
|
||||||
|
|
||||||
|
<Flex direction="column" gap="2">
|
||||||
|
{Object.entries(awaitedSkillDefinitions.classes).map(
|
||||||
|
([tankClass, skills]) => (
|
||||||
|
<Flex gap="2" key={tankClass}>
|
||||||
|
{skills.map((skill) => {
|
||||||
|
const level = skillLevels[skill];
|
||||||
|
|
||||||
|
return (
|
||||||
|
<GenericTankComponentButton
|
||||||
|
first
|
||||||
|
last
|
||||||
|
selected={level > 0}
|
||||||
|
discriminator={
|
||||||
|
level === 0
|
||||||
|
? undefined
|
||||||
|
: TIER_ROMAN_NUMERALS[level as Tier]
|
||||||
|
}
|
||||||
|
icon={asset(`icons/skills/${skill}.webp`)}
|
||||||
|
onClick={(event) => {
|
||||||
|
mutateTankopediaPersistent((draft) => {
|
||||||
|
if (event.shiftKey) {
|
||||||
|
draft.skills[skill] =
|
||||||
|
draft.skills[skill] === 0 ? 7 : 0;
|
||||||
|
} else {
|
||||||
|
draft.skills[skill] = level - 1;
|
||||||
|
if (draft.skills[skill] < 0) draft.skills[skill] = 7;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</Flex>
|
||||||
|
),
|
||||||
|
)}
|
||||||
|
</Flex>
|
||||||
|
</ConfigurationChildWrapper>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -10,10 +10,11 @@ import { mutateTankopediaTemporary } from '../../../../stores/tankopedia';
|
|||||||
import { AntagonistBar } from './components/AntagonistBar';
|
import { AntagonistBar } from './components/AntagonistBar';
|
||||||
import { Characteristics } from './components/Characteristics';
|
import { Characteristics } from './components/Characteristics';
|
||||||
import { Consumables } from './components/Characteristics/components/Consumables';
|
import { Consumables } from './components/Characteristics/components/Consumables';
|
||||||
import { Equipments } from './components/Characteristics/components/Equipments';
|
import { Equipment } from './components/Characteristics/components/Equipment';
|
||||||
import { Miscellaneous } from './components/Characteristics/components/Miscellaneous';
|
import { Miscellaneous } from './components/Characteristics/components/Miscellaneous';
|
||||||
import { Modules } from './components/Characteristics/components/Modules';
|
import { Modules } from './components/Characteristics/components/Modules';
|
||||||
import { Provisions } from './components/Characteristics/components/Provisions';
|
import { Provisions } from './components/Characteristics/components/Provisions';
|
||||||
|
import { Skills } from './components/Characteristics/components/Skills';
|
||||||
import { TankSandbox } from './components/Model/TankSandbox';
|
import { TankSandbox } from './components/Model/TankSandbox';
|
||||||
import { Title } from './components/Title';
|
import { Title } from './components/Title';
|
||||||
|
|
||||||
@@ -63,8 +64,6 @@ export default function Page({ params }: { params: { id: string } }) {
|
|||||||
};
|
};
|
||||||
}, [initialId, assigned]);
|
}, [initialId, assigned]);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<PageWrapper color="purple" size="double">
|
<PageWrapper color="purple" size="double">
|
||||||
{assigned && (
|
{assigned && (
|
||||||
@@ -94,9 +93,10 @@ export default function Page({ params }: { params: { id: string } }) {
|
|||||||
<Flex direction="column" gap="4">
|
<Flex direction="column" gap="4">
|
||||||
<Modules />
|
<Modules />
|
||||||
<Provisions />
|
<Provisions />
|
||||||
<Equipments />
|
<Equipment />
|
||||||
<Miscellaneous />
|
<Miscellaneous />
|
||||||
<Consumables />
|
<Consumables />
|
||||||
|
<Skills />
|
||||||
</Flex>
|
</Flex>
|
||||||
</Flex>
|
</Flex>
|
||||||
|
|
||||||
|
|||||||
@@ -7,5 +7,5 @@ export interface SkillDefinitions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const skillDefinitions = fetchCdonLz4<SkillDefinitions>(
|
export const skillDefinitions = fetchCdonLz4<SkillDefinitions>(
|
||||||
asset('definitions/equipment.cdon.lz4'),
|
asset('definitions/skills.cdon.lz4'),
|
||||||
);
|
);
|
||||||
@@ -38,6 +38,7 @@ export interface TankopediaPersistent {
|
|||||||
test: TankopediaTestTankDisplay;
|
test: TankopediaTestTankDisplay;
|
||||||
page: number;
|
page: number;
|
||||||
};
|
};
|
||||||
|
skills: Record<string, number>;
|
||||||
mode: TankopediaMode;
|
mode: TankopediaMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -146,6 +147,7 @@ export const useTankopediaPersistent = create<TankopediaPersistent>()(
|
|||||||
test: 'include',
|
test: 'include',
|
||||||
page: 0,
|
page: 0,
|
||||||
},
|
},
|
||||||
|
skills: {},
|
||||||
mode: 'model',
|
mode: 'model',
|
||||||
})),
|
})),
|
||||||
{ name: 'tankopedia', merge: (a, b) => merge(b, a) },
|
{ name: 'tankopedia', merge: (a, b) => merge(b, a) },
|
||||||
|
|||||||
Reference in new issue
Block a user