mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-24 03:59:50 +02:00
fix: average tiers not showing up in /stats
This commit is contained in:
1 parent
f134efa1e8
commit
8b9f665d47
15 files changed
+44
-28
No files matched your search
@@ -12,7 +12,7 @@ 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()
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ export const SKILLED_CLANS: Record<SkilledClan, string> = {
|
|||||||
|
|
||||||
export default {
|
export default {
|
||||||
inProduction: true,
|
inProduction: true,
|
||||||
inDevelopment: false,
|
inDevelopment: true,
|
||||||
inPublic: false,
|
inPublic: false,
|
||||||
|
|
||||||
command: new SlashCommandBuilder()
|
command: new SlashCommandBuilder()
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import { client } from '../index.js';
|
|||||||
|
|
||||||
export default {
|
export default {
|
||||||
inProduction: true,
|
inProduction: true,
|
||||||
inDevelopment: false,
|
inDevelopment: true,
|
||||||
inPublic: true,
|
inPublic: true,
|
||||||
|
|
||||||
command: new SlashCommandBuilder()
|
command: new SlashCommandBuilder()
|
||||||
|
|||||||
@@ -18,7 +18,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()
|
||||||
|
|||||||
@@ -43,7 +43,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()
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { CommandRegistry } from '../events/interactionCreate.js';
|
|||||||
|
|
||||||
export default {
|
export default {
|
||||||
inProduction: true,
|
inProduction: true,
|
||||||
inDevelopment: false,
|
inDevelopment: true,
|
||||||
inPublic: true,
|
inPublic: true,
|
||||||
handlesInteraction: true,
|
handlesInteraction: true,
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ type SortBy = 'name' | 'count';
|
|||||||
|
|
||||||
export default {
|
export default {
|
||||||
inProduction: true,
|
inProduction: true,
|
||||||
inDevelopment: false,
|
inDevelopment: true,
|
||||||
inPublic: true,
|
inPublic: true,
|
||||||
|
|
||||||
command: new SlashCommandBuilder()
|
command: new SlashCommandBuilder()
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import { AccountInfo } from '../types/accountInfo.js';
|
|||||||
|
|
||||||
export default {
|
export default {
|
||||||
inProduction: true,
|
inProduction: true,
|
||||||
inDevelopment: false,
|
inDevelopment: true,
|
||||||
inPublic: true,
|
inPublic: true,
|
||||||
|
|
||||||
command: new SlashCommandBuilder()
|
command: new SlashCommandBuilder()
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import { ClanList } from '../types/clanList.js';
|
|||||||
|
|
||||||
export default {
|
export default {
|
||||||
inProduction: true,
|
inProduction: true,
|
||||||
inDevelopment: false,
|
inDevelopment: true,
|
||||||
inPublic: true,
|
inPublic: true,
|
||||||
|
|
||||||
command: new SlashCommandBuilder()
|
command: new SlashCommandBuilder()
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import { AccountList } from '../types/accountList.js';
|
|||||||
|
|
||||||
export default {
|
export default {
|
||||||
inProduction: true,
|
inProduction: true,
|
||||||
inDevelopment: false,
|
inDevelopment: true,
|
||||||
inPublic: true,
|
inPublic: true,
|
||||||
|
|
||||||
command: new SlashCommandBuilder()
|
command: new SlashCommandBuilder()
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import { CommandRegistry } from '../events/interactionCreate.js';
|
|||||||
|
|
||||||
export default {
|
export default {
|
||||||
inProduction: true,
|
inProduction: true,
|
||||||
inDevelopment: false,
|
inDevelopment: true,
|
||||||
inPublic: true,
|
inPublic: true,
|
||||||
|
|
||||||
command: new SlashCommandBuilder()
|
command: new SlashCommandBuilder()
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import { PlayerClanData } from '../types/playerClanData.js';
|
|||||||
|
|
||||||
export default {
|
export default {
|
||||||
inProduction: true,
|
inProduction: true,
|
||||||
inDevelopment: false,
|
inDevelopment: true,
|
||||||
inPublic: true,
|
inPublic: true,
|
||||||
|
|
||||||
command: new SlashCommandBuilder()
|
command: new SlashCommandBuilder()
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import getWN8Percentile from '../core/blitz/getWN8Percentile.js';
|
import getWN8Percentile from '../core/blitz/getWN8Percentile.js';
|
||||||
|
import isNumber from '../core/process/isNumber.js';
|
||||||
import { AllStats, SupplementaryStats } from '../types/accountInfo.js';
|
import { AllStats, SupplementaryStats } from '../types/accountInfo.js';
|
||||||
import GenericStats from './GenericStats/index.js';
|
import GenericStats from './GenericStats/index.js';
|
||||||
|
|
||||||
@@ -22,13 +23,13 @@ export default function GenericAllStats({
|
|||||||
[
|
[
|
||||||
'WN8',
|
'WN8',
|
||||||
supplementaryStats
|
supplementaryStats
|
||||||
? supplementaryStats.WN8 === undefined
|
? isNumber(supplementaryStats.WN8)
|
||||||
? '--'
|
? supplementaryStats.WN8!.toFixed(0)
|
||||||
: supplementaryStats.WN8.toFixed(0)
|
: '--'
|
||||||
|
: undefined,
|
||||||
|
isNumber(supplementaryStats?.WN8)
|
||||||
|
? getWN8Percentile(supplementaryStats!.WN8!)
|
||||||
: undefined,
|
: undefined,
|
||||||
supplementaryStats?.WN8 === undefined
|
|
||||||
? undefined
|
|
||||||
: getWN8Percentile(supplementaryStats.WN8),
|
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'Survival',
|
'Survival',
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
export default function isNumber(value: any) {
|
||||||
|
return typeof value === 'number' && !isNaN(value) && isFinite(value);
|
||||||
|
}
|
||||||
+22
-10
@@ -57,12 +57,24 @@ export default async function stats<Type extends StatType>(
|
|||||||
if (type === 'player') {
|
if (type === 'player') {
|
||||||
const entries = Object.entries(tankStats);
|
const entries = Object.entries(tankStats);
|
||||||
stats = sumStats(entries.map(([, stats]) => stats));
|
stats = sumStats(entries.map(([, stats]) => stats));
|
||||||
const battles = entries.reduce((accumulator, [tankIdString, stats]) => {
|
const battlesOfTanksWithAverages = entries.reduce(
|
||||||
const tankId = parseInt(tankIdString);
|
(accumulator, [tankIdString, stats]) => {
|
||||||
const tankAverage = tankAverages[tankId];
|
const tankId = parseInt(tankIdString);
|
||||||
|
const tankAverage = tankAverages[tankId];
|
||||||
|
|
||||||
return tankAverage ? accumulator + stats.battles : accumulator;
|
return tankAverage ? accumulator + stats.battles : accumulator;
|
||||||
}, 0);
|
},
|
||||||
|
0,
|
||||||
|
);
|
||||||
|
const battlesOfTanksWithTankopediaEntry = entries.reduce(
|
||||||
|
(accumulator, [tankIdString, stats]) => {
|
||||||
|
const tankId = parseInt(tankIdString);
|
||||||
|
const tankopediaEntry = tankopedia[tankId];
|
||||||
|
|
||||||
|
return tankopediaEntry ? accumulator + stats.battles : accumulator;
|
||||||
|
},
|
||||||
|
0,
|
||||||
|
);
|
||||||
|
|
||||||
supplementaryStats = {
|
supplementaryStats = {
|
||||||
WN8:
|
WN8:
|
||||||
@@ -73,16 +85,16 @@ export default async function stats<Type extends StatType>(
|
|||||||
return tankAverage
|
return tankAverage
|
||||||
? accumulator + getWN8(tankAverage.all, stats) * stats.battles
|
? accumulator + getWN8(tankAverage.all, stats) * stats.battles
|
||||||
: accumulator;
|
: accumulator;
|
||||||
}, 0) / battles,
|
}, 0) / battlesOfTanksWithAverages,
|
||||||
tier:
|
tier:
|
||||||
entries.reduce((accumulator, [tankIdString, stats]) => {
|
entries.reduce((accumulator, [tankIdString, stats]) => {
|
||||||
const tankId = parseInt(tankIdString);
|
const tankId = parseInt(tankIdString);
|
||||||
const tankAverage = tankAverages[tankId];
|
const tankopediaEntry = tankopedia[tankId];
|
||||||
|
|
||||||
return tankAverage
|
return tankopediaEntry
|
||||||
? accumulator + tankopedia[tankId].tier * stats.battles
|
? accumulator + tankopediaEntry.tier * stats.battles
|
||||||
: accumulator;
|
: accumulator;
|
||||||
}, 0) / battles,
|
}, 0) / battlesOfTanksWithTankopediaEntry,
|
||||||
};
|
};
|
||||||
tierWeights = entries.reduce<TierWeightsRecord>(
|
tierWeights = entries.reduce<TierWeightsRecord>(
|
||||||
(accumulator, [tankIdString, stats]) => {
|
(accumulator, [tankIdString, stats]) => {
|
||||||
|
|||||||
Reference in new issue
Block a user