mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-21 18:57:03 +02:00
fix: self core imports
This commit is contained in:
1 parent
1790443698
commit
03a51c47bb
31 files changed
+143
-136
No files matched your search
@@ -57,22 +57,24 @@
|
||||
"packages/core": {
|
||||
"name": "@blitzkit/core",
|
||||
"dependencies": {
|
||||
"@blitzkit/i18n": "workspace:*",
|
||||
"@bufbuild/protobuf": "^2.9.0",
|
||||
"@octokit/plugin-throttling": "^11.0.1",
|
||||
"@octokit/rest": "^22.0.0",
|
||||
"@prisma/client": "^6.16.2",
|
||||
"@types/adm-zip": "^0.5.7",
|
||||
"@types/lz4js": "^0.2.1",
|
||||
"@types/three": "^0.180.0",
|
||||
"adm-zip": "^0.5.16",
|
||||
"crc": "^4.3.2",
|
||||
"dotenv": "^17.2.2",
|
||||
"lz4js": "^0.2.0",
|
||||
"pickleparser": "^0.2.1",
|
||||
"protobufjs": "^7.5.4",
|
||||
"three": "^0.180.0",
|
||||
"ts-proto": "^2.7.7",
|
||||
"yaml": "^2.8.1",
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/adm-zip": "^0.5.7",
|
||||
"@types/lz4js": "^0.2.1",
|
||||
},
|
||||
},
|
||||
"packages/i18n": {
|
||||
"name": "@blitzkit/i18n",
|
||||
@@ -2741,8 +2743,6 @@
|
||||
|
||||
"@blitzkit/app/typescript": ["[email protected]", "", { "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" } }, "sha512-hjcS1mhfuyi4WW8IWtjP7brDrG2cuDZukyrYrSauoXGNgx0S7zceP07adYkJycEr56BOUTNPzbInooiN3fn1qw=="],
|
||||
|
||||
"@blitzkit/core/@prisma/client": ["@prisma/[email protected]", "", { "peerDependencies": { "prisma": "*", "typescript": ">=5.1.0" }, "optionalPeers": ["prisma", "typescript"] }, "sha512-E00PxBcalMfYO/TWnXobBVUai6eW/g5OsifWQsQDzJYm7yaY+IRLo7ZLsaefi0QkTpxfuhFcQ/w180i6kX3iJw=="],
|
||||
|
||||
"@discordjs/rest/@discordjs/collection": ["@discordjs/[email protected]", "", {}, "sha512-LiSusze9Tc7qF03sLCujF5iZp7K+vRNEDBZ86FT9aQAv3vxMLihUvKvpsCWiQ2DJq1tVckopKm1rxomgNUc9hg=="],
|
||||
|
||||
"@discordjs/rest/undici": ["[email protected]", "", {}, "sha512-gBLkYIlEnSp8pFbT64yFgGE6UIB9tAkhukC23PmMDCe5Nd+cRqKxSjw5y54MK2AZMgZfJWMaNE4nYUHgi1XEOw=="],
|
||||
|
||||
@@ -4,20 +4,22 @@
|
||||
"type": "module",
|
||||
"main": "src/index.ts",
|
||||
"dependencies": {
|
||||
"@blitzkit/i18n": "workspace:*",
|
||||
"@bufbuild/protobuf": "^2.9.0",
|
||||
"@octokit/plugin-throttling": "^11.0.1",
|
||||
"@octokit/rest": "^22.0.0",
|
||||
"@prisma/client": "^6.16.2",
|
||||
"@types/adm-zip": "^0.5.7",
|
||||
"@types/lz4js": "^0.2.1",
|
||||
"@types/three": "^0.180.0",
|
||||
"adm-zip": "^0.5.16",
|
||||
"crc": "^4.3.2",
|
||||
"dotenv": "^17.2.2",
|
||||
"lz4js": "^0.2.0",
|
||||
"pickleparser": "^0.2.1",
|
||||
"protobufjs": "^7.5.4",
|
||||
"three": "^0.180.0",
|
||||
"ts-proto": "^2.7.7",
|
||||
"yaml": "^2.8.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/adm-zip": "^0.5.7",
|
||||
"@types/lz4js": "^0.2.1"
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
import { type ShellDefinition, ShellType } from '@blitzkit/core';
|
||||
import { ShellDefinition, ShellType } from "../protos";
|
||||
|
||||
export function canSplash(type: ShellDefinition['type']): type is ShellType.HE {
|
||||
export function canSplash(type: ShellDefinition["type"]): type is ShellType.HE {
|
||||
return type === ShellType.HE;
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
import { BlitzStats, calculateWN8 } from '@blitzkit/core';
|
||||
import { BlitzStats, calculateWN8 } from "../statistics";
|
||||
|
||||
export type Stat = keyof ReturnType<typeof generateStats>;
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { fetchBlitz, Region } from '@blitzkit/core';
|
||||
import { normalizeIds } from './normalizeIds';
|
||||
import { fetchBlitz } from "./fetchBlitz";
|
||||
import { normalizeIds } from "./normalizeIds";
|
||||
import { Region } from "./regions";
|
||||
|
||||
interface IndividualAccountAchievements {
|
||||
achievements: {
|
||||
@@ -22,11 +23,11 @@ export async function getAccountAchievements<
|
||||
>(region: Region, ids: Ids) {
|
||||
const object = await fetchBlitz<AccountAchievements>(
|
||||
region,
|
||||
'account/achievements',
|
||||
{ account_id: normalizeIds(ids) },
|
||||
"account/achievements",
|
||||
{ account_id: normalizeIds(ids) }
|
||||
);
|
||||
|
||||
if (typeof ids === 'number') {
|
||||
if (typeof ids === "number") {
|
||||
return object[ids as number] as ReturnType;
|
||||
} else {
|
||||
return ids.map((id) => object[id]) as ReturnType;
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
import {
|
||||
BlitzStats,
|
||||
FetchBlitzParams,
|
||||
Region,
|
||||
fetchBlitz,
|
||||
} from '@blitzkit/core';
|
||||
import { normalizeIds } from './normalizeIds';
|
||||
import { BlitzStats } from "../statistics";
|
||||
import { FetchBlitzParams, fetchBlitz } from "./fetchBlitz";
|
||||
import { normalizeIds } from "./normalizeIds";
|
||||
import { Region } from "./regions";
|
||||
|
||||
export interface SupplementaryStats {
|
||||
WN8?: number;
|
||||
@@ -83,15 +80,15 @@ export async function getAccountInfo<
|
||||
region: Region,
|
||||
ids: Ids,
|
||||
extra: string[] = [],
|
||||
params: FetchBlitzParams = {},
|
||||
params: FetchBlitzParams = {}
|
||||
) {
|
||||
const object = await fetchBlitz<AccountInfo>(region, 'account/info', {
|
||||
const object = await fetchBlitz<AccountInfo>(region, "account/info", {
|
||||
account_id: normalizeIds(ids),
|
||||
extra: extra.length === 0 ? undefined : extra.join(','),
|
||||
extra: extra.length === 0 ? undefined : extra.join(","),
|
||||
...params,
|
||||
});
|
||||
|
||||
if (typeof ids === 'number') {
|
||||
if (typeof ids === "number") {
|
||||
return object[ids as number] as ReturnType;
|
||||
} else {
|
||||
return ids.map((id) => object[id]) as ReturnType;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { fetchBlitz, Region } from '@blitzkit/core';
|
||||
import { normalizeIds } from './normalizeIds';
|
||||
import { fetchBlitz } from "./fetchBlitz";
|
||||
import { normalizeIds } from "./normalizeIds";
|
||||
import { Region } from "./regions";
|
||||
|
||||
type IndividualClanAccountInfo = {
|
||||
account_id: number;
|
||||
@@ -30,14 +31,14 @@ export async function getClanAccountInfo<
|
||||
>(region: Region, ids: Ids, extra: string[] = []) {
|
||||
const object = await fetchBlitz<ClanAccountInfo>(
|
||||
region,
|
||||
'clans/accountinfo',
|
||||
"clans/accountinfo",
|
||||
{
|
||||
account_id: normalizeIds(ids),
|
||||
extra: extra.length === 0 ? undefined : extra.join(','),
|
||||
},
|
||||
extra: extra.length === 0 ? undefined : extra.join(","),
|
||||
}
|
||||
);
|
||||
|
||||
if (typeof ids === 'number') {
|
||||
if (typeof ids === "number") {
|
||||
return object[ids as number] as ReturnType;
|
||||
} else {
|
||||
return ids.map((id) => object[id]) as ReturnType;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { fetchBlitz, Region } from '@blitzkit/core';
|
||||
import { normalizeIds } from './normalizeIds';
|
||||
import { fetchBlitz } from "./fetchBlitz";
|
||||
import { normalizeIds } from "./normalizeIds";
|
||||
import { Region } from "./regions";
|
||||
|
||||
interface IndividualClanInfo {
|
||||
recruiting_options: {
|
||||
@@ -38,11 +39,11 @@ export async function getClanInfo<
|
||||
Ids extends number | number[],
|
||||
ReturnType = Ids extends number ? IndividualClanInfo : IndividualClanInfo[],
|
||||
>(region: Region, ids: Ids) {
|
||||
const object = await fetchBlitz<ClanInfo>(region, 'clans/info', {
|
||||
const object = await fetchBlitz<ClanInfo>(region, "clans/info", {
|
||||
clan_id: normalizeIds(ids),
|
||||
});
|
||||
|
||||
if (typeof ids === 'number') {
|
||||
if (typeof ids === "number") {
|
||||
return object[ids as number] as ReturnType;
|
||||
} else {
|
||||
return ids.map((id) => object[id]) as ReturnType;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { LEAGUES } from '@blitzkit/core';
|
||||
import { LEAGUES } from "./rating";
|
||||
|
||||
export function getLeagueFromScore(score: number) {
|
||||
return LEAGUES.find(({ minScore }) => score >= minScore)!;
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { RatingLeague, RatingReward, Region } from '@blitzkit/core';
|
||||
import { context } from '../blitzkit/context';
|
||||
import { patientFetch } from '../blitzkit/patientFetch';
|
||||
import { regionToRegionSubdomain } from './regionToRegionSubdomain';
|
||||
import { context } from "../blitzkit/context";
|
||||
import { patientFetch } from "../blitzkit/patientFetch";
|
||||
import { RatingLeague, RatingReward } from "./rating";
|
||||
import { Region } from "./regions";
|
||||
import { regionToRegionSubdomain } from "./regionToRegionSubdomain";
|
||||
|
||||
export type RatingInfo =
|
||||
| {
|
||||
@@ -26,12 +27,12 @@ export async function getRatingInfo(region: Region) {
|
||||
if (cache[region]) return cache[region]!;
|
||||
|
||||
const response = await patientFetch(
|
||||
context === 'website'
|
||||
context === "website"
|
||||
? `/api/${region}/rating/current/info`
|
||||
: `https://${regionToRegionSubdomain(
|
||||
region,
|
||||
region
|
||||
)}.wotblitz.com/en/api/rating-leaderboards/season/`,
|
||||
undefined,
|
||||
undefined
|
||||
);
|
||||
const data = (await response.json()) as RatingInfo;
|
||||
|
||||
|
||||
@@ -1,27 +1,29 @@
|
||||
import { LeagueTop, RatingPlayer, Region } from '@blitzkit/core';
|
||||
import { context } from '../blitzkit/context';
|
||||
import { patientFetch } from '../blitzkit/patientFetch';
|
||||
import { regionToRegionSubdomain } from './regionToRegionSubdomain';
|
||||
import { context } from "../blitzkit/context";
|
||||
import { patientFetch } from "../blitzkit/patientFetch";
|
||||
import { RatingPlayer } from "../statistics";
|
||||
import { LeagueTop } from "./rating";
|
||||
import { Region } from "./regions";
|
||||
import { regionToRegionSubdomain } from "./regionToRegionSubdomain";
|
||||
|
||||
export async function getRatingLeague(
|
||||
region: Region,
|
||||
league: number,
|
||||
usePatientFetcher = false,
|
||||
usePatientFetcher = false
|
||||
) {
|
||||
const fetcher = (url: string) =>
|
||||
usePatientFetcher
|
||||
? patientFetch(url, undefined, { cache: 'no-store' })
|
||||
: fetch(url, { cache: 'no-store' });
|
||||
? patientFetch(url, undefined, { cache: "no-store" })
|
||||
: fetch(url, { cache: "no-store" });
|
||||
const response = await fetcher(
|
||||
context === 'website'
|
||||
context === "website"
|
||||
? `/api/${region}/rating/current/league/${league}`
|
||||
: `https://${regionToRegionSubdomain(
|
||||
region,
|
||||
)}.wotblitz.com/en/api/rating-leaderboards/league/${league}/top/`,
|
||||
region
|
||||
)}.wotblitz.com/en/api/rating-leaderboards/league/${league}/top/`
|
||||
);
|
||||
const json = await response.json();
|
||||
|
||||
return context === 'website'
|
||||
return context === "website"
|
||||
? (json as RatingPlayer[])
|
||||
: (json as LeagueTop).result;
|
||||
}
|
||||
@@ -1,24 +1,25 @@
|
||||
import { RatingNeighbors, Region } from '@blitzkit/core';
|
||||
import { patientFetch } from '../blitzkit/patientFetch';
|
||||
import { withCORSProxy } from '../blitzkit/withCORSProxy';
|
||||
import { regionToRegionSubdomain } from './regionToRegionSubdomain';
|
||||
import { patientFetch } from "../blitzkit/patientFetch";
|
||||
import { withCORSProxy } from "../blitzkit/withCORSProxy";
|
||||
import { RatingNeighbors } from "./rating";
|
||||
import { Region } from "./regions";
|
||||
import { regionToRegionSubdomain } from "./regionToRegionSubdomain";
|
||||
|
||||
export async function getRatingNeighbors(
|
||||
region: Region,
|
||||
id: number,
|
||||
count: number,
|
||||
usePatientFetcher = false,
|
||||
usePatientFetcher = false
|
||||
) {
|
||||
const fetcher = (url: string) =>
|
||||
usePatientFetcher
|
||||
? patientFetch(url, undefined, { cache: 'no-store' })
|
||||
: fetch(url, { cache: 'no-store' });
|
||||
? patientFetch(url, undefined, { cache: "no-store" })
|
||||
: fetch(url, { cache: "no-store" });
|
||||
const response = await fetcher(
|
||||
withCORSProxy(
|
||||
`https://${regionToRegionSubdomain(
|
||||
region,
|
||||
)}.wotblitz.com/en/api/rating-leaderboards/user/${id}/?neighbors=${count}`,
|
||||
),
|
||||
region
|
||||
)}.wotblitz.com/en/api/rating-leaderboards/user/${id}/?neighbors=${count}`
|
||||
)
|
||||
);
|
||||
const json = (await response.json()) as RatingNeighbors;
|
||||
|
||||
|
||||
@@ -1,16 +1,13 @@
|
||||
import {
|
||||
fetchBlitz,
|
||||
FetchBlitzParams,
|
||||
Region,
|
||||
TanksStats,
|
||||
} from '@blitzkit/core';
|
||||
import { TanksStats } from "../types";
|
||||
import { FetchBlitzParams, fetchBlitz } from "./fetchBlitz";
|
||||
import { Region } from "./regions";
|
||||
|
||||
export async function getTankStats(
|
||||
region: Region,
|
||||
id: number,
|
||||
params?: FetchBlitzParams,
|
||||
params?: FetchBlitzParams
|
||||
) {
|
||||
const tankStats = await fetchBlitz<TanksStats>(region, 'tanks/stats', {
|
||||
const tankStats = await fetchBlitz<TanksStats>(region, "tanks/stats", {
|
||||
account_id: id,
|
||||
...params,
|
||||
});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { getRatingInfo } from '@blitzkit/core';
|
||||
import { getRatingInfo } from "./getRatingInfo";
|
||||
|
||||
export async function isOnGoingRatingSeason() {
|
||||
const ratingInfo = await getRatingInfo('com');
|
||||
const ratingInfo = await getRatingInfo("com");
|
||||
return ratingInfo.detail === undefined;
|
||||
}
|
||||
@@ -1,4 +1,6 @@
|
||||
import { Region, assertSecret, idToRegion } from '@blitzkit/core';
|
||||
import { assertSecret } from "../blitzkit";
|
||||
import { idToRegion } from "./idToRegion";
|
||||
import { Region } from "./regions";
|
||||
|
||||
export async function isValidBlitzId(id: number, token?: string) {
|
||||
let region: Region;
|
||||
@@ -11,20 +13,20 @@ export async function isValidBlitzId(id: number, token?: string) {
|
||||
|
||||
const json = await fetch(
|
||||
`https://api.wotblitz.${region}/wotb/account/info/?account_id=${id}&application_id=${assertSecret(
|
||||
import.meta.env.PUBLIC_WARGAMING_APPLICATION_ID,
|
||||
import.meta.env.PUBLIC_WARGAMING_APPLICATION_ID
|
||||
)}${
|
||||
token === undefined ? '' : `&access_token=${token}`
|
||||
}&fields=account_id%2C-account_id`,
|
||||
token === undefined ? "" : `&access_token=${token}`
|
||||
}&fields=account_id%2C-account_id`
|
||||
).then(
|
||||
(response) =>
|
||||
response.json() as Promise<
|
||||
| {
|
||||
status: 'ok';
|
||||
status: "ok";
|
||||
data: Record<number, {} | null>;
|
||||
}
|
||||
| { status: 'error' }
|
||||
>,
|
||||
| { status: "error" }
|
||||
>
|
||||
);
|
||||
|
||||
return json.status === 'ok' && json.data[id] !== null;
|
||||
return json.status === "ok" && json.data[id] !== null;
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Region, RegionSubdomain } from '@blitzkit/core';
|
||||
import { Region, RegionSubdomain } from "./regions";
|
||||
|
||||
export function regionSubdomainToRegion(regionDomain: RegionSubdomain): Region {
|
||||
return regionDomain === 'na' ? 'com' : regionDomain;
|
||||
return regionDomain === "na" ? "com" : regionDomain;
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Region, RegionSubdomain } from '@blitzkit/core';
|
||||
import { Region, RegionSubdomain } from "./regions";
|
||||
|
||||
export function regionToRegionSubdomain(regionDomain: Region): RegionSubdomain {
|
||||
return regionDomain === 'com' ? 'na' : regionDomain;
|
||||
return regionDomain === "com" ? "na" : regionDomain;
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
import { fetchBlitz, Region } from '@blitzkit/core';
|
||||
import { ClanList } from './clans';
|
||||
import { ClanList } from "./clans";
|
||||
import { fetchBlitz } from "./fetchBlitz";
|
||||
import { Region } from "./regions";
|
||||
|
||||
export async function searchClansAcrossRegions(search: string, limit = 25) {
|
||||
const trimmed = search.trim();
|
||||
@@ -10,38 +11,38 @@ export async function searchClansAcrossRegions(search: string, limit = 25) {
|
||||
|
||||
return (
|
||||
await Promise.all([
|
||||
fetchBlitz<ClanList>('com', 'clans/list', {
|
||||
fetchBlitz<ClanList>("com", "clans/list", {
|
||||
search,
|
||||
limit: normalizedLimit,
|
||||
}).then((value) =>
|
||||
value
|
||||
.map((account) => ({
|
||||
...account,
|
||||
region: 'com' as Region,
|
||||
region: "com" as Region,
|
||||
}))
|
||||
.splice(0, normalizedLimit),
|
||||
.splice(0, normalizedLimit)
|
||||
),
|
||||
fetchBlitz<ClanList>('eu', 'clans/list', {
|
||||
fetchBlitz<ClanList>("eu", "clans/list", {
|
||||
search,
|
||||
limit: normalizedLimit,
|
||||
}).then((value) =>
|
||||
value
|
||||
.map((account) => ({
|
||||
...account,
|
||||
region: 'eu' as Region,
|
||||
region: "eu" as Region,
|
||||
}))
|
||||
.splice(0, normalizedLimit),
|
||||
.splice(0, normalizedLimit)
|
||||
),
|
||||
fetchBlitz<ClanList>('asia', 'clans/list', {
|
||||
fetchBlitz<ClanList>("asia", "clans/list", {
|
||||
search,
|
||||
limit: normalizedLimit,
|
||||
}).then((value) =>
|
||||
value
|
||||
.map((account) => ({
|
||||
...account,
|
||||
region: 'asia' as Region,
|
||||
region: "asia" as Region,
|
||||
}))
|
||||
.splice(0, normalizedLimit),
|
||||
.splice(0, normalizedLimit)
|
||||
),
|
||||
])
|
||||
)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Region } from '@blitzkit/core';
|
||||
import { context } from '../blitzkit/context';
|
||||
import { regionToRegionSubdomain } from './regionToRegionSubdomain';
|
||||
import { context } from "../blitzkit/context";
|
||||
import { Region } from "./regions";
|
||||
import { regionToRegionSubdomain } from "./regionToRegionSubdomain";
|
||||
|
||||
type CurrentRatingPlayerSearch = Record<
|
||||
number,
|
||||
@@ -27,12 +27,12 @@ type CurrentRatingPlayerSearch = Record<
|
||||
export async function searchCurrentRatingPlayers(region: Region, name: string) {
|
||||
const encodedSearch = encodeURIComponent(name);
|
||||
const response = await fetch(
|
||||
context === 'website'
|
||||
context === "website"
|
||||
? `/api/${region}/rating/current/search/${encodedSearch}`
|
||||
: `https://${regionToRegionSubdomain(
|
||||
region,
|
||||
region
|
||||
)}.wotblitz.com/en/api/rating-leaderboards/search/?prefix=${encodedSearch}`,
|
||||
{ cache: 'no-store' },
|
||||
{ cache: "no-store" }
|
||||
);
|
||||
const accountList = (await response.json()) as CurrentRatingPlayerSearch;
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { fetchBlitz, Region } from '@blitzkit/core';
|
||||
import { fetchBlitz } from '../fetchBlitz';
|
||||
import { Region } from '../regions';
|
||||
import { usernamePattern } from './constants';
|
||||
|
||||
export interface AccountListItem {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { NATION_IDS } from "@blitzkit/core";
|
||||
import { NATION_IDS } from "./nations";
|
||||
|
||||
export function toUniqueId(nation: string, id: number) {
|
||||
return (id << 8) + (NATION_IDS[nation] << 4) + 1;
|
||||
|
||||
@@ -1,16 +1,12 @@
|
||||
import {
|
||||
GunDefinition,
|
||||
ProvisionDefinitions,
|
||||
TankDefinition,
|
||||
} from '@blitzkit/core';
|
||||
import { checkConsumableProvisionInclusivity } from './checkConsumableProvisionInclusivity';
|
||||
import { GunDefinition, ProvisionDefinitions, TankDefinition } from "../protos";
|
||||
import { checkConsumableProvisionInclusivity } from "./checkConsumableProvisionInclusivity";
|
||||
|
||||
export function availableProvisions(
|
||||
tank: TankDefinition,
|
||||
gun: GunDefinition,
|
||||
provisionDefinitions: ProvisionDefinitions,
|
||||
provisionDefinitions: ProvisionDefinitions
|
||||
) {
|
||||
return Object.values(provisionDefinitions.provisions).filter((provision) =>
|
||||
checkConsumableProvisionInclusivity(provision, tank, gun),
|
||||
checkConsumableProvisionInclusivity(provision, tank, gun)
|
||||
);
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
import { SkillDefinitions } from '@blitzkit/core';
|
||||
import { permanentSkills } from '../blitz/permanentSkills';
|
||||
import { SkillDefinitions } from "..";
|
||||
import { permanentSkills } from "../blitz/permanentSkills";
|
||||
|
||||
export function createDefaultSkills(skillDefinitions: SkillDefinitions) {
|
||||
const skills: Record<string, number> = {};
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { assertSecret, getRatingInfo } from '@blitzkit/core';
|
||||
import { getRatingInfo } from "../blitz/getRatingInfo";
|
||||
import { assertSecret } from "./assertSecret";
|
||||
|
||||
interface GitHubTrees {
|
||||
tree: { path: string; url: string }[];
|
||||
@@ -11,21 +12,21 @@ export async function getArchivedLatestSeasonNumber() {
|
||||
return cachedLatestArchivedSeasonNumber;
|
||||
}
|
||||
|
||||
const ratingInfo = await getRatingInfo('com');
|
||||
const ratingInfo = await getRatingInfo("com");
|
||||
|
||||
if (ratingInfo.detail) {
|
||||
const regionsURL = (
|
||||
(await fetch(
|
||||
`https://api.github.com/repos/tresabhi/${assertSecret(
|
||||
import.meta.env.PUBLIC_ASSET_REPO,
|
||||
)}/git/trees/main`,
|
||||
import.meta.env.PUBLIC_ASSET_REPO
|
||||
)}/git/trees/main`
|
||||
).then((response) => response.json())) as GitHubTrees
|
||||
).tree.find(({ path }) => path === 'regions')!.url;
|
||||
).tree.find(({ path }) => path === "regions")!.url;
|
||||
const comURL = (
|
||||
(await fetch(regionsURL).then((response) =>
|
||||
response.json(),
|
||||
response.json()
|
||||
)) as GitHubTrees
|
||||
).tree.find(({ path }) => path === 'com')!.url;
|
||||
).tree.find(({ path }) => path === "com")!.url;
|
||||
const ratingURL = (
|
||||
(await fetch(comURL).then((response) => response.json())) as {
|
||||
tree: [{ url: string }];
|
||||
@@ -36,7 +37,7 @@ export async function getArchivedLatestSeasonNumber() {
|
||||
(await fetch(ratingURL).then((response) => response.json())) as {
|
||||
tree: { path: string }[];
|
||||
}
|
||||
).tree.map(({ path }) => Number(path)),
|
||||
).tree.map(({ path }) => Number(path))
|
||||
);
|
||||
|
||||
cachedLatestArchivedSeasonNumber = latestSeason;
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import { asset, RatingLeaderboard, Region } from '@blitzkit/core';
|
||||
import { Region } from "../blitz/regions";
|
||||
import { RatingLeaderboard } from "../protos";
|
||||
import { asset } from "./asset";
|
||||
|
||||
const cache: Record<Region, Record<number, RatingLeaderboard>> = {
|
||||
asia: {},
|
||||
@@ -8,7 +10,7 @@ const cache: Record<Region, Record<number, RatingLeaderboard>> = {
|
||||
|
||||
export async function getArchivedRatingLeaderboard(
|
||||
region: Region,
|
||||
season: number,
|
||||
season: number
|
||||
) {
|
||||
if (!cache[region][season]) {
|
||||
const info = await fetch(asset(`regions/${region}/rating/${season}.pb`))
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Region } from '@blitzkit/core';
|
||||
import { Region } from "../blitz/regions";
|
||||
|
||||
const TIME_ZONE_MAPPINGS: Record<Region, number> = {
|
||||
com: -5, // Central North American Time
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { ShellDefinition, ShellType } from '@blitzkit/core';
|
||||
import { ShellDefinition, ShellType } from "../protos";
|
||||
|
||||
export function isExplosive(
|
||||
type: ShellDefinition['type'],
|
||||
type: ShellDefinition["type"]
|
||||
): type is ShellType.HEAT | ShellType.HE {
|
||||
return type === ShellType.HEAT || type === ShellType.HE;
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
import { BoundingBox, Vector3 } from '@blitzkit/core';
|
||||
import { Vector3 } from "three";
|
||||
import { BoundingBox } from "../protos";
|
||||
|
||||
export function normalizeBoundingBox(boundingBox: BoundingBox) {
|
||||
return {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { BKNI_COLORS, BkniPercentile, getBkniPercentile } from '@blitzkit/core';
|
||||
import { BKNI_COLORS, BkniPercentile, getBkniPercentile } from "../statistics";
|
||||
|
||||
export function parseBkni(bkni: number) {
|
||||
const bkniFraction = (bkni + 1) / 2;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { asset } from "@blitzkit/core";
|
||||
import { asset } from "./asset";
|
||||
|
||||
export const BLITZKIT_TANK_ICON_SIZE = { width: 40 * 16, height: 30 * 16 };
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { BoundingBox } from '@blitzkit/core';
|
||||
import { BoundingBox } from "../protos";
|
||||
|
||||
export function unionBoundingBox(a: BoundingBox, b: BoundingBox) {
|
||||
return {
|
||||
|
||||
Reference in new issue
Block a user