mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-23 19:49:50 +02:00
fix: use roles
This commit is contained in:
1 parent
9df5efa422
commit
56a09536cd
4 files changed
+51
-52
No files matched your search
@@ -1,6 +1,6 @@
|
|||||||
import type { Consumable } from '@blitzkit/core';
|
import type { Consumable } from "@blitzkit/core";
|
||||||
import { Flex, type FlexProps } from '@radix-ui/themes';
|
import { Flex, type FlexProps } from "@radix-ui/themes";
|
||||||
import { ConsumableButton } from './ModuleButtons/ConsumableButton';
|
import { ConsumableButton } from "./ModuleButtons/ConsumableButton";
|
||||||
|
|
||||||
type ConsumablesManagerProps = FlexProps & {
|
type ConsumablesManagerProps = FlexProps & {
|
||||||
consumables: Consumable[];
|
consumables: Consumable[];
|
||||||
@@ -27,6 +27,8 @@ export function ConsumablesManager({
|
|||||||
return (
|
return (
|
||||||
<Flex wrap="wrap" gap="2" {...props}>
|
<Flex wrap="wrap" gap="2" {...props}>
|
||||||
{consumables.map((consumable) => {
|
{consumables.map((consumable) => {
|
||||||
|
if (consumable.game_mode_exclusive) return null;
|
||||||
|
|
||||||
const isSelected = selected.some((id) => id === consumable.id);
|
const isSelected = selected.some((id) => id === consumable.id);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { Flex } from '@radix-ui/themes';
|
import { Flex } from "@radix-ui/themes";
|
||||||
import { ProvisionButton } from './ModuleButtons/ProvisionButton';
|
import { awaitableProvisionDefinitions } from "../core/awaitables/provisionDefinitions";
|
||||||
|
import { ProvisionButton } from "./ModuleButtons/ProvisionButton";
|
||||||
|
|
||||||
interface ProvisionsManagerProps {
|
interface ProvisionsManagerProps {
|
||||||
provisions: number[];
|
provisions: number[];
|
||||||
@@ -8,6 +9,8 @@ interface ProvisionsManagerProps {
|
|||||||
onChange?: (provisions: number[]) => void;
|
onChange?: (provisions: number[]) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const provisionDefinitions = await awaitableProvisionDefinitions;
|
||||||
|
|
||||||
export function ProvisionsManager({
|
export function ProvisionsManager({
|
||||||
provisions,
|
provisions,
|
||||||
selected,
|
selected,
|
||||||
@@ -15,15 +18,18 @@ export function ProvisionsManager({
|
|||||||
disabled,
|
disabled,
|
||||||
}: ProvisionsManagerProps) {
|
}: ProvisionsManagerProps) {
|
||||||
return (
|
return (
|
||||||
<Flex wrap="wrap" gap="2" justify={{ initial: 'center', sm: 'start' }}>
|
<Flex wrap="wrap" gap="2" justify={{ initial: "center", sm: "start" }}>
|
||||||
{provisions.map((provision) => {
|
{provisions.map((id) => {
|
||||||
const isSelected = selected.includes(provision);
|
const isSelected = selected.includes(id);
|
||||||
|
const provision = provisionDefinitions.provisions[id];
|
||||||
|
|
||||||
|
if (provision.game_mode_exclusive) return null;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ProvisionButton
|
<ProvisionButton
|
||||||
key={provision}
|
key={id}
|
||||||
disabled={disabled && !isSelected}
|
disabled={disabled && !isSelected}
|
||||||
provision={provision}
|
provision={id}
|
||||||
selected={isSelected}
|
selected={isSelected}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
if (!onChange) return;
|
if (!onChange) return;
|
||||||
@@ -31,9 +37,9 @@ export function ProvisionsManager({
|
|||||||
const draft = [...selected];
|
const draft = [...selected];
|
||||||
|
|
||||||
if (isSelected) {
|
if (isSelected) {
|
||||||
draft.splice(draft.indexOf(provision), 1);
|
draft.splice(draft.indexOf(id), 1);
|
||||||
} else {
|
} else {
|
||||||
draft.push(provision);
|
draft.push(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
onChange(draft);
|
onChange(draft);
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
import { asset } from '@blitzkit/core';
|
import { asset } from "@blitzkit/core";
|
||||||
import { Box, Flex, Heading, Text } from '@radix-ui/themes';
|
import { Box, Flex, Heading, Text } from "@radix-ui/themes";
|
||||||
import { awaitableConsumableDefinitions } from '../../core/awaitables/consumableDefinitions';
|
import { awaitableConsumableDefinitions } from "../../core/awaitables/consumableDefinitions";
|
||||||
import { awaitableGameDefinitions } from '../../core/awaitables/gameDefinitions';
|
import { awaitableGameDefinitions } from "../../core/awaitables/gameDefinitions";
|
||||||
import { awaitableProvisionDefinitions } from '../../core/awaitables/provisionDefinitions';
|
import { awaitableProvisionDefinitions } from "../../core/awaitables/provisionDefinitions";
|
||||||
import { useLocale } from '../../hooks/useLocale';
|
import { useLocale } from "../../hooks/useLocale";
|
||||||
import { Duel } from '../../stores/duel';
|
import { Duel } from "../../stores/duel";
|
||||||
|
|
||||||
const [gameDefinitions, consumableDefinitions, provisionDefinitions] =
|
const [gameDefinitions, consumableDefinitions, provisionDefinitions] =
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
@@ -39,22 +39,22 @@ export function GameModeSection() {
|
|||||||
overflow="hidden"
|
overflow="hidden"
|
||||||
direction="column"
|
direction="column"
|
||||||
style={{
|
style={{
|
||||||
borderRadius: 'var(--radius-3)',
|
borderRadius: "var(--radius-3)",
|
||||||
background: `url(${asset(
|
background: `url(${asset(
|
||||||
`icons/game_mode_banners/${id}.webp`,
|
`icons/game_mode_banners/${id}.webp`
|
||||||
)})`,
|
)})`,
|
||||||
backgroundSize: 'cover',
|
backgroundSize: "cover",
|
||||||
backgroundPosition: 'center',
|
backgroundPosition: "center",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Box
|
<Box
|
||||||
flexGrow="1"
|
flexGrow="1"
|
||||||
style={{
|
style={{
|
||||||
background: `url(${asset(
|
background: `url(${asset(
|
||||||
`icons/game_mode_banners/${id}.webp`,
|
`icons/game_mode_banners/${id}.webp`
|
||||||
)})`,
|
)})`,
|
||||||
backgroundSize: 'cover',
|
backgroundSize: "cover",
|
||||||
backgroundPosition: 'center',
|
backgroundPosition: "center",
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
@@ -64,8 +64,8 @@ export function GameModeSection() {
|
|||||||
height="98px"
|
height="98px"
|
||||||
flexShrink="0"
|
flexShrink="0"
|
||||||
style={{
|
style={{
|
||||||
backdropFilter: 'blur(4rem)',
|
backdropFilter: "blur(4rem)",
|
||||||
WebkitBackdropFilter: 'blur(4rem)',
|
WebkitBackdropFilter: "blur(4rem)",
|
||||||
}}
|
}}
|
||||||
align="center"
|
align="center"
|
||||||
justify="center"
|
justify="center"
|
||||||
@@ -83,9 +83,9 @@ export function GameModeSection() {
|
|||||||
<Flex align="center" gap="1">
|
<Flex align="center" gap="1">
|
||||||
<img
|
<img
|
||||||
style={{
|
style={{
|
||||||
width: '1.5em',
|
width: "1.5em",
|
||||||
height: '1.5em',
|
height: "1.5em",
|
||||||
objectFit: 'contain',
|
objectFit: "contain",
|
||||||
}}
|
}}
|
||||||
src={asset(`icons/provisions/${id}.webp`)}
|
src={asset(`icons/provisions/${id}.webp`)}
|
||||||
alt={unwrap(provisions.name)}
|
alt={unwrap(provisions.name)}
|
||||||
@@ -95,6 +95,7 @@ export function GameModeSection() {
|
|||||||
</Text>
|
</Text>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
|
|
||||||
{gameDefinitions.roles[value].consumables.map((id) => {
|
{gameDefinitions.roles[value].consumables.map((id) => {
|
||||||
const consumable = consumableDefinitions.consumables[id];
|
const consumable = consumableDefinitions.consumables[id];
|
||||||
|
|
||||||
@@ -103,9 +104,9 @@ export function GameModeSection() {
|
|||||||
<Flex align="center" gap="1">
|
<Flex align="center" gap="1">
|
||||||
<img
|
<img
|
||||||
style={{
|
style={{
|
||||||
width: '1.5em',
|
width: "1.5em",
|
||||||
height: '1.5em',
|
height: "1.5em",
|
||||||
objectFit: 'contain',
|
objectFit: "contain",
|
||||||
}}
|
}}
|
||||||
src={asset(`icons/consumables/${id}.webp`)}
|
src={asset(`icons/consumables/${id}.webp`)}
|
||||||
alt={unwrap(consumable.name)}
|
alt={unwrap(consumable.name)}
|
||||||
|
|||||||
@@ -3,12 +3,14 @@ import { checkConsumableProvisionInclusivity } from "@blitzkit/core/src/blitzkit
|
|||||||
import { times } from "lodash-es";
|
import { times } from "lodash-es";
|
||||||
import { awaitableConsumableDefinitions } from "../../core/awaitables/consumableDefinitions";
|
import { awaitableConsumableDefinitions } from "../../core/awaitables/consumableDefinitions";
|
||||||
import type { TankFilters } from "../../stores/tankFilters";
|
import type { TankFilters } from "../../stores/tankFilters";
|
||||||
|
import { awaitableGameDefinitions } from "../awaitables/gameDefinitions";
|
||||||
import { awaitableProvisionDefinitions } from "../awaitables/provisionDefinitions";
|
import { awaitableProvisionDefinitions } from "../awaitables/provisionDefinitions";
|
||||||
|
|
||||||
const SHELLS = times(3, (index) => index);
|
const SHELLS = times(3, (index) => index);
|
||||||
|
|
||||||
const consumableDefinitions = await awaitableConsumableDefinitions;
|
const consumableDefinitions = await awaitableConsumableDefinitions;
|
||||||
const provisionDefinitions = await awaitableProvisionDefinitions;
|
const provisionDefinitions = await awaitableProvisionDefinitions;
|
||||||
|
const gameDefinitions = await awaitableGameDefinitions;
|
||||||
|
|
||||||
export async function filterTank(
|
export async function filterTank(
|
||||||
filters: TankFilters,
|
filters: TankFilters,
|
||||||
@@ -72,27 +74,15 @@ export async function filterTank(
|
|||||||
)
|
)
|
||||||
)) &&
|
)) &&
|
||||||
(filters.abilities.length === 0 ||
|
(filters.abilities.length === 0 ||
|
||||||
filters.abilities.every((ability) =>
|
Object.values(tank.roles).some((id) =>
|
||||||
tank.turrets.some((turret) =>
|
gameDefinitions.roles[id as unknown as number].consumables.some(
|
||||||
turret.guns.some((gun) =>
|
(consumable) => filters.abilities.includes(consumable)
|
||||||
checkConsumableProvisionInclusivity(
|
|
||||||
consumableDefinitions.consumables[ability],
|
|
||||||
tank,
|
|
||||||
gun
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
)) &&
|
)) &&
|
||||||
(filters.powers.length === 0 ||
|
(filters.powers.length === 0 ||
|
||||||
filters.powers.every((power) =>
|
Object.values(tank.roles).some((id) =>
|
||||||
tank.turrets.some((turret) =>
|
gameDefinitions.roles[id as unknown as number].provisions.some(
|
||||||
turret.guns.some((gun) =>
|
(consumable) => filters.powers.includes(consumable)
|
||||||
checkConsumableProvisionInclusivity(
|
|
||||||
provisionDefinitions.provisions[power],
|
|
||||||
tank,
|
|
||||||
gun
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
))
|
))
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in new issue
Block a user