feat: 1.3.3

This commit is contained in:
TresAbhi committed 2023-05-29 17:12:05 +00:00
1 parent d62708c21e
commit 7a6de17c1c
5 files changed
+45 -37

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "blitzkrieg",
"version": "1.3.2",
"version": "1.3.3",
"description": "",
"main": "index.js",
"type": "module",
+1 -1
View File
@@ -35,7 +35,7 @@ const periodNames: Record<Period, string> = {
export default {
inProduction: true,
inDevelopment: false,
inDevelopment: true,
inPublic: true,
command: new SlashCommandBuilder()
+3 -2
View File
@@ -11,10 +11,11 @@ export default function GenericStats({
stats,
columnCount = 2,
}: GenericStatsProps) {
const itemsPerRow = Math.ceil(stats.length / columnCount);
const filteredStats = stats.filter(([, value]) => value !== `${-Infinity}`);
const itemsPerRow = Math.ceil(filteredStats.length / columnCount);
const columns: Stat[][] = [];
stats.forEach((stat, index) => {
filteredStats.forEach((stat, index) => {
const column = Math.floor(index / itemsPerRow);
if (!columns[column]) columns[column] = [];
columns[column].push(stat);
+22 -19
View File
@@ -95,25 +95,28 @@ export default async function getTankStatsOverTime(
return Math.max(get(latest.all), get(previous.all));
}
tanksBeforeAndAfter[tankId] = {
battles: diff((a) => a.battles),
capture_points: diff((a) => a.capture_points),
damage_dealt: diff((a) => a.damage_dealt),
damage_received: diff((a) => a.damage_received),
dropped_capture_points: diff((a) => a.dropped_capture_points),
frags: diff((a) => a.frags),
frags8p: diff((a) => a.frags8p),
hits: diff((a) => a.hits),
losses: diff((a) => a.losses),
max_frags: max((a) => a.max_frags),
max_xp: max((a) => a.max_xp),
shots: diff((a) => a.shots),
spotted: diff((a) => a.spotted),
survived_battles: diff((a) => a.survived_battles),
win_and_survived: diff((a) => a.win_and_survived),
wins: diff((a) => a.wins),
xp: diff((a) => a.xp),
};
// check if there was a change in battles as games in ratings do update last_battle_time
if (diff((a) => a.battles) > 0) {
tanksBeforeAndAfter[tankId] = {
battles: diff((a) => a.battles),
capture_points: diff((a) => a.capture_points),
damage_dealt: diff((a) => a.damage_dealt),
damage_received: diff((a) => a.damage_received),
dropped_capture_points: diff((a) => a.dropped_capture_points),
frags: diff((a) => a.frags),
frags8p: diff((a) => a.frags8p),
hits: diff((a) => a.hits),
losses: diff((a) => a.losses),
max_frags: max((a) => a.max_frags),
max_xp: max((a) => a.max_xp),
shots: diff((a) => a.shots),
spotted: diff((a) => a.spotted),
survived_battles: diff((a) => a.survived_battles),
win_and_survived: diff((a) => a.win_and_survived),
wins: diff((a) => a.wins),
xp: diff((a) => a.xp),
};
}
});
return tanksBeforeAndAfter;
+18 -14
View File
@@ -1,3 +1,5 @@
import isDev from '../process/isDev.js';
export type TankType = 'heavyTank' | 'AT-SPG' | 'mediumTank' | 'lightTank';
export interface Tankopedia {
@@ -54,18 +56,20 @@ export const TANK_TYPE_EMOJIS: Record<TankType, string> = {
lightTank: '🇱',
};
console.log('Encoding tank images...');
await Promise.all(
Object.entries(tankopedia).map(async ([, tank]) => {
if (tank.images.normal) {
const response = await fetch(tank.images.normal);
const blob = await response.arrayBuffer();
const base64 = `data:${response.headers.get(
'content-type',
)};base64,${Buffer.from(blob).toString('base64')}`;
if (!isDev()) {
console.log('Encoding tank images...');
await Promise.all(
Object.entries(tankopedia).map(async ([, tank]) => {
if (tank.images.normal) {
const response = await fetch(tank.images.normal);
const blob = await response.arrayBuffer();
const base64 = `data:${response.headers.get(
'content-type',
)};base64,${Buffer.from(blob).toString('base64')}`;
tank.images.normal = base64;
}
}),
);
console.log('Encoded tank images');
tank.images.normal = base64;
}
}),
);
console.log('Encoded tank images');
}