mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-23 11:39:50 +02:00
fix: port to core 4
This commit is contained in:
1 parent
de6a4d5675
commit
3d23ea1497
68 files changed
+122
-119
No files matched your search
@@ -2,7 +2,7 @@ import { tankDefinitions, tankNames } from '@blitzkit/core';
|
||||
import { Locale } from 'discord.js';
|
||||
import { go } from 'fuzzysort';
|
||||
import markdownEscape from 'markdown-escape';
|
||||
import { UserError } from '../../../../website/src/hooks/userError';
|
||||
import { UserError } from '../blitzkit/userError';
|
||||
import { tankNamesTechTreeOnly } from '../discord/autocompleteTanks';
|
||||
import { translator } from '../localization/translator';
|
||||
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
import { tankDefinitions } from '@blitzkit/core';
|
||||
import { resolveAncestry } from './resolveAncestry';
|
||||
|
||||
export async function buildTechTreeLine(start: number, end: number) {
|
||||
const awaitedTankDefinitions = await tankDefinitions;
|
||||
const endTank = awaitedTankDefinitions[end];
|
||||
if (!endTank.ancestors) throw new Error('End tank has no ancestors');
|
||||
const line = [end];
|
||||
|
||||
if (start === end) return line;
|
||||
for (const ancestorId of endTank.ancestors) {
|
||||
if ((await resolveAncestry(ancestorId)).includes(start)) {
|
||||
const ancestorTree = await buildTechTreeLine(start, ancestorId);
|
||||
line.push(...ancestorTree);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return line;
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
import { idToRegion, usersDatabase } from '@blitzkit/core';
|
||||
import { flagUserActivity } from '../../../../website/src/core/blitzkit/flagUserActivity';
|
||||
import { flagUserActivity, idToRegion, usersDatabase } from '@blitzkit/core';
|
||||
|
||||
export async function getBlitzFromDiscord(discordId: bigint) {
|
||||
const unique = await usersDatabase.discordUser.findUnique({
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { Region } from '@blitzkit/core';
|
||||
import { getTimeDaysAgo } from '../../../../website/src/core/blitzkit/getTimeDaysAgo';
|
||||
import { getTimeDaysAgo, Region } from '@blitzkit/core';
|
||||
import { PeriodSize } from '../discord/addPeriodSubCommands';
|
||||
|
||||
export function getPeriodStart(region: Region, period: PeriodSize) {
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
import { tankDefinitions } from '@blitzkit/core';
|
||||
|
||||
export async function resolveAncestry(id: number) {
|
||||
const awaitedTankDefinitions = await tankDefinitions;
|
||||
const tank = awaitedTankDefinitions[id];
|
||||
const ancestors: number[] = [];
|
||||
|
||||
if (tank.ancestors) {
|
||||
for (const ancestor of tank.ancestors) {
|
||||
if (!ancestors.includes(ancestor)) {
|
||||
ancestors.push(ancestor);
|
||||
|
||||
for (const ancestorLayer2 of await resolveAncestry(ancestor)) {
|
||||
if (!ancestors.includes(ancestorLayer2)) {
|
||||
ancestors.push(ancestorLayer2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ancestors.sort(
|
||||
(a, b) => awaitedTankDefinitions[b].tier - awaitedTankDefinitions[a].tier,
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
/**
|
||||
* Discriminator for user caused errors to not report in logs
|
||||
*/
|
||||
export class UserError {
|
||||
constructor(public message: string) {}
|
||||
}
|
||||
@@ -1,12 +1,12 @@
|
||||
import { Region, emptyAllStats, getTankStats } from '@blitzkit/core';
|
||||
import { Locale } from 'discord.js';
|
||||
import { UserError } from '../../../../website/src/hooks/userError';
|
||||
import {
|
||||
GetHistoriesOptions,
|
||||
Histories,
|
||||
History,
|
||||
getHistoriesDefaultOptions,
|
||||
} from '../../types/histories';
|
||||
import { UserError } from '../blitzkit/userError';
|
||||
import { translator } from '../localization/translator';
|
||||
|
||||
export interface TankHistory extends History {
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { Region, searchClansAcrossRegions } from '@blitzkit/core';
|
||||
import { ChatInputCommandInteraction } from 'discord.js';
|
||||
import markdownEscape from 'markdown-escape';
|
||||
import { UserError } from '../../../../website/src/hooks/userError';
|
||||
import { translator } from '../localization/translator';
|
||||
import { serverAndIdPattern } from './resolvePlayerFromCommand/constants';
|
||||
import { UserError } from '../blitzkit/userError';
|
||||
|
||||
export async function resolveClanFromCommand(
|
||||
interaction: ChatInputCommandInteraction,
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { Region } from '@blitzkit/core';
|
||||
import { getTimeDaysAgo, Region } from '@blitzkit/core';
|
||||
import { ButtonInteraction } from 'discord.js';
|
||||
import { getTimeDaysAgo } from '../../../../website/src/core/blitzkit/getTimeDaysAgo';
|
||||
import { getPeriodNow } from '../blitzkit/getPeriodNow';
|
||||
import { getPeriodStart } from '../blitzkit/getPeriodStart';
|
||||
import { PeriodType } from './addPeriodSubCommands';
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { Region } from '@blitzkit/core';
|
||||
import { getTimeDaysAgo, Region } from '@blitzkit/core';
|
||||
import { CacheType, ChatInputCommandInteraction } from 'discord.js';
|
||||
import { getTimeDaysAgo } from '../../../../website/src/core/blitzkit/getTimeDaysAgo';
|
||||
import { getPeriodNow } from '../blitzkit/getPeriodNow';
|
||||
import { getPeriodStart } from '../blitzkit/getPeriodStart';
|
||||
import { translator } from '../localization/translator';
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { Region, searchPlayersAcrossRegions } from '@blitzkit/core';
|
||||
import { CacheType, ChatInputCommandInteraction } from 'discord.js';
|
||||
import markdownEscape from 'markdown-escape';
|
||||
import { UserError } from '../../../../../website/src/hooks/userError';
|
||||
import { getBlitzFromDiscord } from '../../blitzkit/getBlitzFromDiscord';
|
||||
import { translator } from '../../localization/translator';
|
||||
import { serverAndIdPattern } from './constants';
|
||||
import { UserError } from '../../blitzkit/userError';
|
||||
|
||||
export interface ResolvedPlayer {
|
||||
region: Region;
|
||||
|
||||
Reference in new issue
Block a user