feat: change tier back to number

This commit is contained in:
tresabhi committed 2024-11-20 10:26:55 -06:00
1 parent 8089a5eaa6
commit fcb848df5b
16 files changed
+80 -119

No files matched your search

+1 -2
View File
@@ -2,7 +2,6 @@ import {
TANK_CLASSES, TANK_CLASSES,
TIER_ROMAN_NUMERALS, TIER_ROMAN_NUMERALS,
TankDefinition, TankDefinition,
Tier,
flags, flags,
getAccountInfo, getAccountInfo,
getTankStats, getTankStats,
@@ -80,7 +79,7 @@ export const ownedTanksCommand = new Promise<CommandRegistry>((resolve) => {
index === 0 index === 0
? `${translate('bot.commands.owned_tanks.body.title', [ ? `${translate('bot.commands.owned_tanks.body.title', [
markdownEscape(accountInfo.nickname), markdownEscape(accountInfo.nickname),
TIER_ROMAN_NUMERALS[tier as Tier], TIER_ROMAN_NUMERALS[tier],
])}${lines.join('\n')}` ])}${lines.join('\n')}`
: lines.join('\n'), : lines.join('\n'),
); );
@@ -3,7 +3,6 @@ import {
FIRST_MINIMAL_ARCHIVED_RATING_SEASON, FIRST_MINIMAL_ARCHIVED_RATING_SEASON,
getAccountInfo, getAccountInfo,
getArchivedLatestSeasonNumber, getArchivedLatestSeasonNumber,
getArchivedRatingInfo,
getArchivedRatingLeaderboard, getArchivedRatingLeaderboard,
getArchivedRatingMidnightLeaderboard, getArchivedRatingMidnightLeaderboard,
getClanAccountInfo, getClanAccountInfo,
@@ -12,7 +11,6 @@ import {
getRatingNeighbors, getRatingNeighbors,
isOnGoingRatingSeason, isOnGoingRatingSeason,
LEAGUES, LEAGUES,
RatingInfo,
Region, Region,
} from '@blitzkit/core'; } from '@blitzkit/core';
import { import {
@@ -1,8 +1,4 @@
import { import { fetchTankDefinitions, TIER_ROMAN_NUMERALS } from '@blitzkit/core';
fetchTankDefinitions,
Tier,
TIER_ROMAN_NUMERALS,
} from '@blitzkit/core';
import { Locale } from 'discord.js'; import { Locale } from 'discord.js';
import { StatFilters } from '../blitzstars/filterStats'; import { StatFilters } from '../blitzstars/filterStats';
import { translator } from '../localization/translator'; import { translator } from '../localization/translator';
@@ -20,7 +16,7 @@ export async function filtersToDescription(
if (nation) info.push(translate(`common.nations.${nation}`)); if (nation) info.push(translate(`common.nations.${nation}`));
if (tier) { if (tier) {
info.push( info.push(
translate('bot.common.filters.tier', [TIER_ROMAN_NUMERALS[tier as Tier]]), translate('bot.common.filters.tier', [TIER_ROMAN_NUMERALS[tier]]),
); );
} }
if (tankClass) info.push(translate(`common.tank_class_short.${tankClass}`)); if (tankClass) info.push(translate(`common.tank_class_short.${tankClass}`));
+11 -12
View File
@@ -1,15 +1,14 @@
import { Vector3Tuple } from 'three'; import { Vector3Tuple } from 'three';
import { Tier } from '../protos';
export const equipmentPriceMatrix: Record<Tier, Vector3Tuple> = { export const equipmentPriceMatrix: Record<number, Vector3Tuple> = {
[Tier.I]: [100, 200, 300], 1: [100, 200, 300],
[Tier.II]: [200, 300, 400], 2: [200, 300, 400],
[Tier.III]: [400, 500, 600], 3: [400, 500, 600],
[Tier.IV]: [4000, 5000, 6000], 4: [4000, 5000, 6000],
[Tier.V]: [40_000, 50_000, 60_000], 5: [40_000, 50_000, 60_000],
[Tier.VI]: [100_000, 120_000, 140_000], 6: [100_000, 120_000, 140_000],
[Tier.VII]: [150_000, 170_000, 190_000], 7: [150_000, 170_000, 190_000],
[Tier.VIII]: [200_000, 225_000, 250_000], 8: [200_000, 225_000, 250_000],
[Tier.IX]: [250_000, 275_000, 300_000], 9: [250_000, 275_000, 300_000],
[Tier.X]: [300_000, 350_000, 400_000], 10: [300_000, 350_000, 400_000],
}; };
+19 -19
View File
@@ -1,24 +1,24 @@
import { RatingInfo, Region } from '@blitzkit/core'; // import { Region } from '@blitzkit/core';
import { context } from '../blitzkit/context'; // import { context } from '../blitzkit/context';
import { patientFetch } from '../blitzkit/patientFetch'; // import { patientFetch } from '../blitzkit/patientFetch';
import { regionToRegionSubdomain } from './regionToRegionSubdomain'; // import { regionToRegionSubdomain } from './regionToRegionSubdomain';
const cache: Partial<Record<Region, RatingInfo>> = {}; // const cache: Partial<Record<Region, RatingInfo>> = {};
export async function getRatingInfo(region: Region) { // export async function getRatingInfo(region: Region) {
if (cache[region]) return cache[region]!; // if (cache[region]) return cache[region]!;
const response = await patientFetch( // const response = await patientFetch(
context === 'website' // context === 'website'
? `/api/${region}/rating/current/info` // ? `/api/${region}/rating/current/info`
: `https://${regionToRegionSubdomain( // : `https://${regionToRegionSubdomain(
region, // region,
)}.wotblitz.com/en/api/rating-leaderboards/season/`, // )}.wotblitz.com/en/api/rating-leaderboards/season/`,
undefined, // undefined,
); // );
const data = (await response.json()) as RatingInfo; // const data = (await response.json()) as RatingInfo;
cache[region] = data; // cache[region] = data;
return data; // return data;
} // }
+1 -1
View File
@@ -9,7 +9,7 @@ export * from './getAccountInfo';
export * from './getClanAccountInfo'; export * from './getClanAccountInfo';
export * from './getClanInfo'; export * from './getClanInfo';
export * from './getLeagueFromScore'; export * from './getLeagueFromScore';
export * from './getRatingInfo'; // export * from './getRatingInfo';
export * from './getRatingLeague'; export * from './getRatingLeague';
export * from './getRatingNeighbors'; export * from './getRatingNeighbors';
export * from './getTankStats'; export * from './getTankStats';
+1 -1
View File
@@ -16,7 +16,7 @@ export * from './eventManager';
// export * from './flagUserActivity'; // export * from './flagUserActivity';
export * from './gameDefinitions'; export * from './gameDefinitions';
export * from './getArchivedLatestSeasonNumber'; export * from './getArchivedLatestSeasonNumber';
export * from './getArchivedRatingInfo'; // export * from './getArchivedRatingInfo';
export * from './getArchivedRatingLeaderboard'; export * from './getArchivedRatingLeaderboard';
export * from './getArchivedRatingMidnightLeaderboard'; export * from './getArchivedRatingMidnightLeaderboard';
export * from './getTimeDaysAgo'; export * from './getTimeDaysAgo';
@@ -1,10 +1,10 @@
import { times } from 'lodash';
import { import {
CrewType, CrewType,
GunDefinition, GunDefinition,
ShellType, ShellType,
TankClass, TankClass,
TankType, TankType,
Tier,
} from '../../protos'; } from '../../protos';
export const SHELL_NAMES: Record<ShellType, string> = { export const SHELL_NAMES: Record<ShellType, string> = {
@@ -55,29 +55,18 @@ export const TANK_ICONS_COLLECTOR: Record<TankClass, string> = {
[TankClass.MEDIUM]: 'https://i.imgur.com/u8YDMBh.png', [TankClass.MEDIUM]: 'https://i.imgur.com/u8YDMBh.png',
[TankClass.HEAVY]: 'https://i.imgur.com/8xRf3nc.png', [TankClass.HEAVY]: 'https://i.imgur.com/8xRf3nc.png',
}; };
export const TIERS = [ export const TIERS = times(10, (index) => index + 1);
Tier.I, export const TIER_ROMAN_NUMERALS: Record<number, string> = {
Tier.II, 1: 'I',
Tier.III, 2: 'II',
Tier.IV, 3: 'III',
Tier.V, 4: 'IV',
Tier.VI, 5: 'V',
Tier.VII, 6: 'VI',
Tier.VIII, 7: 'VII',
Tier.IX, 8: 'VIII',
Tier.X, 9: 'IX',
]; 10: 'X',
export const TIER_ROMAN_NUMERALS: Record<Tier, string> = {
[Tier.I]: 'I',
[Tier.II]: 'II',
[Tier.III]: 'III',
[Tier.IV]: 'IV',
[Tier.V]: 'V',
[Tier.VI]: 'VI',
[Tier.VII]: 'VII',
[Tier.VIII]: 'VIII',
[Tier.IX]: 'IX',
[Tier.X]: 'X',
}; };
export const flags: Record<string, string> = { export const flags: Record<string, string> = {
@@ -1,5 +1,4 @@
import { fetchTankDefinitions } from '../blitzkit'; import { fetchTankDefinitions } from '../blitzkit';
import { Tier } from '../protos';
import { BlitzStats } from './compositeStats/constants'; import { BlitzStats } from './compositeStats/constants';
export async function getTierWeights( export async function getTierWeights(
@@ -20,4 +19,4 @@ export async function getTierWeights(
return tierWeights; return tierWeights;
} }
export type TierWeightsRecord = Partial<Record<Tier, number>>; export type TierWeightsRecord = Partial<Record<number, number>>;
@@ -26,7 +26,6 @@ import {
TankPrice, TankPrice,
TankPriceType, TankPriceType,
TankType, TankType,
Tier,
toUniqueId, toUniqueId,
Unlock, Unlock,
Vector3, Vector3,
@@ -890,7 +889,7 @@ export async function definitions() {
: (typeof tank.price === 'number' ? false : 'gold' in tank.price) : (typeof tank.price === 'number' ? false : 'gold' in tank.price)
? TankType.PREMIUM ? TankType.PREMIUM
: TankType.RESEARCHABLE, : TankType.RESEARCHABLE,
tier: (tank.level - 1) as Tier, tier: tank.level,
class: blitzTankClassToBlitzkit[tankTags[0] as BlitzTankClass], class: blitzTankClassToBlitzkit[tankTags[0] as BlitzTankClass],
testing: tankTags.includes('testTank'), testing: tankTags.includes('testTank'),
deprecated: tankTags.includes('deprecated'), deprecated: tankTags.includes('deprecated'),
@@ -967,7 +966,7 @@ export async function definitions() {
resistance_hard: terrainResistances[0], resistance_hard: terrainResistances[0],
resistance_medium: terrainResistances[1], resistance_medium: terrainResistances[1],
resistance_soft: terrainResistances[2], resistance_soft: terrainResistances[2],
tier: (track.level - 1) as Tier, tier: track.level,
unlocks: resolveUnlocks(track.unlocks), unlocks: resolveUnlocks(track.unlocks),
}); });
@@ -990,7 +989,7 @@ export async function definitions() {
id: engineId, id: engineId,
name: strings[engineListEntry.userString], name: strings[engineListEntry.userString],
fire_chance: engineListEntry.fireStartingChance, fire_chance: engineListEntry.fireStartingChance,
tier: (engineListEntry.level - 1) as Tier, tier: engineListEntry.level,
weight: engineListEntry.weight, weight: engineListEntry.weight,
power: engineListEntry.power, power: engineListEntry.power,
unlocks: resolveUnlocks(engine.unlocks), unlocks: resolveUnlocks(engine.unlocks),
@@ -1050,7 +1049,7 @@ export async function definitions() {
turretKey turretKey
.replaceAll('_', ' ') .replaceAll('_', ' ')
.replace(/^(Turret ([0-9] )?)+/, ''), .replace(/^(Turret ([0-9] )?)+/, ''),
tier: (turret.level - 1) as Tier, tier: turret.level,
guns: [], guns: [],
health: turret.maxHealth, health: turret.maxHealth,
view_range: turret.circularVisionRadius, view_range: turret.circularVisionRadius,
@@ -1162,7 +1161,7 @@ export async function definitions() {
weight: gunListEntry.weight, weight: gunListEntry.weight,
rotation_speed: gunListEntry.rotationSpeed, rotation_speed: gunListEntry.rotationSpeed,
name: gunName, name: gunName,
tier: (gunListEntry.level - 1) as Tier, tier: gunListEntry.level,
shells: [], shells: [],
camouflage_loss: camouflage_loss:
typeof gun.invisibilityFactorAtShot === 'number' typeof gun.invisibilityFactorAtShot === 'number'
@@ -1440,8 +1439,8 @@ export async function definitions() {
filter_type: { filter_type: {
$case: 'tiers', $case: 'tiers',
value: { value: {
min: (includeRaw.minLevel - 1) as Tier, min: includeRaw.minLevel,
max: (includeRaw.maxLevel - 1) as Tier, max: includeRaw.maxLevel,
}, },
}, },
}); });
@@ -1543,8 +1542,8 @@ export async function definitions() {
filter_type: { filter_type: {
$case: 'tiers', $case: 'tiers',
value: { value: {
min: (includeRaw.minLevel - 1) as Tier, min: includeRaw.minLevel,
max: (includeRaw.maxLevel - 1) as Tier, max: includeRaw.maxLevel,
}, },
}, },
}); });
@@ -4,7 +4,6 @@ import {
TANK_CLASSES, TANK_CLASSES,
TankType, TankType,
TIER_ROMAN_NUMERALS, TIER_ROMAN_NUMERALS,
type Tier,
} from '@blitzkit/core'; } from '@blitzkit/core';
import { useStore } from '@nanostores/react'; import { useStore } from '@nanostores/react';
import { ReloadIcon } from '@radix-ui/react-icons'; import { ReloadIcon } from '@radix-ui/react-icons';
@@ -42,7 +41,7 @@ export function FilterControl({ compact }: FilterControlProps) {
> >
<Flex direction={compact ? 'column' : { md: 'row', initial: 'column' }}> <Flex direction={compact ? 'column' : { md: 'row', initial: 'column' }}>
{times(5, (index) => { {times(5, (index) => {
const tier = index as Tier; const tier = index + 1;
const selected = tankFilters.tiers?.includes(tier); const selected = tankFilters.tiers?.includes(tier);
return ( return (
@@ -70,7 +69,7 @@ export function FilterControl({ compact }: FilterControlProps) {
</Flex> </Flex>
<Flex direction={compact ? 'column' : { md: 'row', initial: 'column' }}> <Flex direction={compact ? 'column' : { md: 'row', initial: 'column' }}>
{times(5, (index) => { {times(5, (index) => {
const tier = (index + 5) as Tier; const tier = index + 6;
const selected = tankFilters.tiers?.includes(tier); const selected = tankFilters.tiers?.includes(tier);
return ( return (
@@ -1,4 +1,4 @@
import { type Tier, TIER_ROMAN_NUMERALS } from '@blitzkit/core'; import { TIER_ROMAN_NUMERALS } from '@blitzkit/core';
import { useStore } from '@nanostores/react'; import { useStore } from '@nanostores/react';
import { Flex, IconButton, Text } from '@radix-ui/themes'; import { Flex, IconButton, Text } from '@radix-ui/themes';
import { times } from 'lodash-es'; import { times } from 'lodash-es';
@@ -20,7 +20,7 @@ export const TierFilter = memo(() => {
style={{ borderRadius: 'var(--radius-full)' }} style={{ borderRadius: 'var(--radius-full)' }}
> >
{times(10, (index) => { {times(10, (index) => {
const tier = (10 - index) as Tier; const tier = 10 - index;
const selected = tankFilters.tiers.includes(tier); const selected = tankFilters.tiers.includes(tier);
return ( return (
@@ -30,25 +30,16 @@ export const TierFilter = memo(() => {
radius="none" radius="none"
color={selected ? undefined : 'gray'} color={selected ? undefined : 'gray'}
highContrast highContrast
onClick={() => onClick={() => {
// mutateTankFilters((draft) => { if (tankFilters.tiers.includes(tier)) {
// if (draft.tiers?.includes(tier)) { $tankFilters.setKey(
// draft.tiers = draft.tiers?.filter((t) => t !== tier); 'tiers',
// } else { tankFilters.tiers.filter((t) => t !== tier),
// draft.tiers = [...(draft.tiers ?? []), tier]; );
// } } else {
// }) $tankFilters.setKey('tiers', [...tankFilters.tiers, tier]);
{
if (tankFilters.tiers.includes(tier)) {
$tankFilters.setKey(
'tiers',
tankFilters.tiers.filter((t) => t !== tier),
);
} else {
$tankFilters.setKey('tiers', [...tankFilters.tiers, tier]);
}
} }
} }}
> >
<Text size="2">{TIER_ROMAN_NUMERALS[tier]}</Text> <Text size="2">{TIER_ROMAN_NUMERALS[tier]}</Text>
</IconButton> </IconButton>
@@ -10,7 +10,6 @@ import {
TrackDefinition, TrackDefinition,
TurretDefinition, TurretDefinition,
type TankDefinition, type TankDefinition,
type Tier,
type Unlock, type Unlock,
} from '@blitzkit/core'; } from '@blitzkit/core';
import { import {
@@ -58,7 +57,7 @@ function ModuleButton({
onClick, onClick,
}: { }: {
unlock: Unlock; unlock: Unlock;
tier: Tier; tier: number;
selected: boolean; selected: boolean;
top: boolean; top: boolean;
onClick: () => void; onClick: () => void;
@@ -3,7 +3,6 @@ import {
fetchAverageDefinitions, fetchAverageDefinitions,
fetchTankDefinitions, fetchTankDefinitions,
formatCompact, formatCompact,
Tier,
TIER_ROMAN_NUMERALS, TIER_ROMAN_NUMERALS,
} from '@blitzkit/core'; } from '@blitzkit/core';
import { Box, Flex, Link, Skeleton, Text } from '@radix-ui/themes'; import { Box, Flex, Link, Skeleton, Text } from '@radix-ui/themes';
@@ -125,7 +124,7 @@ export function Node({ id, highlight, nextIds, skeleton }: NodeProps) {
</Text> </Text>
</Flex> </Flex>
{averages && nextTanks && tank.tier !== Tier.X && ( {averages && nextTanks && tank.tier !== 10 && (
<Text color="gray" size="1" mt="2"> <Text color="gray" size="1" mt="2">
{skeleton && <Skeleton height="1em" width="4em" />} {skeleton && <Skeleton height="1em" width="4em" />}
{!skeleton && ( {!skeleton && (
@@ -1,10 +1,4 @@
import { import { asset, fetchTankDefinitions, imgur, TankType } from '@blitzkit/core';
asset,
fetchTankDefinitions,
imgur,
TankType,
Tier,
} from '@blitzkit/core';
import { CaretLeftIcon, CaretRightIcon, PlusIcon } from '@radix-ui/react-icons'; import { CaretLeftIcon, CaretRightIcon, PlusIcon } from '@radix-ui/react-icons';
import { Flex, Heading, IconButton, ScrollArea, Text } from '@radix-ui/themes'; import { Flex, Heading, IconButton, ScrollArea, Text } from '@radix-ui/themes';
import { Fragment, useEffect, useMemo, useRef, useState } from 'react'; import { Fragment, useEffect, useMemo, useRef, useState } from 'react';
@@ -32,10 +26,10 @@ export function TechTreeSection({ skeleton }: MaybeSkeletonComponentProps) {
function extend(line: Line): Line[] { function extend(line: Line): Line[] {
const root = tankDefinitions.tanks[line.at(-1)!]; const root = tankDefinitions.tanks[line.at(-1)!];
if (root.ancestors === undefined || root.tier === Tier.I) { if (root.ancestors === undefined || root.tier === 1) {
return [line]; return [line];
} else { } else {
if (root.ancestors.length === 1 || root.tier === Tier.II) { if (root.ancestors.length === 1 || root.tier === 2) {
line.push( line.push(
root.ancestors.find( root.ancestors.find(
(ancestor) => !tankDefinitions.tanks[ancestor].deprecated, (ancestor) => !tankDefinitions.tanks[ancestor].deprecated,
@@ -64,7 +58,7 @@ export function TechTreeSection({ skeleton }: MaybeSkeletonComponentProps) {
(xp, id) => (xp, id) =>
xp + xp +
(tankDefinitions.tanks[id].research_cost === undefined || (tankDefinitions.tanks[id].research_cost === undefined ||
tankDefinitions.tanks[id].tier === Tier.I tankDefinitions.tanks[id].tier === 1
? 0 ? 0
: (tankDefinitions.tanks[id].research_cost.research_cost_type! : (tankDefinitions.tanks[id].research_cost.research_cost_type!
.value as number)), .value as number)),
@@ -191,7 +185,7 @@ export function TechTreeSection({ skeleton }: MaybeSkeletonComponentProps) {
); );
})} })}
{master.tier < Tier.X && ( {master.tier < 10 && (
<> <>
<Arrow /> <Arrow />
{master.successors!.map((id, index) => ( {master.successors!.map((id, index) => (
+2 -2
View File
@@ -1,4 +1,4 @@
import type { GunDefinition, TankClass, TankType, Tier } from '@blitzkit/core'; import type { GunDefinition, TankClass, TankType } from '@blitzkit/core';
import { map } from 'nanostores'; import { map } from 'nanostores';
export type CaseType<T> = T extends { export type CaseType<T> = T extends {
@@ -8,7 +8,7 @@ export type CaseType<T> = T extends {
: never; : never;
export interface TankFilters { export interface TankFilters {
tiers: Tier[]; tiers: number[];
nations: string[]; nations: string[];
classes: TankClass[]; classes: TankClass[];
types: TankType[]; types: TankType[];