mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-21 10:47:04 +02:00
fix: no cross-bot imports
This commit is contained in:
1 parent
6c0b46725d
commit
7c6f381bbe
58 files changed
+233
-252
No files matched your search
@@ -0,0 +1,9 @@
|
||||
export interface Clan {
|
||||
members_count: number;
|
||||
created_at: number;
|
||||
clan_id: number;
|
||||
tag: string;
|
||||
name: string;
|
||||
}
|
||||
|
||||
export type ClanList = Clan[];
|
||||
@@ -1,9 +1,10 @@
|
||||
export * from './clans';
|
||||
export * from './constants';
|
||||
export * from './equipmentPrice';
|
||||
export * from './idToRegion';
|
||||
export * from './leagues';
|
||||
export * from './nations';
|
||||
export * from './permanentSkills';
|
||||
export * from './rating';
|
||||
export * from './regions';
|
||||
export * from './resolveNearPenetration';
|
||||
export * from './searchClansAcrossRegions';
|
||||
@@ -1,7 +0,0 @@
|
||||
export const LEAGUES = [
|
||||
{ name: 'diamond', minScore: 5000, index: 0 },
|
||||
{ name: 'platinum', minScore: 4000, index: 1 },
|
||||
{ name: 'gold', minScore: 3000, index: 2 },
|
||||
{ name: 'silver', minScore: 2000, index: 3 },
|
||||
{ name: 'bronze', minScore: -Infinity, index: 4 },
|
||||
];
|
||||
@@ -1,2 +1,79 @@
|
||||
export const FIRST_MINIMAL_ARCHIVED_RATING_SEASON = 49;
|
||||
import { RatingPlayer } from '../statistics';
|
||||
|
||||
export const LEAGUES = [
|
||||
{ name: 'diamond', minScore: 5000, index: 0 },
|
||||
{ name: 'platinum', minScore: 4000, index: 1 },
|
||||
{ name: 'gold', minScore: 3000, index: 2 },
|
||||
{ name: 'silver', minScore: 2000, index: 3 },
|
||||
{ name: 'bronze', minScore: -Infinity, index: 4 },
|
||||
];
|
||||
export type RatingInfo =
|
||||
| {
|
||||
detail: undefined;
|
||||
|
||||
title: string;
|
||||
icon: string | null;
|
||||
start_at: string;
|
||||
finish_at: string;
|
||||
current_season: number;
|
||||
updated_at: string;
|
||||
count: number;
|
||||
|
||||
rewards: RatingReward[];
|
||||
leagues: RatingLeague[];
|
||||
}
|
||||
| { detail: { error: string } };
|
||||
export interface RatingNeighbors {
|
||||
neighbors: RatingPlayer[];
|
||||
}
|
||||
export const FIRST_COMPREHENSIVE1_ARCHIVED_RATING_SEASON = 53;
|
||||
export const FIRST_MINIMAL_ARCHIVED_RATING_SEASON = 49;
|
||||
export interface LeagueTop {
|
||||
result: RatingPlayer[];
|
||||
}
|
||||
export interface RatingLeague {
|
||||
title: string;
|
||||
small_icon: string;
|
||||
big_icon: string;
|
||||
background: string;
|
||||
index: number;
|
||||
percentile: number;
|
||||
}
|
||||
export type RatingReward = {
|
||||
from_position: number;
|
||||
to_position: number;
|
||||
count: number;
|
||||
} & (
|
||||
| {
|
||||
type: 'vehicle';
|
||||
|
||||
vehicle: {
|
||||
id: number;
|
||||
name: string;
|
||||
nation: string;
|
||||
subnation: string;
|
||||
use_subnation_flag: boolean;
|
||||
type_slug: string;
|
||||
level: number;
|
||||
roman_level: string;
|
||||
user_string: string;
|
||||
image_url: string;
|
||||
preview_image_url: string;
|
||||
is_premium: boolean;
|
||||
is_collectible: boolean;
|
||||
};
|
||||
}
|
||||
| {
|
||||
type: 'stuff';
|
||||
|
||||
stuff: {
|
||||
name: string;
|
||||
count: number;
|
||||
title: string;
|
||||
image_url: string;
|
||||
type: string;
|
||||
|
||||
sizes: {};
|
||||
};
|
||||
}
|
||||
);
|
||||
@@ -0,0 +1,54 @@
|
||||
import { Region } from '@blitzkit/core';
|
||||
import fetchBlitz from '../../../website/src/core/blitz/fetchBlitz';
|
||||
import { ClanList } from './clans';
|
||||
|
||||
export default async function searchClansAcrossRegions(
|
||||
search: string,
|
||||
limit = 25,
|
||||
) {
|
||||
const trimmed = search.trim();
|
||||
if (trimmed.length < 3 && trimmed.length > 100) return [];
|
||||
const normalizedLimit = Math.floor(limit / 3);
|
||||
|
||||
// TODO: remove splice once wargaming fixes the functionality of the limit felid
|
||||
|
||||
return (
|
||||
await Promise.all([
|
||||
fetchBlitz<ClanList>('com', 'clans/list', {
|
||||
search,
|
||||
limit: normalizedLimit,
|
||||
}).then((value) =>
|
||||
value
|
||||
.map((account) => ({
|
||||
...account,
|
||||
region: 'com' as Region,
|
||||
}))
|
||||
.splice(0, normalizedLimit),
|
||||
),
|
||||
fetchBlitz<ClanList>('eu', 'clans/list', {
|
||||
search,
|
||||
limit: normalizedLimit,
|
||||
}).then((value) =>
|
||||
value
|
||||
.map((account) => ({
|
||||
...account,
|
||||
region: 'eu' as Region,
|
||||
}))
|
||||
.splice(0, normalizedLimit),
|
||||
),
|
||||
fetchBlitz<ClanList>('asia', 'clans/list', {
|
||||
search,
|
||||
limit: normalizedLimit,
|
||||
}).then((value) =>
|
||||
value
|
||||
.map((account) => ({
|
||||
...account,
|
||||
region: 'asia' as Region,
|
||||
}))
|
||||
.splice(0, normalizedLimit),
|
||||
),
|
||||
])
|
||||
)
|
||||
.filter(Boolean)
|
||||
.flat();
|
||||
}
|
||||
@@ -1,4 +1,11 @@
|
||||
import { CrewMember, GunDefinition, ShellType, TankClass, Tier } from '.';
|
||||
import {
|
||||
CrewMember,
|
||||
GunDefinition,
|
||||
ShellType,
|
||||
TankClass,
|
||||
Tier,
|
||||
TreeType,
|
||||
} from '.';
|
||||
|
||||
export const SHELL_NAMES: Record<ShellType, string> = {
|
||||
ap: 'AP',
|
||||
@@ -70,3 +77,8 @@ export const flags: Record<string, string> = {
|
||||
european: '🇪🇺',
|
||||
other: '<:other:1218421572243558482>',
|
||||
};
|
||||
export const TREE_TYPE_ICONS: Record<TreeType, Record<TankClass, string>> = {
|
||||
researchable: TANK_ICONS,
|
||||
premium: TANK_ICONS_PREMIUM,
|
||||
collector: TANK_ICONS_COLLECTOR,
|
||||
};
|
||||
@@ -0,0 +1 @@
|
||||
export * from './tankAverages';
|
||||
@@ -0,0 +1,105 @@
|
||||
import { BlitzStats, tankDefinitions } from '@blitzkit/core';
|
||||
import { context } from '../../../website/src/core/blitzkit/context';
|
||||
|
||||
interface SpecialStats {
|
||||
winrate: number;
|
||||
damageRatio: number;
|
||||
kdr: number;
|
||||
damagePerBattle: number;
|
||||
killsPerBattle: number;
|
||||
hitsPerBattle: number;
|
||||
spotsPerBattle: number;
|
||||
wpm: number;
|
||||
dpm: number;
|
||||
kpm: number;
|
||||
hitRate: number;
|
||||
survivalRate: number;
|
||||
}
|
||||
|
||||
export type Percentiles = [
|
||||
number,
|
||||
number,
|
||||
number,
|
||||
number,
|
||||
number,
|
||||
number,
|
||||
number,
|
||||
number,
|
||||
number,
|
||||
];
|
||||
|
||||
export interface SpecialPercentiles {
|
||||
winRate: Percentiles;
|
||||
damageRatio: Percentiles;
|
||||
kdr: Percentiles;
|
||||
damagePerBattle: Percentiles;
|
||||
killsPerBattle: Percentiles;
|
||||
hitsPerBattle: Percentiles;
|
||||
spotsPerBattle: Percentiles;
|
||||
wpm: Percentiles;
|
||||
dpm: Percentiles;
|
||||
kpm: Percentiles;
|
||||
hitRate: Percentiles;
|
||||
survivalRate: Percentiles;
|
||||
}
|
||||
|
||||
export interface MeanSd {
|
||||
winrateMean: number;
|
||||
winrateSd: number;
|
||||
hitRateMean: number;
|
||||
hitRateSd: number;
|
||||
survivalRateMean: number;
|
||||
survivalRateSd: number;
|
||||
damageRatioMean: number;
|
||||
damageRatioSd: number;
|
||||
kdrMean: number;
|
||||
kdrSd: number;
|
||||
dpbMean: number;
|
||||
dpbSd: number;
|
||||
kpbMean: number;
|
||||
kpbSd: number;
|
||||
hpbMean: number;
|
||||
hpbSd: number;
|
||||
spbMean: number;
|
||||
spbSd: number;
|
||||
}
|
||||
|
||||
export interface IndividualTankAverage {
|
||||
_id: number;
|
||||
battle_life_time: number;
|
||||
total_battle_life_time: number;
|
||||
number_of_players: number;
|
||||
tank_id: number;
|
||||
all: BlitzStats;
|
||||
special: SpecialStats;
|
||||
percentiles: SpecialPercentiles;
|
||||
percentiles_player_count: number;
|
||||
meanSd: MeanSd;
|
||||
shotEff: number;
|
||||
last_update: number;
|
||||
}
|
||||
|
||||
tankDefinitions;
|
||||
|
||||
export type BlitzStarsTankAverages = Record<number, IndividualTankAverage>;
|
||||
|
||||
export const blitzStarsTankAverages = fetch(
|
||||
context === 'website'
|
||||
? '/api/tank-averages'
|
||||
: 'https://www.blitzstars.com/api/tankaverages.json',
|
||||
)
|
||||
.then((response) => response.json())
|
||||
.then((json) => {
|
||||
if (context === 'server') {
|
||||
const partialTankAverages: BlitzStarsTankAverages = {};
|
||||
|
||||
(json as IndividualTankAverage[]).forEach((individualTankAverage) => {
|
||||
partialTankAverages[individualTankAverage.tank_id] =
|
||||
individualTankAverage;
|
||||
});
|
||||
|
||||
return partialTankAverages;
|
||||
} else {
|
||||
return json as BlitzStarsTankAverages;
|
||||
}
|
||||
});
|
||||
@@ -1,5 +1,6 @@
|
||||
export * from './blitz';
|
||||
export * from './blitzkit';
|
||||
export * from './blitzstars';
|
||||
export * from './databases';
|
||||
export * from './imgur';
|
||||
export * from './math';
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
type Name =
|
||||
| `color-${'background' | `panel-${'solid' | 'translucent'}` | 'surface' | 'overlay'}`
|
||||
| `radius-${1 | 2 | 3 | 4 | 5 | 6 | 'full'}`
|
||||
| `space-${1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9}`;
|
||||
| `space-${1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9}`
|
||||
| string;
|
||||
|
||||
export function Var(name: Name) {
|
||||
return `var(--${name})`;
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { RatingPlayer } from '../../../bot/src/commands/ratingLeaderboard';
|
||||
import { RatingStats } from '../../../website/src/core/blitz/getAccountInfo';
|
||||
import { BkrlSuperset1Entry } from '../streams/bkrl';
|
||||
|
||||
@@ -16,3 +15,16 @@ export function deltaBkrlBlitzStats(
|
||||
score: b2.score - a.score,
|
||||
} satisfies Omit<BkrlSuperset1Entry, 'id'>;
|
||||
}
|
||||
export interface RatingPlayer {
|
||||
spa_id: number;
|
||||
mmr: number;
|
||||
season_number: number;
|
||||
calibrationBattlesLeft: number;
|
||||
number: number;
|
||||
percentile: number;
|
||||
skip: boolean;
|
||||
updated_at: string;
|
||||
score: number;
|
||||
nickname: string;
|
||||
clan_tag: string;
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
import { DiffedTankStats } from '../../../bot/src/core/blitzstars/getStatsInPeriod';
|
||||
import { SupplementaryStats } from '../../../website/src/core/blitz/getAccountInfo';
|
||||
import { tankAverages } from '../../../website/src/core/blitzstars/tankAverages';
|
||||
import { tankDefinitions, TreeType } from '../blitzkit/tankDefinitions';
|
||||
import { blitzStarsTankAverages } from '../blitzstars/tankAverages';
|
||||
import calculateWN8 from './calculateWN8';
|
||||
import { BlitzStats } from './compositeStats';
|
||||
import sumStats from './sumStats';
|
||||
|
||||
export interface StatFilters {
|
||||
@@ -21,7 +21,7 @@ export async function filterStats(
|
||||
if (filters.tank) filters = { tank: filters.tank };
|
||||
|
||||
const awaitedTankDefinitions = await tankDefinitions;
|
||||
const awaitedTankAverages = await tankAverages;
|
||||
const awaitedTankAverages = await blitzStarsTankAverages;
|
||||
const filteredOrder = order.filter((id) => {
|
||||
const entry = awaitedTankDefinitions[id];
|
||||
|
||||
@@ -72,3 +72,8 @@ export async function filterStats(
|
||||
|
||||
return { stats, supplementary, filteredOrder };
|
||||
}
|
||||
|
||||
export interface DiffedTankStats {
|
||||
diff: Record<number, BlitzStats>;
|
||||
order: number[];
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
import { TierWeightsRecord } from '../../../bot/src/components/TierWeights';
|
||||
import { tankDefinitions } from '../blitzkit/tankDefinitions';
|
||||
import { tankDefinitions, Tier } from '../blitzkit/tankDefinitions';
|
||||
import { BlitzStats } from './compositeStats/constants';
|
||||
|
||||
export async function getTierWeights(
|
||||
@@ -20,3 +19,4 @@ export async function getTierWeights(
|
||||
|
||||
return tierWeights;
|
||||
}
|
||||
export type TierWeightsRecord = Partial<Record<Tier, number>>;
|
||||
Vendored
-4
@@ -1,4 +0,0 @@
|
||||
declare module '*.proto' {
|
||||
const value: string;
|
||||
export default value;
|
||||
}
|
||||
Reference in new issue
Block a user