feat: swap core and _core

This commit is contained in:
TrèsAbhi committed 2023-10-14 11:06:03 -05:00
1 parent 07e3660388
commit b827f7f730
113 files changed
+254 -247

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
View File
@@ -1,4 +0,0 @@
type Context = 'website' | 'bot';
export const context: Context =
typeof window === 'undefined' ? 'bot' : 'website';
+3
View File
@@ -0,0 +1,3 @@
export function emblemIdToURL(emblemId: number) {
return `https://wotblitz-gc.gcdn.co/icons/clanEmblems1x/clan-icon-v2-${emblemId}.png`;
}
@@ -1,23 +0,0 @@
import { StatFilters } from '../../_core/statistics/filterStats';
import { TREE_TYPE_NAMES } from '../../components/Tanks';
import resolveTankName from '../blitz/resolveTankName';
import { TIER_ROMAN_NUMERALS, Tier, tankopediaInfo } from '../blitz/tankopedia';
export async function filtersToDescription({
nation,
tier,
tankType,
treeType,
tank,
}: StatFilters) {
const awaitedTankopediaInfo = await tankopediaInfo;
const info: string[] = [];
if (tank) return await resolveTankName(tank);
if (nation) info.push(awaitedTankopediaInfo.vehicle_nations[nation]);
if (tier) info.push(`Tier ${TIER_ROMAN_NUMERALS[tier as Tier]}`);
if (tankType) info.push(awaitedTankopediaInfo.vehicle_types[tankType]);
if (treeType) info.push(TREE_TYPE_NAMES[treeType]);
return info.length === 0 ? 'No filters' : info.join(', ');
}
@@ -0,0 +1,45 @@
import { RatingsInfo } from '../../commands/ratings';
import { Region } from '../../constants/regions';
import { DATABASE_REPO } from '../../LEGACY_core/database/getMidnightLeaderboard';
import { octokit } from '../../LEGACY_core/github/octokit';
import throwError from '../../LEGACY_core/node/throwError';
const ARCHIVED_RATINGS_CACHE: Record<
Region,
Record<
number,
RatingsInfo & {
detail: undefined;
}
>
> = {
com: {},
eu: {},
asia: {},
};
export default async function getArchivedRatingsInfo(
season: number,
region: Region,
) {
if (ARCHIVED_RATINGS_CACHE[region][season]) {
return ARCHIVED_RATINGS_CACHE[region][season];
}
const { data } = await octokit.repos.getContent({
...DATABASE_REPO,
path: `${region}/ratings/${season}/info.json`,
});
if (Array.isArray(data) || data.type !== 'file')
throw throwError('Archived ratings info is malformed');
const content = Buffer.from(data.content, 'base64').toString();
const jsonContent = JSON.parse(content) as RatingsInfo & {
detail: undefined;
};
ARCHIVED_RATINGS_CACHE[region][season] = jsonContent;
return jsonContent;
}
-22
View File
@@ -1,22 +0,0 @@
import { AllStats } from '../../_core/blitz/getAccountInfo';
import { TierWeightsRecord } from '../../components/TierWeights';
import { tankopedia } from '../blitz/tankopedia';
export async function getTierWeights(
stats: Record<number, AllStats>,
order: number[] = Object.keys(stats).map(parseInt),
) {
const awaitedTankopedia = await tankopedia;
const tierWeights: TierWeightsRecord = {};
order.map((id) => {
const entry = awaitedTankopedia[id];
if (!entry) return;
if (!tierWeights[entry.tier]) tierWeights[entry.tier] = 0;
tierWeights[entry.tier]! += stats[id].battles;
});
return tierWeights;
}