mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-24 20:19:49 +02:00
feat: core chunk 5
This commit is contained in:
1 parent
9bdb14e13a
commit
ed8bab7df8
37 files changed
+91
-165
No files matched your search
@@ -1,61 +0,0 @@
|
|||||||
import { SlashCommandStringOption } from 'discord.js';
|
|
||||||
|
|
||||||
export const STAT_PROPERTIES = [
|
|
||||||
{ name: 'Time', value: 'time' },
|
|
||||||
|
|
||||||
{ name: 'Battles', value: 'battles' },
|
|
||||||
{ name: 'Maximum XP', value: 'max_xp' },
|
|
||||||
{ name: 'Maximum kills', value: 'max_frags' },
|
|
||||||
|
|
||||||
{ name: 'Accumulated spots', value: 'spotted' },
|
|
||||||
{ name: 'Accumulated hits', value: 'hits' },
|
|
||||||
{ name: 'Accumulated kills', value: 'frags' },
|
|
||||||
{ name: 'Accumulated wins', value: 'wins' },
|
|
||||||
{ name: 'Accumulated losses', value: 'losses' },
|
|
||||||
{ name: 'Accumulated capture points', value: 'capture_points' },
|
|
||||||
{ name: 'Accumulated damage dealt', value: 'damage_dealt' },
|
|
||||||
{ name: 'Accumulated damage received', value: 'damage_received' },
|
|
||||||
{ name: 'Accumulated shots', value: 'shots' },
|
|
||||||
{ name: 'Accumulated kills above tier 8', value: 'frags8p' },
|
|
||||||
{ name: 'Accumulated XP', value: 'xp' },
|
|
||||||
{
|
|
||||||
name: 'Accumulated won and survived battles',
|
|
||||||
value: 'win_and_survived',
|
|
||||||
},
|
|
||||||
{ name: 'Accumulated survived battles', value: 'survived_battles' },
|
|
||||||
{
|
|
||||||
name: 'Accumulated dropped capture points',
|
|
||||||
value: 'dropped_capture_points',
|
|
||||||
},
|
|
||||||
|
|
||||||
{ name: 'Average spots', value: 'average_spotted' },
|
|
||||||
{ name: 'Average hits', value: 'average_hits' },
|
|
||||||
{ name: 'Average kills', value: 'average_frags' },
|
|
||||||
{ name: 'Average winrate', value: 'average_wins' },
|
|
||||||
{ name: 'Average loss rate', value: 'average_losses' },
|
|
||||||
{ name: 'Average capture points', value: 'average_capture_points' },
|
|
||||||
{ name: 'Average damage dealt', value: 'average_damage_dealt' },
|
|
||||||
{ name: 'Average damage received', value: 'average_damage_received' },
|
|
||||||
{ name: 'Average shots', value: 'average_shots' },
|
|
||||||
{ name: 'Average kills above tier 8', value: 'average_frags8p' },
|
|
||||||
{ name: 'Average XP', value: 'average_xp' },
|
|
||||||
{
|
|
||||||
name: 'Average win and survival rate',
|
|
||||||
value: 'average_win_and_survived',
|
|
||||||
},
|
|
||||||
{ name: 'Average survival rate', value: 'average_survived_battles' },
|
|
||||||
|
|
||||||
{ name: 'Average WN8', value: 'average_wn8' },
|
|
||||||
{ name: 'Average damage ratio', value: 'average_damage_ratio' },
|
|
||||||
{
|
|
||||||
name: 'Average kills to death ratio',
|
|
||||||
value: 'average_kills_to_death_ratio',
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
export function addStatPropertyOptions(option: SlashCommandStringOption) {
|
|
||||||
return option
|
|
||||||
.setName('stat-property')
|
|
||||||
.setDescription('A specific statistical property')
|
|
||||||
.setAutocomplete(true);
|
|
||||||
}
|
|
||||||
@@ -4,7 +4,7 @@ import {
|
|||||||
SlashCommandSubcommandGroupBuilder,
|
SlashCommandSubcommandGroupBuilder,
|
||||||
} from 'discord.js';
|
} from 'discord.js';
|
||||||
import { TREE_TYPE_NAMES, TreeTypeString } from '../../components/Tanks';
|
import { TREE_TYPE_NAMES, TreeTypeString } from '../../components/Tanks';
|
||||||
import { tankopediaInfo } from '../blitz/tankopedia';
|
import { tankopediaInfo } from '../../core/blitzstars/tankopedia';
|
||||||
import addPeriodSubCommands from './addPeriodSubCommands';
|
import addPeriodSubCommands from './addPeriodSubCommands';
|
||||||
import addTankChoices from './addTankChoices';
|
import addTankChoices from './addTankChoices';
|
||||||
import addTierChoices from './addTierChoices';
|
import addTierChoices from './addTierChoices';
|
||||||
|
|||||||
@@ -1,20 +0,0 @@
|
|||||||
import { AutocompleteInteraction, CacheType } from 'discord.js';
|
|
||||||
import { go } from 'fuzzysort';
|
|
||||||
import { STAT_PROPERTIES } from '../blitzkrieg/addStatPropertyOptions';
|
|
||||||
|
|
||||||
export default async function autocompleteStatProperty(
|
|
||||||
interaction: AutocompleteInteraction<CacheType>,
|
|
||||||
name = 'stat-property',
|
|
||||||
) {
|
|
||||||
const focusedOption = interaction.options.getFocused(true);
|
|
||||||
if (focusedOption.name !== name) return;
|
|
||||||
|
|
||||||
await interaction.respond(
|
|
||||||
focusedOption.value
|
|
||||||
? go(focusedOption.value, STAT_PROPERTIES, {
|
|
||||||
keys: ['name'],
|
|
||||||
limit: 10,
|
|
||||||
}).map(({ obj }) => obj)
|
|
||||||
: STAT_PROPERTIES.slice(0, 25),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -4,7 +4,7 @@ import {
|
|||||||
CacheType,
|
CacheType,
|
||||||
} from 'discord.js';
|
} from 'discord.js';
|
||||||
import { go } from 'fuzzysort';
|
import { go } from 'fuzzysort';
|
||||||
import { TANK_NAMES_DIACRITICS } from '../blitz/tankopedia';
|
import { TANK_NAMES_DIACRITICS } from '../../core/blitzstars/tankopedia';
|
||||||
|
|
||||||
export default async function autocompleteTanks(
|
export default async function autocompleteTanks(
|
||||||
interaction: AutocompleteInteraction<CacheType>,
|
interaction: AutocompleteInteraction<CacheType>,
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { ChatInputCommandInteraction } from 'discord.js';
|
import { ChatInputCommandInteraction } from 'discord.js';
|
||||||
import { TreeTypeString } from '../../components/Tanks';
|
import { TreeTypeString } from '../../components/Tanks';
|
||||||
|
import resolveTankId from '../../core/blitz/resolveTankId';
|
||||||
import { StatFilters } from '../../core/statistics/filterStats';
|
import { StatFilters } from '../../core/statistics/filterStats';
|
||||||
import resolveTankId from '../blitz/resolveTankId';
|
|
||||||
|
|
||||||
export async function getFiltersFromCommand(
|
export async function getFiltersFromCommand(
|
||||||
interaction: ChatInputCommandInteraction,
|
interaction: ChatInputCommandInteraction,
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import { ButtonInteraction } from 'discord.js';
|
import { ButtonInteraction } from 'discord.js';
|
||||||
import { Region } from '../../constants/regions';
|
import { Region } from '../../constants/regions';
|
||||||
import getPeriodNow from '../blitzstars/getPeriodNow';
|
import getPeriodNow from '../../core/blitzkrieg/getPeriodNow';
|
||||||
import getPeriodStart from '../blitzstars/getPeriodStart';
|
import getPeriodStart from '../../core/blitzkrieg/getPeriodStart';
|
||||||
import getTimeDaysAgo from '../blitzstars/getTimeDaysAgo';
|
import getTimeDaysAgo from '../../core/blitzkrieg/getTimeDaysAgo';
|
||||||
import { PeriodType } from './addPeriodSubCommands';
|
import { PeriodType } from './addPeriodSubCommands';
|
||||||
import {
|
import {
|
||||||
ResolvedPeriod,
|
ResolvedPeriod,
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import { CacheType, ChatInputCommandInteraction } from 'discord.js';
|
import { CacheType, ChatInputCommandInteraction } from 'discord.js';
|
||||||
import { Region } from '../../constants/regions';
|
import { Region } from '../../constants/regions';
|
||||||
import getPeriodNow from '../blitzstars/getPeriodNow';
|
import getPeriodNow from '../../core/blitzkrieg/getPeriodNow';
|
||||||
import getPeriodStart from '../blitzstars/getPeriodStart';
|
import getPeriodStart from '../../core/blitzkrieg/getPeriodStart';
|
||||||
import getTimeDaysAgo from '../blitzstars/getTimeDaysAgo';
|
import getTimeDaysAgo from '../../core/blitzkrieg/getTimeDaysAgo';
|
||||||
import { PeriodSize, PeriodType } from '../discord/addPeriodSubCommands';
|
import { PeriodSize, PeriodType } from '../discord/addPeriodSubCommands';
|
||||||
|
|
||||||
export function getPeriodOptionName(period: PeriodSize) {
|
export function getPeriodOptionName(period: PeriodSize) {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { NextResponse } from 'next/server';
|
import { NextResponse } from 'next/server';
|
||||||
import { tankAverages } from '../../../LEGACY_core/blitzstars/tankAverages';
|
import { tankAverages } from '../../../core/blitzstars/tankAverages';
|
||||||
|
|
||||||
export async function GET() {
|
export async function GET() {
|
||||||
return NextResponse.json(await tankAverages);
|
return NextResponse.json(await tankAverages);
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { NextResponse } from 'next/server';
|
import { NextResponse } from 'next/server';
|
||||||
import { tankopedia } from '../../../LEGACY_core/blitz/tankopedia';
|
import { tankopedia } from '../../../core/blitzstars/tankopedia';
|
||||||
|
|
||||||
export async function GET() {
|
export async function GET() {
|
||||||
return NextResponse.json(await tankopedia);
|
return NextResponse.json(await tankopedia);
|
||||||
|
|||||||
@@ -2,15 +2,15 @@
|
|||||||
|
|
||||||
import { ContextMenu } from '@radix-ui/themes';
|
import { ContextMenu } from '@radix-ui/themes';
|
||||||
import { useEffect, useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
import {
|
|
||||||
TankopediaEntry,
|
|
||||||
tankopedia,
|
|
||||||
} from '../../../LEGACY_core/blitz/tankopedia';
|
|
||||||
import { tankAverages } from '../../../LEGACY_core/blitzstars/tankAverages';
|
|
||||||
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 fetchBlitz from '../../../core/blitz/fetchWargaming';
|
import fetchBlitz from '../../../core/blitz/fetchWargaming';
|
||||||
|
import { tankAverages } from '../../../core/blitzstars/tankAverages';
|
||||||
|
import {
|
||||||
|
TankopediaEntry,
|
||||||
|
tankopedia,
|
||||||
|
} from '../../../core/blitzstars/tankopedia';
|
||||||
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 getWN8Percentile from '../../../core/statistics/getWN8Percentile';
|
import getWN8Percentile from '../../../core/statistics/getWN8Percentile';
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
import { SlashCommandBuilder } from 'discord.js';
|
import { SlashCommandBuilder } from 'discord.js';
|
||||||
import packageJSON from '../../package.json' assert { type: 'json' };
|
import packageJSON from '../../package.json' assert { type: 'json' };
|
||||||
import { tankopedia } from '../LEGACY_core/blitz/tankopedia';
|
|
||||||
import { tankAverages } from '../LEGACY_core/blitzstars/tankAverages';
|
|
||||||
import { client } from '../LEGACY_core/discord/client';
|
import { client } from '../LEGACY_core/discord/client';
|
||||||
import embedInfo from '../LEGACY_core/discord/embedInfo';
|
import embedInfo from '../LEGACY_core/discord/embedInfo';
|
||||||
import markdownTable from '../LEGACY_core/discord/markdownTable';
|
import markdownTable from '../LEGACY_core/discord/markdownTable';
|
||||||
import getClientId from '../LEGACY_core/node/getClientId';
|
import getClientId from '../LEGACY_core/node/getClientId';
|
||||||
|
import { tankAverages } from '../core/blitzstars/tankAverages';
|
||||||
|
import { tankopedia } from '../core/blitzstars/tankopedia';
|
||||||
import { CommandRegistry } from '../events/interactionCreate';
|
import { CommandRegistry } from '../events/interactionCreate';
|
||||||
|
|
||||||
const executionStart = new Date().getTime();
|
const executionStart = new Date().getTime();
|
||||||
|
|||||||
@@ -1,10 +1,4 @@
|
|||||||
import { SlashCommandBuilder } from 'discord.js';
|
import { SlashCommandBuilder } from 'discord.js';
|
||||||
import sumStats from '../LEGACY_core/blitz/sumStats';
|
|
||||||
import { tankopedia } from '../LEGACY_core/blitz/tankopedia';
|
|
||||||
import getDiffedTankStats from '../LEGACY_core/blitzstars/getDiffedTankStats';
|
|
||||||
import getPeriodNow from '../LEGACY_core/blitzstars/getPeriodNow';
|
|
||||||
import getTimeDaysAgo from '../LEGACY_core/blitzstars/getTimeDaysAgo';
|
|
||||||
import { tankAverages } from '../LEGACY_core/blitzstars/tankAverages';
|
|
||||||
import addUsernameChoices from '../LEGACY_core/discord/addUsernameChoices';
|
import addUsernameChoices from '../LEGACY_core/discord/addUsernameChoices';
|
||||||
import embedNegative from '../LEGACY_core/discord/embedNegative';
|
import embedNegative from '../LEGACY_core/discord/embedNegative';
|
||||||
import embedPositive from '../LEGACY_core/discord/embedPositive';
|
import embedPositive from '../LEGACY_core/discord/embedPositive';
|
||||||
@@ -13,7 +7,13 @@ import markdownTable, {
|
|||||||
} from '../LEGACY_core/discord/markdownTable';
|
} from '../LEGACY_core/discord/markdownTable';
|
||||||
import resolvePlayerFromCommand from '../LEGACY_core/discord/resolvePlayerFromCommand';
|
import resolvePlayerFromCommand from '../LEGACY_core/discord/resolvePlayerFromCommand';
|
||||||
import { getAccountInfo } from '../core/blitz/getAccountInfo';
|
import { getAccountInfo } from '../core/blitz/getAccountInfo';
|
||||||
|
import getPeriodNow from '../core/blitzkrieg/getPeriodNow';
|
||||||
|
import getTimeDaysAgo from '../core/blitzkrieg/getTimeDaysAgo';
|
||||||
|
import getStatsInPeriod from '../core/blitzstars/getStatsInPeriod';
|
||||||
|
import { tankAverages } from '../core/blitzstars/tankAverages';
|
||||||
|
import { tankopedia } from '../core/blitzstars/tankopedia';
|
||||||
import calculateWN8 from '../core/statistics/calculateWN8';
|
import calculateWN8 from '../core/statistics/calculateWN8';
|
||||||
|
import sumStats from '../core/statistics/sumStats';
|
||||||
import { CommandRegistry } from '../events/interactionCreate';
|
import { CommandRegistry } from '../events/interactionCreate';
|
||||||
import { PossiblyPromise } from '../types/possiblyPromise';
|
import { PossiblyPromise } from '../types/possiblyPromise';
|
||||||
|
|
||||||
@@ -56,7 +56,7 @@ export const eligibleCommand: CommandRegistry = {
|
|||||||
let body = '';
|
let body = '';
|
||||||
|
|
||||||
if (clan === 'SKLLD') {
|
if (clan === 'SKLLD') {
|
||||||
const { diff: diffed } = await getDiffedTankStats(
|
const { diff: diffed } = await getStatsInPeriod(
|
||||||
region,
|
region,
|
||||||
id,
|
id,
|
||||||
getTimeDaysAgo(region, 30),
|
getTimeDaysAgo(region, 30),
|
||||||
|
|||||||
@@ -2,10 +2,6 @@ import {
|
|||||||
SlashCommandBuilder,
|
SlashCommandBuilder,
|
||||||
SlashCommandSubcommandGroupBuilder,
|
SlashCommandSubcommandGroupBuilder,
|
||||||
} from 'discord.js';
|
} from 'discord.js';
|
||||||
import resolveTankId from '../LEGACY_core/blitz/resolveTankId';
|
|
||||||
import { getBlitzStarsLinkButton } from '../LEGACY_core/blitzstars/getBlitzStarsLinkButton';
|
|
||||||
import getPlayerHistories from '../LEGACY_core/blitzstars/getPlayerHistories';
|
|
||||||
import getTankHistories from '../LEGACY_core/blitzstars/getTankHistories';
|
|
||||||
import addPeriodSubCommands from '../LEGACY_core/discord/addPeriodSubCommands';
|
import addPeriodSubCommands from '../LEGACY_core/discord/addPeriodSubCommands';
|
||||||
import addTankChoices from '../LEGACY_core/discord/addTankChoices';
|
import addTankChoices from '../LEGACY_core/discord/addTankChoices';
|
||||||
import addUsernameChoices from '../LEGACY_core/discord/addUsernameChoices';
|
import addUsernameChoices from '../LEGACY_core/discord/addUsernameChoices';
|
||||||
@@ -28,7 +24,11 @@ import TitleBar from '../components/TitleBar';
|
|||||||
import Wrapper from '../components/Wrapper';
|
import Wrapper from '../components/Wrapper';
|
||||||
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 resolveTankId from '../core/blitz/resolveTankId';
|
||||||
import { emblemIdToURL } from '../core/blitzkrieg/emblemIdToURL';
|
import { emblemIdToURL } from '../core/blitzkrieg/emblemIdToURL';
|
||||||
|
import getTankHistories from '../core/blitzkrieg/getTankHistories';
|
||||||
|
import { getBlitzStarsLinkButton } from '../core/blitzstars/getBlitzStarsLinkButton';
|
||||||
|
import getPlayerHistories from '../core/blitzstars/getPlayerHistories';
|
||||||
import { CommandRegistryRaw } from '../events/interactionCreate';
|
import { CommandRegistryRaw } from '../events/interactionCreate';
|
||||||
|
|
||||||
type EvolutionStatType = 'player' | 'tank';
|
type EvolutionStatType = 'player' | 'tank';
|
||||||
|
|||||||
@@ -1,8 +1,4 @@
|
|||||||
import { SlashCommandBuilder } from 'discord.js';
|
import { SlashCommandBuilder } from 'discord.js';
|
||||||
import { filtersToDescription } from '../LEGACY_core/blitzkrieg/filtersToDescription';
|
|
||||||
import { getTierWeights } from '../LEGACY_core/blitzkrieg/getTierWeights';
|
|
||||||
import { getBlitzStarsLinkButton } from '../LEGACY_core/blitzstars/getBlitzStarsLinkButton';
|
|
||||||
import getDiffedTankStats from '../LEGACY_core/blitzstars/getDiffedTankStats';
|
|
||||||
import addStatTypeSubCommands from '../LEGACY_core/discord/addStatTypeSubCommands';
|
import addStatTypeSubCommands from '../LEGACY_core/discord/addStatTypeSubCommands';
|
||||||
import addUsernameChoices from '../LEGACY_core/discord/addUsernameChoices';
|
import addUsernameChoices from '../LEGACY_core/discord/addUsernameChoices';
|
||||||
import autocompleteTanks from '../LEGACY_core/discord/autocompleteTanks';
|
import autocompleteTanks from '../LEGACY_core/discord/autocompleteTanks';
|
||||||
@@ -28,7 +24,11 @@ import Wrapper from '../components/Wrapper';
|
|||||||
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 { emblemIdToURL } from '../core/blitzkrieg/emblemIdToURL';
|
||||||
|
import { filtersToDescription } from '../core/blitzkrieg/filtersToDescription';
|
||||||
|
import { getBlitzStarsLinkButton } from '../core/blitzstars/getBlitzStarsLinkButton';
|
||||||
|
import getStatsInPeriod from '../core/blitzstars/getStatsInPeriod';
|
||||||
import { StatFilters, filterStats } from '../core/statistics/filterStats';
|
import { StatFilters, filterStats } from '../core/statistics/filterStats';
|
||||||
|
import { getTierWeights } from '../core/statistics/getTierWeights';
|
||||||
import { CommandRegistryRaw } from '../events/interactionCreate';
|
import { CommandRegistryRaw } from '../events/interactionCreate';
|
||||||
|
|
||||||
async function render(
|
async function render(
|
||||||
@@ -39,7 +39,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 ? emblemIdToURL(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 getStatsInPeriod(region, id, start, end);
|
||||||
const { stats, supplementary, filteredOrder } = await filterStats(
|
const { stats, supplementary, filteredOrder } = await filterStats(
|
||||||
diffedTankStats,
|
diffedTankStats,
|
||||||
filters,
|
filters,
|
||||||
|
|||||||
@@ -1,12 +1,4 @@
|
|||||||
import { SlashCommandBuilder } from 'discord.js';
|
import { SlashCommandBuilder } from 'discord.js';
|
||||||
import resolveTankName from '../LEGACY_core/blitz/resolveTankName';
|
|
||||||
import {
|
|
||||||
TIER_ROMAN_NUMERALS,
|
|
||||||
TankopediaEntry,
|
|
||||||
Tier,
|
|
||||||
tankopedia,
|
|
||||||
tankopediaInfo,
|
|
||||||
} from '../LEGACY_core/blitz/tankopedia';
|
|
||||||
import addTierChoices from '../LEGACY_core/discord/addTierChoices';
|
import addTierChoices from '../LEGACY_core/discord/addTierChoices';
|
||||||
import addUsernameChoices from '../LEGACY_core/discord/addUsernameChoices';
|
import addUsernameChoices from '../LEGACY_core/discord/addUsernameChoices';
|
||||||
import autocompleteUsername from '../LEGACY_core/discord/autocompleteUsername';
|
import autocompleteUsername from '../LEGACY_core/discord/autocompleteUsername';
|
||||||
@@ -19,7 +11,15 @@ 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 getTankStats from '../core/blitz/getTankStats';
|
||||||
import getTreeType from '../core/blitz/getTreeType';
|
import getTreeType from '../core/blitz/getTreeType';
|
||||||
|
import resolveTankName from '../core/blitz/resolveTankName';
|
||||||
import { emblemIdToURL } from '../core/blitzkrieg/emblemIdToURL';
|
import { emblemIdToURL } from '../core/blitzkrieg/emblemIdToURL';
|
||||||
|
import {
|
||||||
|
TIER_ROMAN_NUMERALS,
|
||||||
|
TankopediaEntry,
|
||||||
|
Tier,
|
||||||
|
tankopedia,
|
||||||
|
tankopediaInfo,
|
||||||
|
} from '../core/blitzstars/tankopedia';
|
||||||
import { CommandRegistry } from '../events/interactionCreate';
|
import { CommandRegistry } from '../events/interactionCreate';
|
||||||
|
|
||||||
export const ownedTanksCommand: CommandRegistry = {
|
export const ownedTanksCommand: CommandRegistry = {
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import { SlashCommandBuilder } from 'discord.js';
|
import { SlashCommandBuilder } from 'discord.js';
|
||||||
import { go } from 'fuzzysort';
|
import { go } from 'fuzzysort';
|
||||||
import markdownEscape from 'markdown-escape';
|
import markdownEscape from 'markdown-escape';
|
||||||
import { TANK_NAMES_DIACRITICS } from '../LEGACY_core/blitz/tankopedia';
|
|
||||||
import addTankChoices from '../LEGACY_core/discord/addTankChoices';
|
import addTankChoices from '../LEGACY_core/discord/addTankChoices';
|
||||||
import embedInfo from '../LEGACY_core/discord/embedInfo';
|
import embedInfo from '../LEGACY_core/discord/embedInfo';
|
||||||
|
import { TANK_NAMES_DIACRITICS } from '../core/blitzstars/tankopedia';
|
||||||
import { CommandRegistry } from '../events/interactionCreate';
|
import { CommandRegistry } from '../events/interactionCreate';
|
||||||
|
|
||||||
export const searchTanksCommand: CommandRegistry = {
|
export const searchTanksCommand: CommandRegistry = {
|
||||||
|
|||||||
@@ -1,7 +1,4 @@
|
|||||||
import { SlashCommandBuilder } from 'discord.js';
|
import { SlashCommandBuilder } from 'discord.js';
|
||||||
import { filtersToDescription } from '../LEGACY_core/blitzkrieg/filtersToDescription';
|
|
||||||
import { getBlitzStarsLinkButton } from '../LEGACY_core/blitzstars/getBlitzStarsLinkButton';
|
|
||||||
import getDiffedTankStats from '../LEGACY_core/blitzstars/getDiffedTankStats';
|
|
||||||
import addStatTypeSubCommands from '../LEGACY_core/discord/addStatTypeSubCommands';
|
import addStatTypeSubCommands from '../LEGACY_core/discord/addStatTypeSubCommands';
|
||||||
import addUsernameChoices from '../LEGACY_core/discord/addUsernameChoices';
|
import addUsernameChoices from '../LEGACY_core/discord/addUsernameChoices';
|
||||||
import autocompleteTanks from '../LEGACY_core/discord/autocompleteTanks';
|
import autocompleteTanks from '../LEGACY_core/discord/autocompleteTanks';
|
||||||
@@ -26,6 +23,9 @@ import Wrapper from '../components/Wrapper';
|
|||||||
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 { emblemIdToURL } from '../core/blitzkrieg/emblemIdToURL';
|
||||||
|
import { filtersToDescription } from '../core/blitzkrieg/filtersToDescription';
|
||||||
|
import { getBlitzStarsLinkButton } from '../core/blitzstars/getBlitzStarsLinkButton';
|
||||||
|
import getStatsInPeriod from '../core/blitzstars/getStatsInPeriod';
|
||||||
import { StatFilters, filterStats } from '../core/statistics/filterStats';
|
import { StatFilters, filterStats } from '../core/statistics/filterStats';
|
||||||
import { CommandRegistryRaw } from '../events/interactionCreate';
|
import { CommandRegistryRaw } from '../events/interactionCreate';
|
||||||
|
|
||||||
@@ -37,7 +37,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 ? emblemIdToURL(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 getStatsInPeriod(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);
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import {
|
|||||||
TANK_ICONS,
|
TANK_ICONS,
|
||||||
TANK_ICONS_COLLECTOR,
|
TANK_ICONS_COLLECTOR,
|
||||||
TANK_ICONS_PREMIUM,
|
TANK_ICONS_PREMIUM,
|
||||||
} from '../../../LEGACY_core/blitz/tankopedia';
|
} from '../../../core/blitzstars/tankopedia';
|
||||||
import { theme } from '../../../stitches.config';
|
import { theme } from '../../../stitches.config';
|
||||||
|
|
||||||
export enum TreeTypeEnum {
|
export enum TreeTypeEnum {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { Tier } from '../LEGACY_core/blitz/tankopedia';
|
import { Tier } from '../core/blitzstars/tankopedia';
|
||||||
import { theme } from '../stitches.config';
|
import { theme } from '../stitches.config';
|
||||||
|
|
||||||
export type TierWeightsRecord = Partial<Record<Tier, number>>;
|
export type TierWeightsRecord = Partial<Record<Tier, number>>;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { TreeTypeEnum } from '../../components/Tanks';
|
import { TreeTypeEnum } from '../../components/Tanks';
|
||||||
import { tankopedia } from '../../LEGACY_core/blitz/tankopedia';
|
import { tankopedia } from '../blitzstars/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];
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { go } from 'fuzzysort';
|
import { go } from 'fuzzysort';
|
||||||
import throwError from '../node/throwError';
|
import throwError from '../../LEGACY_core/node/throwError';
|
||||||
import { TANKS, tankopedia } from './tankopedia';
|
import { TANKS, tankopedia } from '../blitzstars/tankopedia';
|
||||||
|
|
||||||
export default async function resolveTankId(tank: string | number) {
|
export default async function resolveTankId(tank: string | number) {
|
||||||
const number = typeof tank === 'string' ? parseInt(tank) : tank;
|
const number = typeof tank === 'string' ? parseInt(tank) : tank;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import { tankopedia } from './tankopedia';
|
import { tankopedia } from '../blitzstars/tankopedia';
|
||||||
|
|
||||||
export default async function resolveTankName(tankId: number) {
|
export default async function resolveTankName(tankId: number) {
|
||||||
const tankopediaName = (await tankopedia)[tankId]?.name;
|
const tankopediaName = (await tankopedia)[tankId]?.name;
|
||||||
File renamed without changes.
+6
-2
@@ -1,7 +1,11 @@
|
|||||||
import { TREE_TYPE_NAMES } from '../../components/Tanks';
|
import { TREE_TYPE_NAMES } from '../../components/Tanks';
|
||||||
import { StatFilters } from '../../core/statistics/filterStats';
|
|
||||||
import resolveTankName from '../blitz/resolveTankName';
|
import resolveTankName from '../blitz/resolveTankName';
|
||||||
import { TIER_ROMAN_NUMERALS, Tier, tankopediaInfo } from '../blitz/tankopedia';
|
import {
|
||||||
|
TIER_ROMAN_NUMERALS,
|
||||||
|
Tier,
|
||||||
|
tankopediaInfo,
|
||||||
|
} from '../blitzstars/tankopedia';
|
||||||
|
import { StatFilters } from '../statistics/filterStats';
|
||||||
|
|
||||||
export async function filtersToDescription({
|
export async function filtersToDescription({
|
||||||
nation,
|
nation,
|
||||||
File renamed without changes.
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
|
import { PeriodSize } from '../../LEGACY_core/discord/addPeriodSubCommands';
|
||||||
import { Region } from '../../constants/regions';
|
import { Region } from '../../constants/regions';
|
||||||
import { PeriodSize } from '../discord/addPeriodSubCommands';
|
|
||||||
import getTimeDaysAgo from './getTimeDaysAgo';
|
import getTimeDaysAgo from './getTimeDaysAgo';
|
||||||
|
|
||||||
export default function getPeriodStart(region: Region, period: PeriodSize) {
|
export default function getPeriodStart(region: Region, period: PeriodSize) {
|
||||||
+2
-2
@@ -1,12 +1,12 @@
|
|||||||
import { Region } from '../../constants/regions';
|
import { Region } from '../../constants/regions';
|
||||||
import getTankStats from '../../core/blitz/getTankStats';
|
|
||||||
import {
|
import {
|
||||||
GetHistoriesOptions,
|
GetHistoriesOptions,
|
||||||
Histories,
|
Histories,
|
||||||
History,
|
History,
|
||||||
getHistoriesDefaultOptions,
|
getHistoriesDefaultOptions,
|
||||||
} from '../../types/histories';
|
} from '../../types/histories';
|
||||||
import { emptyAllStats } from './getDiffedTankStats';
|
import getTankStats from '../blitz/getTankStats';
|
||||||
|
import { emptyAllStats } from '../blitzstars/getStatsInPeriod';
|
||||||
|
|
||||||
export interface TankHistory extends History {
|
export interface TankHistory extends History {
|
||||||
tank_id: number;
|
tank_id: number;
|
||||||
File renamed without changes.
+2
-2
@@ -1,6 +1,6 @@
|
|||||||
|
import linkButton from '../../LEGACY_core/discord/linkButton';
|
||||||
import { Region } from '../../constants/regions';
|
import { Region } from '../../constants/regions';
|
||||||
import { getAccountInfo } from '../../core/blitz/getAccountInfo';
|
import { getAccountInfo } from '../blitz/getAccountInfo';
|
||||||
import linkButton from '../discord/linkButton';
|
|
||||||
|
|
||||||
export async function getBlitzStarsLinkButton(
|
export async function getBlitzStarsLinkButton(
|
||||||
region: Region,
|
region: Region,
|
||||||
+3
-3
@@ -1,13 +1,13 @@
|
|||||||
import { Region } from '../../constants/regions';
|
import { Region } from '../../constants/regions';
|
||||||
import { getAccountInfo } from '../../core/blitz/getAccountInfo';
|
|
||||||
import { PlayerStats } from '../../core/blitzstars/getPlayerStats';
|
|
||||||
import {
|
import {
|
||||||
GetHistoriesOptions,
|
GetHistoriesOptions,
|
||||||
Histories,
|
Histories,
|
||||||
History,
|
History,
|
||||||
getHistoriesDefaultOptions,
|
getHistoriesDefaultOptions,
|
||||||
} from '../../types/histories';
|
} from '../../types/histories';
|
||||||
import { emptyAllStats } from './getDiffedTankStats';
|
import { getAccountInfo } from '../blitz/getAccountInfo';
|
||||||
|
import { PlayerStats } from './getPlayerStats';
|
||||||
|
import { emptyAllStats } from './getStatsInPeriod';
|
||||||
|
|
||||||
export default async function getPlayerHistories(
|
export default async function getPlayerHistories(
|
||||||
server: Region,
|
server: Region,
|
||||||
+3
-3
@@ -1,9 +1,9 @@
|
|||||||
import { Region } from '../../constants/regions';
|
import { Region } from '../../constants/regions';
|
||||||
import { AllStats } from '../../core/blitz/getAccountInfo';
|
import { AllStats } from '../blitz/getAccountInfo';
|
||||||
import getTankHistories, {
|
import getTankHistories, {
|
||||||
TankHistories,
|
TankHistories,
|
||||||
TankHistoryRaw,
|
TankHistoryRaw,
|
||||||
} from './getTankHistories';
|
} from '../blitzkrieg/getTankHistories';
|
||||||
|
|
||||||
export const emptyAllStats: AllStats = {
|
export const emptyAllStats: AllStats = {
|
||||||
battles: 0,
|
battles: 0,
|
||||||
@@ -40,7 +40,7 @@ export interface DiffedTankStats {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// BIG TODO: merge this neatly with diffNormalizedTankStats
|
// BIG TODO: merge this neatly with diffNormalizedTankStats
|
||||||
export default async function getDiffedTankStats(
|
export default async function getStatsInPeriod(
|
||||||
server: Region,
|
server: Region,
|
||||||
id: number,
|
id: number,
|
||||||
start: number,
|
start: number,
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
import { AllStats } from '../../core/blitz/getAccountInfo';
|
import { AllStats } from '../blitz/getAccountInfo';
|
||||||
import { context } from '../blitzkrieg/context';
|
import { context } from '../blitzkrieg/context';
|
||||||
|
import { tankopedia } from './tankopedia';
|
||||||
|
|
||||||
export interface SpecialStats {
|
export interface SpecialStats {
|
||||||
winrate: number;
|
winrate: number;
|
||||||
@@ -79,6 +80,8 @@ export interface IndividualTankAverage {
|
|||||||
last_update: number;
|
last_update: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tankopedia;
|
||||||
|
|
||||||
export type TankAverages = Record<number, IndividualTankAverage>;
|
export type TankAverages = Record<number, IndividualTankAverage>;
|
||||||
|
|
||||||
console.log('Caching tank averages...');
|
console.log('Caching tank averages...');
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
import { deburr } from 'lodash';
|
import { deburr } from 'lodash';
|
||||||
import { TreeTypeString } from '../../components/Tanks';
|
import { TreeTypeString } from '../../components/Tanks';
|
||||||
import { WARGAMING_APPLICATION_ID } from '../../constants/wargamingApplicationID';
|
import { WARGAMING_APPLICATION_ID } from '../../constants/wargamingApplicationID';
|
||||||
import fetchBlitz from '../../core/blitz/fetchWargaming';
|
import fetchBlitz from '../blitz/fetchWargaming';
|
||||||
import { context } from '../blitzkrieg/context';
|
import { context } from '../blitzkrieg/context';
|
||||||
|
|
||||||
export interface TankopediaEntry {
|
export interface TankopediaEntry {
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
import { TreeTypeString } from '../../components/Tanks';
|
import { TreeTypeString } from '../../components/Tanks';
|
||||||
import sumStats from '../../LEGACY_core/blitz/sumStats';
|
import { DiffedTankStats } from '../blitzstars/getStatsInPeriod';
|
||||||
import { tankopedia } from '../../LEGACY_core/blitz/tankopedia';
|
import { tankAverages } from '../blitzstars/tankAverages';
|
||||||
import { DiffedTankStats } from '../../LEGACY_core/blitzstars/getDiffedTankStats';
|
import { tankopedia } from '../blitzstars/tankopedia';
|
||||||
import { tankAverages } from '../../LEGACY_core/blitzstars/tankAverages';
|
|
||||||
import calculateWN8 from './calculateWN8';
|
import calculateWN8 from './calculateWN8';
|
||||||
|
import sumStats from './sumStats';
|
||||||
|
|
||||||
export interface StatFilters {
|
export interface StatFilters {
|
||||||
nation?: string;
|
nation?: string;
|
||||||
|
|||||||
+2
-2
@@ -1,6 +1,6 @@
|
|||||||
import { TierWeightsRecord } from '../../components/TierWeights';
|
import { TierWeightsRecord } from '../../components/TierWeights';
|
||||||
import { AllStats } from '../../core/blitz/getAccountInfo';
|
import { AllStats } from '../blitz/getAccountInfo';
|
||||||
import { tankopedia } from '../blitz/tankopedia';
|
import { tankopedia } from '../blitzstars/tankopedia';
|
||||||
|
|
||||||
export async function getTierWeights(
|
export async function getTierWeights(
|
||||||
stats: Record<number, AllStats>,
|
stats: Record<number, AllStats>,
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import { AllStats } from '../../core/blitz/getAccountInfo';
|
import { AllStats } from '../blitz/getAccountInfo';
|
||||||
import { emptyAllStats } from '../blitzstars/getDiffedTankStats';
|
import { emptyAllStats } from '../blitzstars/getStatsInPeriod';
|
||||||
|
|
||||||
export default function sumStats(allStatsCollection: AllStats[]) {
|
export default function sumStats(allStatsCollection: AllStats[]) {
|
||||||
return allStatsCollection.reduce((accumulated, current) => {
|
return allStatsCollection.reduce((accumulated, current) => {
|
||||||
@@ -1,10 +1,3 @@
|
|||||||
import resolveTankName from '../LEGACY_core/blitz/resolveTankName';
|
|
||||||
import sumStats from '../LEGACY_core/blitz/sumStats';
|
|
||||||
import { tankopedia } from '../LEGACY_core/blitz/tankopedia';
|
|
||||||
import getDiffedTankStats from '../LEGACY_core/blitzstars/getDiffedTankStats';
|
|
||||||
import getPeriodNow from '../LEGACY_core/blitzstars/getPeriodNow';
|
|
||||||
import getTimeDaysAgo from '../LEGACY_core/blitzstars/getTimeDaysAgo';
|
|
||||||
import { tankAverages } from '../LEGACY_core/blitzstars/tankAverages';
|
|
||||||
import { ResolvedPlayer } from '../LEGACY_core/discord/resolvePlayerFromCommand';
|
import { ResolvedPlayer } from '../LEGACY_core/discord/resolvePlayerFromCommand';
|
||||||
import * as Breakdown from '../components/Breakdown';
|
import * as Breakdown from '../components/Breakdown';
|
||||||
import NoData, { NoDataType } from '../components/NoData';
|
import NoData, { NoDataType } from '../components/NoData';
|
||||||
@@ -14,8 +7,15 @@ 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 getTankStats from '../core/blitz/getTankStats';
|
||||||
import getTreeType from '../core/blitz/getTreeType';
|
import getTreeType from '../core/blitz/getTreeType';
|
||||||
|
import resolveTankName from '../core/blitz/resolveTankName';
|
||||||
|
import getPeriodNow from '../core/blitzkrieg/getPeriodNow';
|
||||||
|
import getTimeDaysAgo from '../core/blitzkrieg/getTimeDaysAgo';
|
||||||
|
import getStatsInPeriod from '../core/blitzstars/getStatsInPeriod';
|
||||||
|
import { tankAverages } from '../core/blitzstars/tankAverages';
|
||||||
|
import { tankopedia } from '../core/blitzstars/tankopedia';
|
||||||
import calculateWN8 from '../core/statistics/calculateWN8';
|
import calculateWN8 from '../core/statistics/calculateWN8';
|
||||||
import getWN8Percentile from '../core/statistics/getWN8Percentile';
|
import getWN8Percentile from '../core/statistics/getWN8Percentile';
|
||||||
|
import sumStats from '../core/statistics/sumStats';
|
||||||
import { PossiblyPromise } from '../types/possiblyPromise';
|
import { PossiblyPromise } from '../types/possiblyPromise';
|
||||||
|
|
||||||
export default async function today(
|
export default async function today(
|
||||||
@@ -25,7 +25,7 @@ export default async function today(
|
|||||||
showTotal = true,
|
showTotal = true,
|
||||||
naked?: boolean,
|
naked?: boolean,
|
||||||
) {
|
) {
|
||||||
const { diff: diffed, order } = await getDiffedTankStats(
|
const { diff: diffed, order } = await getStatsInPeriod(
|
||||||
server,
|
server,
|
||||||
id,
|
id,
|
||||||
getTimeDaysAgo(server, 1),
|
getTimeDaysAgo(server, 1),
|
||||||
|
|||||||
Reference in new issue
Block a user