mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-25 11:39:51 +01:00
feat: core chunk 3
This commit is contained in:
1 parent
970ab9004e
commit
07e3660388
25 files changed
+57
-58
No files matched your search
Vendored
+1
@@ -43,6 +43,7 @@
|
|||||||
"wargaming",
|
"wargaming",
|
||||||
"webp",
|
"webp",
|
||||||
"winrate",
|
"winrate",
|
||||||
|
"wotblitz",
|
||||||
"zustand"
|
"zustand"
|
||||||
],
|
],
|
||||||
"deno.enable": false,
|
"deno.enable": false,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import throwError from '../node/throwError';
|
import throwError from '../../core/node/throwError';
|
||||||
|
|
||||||
export type WargamingResponse<Data extends object> =
|
export type BlitzResponse<Data extends object> =
|
||||||
| {
|
| {
|
||||||
status: 'error';
|
status: 'error';
|
||||||
error: { field: string; message: string; code: 402; value: null };
|
error: { field: string; message: string; code: 402; value: null };
|
||||||
@@ -10,12 +10,10 @@ export type WargamingResponse<Data extends object> =
|
|||||||
data: Data;
|
data: Data;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default async function getWargamingResponse<Data extends object>(
|
export default async function fetchBlitz<Data extends object>(url: string) {
|
||||||
url: string,
|
|
||||||
) {
|
|
||||||
const data = (await fetch(url).then((response) =>
|
const data = (await fetch(url).then((response) =>
|
||||||
response.json(),
|
response.json(),
|
||||||
)) as WargamingResponse<Data>;
|
)) as BlitzResponse<Data>;
|
||||||
|
|
||||||
if (data.status === 'ok') {
|
if (data.status === 'ok') {
|
||||||
return data.data;
|
return data.data;
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import { Region } from '../../constants/regions';
|
import { Region } from '../../constants/regions';
|
||||||
import { WARGAMING_APPLICATION_ID } from '../../constants/wargamingApplicationID';
|
import { WARGAMING_APPLICATION_ID } from '../../constants/wargamingApplicationID';
|
||||||
import getWargamingResponse from '../../core/blitz/getWargamingResponse';
|
import fetchBlitz from './fetchWargaming';
|
||||||
import { normalizeIds } from './normalizeIds';
|
import { normalizeIds } from './normalizeIds';
|
||||||
|
|
||||||
interface IndividualAccountAchievements {
|
interface IndividualAccountAchievements {
|
||||||
@@ -22,7 +22,7 @@ export async function getAccountAchievements<
|
|||||||
? IndividualAccountAchievements
|
? IndividualAccountAchievements
|
||||||
: IndividualAccountAchievements[],
|
: IndividualAccountAchievements[],
|
||||||
>(region: Region, ids: Ids) {
|
>(region: Region, ids: Ids) {
|
||||||
const object = await getWargamingResponse<AccountAchievements>(
|
const object = await fetchBlitz<AccountAchievements>(
|
||||||
`https://api.wotblitz.${region}/wotb/account/achievements/?application_id=${WARGAMING_APPLICATION_ID}&account_id=${normalizeIds(
|
`https://api.wotblitz.${region}/wotb/account/achievements/?application_id=${WARGAMING_APPLICATION_ID}&account_id=${normalizeIds(
|
||||||
ids,
|
ids,
|
||||||
)}`,
|
)}`,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { Region } from '../../constants/regions';
|
import { Region } from '../../constants/regions';
|
||||||
import { WARGAMING_APPLICATION_ID } from '../../constants/wargamingApplicationID';
|
import { WARGAMING_APPLICATION_ID } from '../../constants/wargamingApplicationID';
|
||||||
import getWargamingResponse from '../../core/blitz/getWargamingResponse';
|
import fetchBlitz from './fetchWargaming';
|
||||||
import { normalizeIds } from './normalizeIds';
|
import { normalizeIds } from './normalizeIds';
|
||||||
|
|
||||||
export interface AllStats {
|
export interface AllStats {
|
||||||
@@ -75,7 +75,7 @@ export async function getAccountInfo<
|
|||||||
? IndividualAccountInfo
|
? IndividualAccountInfo
|
||||||
: IndividualAccountInfo[],
|
: IndividualAccountInfo[],
|
||||||
>(region: Region, ids: Ids) {
|
>(region: Region, ids: Ids) {
|
||||||
const object = await getWargamingResponse<AccountInfo>(
|
const object = await fetchBlitz<AccountInfo>(
|
||||||
`https://api.wotblitz.${region}/wotb/account/info/?application_id=${WARGAMING_APPLICATION_ID}&account_id=${normalizeIds(
|
`https://api.wotblitz.${region}/wotb/account/info/?application_id=${WARGAMING_APPLICATION_ID}&account_id=${normalizeIds(
|
||||||
ids,
|
ids,
|
||||||
)}`,
|
)}`,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { Region } from '../../constants/regions';
|
import { Region } from '../../constants/regions';
|
||||||
import { WARGAMING_APPLICATION_ID } from '../../constants/wargamingApplicationID';
|
import { WARGAMING_APPLICATION_ID } from '../../constants/wargamingApplicationID';
|
||||||
import getWargamingResponse from '../../core/blitz/getWargamingResponse';
|
import fetchBlitz from './fetchWargaming';
|
||||||
import { normalizeExtra } from './normalizeExtra';
|
import { normalizeExtra } from './normalizeExtra';
|
||||||
import { normalizeIds } from './normalizeIds';
|
import { normalizeIds } from './normalizeIds';
|
||||||
|
|
||||||
@@ -31,7 +31,7 @@ export async function getClanAccountInfo<
|
|||||||
? IndividualClanAccountInfo
|
? IndividualClanAccountInfo
|
||||||
: IndividualClanAccountInfo[],
|
: IndividualClanAccountInfo[],
|
||||||
>(region: Region, ids: Ids, extra?: string[]) {
|
>(region: Region, ids: Ids, extra?: string[]) {
|
||||||
const object = await getWargamingResponse<ClanAccountInfo>(
|
const object = await fetchBlitz<ClanAccountInfo>(
|
||||||
`https://api.wotblitz.${region}/wotb/clans/info/?application_id=${WARGAMING_APPLICATION_ID}&account_id=${normalizeIds(
|
`https://api.wotblitz.${region}/wotb/clans/info/?application_id=${WARGAMING_APPLICATION_ID}&account_id=${normalizeIds(
|
||||||
ids,
|
ids,
|
||||||
)}${normalizeExtra(extra)}`,
|
)}${normalizeExtra(extra)}`,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { Region } from '../../constants/regions';
|
import { Region } from '../../constants/regions';
|
||||||
import { WARGAMING_APPLICATION_ID } from '../../constants/wargamingApplicationID';
|
import { WARGAMING_APPLICATION_ID } from '../../constants/wargamingApplicationID';
|
||||||
import getWargamingResponse from '../../core/blitz/getWargamingResponse';
|
import fetchBlitz from './fetchWargaming';
|
||||||
import { normalizeIds } from './normalizeIds';
|
import { normalizeIds } from './normalizeIds';
|
||||||
|
|
||||||
export interface IndividualClanInfo {
|
export interface IndividualClanInfo {
|
||||||
@@ -40,7 +40,7 @@ export async function getClanInfo<
|
|||||||
Ids extends number | number[],
|
Ids extends number | number[],
|
||||||
ReturnType = Ids extends number ? IndividualClanInfo : IndividualClanInfo[],
|
ReturnType = Ids extends number ? IndividualClanInfo : IndividualClanInfo[],
|
||||||
>(region: Region, ids: Ids) {
|
>(region: Region, ids: Ids) {
|
||||||
const object = await getWargamingResponse<ClanInfo>(
|
const object = await fetchBlitz<ClanInfo>(
|
||||||
`https://api.wotblitz.${region}/wotb/clans/info/?application_id=${WARGAMING_APPLICATION_ID}&account_id=${normalizeIds(
|
`https://api.wotblitz.${region}/wotb/clans/info/?application_id=${WARGAMING_APPLICATION_ID}&account_id=${normalizeIds(
|
||||||
ids,
|
ids,
|
||||||
)}`,
|
)}`,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { RatingsInfo } from '../../commands/ratings';
|
import { RatingsInfo } from '../../commands/ratings';
|
||||||
import { Region } from '../../constants/regions';
|
import { Region } from '../../constants/regions';
|
||||||
import regionToRegionSubdomain from './regionToRegionSubdomain';
|
import regionToRegionSubdomain from '../../core/blitz/regionToRegionSubdomain';
|
||||||
|
|
||||||
export default async function getRatingsInfo(region: Region) {
|
export default async function getRatingsInfo(region: Region) {
|
||||||
const response = await fetch(
|
const response = await fetch(
|
||||||
@@ -1,18 +1,18 @@
|
|||||||
import { REGION_NAMES, Region } from '../../constants/regions';
|
import { Region } from '../../constants/regions';
|
||||||
import { WARGAMING_APPLICATION_ID } from '../../constants/wargamingApplicationID';
|
import { WARGAMING_APPLICATION_ID } from '../../constants/wargamingApplicationID';
|
||||||
|
import throwError from '../../core/node/throwError';
|
||||||
import { TanksStats } from '../../types/tanksStats';
|
import { TanksStats } from '../../types/tanksStats';
|
||||||
import throwError from '../node/throwError';
|
import fetchBlitz from './fetchWargaming';
|
||||||
import getWargamingResponse from './getWargamingResponse';
|
|
||||||
|
|
||||||
export default async function getTankStats(region: Region, id: number) {
|
export default async function getTankStats(region: Region, id: number) {
|
||||||
const tankStats = await getWargamingResponse<TanksStats>(
|
const tankStats = await fetchBlitz<TanksStats>(
|
||||||
`https://api.wotblitz.${region}/wotb/tanks/stats/?application_id=${WARGAMING_APPLICATION_ID}&account_id=${id}`,
|
`https://api.wotblitz.${region}/wotb/tanks/stats/?application_id=${WARGAMING_APPLICATION_ID}&account_id=${id}`,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (tankStats[id] === null) {
|
if (tankStats[id] === null) {
|
||||||
throw throwError(
|
throw throwError(
|
||||||
'No tank stats available',
|
'No tank stats available',
|
||||||
`Wargaming says there is no tank stats for this account. This account may not have any battles/tanks or exist in the ${REGION_NAMES[region]} server.`,
|
"This player doesn't have any stats for tanks available. This may not be the player you are looking for.",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import { TreeTypeEnum } from '../../components/Tanks';
|
import { TreeTypeEnum } from '../../components/Tanks';
|
||||||
import { tankopedia } from './tankopedia';
|
import { tankopedia } from '../../core/blitz/tankopedia';
|
||||||
|
|
||||||
export default async function getTreeType(id: number) {
|
export default async function getTreeType(id: number) {
|
||||||
const entry = (await tankopedia)[id];
|
const entry = (await tankopedia)[id];
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
export function emblemIdToURL(emblemId: number) {
|
||||||
|
return `https://wotblitz-gc.gcdn.co/icons/clanEmblems1x/clan-icon-v2-${emblemId}.png`;
|
||||||
|
}
|
||||||
@@ -2,13 +2,13 @@
|
|||||||
|
|
||||||
import { ContextMenu } from '@radix-ui/themes';
|
import { ContextMenu } from '@radix-ui/themes';
|
||||||
import { useEffect, useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
|
import fetchBlitz from '../../../_core/blitz/fetchWargaming';
|
||||||
import calculateWN8 from '../../../_core/statistics/calculateWN8';
|
import calculateWN8 from '../../../_core/statistics/calculateWN8';
|
||||||
import { deltaTankStats } from '../../../_core/statistics/deltaTankStats';
|
import { deltaTankStats } from '../../../_core/statistics/deltaTankStats';
|
||||||
import * as Breakdown from '../../../components/Breakdown';
|
import * as Breakdown from '../../../components/Breakdown';
|
||||||
import { TreeTypeEnum } from '../../../components/Tanks';
|
import { TreeTypeEnum } from '../../../components/Tanks';
|
||||||
import { WARGAMING_APPLICATION_ID } from '../../../constants/wargamingApplicationID';
|
import { WARGAMING_APPLICATION_ID } from '../../../constants/wargamingApplicationID';
|
||||||
import getWN8Percentile from '../../../core/blitz/getWN8Percentile';
|
import getWN8Percentile from '../../../core/blitz/getWN8Percentile';
|
||||||
import getWargamingResponse from '../../../core/blitz/getWargamingResponse';
|
|
||||||
import { TankopediaEntry, tankopedia } from '../../../core/blitz/tankopedia';
|
import { TankopediaEntry, tankopedia } from '../../../core/blitz/tankopedia';
|
||||||
import { tankAverages } from '../../../core/blitzstars/tankAverages';
|
import { tankAverages } from '../../../core/blitzstars/tankAverages';
|
||||||
import { useSession } from '../../../stores/session';
|
import { useSession } from '../../../stores/session';
|
||||||
@@ -73,7 +73,7 @@ export default function SessionPage() {
|
|||||||
async function recalculateDiff() {
|
async function recalculateDiff() {
|
||||||
if (session.isTracking) {
|
if (session.isTracking) {
|
||||||
const { id, region } = session;
|
const { id, region } = session;
|
||||||
const careerRaw = await getWargamingResponse<TanksStats>(
|
const careerRaw = await fetchBlitz<TanksStats>(
|
||||||
`https://api.wotblitz.${region}/wotb/tanks/stats/?application_id=${WARGAMING_APPLICATION_ID}&account_id=${id}`,
|
`https://api.wotblitz.${region}/wotb/tanks/stats/?application_id=${WARGAMING_APPLICATION_ID}&account_id=${id}`,
|
||||||
);
|
);
|
||||||
const career = careerRaw[id].reduce<
|
const career = careerRaw[id].reduce<
|
||||||
|
|||||||
@@ -18,10 +18,10 @@ import {
|
|||||||
} from '@radix-ui/themes';
|
} from '@radix-ui/themes';
|
||||||
import { debounce } from 'lodash';
|
import { debounce } from 'lodash';
|
||||||
import { ChangeEvent, useRef, useState } from 'react';
|
import { ChangeEvent, useRef, useState } from 'react';
|
||||||
|
import fetchBlitz from '../../../_core/blitz/fetchWargaming';
|
||||||
import PageWrapper from '../../../components/PageWrapper';
|
import PageWrapper from '../../../components/PageWrapper';
|
||||||
import { REGION_NAMES, Region } from '../../../constants/regions';
|
import { REGION_NAMES, Region } from '../../../constants/regions';
|
||||||
import { WARGAMING_APPLICATION_ID } from '../../../constants/wargamingApplicationID';
|
import { WARGAMING_APPLICATION_ID } from '../../../constants/wargamingApplicationID';
|
||||||
import getWargamingResponse from '../../../core/blitz/getWargamingResponse';
|
|
||||||
import listPlayers, {
|
import listPlayers, {
|
||||||
AccountListWithServer,
|
AccountListWithServer,
|
||||||
} from '../../../core/blitz/listPlayers';
|
} from '../../../core/blitz/listPlayers';
|
||||||
@@ -54,7 +54,7 @@ export default function Page() {
|
|||||||
input.current!.value = nickname;
|
input.current!.value = nickname;
|
||||||
|
|
||||||
const rawTankStats = (
|
const rawTankStats = (
|
||||||
await getWargamingResponse<TanksStats>(
|
await fetchBlitz<TanksStats>(
|
||||||
`https://api.wotblitz.${region}/wotb/tanks/stats/?application_id=${WARGAMING_APPLICATION_ID}&account_id=${id}`,
|
`https://api.wotblitz.${region}/wotb/tanks/stats/?application_id=${WARGAMING_APPLICATION_ID}&account_id=${id}`,
|
||||||
)
|
)
|
||||||
)[id];
|
)[id];
|
||||||
|
|||||||
@@ -4,11 +4,11 @@ import {
|
|||||||
} from 'discord.js';
|
} from 'discord.js';
|
||||||
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 { emblemIdToURL } from '../_core/blitzkrieg/emblemIdToURL';
|
||||||
import * as Graph from '../components/Graph';
|
import * as Graph from '../components/Graph';
|
||||||
import NoData, { NoDataType } from '../components/NoData';
|
import NoData, { NoDataType } from '../components/NoData';
|
||||||
import TitleBar from '../components/TitleBar';
|
import TitleBar from '../components/TitleBar';
|
||||||
import Wrapper from '../components/Wrapper';
|
import Wrapper from '../components/Wrapper';
|
||||||
import { getClanLogo } from '../core/blitz/getClanLogo';
|
|
||||||
import resolveTankId from '../core/blitz/resolveTankId';
|
import resolveTankId from '../core/blitz/resolveTankId';
|
||||||
import { getBlitzStarsLinkButton } from '../core/blitzstars/getBlitzStarsLinkButton';
|
import { getBlitzStarsLinkButton } from '../core/blitzstars/getBlitzStarsLinkButton';
|
||||||
import getPlayerHistories from '../core/blitzstars/getPlayerHistories';
|
import getPlayerHistories from '../core/blitzstars/getPlayerHistories';
|
||||||
@@ -41,7 +41,7 @@ async function render(
|
|||||||
) {
|
) {
|
||||||
const accountInfo = await getAccountInfo(region, id);
|
const accountInfo = await getAccountInfo(region, id);
|
||||||
const clan = (await getClanAccountInfo(region, id))?.clan;
|
const clan = (await getClanAccountInfo(region, id))?.clan;
|
||||||
const logo = clan ? getClanLogo(clan.emblem_set_id) : undefined;
|
const logo = clan ? emblemIdToURL(clan.emblem_set_id) : undefined;
|
||||||
const histories = await (type === 'player'
|
const histories = await (type === 'player'
|
||||||
? getPlayerHistories(region, id, {
|
? getPlayerHistories(region, id, {
|
||||||
start,
|
start,
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
import { SlashCommandBuilder } from 'discord.js';
|
import { SlashCommandBuilder } from 'discord.js';
|
||||||
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 { emblemIdToURL } from '../_core/blitzkrieg/emblemIdToURL';
|
||||||
import { StatFilters, filterStats } from '../_core/statistics/filterStats';
|
import { StatFilters, filterStats } from '../_core/statistics/filterStats';
|
||||||
import GenericAllStats from '../components/GenericAllStats';
|
import GenericAllStats from '../components/GenericAllStats';
|
||||||
import NoData, { NoDataType } from '../components/NoData';
|
import NoData, { NoDataType } from '../components/NoData';
|
||||||
import TierWeights from '../components/TierWeights';
|
import TierWeights from '../components/TierWeights';
|
||||||
import TitleBar from '../components/TitleBar';
|
import TitleBar from '../components/TitleBar';
|
||||||
import Wrapper from '../components/Wrapper';
|
import Wrapper from '../components/Wrapper';
|
||||||
import { getClanLogo } from '../core/blitz/getClanLogo';
|
|
||||||
import { filtersToDescription } from '../core/blitzkrieg/filtersToDescription';
|
import { filtersToDescription } from '../core/blitzkrieg/filtersToDescription';
|
||||||
import { getTierWeights } from '../core/blitzkrieg/getTierWeights';
|
import { getTierWeights } from '../core/blitzkrieg/getTierWeights';
|
||||||
import { getBlitzStarsLinkButton } from '../core/blitzstars/getBlitzStarsLinkButton';
|
import { getBlitzStarsLinkButton } from '../core/blitzstars/getBlitzStarsLinkButton';
|
||||||
@@ -38,7 +38,7 @@ async function render(
|
|||||||
) {
|
) {
|
||||||
const { nickname } = await getAccountInfo(region, id);
|
const { nickname } = await getAccountInfo(region, id);
|
||||||
const clan = (await getClanAccountInfo(region, id))?.clan;
|
const clan = (await getClanAccountInfo(region, id))?.clan;
|
||||||
const clanImage = clan ? getClanLogo(clan.emblem_set_id) : undefined;
|
const clanImage = clan ? emblemIdToURL(clan.emblem_set_id) : undefined;
|
||||||
const diffedTankStats = await getDiffedTankStats(region, id, start, end);
|
const diffedTankStats = await getDiffedTankStats(region, id, start, end);
|
||||||
const { stats, supplementary, filteredOrder } = await filterStats(
|
const { stats, supplementary, filteredOrder } = await filterStats(
|
||||||
diffedTankStats,
|
diffedTankStats,
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
import { SlashCommandBuilder } from 'discord.js';
|
import { SlashCommandBuilder } from 'discord.js';
|
||||||
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 getTreeType from '../_core/blitz/getTreeType';
|
||||||
|
import { emblemIdToURL } from '../_core/blitzkrieg/emblemIdToURL';
|
||||||
import NoData, { NoDataType } from '../components/NoData';
|
import NoData, { NoDataType } from '../components/NoData';
|
||||||
import * as Tanks from '../components/Tanks';
|
import * as Tanks from '../components/Tanks';
|
||||||
import TitleBar from '../components/TitleBar';
|
import TitleBar from '../components/TitleBar';
|
||||||
import Wrapper from '../components/Wrapper';
|
import Wrapper from '../components/Wrapper';
|
||||||
import { getClanLogo } from '../core/blitz/getClanLogo';
|
|
||||||
import getTankStats from '../core/blitz/getTankStats';
|
|
||||||
import getTreeType from '../core/blitz/getTreeType';
|
|
||||||
import resolveTankName from '../core/blitz/resolveTankName';
|
import resolveTankName from '../core/blitz/resolveTankName';
|
||||||
import {
|
import {
|
||||||
TIER_ROMAN_NUMERALS,
|
TIER_ROMAN_NUMERALS,
|
||||||
@@ -67,7 +67,7 @@ export const ownedTanksCommand: CommandRegistry = {
|
|||||||
name={accountInfo.nickname}
|
name={accountInfo.nickname}
|
||||||
image={
|
image={
|
||||||
clanAccountInfo?.clan
|
clanAccountInfo?.clan
|
||||||
? getClanLogo(clanAccountInfo.clan.emblem_set_id)
|
? emblemIdToURL(clanAccountInfo.clan.emblem_set_id)
|
||||||
: undefined
|
: undefined
|
||||||
}
|
}
|
||||||
description={`Tier ${TIER_ROMAN_NUMERALS[tier as Tier]} tanks`}
|
description={`Tier ${TIER_ROMAN_NUMERALS[tier as Tier]} tanks`}
|
||||||
|
|||||||
@@ -7,12 +7,12 @@ import {
|
|||||||
import { BlitzkriegRatingsLeaderboard } from '../../scripts/buildRatingsLeaderboard';
|
import { BlitzkriegRatingsLeaderboard } from '../../scripts/buildRatingsLeaderboard';
|
||||||
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 getRatingsInfo from '../_core/blitz/getRatingsInfo';
|
||||||
import getArchivedRatingsInfo from '../_core/blitzkrieg/getArchivedRatingsInfo';
|
import getArchivedRatingsInfo from '../_core/blitzkrieg/getArchivedRatingsInfo';
|
||||||
import * as Leaderboard from '../components/Leaderboard';
|
import * as Leaderboard from '../components/Leaderboard';
|
||||||
import TitleBar from '../components/TitleBar';
|
import TitleBar from '../components/TitleBar';
|
||||||
import Wrapper from '../components/Wrapper';
|
import Wrapper from '../components/Wrapper';
|
||||||
import { REGION_NAMES_SHORT, Region } from '../constants/regions';
|
import { REGION_NAMES_SHORT, Region } from '../constants/regions';
|
||||||
import getRatingsInfo from '../core/blitz/getRatingsInfo';
|
|
||||||
import regionToRegionSubdomain from '../core/blitz/regionToRegionSubdomain';
|
import regionToRegionSubdomain from '../core/blitz/regionToRegionSubdomain';
|
||||||
import getMidnightLeaderboard, {
|
import getMidnightLeaderboard, {
|
||||||
DATABASE_REPO,
|
DATABASE_REPO,
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import { SlashCommandBuilder } from 'discord.js';
|
import { SlashCommandBuilder } from 'discord.js';
|
||||||
import markdownEscape from 'markdown-escape';
|
import markdownEscape from 'markdown-escape';
|
||||||
|
import fetchBlitz from '../_core/blitz/fetchWargaming';
|
||||||
import { REGION_NAMES, Region } from '../constants/regions';
|
import { REGION_NAMES, Region } from '../constants/regions';
|
||||||
import { WARGAMING_APPLICATION_ID } from '../constants/wargamingApplicationID';
|
import { WARGAMING_APPLICATION_ID } from '../constants/wargamingApplicationID';
|
||||||
import getWargamingResponse from '../core/blitz/getWargamingResponse';
|
|
||||||
import addClanChoices from '../core/discord/addClanChoices';
|
import addClanChoices from '../core/discord/addClanChoices';
|
||||||
import addRegionChoices from '../core/discord/addRegionChoices';
|
import addRegionChoices from '../core/discord/addRegionChoices';
|
||||||
import embedInfo from '../core/discord/embedInfo';
|
import embedInfo from '../core/discord/embedInfo';
|
||||||
@@ -30,7 +30,7 @@ export const searchClansCommand: CommandRegistry = {
|
|||||||
const server = interaction.options.getString('region') as Region;
|
const server = interaction.options.getString('region') as Region;
|
||||||
const clan = interaction.options.getString('clan')!;
|
const clan = interaction.options.getString('clan')!;
|
||||||
const limit = interaction.options.getInteger('limit') ?? 25;
|
const limit = interaction.options.getInteger('limit') ?? 25;
|
||||||
const clanList = await getWargamingResponse<ClanList>(
|
const clanList = await fetchBlitz<ClanList>(
|
||||||
`https://api.wotblitz.${server}/wotb/clans/list/?application_id=${WARGAMING_APPLICATION_ID}&search=${clan}&limit=${limit}`,
|
`https://api.wotblitz.${server}/wotb/clans/list/?application_id=${WARGAMING_APPLICATION_ID}&search=${clan}&limit=${limit}`,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import { SlashCommandBuilder } from 'discord.js';
|
import { SlashCommandBuilder } from 'discord.js';
|
||||||
import markdownEscape from 'markdown-escape';
|
import markdownEscape from 'markdown-escape';
|
||||||
|
import fetchBlitz from '../_core/blitz/fetchWargaming';
|
||||||
import { REGION_NAMES, Region } from '../constants/regions';
|
import { REGION_NAMES, Region } from '../constants/regions';
|
||||||
import { WARGAMING_APPLICATION_ID } from '../constants/wargamingApplicationID';
|
import { WARGAMING_APPLICATION_ID } from '../constants/wargamingApplicationID';
|
||||||
import getWargamingResponse from '../core/blitz/getWargamingResponse';
|
|
||||||
import { AccountList, usernamePattern } from '../core/blitz/listPlayers';
|
import { AccountList, usernamePattern } from '../core/blitz/listPlayers';
|
||||||
import addRegionChoices from '../core/discord/addRegionChoices';
|
import addRegionChoices from '../core/discord/addRegionChoices';
|
||||||
import addUsernameChoices from '../core/discord/addUsernameChoices';
|
import addUsernameChoices from '../core/discord/addUsernameChoices';
|
||||||
@@ -34,7 +34,7 @@ export const searchPlayersCommand: CommandRegistry = {
|
|||||||
const limit = interaction.options.getInteger('limit') ?? 25;
|
const limit = interaction.options.getInteger('limit') ?? 25;
|
||||||
const trimmedSearch = name.trim();
|
const trimmedSearch = name.trim();
|
||||||
const players = usernamePattern.test(trimmedSearch)
|
const players = usernamePattern.test(trimmedSearch)
|
||||||
? await getWargamingResponse<AccountList>(
|
? await fetchBlitz<AccountList>(
|
||||||
`https://api.wotblitz.${server}/wotb/account/list/?application_id=${WARGAMING_APPLICATION_ID}&search=${encodeURIComponent(
|
`https://api.wotblitz.${server}/wotb/account/list/?application_id=${WARGAMING_APPLICATION_ID}&search=${encodeURIComponent(
|
||||||
trimmedSearch,
|
trimmedSearch,
|
||||||
)}&limit=${limit}`,
|
)}&limit=${limit}`,
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
import { SlashCommandBuilder } from 'discord.js';
|
import { SlashCommandBuilder } from 'discord.js';
|
||||||
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 { emblemIdToURL } from '../_core/blitzkrieg/emblemIdToURL';
|
||||||
import { StatFilters, filterStats } from '../_core/statistics/filterStats';
|
import { StatFilters, filterStats } from '../_core/statistics/filterStats';
|
||||||
import AllStatsOverview from '../components/AllStatsOverview';
|
import AllStatsOverview from '../components/AllStatsOverview';
|
||||||
import NoData, { NoDataType } from '../components/NoData';
|
import NoData, { NoDataType } from '../components/NoData';
|
||||||
import TitleBar from '../components/TitleBar';
|
import TitleBar from '../components/TitleBar';
|
||||||
import Wrapper from '../components/Wrapper';
|
import Wrapper from '../components/Wrapper';
|
||||||
import { getClanLogo } from '../core/blitz/getClanLogo';
|
|
||||||
import { filtersToDescription } from '../core/blitzkrieg/filtersToDescription';
|
import { filtersToDescription } from '../core/blitzkrieg/filtersToDescription';
|
||||||
import { getBlitzStarsLinkButton } from '../core/blitzstars/getBlitzStarsLinkButton';
|
import { getBlitzStarsLinkButton } from '../core/blitzstars/getBlitzStarsLinkButton';
|
||||||
import getDiffedTankStats from '../core/blitzstars/getDiffedTankStats';
|
import getDiffedTankStats from '../core/blitzstars/getDiffedTankStats';
|
||||||
@@ -36,7 +36,7 @@ async function render(
|
|||||||
) {
|
) {
|
||||||
const { nickname } = await getAccountInfo(region, id);
|
const { nickname } = await getAccountInfo(region, id);
|
||||||
const clan = (await getClanAccountInfo(region, id))?.clan;
|
const clan = (await getClanAccountInfo(region, id))?.clan;
|
||||||
const clanImage = clan ? getClanLogo(clan.emblem_set_id) : undefined;
|
const clanImage = clan ? emblemIdToURL(clan.emblem_set_id) : undefined;
|
||||||
const diffedTankStats = await getDiffedTankStats(region, id, start, end);
|
const diffedTankStats = await getDiffedTankStats(region, id, start, end);
|
||||||
const { stats, supplementary } = await filterStats(diffedTankStats, filters);
|
const { stats, supplementary } = await filterStats(diffedTankStats, filters);
|
||||||
const filterDescriptions = await filtersToDescription(filters);
|
const filterDescriptions = await filtersToDescription(filters);
|
||||||
|
|||||||
@@ -1,3 +0,0 @@
|
|||||||
export function getClanLogo(emblemId: number) {
|
|
||||||
return `https://wotblitz-gc.gcdn.co/icons/clanEmblems1x/clan-icon-v2-${emblemId}.png`
|
|
||||||
}
|
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
|
import fetchBlitz from '../../_core/blitz/fetchWargaming';
|
||||||
import { Region } from '../../constants/regions';
|
import { Region } from '../../constants/regions';
|
||||||
import { WARGAMING_APPLICATION_ID } from '../../constants/wargamingApplicationID';
|
import { WARGAMING_APPLICATION_ID } from '../../constants/wargamingApplicationID';
|
||||||
import { Clan, ClanList } from '../../types/clanList';
|
import { Clan, ClanList } from '../../types/clanList';
|
||||||
import getWargamingResponse from './getWargamingResponse';
|
|
||||||
|
|
||||||
export type ClanListWithRegion = (Clan & {
|
export type ClanListWithRegion = (Clan & {
|
||||||
region: 'com' | 'eu' | 'asia';
|
region: 'com' | 'eu' | 'asia';
|
||||||
@@ -14,7 +14,7 @@ export default async function listClans(search: string, limit = 9) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
getWargamingResponse<ClanList>(
|
fetchBlitz<ClanList>(
|
||||||
`https://api.wotblitz.com/wotb/clans/list/?application_id=${WARGAMING_APPLICATION_ID}&search=${search}&limit=${normalizedLimit}`,
|
`https://api.wotblitz.com/wotb/clans/list/?application_id=${WARGAMING_APPLICATION_ID}&search=${search}&limit=${normalizedLimit}`,
|
||||||
).then(
|
).then(
|
||||||
(value) =>
|
(value) =>
|
||||||
@@ -24,7 +24,7 @@ export default async function listClans(search: string, limit = 9) {
|
|||||||
region: 'com' as Region,
|
region: 'com' as Region,
|
||||||
})),
|
})),
|
||||||
),
|
),
|
||||||
getWargamingResponse<ClanList>(
|
fetchBlitz<ClanList>(
|
||||||
`https://api.wotblitz.eu/wotb/clans/list/?application_id=${WARGAMING_APPLICATION_ID}&search=${search}&limit=${normalizedLimit}`,
|
`https://api.wotblitz.eu/wotb/clans/list/?application_id=${WARGAMING_APPLICATION_ID}&search=${search}&limit=${normalizedLimit}`,
|
||||||
).then(
|
).then(
|
||||||
(value) =>
|
(value) =>
|
||||||
@@ -34,7 +34,7 @@ export default async function listClans(search: string, limit = 9) {
|
|||||||
region: 'eu' as Region,
|
region: 'eu' as Region,
|
||||||
})),
|
})),
|
||||||
),
|
),
|
||||||
getWargamingResponse<ClanList>(
|
fetchBlitz<ClanList>(
|
||||||
`https://api.wotblitz.asia/wotb/clans/list/?application_id=${WARGAMING_APPLICATION_ID}&search=${search}&limit=${normalizedLimit}`,
|
`https://api.wotblitz.asia/wotb/clans/list/?application_id=${WARGAMING_APPLICATION_ID}&search=${search}&limit=${normalizedLimit}`,
|
||||||
).then(
|
).then(
|
||||||
(value) =>
|
(value) =>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
|
import fetchBlitz from '../../_core/blitz/fetchWargaming';
|
||||||
import { Region } from '../../constants/regions';
|
import { Region } from '../../constants/regions';
|
||||||
import { WARGAMING_APPLICATION_ID } from '../../constants/wargamingApplicationID';
|
import { WARGAMING_APPLICATION_ID } from '../../constants/wargamingApplicationID';
|
||||||
import getWargamingResponse from './getWargamingResponse';
|
|
||||||
|
|
||||||
interface Account {
|
interface Account {
|
||||||
nickname: string;
|
nickname: string;
|
||||||
@@ -22,7 +22,7 @@ export default async function listPlayers(search: string, limit = 9) {
|
|||||||
if (usernamePattern.test(trimmedSearch)) {
|
if (usernamePattern.test(trimmedSearch)) {
|
||||||
return (
|
return (
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
getWargamingResponse<AccountList>(
|
fetchBlitz<AccountList>(
|
||||||
`https://api.wotblitz.com/wotb/account/list/?application_id=${WARGAMING_APPLICATION_ID}&search=${encodedSearch}&limit=${normalizedLimit}`,
|
`https://api.wotblitz.com/wotb/account/list/?application_id=${WARGAMING_APPLICATION_ID}&search=${encodedSearch}&limit=${normalizedLimit}`,
|
||||||
).then(
|
).then(
|
||||||
(value) =>
|
(value) =>
|
||||||
@@ -32,7 +32,7 @@ export default async function listPlayers(search: string, limit = 9) {
|
|||||||
region: 'com' as Region,
|
region: 'com' as Region,
|
||||||
})),
|
})),
|
||||||
),
|
),
|
||||||
getWargamingResponse<AccountList>(
|
fetchBlitz<AccountList>(
|
||||||
`https://api.wotblitz.eu/wotb/account/list/?application_id=${WARGAMING_APPLICATION_ID}&search=${encodedSearch}&limit=${normalizedLimit}`,
|
`https://api.wotblitz.eu/wotb/account/list/?application_id=${WARGAMING_APPLICATION_ID}&search=${encodedSearch}&limit=${normalizedLimit}`,
|
||||||
).then(
|
).then(
|
||||||
(value) =>
|
(value) =>
|
||||||
@@ -42,7 +42,7 @@ export default async function listPlayers(search: string, limit = 9) {
|
|||||||
region: 'eu' as Region,
|
region: 'eu' as Region,
|
||||||
})),
|
})),
|
||||||
),
|
),
|
||||||
getWargamingResponse<AccountList>(
|
fetchBlitz<AccountList>(
|
||||||
`https://api.wotblitz.asia/wotb/account/list/?application_id=${WARGAMING_APPLICATION_ID}&search=${encodedSearch}&limit=${normalizedLimit}`,
|
`https://api.wotblitz.asia/wotb/account/list/?application_id=${WARGAMING_APPLICATION_ID}&search=${encodedSearch}&limit=${normalizedLimit}`,
|
||||||
).then(
|
).then(
|
||||||
(value) =>
|
(value) =>
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import { deburr } from 'lodash';
|
import { deburr } from 'lodash';
|
||||||
|
import fetchBlitz from '../../_core/blitz/fetchWargaming';
|
||||||
|
import { TreeTypeString } from '../../components/Tanks';
|
||||||
import { WARGAMING_APPLICATION_ID } from '../../constants/wargamingApplicationID';
|
import { WARGAMING_APPLICATION_ID } from '../../constants/wargamingApplicationID';
|
||||||
import { context } from '../blitzkrieg/context';
|
import { context } from '../blitzkrieg/context';
|
||||||
import getWargamingResponse from './getWargamingResponse';
|
|
||||||
import { TreeTypeString } from '../../components/Tanks';
|
|
||||||
|
|
||||||
export interface TankopediaEntry {
|
export interface TankopediaEntry {
|
||||||
name: string;
|
name: string;
|
||||||
@@ -16,7 +16,7 @@ export interface TankopediaEntry {
|
|||||||
type: string;
|
type: string;
|
||||||
description: string;
|
description: string;
|
||||||
}
|
}
|
||||||
type asd = TreeTypeString
|
type asd = TreeTypeString;
|
||||||
export interface Tankopedia {
|
export interface Tankopedia {
|
||||||
[id: number]: TankopediaEntry | undefined;
|
[id: number]: TankopediaEntry | undefined;
|
||||||
}
|
}
|
||||||
@@ -71,7 +71,7 @@ export interface TankopediaInfo {
|
|||||||
|
|
||||||
// this is blocking because info is needed for command creation
|
// this is blocking because info is needed for command creation
|
||||||
console.log('Caching tankopedia info...');
|
console.log('Caching tankopedia info...');
|
||||||
export const tankopediaInfo = getWargamingResponse<TankopediaInfo>(
|
export const tankopediaInfo = fetchBlitz<TankopediaInfo>(
|
||||||
`https://api.wotblitz.com/wotb/encyclopedia/info/?application_id=${WARGAMING_APPLICATION_ID}`,
|
`https://api.wotblitz.com/wotb/encyclopedia/info/?application_id=${WARGAMING_APPLICATION_ID}`,
|
||||||
);
|
);
|
||||||
console.log('Cached tankopedia info');
|
console.log('Cached tankopedia info');
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import getTankStats from '../../_core/blitz/getTankStats';
|
||||||
import { Region } from '../../constants/regions';
|
import { Region } from '../../constants/regions';
|
||||||
import {
|
import {
|
||||||
GetHistoriesOptions,
|
GetHistoriesOptions,
|
||||||
@@ -5,7 +6,6 @@ import {
|
|||||||
History,
|
History,
|
||||||
getHistoriesDefaultOptions,
|
getHistoriesDefaultOptions,
|
||||||
} from '../../types/histories';
|
} from '../../types/histories';
|
||||||
import getTankStats from '../blitz/getTankStats';
|
|
||||||
import { emptyAllStats } from './getDiffedTankStats';
|
import { emptyAllStats } from './getDiffedTankStats';
|
||||||
|
|
||||||
export interface TankHistory extends History {
|
export interface TankHistory extends History {
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
import { AllStats, getAccountInfo } from '../_core/blitz/getAccountInfo';
|
import { AllStats, getAccountInfo } from '../_core/blitz/getAccountInfo';
|
||||||
import { getClanAccountInfo } from '../_core/blitz/getClanAccountInfo';
|
import { getClanAccountInfo } from '../_core/blitz/getClanAccountInfo';
|
||||||
|
import getTankStats from '../_core/blitz/getTankStats';
|
||||||
|
import getTreeType from '../_core/blitz/getTreeType';
|
||||||
import calculateWN8 from '../_core/statistics/calculateWN8';
|
import calculateWN8 from '../_core/statistics/calculateWN8';
|
||||||
import * as Breakdown from '../components/Breakdown';
|
import * as Breakdown from '../components/Breakdown';
|
||||||
import NoData, { NoDataType } from '../components/NoData';
|
import NoData, { NoDataType } from '../components/NoData';
|
||||||
import TitleBar from '../components/TitleBar';
|
import TitleBar from '../components/TitleBar';
|
||||||
import Wrapper from '../components/Wrapper';
|
import Wrapper from '../components/Wrapper';
|
||||||
import getTankStats from '../core/blitz/getTankStats';
|
|
||||||
import getTreeType from '../core/blitz/getTreeType';
|
|
||||||
import getWN8Percentile from '../core/blitz/getWN8Percentile';
|
import getWN8Percentile from '../core/blitz/getWN8Percentile';
|
||||||
import resolveTankName from '../core/blitz/resolveTankName';
|
import resolveTankName from '../core/blitz/resolveTankName';
|
||||||
import sumStats from '../core/blitz/sumStats';
|
import sumStats from '../core/blitz/sumStats';
|
||||||
|
|||||||
Reference in new issue
Block a user