mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-21 18:57:03 +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 {
|
||||
inProduction: true,
|
||||
inDevelopment: false,
|
||||
inDevelopment: true,
|
||||
inPublic: true,
|
||||
|
||||
command: new SlashCommandBuilder()
|
||||
|
||||
@@ -25,7 +25,7 @@ export const SKILLED_CLANS: Record<SkilledClan, string> = {
|
||||
|
||||
export default {
|
||||
inProduction: true,
|
||||
inDevelopment: false,
|
||||
inDevelopment: true,
|
||||
inPublic: false,
|
||||
|
||||
command: new SlashCommandBuilder()
|
||||
|
||||
@@ -10,7 +10,7 @@ import { client } from '../index.js';
|
||||
|
||||
export default {
|
||||
inProduction: true,
|
||||
inDevelopment: false,
|
||||
inDevelopment: true,
|
||||
inPublic: true,
|
||||
|
||||
command: new SlashCommandBuilder()
|
||||
|
||||
@@ -18,7 +18,7 @@ const DEFAULT_THRESHOLD = 7;
|
||||
|
||||
export default {
|
||||
inProduction: true,
|
||||
inDevelopment: false,
|
||||
inDevelopment: true,
|
||||
inPublic: true,
|
||||
|
||||
command: new SlashCommandBuilder()
|
||||
|
||||
@@ -43,7 +43,7 @@ const COMP_TANKS = [
|
||||
|
||||
export default {
|
||||
inProduction: true,
|
||||
inDevelopment: false,
|
||||
inDevelopment: true,
|
||||
inPublic: true,
|
||||
|
||||
command: new SlashCommandBuilder()
|
||||
|
||||
@@ -3,7 +3,7 @@ import { CommandRegistry } from '../events/interactionCreate.js';
|
||||
|
||||
export default {
|
||||
inProduction: true,
|
||||
inDevelopment: false,
|
||||
inDevelopment: true,
|
||||
inPublic: true,
|
||||
handlesInteraction: true,
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ type SortBy = 'name' | 'count';
|
||||
|
||||
export default {
|
||||
inProduction: true,
|
||||
inDevelopment: false,
|
||||
inDevelopment: true,
|
||||
inPublic: true,
|
||||
|
||||
command: new SlashCommandBuilder()
|
||||
|
||||
@@ -12,7 +12,7 @@ import { AccountInfo } from '../types/accountInfo.js';
|
||||
|
||||
export default {
|
||||
inProduction: true,
|
||||
inDevelopment: false,
|
||||
inDevelopment: true,
|
||||
inPublic: true,
|
||||
|
||||
command: new SlashCommandBuilder()
|
||||
|
||||
@@ -11,7 +11,7 @@ import { ClanList } from '../types/clanList.js';
|
||||
|
||||
export default {
|
||||
inProduction: true,
|
||||
inDevelopment: false,
|
||||
inDevelopment: true,
|
||||
inPublic: true,
|
||||
|
||||
command: new SlashCommandBuilder()
|
||||
|
||||
@@ -12,7 +12,7 @@ import { AccountList } from '../types/accountList.js';
|
||||
|
||||
export default {
|
||||
inProduction: true,
|
||||
inDevelopment: false,
|
||||
inDevelopment: true,
|
||||
inPublic: true,
|
||||
|
||||
command: new SlashCommandBuilder()
|
||||
|
||||
@@ -8,7 +8,7 @@ import { CommandRegistry } from '../events/interactionCreate.js';
|
||||
|
||||
export default {
|
||||
inProduction: true,
|
||||
inDevelopment: false,
|
||||
inDevelopment: true,
|
||||
inPublic: true,
|
||||
|
||||
command: new SlashCommandBuilder()
|
||||
|
||||
@@ -14,7 +14,7 @@ import { PlayerClanData } from '../types/playerClanData.js';
|
||||
|
||||
export default {
|
||||
inProduction: true,
|
||||
inDevelopment: false,
|
||||
inDevelopment: true,
|
||||
inPublic: true,
|
||||
|
||||
command: new SlashCommandBuilder()
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import getWN8Percentile from '../core/blitz/getWN8Percentile.js';
|
||||
import isNumber from '../core/process/isNumber.js';
|
||||
import { AllStats, SupplementaryStats } from '../types/accountInfo.js';
|
||||
import GenericStats from './GenericStats/index.js';
|
||||
|
||||
@@ -22,13 +23,13 @@ export default function GenericAllStats({
|
||||
[
|
||||
'WN8',
|
||||
supplementaryStats
|
||||
? supplementaryStats.WN8 === undefined
|
||||
? '--'
|
||||
: supplementaryStats.WN8.toFixed(0)
|
||||
? isNumber(supplementaryStats.WN8)
|
||||
? supplementaryStats.WN8!.toFixed(0)
|
||||
: '--'
|
||||
: undefined,
|
||||
isNumber(supplementaryStats?.WN8)
|
||||
? getWN8Percentile(supplementaryStats!.WN8!)
|
||||
: undefined,
|
||||
supplementaryStats?.WN8 === undefined
|
||||
? undefined
|
||||
: getWN8Percentile(supplementaryStats.WN8),
|
||||
],
|
||||
[
|
||||
'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') {
|
||||
const entries = Object.entries(tankStats);
|
||||
stats = sumStats(entries.map(([, stats]) => stats));
|
||||
const battles = entries.reduce((accumulator, [tankIdString, stats]) => {
|
||||
const tankId = parseInt(tankIdString);
|
||||
const tankAverage = tankAverages[tankId];
|
||||
const battlesOfTanksWithAverages = entries.reduce(
|
||||
(accumulator, [tankIdString, stats]) => {
|
||||
const tankId = parseInt(tankIdString);
|
||||
const tankAverage = tankAverages[tankId];
|
||||
|
||||
return tankAverage ? accumulator + stats.battles : accumulator;
|
||||
}, 0);
|
||||
return tankAverage ? accumulator + stats.battles : accumulator;
|
||||
},
|
||||
0,
|
||||
);
|
||||
const battlesOfTanksWithTankopediaEntry = entries.reduce(
|
||||
(accumulator, [tankIdString, stats]) => {
|
||||
const tankId = parseInt(tankIdString);
|
||||
const tankopediaEntry = tankopedia[tankId];
|
||||
|
||||
return tankopediaEntry ? accumulator + stats.battles : accumulator;
|
||||
},
|
||||
0,
|
||||
);
|
||||
|
||||
supplementaryStats = {
|
||||
WN8:
|
||||
@@ -73,16 +85,16 @@ export default async function stats<Type extends StatType>(
|
||||
return tankAverage
|
||||
? accumulator + getWN8(tankAverage.all, stats) * stats.battles
|
||||
: accumulator;
|
||||
}, 0) / battles,
|
||||
}, 0) / battlesOfTanksWithAverages,
|
||||
tier:
|
||||
entries.reduce((accumulator, [tankIdString, stats]) => {
|
||||
const tankId = parseInt(tankIdString);
|
||||
const tankAverage = tankAverages[tankId];
|
||||
const tankopediaEntry = tankopedia[tankId];
|
||||
|
||||
return tankAverage
|
||||
? accumulator + tankopedia[tankId].tier * stats.battles
|
||||
return tankopediaEntry
|
||||
? accumulator + tankopediaEntry.tier * stats.battles
|
||||
: accumulator;
|
||||
}, 0) / battles,
|
||||
}, 0) / battlesOfTanksWithTankopediaEntry,
|
||||
};
|
||||
tierWeights = entries.reduce<TierWeightsRecord>(
|
||||
(accumulator, [tankIdString, stats]) => {
|
||||
|
||||
Reference in new issue
Block a user