mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-23 11:39:50 +02:00
feat: organize files
This commit is contained in:
1 parent
f02fb00e8c
commit
f79f1ffdc3
102 files changed
+486
-502
No files matched your search
@@ -1,9 +1,6 @@
|
||||
import { degToRad } from 'three/src/math/MathUtils';
|
||||
import {
|
||||
DuelMember,
|
||||
genericDefaultEquipmentMatrix,
|
||||
mutateDuel,
|
||||
} from '../../stores/duel';
|
||||
import { DuelMember, mutateDuel } from '../../stores/duel';
|
||||
import { genericDefaultEquipmentMatrix } from '../../stores/duel/constants';
|
||||
import { availableProvisions } from './availableProvisions';
|
||||
import { modelDefinitions } from './modelDefinitions';
|
||||
import { provisionDefinitions } from './provisionDefinitions';
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
import { PrismaClient } from '@prisma/client';
|
||||
import { Region } from '../../constants/regions';
|
||||
|
||||
export const discordBlitzDB = new PrismaClient();
|
||||
import { discordBlitzDB } from './discordBlitzDB';
|
||||
|
||||
export function linkBlitzAndDiscord(
|
||||
discord: number,
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
import { PrismaClient } from '@prisma/client';
|
||||
|
||||
export const discordBlitzDB = new PrismaClient();
|
||||
@@ -1,7 +1,8 @@
|
||||
import { Locale } from 'discord.js';
|
||||
import { translator } from '../localization/translator';
|
||||
import { StatFilters } from '../statistics/filterStats';
|
||||
import { TIER_ROMAN_NUMERALS, Tier, tankDefinitions } from './tankDefinitions';
|
||||
import { Tier, tankDefinitions } from './tankDefinitions';
|
||||
import { TIER_ROMAN_NUMERALS } from './tankDefinitions/constants';
|
||||
|
||||
export async function filtersToDescription(
|
||||
{ nation, tier, tankType, treeType, tank }: StatFilters,
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
import { BlitzkriegRatingsLeaderboard } from '../../../scripts/buildRatingsLeaderboard';
|
||||
import { Region } from '../../constants/regions';
|
||||
|
||||
export const DATABASE_REPO = { owner: 'tresabhi', repo: 'blitzkrieg-assets' };
|
||||
|
||||
const MIDNIGHT_LEADERBOARD_CACHE: Record<
|
||||
Region,
|
||||
Record<number, BlitzkriegRatingsLeaderboard>
|
||||
|
||||
@@ -7,7 +7,7 @@ import {
|
||||
getHistoriesDefaultOptions,
|
||||
} from '../../types/histories';
|
||||
import getTankStats from '../blitz/getTankStats';
|
||||
import { emptyAllStats } from '../blitzstars/getStatsInPeriod';
|
||||
import { emptyAllStats } from '../blitzstars/getStatsInPeriod/constants';
|
||||
|
||||
export interface TankHistory extends History {
|
||||
tank_id: number;
|
||||
@@ -27,7 +27,7 @@ export interface GetTankHistoriesOptions extends GetHistoriesOptions {
|
||||
tankId?: number;
|
||||
}
|
||||
|
||||
export const getTankHistoriesDefaultOptions: GetTankHistoriesOptions = {
|
||||
const getTankHistoriesDefaultOptions: GetTankHistoriesOptions = {
|
||||
...getHistoriesDefaultOptions,
|
||||
tankId: undefined,
|
||||
};
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Region } from '../../constants/regions';
|
||||
|
||||
export const TIME_ZONE_MAPPINGS: Record<Region, number> = {
|
||||
const TIME_ZONE_MAPPINGS: Record<Region, number> = {
|
||||
com: -5, // Central North American Time
|
||||
eu: +1, // Central European Time
|
||||
asia: +7, // Central Asia Standard Time
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { client } from '../discord/client';
|
||||
import { discordBlitzDB } from './discordBlitz';
|
||||
import { discordBlitzDB } from './discordBlitzDB';
|
||||
|
||||
const EXIT_EVENTS = [
|
||||
'beforeExit',
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
export enum TextureMutation {
|
||||
Normal,
|
||||
RoughnessMetallicness,
|
||||
BaseColor,
|
||||
Miscellaneous,
|
||||
}
|
||||
@@ -1,16 +1,10 @@
|
||||
import { existsSync } from 'fs';
|
||||
import sharp from 'sharp';
|
||||
import { Vector3Tuple } from 'three';
|
||||
import { readDVPLFile } from '../blitz/readDVPLFile';
|
||||
import { DdsReadStream } from '../streams/dds';
|
||||
import { PvrReadStream } from '../streams/pvr';
|
||||
|
||||
export enum TextureMutation {
|
||||
Normal,
|
||||
RoughnessMetallicness,
|
||||
BaseColor,
|
||||
Miscellaneous,
|
||||
}
|
||||
import { readDVPLFile } from '../../blitz/readDVPLFile';
|
||||
import { DdsReadStream } from '../../streams/dds';
|
||||
import { PvrReadStream } from '../../streams/pvr';
|
||||
import { TextureMutation } from './constants';
|
||||
|
||||
type ReadTextureOptions =
|
||||
| {
|
||||
@@ -0,0 +1,8 @@
|
||||
import { useSession } from '../../stores/session';
|
||||
import { setSession } from './setSession';
|
||||
|
||||
export function resetSession() {
|
||||
const session = useSession.getState();
|
||||
if (!session.isTracking) return;
|
||||
setSession(session.region, session.id, session.nickname);
|
||||
}
|
||||
@@ -2,7 +2,7 @@ import { config } from 'dotenv';
|
||||
|
||||
config();
|
||||
|
||||
export const SECRET_KEYS = [
|
||||
const SECRET_KEYS = [
|
||||
'DISCORD_TOKEN',
|
||||
'GH_TOKEN',
|
||||
'DISCORD_BLITZ_DB',
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
import { Region } from '../../constants/regions';
|
||||
import { WARGAMING_APPLICATION_ID } from '../../constants/wargamingApplicationID';
|
||||
import { useSession } from '../../stores/session';
|
||||
import { NormalizedTankStats, TanksStats } from '../../types/tanksStats';
|
||||
import fetchBlitz from '../blitz/fetchBlitz';
|
||||
|
||||
export async function setSession(region: Region, id: number, nickname: string) {
|
||||
// TODO: generalize this function and also check for more of these kind
|
||||
const rawTankStats = (
|
||||
await fetchBlitz<TanksStats>(
|
||||
`https://api.wotblitz.${region}/wotb/tanks/stats/?application_id=${WARGAMING_APPLICATION_ID}&account_id=${id}`,
|
||||
)
|
||||
)[id];
|
||||
const tankStats = rawTankStats.reduce<NormalizedTankStats>(
|
||||
(accumulator, tank) => ({
|
||||
...accumulator,
|
||||
[tank.tank_id]: tank,
|
||||
}),
|
||||
{},
|
||||
);
|
||||
|
||||
useSession.setState({
|
||||
isTracking: true,
|
||||
id,
|
||||
region,
|
||||
nickname,
|
||||
tankStats,
|
||||
time: Date.now(),
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
import { CrewMember, GunDefinition, ShellType, Tier } from '.';
|
||||
import { TankClass } from '../../../components/Tanks';
|
||||
|
||||
export const SHELL_NAMES: Record<ShellType, string> = {
|
||||
ap: 'AP',
|
||||
ap_cr: 'APCR',
|
||||
hc: 'HEAT',
|
||||
he: 'HE',
|
||||
};
|
||||
export const CREW_MEMBER_NAMES: Record<CrewMember, string> = {
|
||||
commander: 'Commander',
|
||||
radioman: 'Radioman',
|
||||
gunner: 'Gunner',
|
||||
driver: 'Driver',
|
||||
loader: 'Loader',
|
||||
};
|
||||
export const GUN_TYPE_NAMES: Record<GunDefinition['type'], string> = {
|
||||
regular: 'Regular',
|
||||
autoLoader: 'Auto loader',
|
||||
autoReloader: 'Auto reloader',
|
||||
};
|
||||
export const TANK_ICONS: Record<TankClass, string> = {
|
||||
'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',
|
||||
};
|
||||
export const TANK_ICONS_PREMIUM: Record<TankClass, string> = {
|
||||
'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',
|
||||
};
|
||||
export const TANK_ICONS_COLLECTOR: Record<TankClass, string> = {
|
||||
'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',
|
||||
};
|
||||
export const TIERS = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] as const;
|
||||
export const TIER_ROMAN_NUMERALS: Record<Tier, string> = {
|
||||
1: 'I',
|
||||
2: 'II',
|
||||
3: 'III',
|
||||
4: 'IV',
|
||||
5: 'V',
|
||||
6: 'VI',
|
||||
7: 'VII',
|
||||
8: 'VIII',
|
||||
9: 'IX',
|
||||
10: 'X',
|
||||
};
|
||||
+4
-59
@@ -1,18 +1,12 @@
|
||||
import { deburr } from 'lodash';
|
||||
import { Vector2Tuple } from 'three';
|
||||
import { TankClass, TreeType } from '../../components/Tanks';
|
||||
import { asset } from './asset';
|
||||
import { fetchCdonLz4 } from './fetchCdonLz4';
|
||||
import { TankClass, TreeType } from '../../../components/Tanks';
|
||||
import { asset } from '../asset';
|
||||
import { fetchCdonLz4 } from '../fetchCdonLz4';
|
||||
import { TIERS } from './constants';
|
||||
|
||||
export type ShellType = 'ap' | 'ap_cr' | 'hc' | 'he';
|
||||
|
||||
export const SHELL_NAMES: Record<ShellType, string> = {
|
||||
ap: 'AP',
|
||||
ap_cr: 'APCR',
|
||||
hc: 'HEAT',
|
||||
he: 'HE',
|
||||
};
|
||||
|
||||
export type CrewMember =
|
||||
| 'commander'
|
||||
| 'radioman'
|
||||
@@ -20,13 +14,6 @@ export type CrewMember =
|
||||
| 'driver'
|
||||
| 'loader';
|
||||
export type TankDefinitions = Record<number, TankDefinition>;
|
||||
export const CREW_MEMBER_NAMES: Record<CrewMember, string> = {
|
||||
commander: 'Commander',
|
||||
radioman: 'Radioman',
|
||||
gunner: 'Gunner',
|
||||
driver: 'Driver',
|
||||
loader: 'Loader',
|
||||
};
|
||||
export interface Crew {
|
||||
type: CrewMember;
|
||||
count?: number;
|
||||
@@ -148,12 +135,6 @@ export type ShellDefinition = {
|
||||
explosionRadius?: number;
|
||||
};
|
||||
|
||||
export const GUN_TYPE_NAMES: Record<GunDefinition['type'], string> = {
|
||||
regular: 'Regular',
|
||||
autoLoader: 'Auto loader',
|
||||
autoReloader: 'Auto reloader',
|
||||
};
|
||||
|
||||
export const tankDefinitions = fetchCdonLz4<TankDefinitions>(
|
||||
asset('definitions/tanks.cdon.lz4'),
|
||||
);
|
||||
@@ -180,44 +161,8 @@ export const tankNames = tanksDefinitionsArray.then((tanks) =>
|
||||
),
|
||||
);
|
||||
|
||||
export const TANK_ICONS: Record<TankClass, string> = {
|
||||
'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',
|
||||
};
|
||||
|
||||
export const TANK_ICONS_PREMIUM: Record<TankClass, string> = {
|
||||
'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',
|
||||
};
|
||||
|
||||
export const TANK_ICONS_COLLECTOR: Record<TankClass, string> = {
|
||||
'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',
|
||||
};
|
||||
|
||||
export const TIERS = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] as const;
|
||||
|
||||
export type Tier = (typeof TIERS)[number];
|
||||
|
||||
export const TIER_ROMAN_NUMERALS: Record<Tier, string> = {
|
||||
1: 'I',
|
||||
2: 'II',
|
||||
3: 'III',
|
||||
4: 'IV',
|
||||
5: 'V',
|
||||
6: 'VI',
|
||||
7: 'VII',
|
||||
8: 'VIII',
|
||||
9: 'IX',
|
||||
10: 'X',
|
||||
};
|
||||
|
||||
export const NATIONS = tanksDefinitionsArray.then((tanks) => {
|
||||
const nations = Array.from(
|
||||
new Set<string>(Object.values(tanks).map((tank) => tank.nation)),
|
||||
Reference in new issue
Block a user