mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-24 12:09:51 +02:00
feat: cleaned up directories
This commit is contained in:
1 parent
473ebfa46c
commit
613527e78f
41 files changed
+116
-832
No files matched your search
@@ -1,8 +1,8 @@
|
|||||||
import { Client, EmbedBuilder, TextChannel } from 'discord.js';
|
import { Client, EmbedBuilder, TextChannel } from 'discord.js';
|
||||||
import discord from '../../discord.json' assert { type: 'json' };
|
import discord from '../../discord.json' assert { type: 'json' };
|
||||||
import { NEGATIVE_COLOR } from '../constants/colors.js';
|
import { NEGATIVE_COLOR } from '../constants/colors.js';
|
||||||
|
import isDev from '../core/process/isDev.js';
|
||||||
import { client } from '../index.js';
|
import { client } from '../index.js';
|
||||||
import isDev from '../utilities/isDev.js';
|
|
||||||
|
|
||||||
const PROCESS_ERROR_EVENTS = ['uncaughtException'];
|
const PROCESS_ERROR_EVENTS = ['uncaughtException'];
|
||||||
const CLIENT_ERROR_EVENTS = ['error'];
|
const CLIENT_ERROR_EVENTS = ['error'];
|
||||||
|
|||||||
@@ -11,9 +11,9 @@ import {
|
|||||||
} from 'discord.js';
|
} from 'discord.js';
|
||||||
import { readdirSync } from 'fs';
|
import { readdirSync } from 'fs';
|
||||||
import discord from '../../discord.json' assert { type: 'json' };
|
import discord from '../../discord.json' assert { type: 'json' };
|
||||||
import { args } from '../utilities/args.js';
|
import { args } from '../core/process/args.js';
|
||||||
import getClientId from '../utilities/getClientId.js';
|
import getClientId from '../core/process/getClientId.js';
|
||||||
import isDev from '../utilities/isDev.js';
|
import isDev from '../core/process/isDev.js';
|
||||||
|
|
||||||
export interface CommandRegistry {
|
export interface CommandRegistry {
|
||||||
inDevelopment: boolean; // register with Skilled Bot (default: false)
|
inDevelopment: boolean; // register with Skilled Bot (default: false)
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { Client, EmbedBuilder, TextChannel } from 'discord.js';
|
import { Client, EmbedBuilder, TextChannel } from 'discord.js';
|
||||||
import discord from '../../discord.json' assert { type: 'json' };
|
import discord from '../../discord.json' assert { type: 'json' };
|
||||||
import { POSITIVE_COLOR } from '../constants/colors.js';
|
import { POSITIVE_COLOR } from '../constants/colors.js';
|
||||||
import isDev from '../utilities/isDev.js';
|
import isDev from '../core/process/isDev.js';
|
||||||
|
|
||||||
export default function ready(client: Client<true>) {
|
export default function ready(client: Client<true>) {
|
||||||
(
|
(
|
||||||
|
|||||||
@@ -2,17 +2,16 @@ import { EmbedBuilder, SlashCommandBuilder } from 'discord.js';
|
|||||||
import packageJSON from '../../package.json' assert { type: 'json' };
|
import packageJSON from '../../package.json' assert { type: 'json' };
|
||||||
import { CommandRegistry } from '../behaviors/interactionCreate.js';
|
import { CommandRegistry } from '../behaviors/interactionCreate.js';
|
||||||
import { SKILLED_COLOR } from '../constants/colors.js';
|
import { SKILLED_COLOR } from '../constants/colors.js';
|
||||||
|
import { tankopedia } from '../core/blitzstars/tankopedia.js';
|
||||||
|
import cmdName from '../core/interaction/cmdName.js';
|
||||||
|
import getClientId from '../core/process/getClientId.js';
|
||||||
import { client } from '../index.js';
|
import { client } from '../index.js';
|
||||||
import cmdName from '../utilities/cmdName.js';
|
|
||||||
import getClientId from '../utilities/getClientId.js';
|
|
||||||
import { tankAverages } from '../utilities/tankAverages.js';
|
|
||||||
import { tankopedia } from '../utilities/tankopedia.js';
|
|
||||||
|
|
||||||
const executionStart = new Date().getTime();
|
const executionStart = new Date().getTime();
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
inProduction: true,
|
inProduction: true,
|
||||||
inDevelopment: false,
|
inDevelopment: true,
|
||||||
inPublic: true,
|
inPublic: true,
|
||||||
|
|
||||||
command: new SlashCommandBuilder()
|
command: new SlashCommandBuilder()
|
||||||
@@ -37,8 +36,6 @@ export default {
|
|||||||
uptime % 1000,
|
uptime % 1000,
|
||||||
)}ms\n**Tankopedia**: ${
|
)}ms\n**Tankopedia**: ${
|
||||||
tankopedia ? 'cached' : 'not cached'
|
tankopedia ? 'cached' : 'not cached'
|
||||||
}\n**Tank averages**: ${
|
|
||||||
tankAverages ? 'cached' : 'not cached'
|
|
||||||
}\n**Client ID**: ${getClientId()}\n**Tag**: ${
|
}\n**Client ID**: ${getClientId()}\n**Tag**: ${
|
||||||
interaction.client.user.tag
|
interaction.client.user.tag
|
||||||
}`,
|
}`,
|
||||||
|
|||||||
@@ -3,13 +3,13 @@ import markdownEscape from 'markdown-escape';
|
|||||||
import { CommandRegistry } from '../behaviors/interactionCreate.js';
|
import { CommandRegistry } from '../behaviors/interactionCreate.js';
|
||||||
import { NEGATIVE_COLOR, POSITIVE_COLOR } from '../constants/colors.js';
|
import { NEGATIVE_COLOR, POSITIVE_COLOR } from '../constants/colors.js';
|
||||||
import { BlitzServer } from '../constants/servers.js';
|
import { BlitzServer } from '../constants/servers.js';
|
||||||
import addIGNOption from '../utilities/addIGNOption.js';
|
import getBlitzAccount from '../core/blitz/getBlitzAccount.js';
|
||||||
import addServerChoices from '../utilities/addServerChoices.js';
|
import blitzStarsLinks from '../core/blitzstars/blitzStarsLinks.js';
|
||||||
import blitzLinks from '../utilities/blitzLinks.js';
|
import getBlitzStarsAccount from '../core/blitzstars/getBlitzStarsAccount.js';
|
||||||
import cmdName from '../utilities/cmdName.js';
|
import poweredByBlitzStars from '../core/blitzstars/poweredByBlitzStars.js';
|
||||||
import getBlitzAccount from '../utilities/getBlitzAccount.js';
|
import cmdName from '../core/interaction/cmdName.js';
|
||||||
import getBlitzStarsAccount from '../utilities/getBlitzStarsAccount.js';
|
import addIGNOption from '../core/options/addIGNOption.js';
|
||||||
import poweredByBlitzStars from '../utilities/poweredByBlitzStars.js';
|
import addServerChoices from '../core/options/addServerChoices.js';
|
||||||
|
|
||||||
const CLANS = {
|
const CLANS = {
|
||||||
sklld: { id: 71559, name: 'Skilled' },
|
sklld: { id: 71559, name: 'Skilled' },
|
||||||
@@ -18,7 +18,7 @@ const CLANS = {
|
|||||||
|
|
||||||
export default {
|
export default {
|
||||||
inProduction: false,
|
inProduction: false,
|
||||||
inDevelopment: false,
|
inDevelopment: true,
|
||||||
inPublic: false,
|
inPublic: false,
|
||||||
|
|
||||||
command: new SlashCommandBuilder()
|
command: new SlashCommandBuilder()
|
||||||
@@ -133,7 +133,7 @@ export default {
|
|||||||
)}'s shortcomings for ${CLANS[clan].name} (${
|
)}'s shortcomings for ${CLANS[clan].name} (${
|
||||||
clan === 'sklld' ? '30 days stats' : 'career stats'
|
clan === 'sklld' ? '30 days stats' : 'career stats'
|
||||||
}):\n\n${issues.join('\n')}`
|
}):\n\n${issues.join('\n')}`
|
||||||
}\n\n${blitzLinks(server, blitzAccount.nickname)}`,
|
}\n\n${blitzStarsLinks(server, blitzAccount.nickname)}`,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -6,12 +6,12 @@ import {
|
|||||||
publicCommands,
|
publicCommands,
|
||||||
} from '../behaviors/interactionCreate.js';
|
} from '../behaviors/interactionCreate.js';
|
||||||
import { SKILLED_COLOR } from '../constants/colors.js';
|
import { SKILLED_COLOR } from '../constants/colors.js';
|
||||||
|
import cmdName from '../core/interaction/cmdName.js';
|
||||||
import { client } from '../index.js';
|
import { client } from '../index.js';
|
||||||
import cmdName from '../utilities/cmdName.js';
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
inProduction: true,
|
inProduction: true,
|
||||||
inDevelopment: false,
|
inDevelopment: true,
|
||||||
inPublic: true,
|
inPublic: true,
|
||||||
|
|
||||||
command: new SlashCommandBuilder()
|
command: new SlashCommandBuilder()
|
||||||
|
|||||||
@@ -3,26 +3,26 @@ import markdownEscape from 'markdown-escape';
|
|||||||
import { CommandRegistry } from '../behaviors/interactionCreate.js';
|
import { CommandRegistry } from '../behaviors/interactionCreate.js';
|
||||||
import { NEGATIVE_COLOR, POSITIVE_COLOR } from '../constants/colors.js';
|
import { NEGATIVE_COLOR, POSITIVE_COLOR } from '../constants/colors.js';
|
||||||
import { BlitzServer } from '../constants/servers.js';
|
import { BlitzServer } from '../constants/servers.js';
|
||||||
|
import getClan from '../core/blitz/getClan.js';
|
||||||
|
import getWargamingResponse from '../core/blitz/getWargamingResponse.js';
|
||||||
|
import cmdName from '../core/interaction/cmdName.js';
|
||||||
|
import addServerChoices from '../core/options/addServerChoices.js';
|
||||||
|
import { args } from '../core/process/args.js';
|
||||||
import { AccountInfo } from '../types/accountInfo.js';
|
import { AccountInfo } from '../types/accountInfo.js';
|
||||||
import { ClanInfo } from '../types/clanInfo.js';
|
import { ClanInfo } from '../types/clanInfo.js';
|
||||||
import { Clan } from '../types/clanList.js';
|
import { Clan } from '../types/clanList.js';
|
||||||
import addServerChoices from '../utilities/addServerChoices.js';
|
|
||||||
import { args } from '../utilities/args.js';
|
|
||||||
import cmdName from '../utilities/cmdName.js';
|
|
||||||
import getClan from '../utilities/getClan.js';
|
|
||||||
import getWargamingResponse from '../utilities/getWargamingResponse.js';
|
|
||||||
|
|
||||||
const DEFAULT_THRESHOLD = 7;
|
const DEFAULT_THRESHOLD = 7;
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
inProduction: true,
|
inProduction: true,
|
||||||
inDevelopment: false,
|
inDevelopment: true,
|
||||||
inPublic: true,
|
inPublic: true,
|
||||||
|
|
||||||
command: new SlashCommandBuilder()
|
command: new SlashCommandBuilder()
|
||||||
.setName(cmdName('inactive'))
|
.setName(cmdName('inactive'))
|
||||||
.setDescription('Lists all inactive players')
|
.setDescription('Lists all inactive players')
|
||||||
.addStringOption((option) => addServerChoices(option).setRequired(true))
|
.addStringOption(addServerChoices)
|
||||||
.addStringOption((option) =>
|
.addStringOption((option) =>
|
||||||
option
|
option
|
||||||
.setName('name')
|
.setName('name')
|
||||||
@@ -48,19 +48,17 @@ export default {
|
|||||||
const threshold =
|
const threshold =
|
||||||
interaction.options.getNumber('threshold')! ?? DEFAULT_THRESHOLD;
|
interaction.options.getNumber('threshold')! ?? DEFAULT_THRESHOLD;
|
||||||
const time = new Date().getTime() / 1000;
|
const time = new Date().getTime() / 1000;
|
||||||
|
|
||||||
const clanInfo = await getWargamingResponse<ClanInfo>(
|
const clanInfo = await getWargamingResponse<ClanInfo>(
|
||||||
`https://api.wotblitz.${server}/wotb/clans/info/?application_id=${args['wargaming-application-id']}&clan_id=${clan.clan_id}`,
|
`https://api.wotblitz.${server}/wotb/clans/info/?application_id=${args['wargaming-application-id']}&clan_id=${clan.clan_id}`,
|
||||||
);
|
);
|
||||||
|
if (!clanInfo) return;
|
||||||
const memberIds = clanInfo[clan.clan_id].members_ids;
|
const memberIds = clanInfo[clan.clan_id].members_ids;
|
||||||
|
|
||||||
const accountInfo = await getWargamingResponse<AccountInfo>(
|
const accountInfo = await getWargamingResponse<AccountInfo>(
|
||||||
`https://api.wotblitz.${server}/wotb/account/info/?application_id=${
|
`https://api.wotblitz.${server}/wotb/account/info/?application_id=${
|
||||||
args['wargaming-application-id']
|
args['wargaming-application-id']
|
||||||
}&account_id=${memberIds.join(',')}`,
|
}&account_id=${memberIds.join(',')}`,
|
||||||
);
|
);
|
||||||
|
if (!accountInfo) return;
|
||||||
const inactiveInfo = memberIds
|
const inactiveInfo = memberIds
|
||||||
.map((memberId) => {
|
.map((memberId) => {
|
||||||
const member = accountInfo[memberId];
|
const member = accountInfo[memberId];
|
||||||
|
|||||||
@@ -2,15 +2,15 @@ import { EmbedBuilder, SlashCommandBuilder } from 'discord.js';
|
|||||||
import markdownEscape from 'markdown-escape';
|
import markdownEscape from 'markdown-escape';
|
||||||
import { CommandRegistry } from '../behaviors/interactionCreate.js';
|
import { CommandRegistry } from '../behaviors/interactionCreate.js';
|
||||||
import { SKILLED_COLOR } from '../constants/colors.js';
|
import { SKILLED_COLOR } from '../constants/colors.js';
|
||||||
|
import getWargamingResponse from '../core/blitz/getWargamingResponse.js';
|
||||||
|
import cmdName from '../core/interaction/cmdName.js';
|
||||||
|
import addIGNOption from '../core/options/addIGNOption.js';
|
||||||
|
import addServerChoices from '../core/options/addServerChoices.js';
|
||||||
|
import { args } from '../core/process/args.js';
|
||||||
import { Players } from '../types/players.js';
|
import { Players } from '../types/players.js';
|
||||||
import addIGNOption from '../utilities/addIGNOption.js';
|
|
||||||
import addServerChoices from '../utilities/addServerChoices.js';
|
|
||||||
import { args } from '../utilities/args.js';
|
|
||||||
import cmdName from '../utilities/cmdName.js';
|
|
||||||
import getWargamingResponse from '../utilities/getWargamingResponse.js';
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
inDevelopment: false,
|
inDevelopment: true,
|
||||||
inProduction: true,
|
inProduction: true,
|
||||||
inPublic: true,
|
inPublic: true,
|
||||||
|
|
||||||
@@ -31,10 +31,10 @@ export default {
|
|||||||
const server = interaction.options.getString('server')!;
|
const server = interaction.options.getString('server')!;
|
||||||
const name = interaction.options.getString('name')!;
|
const name = interaction.options.getString('name')!;
|
||||||
const limit = interaction.options.getInteger('limit') ?? 25;
|
const limit = interaction.options.getInteger('limit') ?? 25;
|
||||||
|
|
||||||
const players = await getWargamingResponse<Players>(
|
const players = await getWargamingResponse<Players>(
|
||||||
`https://api.wotblitz.${server}/wotb/account/list/?application_id=${args['wargaming-application-id']}&search=${name}&limit=${limit}`,
|
`https://api.wotblitz.${server}/wotb/account/list/?application_id=${args['wargaming-application-id']}&search=${name}&limit=${limit}`,
|
||||||
);
|
);
|
||||||
|
if (!players) return;
|
||||||
|
|
||||||
await interaction.editReply({
|
await interaction.editReply({
|
||||||
embeds: [
|
embeds: [
|
||||||
|
|||||||
+12
-12
@@ -3,18 +3,18 @@ import markdownEscape from 'markdown-escape';
|
|||||||
import { CommandRegistry } from '../behaviors/interactionCreate.js';
|
import { CommandRegistry } from '../behaviors/interactionCreate.js';
|
||||||
import { SKILLED_COLOR } from '../constants/colors.js';
|
import { SKILLED_COLOR } from '../constants/colors.js';
|
||||||
import { BlitzServer } from '../constants/servers.js';
|
import { BlitzServer } from '../constants/servers.js';
|
||||||
|
import getBlitzAccount from '../core/blitz/getBlitzAccount.js';
|
||||||
|
import getWargamingResponse from '../core/blitz/getWargamingResponse.js';
|
||||||
|
import blitzStarsLinks from '../core/blitzstars/blitzStarsLinks.js';
|
||||||
|
import getBlitzStarsAccount from '../core/blitzstars/getBlitzStarsAccount.js';
|
||||||
|
import poweredByBlitzStars from '../core/blitzstars/poweredByBlitzStars.js';
|
||||||
|
import cleanTable from '../core/interaction/cleanTable.js';
|
||||||
|
import cmdName from '../core/interaction/cmdName.js';
|
||||||
|
import addIGNOption from '../core/options/addIGNOption.js';
|
||||||
|
import addServerChoices from '../core/options/addServerChoices.js';
|
||||||
|
import { args } from '../core/process/args.js';
|
||||||
import { AccountInfo, AllStats } from '../types/accountInfo.js';
|
import { AccountInfo, AllStats } from '../types/accountInfo.js';
|
||||||
import { BlitzStartsComputedPeriodicStatistics } from '../types/statistics.js';
|
import { BlitzStartsComputedPeriodicStatistics } from '../types/statistics.js';
|
||||||
import addIGNOption from '../utilities/addIGNOption.js';
|
|
||||||
import addServerChoices from '../utilities/addServerChoices.js';
|
|
||||||
import { args } from '../utilities/args.js';
|
|
||||||
import blitzLinks from '../utilities/blitzLinks.js';
|
|
||||||
import cleanTable from '../utilities/cleanTable.js';
|
|
||||||
import cmdName from '../utilities/cmdName.js';
|
|
||||||
import getBlitzAccount from '../utilities/getBlitzAccount.js';
|
|
||||||
import getBlitzStarsAccount from '../utilities/getBlitzStarsAccount.js';
|
|
||||||
import getWargamingResponse from '../utilities/getWargamingResponse.js';
|
|
||||||
import poweredByBlitzStars from '../utilities/poweredByBlitzStars.js';
|
|
||||||
|
|
||||||
type Period = 'today' | '30' | '90' | 'career';
|
type Period = 'today' | '30' | '90' | 'career';
|
||||||
|
|
||||||
@@ -27,7 +27,7 @@ const daysInPeriod: Record<Period, number> = {
|
|||||||
|
|
||||||
export default {
|
export default {
|
||||||
inProduction: true,
|
inProduction: true,
|
||||||
inDevelopment: false,
|
inDevelopment: true,
|
||||||
inPublic: true,
|
inPublic: true,
|
||||||
|
|
||||||
command: new SlashCommandBuilder()
|
command: new SlashCommandBuilder()
|
||||||
@@ -201,7 +201,7 @@ export default {
|
|||||||
(stats.all.battles - stats.all.survived_battles)
|
(stats.all.battles - stats.all.survived_battles)
|
||||||
).toFixed(2),
|
).toFixed(2),
|
||||||
],
|
],
|
||||||
])}\n\n${blitzLinks(server, blitzAccount.nickname)}`
|
])}\n\n${blitzStarsLinks(server, blitzAccount.nickname)}`
|
||||||
: 'No battles played in this period.',
|
: 'No battles played in this period.',
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
+12
-12
@@ -3,14 +3,15 @@ import markdownEscape from 'markdown-escape';
|
|||||||
import { CommandRegistry } from '../behaviors/interactionCreate.js';
|
import { CommandRegistry } from '../behaviors/interactionCreate.js';
|
||||||
import { SKILLED_COLOR } from '../constants/colors.js';
|
import { SKILLED_COLOR } from '../constants/colors.js';
|
||||||
import { BlitzServer } from '../constants/servers.js';
|
import { BlitzServer } from '../constants/servers.js';
|
||||||
|
import getBlitzAccount from '../core/blitz/getBlitzAccount.js';
|
||||||
|
import getWargamingResponse from '../core/blitz/getWargamingResponse.js';
|
||||||
|
import { TANK_TYPE_EMOJIS, tankopedia } from '../core/blitzstars/tankopedia.js';
|
||||||
|
import cmdName from '../core/interaction/cmdName.js';
|
||||||
|
import addIGNOption from '../core/options/addIGNOption.js';
|
||||||
|
import addServerChoices from '../core/options/addServerChoices.js';
|
||||||
|
import { args } from '../core/process/args.js';
|
||||||
import { TanksStats } from '../types/tanksStats.js';
|
import { TanksStats } from '../types/tanksStats.js';
|
||||||
import addIGNOption from '../utilities/addIGNOption.js';
|
import resolveTankName from '../utilities/resolveTankName.js';
|
||||||
import addServerChoices from '../utilities/addServerChoices.js';
|
|
||||||
import { args } from '../utilities/args.js';
|
|
||||||
import cmdName from '../utilities/cmdName.js';
|
|
||||||
import getBlitzAccount from '../utilities/getBlitzAccount.js';
|
|
||||||
import getWargamingResponse from '../utilities/getWargamingResponse.js';
|
|
||||||
import { TANK_TYPE_EMOJIS, tankopedia } from '../utilities/tankopedia.js';
|
|
||||||
|
|
||||||
const COMP_TANKS = [
|
const COMP_TANKS = [
|
||||||
// light tanks
|
// light tanks
|
||||||
@@ -35,7 +36,7 @@ const COMP_TANKS = [
|
|||||||
|
|
||||||
export default {
|
export default {
|
||||||
inProduction: true,
|
inProduction: true,
|
||||||
inDevelopment: false,
|
inDevelopment: true,
|
||||||
inPublic: true,
|
inPublic: true,
|
||||||
|
|
||||||
command: new SlashCommandBuilder()
|
command: new SlashCommandBuilder()
|
||||||
@@ -57,12 +58,11 @@ export default {
|
|||||||
const name = interaction.options.getString('name')!;
|
const name = interaction.options.getString('name')!;
|
||||||
const server = interaction.options.getString('server') as BlitzServer;
|
const server = interaction.options.getString('server') as BlitzServer;
|
||||||
const account = await getBlitzAccount(interaction, name, server);
|
const account = await getBlitzAccount(interaction, name, server);
|
||||||
|
|
||||||
if (!account) return;
|
if (!account) return;
|
||||||
|
|
||||||
const tankStats = await getWargamingResponse<TanksStats>(
|
const tankStats = await getWargamingResponse<TanksStats>(
|
||||||
`https://api.wotblitz.${server}/wotb/tanks/stats/?application_id=${args['wargaming-application-id']}&account_id=${account.account_id}`,
|
`https://api.wotblitz.${server}/wotb/tanks/stats/?application_id=${args['wargaming-application-id']}&account_id=${account.account_id}`,
|
||||||
);
|
);
|
||||||
|
if (!tankStats) return;
|
||||||
const tanks = tankStats[account.account_id]
|
const tanks = tankStats[account.account_id]
|
||||||
.map((tankData) => tankopedia.data[tankData.tank_id])
|
.map((tankData) => tankopedia.data[tankData.tank_id])
|
||||||
.filter((tank) => tank.tier === tier);
|
.filter((tank) => tank.tier === tier);
|
||||||
@@ -82,8 +82,8 @@ export default {
|
|||||||
: tanks
|
: tanks
|
||||||
.map(
|
.map(
|
||||||
(tank) =>
|
(tank) =>
|
||||||
`${TANK_TYPE_EMOJIS[tank.type]} ${markdownEscape(
|
`${TANK_TYPE_EMOJIS[tank.type]} ${resolveTankName(
|
||||||
tank.name,
|
tank,
|
||||||
)} ${tank.is_premium ? '⭐' : ''}${
|
)} ${tank.is_premium ? '⭐' : ''}${
|
||||||
COMP_TANKS.includes(tank.tank_id) ? '🏆' : ''
|
COMP_TANKS.includes(tank.tank_id) ? '🏆' : ''
|
||||||
}`,
|
}`,
|
||||||
|
|||||||
+12
-13
@@ -3,24 +3,25 @@ import markdownEscape from 'markdown-escape';
|
|||||||
import { CommandRegistry } from '../behaviors/interactionCreate.js';
|
import { CommandRegistry } from '../behaviors/interactionCreate.js';
|
||||||
import { BlitzServer } from '../constants/servers.js';
|
import { BlitzServer } from '../constants/servers.js';
|
||||||
import tanksAutocomplete from '../core/autocomplete/tanks.js';
|
import tanksAutocomplete from '../core/autocomplete/tanks.js';
|
||||||
|
import getBlitzAccount from '../core/blitz/getBlitzAccount.js';
|
||||||
|
import { tankopedia } from '../core/blitzstars/tankopedia.js';
|
||||||
import getPeriodicStats, {
|
import getPeriodicStats, {
|
||||||
Period,
|
Period,
|
||||||
} from '../core/blitztankstats/getPeriodicStats.js';
|
} from '../core/blitztankstats/getPeriodicStats.js';
|
||||||
import errorEmbed from '../core/embeds/errorEmbed.js';
|
import cleanTable from '../core/interaction/cleanTable.js';
|
||||||
import sklldEmbed from '../core/embeds/sklldEmbed.js';
|
import cmdName from '../core/interaction/cmdName.js';
|
||||||
import addIGNOption from '../utilities/addIGNOption.js';
|
import errorEmbed from '../core/interaction/errorEmbed.js';
|
||||||
import addServerChoices from '../utilities/addServerChoices.js';
|
import sklldEmbed from '../core/interaction/sklldEmbed.js';
|
||||||
import addTankChoices from '../utilities/addTankChoices.js';
|
import addIGNOption from '../core/options/addIGNOption.js';
|
||||||
import cleanTable from '../utilities/cleanTable.js';
|
import addServerChoices from '../core/options/addServerChoices.js';
|
||||||
import cmdName from '../utilities/cmdName.js';
|
import addTankChoices from '../core/options/addTankChoices.js';
|
||||||
import getBlitzAccount from '../utilities/getBlitzAccount.js';
|
import resolveTankName from '../utilities/resolveTankName.js';
|
||||||
import { tankopedia } from '../utilities/tankopedia.js';
|
|
||||||
|
|
||||||
type Periods = '30' | '60' | '90';
|
type Periods = '30' | '60' | '90';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
inProduction: true,
|
inProduction: true,
|
||||||
inDevelopment: false,
|
inDevelopment: true,
|
||||||
inPublic: true,
|
inPublic: true,
|
||||||
|
|
||||||
command: new SlashCommandBuilder()
|
command: new SlashCommandBuilder()
|
||||||
@@ -76,9 +77,7 @@ export default {
|
|||||||
sklldEmbed(
|
sklldEmbed(
|
||||||
`${period} day stats for ${markdownEscape(
|
`${period} day stats for ${markdownEscape(
|
||||||
blitzAccount.nickname,
|
blitzAccount.nickname,
|
||||||
)}'s ${
|
)}'s ${resolveTankName(tank)}`,
|
||||||
tank.name ? markdownEscape(tank.name) : `Unknown Tank ${tankId}`
|
|
||||||
}`,
|
|
||||||
periodicStats.length > 0
|
periodicStats.length > 0
|
||||||
? cleanTable([
|
? cleanTable([
|
||||||
[
|
[
|
||||||
|
|||||||
+12
-15
@@ -4,17 +4,17 @@ import discord from '../../discord.json' assert { type: 'json' };
|
|||||||
import { CommandRegistry } from '../behaviors/interactionCreate.js';
|
import { CommandRegistry } from '../behaviors/interactionCreate.js';
|
||||||
import { NEGATIVE_COLOR, POSITIVE_COLOR } from '../constants/colors.js';
|
import { NEGATIVE_COLOR, POSITIVE_COLOR } from '../constants/colors.js';
|
||||||
import { BlitzServer } from '../constants/servers.js';
|
import { BlitzServer } from '../constants/servers.js';
|
||||||
|
import getBlitzAccount from '../core/blitz/getBlitzAccount.js';
|
||||||
|
import getWargamingResponse from '../core/blitz/getWargamingResponse.js';
|
||||||
|
import cmdName from '../core/interaction/cmdName.js';
|
||||||
|
import addIGNOption from '../core/options/addIGNOption.js';
|
||||||
|
import addServerChoices from '../core/options/addServerChoices.js';
|
||||||
|
import { args } from '../core/process/args.js';
|
||||||
import { PlayerClanData } from '../types/playerClanData.js';
|
import { PlayerClanData } from '../types/playerClanData.js';
|
||||||
import addIGNOption from '../utilities/addIGNOption.js';
|
|
||||||
import addServerChoices from '../utilities/addServerChoices.js';
|
|
||||||
import { args } from '../utilities/args.js';
|
|
||||||
import cmdName from '../utilities/cmdName.js';
|
|
||||||
import getBlitzAccount from '../utilities/getBlitzAccount.js';
|
|
||||||
import getWargamingResponse from '../utilities/getWargamingResponse.js';
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
inProduction: true,
|
inProduction: true,
|
||||||
inDevelopment: false,
|
inDevelopment: true,
|
||||||
inPublic: true,
|
inPublic: true,
|
||||||
|
|
||||||
command: new SlashCommandBuilder()
|
command: new SlashCommandBuilder()
|
||||||
@@ -24,17 +24,14 @@ export default {
|
|||||||
.addStringOption(addIGNOption),
|
.addStringOption(addIGNOption),
|
||||||
|
|
||||||
async execute(interaction) {
|
async execute(interaction) {
|
||||||
let name = interaction.options.getString('name')!;
|
const name = interaction.options.getString('name')!;
|
||||||
const server = interaction.options.getString('server') as BlitzServer;
|
const server = interaction.options.getString('server') as BlitzServer;
|
||||||
const account = await getBlitzAccount(interaction, name, server);
|
const account = await getBlitzAccount(interaction, name, server);
|
||||||
|
|
||||||
if (!account) return;
|
if (!account) return;
|
||||||
|
|
||||||
name = account.nickname;
|
|
||||||
|
|
||||||
const clanData = await getWargamingResponse<PlayerClanData>(
|
const clanData = await getWargamingResponse<PlayerClanData>(
|
||||||
`https://api.wotblitz.${server}/wotb/clans/accountinfo/?application_id=${args['wargaming-application-id']}&account_id=${account.account_id}&extra=clan`,
|
`https://api.wotblitz.${server}/wotb/clans/accountinfo/?application_id=${args['wargaming-application-id']}&account_id=${account.account_id}&extra=clan`,
|
||||||
);
|
);
|
||||||
|
if (!clanData) return;
|
||||||
const clan = clanData[account.account_id]?.clan;
|
const clan = clanData[account.account_id]?.clan;
|
||||||
const clanTag = clan ? ` [${clan!.tag}]` : '';
|
const clanTag = clan ? ` [${clan!.tag}]` : '';
|
||||||
|
|
||||||
@@ -66,7 +63,7 @@ export default {
|
|||||||
|
|
||||||
if (member) {
|
if (member) {
|
||||||
try {
|
try {
|
||||||
await member.setNickname(`${name}${clanTag}`);
|
await member.setNickname(`${account.nickname}${clanTag}`);
|
||||||
|
|
||||||
if (interaction.guildId === discord.guild_id) {
|
if (interaction.guildId === discord.guild_id) {
|
||||||
if (
|
if (
|
||||||
@@ -105,14 +102,14 @@ export default {
|
|||||||
.setTitle(`${interaction.user.username} is verified`)
|
.setTitle(`${interaction.user.username} is verified`)
|
||||||
.setDescription(
|
.setDescription(
|
||||||
`The user is now verified as ${markdownEscape(
|
`The user is now verified as ${markdownEscape(
|
||||||
name,
|
account.nickname,
|
||||||
)}${markdownEscape(clanTag)}`,
|
)}${markdownEscape(clanTag)}`,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log(
|
console.log(
|
||||||
`${interaction.user.username} verified as ${name}${clanTag}`,
|
`${interaction.user.username} verified as ${account.nickname}${clanTag}`,
|
||||||
);
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
await interaction.editReply({
|
await interaction.editReply({
|
||||||
|
|||||||
@@ -4,7 +4,8 @@ import {
|
|||||||
CacheType,
|
CacheType,
|
||||||
} from 'discord.js';
|
} from 'discord.js';
|
||||||
import { go } from 'fuzzysort';
|
import { go } from 'fuzzysort';
|
||||||
import { tanks } from '../../utilities/tankopedia.js';
|
import resolveTankName from '../../utilities/resolveTankName.js';
|
||||||
|
import { tanks } from '../blitzstars/tankopedia.js';
|
||||||
|
|
||||||
export default async function tanksAutocomplete(
|
export default async function tanksAutocomplete(
|
||||||
interaction: AutocompleteInteraction<CacheType>,
|
interaction: AutocompleteInteraction<CacheType>,
|
||||||
@@ -16,9 +17,7 @@ export default async function tanksAutocomplete(
|
|||||||
? go(focusedValue, tanks, { keys: ['name'], limit: 10 }).map(
|
? go(focusedValue, tanks, { keys: ['name'], limit: 10 }).map(
|
||||||
(item) =>
|
(item) =>
|
||||||
({
|
({
|
||||||
name: item.obj.name
|
name: item.obj.name ? item.obj.name : resolveTankName(item.obj),
|
||||||
? item.obj.name
|
|
||||||
: `Unknown Tank ${item.obj.tank_id}`,
|
|
||||||
value: `${item.obj.tank_id}`,
|
value: `${item.obj.tank_id}`,
|
||||||
} satisfies ApplicationCommandOptionChoiceData<string>),
|
} satisfies ApplicationCommandOptionChoiceData<string>),
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -4,10 +4,10 @@ import {
|
|||||||
EmbedBuilder,
|
EmbedBuilder,
|
||||||
} from 'discord.js';
|
} from 'discord.js';
|
||||||
import markdownEscape from 'markdown-escape';
|
import markdownEscape from 'markdown-escape';
|
||||||
import { NEGATIVE_COLOR } from '../constants/colors.js';
|
import { NEGATIVE_COLOR } from '../../constants/colors.js';
|
||||||
import { BLITZ_SERVERS, BlitzServer } from '../constants/servers.js';
|
import { BLITZ_SERVERS, BlitzServer } from '../../constants/servers.js';
|
||||||
import { Players } from '../types/players.js';
|
import { Players } from '../../types/players.js';
|
||||||
import { args } from './args.js';
|
import { args } from '../process/args.js';
|
||||||
import getWargamingResponse from './getWargamingResponse.js';
|
import getWargamingResponse from './getWargamingResponse.js';
|
||||||
|
|
||||||
export default async function getBlitzAccount(
|
export default async function getBlitzAccount(
|
||||||
@@ -4,10 +4,10 @@ import {
|
|||||||
EmbedBuilder,
|
EmbedBuilder,
|
||||||
} from 'discord.js';
|
} from 'discord.js';
|
||||||
import markdownEscape from 'markdown-escape';
|
import markdownEscape from 'markdown-escape';
|
||||||
import { NEGATIVE_COLOR } from '../constants/colors.js';
|
import { NEGATIVE_COLOR } from '../../constants/colors.js';
|
||||||
import { BLITZ_SERVERS, BlitzServer } from '../constants/servers.js';
|
import { BLITZ_SERVERS, BlitzServer } from '../../constants/servers.js';
|
||||||
import { ClanList } from '../types/clanList.js';
|
import { ClanList } from '../../types/clanList.js';
|
||||||
import { args } from './args.js';
|
import { args } from '../process/args.js';
|
||||||
import getWargamingResponse from './getWargamingResponse.js';
|
import getWargamingResponse from './getWargamingResponse.js';
|
||||||
|
|
||||||
export default async function getClan(
|
export default async function getClan(
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import fetch from 'node-fetch';
|
import fetch from 'node-fetch';
|
||||||
import { WargamingResponse } from '../types/wargamingResponse.js';
|
import { WargamingResponse } from '../../types/wargamingResponse.js';
|
||||||
|
|
||||||
export default async function getWargamingResponse<Data extends object>(
|
export default async function getWargamingResponse<Data extends object>(
|
||||||
url: string,
|
url: string,
|
||||||
@@ -3,9 +3,9 @@ import {
|
|||||||
ChatInputCommandInteraction,
|
ChatInputCommandInteraction,
|
||||||
EmbedBuilder,
|
EmbedBuilder,
|
||||||
} from 'discord.js';
|
} from 'discord.js';
|
||||||
import { handleError } from '../behaviors/error.js';
|
import { handleError } from '../../behaviors/error.js';
|
||||||
import { NEGATIVE_COLOR } from '../constants/colors.js';
|
import { NEGATIVE_COLOR } from '../../constants/colors.js';
|
||||||
import { client } from '../index.js';
|
import { client } from '../../index.js';
|
||||||
|
|
||||||
export default async function wargamingError(
|
export default async function wargamingError(
|
||||||
interaction: ChatInputCommandInteraction<CacheType>,
|
interaction: ChatInputCommandInteraction<CacheType>,
|
||||||
File renamed without changes.
@@ -1,5 +1,5 @@
|
|||||||
import { BlitzServer } from '../constants/servers.js';
|
import { BlitzServer } from '../../constants/servers.js';
|
||||||
|
|
||||||
export default function blitzLinks(server: BlitzServer, nickname: string) {
|
export default function blitzStarsLinks(server: BlitzServer, nickname: string) {
|
||||||
return `[View full stats](https://www.blitzstars.com/player/${server}/${nickname}) • [Support BlitzStars](https://www.blitzstars.com/supporters)`;
|
return `[View full stats](https://www.blitzstars.com/player/${server}/${nickname}) • [Support BlitzStars](https://www.blitzstars.com/supporters)`;
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
import { CacheType, ChatInputCommandInteraction } from 'discord.js';
|
import { CacheType, ChatInputCommandInteraction } from 'discord.js';
|
||||||
import fetch from 'node-fetch';
|
import fetch from 'node-fetch';
|
||||||
import { notTrackedByBlitzStars } from '../core/embeds/notTrackedByBlitzStars.js';
|
import { PlayerPeriodicStatsCollection } from '../../types/statistics.js';
|
||||||
import { PlayerPeriodicStatsCollection } from '../types/statistics.js';
|
import { notTrackedByBlitzStars } from '../interaction/notTrackedByBlitzStars.js';
|
||||||
|
|
||||||
export default async function getBlitzStarsAccount(
|
export default async function getBlitzStarsAccount(
|
||||||
interaction: ChatInputCommandInteraction<CacheType>,
|
interaction: ChatInputCommandInteraction<CacheType>,
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import { CacheType, ChatInputCommandInteraction } from 'discord.js';
|
import { CacheType, ChatInputCommandInteraction } from 'discord.js';
|
||||||
import fetch from 'node-fetch';
|
import fetch from 'node-fetch';
|
||||||
import { PlayerStats } from '../types/playerStats.js';
|
import { PlayerStats } from '../../types/playerStats.js';
|
||||||
|
|
||||||
export default async function getPlayerStats(
|
export default async function getPlayerStats(
|
||||||
interaction: ChatInputCommandInteraction<CacheType>,
|
interaction: ChatInputCommandInteraction<CacheType>,
|
||||||
File renamed without changes.
File renamed without changes.
@@ -1,6 +0,0 @@
|
|||||||
import errorEmbed from './errorEmbed.js';
|
|
||||||
|
|
||||||
export const badNicknameFormat = errorEmbed(
|
|
||||||
'Bad nickname format',
|
|
||||||
'I expected your nickname to be... \n\n```\nIN_GAME_NAME (SERVER) [CLAN_TAG]\n```\nUse the `/verify` command to setup your nickname correctly or manually provide me with your in-game name and server in the command.',
|
|
||||||
);
|
|
||||||
File renamed without changes.
@@ -1,4 +1,4 @@
|
|||||||
import isDev from './isDev.js';
|
import isDev from '../process/isDev.js';
|
||||||
|
|
||||||
export default function cmdName(name: string) {
|
export default function cmdName(name: string) {
|
||||||
return isDev() ? `${name}dev` : name;
|
return isDev() ? `${name}dev` : name;
|
||||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -1,5 +1,5 @@
|
|||||||
import { SlashCommandStringOption } from 'discord.js';
|
import { SlashCommandStringOption } from 'discord.js';
|
||||||
import { BLITZ_SERVERS } from '../constants/servers.js';
|
import { BLITZ_SERVERS } from '../../constants/servers.js';
|
||||||
|
|
||||||
export default function addServerChoices(option: SlashCommandStringOption) {
|
export default function addServerChoices(option: SlashCommandStringOption) {
|
||||||
return option
|
return option
|
||||||
File renamed without changes.
File renamed without changes.
@@ -1,4 +1,4 @@
|
|||||||
import discord from '../../discord.json' assert { type: 'json' };
|
import discord from '../../../discord.json' assert { type: 'json' };
|
||||||
import isDev from './isDev.js';
|
import isDev from './isDev.js';
|
||||||
|
|
||||||
export default function getClientId() {
|
export default function getClientId() {
|
||||||
File renamed without changes.
+1
-1
@@ -3,7 +3,7 @@ import { registerErrorHandlers } from './behaviors/error.js';
|
|||||||
import guildMemberAdd from './behaviors/guildMemberAdd.js';
|
import guildMemberAdd from './behaviors/guildMemberAdd.js';
|
||||||
import interactionCreate from './behaviors/interactionCreate.js';
|
import interactionCreate from './behaviors/interactionCreate.js';
|
||||||
import ready from './behaviors/ready.js';
|
import ready from './behaviors/ready.js';
|
||||||
import { args } from './utilities/args.js';
|
import { args } from './core/process/args.js';
|
||||||
|
|
||||||
export const client = new Client({
|
export const client = new Client({
|
||||||
intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMembers],
|
intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMembers],
|
||||||
|
|||||||
@@ -1,8 +0,0 @@
|
|||||||
export default function compoundingAverage(
|
|
||||||
average1: number,
|
|
||||||
battles1: number,
|
|
||||||
average2: number,
|
|
||||||
battles2: number,
|
|
||||||
) {
|
|
||||||
return (average2 * battles2 - average1 * battles1) / (battles2 - battles1);
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
import markdownEscape from 'markdown-escape';
|
||||||
|
|
||||||
|
export default function resolveTankName(tank: {
|
||||||
|
tank_id: number;
|
||||||
|
name?: string;
|
||||||
|
}) {
|
||||||
|
return tank.name ? markdownEscape(tank.name) : `Unknown Tank ${tank.tank_id}`;
|
||||||
|
}
|
||||||
@@ -1,641 +0,0 @@
|
|||||||
import fetch from 'node-fetch';
|
|
||||||
import { AllStats } from '../types/accountInfo.js';
|
|
||||||
|
|
||||||
/*
|
|
||||||
[
|
|
||||||
{
|
|
||||||
"_id": 1,
|
|
||||||
"battle_life_time": 87518,
|
|
||||||
"total_battle_life_time": 875184684,
|
|
||||||
"number_of_players": 10000,
|
|
||||||
"tank_id": 1,
|
|
||||||
"all": {
|
|
||||||
"spotted": 616.4213,
|
|
||||||
"hits": 3994.2422,
|
|
||||||
"wins": 290.8189,
|
|
||||||
"losses": 265.5425,
|
|
||||||
"capture_points": 239.7655,
|
|
||||||
"battles": 567.3393,
|
|
||||||
"damage_dealt": 325559.6622,
|
|
||||||
"damage_received": 316424.7297,
|
|
||||||
"shots": 5125.5252,
|
|
||||||
"max_xp": 1199.4879,
|
|
||||||
"xp": 210141.9274,
|
|
||||||
"frags": 403.2506,
|
|
||||||
"survived_battles": 170.2097,
|
|
||||||
"dropped_capture_points": 619.8172
|
|
||||||
},
|
|
||||||
"special": {
|
|
||||||
"winrate": 51.2601,
|
|
||||||
"damageRatio": 1.0289,
|
|
||||||
"kdr": 1.0154,
|
|
||||||
"damagePerBattle": 573.8359,
|
|
||||||
"killsPerBattle": 0.7108,
|
|
||||||
"hitsPerBattle": 7.0403,
|
|
||||||
"spotsPerBattle": 1.0865,
|
|
||||||
"wpm": 0.1994,
|
|
||||||
"dpm": 223.1938,
|
|
||||||
"kpm": 0.2765,
|
|
||||||
"hitRate": 77.9284,
|
|
||||||
"survivalRate": 30.0014
|
|
||||||
},
|
|
||||||
"percentiles": {
|
|
||||||
"winRate": [
|
|
||||||
43.714,
|
|
||||||
46.429,
|
|
||||||
48.3395,
|
|
||||||
50.101,
|
|
||||||
51.835,
|
|
||||||
53.755,
|
|
||||||
55.8765,
|
|
||||||
58.58,
|
|
||||||
62.749
|
|
||||||
],
|
|
||||||
"damageRatio": [
|
|
||||||
0.622,
|
|
||||||
0.7585,
|
|
||||||
0.861,
|
|
||||||
0.955,
|
|
||||||
1.051,
|
|
||||||
1.1535,
|
|
||||||
1.269,
|
|
||||||
1.428,
|
|
||||||
1.686
|
|
||||||
],
|
|
||||||
"kdr": [
|
|
||||||
0.4935,
|
|
||||||
0.655,
|
|
||||||
0.79,
|
|
||||||
0.9245,
|
|
||||||
1.0665,
|
|
||||||
1.226,
|
|
||||||
1.424,
|
|
||||||
1.702,
|
|
||||||
2.2165
|
|
||||||
],
|
|
||||||
"damagePerBattle": [
|
|
||||||
361.925,
|
|
||||||
437.475,
|
|
||||||
493.325,
|
|
||||||
544.06,
|
|
||||||
593.75,
|
|
||||||
645.125,
|
|
||||||
702.875,
|
|
||||||
776.97,
|
|
||||||
896.835
|
|
||||||
],
|
|
||||||
"killsPerBattle": [
|
|
||||||
0.381,
|
|
||||||
0.489,
|
|
||||||
0.574,
|
|
||||||
0.655,
|
|
||||||
0.735,
|
|
||||||
0.82,
|
|
||||||
0.917,
|
|
||||||
1.0425,
|
|
||||||
1.2385
|
|
||||||
],
|
|
||||||
"hitsPerBattle": [
|
|
||||||
3.9295,
|
|
||||||
4.6525,
|
|
||||||
5.335,
|
|
||||||
6.04,
|
|
||||||
7.0145,
|
|
||||||
8.14,
|
|
||||||
9.343,
|
|
||||||
10.594,
|
|
||||||
12.313
|
|
||||||
],
|
|
||||||
"spotsPerBattle": [
|
|
||||||
0.648,
|
|
||||||
0.789,
|
|
||||||
0.903,
|
|
||||||
1.008,
|
|
||||||
1.11,
|
|
||||||
1.214,
|
|
||||||
1.337,
|
|
||||||
1.474,
|
|
||||||
1.671
|
|
||||||
],
|
|
||||||
"wpm": [
|
|
||||||
0.1582,
|
|
||||||
0.1717,
|
|
||||||
0.182,
|
|
||||||
0.1908,
|
|
||||||
0.1992,
|
|
||||||
0.208,
|
|
||||||
0.2179,
|
|
||||||
0.2295,
|
|
||||||
0.2459
|
|
||||||
],
|
|
||||||
"dpm": [
|
|
||||||
139.612,
|
|
||||||
167.501,
|
|
||||||
188.5304,
|
|
||||||
207.8887,
|
|
||||||
226.5041,
|
|
||||||
246.3742,
|
|
||||||
268.8646,
|
|
||||||
297.8587,
|
|
||||||
339.6516
|
|
||||||
],
|
|
||||||
"kpm": [
|
|
||||||
0.1511,
|
|
||||||
0.1916,
|
|
||||||
0.222,
|
|
||||||
0.2502,
|
|
||||||
0.2791,
|
|
||||||
0.31,
|
|
||||||
0.3448,
|
|
||||||
0.39,
|
|
||||||
0.463
|
|
||||||
],
|
|
||||||
"hitRate": [
|
|
||||||
69.3035,
|
|
||||||
73.4495,
|
|
||||||
75.77,
|
|
||||||
77.587,
|
|
||||||
79.0885,
|
|
||||||
80.4375,
|
|
||||||
81.807,
|
|
||||||
83.251,
|
|
||||||
84.895
|
|
||||||
],
|
|
||||||
"survivalRate": [
|
|
||||||
20.495,
|
|
||||||
24.071,
|
|
||||||
26.696,
|
|
||||||
29.07,
|
|
||||||
31.2725,
|
|
||||||
33.632,
|
|
||||||
36.387,
|
|
||||||
39.651,
|
|
||||||
44.9655
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"percentiles_player_count": 10000,
|
|
||||||
"meanSd": {
|
|
||||||
"winrateMean": 52.6691,
|
|
||||||
"winrateSd": 7.501,
|
|
||||||
"hitRateMean": 76.8419,
|
|
||||||
"hitRateSd": 11.8812,
|
|
||||||
"survivalRateMean": 31.8702,
|
|
||||||
"survivalRateSd": 10.2378,
|
|
||||||
"damageRatioMean": 1.1025,
|
|
||||||
"damageRatioSd": 0.4427,
|
|
||||||
"kdrMean": 1.2394,
|
|
||||||
"kdrSd": 0.7795,
|
|
||||||
"dpbMean": 608.4002,
|
|
||||||
"dpbSd": 217.8841,
|
|
||||||
"kpbMean": 0.774,
|
|
||||||
"kpbSd": 0.3449,
|
|
||||||
"hpbMean": 7.5795,
|
|
||||||
"hpbSd": 3.3543,
|
|
||||||
"spbMean": 1.1317,
|
|
||||||
"spbSd": 0.4135
|
|
||||||
},
|
|
||||||
"shotEff": 81.3044,
|
|
||||||
"last_update": 1678771055585
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"_id": 17,
|
|
||||||
"battle_life_time": 106463,
|
|
||||||
"total_battle_life_time": 1064627816,
|
|
||||||
"number_of_players": 10000,
|
|
||||||
"tank_id": 17,
|
|
||||||
"all": {
|
|
||||||
"spotted": 707.8467,
|
|
||||||
"hits": 3128.9507,
|
|
||||||
"wins": 337.453,
|
|
||||||
"losses": 326.723,
|
|
||||||
"capture_points": 273.1936,
|
|
||||||
"battles": 673.9891,
|
|
||||||
"damage_dealt": 371207.8193,
|
|
||||||
"damage_received": 386415.786,
|
|
||||||
"shots": 4144.258,
|
|
||||||
"max_xp": 1191.7719,
|
|
||||||
"xp": 242667.5486,
|
|
||||||
"frags": 462.8709,
|
|
||||||
"survived_battles": 200.5843,
|
|
||||||
"dropped_capture_points": 595.6305
|
|
||||||
},
|
|
||||||
"special": {
|
|
||||||
"winrate": 50.068,
|
|
||||||
"damageRatio": 0.9606,
|
|
||||||
"kdr": 0.9777,
|
|
||||||
"damagePerBattle": 550.7623,
|
|
||||||
"killsPerBattle": 0.6868,
|
|
||||||
"hitsPerBattle": 4.6424,
|
|
||||||
"spotsPerBattle": 1.0502,
|
|
||||||
"wpm": 0.1902,
|
|
||||||
"dpm": 209.2043,
|
|
||||||
"kpm": 0.2609,
|
|
||||||
"hitRate": 75.5009,
|
|
||||||
"survivalRate": 29.7608
|
|
||||||
},
|
|
||||||
"percentiles": {
|
|
||||||
"winRate": [
|
|
||||||
43.103,
|
|
||||||
45.24,
|
|
||||||
46.8795,
|
|
||||||
48.332,
|
|
||||||
49.8065,
|
|
||||||
51.196,
|
|
||||||
52.918,
|
|
||||||
55.1185,
|
|
||||||
59.0235
|
|
||||||
],
|
|
||||||
"damageRatio": [
|
|
||||||
0.584,
|
|
||||||
0.704,
|
|
||||||
0.789,
|
|
||||||
0.861,
|
|
||||||
0.935,
|
|
||||||
1.018,
|
|
||||||
1.112,
|
|
||||||
1.244,
|
|
||||||
1.465
|
|
||||||
],
|
|
||||||
"kdr": [
|
|
||||||
0.485,
|
|
||||||
0.617,
|
|
||||||
0.726,
|
|
||||||
0.827,
|
|
||||||
0.9345,
|
|
||||||
1.056,
|
|
||||||
1.2155,
|
|
||||||
1.428,
|
|
||||||
1.845
|
|
||||||
],
|
|
||||||
"damagePerBattle": [
|
|
||||||
345.69,
|
|
||||||
412.49,
|
|
||||||
459.44,
|
|
||||||
499.55,
|
|
||||||
540.035,
|
|
||||||
584.985,
|
|
||||||
633.355,
|
|
||||||
699.025,
|
|
||||||
811.67
|
|
||||||
],
|
|
||||||
"killsPerBattle": [
|
|
||||||
0.375,
|
|
||||||
0.465,
|
|
||||||
0.533,
|
|
||||||
0.596,
|
|
||||||
0.659,
|
|
||||||
0.73,
|
|
||||||
0.811,
|
|
||||||
0.918,
|
|
||||||
1.102
|
|
||||||
],
|
|
||||||
"hitsPerBattle": [
|
|
||||||
3.195,
|
|
||||||
3.69,
|
|
||||||
4.068,
|
|
||||||
4.362,
|
|
||||||
4.647,
|
|
||||||
4.9485,
|
|
||||||
5.271,
|
|
||||||
5.656,
|
|
||||||
6.2055
|
|
||||||
],
|
|
||||||
"spotsPerBattle": [
|
|
||||||
0.629,
|
|
||||||
0.752,
|
|
||||||
0.8575,
|
|
||||||
0.956,
|
|
||||||
1.049,
|
|
||||||
1.1465,
|
|
||||||
1.262,
|
|
||||||
1.4,
|
|
||||||
1.603
|
|
||||||
],
|
|
||||||
"wpm": [
|
|
||||||
0.1528,
|
|
||||||
0.1655,
|
|
||||||
0.1743,
|
|
||||||
0.1825,
|
|
||||||
0.19,
|
|
||||||
0.1979,
|
|
||||||
0.2065,
|
|
||||||
0.2171,
|
|
||||||
0.2339
|
|
||||||
],
|
|
||||||
"dpm": [
|
|
||||||
131.2505,
|
|
||||||
155.7725,
|
|
||||||
174.1863,
|
|
||||||
189.9051,
|
|
||||||
205.3328,
|
|
||||||
221.5702,
|
|
||||||
240.8529,
|
|
||||||
264.8677,
|
|
||||||
307.253
|
|
||||||
],
|
|
||||||
"kpm": [
|
|
||||||
0.1463,
|
|
||||||
0.1799,
|
|
||||||
0.2042,
|
|
||||||
0.2268,
|
|
||||||
0.2493,
|
|
||||||
0.2736,
|
|
||||||
0.3036,
|
|
||||||
0.3432,
|
|
||||||
0.4089
|
|
||||||
],
|
|
||||||
"hitRate": [
|
|
||||||
65.617,
|
|
||||||
70.051,
|
|
||||||
72.553,
|
|
||||||
74.549,
|
|
||||||
76.2425,
|
|
||||||
77.7385,
|
|
||||||
79.2765,
|
|
||||||
80.858,
|
|
||||||
83.018
|
|
||||||
],
|
|
||||||
"survivalRate": [
|
|
||||||
20.444,
|
|
||||||
23.447,
|
|
||||||
25.6725,
|
|
||||||
27.725,
|
|
||||||
29.6715,
|
|
||||||
31.6955,
|
|
||||||
33.923,
|
|
||||||
36.803,
|
|
||||||
41.437
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"percentiles_player_count": 10000,
|
|
||||||
"meanSd": {
|
|
||||||
"winrateMean": 50.5356,
|
|
||||||
"winrateSd": 6.6334,
|
|
||||||
"hitRateMean": 74.5835,
|
|
||||||
"hitRateSd": 9.6505,
|
|
||||||
"survivalRateMean": 30.3145,
|
|
||||||
"survivalRateSd": 8.9155,
|
|
||||||
"damageRatioMean": 0.9912,
|
|
||||||
"damageRatioSd": 0.3822,
|
|
||||||
"kdrMean": 1.0923,
|
|
||||||
"kdrSd": 0.6887,
|
|
||||||
"dpbMean": 562.3008,
|
|
||||||
"dpbSd": 195.5684,
|
|
||||||
"kpbMean": 0.7088,
|
|
||||||
"kpbSd": 0.312,
|
|
||||||
"hpbMean": 4.6704,
|
|
||||||
"hpbSd": 1.2382,
|
|
||||||
"spbMean": 1.0833,
|
|
||||||
"spbSd": 0.3853
|
|
||||||
},
|
|
||||||
"shotEff": 154.9048,
|
|
||||||
"last_update": 1677561392794
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"_id": 33,
|
|
||||||
"battle_life_time": 47339,
|
|
||||||
"total_battle_life_time": 473389371,
|
|
||||||
"number_of_players": 10000,
|
|
||||||
"tank_id": 33,
|
|
||||||
"all": {
|
|
||||||
"spotted": 318.6163,
|
|
||||||
"hits": 1918.026,
|
|
||||||
"wins": 161.9938,
|
|
||||||
"losses": 135.1226,
|
|
||||||
"capture_points": 163.6557,
|
|
||||||
"battles": 300.0921,
|
|
||||||
"damage_dealt": 199194.9486,
|
|
||||||
"damage_received": 183696.4883,
|
|
||||||
"shots": 2420.9167,
|
|
||||||
"max_xp": 1377.8881,
|
|
||||||
"xp": 148216.5586,
|
|
||||||
"frags": 257.9868,
|
|
||||||
"survived_battles": 103.0862,
|
|
||||||
"dropped_capture_points": 260.2245
|
|
||||||
},
|
|
||||||
"special": {
|
|
||||||
"winrate": 53.9814,
|
|
||||||
"damageRatio": 1.0844,
|
|
||||||
"kdr": 1.3095,
|
|
||||||
"damagePerBattle": 663.7794,
|
|
||||||
"killsPerBattle": 0.8597,
|
|
||||||
"hitsPerBattle": 6.3915,
|
|
||||||
"spotsPerBattle": 1.0617,
|
|
||||||
"wpm": 0.2053,
|
|
||||||
"dpm": 252.4707,
|
|
||||||
"kpm": 0.327,
|
|
||||||
"hitRate": 79.2273,
|
|
||||||
"survivalRate": 34.3515
|
|
||||||
},
|
|
||||||
"percentiles": {
|
|
||||||
"winRate": [
|
|
||||||
45.669,
|
|
||||||
48.923,
|
|
||||||
51.2915,
|
|
||||||
53.4155,
|
|
||||||
55.4195,
|
|
||||||
57.519,
|
|
||||||
59.783,
|
|
||||||
62.553,
|
|
||||||
66.882
|
|
||||||
],
|
|
||||||
"damageRatio": [
|
|
||||||
0.695,
|
|
||||||
0.839,
|
|
||||||
0.949,
|
|
||||||
1.05,
|
|
||||||
1.156,
|
|
||||||
1.261,
|
|
||||||
1.378,
|
|
||||||
1.5385,
|
|
||||||
1.7965
|
|
||||||
],
|
|
||||||
"kdr": [
|
|
||||||
0.705,
|
|
||||||
0.915,
|
|
||||||
1.086,
|
|
||||||
1.254,
|
|
||||||
1.424,
|
|
||||||
1.617,
|
|
||||||
1.86,
|
|
||||||
2.1795,
|
|
||||||
2.7895
|
|
||||||
],
|
|
||||||
"damagePerBattle": [
|
|
||||||
450.59,
|
|
||||||
533.78,
|
|
||||||
595.96,
|
|
||||||
652.085,
|
|
||||||
702.07,
|
|
||||||
755.18,
|
|
||||||
810.885,
|
|
||||||
880.155,
|
|
||||||
980.285
|
|
||||||
],
|
|
||||||
"killsPerBattle": [
|
|
||||||
0.521,
|
|
||||||
0.653,
|
|
||||||
0.743,
|
|
||||||
0.831,
|
|
||||||
0.912,
|
|
||||||
0.994,
|
|
||||||
1.09,
|
|
||||||
1.208,
|
|
||||||
1.382
|
|
||||||
],
|
|
||||||
"hitsPerBattle": [
|
|
||||||
4.8345,
|
|
||||||
5.4535,
|
|
||||||
5.933,
|
|
||||||
6.3205,
|
|
||||||
6.716,
|
|
||||||
7.0945,
|
|
||||||
7.508,
|
|
||||||
8,
|
|
||||||
8.7625
|
|
||||||
],
|
|
||||||
"spotsPerBattle": [
|
|
||||||
0.67,
|
|
||||||
0.812,
|
|
||||||
0.919,
|
|
||||||
1.0105,
|
|
||||||
1.096,
|
|
||||||
1.188,
|
|
||||||
1.284,
|
|
||||||
1.401,
|
|
||||||
1.568
|
|
||||||
],
|
|
||||||
"wpm": [
|
|
||||||
0.1667,
|
|
||||||
0.1817,
|
|
||||||
0.1923,
|
|
||||||
0.2014,
|
|
||||||
0.2098,
|
|
||||||
0.2185,
|
|
||||||
0.2272,
|
|
||||||
0.2377,
|
|
||||||
0.2524
|
|
||||||
],
|
|
||||||
"dpm": [
|
|
||||||
170.9212,
|
|
||||||
203.7661,
|
|
||||||
227.6935,
|
|
||||||
247.3242,
|
|
||||||
266.3126,
|
|
||||||
284.356,
|
|
||||||
303.8913,
|
|
||||||
325.3216,
|
|
||||||
359.4345
|
|
||||||
],
|
|
||||||
"kpm": [
|
|
||||||
0.2015,
|
|
||||||
0.2506,
|
|
||||||
0.2854,
|
|
||||||
0.3168,
|
|
||||||
0.3443,
|
|
||||||
0.3722,
|
|
||||||
0.4033,
|
|
||||||
0.4413,
|
|
||||||
0.4974
|
|
||||||
],
|
|
||||||
"hitRate": [
|
|
||||||
72.5495,
|
|
||||||
75.8405,
|
|
||||||
77.7595,
|
|
||||||
79.216,
|
|
||||||
80.451,
|
|
||||||
81.597,
|
|
||||||
82.783,
|
|
||||||
83.9565,
|
|
||||||
85.5015
|
|
||||||
],
|
|
||||||
"survivalRate": [
|
|
||||||
24.224,
|
|
||||||
28.201,
|
|
||||||
31.128,
|
|
||||||
33.803,
|
|
||||||
36.3355,
|
|
||||||
38.8445,
|
|
||||||
41.722,
|
|
||||||
45.3425,
|
|
||||||
51.186
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"percentiles_player_count": 10000,
|
|
||||||
"meanSd": {
|
|
||||||
"winrateMean": 55.9148,
|
|
||||||
"winrateSd": 8.2526,
|
|
||||||
"hitRateMean": 79.1161,
|
|
||||||
"hitRateSd": 8.4723,
|
|
||||||
"survivalRateMean": 36.9185,
|
|
||||||
"survivalRateSd": 10.7729,
|
|
||||||
"damageRatioMean": 1.2076,
|
|
||||||
"damageRatioSd": 0.454,
|
|
||||||
"kdrMean": 1.6293,
|
|
||||||
"kdrSd": 0.9557,
|
|
||||||
"dpbMean": 709.1817,
|
|
||||||
"dpbSd": 212.8413,
|
|
||||||
"kpbMean": 0.9358,
|
|
||||||
"kpbSd": 0.3445,
|
|
||||||
"hpbMean": 6.7378,
|
|
||||||
"hpbSd": 1.634,
|
|
||||||
"spbMean": 1.1089,
|
|
||||||
"spbSd": 0.3544
|
|
||||||
},
|
|
||||||
"shotEff": 117.2326,
|
|
||||||
"last_update": 1681791408996
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"_id": 49,
|
|
||||||
"battle_life_time": 107010,
|
|
||||||
"total_battle_life_time": 1070098258,
|
|
||||||
"number_of_players": 10000,
|
|
||||||
"tank_id": 49,
|
|
||||||
"all": {
|
|
||||||
"spotted": 998.0054,
|
|
||||||
"hits": 3884.2635,
|
|
||||||
"wins": 334.7506,
|
|
||||||
"losses": 306.5336,
|
|
||||||
"capture_points": 69.2516,
|
|
||||||
"battles": 646.2226,
|
|
||||||
"damage_dealt": 789251.7596,
|
|
||||||
"damage_received": 715410.0777,
|
|
||||||
"shots": 4686.3514,
|
|
||||||
"max_xp": 1912.2171,
|
|
||||||
"xp": 465914.6865,
|
|
||||||
"frags": 489.4052,
|
|
||||||
"survived_battles": 205.6315,
|
|
||||||
"dropped_capture_points": 272.3055
|
|
||||||
},
|
|
||||||
"special": {
|
|
||||||
"winrate": 51.8011,
|
|
||||||
"damageRatio": 1.1032,
|
|
||||||
"kdr": 1.1108,
|
|
||||||
"damagePerBattle": 1221.3311,
|
|
||||||
"killsPerBattle": 0.7573,
|
|
||||||
"hitsPerBattle": 6.01
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
*/
|
|
||||||
|
|
||||||
export const tankAverages = (await (
|
|
||||||
await fetch('https://www.blitzstars.com/api/tankaverages.json')
|
|
||||||
).json()) as TankAverages;
|
|
||||||
|
|
||||||
export type TankAverages = {
|
|
||||||
_id: number;
|
|
||||||
battle_life_time: number;
|
|
||||||
total_battle_life_time: number;
|
|
||||||
number_of_players: number;
|
|
||||||
tank_id: number;
|
|
||||||
all: AllStats;
|
|
||||||
special: {
|
|
||||||
winrate: number;
|
|
||||||
damageRatio: number;
|
|
||||||
kdr: number;
|
|
||||||
damagePerBattle: number;
|
|
||||||
killsPerBattle: number;
|
|
||||||
hitsPerBattle: number;
|
|
||||||
};
|
|
||||||
}[];
|
|
||||||
@@ -1,59 +0,0 @@
|
|||||||
import { PeriodStatistics } from '../types/statistics.js';
|
|
||||||
import { tankAverages } from './tankAverages.js';
|
|
||||||
|
|
||||||
// const expDmg = 2300;
|
|
||||||
// const expSpot = 1;
|
|
||||||
// const expFrag = 0.5;
|
|
||||||
// const expDef = 5;
|
|
||||||
// const expWinRate = 48;
|
|
||||||
|
|
||||||
const expDmg =
|
|
||||||
tankAverages.reduce((a, b) => a + b.special.damagePerBattle, 0) / tankAverages.length;
|
|
||||||
const expSpot =
|
|
||||||
tankAverages.reduce((a, b) => a + (b.all.spotted / b.all.battles), 0) / tankAverages.length;
|
|
||||||
const expFrag =
|
|
||||||
tankAverages.reduce((a, b) => a + b.special.killsPerBattle, 0) / tankAverages.length;
|
|
||||||
const expDef =
|
|
||||||
tankAverages.reduce((a, b) => a + b.all.capture_points / b.all.battles, 0) /
|
|
||||||
tankAverages.length;
|
|
||||||
const expWinRate =
|
|
||||||
tankAverages.reduce((a, b) => a + b.special.winrate, 0) / tankAverages.length;
|
|
||||||
|
|
||||||
export default function wn8(stats: PeriodStatistics) {
|
|
||||||
const rDAMAGE = stats.special.dpb / expDmg;
|
|
||||||
|
|
||||||
const rDAMAGEc = Math.max(0, (rDAMAGE - 0.22) / (1 - 0.22));
|
|
||||||
|
|
||||||
const rSPOT = stats.special.spb / expSpot;
|
|
||||||
const rFRAG = stats.special.kpb / expFrag;
|
|
||||||
const rDEF = stats.all.capture_points / stats.all.battles / expDef;
|
|
||||||
const rWIN = stats.special.winrate / expWinRate;
|
|
||||||
|
|
||||||
const rFRAGc = Math.max(
|
|
||||||
0,
|
|
||||||
Math.min(rDAMAGEc + 0.2, (rFRAG - 0.12) / (1 - 0.12)),
|
|
||||||
);
|
|
||||||
const rSPOTc = Math.max(
|
|
||||||
0,
|
|
||||||
Math.min(rDAMAGEc + 0.1, (rSPOT - 0.38) / (1 - 0.38)),
|
|
||||||
);
|
|
||||||
const rDEFc = Math.max(0, Math.min(rDAMAGEc + 0.1, (rDEF - 0.1) / (1 - 0.1)));
|
|
||||||
|
|
||||||
let rWINc =
|
|
||||||
0.09 +
|
|
||||||
0.613 * rDAMAGEc +
|
|
||||||
0.131 * rFRAGc * rDAMAGEc +
|
|
||||||
0.097 * rFRAGc * rSPOTc +
|
|
||||||
0.047 * rFRAGc * rDEFc;
|
|
||||||
|
|
||||||
rWINc = Math.max(0, (rWIN - 0.71) / (1 - 0.71));
|
|
||||||
|
|
||||||
const WN8 =
|
|
||||||
980 * rDAMAGEc +
|
|
||||||
210 * rDAMAGEc * rFRAGc +
|
|
||||||
155 * rFRAGc * rSPOTc +
|
|
||||||
75 * rDEFc * rFRAGc +
|
|
||||||
145 * Math.min(1.8, rWINc);
|
|
||||||
|
|
||||||
return WN8;
|
|
||||||
}
|
|
||||||
Reference in new issue
Block a user