mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-11-19 20:03:51 +01:00
Compare commits
16
Commits
f837aaf40a
...
5ed5f45240
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5ed5f45240 | ||
|
|
a8cdc96382 | ||
|
|
532d677491 | ||
|
|
610ea60ca2 | ||
|
|
718576d5a9 | ||
|
|
f885fba4bd | ||
|
|
408a14003c | ||
|
|
9416e25ee9 | ||
|
|
8a3bbb3647 | ||
|
|
e16cc63cfe | ||
|
|
b2856eab58 | ||
|
|
55ffe22fd6 | ||
|
|
98e0f28cd9 | ||
|
|
547381286e | ||
|
|
bdaf6e662c | ||
|
|
87438abaa3 |
No files matched your search
@@ -0,0 +1,13 @@
|
||||
# BlitzKit 1.29.9
|
||||
|
||||
Thank you to [Mark Greene](https://github.com/Hitjack007) for your contributions this update.
|
||||
|
||||
## Features
|
||||
|
||||
- [Mark Greene] Added the ability to filter tanks by consumables
|
||||
- Also added the ability to filter tanks by game-mode abilities and provisions
|
||||
|
||||
## Fixes
|
||||
|
||||
- Consumable and provision icons in Compare are now properly sized
|
||||
- [Mark Greene] Provisions now properly affect terrain resistances
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "blitzkit",
|
||||
"version": "1.29.8",
|
||||
"version": "1.29.9",
|
||||
"license": "BlitzKit License",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
|
||||
@@ -4,54 +4,54 @@ import {
|
||||
GunDefinition,
|
||||
Provision,
|
||||
TankDefinition,
|
||||
} from '../protos';
|
||||
} from "../protos";
|
||||
|
||||
export function checkConsumableProvisionInclusivity(
|
||||
consumableProvision: Consumable | Provision,
|
||||
tank: TankDefinition,
|
||||
gun: GunDefinition,
|
||||
gun: GunDefinition
|
||||
) {
|
||||
const included =
|
||||
!consumableProvision.game_mode_exclusive &&
|
||||
consumableProvision.include?.every((rule) => {
|
||||
switch (rule.filter_type!.$case) {
|
||||
case 'tiers':
|
||||
case "tiers":
|
||||
return (
|
||||
rule.filter_type!.value.min <= tank.tier &&
|
||||
tank.tier <= rule.filter_type!.value.max
|
||||
);
|
||||
|
||||
case 'ids':
|
||||
case "ids":
|
||||
return rule.filter_type!.value.ids.includes(tank.id);
|
||||
|
||||
case 'nations':
|
||||
case "nations":
|
||||
return rule.filter_type!.value.nations.includes(tank.nation);
|
||||
|
||||
case 'categories':
|
||||
throw new SyntaxError('Category filtering found in include rule');
|
||||
case "categories":
|
||||
throw new SyntaxError("Category filtering found in include rule");
|
||||
}
|
||||
});
|
||||
const excluded =
|
||||
consumableProvision.game_mode_exclusive ||
|
||||
consumableProvision.exclude?.some((rule) => {
|
||||
switch (rule.filter_type!.$case) {
|
||||
case 'tiers':
|
||||
case "tiers":
|
||||
return (
|
||||
rule.filter_type!.value.min <= tank.tier &&
|
||||
tank.tier <= rule.filter_type!.value.max
|
||||
);
|
||||
|
||||
case 'ids':
|
||||
case "ids":
|
||||
return rule.filter_type!.value.ids.includes(tank.id);
|
||||
|
||||
case 'nations':
|
||||
case "nations":
|
||||
return rule.filter_type!.value.nations.includes(tank.nation);
|
||||
|
||||
case 'categories':
|
||||
case "categories":
|
||||
return rule.filter_type!.value.categories.some((category) => {
|
||||
switch (category) {
|
||||
case ConsumableTankCategoryFilterCategory.CLIP:
|
||||
return gun.gun_type!.$case !== 'regular';
|
||||
return gun.gun_type!.$case !== "regular";
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -15,7 +15,8 @@
|
||||
"hp": "{value}hp",
|
||||
"x": "x{value}",
|
||||
"percentage": "{value}%",
|
||||
"deg_s": "{value}°/s"
|
||||
"deg_s": "{value}°/s",
|
||||
"plus": "+{value}"
|
||||
},
|
||||
|
||||
"gun_types": {
|
||||
@@ -759,6 +760,8 @@
|
||||
"count_singular": "1 tank",
|
||||
"count_plural": "{count} tanks",
|
||||
"sorting_by": "Sorting by {name}",
|
||||
"clear": "Clear",
|
||||
"tier": "Tier {tier}",
|
||||
|
||||
"no_tanks_found": {
|
||||
"body": "No tanks found.",
|
||||
|
||||
@@ -7,7 +7,13 @@ import {
|
||||
TankType,
|
||||
TIER_ROMAN_NUMERALS,
|
||||
} from "@blitzkit/core";
|
||||
import { TrashIcon } from "@radix-ui/react-icons";
|
||||
import { literals } from "@blitzkit/i18n";
|
||||
import locales from "@blitzkit/i18n/locales.json";
|
||||
import {
|
||||
LockClosedIcon,
|
||||
LockOpen2Icon,
|
||||
TrashIcon,
|
||||
} from "@radix-ui/react-icons";
|
||||
import {
|
||||
Box,
|
||||
Button,
|
||||
@@ -15,11 +21,16 @@ import {
|
||||
Flex,
|
||||
IconButton,
|
||||
Text,
|
||||
Tooltip,
|
||||
type FlexProps,
|
||||
} from "@radix-ui/themes";
|
||||
import { times } from "lodash-es";
|
||||
import type { ComponentProps, ReactNode } from "react";
|
||||
import { awaitableConsumableDefinitions } from "../../../core/awaitables/consumableDefinitions";
|
||||
import { awaitableGameDefinitions } from "../../../core/awaitables/gameDefinitions";
|
||||
import { awaitableProvisionDefinitions } from "../../../core/awaitables/provisionDefinitions";
|
||||
import { useLocale } from "../../../hooks/useLocale";
|
||||
import { App } from "../../../stores/app";
|
||||
import { TankFilters, type CaseType } from "../../../stores/tankFilters";
|
||||
import { classIcons } from "../../ClassIcon";
|
||||
import { GunAutoloaderIcon } from "../../GunAutoloaderIcon";
|
||||
@@ -27,8 +38,63 @@ import { GunAutoreloaderIcon } from "../../GunAutoreloaderIcon";
|
||||
import { GunRegularIcon } from "../../GunRegularIcon";
|
||||
import { MissingShellIcon } from "../../MissingShellIcon";
|
||||
import { ResearchedIcon } from "../../ResearchedIcon";
|
||||
import { ScienceIcon } from "../../ScienceIcon";
|
||||
import { ScienceOffIcon } from "../../ScienceOffIcon";
|
||||
|
||||
const gameDefinitions = await awaitableGameDefinitions;
|
||||
const consumableDefinitions = await awaitableConsumableDefinitions;
|
||||
const provisionDefinitions = await awaitableProvisionDefinitions;
|
||||
|
||||
const consumablesArray = Object.values(consumableDefinitions.consumables)
|
||||
.filter(
|
||||
(consumable) =>
|
||||
!consumable.game_mode_exclusive &&
|
||||
consumable.name.locales[locales.default]
|
||||
)
|
||||
.map((consumable) => consumable.id);
|
||||
const abilitiesArray = Array.from(
|
||||
Object.values(consumableDefinitions.consumables)
|
||||
.filter((ability) => ability.game_mode_exclusive)
|
||||
.reduce((uniqueMap, consumable) => {
|
||||
if (!uniqueMap.has(consumable.name.locales[locales.default])) {
|
||||
uniqueMap.set(consumable.name.locales[locales.default], consumable.id);
|
||||
}
|
||||
|
||||
return uniqueMap;
|
||||
}, new Map<string, number>())
|
||||
.values()
|
||||
);
|
||||
const provisionsArray = Array.from(
|
||||
Object.values(provisionDefinitions.provisions)
|
||||
.filter(
|
||||
(provision) =>
|
||||
!provision.game_mode_exclusive &&
|
||||
provision.name.locales[locales.default]
|
||||
)
|
||||
.reduce((uniqueMap, consumable) => {
|
||||
if (!uniqueMap.has(consumable.name.locales[locales.default])) {
|
||||
uniqueMap.set(consumable.name.locales[locales.default], consumable.id);
|
||||
}
|
||||
|
||||
return uniqueMap;
|
||||
}, new Map<string, number>())
|
||||
.values()
|
||||
);
|
||||
const powersArray = Array.from(
|
||||
Object.values(provisionDefinitions.provisions)
|
||||
.filter(
|
||||
(provision) =>
|
||||
provision.game_mode_exclusive && provision.name.locales[locales.default]
|
||||
)
|
||||
.reduce((uniqueMap, consumable) => {
|
||||
if (!uniqueMap.has(consumable.name.locales[locales.default])) {
|
||||
uniqueMap.set(consumable.name.locales[locales.default], consumable.id);
|
||||
}
|
||||
|
||||
return uniqueMap;
|
||||
}, new Map<string, number>())
|
||||
.values()
|
||||
);
|
||||
|
||||
const shellTypeIcons: Record<ShellType, string> = {
|
||||
[ShellType.AP]: "ap",
|
||||
@@ -56,40 +122,72 @@ const GUN_TYPES = Object.keys(
|
||||
GUN_TYPE_ICONS
|
||||
) as (keyof typeof GUN_TYPE_ICONS)[];
|
||||
|
||||
const MAX_TIERS = 4;
|
||||
const MAX_ICONS = 4;
|
||||
|
||||
const TIERS = times(10, (i) => 10 - i);
|
||||
|
||||
export function FilterControl() {
|
||||
return (
|
||||
<Flex align="center" gap="2" wrap="wrap">
|
||||
<Flex align="center" gap="2" wrap="wrap" justify="center">
|
||||
<TiersFilter />
|
||||
<NationsFilter />
|
||||
<TypeFilter />
|
||||
<ClassFilter />
|
||||
<TypeFilter />
|
||||
<NationsFilter />
|
||||
|
||||
<OwnershipFilter />
|
||||
<TestFilter />
|
||||
|
||||
<GunTypeFilter />
|
||||
<ShellFilter />
|
||||
<ConsumablesFilter />
|
||||
<ProvisionsFilter />
|
||||
<AbilitiesFilter />
|
||||
<PowersFilter />
|
||||
|
||||
<ClearButton />
|
||||
</Flex>
|
||||
);
|
||||
}
|
||||
|
||||
function ClearButton() {
|
||||
const { strings } = useLocale();
|
||||
|
||||
return (
|
||||
<Button
|
||||
color="red"
|
||||
variant="surface"
|
||||
onClick={() => {
|
||||
TankFilters.set(TankFilters.initial);
|
||||
}}
|
||||
>
|
||||
<TrashIcon />
|
||||
{strings.website.common.tank_search.clear}
|
||||
</Button>
|
||||
);
|
||||
}
|
||||
|
||||
function TiersFilter() {
|
||||
const { strings } = useLocale();
|
||||
const tiersRaw = TankFilters.use((state) => state.tiers);
|
||||
const tiers = tiersRaw.length === 0 ? TIERS : tiersRaw;
|
||||
|
||||
return (
|
||||
<DropdownMenu.Root>
|
||||
<DropdownMenu.Root modal={false}>
|
||||
<DropdownMenu.Trigger>
|
||||
<Button color="gray" variant="surface">
|
||||
<Flex gap="1">
|
||||
{tiers.slice(0, MAX_TIERS).map((tier) => (
|
||||
{tiers.slice(0, MAX_ICONS).map((tier) => (
|
||||
<Text size="1" key={tier}>
|
||||
{TIER_ROMAN_NUMERALS[tier]}
|
||||
</Text>
|
||||
))}
|
||||
|
||||
{tiers.length > MAX_TIERS && (
|
||||
<Text size="1">+{tiers.length - MAX_TIERS}</Text>
|
||||
{tiers.length > MAX_ICONS && (
|
||||
<Text size="1">
|
||||
{literals(strings.common.units.plus, {
|
||||
value: tiers.length - MAX_ICONS,
|
||||
})}
|
||||
</Text>
|
||||
)}
|
||||
</Flex>
|
||||
</Button>
|
||||
@@ -115,7 +213,9 @@ function TiersFilter() {
|
||||
checked={selected}
|
||||
key={tier}
|
||||
>
|
||||
Tier {TIER_ROMAN_NUMERALS[tier]}
|
||||
{literals(strings.website.common.tank_search.tier, {
|
||||
tier: TIER_ROMAN_NUMERALS[tier],
|
||||
})}
|
||||
</DropdownMenu.CheckboxItem>
|
||||
);
|
||||
})}
|
||||
@@ -133,7 +233,7 @@ function TiersFilter() {
|
||||
}}
|
||||
>
|
||||
<TrashIcon />
|
||||
Clear
|
||||
{strings.website.common.tank_search.clear}
|
||||
</DropdownMenu.Item>
|
||||
</DropdownMenu.Content>
|
||||
</DropdownMenu.Root>
|
||||
@@ -147,12 +247,13 @@ function NationsFilter() {
|
||||
const { strings } = useLocale();
|
||||
|
||||
return (
|
||||
<DropdownMenu.Root>
|
||||
<DropdownMenu.Root modal={false}>
|
||||
<DropdownMenu.Trigger>
|
||||
<Button color="gray" variant="surface">
|
||||
<Flex>
|
||||
{nations.map((nation, index) => (
|
||||
<img
|
||||
key={nation}
|
||||
style={{
|
||||
filter: "drop-shadow(0 0 var(--space-1) var(--black-a11))",
|
||||
marginLeft: index > 0 ? "-0.5em" : undefined,
|
||||
@@ -237,7 +338,7 @@ function NationsFilter() {
|
||||
}}
|
||||
>
|
||||
<TrashIcon />
|
||||
Clear
|
||||
{strings.website.common.tank_search.clear}
|
||||
</DropdownMenu.Item>
|
||||
</DropdownMenu.Content>
|
||||
</DropdownMenu.Root>
|
||||
@@ -250,7 +351,7 @@ function ClassFilter() {
|
||||
const classes = rawClasses.length === 0 ? TANK_CLASSES : rawClasses;
|
||||
|
||||
return (
|
||||
<DropdownMenu.Root>
|
||||
<DropdownMenu.Root modal={false}>
|
||||
<DropdownMenu.Trigger>
|
||||
<Button color="gray" variant="surface">
|
||||
<Flex>
|
||||
@@ -258,6 +359,7 @@ function ClassFilter() {
|
||||
const Icon = classIcons[tankClass];
|
||||
return (
|
||||
<Icon
|
||||
key={tankClass}
|
||||
style={{
|
||||
color: "var(--gray-12)",
|
||||
opacity: 1,
|
||||
@@ -266,7 +368,6 @@ function ClassFilter() {
|
||||
width: "1.25em",
|
||||
height: "1.25em",
|
||||
}}
|
||||
key={tankClass}
|
||||
/>
|
||||
);
|
||||
})}
|
||||
@@ -281,6 +382,7 @@ function ClassFilter() {
|
||||
|
||||
return (
|
||||
<DropdownMenu.CheckboxItem
|
||||
key={tankClass}
|
||||
onClick={(event) => {
|
||||
event.preventDefault();
|
||||
|
||||
@@ -295,9 +397,8 @@ function ClassFilter() {
|
||||
});
|
||||
}}
|
||||
checked={selected}
|
||||
key={tankClass}
|
||||
>
|
||||
<Icon style={{ width: "1em", height: "1em" }} />
|
||||
<Icon style={{ width: "1.25em", height: "1.25em" }} />
|
||||
|
||||
{strings.common.tank_class_medium[tankClass]}
|
||||
</DropdownMenu.CheckboxItem>
|
||||
@@ -317,7 +418,7 @@ function ClassFilter() {
|
||||
}}
|
||||
>
|
||||
<TrashIcon />
|
||||
Clear
|
||||
{strings.website.common.tank_search.clear}
|
||||
</DropdownMenu.Item>
|
||||
</DropdownMenu.Content>
|
||||
</DropdownMenu.Root>
|
||||
@@ -330,7 +431,7 @@ function GunTypeFilter() {
|
||||
const { strings } = useLocale();
|
||||
|
||||
return (
|
||||
<DropdownMenu.Root>
|
||||
<DropdownMenu.Root modal={false}>
|
||||
<DropdownMenu.Trigger>
|
||||
<Button color="gray" variant="surface">
|
||||
<Flex>
|
||||
@@ -339,6 +440,7 @@ function GunTypeFilter() {
|
||||
|
||||
return (
|
||||
<Icon
|
||||
key={gunType}
|
||||
style={{
|
||||
margin: gunType === "regular" ? "0 -0.125em" : undefined,
|
||||
opacity: 1,
|
||||
@@ -346,7 +448,6 @@ function GunTypeFilter() {
|
||||
width: "1.25em",
|
||||
height: "1.25em",
|
||||
}}
|
||||
key={gunType}
|
||||
/>
|
||||
);
|
||||
})}
|
||||
@@ -375,7 +476,7 @@ function GunTypeFilter() {
|
||||
checked={selected}
|
||||
key={gunType}
|
||||
>
|
||||
<Icon style={{ width: "1em", height: "1em" }} />
|
||||
<Icon style={{ width: "1.25em", height: "1.25em" }} />
|
||||
|
||||
{strings.common.gun_types[gunType]}
|
||||
</DropdownMenu.CheckboxItem>
|
||||
@@ -395,7 +496,7 @@ function GunTypeFilter() {
|
||||
}}
|
||||
>
|
||||
<TrashIcon />
|
||||
Clear
|
||||
{strings.website.common.tank_search.clear}
|
||||
</DropdownMenu.Item>
|
||||
</DropdownMenu.Content>
|
||||
</DropdownMenu.Root>
|
||||
@@ -408,7 +509,7 @@ function TypeFilter() {
|
||||
const types = rawTypes.length === 0 ? TANK_TYPES : rawTypes;
|
||||
|
||||
return (
|
||||
<DropdownMenu.Root>
|
||||
<DropdownMenu.Root modal={false}>
|
||||
<DropdownMenu.Trigger>
|
||||
<Button color="gray" variant="surface">
|
||||
<Flex gap="1">
|
||||
@@ -458,8 +559,8 @@ function TypeFilter() {
|
||||
tankType === TankType.RESEARCHABLE ? "12" : "11"
|
||||
})`,
|
||||
opacity: 1,
|
||||
width: "1em",
|
||||
height: "1em",
|
||||
width: "1.25em",
|
||||
height: "1.25em",
|
||||
}}
|
||||
/>
|
||||
|
||||
@@ -481,7 +582,7 @@ function TypeFilter() {
|
||||
}}
|
||||
>
|
||||
<TrashIcon />
|
||||
Clear
|
||||
{strings.website.common.tank_search.clear}
|
||||
</DropdownMenu.Item>
|
||||
</DropdownMenu.Content>
|
||||
</DropdownMenu.Root>
|
||||
@@ -509,7 +610,7 @@ function IndividualShellFilter({
|
||||
const shells = TankFilters.use((state) => state.shells);
|
||||
|
||||
return (
|
||||
<DropdownMenu.Root>
|
||||
<DropdownMenu.Root modal={false}>
|
||||
<DropdownMenu.Trigger>
|
||||
<IconButton
|
||||
ml="-0.5px"
|
||||
@@ -552,7 +653,9 @@ function IndividualShellFilter({
|
||||
<DropdownMenu.RadioItem
|
||||
key={shellType}
|
||||
value={`${shellType}`}
|
||||
onClick={() => {
|
||||
onClick={(event) => {
|
||||
event.preventDefault();
|
||||
|
||||
const mutated = [...shells] as TankFilters["shells"];
|
||||
|
||||
mutated[index] = selected ? null : shellType;
|
||||
@@ -569,7 +672,7 @@ function IndividualShellFilter({
|
||||
premium ? "_premium" : ""
|
||||
}.webp`
|
||||
)}
|
||||
style={{ width: "1em", height: "1em" }}
|
||||
style={{ width: "1.25em", height: "1.25em" }}
|
||||
/>
|
||||
|
||||
{
|
||||
@@ -582,8 +685,506 @@ function IndividualShellFilter({
|
||||
</DropdownMenu.RadioItem>
|
||||
);
|
||||
})}
|
||||
|
||||
<DropdownMenu.Separator />
|
||||
|
||||
<DropdownMenu.Item
|
||||
color="red"
|
||||
onClick={(event) => {
|
||||
event.preventDefault();
|
||||
|
||||
const mutated = [...shells] as TankFilters["shells"];
|
||||
|
||||
mutated[index] = null;
|
||||
|
||||
TankFilters.mutate((draft) => {
|
||||
draft.shells = mutated;
|
||||
});
|
||||
}}
|
||||
>
|
||||
<TrashIcon />
|
||||
{strings.website.common.tank_search.clear}
|
||||
</DropdownMenu.Item>
|
||||
</DropdownMenu.RadioGroup>
|
||||
</DropdownMenu.Content>
|
||||
</DropdownMenu.Root>
|
||||
);
|
||||
}
|
||||
|
||||
function OwnershipFilter() {
|
||||
const wargaming = App.use((state) => state.logins.wargaming);
|
||||
const { strings } = useLocale();
|
||||
|
||||
return wargaming ? (
|
||||
<OwnershipFilterInternal />
|
||||
) : (
|
||||
<Tooltip content={strings.website.common.tank_search.login}>
|
||||
<OwnershipFilterInternal />
|
||||
</Tooltip>
|
||||
);
|
||||
}
|
||||
|
||||
function OwnershipFilterInternal(props: FlexProps) {
|
||||
const wargaming = App.use((state) => state.logins.wargaming);
|
||||
const showOwned = TankFilters.use((state) => state.showOwned);
|
||||
const showUnowned = TankFilters.use((state) => state.showUnowned);
|
||||
|
||||
return (
|
||||
<Flex {...props}>
|
||||
<IconButton
|
||||
style={{
|
||||
borderTopRightRadius: 0,
|
||||
borderBottomRightRadius: 0,
|
||||
}}
|
||||
disabled={!wargaming}
|
||||
variant={showOwned ? "solid" : "surface"}
|
||||
color={showOwned ? undefined : "gray"}
|
||||
highContrast
|
||||
onClick={() => {
|
||||
TankFilters.mutate((draft) => {
|
||||
draft.showOwned = !draft.showOwned;
|
||||
});
|
||||
}}
|
||||
>
|
||||
<LockOpen2Icon />
|
||||
</IconButton>
|
||||
|
||||
<IconButton
|
||||
style={{
|
||||
borderTopLeftRadius: 0,
|
||||
borderBottomLeftRadius: 0,
|
||||
marginLeft: "-1px",
|
||||
}}
|
||||
disabled={!wargaming}
|
||||
variant={showUnowned ? "solid" : "surface"}
|
||||
color={showUnowned ? undefined : "gray"}
|
||||
highContrast
|
||||
onClick={() => {
|
||||
TankFilters.mutate((draft) => {
|
||||
draft.showUnowned = !draft.showUnowned;
|
||||
});
|
||||
}}
|
||||
>
|
||||
<LockClosedIcon />
|
||||
</IconButton>
|
||||
</Flex>
|
||||
);
|
||||
}
|
||||
|
||||
function TestFilter() {
|
||||
const showTesting = TankFilters.use((state) => state.showTesting);
|
||||
const showNonTesting = TankFilters.use((state) => state.showNonTesting);
|
||||
|
||||
return (
|
||||
<Flex>
|
||||
<IconButton
|
||||
style={{
|
||||
borderTopRightRadius: 0,
|
||||
borderBottomRightRadius: 0,
|
||||
}}
|
||||
variant={showNonTesting ? "solid" : "surface"}
|
||||
color={showNonTesting ? undefined : "gray"}
|
||||
highContrast
|
||||
onClick={() => {
|
||||
TankFilters.mutate((draft) => {
|
||||
draft.showNonTesting = !draft.showNonTesting;
|
||||
});
|
||||
}}
|
||||
>
|
||||
<ScienceOffIcon
|
||||
style={{ width: "1em", height: "1em", color: "currentColor" }}
|
||||
/>
|
||||
</IconButton>
|
||||
|
||||
<IconButton
|
||||
style={{
|
||||
borderTopLeftRadius: 0,
|
||||
borderBottomLeftRadius: 0,
|
||||
marginLeft: "-1px",
|
||||
}}
|
||||
variant={showTesting ? "solid" : "surface"}
|
||||
color={showTesting ? undefined : "gray"}
|
||||
highContrast
|
||||
onClick={() => {
|
||||
TankFilters.mutate((draft) => {
|
||||
draft.showTesting = !draft.showTesting;
|
||||
});
|
||||
}}
|
||||
>
|
||||
<ScienceIcon
|
||||
style={{ width: "1em", height: "1em", color: "currentColor" }}
|
||||
/>
|
||||
</IconButton>
|
||||
</Flex>
|
||||
);
|
||||
}
|
||||
|
||||
function ConsumablesFilter() {
|
||||
const { unwrap, strings } = useLocale();
|
||||
const rawConsumables = TankFilters.use((state) => state.consumables);
|
||||
const consumables =
|
||||
rawConsumables.length === 0 ? consumablesArray : rawConsumables;
|
||||
|
||||
return (
|
||||
<DropdownMenu.Root modal={false}>
|
||||
<DropdownMenu.Trigger>
|
||||
<Button color="gray" variant="surface">
|
||||
<Flex>
|
||||
{consumables.slice(0, MAX_ICONS).map((consumable, index) => (
|
||||
<img
|
||||
key={consumable}
|
||||
style={{
|
||||
filter: "drop-shadow(0 0 var(--space-1) var(--black-a11))",
|
||||
marginLeft: index > 0 ? "-0.5em" : undefined,
|
||||
width: "1.25em",
|
||||
height: "1.25em",
|
||||
objectFit: "contain",
|
||||
}}
|
||||
src={asset(`icons/consumables/${consumable}.webp`)}
|
||||
/>
|
||||
))}
|
||||
|
||||
{consumables.length > MAX_ICONS && (
|
||||
<Text size="1" ml="1">
|
||||
{literals(strings.common.units.plus, {
|
||||
value: consumables.length - MAX_ICONS,
|
||||
})}
|
||||
</Text>
|
||||
)}
|
||||
</Flex>
|
||||
</Button>
|
||||
</DropdownMenu.Trigger>
|
||||
|
||||
<DropdownMenu.Content>
|
||||
{consumablesArray.map((consumable) => {
|
||||
const selected = rawConsumables.includes(consumable);
|
||||
const consumableDefinition =
|
||||
consumableDefinitions.consumables[consumable];
|
||||
|
||||
return (
|
||||
<DropdownMenu.CheckboxItem
|
||||
onClick={(event) => {
|
||||
event.preventDefault();
|
||||
|
||||
TankFilters.mutate((draft) => {
|
||||
if (selected) {
|
||||
draft.consumables = draft.consumables.filter(
|
||||
(n) => n !== consumable
|
||||
);
|
||||
} else {
|
||||
draft.consumables = [...draft.consumables, consumable];
|
||||
}
|
||||
});
|
||||
}}
|
||||
checked={selected}
|
||||
key={consumable}
|
||||
>
|
||||
<img
|
||||
style={{
|
||||
width: "1.25em",
|
||||
height: "1.25em",
|
||||
objectFit: "contain",
|
||||
}}
|
||||
src={asset(`icons/consumables/${consumable}.webp`)}
|
||||
/>
|
||||
|
||||
{unwrap(consumableDefinition.name)}
|
||||
</DropdownMenu.CheckboxItem>
|
||||
);
|
||||
})}
|
||||
|
||||
<DropdownMenu.Separator />
|
||||
|
||||
<DropdownMenu.Item
|
||||
color="red"
|
||||
onClick={(event) => {
|
||||
event.preventDefault();
|
||||
|
||||
TankFilters.mutate((draft) => {
|
||||
draft.consumables = [];
|
||||
});
|
||||
}}
|
||||
>
|
||||
<TrashIcon />
|
||||
{strings.website.common.tank_search.clear}
|
||||
</DropdownMenu.Item>
|
||||
</DropdownMenu.Content>
|
||||
</DropdownMenu.Root>
|
||||
);
|
||||
}
|
||||
|
||||
function ProvisionsFilter() {
|
||||
const { unwrap, strings } = useLocale();
|
||||
const rawProvisions = TankFilters.use((state) => state.provisions);
|
||||
const provisions =
|
||||
rawProvisions.length === 0 ? provisionsArray : rawProvisions;
|
||||
|
||||
return (
|
||||
<DropdownMenu.Root modal={false}>
|
||||
<DropdownMenu.Trigger>
|
||||
<Button color="gray" variant="surface">
|
||||
<Flex>
|
||||
{provisions.slice(0, MAX_ICONS).map((provision, index) => (
|
||||
<img
|
||||
key={provision}
|
||||
style={{
|
||||
filter: "drop-shadow(0 0 var(--space-1) var(--black-a11))",
|
||||
marginLeft: index > 0 ? "-0.5em" : undefined,
|
||||
width: "1.25em",
|
||||
height: "1.25em",
|
||||
objectFit: "contain",
|
||||
}}
|
||||
src={asset(`icons/provisions/${provision}.webp`)}
|
||||
/>
|
||||
))}
|
||||
|
||||
{provisions.length > MAX_ICONS && (
|
||||
<Text size="1" ml="1">
|
||||
{literals(strings.common.units.plus, {
|
||||
value: provisions.length - MAX_ICONS,
|
||||
})}
|
||||
</Text>
|
||||
)}
|
||||
</Flex>
|
||||
</Button>
|
||||
</DropdownMenu.Trigger>
|
||||
|
||||
<DropdownMenu.Content>
|
||||
{provisionsArray.map((provision) => {
|
||||
const selected = rawProvisions.includes(provision);
|
||||
const provisionDefinition =
|
||||
provisionDefinitions.provisions[provision];
|
||||
|
||||
return (
|
||||
<DropdownMenu.CheckboxItem
|
||||
onClick={(event) => {
|
||||
event.preventDefault();
|
||||
|
||||
TankFilters.mutate((draft) => {
|
||||
if (selected) {
|
||||
draft.provisions = draft.provisions.filter(
|
||||
(n) => n !== provision
|
||||
);
|
||||
} else {
|
||||
draft.provisions = [...draft.provisions, provision];
|
||||
}
|
||||
});
|
||||
}}
|
||||
checked={selected}
|
||||
key={provision}
|
||||
>
|
||||
<img
|
||||
style={{
|
||||
width: "1.25em",
|
||||
height: "1.25em",
|
||||
objectFit: "contain",
|
||||
}}
|
||||
src={asset(`icons/provisions/${provision}.webp`)}
|
||||
/>
|
||||
|
||||
{unwrap(provisionDefinition.name)}
|
||||
</DropdownMenu.CheckboxItem>
|
||||
);
|
||||
})}
|
||||
|
||||
<DropdownMenu.Separator />
|
||||
|
||||
<DropdownMenu.Item
|
||||
color="red"
|
||||
onClick={(event) => {
|
||||
event.preventDefault();
|
||||
|
||||
TankFilters.mutate((draft) => {
|
||||
draft.provisions = [];
|
||||
});
|
||||
}}
|
||||
>
|
||||
<TrashIcon />
|
||||
{strings.website.common.tank_search.clear}
|
||||
</DropdownMenu.Item>
|
||||
</DropdownMenu.Content>
|
||||
</DropdownMenu.Root>
|
||||
);
|
||||
}
|
||||
|
||||
function PowersFilter() {
|
||||
const { unwrap, strings } = useLocale();
|
||||
const rawPowers = TankFilters.use((state) => state.powers);
|
||||
const powers = rawPowers.length === 0 ? powersArray : rawPowers;
|
||||
|
||||
return (
|
||||
<DropdownMenu.Root modal={false}>
|
||||
<DropdownMenu.Trigger>
|
||||
<Button color="gray" variant="surface">
|
||||
<Flex>
|
||||
{powers.slice(0, MAX_ICONS).map((power, index) => (
|
||||
<img
|
||||
key={power}
|
||||
style={{
|
||||
filter: "drop-shadow(0 0 var(--space-1) var(--black-a11))",
|
||||
marginLeft: index > 0 ? "-0.5em" : undefined,
|
||||
width: "1.25em",
|
||||
height: "1.25em",
|
||||
objectFit: "contain",
|
||||
}}
|
||||
src={asset(`icons/provisions/${power}.webp`)}
|
||||
/>
|
||||
))}
|
||||
|
||||
{powers.length > MAX_ICONS && (
|
||||
<Text size="1" ml="1">
|
||||
{literals(strings.common.units.plus, {
|
||||
value: powers.length - MAX_ICONS,
|
||||
})}
|
||||
</Text>
|
||||
)}
|
||||
</Flex>
|
||||
</Button>
|
||||
</DropdownMenu.Trigger>
|
||||
|
||||
<DropdownMenu.Content>
|
||||
{powersArray.map((power) => {
|
||||
const selected = rawPowers.includes(power);
|
||||
const powerDefinition = provisionDefinitions.provisions[power];
|
||||
|
||||
return (
|
||||
<DropdownMenu.CheckboxItem
|
||||
onClick={(event) => {
|
||||
event.preventDefault();
|
||||
|
||||
TankFilters.mutate((draft) => {
|
||||
if (selected) {
|
||||
draft.powers = draft.powers.filter((n) => n !== power);
|
||||
} else {
|
||||
draft.powers = [...draft.powers, power];
|
||||
}
|
||||
});
|
||||
}}
|
||||
checked={selected}
|
||||
key={power}
|
||||
>
|
||||
<img
|
||||
style={{
|
||||
width: "1.25em",
|
||||
height: "1.25em",
|
||||
objectFit: "contain",
|
||||
}}
|
||||
src={asset(`icons/provisions/${power}.webp`)}
|
||||
/>
|
||||
|
||||
{unwrap(powerDefinition.name)}
|
||||
</DropdownMenu.CheckboxItem>
|
||||
);
|
||||
})}
|
||||
|
||||
<DropdownMenu.Separator />
|
||||
|
||||
<DropdownMenu.Item
|
||||
color="red"
|
||||
onClick={(event) => {
|
||||
event.preventDefault();
|
||||
|
||||
TankFilters.mutate((draft) => {
|
||||
draft.powers = [];
|
||||
});
|
||||
}}
|
||||
>
|
||||
<TrashIcon />
|
||||
{strings.website.common.tank_search.clear}
|
||||
</DropdownMenu.Item>
|
||||
</DropdownMenu.Content>
|
||||
</DropdownMenu.Root>
|
||||
);
|
||||
}
|
||||
|
||||
function AbilitiesFilter() {
|
||||
const { unwrap, strings } = useLocale();
|
||||
const rawAbilities = TankFilters.use((state) => state.abilities);
|
||||
const abilities = rawAbilities.length === 0 ? abilitiesArray : rawAbilities;
|
||||
|
||||
return (
|
||||
<DropdownMenu.Root modal={false}>
|
||||
<DropdownMenu.Trigger>
|
||||
<Button color="gray" variant="surface">
|
||||
<Flex>
|
||||
{abilities.slice(0, MAX_ICONS).map((ability, index) => (
|
||||
<img
|
||||
key={ability}
|
||||
style={{
|
||||
filter: "drop-shadow(0 0 var(--space-1) var(--black-a11))",
|
||||
marginLeft: index > 0 ? "-0.5em" : undefined,
|
||||
width: "1.25em",
|
||||
height: "1.25em",
|
||||
objectFit: "contain",
|
||||
}}
|
||||
src={asset(`icons/consumables/${ability}.webp`)}
|
||||
/>
|
||||
))}
|
||||
|
||||
{abilities.length > MAX_ICONS && (
|
||||
<Text size="1" ml="1">
|
||||
{literals(strings.common.units.plus, {
|
||||
value: abilities.length - MAX_ICONS,
|
||||
})}
|
||||
</Text>
|
||||
)}
|
||||
</Flex>
|
||||
</Button>
|
||||
</DropdownMenu.Trigger>
|
||||
|
||||
<DropdownMenu.Content>
|
||||
{abilitiesArray.map((ability) => {
|
||||
const selected = rawAbilities.includes(ability);
|
||||
const abilityDefinition = consumableDefinitions.consumables[ability];
|
||||
|
||||
return (
|
||||
<DropdownMenu.CheckboxItem
|
||||
onClick={(event) => {
|
||||
event.preventDefault();
|
||||
|
||||
TankFilters.mutate((draft) => {
|
||||
if (selected) {
|
||||
draft.abilities = draft.abilities.filter(
|
||||
(n) => n !== ability
|
||||
);
|
||||
} else {
|
||||
draft.abilities = [...draft.abilities, ability];
|
||||
}
|
||||
});
|
||||
}}
|
||||
checked={selected}
|
||||
key={ability}
|
||||
>
|
||||
<img
|
||||
style={{
|
||||
width: "1.25em",
|
||||
height: "1.25em",
|
||||
objectFit: "contain",
|
||||
}}
|
||||
src={asset(`icons/consumables/${ability}.webp`)}
|
||||
/>
|
||||
|
||||
{unwrap(abilityDefinition.name)}
|
||||
</DropdownMenu.CheckboxItem>
|
||||
);
|
||||
})}
|
||||
|
||||
<DropdownMenu.Separator />
|
||||
|
||||
<DropdownMenu.Item
|
||||
color="red"
|
||||
onClick={(event) => {
|
||||
event.preventDefault();
|
||||
|
||||
TankFilters.mutate((draft) => {
|
||||
draft.abilities = [];
|
||||
});
|
||||
}}
|
||||
>
|
||||
<TrashIcon />
|
||||
{strings.website.common.tank_search.clear}
|
||||
</DropdownMenu.Item>
|
||||
</DropdownMenu.Content>
|
||||
</DropdownMenu.Root>
|
||||
);
|
||||
}
|
||||
@@ -3,10 +3,12 @@ import { checkConsumableProvisionInclusivity } from "@blitzkit/core/src/blitzkit
|
||||
import { times } from "lodash-es";
|
||||
import { awaitableConsumableDefinitions } from "../../core/awaitables/consumableDefinitions";
|
||||
import type { TankFilters } from "../../stores/tankFilters";
|
||||
import { awaitableProvisionDefinitions } from "../awaitables/provisionDefinitions";
|
||||
|
||||
const SHELLS = times(3, (index) => index);
|
||||
|
||||
const consumableDefinitions = await awaitableConsumableDefinitions;
|
||||
const provisionDefinitions = await awaitableProvisionDefinitions;
|
||||
|
||||
export async function filterTank(
|
||||
filters: TankFilters,
|
||||
@@ -46,11 +48,47 @@ export async function filterTank(
|
||||
)
|
||||
) &&
|
||||
(filters.consumables.length === 0 ||
|
||||
filters.consumables.every((consumableId) =>
|
||||
filters.consumables.every((consumable) =>
|
||||
tank.turrets.some((turret) =>
|
||||
turret.guns.some((gun) =>
|
||||
checkConsumableProvisionInclusivity(
|
||||
consumableDefinitions.consumables[consumableId],
|
||||
consumableDefinitions.consumables[consumable],
|
||||
tank,
|
||||
gun
|
||||
)
|
||||
)
|
||||
)
|
||||
)) &&
|
||||
(filters.provisions.length === 0 ||
|
||||
filters.provisions.every((provision) =>
|
||||
tank.turrets.some((turret) =>
|
||||
turret.guns.some((gun) =>
|
||||
checkConsumableProvisionInclusivity(
|
||||
provisionDefinitions.provisions[provision],
|
||||
tank,
|
||||
gun
|
||||
)
|
||||
)
|
||||
)
|
||||
)) &&
|
||||
(filters.abilities.length === 0 ||
|
||||
filters.abilities.every((ability) =>
|
||||
tank.turrets.some((turret) =>
|
||||
turret.guns.some((gun) =>
|
||||
checkConsumableProvisionInclusivity(
|
||||
consumableDefinitions.consumables[ability],
|
||||
tank,
|
||||
gun
|
||||
)
|
||||
)
|
||||
)
|
||||
)) &&
|
||||
(filters.powers.length === 0 ||
|
||||
filters.powers.every((power) =>
|
||||
tank.turrets.some((turret) =>
|
||||
turret.guns.some((gun) =>
|
||||
checkConsumableProvisionInclusivity(
|
||||
provisionDefinitions.provisions[power],
|
||||
tank,
|
||||
gun
|
||||
)
|
||||
|
||||
@@ -12,7 +12,7 @@ export function Page({
|
||||
}: LocaleAcceptorProps & MaybeSkeletonComponentProps) {
|
||||
return (
|
||||
<LocaleProvider locale={locale}>
|
||||
<PageWrapper color="purple" maxWidth="80rem">
|
||||
<PageWrapper color="purple" maxWidth="90rem">
|
||||
<TankSearch skeleton={skeleton} />
|
||||
</PageWrapper>
|
||||
</LocaleProvider>
|
||||
|
||||
@@ -22,6 +22,9 @@ export interface TankFilters {
|
||||
gunType: CaseType<GunDefinition>[];
|
||||
shells: [ShellType | null, ShellType | null, ShellType | null];
|
||||
consumables: number[];
|
||||
provisions: number[];
|
||||
abilities: number[];
|
||||
powers: number[];
|
||||
|
||||
showTesting: boolean;
|
||||
showNonTesting: boolean;
|
||||
@@ -39,6 +42,9 @@ export const TankFilters = new Varuna<TankFilters>({
|
||||
gunType: [],
|
||||
shells: [null, null, null],
|
||||
consumables: [],
|
||||
provisions: [],
|
||||
abilities: [],
|
||||
powers: [],
|
||||
|
||||
showTesting: true,
|
||||
showNonTesting: true,
|
||||
|
||||
Reference in new issue
Block a user