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