mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-21 10:47:04 +02:00
feat: no flags
This commit is contained in:
1 parent
0250546ab5
commit
e835498e59
13 files changed
+72
-61
No files matched your search
@@ -3,7 +3,6 @@
|
||||
import { ContextMenu } from '@radix-ui/themes';
|
||||
import { useEffect, useState } from 'react';
|
||||
import * as Breakdown from '../../../components/Breakdown';
|
||||
import { TreeTypeEnum } from '../../../components/Tanks';
|
||||
import { WARGAMING_APPLICATION_ID } from '../../../constants/wargamingApplicationID';
|
||||
import fetchBlitz from '../../../core/blitz/fetchBlitz';
|
||||
import {
|
||||
@@ -296,12 +295,7 @@ export default function SessionPage() {
|
||||
}
|
||||
type="tank"
|
||||
tankType={tankDefinitions?.type}
|
||||
treeType={(() => {
|
||||
if (tankDefinitions?.tree_type === 'collector')
|
||||
return TreeTypeEnum.Collector;
|
||||
if (tankDefinitions?.tree_type === 'premium')
|
||||
return TreeTypeEnum.Premium;
|
||||
})()}
|
||||
treeType={tankDefinitions?.tree_type}
|
||||
stats={session.customColumns.map((customColumn) => {
|
||||
const rowStat = rowStats[customColumn.display];
|
||||
|
||||
|
||||
@@ -1,16 +1,43 @@
|
||||
import { Flex, Heading } from '@radix-ui/themes';
|
||||
import { Flag } from '../../../../../components/Flag';
|
||||
import { UpdateIcon } from '@radix-ui/react-icons';
|
||||
import { Button, Flex, Heading } from '@radix-ui/themes';
|
||||
import { TREE_TYPE_ICONS } from '../../../../../components/Tanks';
|
||||
import { useDuel } from '../../../../../stores/duel';
|
||||
|
||||
export function Title() {
|
||||
const protagonist = useDuel((state) => state.protagonist!);
|
||||
|
||||
return (
|
||||
<Flex justify="between" align="center">
|
||||
<Flex gap="6" justify="center" align="center" style={{ padding: 16 }}>
|
||||
<Flex gap="2" align="center">
|
||||
<Flag nation={protagonist.tank.nation} />
|
||||
<Heading>{protagonist.tank.name}</Heading>
|
||||
<Heading
|
||||
color={
|
||||
protagonist.tank.tree_type === 'premium'
|
||||
? 'amber'
|
||||
: protagonist.tank.tree_type === 'collector'
|
||||
? 'blue'
|
||||
: undefined
|
||||
}
|
||||
>
|
||||
<Flex align="center" gap="2">
|
||||
<img
|
||||
src={
|
||||
TREE_TYPE_ICONS[protagonist.tank.tree_type][
|
||||
protagonist.tank.type
|
||||
]
|
||||
}
|
||||
style={{
|
||||
width: '1em',
|
||||
height: '1em',
|
||||
}}
|
||||
/>{' '}
|
||||
{protagonist.tank.name}
|
||||
</Flex>
|
||||
</Heading>
|
||||
</Flex>
|
||||
|
||||
<Button variant="ghost">
|
||||
Change <UpdateIcon />
|
||||
</Button>
|
||||
</Flex>
|
||||
);
|
||||
}
|
||||
@@ -9,7 +9,6 @@ import {
|
||||
TREE_TYPES,
|
||||
TREE_TYPE_ICONS,
|
||||
TREE_TYPE_IMAGES,
|
||||
TreeTypeEnum,
|
||||
} from '../../../../../../../components/Tanks';
|
||||
import {
|
||||
NATIONS,
|
||||
@@ -136,7 +135,7 @@ export function Options() {
|
||||
}
|
||||
>
|
||||
<img
|
||||
src={TREE_TYPE_ICONS[TreeTypeEnum.TechTree][type]}
|
||||
src={TREE_TYPE_ICONS.researchable[type]}
|
||||
style={{ width: '1em', height: '1em' }}
|
||||
/>
|
||||
</Button>
|
||||
|
||||
@@ -7,7 +7,6 @@ import { encyclopediaInfo } from '../core/blitz/encyclopediaInfo';
|
||||
import { getAccountInfo } from '../core/blitz/getAccountInfo';
|
||||
import { getClanAccountInfo } from '../core/blitz/getClanAccountInfo';
|
||||
import getTankStats from '../core/blitz/getTankStats';
|
||||
import getTreeType from '../core/blitz/getTreeType';
|
||||
import { emblemIdToURL } from '../core/blitzkrieg/emblemIdToURL';
|
||||
import {
|
||||
TIER_ROMAN_NUMERALS,
|
||||
@@ -98,7 +97,7 @@ export const ownedTanksCommand: CommandRegistry = {
|
||||
name={tank.name}
|
||||
tankType={tank.type}
|
||||
image={tankIcon(tank.id)}
|
||||
treeType={await getTreeType(tank.id)}
|
||||
treeType={tank.tree_type}
|
||||
/>
|
||||
)),
|
||||
)}
|
||||
@@ -111,7 +110,7 @@ export const ownedTanksCommand: CommandRegistry = {
|
||||
name={tank.name}
|
||||
tankType={tank.type}
|
||||
image={tankIcon(tank.id)}
|
||||
treeType={await getTreeType(tank.id)}
|
||||
treeType={tank.tree_type}
|
||||
/>
|
||||
)),
|
||||
)}
|
||||
|
||||
@@ -5,7 +5,7 @@ import {
|
||||
GrayColor,
|
||||
PALETTES,
|
||||
} from '../../../constants/radixColors';
|
||||
import { TREE_TYPE_ICONS, TankType, TreeTypeEnum } from '../../Tanks';
|
||||
import { TREE_TYPE_ICONS, TankType, TreeType } from '../../Tanks';
|
||||
import { RowStat } from './RowStat';
|
||||
|
||||
export interface RowStatItem {
|
||||
@@ -20,7 +20,7 @@ interface RowProps {
|
||||
type?: 'tank' | 'summary';
|
||||
title: string;
|
||||
minimized?: boolean;
|
||||
treeType?: TreeTypeEnum;
|
||||
treeType?: TreeType;
|
||||
tankType?: TankType;
|
||||
color?: AccentColor | GrayColor;
|
||||
stats: (RowStatItem | undefined)[];
|
||||
@@ -60,7 +60,7 @@ export function Row({
|
||||
>
|
||||
{type === 'tank' && tankType !== undefined && (
|
||||
<img
|
||||
src={TREE_TYPE_ICONS[treeType ?? TreeTypeEnum.TechTree][tankType]}
|
||||
src={TREE_TYPE_ICONS[treeType ?? 'researchable'][tankType]}
|
||||
style={{ width: 16, height: 16 }}
|
||||
/>
|
||||
)}
|
||||
@@ -69,9 +69,9 @@ export function Row({
|
||||
style={{
|
||||
color:
|
||||
type === 'tank'
|
||||
? treeType === TreeTypeEnum.Collector
|
||||
? treeType === 'collector'
|
||||
? theme.textLowContrast_blue
|
||||
: treeType === TreeTypeEnum.Premium
|
||||
: treeType === 'premium'
|
||||
? theme.textLowContrast_amber
|
||||
: theme.textHighContrast
|
||||
: theme.textLowContrast,
|
||||
|
||||
@@ -5,12 +5,6 @@ import {
|
||||
} from '../../../core/blitzkrieg/tankDefinitions';
|
||||
import { theme } from '../../../stitches.config';
|
||||
|
||||
export enum TreeTypeEnum {
|
||||
TechTree,
|
||||
Premium,
|
||||
Collector,
|
||||
}
|
||||
|
||||
export const TANK_TYPES = [
|
||||
'tank_destroyer',
|
||||
'light',
|
||||
@@ -22,15 +16,15 @@ export const TANK_TYPES = [
|
||||
export const TREE_TYPES = ['researchable', 'premium', 'collector'] as const;
|
||||
|
||||
export type TankType = (typeof TANK_TYPES)[number];
|
||||
export type TreeTypeString = (typeof TREE_TYPES)[number];
|
||||
export type TreeType = (typeof TREE_TYPES)[number];
|
||||
|
||||
export const TREE_TYPE_NAMES: Record<TreeTypeString, string> = {
|
||||
export const TREE_TYPE_NAMES: Record<TreeType, string> = {
|
||||
researchable: 'Tech tree',
|
||||
premium: 'Premium',
|
||||
collector: 'Collector',
|
||||
};
|
||||
|
||||
export const TREE_TYPE_IMAGES: Record<TreeTypeString, string> = {
|
||||
export const TREE_TYPE_IMAGES: Record<TreeType, string> = {
|
||||
researchable: 'https://i.imgur.com/pJxO2XY.png',
|
||||
premium: 'https://i.imgur.com/mZzSwOU.png',
|
||||
collector: 'https://i.imgur.com/7A0RsG5.png',
|
||||
@@ -40,19 +34,19 @@ export interface ItemProps {
|
||||
image?: string;
|
||||
tankType?: TankType;
|
||||
name: string;
|
||||
treeType: TreeTypeEnum;
|
||||
treeType: TreeType;
|
||||
}
|
||||
|
||||
const TREE_TYPE_COLOR = {
|
||||
[TreeTypeEnum.TechTree]: '',
|
||||
[TreeTypeEnum.Premium]: '_amber',
|
||||
[TreeTypeEnum.Collector]: '_blue',
|
||||
researchable: '',
|
||||
premium: '_amber',
|
||||
collector: '_blue',
|
||||
} as const;
|
||||
|
||||
export const TREE_TYPE_ICONS = {
|
||||
[TreeTypeEnum.TechTree]: TANK_ICONS,
|
||||
[TreeTypeEnum.Premium]: TANK_ICONS_PREMIUM,
|
||||
[TreeTypeEnum.Collector]: TANK_ICONS_COLLECTOR,
|
||||
export const TREE_TYPE_ICONS: Record<TreeType, Record<TankType, string>> = {
|
||||
researchable: TANK_ICONS,
|
||||
premium: TANK_ICONS_PREMIUM,
|
||||
collector: TANK_ICONS_COLLECTOR,
|
||||
};
|
||||
|
||||
export function Item({ image, tankType, name, treeType }: ItemProps) {
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import { TreeTypeEnum } from '../../components/Tanks';
|
||||
import { TreeType } from '../../components/Tanks';
|
||||
import { tankDefinitions } from '../blitzkrieg/tankDefinitions';
|
||||
|
||||
export default async function getTreeType(id: number) {
|
||||
export default async function getTreeType(id: number): Promise<TreeType> {
|
||||
const entry = (await tankDefinitions)[id];
|
||||
|
||||
if (entry.tree_type === 'collector') return TreeTypeEnum.Collector;
|
||||
if (entry.tree_type === 'premium') return TreeTypeEnum.Premium;
|
||||
if (entry.tree_type === 'collector') return 'collector';
|
||||
if (entry.tree_type === 'premium') return 'premium';
|
||||
|
||||
return TreeTypeEnum.TechTree;
|
||||
return 'researchable';
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
import { deburr } from 'lodash';
|
||||
import { Vector2Tuple } from 'three';
|
||||
import { TankType, TreeTypeString } from '../../components/Tanks';
|
||||
import { TankType, TreeType } from '../../components/Tanks';
|
||||
import { asset } from './asset';
|
||||
|
||||
export type ShellType = 'ap' | 'ap_cr' | 'hc' | 'he';
|
||||
@@ -18,7 +18,7 @@ export interface TankDefinition {
|
||||
nation: string;
|
||||
name: string;
|
||||
name_full?: string;
|
||||
tree_type: TreeTypeString;
|
||||
tree_type: TreeType;
|
||||
consumables: number;
|
||||
provisions: number;
|
||||
tier: Tier;
|
||||
|
||||
@@ -3,7 +3,7 @@ import {
|
||||
SlashCommandSubcommandBuilder,
|
||||
SlashCommandSubcommandGroupBuilder,
|
||||
} from 'discord.js';
|
||||
import { TREE_TYPE_NAMES, TreeTypeString } from '../../components/Tanks';
|
||||
import { TREE_TYPE_NAMES, TreeType } from '../../components/Tanks';
|
||||
import { encyclopediaInfo } from '../blitz/encyclopediaInfo';
|
||||
import addPeriodSubCommands from './addPeriodSubCommands';
|
||||
import addTankChoices from './addTankChoices';
|
||||
@@ -56,15 +56,15 @@ export default async function addFilterOptions<
|
||||
.addChoices(
|
||||
{
|
||||
name: TREE_TYPE_NAMES['researchable'],
|
||||
value: 'researchable' satisfies TreeTypeString,
|
||||
value: 'researchable' satisfies TreeType,
|
||||
},
|
||||
{
|
||||
name: TREE_TYPE_NAMES.premium,
|
||||
value: 'premium' satisfies TreeTypeString,
|
||||
value: 'premium' satisfies TreeType,
|
||||
},
|
||||
{
|
||||
name: TREE_TYPE_NAMES.collector,
|
||||
value: 'collector' satisfies TreeTypeString,
|
||||
value: 'collector' satisfies TreeType,
|
||||
},
|
||||
)
|
||||
.setRequired(false),
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { ButtonInteraction } from 'discord.js';
|
||||
import { TreeTypeString } from '../../components/Tanks';
|
||||
import { TreeType } from '../../components/Tanks';
|
||||
import { StatFilters } from '../statistics/filterStats';
|
||||
|
||||
export function getFiltersFromButton(interaction: ButtonInteraction) {
|
||||
@@ -10,8 +10,7 @@ export function getFiltersFromButton(interaction: ButtonInteraction) {
|
||||
tank: parseInt(url.searchParams.get('tank') ?? '0') || undefined,
|
||||
tankType: url.searchParams.get('tank-type') ?? undefined,
|
||||
treeType:
|
||||
(url.searchParams.get('tree-type') as TreeTypeString | undefined) ??
|
||||
undefined,
|
||||
(url.searchParams.get('tree-type') as TreeType | undefined) ?? undefined,
|
||||
tier: parseInt(url.searchParams.get('tier') ?? '0') || undefined,
|
||||
} satisfies StatFilters;
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
import { ChatInputCommandInteraction } from 'discord.js';
|
||||
import { TreeTypeString } from '../../components/Tanks';
|
||||
import { TreeType } from '../../components/Tanks';
|
||||
import resolveTankId from '../blitz/resolveTankId';
|
||||
import { StatFilters } from '../statistics/filterStats';
|
||||
|
||||
@@ -13,9 +13,8 @@ export async function getFiltersFromCommand(
|
||||
tier: parseInt(interaction.options.getString('tier') ?? '0') || undefined,
|
||||
tankType: interaction.options.getString('tank-type') ?? undefined,
|
||||
treeType:
|
||||
(interaction.options.getString('tree-type') as
|
||||
| TreeTypeString
|
||||
| undefined) ?? undefined,
|
||||
(interaction.options.getString('tree-type') as TreeType | undefined) ??
|
||||
undefined,
|
||||
tank: tankRaw === null ? undefined : await resolveTankId(tankRaw),
|
||||
} satisfies StatFilters;
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
import { TreeTypeString } from '../../components/Tanks';
|
||||
import { TreeType } from '../../components/Tanks';
|
||||
import { tankDefinitions } from '../blitzkrieg/tankDefinitions';
|
||||
import { DiffedTankStats } from '../blitzstars/getStatsInPeriod';
|
||||
import { tankAverages } from '../blitzstars/tankAverages';
|
||||
@@ -9,7 +9,7 @@ export interface StatFilters {
|
||||
nation?: string;
|
||||
tier?: number;
|
||||
tankType?: string;
|
||||
treeType?: TreeTypeString;
|
||||
treeType?: TreeType;
|
||||
tank?: number;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { produce } from 'immer';
|
||||
import { create } from 'zustand';
|
||||
import { persist, subscribeWithSelector } from 'zustand/middleware';
|
||||
import { TankType, TreeTypeString } from '../components/Tanks';
|
||||
import { TankType, TreeType } from '../components/Tanks';
|
||||
import {
|
||||
GunDefinition,
|
||||
ShellDefinition,
|
||||
@@ -39,7 +39,7 @@ interface TankopediaPersistent {
|
||||
filters: {
|
||||
tiers: Tier[];
|
||||
types: TankType[];
|
||||
treeTypes: TreeTypeString[];
|
||||
treeTypes: TreeType[];
|
||||
nations: string[];
|
||||
test: TankopediaTestTankDisplay;
|
||||
page: number;
|
||||
|
||||
Reference in new issue
Block a user