2023-08-10 01:46:39 +00:00
|
|
|
import { deburr } from 'lodash';
|
2023-11-30 12:21:20 -06:00
|
|
|
import { TankType, TreeTypeString } from '../../components/Tanks';
|
2023-11-29 12:17:21 -06:00
|
|
|
import { asset } from './asset';
|
2023-08-10 01:03:53 +00:00
|
|
|
|
2023-06-03 18:25:33 +00:00
|
|
|
export interface TankopediaEntry {
|
2023-07-08 19:47:21 +00:00
|
|
|
name: string;
|
2023-07-09 00:51:53 +00:00
|
|
|
nation: string;
|
2023-07-08 19:47:21 +00:00
|
|
|
is_premium: boolean;
|
2023-07-10 18:16:33 +00:00
|
|
|
is_collectible: boolean;
|
2023-10-11 18:57:51 -05:00
|
|
|
tier: Tier;
|
2023-07-09 00:51:53 +00:00
|
|
|
cost: { price_credit: number; price_gold: number };
|
2023-07-08 19:47:21 +00:00
|
|
|
images: { preview: string; normal: string };
|
2023-07-09 00:51:53 +00:00
|
|
|
tank_id: number;
|
2023-10-11 18:26:35 -05:00
|
|
|
type: string;
|
2023-07-09 00:51:53 +00:00
|
|
|
description: string;
|
2023-06-03 18:25:33 +00:00
|
|
|
}
|
2023-05-30 18:42:34 +00:00
|
|
|
export interface Tankopedia {
|
2023-07-07 01:08:00 +00:00
|
|
|
[id: number]: TankopediaEntry | undefined;
|
2023-05-30 18:42:34 +00:00
|
|
|
}
|
|
|
|
|
|
2023-11-29 12:17:21 -06:00
|
|
|
export interface BlitzkriegTankopediaEntry {
|
|
|
|
|
id: number;
|
|
|
|
|
nation: string;
|
|
|
|
|
name: string;
|
|
|
|
|
name_short?: string;
|
|
|
|
|
tree_type: TreeTypeString;
|
|
|
|
|
tier: Tier;
|
2023-11-30 12:21:20 -06:00
|
|
|
type: TankType;
|
2023-11-29 12:17:21 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export type BlitzkriegTankopedia = Record<number, BlitzkriegTankopediaEntry>;
|
|
|
|
|
|
2023-11-30 12:59:37 -06:00
|
|
|
export const tankopedia = fetch(asset('tankopedia.json'), {
|
|
|
|
|
cache: 'no-store',
|
|
|
|
|
}).then(async (response) => response.json() as Promise<BlitzkriegTankopedia>);
|
2023-11-29 12:17:21 -06:00
|
|
|
const entries = new Promise<BlitzkriegTankopediaEntry[]>(async (resolve) => {
|
2023-07-05 17:42:14 +00:00
|
|
|
resolve(Object.entries(await tankopedia).map(([, entry]) => entry));
|
|
|
|
|
});
|
2023-11-30 12:21:20 -06:00
|
|
|
export const tanks = new Promise<BlitzkriegTankopediaEntry[]>(
|
2023-11-29 12:17:21 -06:00
|
|
|
async (resolve) => {
|
|
|
|
|
resolve((await entries).map((entry) => entry));
|
|
|
|
|
},
|
|
|
|
|
);
|
2023-11-30 12:21:20 -06:00
|
|
|
export const tankNames = new Promise<string[]>(async (resolve) => {
|
2023-07-05 17:42:14 +00:00
|
|
|
resolve((await entries).map(({ name }) => name));
|
|
|
|
|
});
|
2023-11-30 12:21:20 -06:00
|
|
|
export const tankNamesDiacritics = tankNames.then((tankNames) =>
|
2023-08-10 01:46:39 +00:00
|
|
|
Promise.all(
|
|
|
|
|
tankNames.map(async (tankName, index) => {
|
2023-11-30 12:21:20 -06:00
|
|
|
const { id } = (await tanks)[index];
|
2023-08-11 17:57:44 +00:00
|
|
|
const name = tankName ?? `Unknown Tank ${id}`;
|
2023-08-10 01:46:39 +00:00
|
|
|
const diacriticless = deburr(name);
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
original: name,
|
|
|
|
|
diacriticless,
|
|
|
|
|
combined: `${name}${diacriticless}`,
|
2023-08-11 17:57:44 +00:00
|
|
|
id,
|
2023-08-10 01:46:39 +00:00
|
|
|
};
|
|
|
|
|
}),
|
|
|
|
|
),
|
|
|
|
|
);
|
2023-05-30 18:42:34 +00:00
|
|
|
|
2023-12-01 12:36:31 -06:00
|
|
|
export const TANK_ICONS: Record<TankType, string> = {
|
2023-06-05 18:47:00 +00:00
|
|
|
'AT-SPG': 'https://i.imgur.com/BIHSEH0.png',
|
|
|
|
|
lightTank: 'https://i.imgur.com/CSNha5V.png',
|
|
|
|
|
mediumTank: 'https://i.imgur.com/wvf3ltm.png',
|
|
|
|
|
heavyTank: 'https://i.imgur.com/ECeqlZa.png',
|
|
|
|
|
};
|
|
|
|
|
|
2023-12-01 12:36:31 -06:00
|
|
|
export const TANK_ICONS_PREMIUM: Record<TankType, string> = {
|
2023-07-09 00:47:03 +00:00
|
|
|
'AT-SPG': 'https://i.imgur.com/TCu3EdR.png',
|
|
|
|
|
lightTank: 'https://i.imgur.com/zdkpTRb.png',
|
|
|
|
|
mediumTank: 'https://i.imgur.com/3z7eHX6.png',
|
|
|
|
|
heavyTank: 'https://i.imgur.com/P3vbmyA.png',
|
|
|
|
|
};
|
|
|
|
|
|
2023-12-01 12:36:31 -06:00
|
|
|
export const TANK_ICONS_COLLECTOR: Record<TankType, string> = {
|
2023-07-10 18:16:33 +00:00
|
|
|
'AT-SPG': 'https://i.imgur.com/WTjeirB.png',
|
|
|
|
|
lightTank: 'https://i.imgur.com/EwhtKkU.png',
|
|
|
|
|
mediumTank: 'https://i.imgur.com/u8YDMBh.png',
|
|
|
|
|
heavyTank: 'https://i.imgur.com/8xRf3nc.png',
|
|
|
|
|
};
|
|
|
|
|
|
2023-06-19 18:08:34 +00:00
|
|
|
export type Tier = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10;
|
|
|
|
|
|
|
|
|
|
export const TIER_ROMAN_NUMERALS: Record<Tier, string> = {
|
2023-06-05 18:47:00 +00:00
|
|
|
1: 'I',
|
|
|
|
|
2: 'II',
|
|
|
|
|
3: 'III',
|
|
|
|
|
4: 'IV',
|
|
|
|
|
5: 'V',
|
|
|
|
|
6: 'VI',
|
|
|
|
|
7: 'VII',
|
|
|
|
|
8: 'VIII',
|
|
|
|
|
9: 'IX',
|
|
|
|
|
10: 'X',
|
2023-05-30 18:42:34 +00:00
|
|
|
};
|