From 132817dbe0f9ec585a8db2c1f15bf3b17c2a44b2 Mon Sep 17 00:00:00 2001 From: tresabhi Date: Sat, 3 Jun 2023 00:32:50 +0000 Subject: [PATCH 1/4] feat: disabled image encoding --- package.json | 2 +- src/commands/stats.tsx | 2 +- src/core/blitz/tankopedia.ts | 27 +++++++++++++-------------- 3 files changed, 15 insertions(+), 16 deletions(-) diff --git a/package.json b/package.json index 9261c5965..ab9f3d934 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "blitzkrieg", - "version": "1.5.1", + "version": "1.5.2", "description": "", "main": "index.js", "type": "module", diff --git a/src/commands/stats.tsx b/src/commands/stats.tsx index 47e4ce267..ee6e30b45 100644 --- a/src/commands/stats.tsx +++ b/src/commands/stats.tsx @@ -39,7 +39,7 @@ import { PlayerClanData } from '../types/playerClanData.js'; export default { inProduction: true, - inDevelopment: false, + inDevelopment: true, inPublic: true, command: new SlashCommandBuilder() diff --git a/src/core/blitz/tankopedia.ts b/src/core/blitz/tankopedia.ts index 876f5b7b3..3889df0c3 100644 --- a/src/core/blitz/tankopedia.ts +++ b/src/core/blitz/tankopedia.ts @@ -1,5 +1,4 @@ import { WargamingResponse } from '../../types/wargamingResponse.js'; -import URLToBase64 from '../ui/URLToBase64.js'; /* "1": { @@ -57,16 +56,16 @@ export const TANK_IDS = Object.keys(tankopedia).map((id) => Number(id)); export const TANKS = TANK_IDS.map((id) => tankopedia[id]); export const TANK_NAMES = TANKS.map((tank) => tank.name); -console.log('Encoding tank images...'); -await Promise.all( - Object.entries(tankopedia).map(async ([, tank]) => { - try { - tank.images.normal = await URLToBase64(tank.images.normal); - } catch (error) { - console.warn( - `Failed to encode tank image for ${tank.images.normal}: ${error}`, - ); - } - }), -); -console.log('Encoded tank images'); +// console.log('Encoding tank images...'); +// await Promise.all( +// Object.entries(tankopedia).map(async ([, tank]) => { +// try { +// tank.images.normal = await URLToBase64(tank.images.normal); +// } catch (error) { +// console.warn( +// `Failed to encode tank image for ${tank.images.normal}: ${error}`, +// ); +// } +// }), +// ); +// console.log('Encoded tank images'); From bf9f3ce20e43cf442f511f0f5d7bfe27b50b54bb Mon Sep 17 00:00:00 2001 From: tresabhi Date: Sat, 3 Jun 2023 00:38:57 +0000 Subject: [PATCH 2/4] fix: edge case; new tanks don't have averages --- src/commands/stats.tsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/commands/stats.tsx b/src/commands/stats.tsx index ee6e30b45..1ed746868 100644 --- a/src/commands/stats.tsx +++ b/src/commands/stats.tsx @@ -88,9 +88,12 @@ export default { WN8: entries.reduce((accumulator, [tankIdString, stats]) => { const tankId = Number(tankIdString); - const tankWN8 = getWN8(tankAverages[tankId].all, stats); - return accumulator + tankWN8 * stats.battles; + // edge case where new tanks don't have averages + if (tankAverages[tankId]) { + const tankWN8 = getWN8(tankAverages[tankId].all, stats); + return accumulator + tankWN8 * stats.battles; + } else return accumulator; }, 0) / totalBattles, }; From dd2052c421ccea11bc50cf3edd260789885f684c Mon Sep 17 00:00:00 2001 From: tresabhi Date: Sat, 3 Jun 2023 00:41:15 +0000 Subject: [PATCH 3/4] fix: removed very large image prompt --- src/commands/today.tsx | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/commands/today.tsx b/src/commands/today.tsx index f3e0afa0c..1695acd7a 100644 --- a/src/commands/today.tsx +++ b/src/commands/today.tsx @@ -21,7 +21,6 @@ import last5AM from '../core/blitzstars/last5AM.js'; import { tankAverages } from '../core/blitzstars/tankAverages.js'; import cmdName from '../core/interaction/cmdName.js'; import fullBlitzStarsStats from '../core/interaction/fullBlitzStarsStats.js'; -import infoEmbed from '../core/interaction/infoEmbed.js'; import { supportBlitzStars } from '../core/interaction/supportBlitzStars.js'; import addUsernameOption from '../core/options/addUsernameOption.js'; import { args } from '../core/process/args.js'; @@ -33,7 +32,7 @@ import { TanksStats } from '../types/tanksStats.js'; export default { inProduction: true, - inDevelopment: false, + inDevelopment: true, inPublic: true, command: new SlashCommandBuilder() @@ -189,10 +188,6 @@ export default { ); await interaction.editReply({ - embeds: - rows.length >= 6 - ? [infoEmbed('Very large image!', "Don't forget to oom in.")] - : undefined, files: [image], components: [actionRow], }); From b12f9846331a07a67ec50a59983b8636a8bbee08 Mon Sep 17 00:00:00 2001 From: tresabhi Date: Sat, 3 Jun 2023 00:54:13 +0000 Subject: [PATCH 4/4] fix: /today cooperation with tanks without WN8 --- src/commands/today.tsx | 10 +++++----- src/components/Breakdown/components/Row.tsx | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/commands/today.tsx b/src/commands/today.tsx index 1695acd7a..6328760ca 100644 --- a/src/commands/today.tsx +++ b/src/commands/today.tsx @@ -82,7 +82,7 @@ export default { (accumulator, [tankIdString, tankStats]) => { const tankId = Number(tankIdString); - return tankId === 0 + return tankId === 0 || tankAverages[tankId] === undefined ? accumulator : { ...accumulator, @@ -92,10 +92,10 @@ export default { {}, ); const careerWN8s = tankStatsOverTimeEntries.reduce>( - (accumulator, [tankIdString, tankStats]) => { + (accumulator, [tankIdString]) => { const tankId = Number(tankIdString); - return tankId === 0 + return tankId === 0 || tankAverages[tankId] === undefined ? accumulator : { ...accumulator, @@ -140,8 +140,8 @@ export default { name={tankId === 0 ? 'Total' : resolveTankName(Number(tankIdString))} winrate={tankStats.wins / tankStats.battles} careerWinrate={career.wins / career.battles} - WN8={todayWN8s[tankId]} - careerWN8={careerWN8s[tankId]} + WN8={isNaN(todayWN8s[tankId]) ? undefined : todayWN8s[tankId]} + careerWN8={isNaN(careerWN8s[tankId]) ? undefined : careerWN8s[tankId]} damage={tankStats.damage_dealt / tankStats.battles} careerDamage={career.damage_dealt / career.battles} survival={tankStats.survived_battles / tankStats.battles} diff --git a/src/components/Breakdown/components/Row.tsx b/src/components/Breakdown/components/Row.tsx index 0d5f8e125..11eac9794 100644 --- a/src/components/Breakdown/components/Row.tsx +++ b/src/components/Breakdown/components/Row.tsx @@ -6,8 +6,8 @@ export interface RowProps { name: string; winrate: number; careerWinrate: number; - WN8: number; - careerWN8: number; + WN8?: number; + careerWN8?: number; damage: number; careerDamage: number; survival: number; @@ -42,9 +42,9 @@ export function Row({ />