Compare commits

...
14 Commits
Author SHA1 Message Date
TrèsAbhi 50f82d68b4 feat: logs 2025-10-14 22:34:11 -05:00
TrèsAbhi b81f664379 Merge branch 'main' into dev 2025-10-14 22:28:12 -05:00
TrèsAbhi 389707d0c8 fix: keys 2025-10-14 22:28:00 -05:00
TrèsAbhi 9fbd623d91 feat: enable playlist 2025-10-14 22:27:12 -05:00
TrèsAbhi f36df9e902 feat: landing page for mobile 2025-10-14 22:26:13 -05:00
TrèsAbhi 437bbfdc89 feat: large warning 2025-10-14 22:21:22 -05:00
TrèsAbhi 7becb7b6ad fix: modify only when needed 2025-10-14 22:06:01 -05:00
TrèsAbhi 94e8a07f90 feat: hide playlist 2025-10-14 22:03:51 -05:00
TrèsAbhi 4ae5283ac4 feat: landing page cleanup 2025-10-14 22:02:47 -05:00
TrèsAbhi ade238966b feat: some cleanup 2025-10-14 21:53:58 -05:00
TrèsAbhi ea048da7a2 feat: tracking 2025-10-14 21:36:37 -05:00
TrèsAbhi 263f292a59 feat: shuffle button 2025-10-14 20:19:52 -05:00
TrèsAbhi ff4a87e5b8 perf: reactive updates 2025-10-14 20:15:00 -05:00
TrèsAbhi 927495ca16 New translations en.json (Chinese Simplified) (#174) 2025-10-13 16:41:50 -05:00
22 changed files with 530 additions and 258 deletions

No files matched your search

+12
View File
@@ -0,0 +1,12 @@
# BlitzKit 1.29.0
## Features
- Added the Playlist tool
- Don't know what to play today? Let BlitzKit do the thinking!
- Navigate to [the tool on BlitzKit](https://blitzkit.app/playlist)
- Make sure you login with your Wargaming account to unlock all features like live tracking and filtering by owned tanks
- Use filters to pick tiers, nations, etc. then hit Generate playlist
- BlitzKit will generate a checklist for you to go through as you play
- Don't like the order of tanks? Hit Shuffle, Sort by Last played and Least played, or straight up remove tanks from the list by using the (-) button
- If you're logged in, BlitzKit will automatically check off tanks as you play them
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "blitzkit",
"private": true,
"version": "1.28.4",
"version": "1.29.0",
"description": "🎉 Tools for everything World of Tanks Blitz",
"type": "module",
"types": "./types.d.ts",
+8
View File
@@ -0,0 +1,8 @@
export function fisherYates<Type extends unknown[]>(array: Type) {
for (let i = array.length - 1; i > 0; i--) {
const j = Math.floor(Math.random() * (i + 1));
[array[i], array[j]] = [array[j], array[i]];
}
return array;
}
+8 -7
View File
@@ -1,7 +1,8 @@
export * from './axis';
export * from './formatCompact';
export * from './isNumber';
export * from './NaNFallback';
export * from './normalizeAngleRad';
export * from './normalToEuler';
export * from './numberToRomanNumeral';
export * from "./axis";
export * from "./fisherYates";
export * from "./formatCompact";
export * from "./isNumber";
export * from "./NaNFallback";
export * from "./normalizeAngleRad";
export * from "./normalToEuler";
export * from "./numberToRomanNumeral";
+19 -3
View File
@@ -862,16 +862,32 @@
"playlist": {
"reset": "Reset",
"shuffle": "Shuffle",
"sort": "Sort by",
"remove": "Remove played",
"tracking": "BlitzKit is tracking your battles",
"sort": {
"button": "Sort by",
"last_played": "Last played",
"least_played": "Least played"
},
"table": {
"index": "#",
"never": "Never",
"tank": "Tank",
"last_played": "Last played",
"battles": "Battles"
"battles": "Career battles",
"unrecorded": "--",
"wins": "Wins"
},
"no_login_warning": "You are not logged in. BlitzKit will not keep track of your played tanks.",
"large_warning": {
"title": "That's a lot of tanks!",
"description": "Are you sure you want to create a playlist of {count} tanks? That's {time} hours of gameplay at 50% winrate!",
"cancel": "Cancel",
"proceed": "Proceed"
},
"generate": "Generate playlist",
"name": "Playlist",
"description": "Tank playlist generator",
+16 -16
View File
@@ -186,11 +186,11 @@
"bot": {
"common": {
"errors": {
"clan_not_found": "# Could not find clan\nCouldn't find \"{search}\". Try selecting a clan from the search result.",
"clan_not_found": "# 找不到军团\n找不到 \"{search}\". 请尝试选从搜索结果中择一个军团。",
"player_not_found": "# Could not find user\nI couldn't find user \"{search}\". Try picking an user from the search result, typing in a valid username, or using the `/link` command.",
"player_not_linked": "# 使用 `/link` 来开始\n我不知道你是谁,但你今天可以告诉我!",
"tank_name_not_found": "# Tank not found\nCould not find tank by the name \"{search}\".",
"tank_id_not_found": "# Tank not found\nCould not find tank by the ID \"{search}\". Try typing the name of the tank instead of a number.",
"tank_name_not_found": "# 找不到坦克\n找不到名称为 \"{search}\"的坦克。",
"tank_id_not_found": "# 找不到坦克\n找不到ID为 \"{search}\"的坦克. 尝试输入坦克的名称。",
"no_tank_stats": "# 没有这辆战车的数据\n这个玩家没有可用资料。 这可能不是你要找的玩家。",
"get_help": "Discord的协助服务器",
"uncaught_error": "# BlitzKit 发生错误!\n我们对此感到抱歉。 欢迎加入[官方Discord](https://discord.gg/nDt7AjGJQH),以方便帮助你解决问题。",
@@ -394,7 +394,7 @@
"wn8": "WN8",
"winrate": "胜率",
"damage": "伤害",
"unknown_tank": "Unknown tank {id}"
"unknown_tank": "未知坦克{id}"
}
},
"debug": {
@@ -549,7 +549,7 @@
"top_players": "Top {count} players",
"no_participation": "# {player} didn't play rating in season {season}\n\nThis player did not participate in this season or did not get past calibration.",
"no_ongoing_season": "# 没有进行中的赛季\n\n目前没有赛季。",
"deleted_player": "Deleted {id}",
"deleted_player": "删除{id}",
"neighbors": "对邻居进行评分",
"more": "+ {count} more"
}
@@ -573,7 +573,7 @@
"name": "权限",
"description": "检查机器人是否拥有运行所需的权限",
"body": {
"title": "# Permissions\n\n{body}",
"title": "# 权限\n\n{body}",
"view_channels": "查看频道:需要找到重新整理按钮使用的讯息",
"read_message_history": "读取消息历史: 需要找到消息以刷新",
"attach_files": "附加文件:需要将图像添加到基于图像的命令",
@@ -602,7 +602,7 @@
"name": "玩家信息",
"description": "玩家基本信息",
"body": {
"title": "{name}'s information",
"title": "{name}的信息",
"nickname": "昵称",
"battles": "战斗场次",
"winrate": "胜率",
@@ -631,7 +631,7 @@
}
},
"errors": {
"no_participation": "# {name} hasn't played rating\n\nThis player hasn't participated in the rating gamemode this season.",
"no_participation": "# {name}还没有玩过评级模式。",
"unrecorded_stats": "# 统计数据目前无法使用\n\nWargaming 可能暂停了服务器。 如果有连续的赛季,统计数据可能在24小时内提供。"
}
}
@@ -643,8 +643,8 @@
"body": "此页面已被移动。正在重定向……"
},
"settings": {
"title": "Settings",
"description": "Change BlitzKit settings",
"title": "设置",
"description": "调整BlitzKit设置",
"dev_mode": "开发者模式",
"language": "语言"
},
@@ -658,8 +658,8 @@
"copied": "已拷贝!"
},
"tank_search": {
"select_dialog_title": "Search for tanks",
"swap_dialog_title": "Swap tank",
"select_dialog_title": "搜索坦克",
"swap_dialog_title": "交换坦克",
"clear_filters": "清除筛选",
"login": "Login to use this",
"search_bar_hint": "搜寻战车……",
@@ -730,12 +730,12 @@
},
"home": {
"pwa": {
"title": "Install the BlitzKit App",
"title": "安装Blitz Kit App",
"new": "NEW",
"checking": "Checking compatibility...",
"checking": "正在检查兼容性……",
"instructions": "Instructions for Apple devices.",
"install": "Install",
"dismiss": "Dismiss"
"install": "安装",
"dismiss": "忽略"
},
"discord": {
"join_short": "加入超級酷的人群!",
@@ -28,9 +28,7 @@ export function PageWrapper({
style={{
flex: noFlex1 ? undefined : 1,
display: "flex",
minHeight: noMinHeight
? "unset"
: `calc(100svh - ${NAVBAR_HEIGHT}px - 7.75rem)`,
minHeight: noMinHeight ? "unset" : `calc(100svh - ${NAVBAR_HEIGHT}px)`,
flexDirection: "column",
...containerProps?.style,
}}
@@ -1,33 +1,105 @@
import { fisherYates } from "@blitzkit/core";
import { CaretDownIcon } from "@radix-ui/react-icons";
import { Button, Flex } from "@radix-ui/themes";
import { Button, DropdownMenu, Flex, Spinner } from "@radix-ui/themes";
import { useLocale } from "../hooks/useLocale";
import { App } from "../stores/app";
import { Playlist } from "../stores/playlist";
export function PlaylistActions() {
const { strings } = useLocale();
const wargaming = App.use((state) => state.logins.wargaming);
return (
<Flex gap="2">
<Button
variant="outline"
color="red"
onClick={() => {
Playlist.mutate((draft) => {
draft.list = undefined;
});
}}
>
{strings.website.tools.playlist.reset}
</Button>
<>
<Flex gap="2">
<Button
size={{ initial: "1", xs: "2" }}
variant="outline"
color="red"
onClick={() => {
Playlist.mutate((draft) => {
draft.list = undefined;
});
}}
>
{strings.website.tools.playlist.reset}
</Button>
<Button variant="outline">
{strings.website.tools.playlist.shuffle}
</Button>
<Button
size={{ initial: "1", xs: "2" }}
variant={wargaming ? "outline" : undefined}
onClick={() => {
Playlist.mutate((draft) => {
if (draft.list) fisherYates(draft.list);
});
}}
>
{strings.website.tools.playlist.shuffle}
</Button>
<Button>
{strings.website.tools.playlist.sort}
<CaretDownIcon />
</Button>
</Flex>
{wargaming && (
<>
<Button
size={{ initial: "1", xs: "2" }}
variant="outline"
onClick={() => {
Playlist.mutate((draft) => {
draft.list = draft.list?.filter(
(entry) =>
!entry.now ||
!entry.then ||
entry.now.battles === entry.then.battles
);
});
}}
>
{strings.website.tools.playlist.remove}
</Button>
<DropdownMenu.Root>
<DropdownMenu.Trigger>
<Button size={{ initial: "1", xs: "2" }}>
{strings.website.tools.playlist.sort.button}
<CaretDownIcon />
</Button>
</DropdownMenu.Trigger>
<DropdownMenu.Content>
<DropdownMenu.Item
onClick={() => {
Playlist.mutate((draft) => {
draft.list = draft.list?.sort(
(a, b) => (a.then?.last ?? 0) - (b.then?.last ?? 0)
);
});
}}
>
{strings.website.tools.playlist.sort.last_played}
</DropdownMenu.Item>
<DropdownMenu.Item
onClick={() => {
Playlist.mutate((draft) => {
draft.list = draft.list?.sort(
(a, b) =>
(a.then?.battles ?? 0) - (b.then?.battles ?? 0)
);
});
}}
>
{strings.website.tools.playlist.sort.least_played}
</DropdownMenu.Item>
</DropdownMenu.Content>
</DropdownMenu.Root>
</>
)}
</Flex>
{wargaming && (
<Flex gap="2" align="center">
<Spinner />
{strings.website.tools.playlist.tracking}
</Flex>
)}
</>
);
}
@@ -1,8 +1,16 @@
import { tankIcon } from "@blitzkit/core";
import { fisherYates, tankIcon } from "@blitzkit/core";
import { literals } from "@blitzkit/i18n";
import { ExclamationTriangleIcon } from "@radix-ui/react-icons";
import { Box, Button, Flex, Grid, Text } from "@radix-ui/themes";
import { useMemo } from "react";
import { ChevronRightIcon } from "@radix-ui/react-icons";
import {
AlertDialog,
Box,
Button,
Flex,
Grid,
Skeleton,
Text,
} from "@radix-ui/themes";
import { useMemo, useState } from "react";
import usePromise from "react-promise-suspense";
import { awaitableTankDefinitions } from "../core/awaitables/tankDefinitions";
import { filterTanks } from "../core/blitzkit/filterTanks";
@@ -10,6 +18,7 @@ import { generatePlaylist } from "../core/blitzkit/generatePlaylist";
import { useLocale } from "../hooks/useLocale";
import { App } from "../stores/app";
import { TankFilters } from "../stores/tankFilters";
import type { MaybeSkeletonComponentProps } from "../types/maybeSkeletonComponentProps";
import { LinkI18n } from "./LinkI18n";
import { FilterControl } from "./TankSearch/components/FilterControl";
@@ -17,20 +26,15 @@ const tankDefinitions = await awaitableTankDefinitions;
const POOL_HEIGHT = "16rem";
export function PlaylistGenerator() {
export function PlaylistGenerator({ skeleton }: MaybeSkeletonComponentProps) {
const [largeWarningOpen, setLargeWarningOpen] = useState(false);
const { strings, locale } = useLocale();
const wargaming = App.use((state) => state.logins.wargaming);
const filters = TankFilters.use();
const randomTankList = useMemo(() => {
const list = Object.values(tankDefinitions.tanks);
for (let i = list.length - 1; i > 0; i--) {
const j = Math.floor(Math.random() * (i + 1));
[list[i], list[j]] = [list[j], list[i]];
}
return list;
}, [filters]);
const randomTankList = useMemo(
() => fisherYates(Object.values(tankDefinitions.tanks)),
[filters]
);
const tanks = usePromise(
() => filterTanks(filters, randomTankList, wargaming?.id),
// react-promise-suspense has awful type annotations
@@ -39,74 +43,132 @@ export function PlaylistGenerator() {
const tanksTrimmed = useMemo(() => tanks.slice(0, 65), [filters]);
return (
<Flex justify="center" width="100%" gap="9" align="center">
<Flex direction="column" gap="4" align="center">
<FilterControl />
<Button onClick={generatePlaylist} size="3">
{strings.website.tools.playlist.generate}
</Button>
{!wargaming && (
<Text color="gray">
<Flex align="center" gap="1">
<ExclamationTriangleIcon />
{strings.website.tools.playlist.no_login_warning}
</Flex>
</Text>
)}
</Flex>
<Flex
direction="column"
flexGrow="1"
flexBasis="0"
align="center"
gap="4"
<>
<AlertDialog.Root
open={largeWarningOpen}
onOpenChange={setLargeWarningOpen}
>
<Grid
columns="repeat(auto-fill, minmax(4rem, 1fr))"
flow="dense"
overflow="hidden"
position="relative"
maxHeight={POOL_HEIGHT}
width="100%"
<AlertDialog.Content>
<AlertDialog.Title>
{strings.website.tools.playlist.large_warning.title}
</AlertDialog.Title>
<AlertDialog.Description>
{literals(
strings.website.tools.playlist.large_warning.description,
{
count: tanks.length,
time: Math.round(tanks.length * ((2 * 4) / 60)),
}
)}
</AlertDialog.Description>
<Flex justify="end" gap="2" mt="4">
<AlertDialog.Cancel>
<Button variant="outline">
{strings.website.tools.playlist.large_warning.cancel}
</Button>
</AlertDialog.Cancel>
<AlertDialog.Action onClick={generatePlaylist}>
<Button color="red">
{strings.website.tools.playlist.large_warning.proceed}
</Button>
</AlertDialog.Action>
</Flex>
</AlertDialog.Content>
</AlertDialog.Root>
<Flex justify="center" width="100%" align="center" px="4">
<Flex
flexGrow="1"
gap="9"
align="center"
justify="center"
maxWidth="80rem"
direction={{ initial: "column-reverse", md: "row" }}
>
{tanksTrimmed.map((tank) => (
<LinkI18n
target="_blank"
locale={locale}
href={`/tanks/${tank.slug}`}
key={tank.id}
style={{
aspectRatio: "4 / 3",
backgroundSize: "cover",
backgroundPosition: "center",
backgroundImage: `url(${tankIcon(tank.id)})`,
backgroundRepeat: "no-repeat",
<Flex direction="column" gap="4" align="center">
<FilterControl />
<Button
onClick={() => {
if (tanks.length >= 32) {
setLargeWarningOpen(true);
return;
}
generatePlaylist();
}}
/>
))}
size="3"
>
{strings.website.tools.playlist.generate} <ChevronRightIcon />
</Button>
</Flex>
<Box
position="absolute"
top="0"
left="0"
<Flex
direction="column"
flexGrow="1"
flexBasis="0"
align="center"
gap="4"
width="100%"
height="100%"
style={{
pointerEvents: "none",
background: `linear-gradient(transparent, var(--gray-1) ${POOL_HEIGHT})`,
}}
/>
</Grid>
>
<Grid
columns="repeat(auto-fill, minmax(4rem, 1fr))"
flow="dense"
overflow="hidden"
position="relative"
maxHeight={POOL_HEIGHT}
width="100%"
>
{tanksTrimmed.map((tank) =>
skeleton ? (
<Box
key={tank.id}
width="100%"
height="100%"
style={{ aspectRatio: "4 / 3" }}
p="1"
>
<Skeleton width="100%" height="100%" />
</Box>
) : (
<LinkI18n
key={tank.id}
target="_blank"
locale={locale}
href={`/tanks/${tank.slug}`}
style={{
aspectRatio: "4 / 3",
backgroundSize: "cover",
backgroundPosition: "center",
backgroundImage: `url(${tankIcon(tank.id)})`,
backgroundRepeat: "no-repeat",
}}
/>
)
)}
<Text color="gray">
{literals(strings.website.tools.playlist.pool_size, {
count: tanks.length,
})}
</Text>
<Box
position="absolute"
top="0"
left="0"
width="100%"
height="100%"
style={{
pointerEvents: "none",
background: `linear-gradient(transparent, var(--gray-1) ${POOL_HEIGHT})`,
}}
/>
</Grid>
<Text color="gray">
{literals(strings.website.tools.playlist.pool_size, {
count: tanks.length,
})}
</Text>
</Flex>
</Flex>
</Flex>
</Flex>
</>
);
}
@@ -1,11 +1,10 @@
import { Box, Flex } from "@radix-ui/themes";
import { useLocale } from "../hooks/useLocale";
import { CurrentlyPlaying } from "./CurrentlyPlaying";
import { PlaylistActions } from "./PlaylistActions";
import { PlaylistTable } from "./PlaylistTable";
import { PlaylistTracking } from "./PlaylistTracking";
export function PlaylistOrder() {
return (
<Flex
direction="column"
@@ -16,8 +15,8 @@ export function PlaylistOrder() {
maxHeight="100%"
>
<CurrentlyPlaying />
<PlaylistActions />
<PlaylistTracking />
<Box flexGrow="1" width="100%" position="relative">
<PlaylistTable />
@@ -20,6 +20,7 @@ export function PlaylistTable() {
height: "100%",
width: "100%",
borderRadius: 0,
whiteSpace: "nowrap",
}}
variant="surface"
>
@@ -31,27 +32,31 @@ export function PlaylistTable() {
</Text>
</StickyColumnHeaderCell>
<StickyColumnHeaderCell width="0" />
<StickyColumnHeaderCell width="0" />
<StickyColumnHeaderCell width="1">
{strings.website.tools.playlist.table.tank}
</StickyColumnHeaderCell>
<StickyColumnHeaderCell width="1">
{strings.website.tools.playlist.table.last_played}
{strings.website.tools.playlist.table.wins}
</StickyColumnHeaderCell>
<StickyColumnHeaderCell width="1">
{strings.website.tools.playlist.table.battles}
</StickyColumnHeaderCell>
<StickyColumnHeaderCell width="0" />
<StickyColumnHeaderCell width="0" />
<StickyColumnHeaderCell width="1">
{strings.website.tools.playlist.table.last_played}
</StickyColumnHeaderCell>
</Table.Row>
</Table.Header>
<Table.Body>
{list.map((props, index) => (
<PlaylistTankEntry key={props.tank.id} index={index} {...props} />
<PlaylistTankEntry key={props.id} index={index} {...props} />
))}
</Table.Body>
</StickyTableRoot>
@@ -1,5 +1,11 @@
import { MinusCircledIcon } from "@radix-ui/react-icons";
import { Checkbox, IconButton, Table } from "@radix-ui/themes";
import {
MinusCircledIcon,
TriangleDownIcon,
TriangleUpIcon,
} from "@radix-ui/react-icons";
import { Checkbox, Flex, IconButton, Table, Text } from "@radix-ui/themes";
import { memo } from "react";
import { awaitableTankDefinitions } from "../core/awaitables/tankDefinitions";
import { useLocale } from "../hooks/useLocale";
import { Playlist, type PlaylistEntry } from "../stores/playlist";
import { TankRowHeaderCell } from "./TankRowHeaderCell";
@@ -8,55 +14,94 @@ interface Props extends PlaylistEntry {
index: number;
}
export function PlaylistTankEntry({
tank,
checked,
last,
battles,
index,
}: Props) {
const { locale, strings } = useLocale();
const rtf = new Intl.RelativeTimeFormat(locale, { numeric: "auto" });
const nowDays = Date.now() / (1000 * 60 * 60 * 24);
const lastDays = last ? last / (60 * 60 * 24) : undefined;
const tankDefinitions = await awaitableTankDefinitions;
return (
<Table.Row>
<Table.Cell>{index + 1}</Table.Cell>
export const PlaylistTankEntry = memo<Props>(
({ id, checked, then, now, index }) => {
const { locale, strings } = useLocale();
const rtf = new Intl.RelativeTimeFormat(locale, { numeric: "auto" });
const dateNow = Date.now();
const tank = tankDefinitions.tanks[id];
<TankRowHeaderCell tank={tank} />
return (
<Table.Row>
<Table.Cell>{index + 1}</Table.Cell>
<Table.Cell>
{lastDays
? rtf.format(Math.floor(lastDays - nowDays), "day")
: strings.website.tools.playlist.table.never}
</Table.Cell>
<Table.Cell>{battles}</Table.Cell>
<Table.Cell
onClick={() => {
Playlist.mutate((draft) => {
draft.list![index].checked = !checked;
});
}}
>
<Checkbox variant="classic" checked={checked} />
</Table.Cell>
<Table.Cell>
<IconButton
variant="ghost"
size="1"
<Table.Cell
onClick={() => {
Playlist.mutate((draft) => {
draft.list!.splice(index, 1);
draft.list![index].checked = !checked;
});
}}
>
<MinusCircledIcon />
</IconButton>
</Table.Cell>
</Table.Row>
);
}
<Checkbox
size="3"
variant="classic"
checked={
(checked === undefined &&
now &&
then &&
now.battles > then.battles) ||
checked
}
/>
</Table.Cell>
<Table.Cell>
<IconButton
variant="ghost"
size="1"
onClick={() => {
Playlist.mutate((draft) => {
draft.list!.splice(index, 1);
});
}}
>
<MinusCircledIcon />
</IconButton>
</Table.Cell>
<TankRowHeaderCell tank={tank} />
<Table.Cell>
{now && then && now.battles !== then.battles ? (
<Flex gap="2">
<Text color="green">
<Flex align="center">
<TriangleUpIcon />
{now.wins - then.wins}
</Flex>
</Text>
<Text color="tomato">
<Flex align="center">
<TriangleDownIcon />
{now.battles - then.battles - now.wins + then.wins}
</Flex>
</Text>
</Flex>
) : (
strings.website.tools.playlist.table.unrecorded
)}
</Table.Cell>
<Table.Cell>
{now?.battles ?? strings.website.tools.playlist.table.unrecorded}
</Table.Cell>
<Table.Cell>
{now && now.last !== 0
? rtf.format(
Math.ceil((now.last - dateNow / 1000) / (60 * 60 * 24)),
"day"
)
: strings.website.tools.playlist.table.unrecorded}
</Table.Cell>
</Table.Row>
);
},
(a, b) =>
a.checked === b.checked &&
a.then?.battles === b.then?.battles &&
a.index === b.index
);
@@ -0,0 +1,14 @@
import { useEffect } from "react";
import { updatePlaylist } from "../core/blitzkit/updatePlaylist";
export function PlaylistTracking() {
useEffect(() => {
const interval = setInterval(updatePlaylist, 5000);
return () => {
clearInterval(interval);
};
}, []);
return null;
}
@@ -5,7 +5,6 @@ export function StickyRowHeaderCell({ style, ...props }: RowHeaderCellProps) {
return (
<Table.RowHeaderCell
style={{
display: "flex",
position: "sticky",
left: 0,
backgroundColor: "var(--color-panel)",
@@ -1,4 +1,5 @@
import { type TankDefinition, tankIcon, TankType } from "@blitzkit/core";
import { Box, Flex } from "@radix-ui/themes";
import { useLocale } from "../hooks/useLocale";
import { classIcons } from "./ClassIcon";
import { ExperimentIcon } from "./ExperimentIcon";
@@ -15,20 +16,6 @@ export function TankRowHeaderCell({ tank }: TankRowHeaderCellProps) {
return (
<StickyRowHeaderCell style={{ overflow: "hidden" }}>
<LinkI18n locale={locale} href={`/tanks/${tank.slug}`} tabIndex={-1}>
<img
alt={unwrap(tank.name)}
draggable={false}
src={tankIcon(tank.id)}
style={{
margin: "calc(-1 * var(--table-cell-padding)) 0",
height: "calc(100% + 2 * var(--table-cell-padding))",
aspectRatio: "4 / 3",
objectFit: "cover",
}}
/>
</LinkI18n>
<LinkI18n
locale={locale}
color={
@@ -42,28 +29,34 @@ export function TankRowHeaderCell({ tank }: TankRowHeaderCellProps) {
underline="hover"
wrap="nowrap"
href={`/tanks/${tank.slug}`}
style={{
paddingLeft: "var(--space-2)",
display: "flex",
alignItems: "center",
gap: "var(--space-1)",
whiteSpace: "nowrap",
overflow: "hidden",
textOverflow: "ellipsis",
}}
style={{ height: "100%" }}
size={{ initial: "1", sm: "2" }}
>
<Icon
width="1em"
height="1em"
style={{ minWidth: "1em", minHeight: "1em" }}
/>
<Flex height="100%" align="center" gap="1">
<Box
draggable={false}
height="calc(100% + 2 * var(--table-cell-padding))"
style={{
aspectRatio: "4 / 3",
backgroundImage: `url(${tankIcon(tank.id)})`,
backgroundSize: "cover",
backgroundPosition: "center",
backgroundRepeat: "no-repeat",
}}
/>
{tank.testing && (
<ExperimentIcon style={{ width: "1em", height: "1em" }} />
)}
<Icon
width="1em"
height="1em"
style={{ minWidth: "1em", minHeight: "1em" }}
/>
{unwrap(tank.name)}
{tank.testing && (
<ExperimentIcon style={{ width: "1em", height: "1em" }} />
)}
{unwrap(tank.name)}
</Flex>
</LinkI18n>
</StickyRowHeaderCell>
);
@@ -19,6 +19,7 @@ import {
Popover,
Text,
Tooltip,
type ButtonProps,
type FlexProps,
} from "@radix-ui/themes";
import { isEqual, times } from "lodash-es";
@@ -37,10 +38,6 @@ import { ResearchedIcon } from "../../ResearchedIcon";
import { ScienceIcon } from "../../ScienceIcon";
import { ScienceOffIcon } from "../../ScienceOffIcon";
interface FilterControlProps {
compact?: boolean;
}
const gameDefinitions = await awaitableGameDefinitions;
const shellTypeIcons: Record<ShellType, string> = {
@@ -50,13 +47,21 @@ const shellTypeIcons: Record<ShellType, string> = {
[ShellType.HEAT]: "hc",
};
const size: ButtonProps["size"] = { initial: "1", xs: "2" };
function ShellFilter({ index, premium }: { index: number; premium?: boolean }) {
const shells = TankFilters.use((state) => state.shells);
return (
<Popover.Root>
<Popover.Trigger>
<IconButton variant="soft" radius="none" color="gray" highContrast>
<IconButton
size={size}
variant="soft"
radius="none"
color="gray"
highContrast
>
{shells[index] === null && (
<Text color="gray" style={{ display: "contents" }}>
<MissingShellIcon width="1em" height="1em" />
@@ -83,6 +88,7 @@ function ShellFilter({ index, premium }: { index: number; premium?: boolean }) {
return (
<IconButton
size={size}
key={shellType}
value={`${shellType}`}
radius="none"
@@ -127,6 +133,7 @@ function OwnershipFilter(props: FlexProps) {
{...props}
>
<IconButton
size={size}
disabled={!wargaming}
variant={tankFilters.ownership === "all" ? "solid" : "soft"}
radius="none"
@@ -142,6 +149,7 @@ function OwnershipFilter(props: FlexProps) {
</IconButton>
<IconButton
size={size}
disabled={!wargaming}
variant={tankFilters.ownership === "owned" ? "solid" : "soft"}
radius="none"
@@ -157,6 +165,7 @@ function OwnershipFilter(props: FlexProps) {
</IconButton>
<IconButton
size={size}
disabled={!wargaming}
variant={tankFilters.ownership === "unowned" ? "solid" : "soft"}
radius="none"
@@ -195,6 +204,7 @@ export function FilterControl() {
return (
<IconButton
size={size}
key={tier}
variant={selected ? "solid" : "soft"}
radius="none"
@@ -233,6 +243,7 @@ export function FilterControl() {
return (
<IconButton
size={size}
key={tier}
variant={selected ? "solid" : "soft"}
radius="none"
@@ -270,6 +281,7 @@ export function FilterControl() {
return (
<IconButton
size={size}
key={nation}
variant={selected ? "solid" : "soft"}
color={selected ? undefined : "gray"}
@@ -312,6 +324,7 @@ export function FilterControl() {
return (
<IconButton
size={size}
key={nation}
style={{ flex: 1 }}
variant={selected ? "solid" : "soft"}
@@ -351,6 +364,7 @@ export function FilterControl() {
return (
<IconButton
size={size}
key={tankClass}
variant={selected ? "solid" : "soft"}
radius="none"
@@ -380,6 +394,7 @@ export function FilterControl() {
direction="column"
>
<IconButton
size={size}
variant={tankFilters.gunType.includes("regular") ? "solid" : "soft"}
radius="none"
color={tankFilters.gunType.includes("regular") ? undefined : "gray"}
@@ -397,6 +412,7 @@ export function FilterControl() {
<GunRegularIcon style={{ width: "1em", height: "1em" }} />
</IconButton>
<IconButton
size={size}
variant={
tankFilters.gunType.includes("auto_loader") ? "solid" : "soft"
}
@@ -420,6 +436,7 @@ export function FilterControl() {
<GunAutoloaderIcon style={{ width: "1em", height: "1em" }} />
</IconButton>
<IconButton
size={size}
variant={
tankFilters.gunType.includes("auto_reloader") ? "solid" : "soft"
}
@@ -460,6 +477,7 @@ export function FilterControl() {
direction="column"
>
<IconButton
size={size}
variant={
tankFilters.types?.includes(TankType.RESEARCHABLE)
? "solid"
@@ -487,6 +505,7 @@ export function FilterControl() {
<ResearchedIcon style={{ width: "1em", height: "1em" }} />
</IconButton>
<IconButton
size={size}
variant={
tankFilters.types?.includes(TankType.PREMIUM) ? "solid" : "soft"
}
@@ -519,6 +538,7 @@ export function FilterControl() {
</Text>
</IconButton>
<IconButton
size={size}
variant={
tankFilters.types?.includes(TankType.COLLECTOR) ? "solid" : "soft"
}
@@ -558,6 +578,7 @@ export function FilterControl() {
direction="column"
>
<IconButton
size={size}
variant={tankFilters.testing === "include" ? "solid" : "soft"}
radius="none"
color={tankFilters.testing === "include" ? undefined : "gray"}
@@ -571,6 +592,7 @@ export function FilterControl() {
<ComponentBooleanIcon />
</IconButton>
<IconButton
size={size}
variant={tankFilters.testing === "exclude" ? "solid" : "soft"}
radius="none"
color={tankFilters.testing === "exclude" ? undefined : "gray"}
@@ -586,6 +608,7 @@ export function FilterControl() {
/>
</IconButton>
<IconButton
size={size}
variant={tankFilters.testing === "only" ? "solid" : "soft"}
radius="none"
color={tankFilters.testing === "only" ? undefined : "gray"}
@@ -1,4 +1,5 @@
import {
fisherYates,
getTankStats,
idToRegion,
type IndividualTankStats,
@@ -24,19 +25,20 @@ export async function generatePlaylist() {
}
}
for (let i = filtered.length - 1; i > 0; i--) {
const j = Math.floor(Math.random() * (i + 1));
[filtered[i], filtered[j]] = [filtered[j], filtered[i]];
}
fisherYates(filtered);
Playlist.mutate((draft) => {
draft.list = filtered.map((tank, index) => ({
index,
tank,
battles: stats[tank.id]?.all.battles,
wins: stats[tank.id]?.all.wins,
last: stats[tank.id]?.last_battle_time,
checked: false,
}));
draft.list = filtered.map((tank) => {
const tankStats = stats[tank.id];
const then = tankStats
? {
battles: tankStats.all.battles,
wins: tankStats.all.wins,
last: tankStats.last_battle_time,
}
: undefined;
return { id: tank.id, then, now: then };
});
});
}
@@ -0,0 +1,32 @@
import {
getTankStats,
idToRegion,
type IndividualTankStats,
} from "@blitzkit/core";
import { App } from "../../stores/app";
import { Playlist } from "../../stores/playlist";
export async function updatePlaylist() {
const id = App.state.logins.wargaming?.id;
const statsList = id ? await getTankStats(idToRegion(id), id) : undefined;
const stats: Record<number, IndividualTankStats> = {};
if (statsList) {
for (const tankStat of statsList) {
stats[tankStat.tank_id] = tankStat;
}
}
Playlist.mutate((draft) => {
draft.list?.map((item) => {
const tankStats = stats[item.id];
item.now = tankStats
? {
battles: tankStats.all.battles,
wins: tankStats.all.wins,
last: tankStats.last_battle_time,
}
: undefined;
});
});
}
@@ -1,4 +1,3 @@
import { useEffect } from "react";
import { PageWrapper } from "../../../components/PageWrapper";
import { PlaylistGenerator } from "../../../components/PlaylistGenerator";
import { PlaylistOrder } from "../../../components/PlaylistOrder";
@@ -16,22 +15,17 @@ export function Page({
locale,
skeleton,
}: Props & MaybeSkeletonComponentProps) {
const list = Playlist.use((state) => state.list);
const wargaming = App.use((state) => state.logins.wargaming);
const generated = Playlist.use((state) => state.list !== undefined);
useEffect(() => {
if (wargaming) {
TankFilters.mutate((draft) => {
draft.ownership = "owned";
});
}
}, []);
if (App.state.logins.wargaming && TankFilters.state.ownership !== "owned") {
TankFilters.state.ownership = "owned";
}
return (
<LocaleProvider locale={locale}>
<PageWrapper color="tomato" direction="row" maxWidth="unset" p="0">
{!list && <PlaylistGenerator />}
{list && <PlaylistOrder />}
{!generated && <PlaylistGenerator skeleton={skeleton} />}
{generated && <PlaylistOrder />}
</PageWrapper>
</LocaleProvider>
);
@@ -1,6 +1,7 @@
---
import ToolOpenGraph from "../../../components/ToolOpenGraph.astro";
import { tools } from "../../../constants/tools";
import ToolLayout from "../../../layouts/ToolLayout.astro";
import BaseLayout from "../../../layouts/BaseLayout.astro";
import { Page } from "./_index.tsx";
export { getStaticPaths } from "../index.astro";
@@ -8,8 +9,10 @@ export { getStaticPaths } from "../index.astro";
const { locale } = Astro.params;
---
<ToolLayout {locale} tool={tools.playlist} noFooter>
<ToolOpenGraph tool={tools.playlist} />
<BaseLayout {locale} noFooter>
<Page {locale} client:only="react">
<Page {locale} skeleton slot="fallback" />
</Page>
</ToolLayout>
</BaseLayout>
+4 -6
View File
@@ -1,12 +1,10 @@
import type { TankDefinition } from "@blitzkit/core";
import { Varuna } from "varuna";
export interface PlaylistEntry {
tank: TankDefinition;
battles?: number;
wins?: number;
checked: boolean;
last?: number;
id: number;
then?: { battles: number; wins: number; last: number };
now?: { battles: number; wins: number; last: number };
checked?: boolean;
}
export interface Playlist {
+1 -5
View File
@@ -3,10 +3,6 @@
"compilerOptions": {
"jsx": "react-jsx",
"jsxImportSource": "react",
"types": [
"vite/client",
"vite-plugin-pwa/info.d.ts",
"vite-plugin-pwa/client.d.ts"
]
"types": ["vite/client"]
}
}