feat: no flags

This commit is contained in:
TrèsAbhi committed 2024-01-27 17:36:29 -06:00
1 parent 0250546ab5
commit e835498e59
13 files changed
+72 -61

No files matched your search

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