mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-25 03:29:51 +01:00
Merge branch 'main' into ue
This commit is contained in:
commit
5412c479c8
42 files changed
+1044
-934
No files matched your search
Vendored
+3
@@ -17,6 +17,9 @@
|
|||||||
"astrojs",
|
"astrojs",
|
||||||
"astrolib",
|
"astrolib",
|
||||||
"atgm",
|
"atgm",
|
||||||
|
"autocrop",
|
||||||
|
"Autoloader",
|
||||||
|
"Autoreloader",
|
||||||
"AYUV",
|
"AYUV",
|
||||||
"battleresults",
|
"battleresults",
|
||||||
"bbox",
|
"bbox",
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
# BlitzKit 1.29.12
|
||||||
|
|
||||||
|
## Fixes
|
||||||
|
|
||||||
|
- BlitzKit no longer uses BlitzStars for tank averages for some commands
|
||||||
|
- BlitzKit Performance was created to completely replace BlitzStars but BlitzStars was still used for some older commands
|
||||||
|
- But since BlitzStars keeps having downtime, it has been completely removed
|
||||||
|
- Upgraded all dependencies to the latest versions
|
||||||
|
- The replay command is now properly localized across all languages
|
||||||
|
- Special Chinese characters are now properly handled
|
||||||
|
- Commands are now registered synchronously, allowing errors to reveal their exact origins
|
||||||
|
- Error handling now properly exists the process after logging the error
|
||||||
|
- The bot now uses Discord's new `clientReady` instead of the ambiguous `ready` event
|
||||||
|
- Both the armor and model extractors now use the new BlitzKit `SteamVFS`
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
# BlitzKit 1.29.13
|
||||||
|
|
||||||
|
## Features
|
||||||
|
|
||||||
|
- The screenshot button now automatically crops your image so you don't have excessive blank space all around
|
||||||
|
- Increased the max zoom out distance in Tankopedia to 50m
|
||||||
|
|
||||||
|
## Fixes
|
||||||
|
|
||||||
|
- Turrets in Tankopedia now stay within a range of -180 and +180 degrees
|
||||||
|
- Tanks with transparency like the T34 and Herdbreaker are now properly rendered
|
||||||
|
- This will take a few days to roll out for all tanks (see screenshots below for the fixed models)
|
||||||
|
- High End Consumables now give a 33% boost instead of 70%
|
||||||
|
- Static Armor now properly deselects all irrelevant armor plates
|
||||||
|
- Removed a few debug loggers left behind
|
||||||
|
- Static Armor now properly rerenders armor plates when their thicknesses are changed
|
||||||
|
- The Ricochet Visualizer now stays in place when dragging around on mobile
|
||||||
|
- Reduced the text in the Tankopedia Compare segmented display to fit on smaller screens
|
||||||
|
- Sorting by tertiary shells no longer crashes for some tanks
|
||||||
|
- The Tank Filters are now left aligned on smaller screens for readability
|
||||||
+2
-1
@@ -14,7 +14,7 @@
|
|||||||
"build:catalogitemaccesssor": "cd packages/scripts && bun run build:catalogitemaccesssor",
|
"build:catalogitemaccesssor": "cd packages/scripts && bun run build:catalogitemaccesssor",
|
||||||
"build:ratingleaderboard": "cd packages/scripts && bun run build:ratingleaderboard",
|
"build:ratingleaderboard": "cd packages/scripts && bun run build:ratingleaderboard",
|
||||||
"build:app": "cd packages/app && bun run build",
|
"build:app": "cd packages/app && bun run build",
|
||||||
"dev:bot": "bun run build:bot --dev && bun start:bot",
|
"dev:bot": "bun run build:bot --dev && bun start:bot --dev",
|
||||||
"start:bot": "bun dist/bot/main.js",
|
"start:bot": "bun dist/bot/main.js",
|
||||||
"dev:docs": "vitepress dev docs",
|
"dev:docs": "vitepress dev docs",
|
||||||
"dev:website": "cd packages/website-ue && bun run dev",
|
"dev:website": "cd packages/website-ue && bun run dev",
|
||||||
@@ -47,6 +47,7 @@
|
|||||||
"@fontsource-variable/jetbrains-mono": "^5.2.8",
|
"@fontsource-variable/jetbrains-mono": "^5.2.8",
|
||||||
"@prisma/client": "^6.18.0",
|
"@prisma/client": "^6.18.0",
|
||||||
"prisma": "^6.18.0",
|
"prisma": "^6.18.0",
|
||||||
|
"sharp": "^0.34.5",
|
||||||
"typescript": "^5.9.3"
|
"typescript": "^5.9.3"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Generated
+11
-11
@@ -356,9 +356,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bytes"
|
name = "bytes"
|
||||||
version = "1.10.1"
|
version = "1.11.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d71b6127be86fdcfddb610f7182ac57211d4b18a3e9c82eb2d17662f2227ad6a"
|
checksum = "1e748733b7cbc798e1434b6ac524f0c1ff2ab456fe201501e6497c8417a4fc33"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"serde",
|
"serde",
|
||||||
]
|
]
|
||||||
@@ -2105,9 +2105,9 @@ checksum = "72ef4a56884ca558e5ddb05a1d1e7e1bfd9a68d9ed024c21704cc98872dae1bb"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "num-conv"
|
name = "num-conv"
|
||||||
version = "0.1.0"
|
version = "0.2.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9"
|
checksum = "cf97ec579c3c42f953ef76dbf8d55ac91fb219dde70e49aa4a6b7d74e9919050"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "num-traits"
|
name = "num-traits"
|
||||||
@@ -3907,30 +3907,30 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "time"
|
name = "time"
|
||||||
version = "0.3.44"
|
version = "0.3.47"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "91e7d9e3bb61134e77bde20dd4825b97c010155709965fedf0f49bb138e52a9d"
|
checksum = "743bd48c283afc0388f9b8827b976905fb217ad9e647fae3a379a9283c4def2c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"deranged",
|
"deranged",
|
||||||
"itoa",
|
"itoa",
|
||||||
"num-conv",
|
"num-conv",
|
||||||
"powerfmt",
|
"powerfmt",
|
||||||
"serde",
|
"serde_core",
|
||||||
"time-core",
|
"time-core",
|
||||||
"time-macros",
|
"time-macros",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "time-core"
|
name = "time-core"
|
||||||
version = "0.1.6"
|
version = "0.1.8"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "40868e7c1d2f0b8d73e4a8c7f0ff63af4f6d19be117e90bd73eb1d62cf831c6b"
|
checksum = "7694e1cfe791f8d31026952abf09c69ca6f6fa4e1a1229e18988f06a04a12dca"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "time-macros"
|
name = "time-macros"
|
||||||
version = "0.2.24"
|
version = "0.2.27"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "30cfb0125f12d9c277f35663a0a33f8c30190f4e4574868a330595412d34ebf3"
|
checksum = "2e70e4c5a0e0a8a4823ad65dfe1a6930e4f4d756dcd9dd7939022b5e8c501215"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"num-conv",
|
"num-conv",
|
||||||
"time-core",
|
"time-core",
|
||||||
|
|||||||
@@ -4,25 +4,26 @@
|
|||||||
"@blitzkit/core": "workspace:*",
|
"@blitzkit/core": "workspace:*",
|
||||||
"@blitzkit/i18n": "workspace:*",
|
"@blitzkit/i18n": "workspace:*",
|
||||||
"@radix-ui/colors": "^3.0.0",
|
"@radix-ui/colors": "^3.0.0",
|
||||||
"@radix-ui/themes": "^3.2.1",
|
"@radix-ui/themes": "^3.3.0",
|
||||||
"@resvg/resvg-js": "^2.6.2",
|
"@resvg/resvg-js": "^2.6.2",
|
||||||
"@types/adm-zip": "^0.5.7",
|
"@types/adm-zip": "^0.5.7",
|
||||||
|
"@types/bun": "^1.3.9",
|
||||||
"@types/lodash-es": "^4.17.12",
|
"@types/lodash-es": "^4.17.12",
|
||||||
"@types/markdown-escape": "^1.1.3",
|
"@types/markdown-escape": "^1.1.3",
|
||||||
"@types/react": "^19.2.2",
|
"@types/react": "^19.2.14",
|
||||||
"adm-zip": "^0.5.16",
|
"adm-zip": "^0.5.16",
|
||||||
"bepaint": "^0.1.0-beta.3",
|
"bepaint": "^0.1.0-beta.3",
|
||||||
"discord.js": "^14.22.1",
|
"discord.js": "^14.25.1",
|
||||||
"dotenv": "^17.2.2",
|
"dotenv": "^17.3.1",
|
||||||
"fuzzysort": "^3.1.0",
|
"fuzzysort": "^3.1.0",
|
||||||
"lodash-es": "^4.17.21",
|
"lodash-es": "^4.17.23",
|
||||||
"markdown-escape": "^2.0.0",
|
"markdown-escape": "^2.0.0",
|
||||||
"pickleparser": "^0.2.1",
|
"pickleparser": "^0.2.1",
|
||||||
"prisma": "^6.17.1",
|
"prisma": "^6.19.2",
|
||||||
"protobufjs": "^7.5.4",
|
"protobufjs": "^7.5.4",
|
||||||
"react": "^19.2.0",
|
"react": "^19.2.4",
|
||||||
"satori": "^0.18.3",
|
"satori": "^0.18.4",
|
||||||
"sharp": "^0.34.4"
|
"sharp": "^0.34.5"
|
||||||
},
|
},
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { createLocalizedCommand } from "../core/discord/createLocalizedCommand";
|
import { createLocalizedCommand } from "../core/discord/createLocalizedCommand";
|
||||||
import { translator } from "../core/localization/translator";
|
import { translator } from "../core/localization/translator";
|
||||||
import {
|
import {
|
||||||
COMMANDS_RAW,
|
commandsArray,
|
||||||
type CommandRegistry,
|
type CommandRegistry,
|
||||||
} from "../events/interactionCreate";
|
} from "../events/interactionCreate";
|
||||||
|
|
||||||
@@ -35,7 +35,7 @@ export const aboutCommand = new Promise<CommandRegistry>(async (resolve) => {
|
|||||||
|
|
||||||
if (subcommand === "commands") {
|
if (subcommand === "commands") {
|
||||||
return `${strings.bot.commands.about.subcommands.commands.body}${(
|
return `${strings.bot.commands.about.subcommands.commands.body}${(
|
||||||
await Promise.all(COMMANDS_RAW)
|
await Promise.all(commandsArray)
|
||||||
)
|
)
|
||||||
.sort((a, b) =>
|
.sort((a, b) =>
|
||||||
(a.command.name_localizations?.[interaction.locale] ??
|
(a.command.name_localizations?.[interaction.locale] ??
|
||||||
@@ -43,7 +43,7 @@ export const aboutCommand = new Promise<CommandRegistry>(async (resolve) => {
|
|||||||
(b.command.name_localizations?.[interaction.locale] ??
|
(b.command.name_localizations?.[interaction.locale] ??
|
||||||
b.command.name)
|
b.command.name)
|
||||||
? -1
|
? -1
|
||||||
: 1
|
: 1,
|
||||||
)
|
)
|
||||||
.map(
|
.map(
|
||||||
(registry) =>
|
(registry) =>
|
||||||
@@ -54,7 +54,7 @@ export const aboutCommand = new Promise<CommandRegistry>(async (resolve) => {
|
|||||||
registry.command.description_localizations?.[
|
registry.command.description_localizations?.[
|
||||||
interaction.locale
|
interaction.locale
|
||||||
] ?? registry.command.description
|
] ?? registry.command.description
|
||||||
}`
|
}`,
|
||||||
)
|
)
|
||||||
.join("\n")}`;
|
.join("\n")}`;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,11 +15,16 @@ import { CommandWrapper } from "../../components/CommandWrapper";
|
|||||||
import { NoData } from "../../components/NoData";
|
import { NoData } from "../../components/NoData";
|
||||||
import { TitleBar } from "../../components/TitleBar";
|
import { TitleBar } from "../../components/TitleBar";
|
||||||
import { filtersToDescription } from "../../core/blitzkit/filtersToDescription";
|
import { filtersToDescription } from "../../core/blitzkit/filtersToDescription";
|
||||||
import { tankDefinitions } from "../../core/blitzkit/nonBlockingPromises";
|
import {
|
||||||
|
averageDefinitions,
|
||||||
|
tankDefinitions,
|
||||||
|
} from "../../core/blitzkit/nonBlockingPromises";
|
||||||
import { UserError } from "../../core/blitzkit/userError";
|
import { UserError } from "../../core/blitzkit/userError";
|
||||||
import { filterStats, type StatFilters } from "../../core/blitzstars/filterStats";
|
import {
|
||||||
|
filterStats,
|
||||||
|
type StatFilters,
|
||||||
|
} from "../../core/blitzstars/filterStats";
|
||||||
import { getStatsInPeriod } from "../../core/blitzstars/getStatsInPeriod";
|
import { getStatsInPeriod } from "../../core/blitzstars/getStatsInPeriod";
|
||||||
import { blitzStarsTankAverages } from "../../core/blitzstars/tankAverages";
|
|
||||||
import type { ResolvedPeriod } from "../../core/discord/resolvePeriodFromCommand";
|
import type { ResolvedPeriod } from "../../core/discord/resolvePeriodFromCommand";
|
||||||
import type { ResolvedPlayer } from "../../core/discord/resolvePlayerFromCommand";
|
import type { ResolvedPlayer } from "../../core/discord/resolvePlayerFromCommand";
|
||||||
import { translator } from "../../core/localization/translator";
|
import { translator } from "../../core/localization/translator";
|
||||||
@@ -31,11 +36,11 @@ export async function renderBreakdown(
|
|||||||
{ region, id }: ResolvedPlayer,
|
{ region, id }: ResolvedPlayer,
|
||||||
{ start, end, name }: ResolvedPeriod,
|
{ start, end, name }: ResolvedPeriod,
|
||||||
filters: StatFilters,
|
filters: StatFilters,
|
||||||
locale: Locale
|
locale: Locale,
|
||||||
) {
|
) {
|
||||||
const { strings, unwrap } = translator(locale);
|
const { strings, unwrap } = translator(locale);
|
||||||
const awaitedTankDefinitions = await tankDefinitions;
|
const awaitedTankDefinitions = await tankDefinitions;
|
||||||
const awaitedTankAverages = await blitzStarsTankAverages;
|
const awaitedTankAverages = await averageDefinitions;
|
||||||
const statsInPeriod = await getStatsInPeriod(region, id, start, end, locale);
|
const statsInPeriod = await getStatsInPeriod(region, id, start, end, locale);
|
||||||
const { filteredOrder } = await filterStats(statsInPeriod, filters);
|
const { filteredOrder } = await filterStats(statsInPeriod, filters);
|
||||||
const accountInfo = await getAccountInfo(region, id);
|
const accountInfo = await getAccountInfo(region, id);
|
||||||
@@ -53,14 +58,14 @@ export async function renderBreakdown(
|
|||||||
}
|
}
|
||||||
|
|
||||||
filteredOrder.forEach((id) => {
|
filteredOrder.forEach((id) => {
|
||||||
const tankAveragesEntry = awaitedTankAverages[id];
|
const tankAveragesEntry = awaitedTankAverages.averages[id];
|
||||||
const current = statsInPeriod.diff[id];
|
const current = statsInPeriod.diff[id];
|
||||||
const career = tankStats.find((tank) => tank.tank_id === id)!.all;
|
const career = tankStats.find((tank) => tank.tank_id === id)!.all;
|
||||||
const currentWN8 = tankAveragesEntry
|
const currentWN8 = tankAveragesEntry
|
||||||
? calculateWN8(tankAveragesEntry.all, current)
|
? calculateWN8(tankAveragesEntry.mu, current)
|
||||||
: undefined;
|
: undefined;
|
||||||
const careerWN8 = tankAveragesEntry
|
const careerWN8 = tankAveragesEntry
|
||||||
? calculateWN8(tankAveragesEntry.all, career)
|
? calculateWN8(tankAveragesEntry.mu, career)
|
||||||
: undefined;
|
: undefined;
|
||||||
|
|
||||||
orderedCurrentStats.push(current);
|
orderedCurrentStats.push(current);
|
||||||
@@ -69,65 +74,65 @@ export async function renderBreakdown(
|
|||||||
orderedCareerWN8.push(careerWN8);
|
orderedCareerWN8.push(careerWN8);
|
||||||
});
|
});
|
||||||
tankStats.forEach((tank) => {
|
tankStats.forEach((tank) => {
|
||||||
const tankAveragesEntry = awaitedTankAverages[tank.tank_id];
|
const tankAveragesEntry = awaitedTankAverages.averages[tank.tank_id];
|
||||||
|
|
||||||
orderedCareerWN8Full.push(
|
orderedCareerWN8Full.push(
|
||||||
tankAveragesEntry
|
tankAveragesEntry
|
||||||
? calculateWN8(tankAveragesEntry.all, tank.all)
|
? calculateWN8(tankAveragesEntry.mu, tank.all)
|
||||||
: undefined
|
: undefined,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
const currentBattles = orderedCurrentStats.reduce(
|
const currentBattles = orderedCurrentStats.reduce(
|
||||||
(accumulator, current) => accumulator + current.battles,
|
(accumulator, current) => accumulator + current.battles,
|
||||||
0
|
0,
|
||||||
);
|
);
|
||||||
const careerBattles = tankStats.reduce(
|
const careerBattles = tankStats.reduce(
|
||||||
(accumulator, current) => accumulator + current.all.battles,
|
(accumulator, current) => accumulator + current.all.battles,
|
||||||
0
|
0,
|
||||||
);
|
);
|
||||||
const currentWinrate =
|
const currentWinrate =
|
||||||
orderedCurrentStats.reduce(
|
orderedCurrentStats.reduce(
|
||||||
(accumulator, current) => accumulator + current.wins,
|
(accumulator, current) => accumulator + current.wins,
|
||||||
0
|
0,
|
||||||
) / currentBattles;
|
) / currentBattles;
|
||||||
const careerWinrate =
|
const careerWinrate =
|
||||||
tankStats.reduce(
|
tankStats.reduce(
|
||||||
(accumulator, current) => accumulator + current.all.wins,
|
(accumulator, current) => accumulator + current.all.wins,
|
||||||
0
|
0,
|
||||||
) / careerBattles;
|
) / careerBattles;
|
||||||
const currentWN8 =
|
const currentWN8 =
|
||||||
orderedCurrentWN8.reduce<number>(
|
orderedCurrentWN8.reduce<number>(
|
||||||
(accumulator, current, index) =>
|
(accumulator, current, index) =>
|
||||||
accumulator + (current ?? 0) * orderedCurrentStats[index].battles,
|
accumulator + (current ?? 0) * orderedCurrentStats[index].battles,
|
||||||
0
|
0,
|
||||||
) /
|
) /
|
||||||
orderedCurrentStats.reduce(
|
orderedCurrentStats.reduce(
|
||||||
(accumulator, current, index) =>
|
(accumulator, current, index) =>
|
||||||
accumulator +
|
accumulator +
|
||||||
(orderedCurrentWN8[index] === undefined ? 0 : current.battles),
|
(orderedCurrentWN8[index] === undefined ? 0 : current.battles),
|
||||||
0
|
0,
|
||||||
);
|
);
|
||||||
const careerWN8 =
|
const careerWN8 =
|
||||||
orderedCareerWN8Full.reduce<number>(
|
orderedCareerWN8Full.reduce<number>(
|
||||||
(accumulator, current) => accumulator + (current ?? 0),
|
(accumulator, current) => accumulator + (current ?? 0),
|
||||||
0
|
0,
|
||||||
) /
|
) /
|
||||||
tankStats.reduce(
|
tankStats.reduce(
|
||||||
(accumulator, current, index) =>
|
(accumulator, current, index) =>
|
||||||
accumulator +
|
accumulator +
|
||||||
(orderedCareerWN8Full[index] === undefined ? 0 : current.all.battles),
|
(orderedCareerWN8Full[index] === undefined ? 0 : current.all.battles),
|
||||||
0
|
0,
|
||||||
);
|
);
|
||||||
const currentDamage =
|
const currentDamage =
|
||||||
orderedCurrentStats.reduce(
|
orderedCurrentStats.reduce(
|
||||||
(accumulator, current) => accumulator + current.damage_dealt,
|
(accumulator, current) => accumulator + current.damage_dealt,
|
||||||
0
|
0,
|
||||||
) / currentBattles;
|
) / currentBattles;
|
||||||
const careerDamage =
|
const careerDamage =
|
||||||
tankStats.reduce(
|
tankStats.reduce(
|
||||||
(accumulator, current) => accumulator + current.all.damage_dealt,
|
(accumulator, current) => accumulator + current.all.damage_dealt,
|
||||||
0
|
0,
|
||||||
) / careerBattles;
|
) / careerBattles;
|
||||||
|
|
||||||
const children: React.JSX.Element[] = [];
|
const children: React.JSX.Element[] = [];
|
||||||
@@ -172,7 +177,7 @@ export async function renderBreakdown(
|
|||||||
delta: currentDamage - careerDamage,
|
delta: currentDamage - careerDamage,
|
||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
/>
|
/>,
|
||||||
);
|
);
|
||||||
|
|
||||||
filteredOrder.forEach((id, index) => {
|
filteredOrder.forEach((id, index) => {
|
||||||
@@ -206,7 +211,7 @@ export async function renderBreakdown(
|
|||||||
{
|
{
|
||||||
title: strings.bot.commands.breakdown.body.winrate,
|
title: strings.bot.commands.breakdown.body.winrate,
|
||||||
current: `${(100 * (current.wins / current.battles)).toFixed(
|
current: `${(100 * (current.wins / current.battles)).toFixed(
|
||||||
2
|
2,
|
||||||
)}%`,
|
)}%`,
|
||||||
career: `${(100 * (career.wins / career.battles)).toFixed(2)}%`,
|
career: `${(100 * (career.wins / career.battles)).toFixed(2)}%`,
|
||||||
delta:
|
delta:
|
||||||
@@ -230,24 +235,24 @@ export async function renderBreakdown(
|
|||||||
{
|
{
|
||||||
title: strings.bot.commands.breakdown.body.damage,
|
title: strings.bot.commands.breakdown.body.damage,
|
||||||
current: Math.round(
|
current: Math.round(
|
||||||
current.damage_dealt / current.battles
|
current.damage_dealt / current.battles,
|
||||||
).toLocaleString(),
|
).toLocaleString(),
|
||||||
career: Math.round(
|
career: Math.round(
|
||||||
career.damage_dealt / career.battles
|
career.damage_dealt / career.battles,
|
||||||
).toLocaleString(),
|
).toLocaleString(),
|
||||||
delta:
|
delta:
|
||||||
current.damage_dealt / current.battles -
|
current.damage_dealt / current.battles -
|
||||||
career.damage_dealt / career.battles,
|
career.damage_dealt / career.battles,
|
||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
/>
|
/>,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const pages = chunk(
|
const pages = chunk(
|
||||||
children,
|
children,
|
||||||
Math.max(Math.ceil(children.length / MAX_PAGES), ROWS_PER_PAGE)
|
Math.max(Math.ceil(children.length / MAX_PAGES), ROWS_PER_PAGE),
|
||||||
);
|
);
|
||||||
|
|
||||||
if (filteredOrder.length > 0) {
|
if (filteredOrder.length > 0) {
|
||||||
|
|||||||
@@ -5,28 +5,29 @@ import {
|
|||||||
idToRegion,
|
idToRegion,
|
||||||
tankIcon,
|
tankIcon,
|
||||||
TIER_ROMAN_NUMERALS,
|
TIER_ROMAN_NUMERALS,
|
||||||
} from '@blitzkit/core';
|
} from "@blitzkit/core";
|
||||||
import { Locale } from 'discord.js';
|
import { Locale } from "discord.js";
|
||||||
import { clamp } from 'lodash-es';
|
import { clamp } from "lodash-es";
|
||||||
import { CommandWrapper } from '../components/CommandWrapper';
|
import { CommandWrapper } from "../components/CommandWrapper";
|
||||||
import { TitleBar } from '../components/TitleBar';
|
import { TitleBar } from "../components/TitleBar";
|
||||||
import { iconPng } from '../core/blitzkit/iconPng';
|
import { iconPng } from "../core/blitzkit/iconPng";
|
||||||
import {
|
import {
|
||||||
|
averageDefinitions,
|
||||||
mapDefinitions,
|
mapDefinitions,
|
||||||
tankDefinitions,
|
tankDefinitions,
|
||||||
} from '../core/blitzkit/nonBlockingPromises';
|
} from "../core/blitzkit/nonBlockingPromises";
|
||||||
import { RenderConfiguration } from '../core/blitzkit/renderConfiguration';
|
import { RenderConfiguration } from "../core/blitzkit/renderConfiguration";
|
||||||
import { blitzStarsTankAverages } from '../core/blitzstars/tankAverages';
|
import { buttonLink } from "../core/discord/buttonLink";
|
||||||
import { buttonLink } from '../core/discord/buttonLink';
|
import { createLocalizedCommand } from "../core/discord/createLocalizedCommand";
|
||||||
import { createLocalizedCommand } from '../core/discord/createLocalizedCommand';
|
import { localizationObject } from "../core/discord/localizationObject";
|
||||||
import { translator } from '../core/localization/translator';
|
import { translator } from "../core/localization/translator";
|
||||||
import { type CommandRegistry } from '../events/interactionCreate';
|
import { type CommandRegistry } from "../events/interactionCreate";
|
||||||
import { theme } from '../stitches.config';
|
import { theme } from "../stitches.config";
|
||||||
|
|
||||||
type WotInspectorReplaySubmission =
|
type WotInspectorReplaySubmission =
|
||||||
| { status: 'error'; data: unknown; error: { message: string } }
|
| { status: "error"; data: unknown; error: { message: string } }
|
||||||
| {
|
| {
|
||||||
status: 'ok';
|
status: "ok";
|
||||||
data: {
|
data: {
|
||||||
download_url: string;
|
download_url: string;
|
||||||
view_url: string;
|
view_url: string;
|
||||||
@@ -209,9 +210,9 @@ function stat(value: string | number, flex = 2) {
|
|||||||
<div
|
<div
|
||||||
style={{
|
style={{
|
||||||
flex,
|
flex,
|
||||||
display: 'flex',
|
display: "flex",
|
||||||
alignItems: 'center',
|
alignItems: "center",
|
||||||
justifyContent: 'center',
|
justifyContent: "center",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<span style={{ fontSize: 16 }}>{value}</span>
|
<span style={{ fontSize: 16 }}>{value}</span>
|
||||||
@@ -227,15 +228,15 @@ async function playerListing(
|
|||||||
recordingPlayer = false,
|
recordingPlayer = false,
|
||||||
) {
|
) {
|
||||||
const { unwrap } = translator(locale);
|
const { unwrap } = translator(locale);
|
||||||
const awaitedTankAverages = await blitzStarsTankAverages;
|
const awaitedTankAverages = await averageDefinitions;
|
||||||
const awaitedTankDefinitions = await tankDefinitions;
|
const awaitedTankDefinitions = await tankDefinitions;
|
||||||
const tank = awaitedTankDefinitions.tanks[player.vehicle_descr];
|
const tank = awaitedTankDefinitions.tanks[player.vehicle_descr];
|
||||||
const blockAccent = recordingPlayer ? '_amber' : '';
|
const blockAccent = recordingPlayer ? "_amber" : "";
|
||||||
const healthAccent = protagonistTeam
|
const healthAccent = protagonistTeam
|
||||||
? recordingPlayer
|
? recordingPlayer
|
||||||
? '_amber'
|
? "_amber"
|
||||||
: '_green'
|
: "_green"
|
||||||
: '_red';
|
: "_red";
|
||||||
|
|
||||||
// our turret ids are always off by 1 or 2 lol so imma just grab the closest
|
// our turret ids are always off by 1 or 2 lol so imma just grab the closest
|
||||||
// TODO: 💀
|
// TODO: 💀
|
||||||
@@ -245,11 +246,11 @@ async function playerListing(
|
|||||||
)[0];
|
)[0];
|
||||||
const totalHealth = turret.health + tank.health;
|
const totalHealth = turret.health + tank.health;
|
||||||
const healthLeft = clamp(player.hitpoints_left / totalHealth, 0, 1);
|
const healthLeft = clamp(player.hitpoints_left / totalHealth, 0, 1);
|
||||||
const tankAveragesEntry = awaitedTankAverages[player.vehicle_descr];
|
const tankAveragesEntry = awaitedTankAverages.averages[player.vehicle_descr];
|
||||||
const wn8 =
|
const wn8 =
|
||||||
tankAveragesEntry === undefined
|
tankAveragesEntry === undefined
|
||||||
? -1
|
? -1
|
||||||
: calculateWN8(tankAveragesEntry.all, {
|
: calculateWN8(tankAveragesEntry.mu, {
|
||||||
battles: 1,
|
battles: 1,
|
||||||
damage_dealt: player.damage_made,
|
damage_dealt: player.damage_made,
|
||||||
dropped_capture_points: player.base_defend_points,
|
dropped_capture_points: player.base_defend_points,
|
||||||
@@ -262,8 +263,8 @@ async function playerListing(
|
|||||||
<div
|
<div
|
||||||
key={player.entity_id}
|
key={player.entity_id}
|
||||||
style={{
|
style={{
|
||||||
display: 'flex',
|
display: "flex",
|
||||||
alignItems: 'center',
|
alignItems: "center",
|
||||||
gap: 8,
|
gap: 8,
|
||||||
backgroundColor: theme.colors[`appBackground2${blockAccent}`],
|
backgroundColor: theme.colors[`appBackground2${blockAccent}`],
|
||||||
padding: 8,
|
padding: 8,
|
||||||
@@ -271,11 +272,11 @@ async function playerListing(
|
|||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
style={{
|
style={{
|
||||||
display: 'flex',
|
display: "flex",
|
||||||
gap: 8,
|
gap: 8,
|
||||||
flex: 1,
|
flex: 1,
|
||||||
overflow: 'hidden',
|
overflow: "hidden",
|
||||||
alignItems: 'center',
|
alignItems: "center",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<img
|
<img
|
||||||
@@ -284,22 +285,22 @@ async function playerListing(
|
|||||||
style={{
|
style={{
|
||||||
width: 32,
|
width: 32,
|
||||||
height: 32,
|
height: 32,
|
||||||
objectFit: 'contain',
|
objectFit: "contain",
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
style={{
|
style={{
|
||||||
display: 'flex',
|
display: "flex",
|
||||||
flexDirection: 'column',
|
flexDirection: "column",
|
||||||
// align
|
// align
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
style={{
|
style={{
|
||||||
display: 'flex',
|
display: "flex",
|
||||||
gap: 4,
|
gap: 4,
|
||||||
alignItems: 'center',
|
alignItems: "center",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<span
|
<span
|
||||||
@@ -324,23 +325,23 @@ async function playerListing(
|
|||||||
style={{
|
style={{
|
||||||
fontSize: 16,
|
fontSize: 16,
|
||||||
color: theme.colors[`textLowContrast${blockAccent}`],
|
color: theme.colors[`textLowContrast${blockAccent}`],
|
||||||
whiteSpace: 'nowrap',
|
whiteSpace: "nowrap",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{player.name}
|
{player.name}
|
||||||
{player.clan_tag ? ` [${player.clan_tag}]` : ''}
|
{player.clan_tag ? ` [${player.clan_tag}]` : ""}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
style={{
|
style={{
|
||||||
display: 'flex',
|
display: "flex",
|
||||||
flex: 1,
|
flex: 1,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{stat(player.damage_made.toLocaleString())}
|
{stat(player.damage_made.toLocaleString())}
|
||||||
{stat(wn8 === -1 ? '--' : Math.round(wn8).toLocaleString())}
|
{stat(wn8 === -1 ? "--" : Math.round(wn8).toLocaleString())}
|
||||||
{stat(player.exp.toLocaleString())}
|
{stat(player.exp.toLocaleString())}
|
||||||
{stat(player.enemies_destroyed, 1)}
|
{stat(player.enemies_destroyed, 1)}
|
||||||
</div>
|
</div>
|
||||||
@@ -349,15 +350,15 @@ async function playerListing(
|
|||||||
style={{
|
style={{
|
||||||
borderRadius: 2,
|
borderRadius: 2,
|
||||||
backgroundColor: theme.colors[`componentInteractive${healthAccent}`],
|
backgroundColor: theme.colors[`componentInteractive${healthAccent}`],
|
||||||
display: 'flex',
|
display: "flex",
|
||||||
width: 4,
|
width: 4,
|
||||||
height: '100%',
|
height: "100%",
|
||||||
transform: 'scaleY(-1)',
|
transform: "scaleY(-1)",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
style={{
|
style={{
|
||||||
width: '100%',
|
width: "100%",
|
||||||
height: `${healthLeft * 100}%`,
|
height: `${healthLeft * 100}%`,
|
||||||
borderRadius: 2,
|
borderRadius: 2,
|
||||||
backgroundColor: theme.colors[`solidBackground${healthAccent}`],
|
backgroundColor: theme.colors[`solidBackground${healthAccent}`],
|
||||||
@@ -373,8 +374,8 @@ function Header() {
|
|||||||
<div
|
<div
|
||||||
style={{
|
style={{
|
||||||
padding: 8,
|
padding: 8,
|
||||||
display: 'flex',
|
display: "flex",
|
||||||
alignItems: 'center',
|
alignItems: "center",
|
||||||
gap: 8,
|
gap: 8,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
@@ -382,16 +383,16 @@ function Header() {
|
|||||||
|
|
||||||
<div
|
<div
|
||||||
style={{
|
style={{
|
||||||
display: 'flex',
|
display: "flex",
|
||||||
flex: 1,
|
flex: 1,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
style={{
|
style={{
|
||||||
flex: 2,
|
flex: 2,
|
||||||
display: 'flex',
|
display: "flex",
|
||||||
alignItems: 'center',
|
alignItems: "center",
|
||||||
justifyContent: 'center',
|
justifyContent: "center",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<span
|
<span
|
||||||
@@ -406,9 +407,9 @@ function Header() {
|
|||||||
<div
|
<div
|
||||||
style={{
|
style={{
|
||||||
flex: 2,
|
flex: 2,
|
||||||
display: 'flex',
|
display: "flex",
|
||||||
alignItems: 'center',
|
alignItems: "center",
|
||||||
justifyContent: 'center',
|
justifyContent: "center",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<span
|
<span
|
||||||
@@ -423,9 +424,9 @@ function Header() {
|
|||||||
<div
|
<div
|
||||||
style={{
|
style={{
|
||||||
flex: 2,
|
flex: 2,
|
||||||
display: 'flex',
|
display: "flex",
|
||||||
alignItems: 'center',
|
alignItems: "center",
|
||||||
justifyContent: 'center',
|
justifyContent: "center",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<span
|
<span
|
||||||
@@ -440,9 +441,9 @@ function Header() {
|
|||||||
<div
|
<div
|
||||||
style={{
|
style={{
|
||||||
flex: 1,
|
flex: 1,
|
||||||
display: 'flex',
|
display: "flex",
|
||||||
alignItems: 'center',
|
alignItems: "center",
|
||||||
justifyContent: 'center',
|
justifyContent: "center",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<span
|
<span
|
||||||
@@ -460,28 +461,42 @@ function Header() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const replayCommand = new Promise<CommandRegistry>((resolve) => {
|
export const replayCommand = new Promise<CommandRegistry>((resolve) => {
|
||||||
|
const { strings } = translator(Locale.EnglishUS);
|
||||||
|
|
||||||
resolve({
|
resolve({
|
||||||
command: createLocalizedCommand('replay').addAttachmentOption((option) =>
|
command: createLocalizedCommand("replay").addAttachmentOption((option) =>
|
||||||
option.setName('file').setDescription('Replay file').setRequired(true),
|
option
|
||||||
|
.setName(strings.bot.commands.replay.options.file.name)
|
||||||
|
.setNameLocalizations(
|
||||||
|
localizationObject(
|
||||||
|
(strings) => strings.bot.commands.replay.options.file.name,
|
||||||
|
undefined,
|
||||||
|
true,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.setDescription(strings.bot.commands.replay.options.file.description)
|
||||||
|
.setDescriptionLocalizations(
|
||||||
|
localizationObject(
|
||||||
|
(strings) => strings.bot.commands.replay.options.file.description,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.setRequired(true),
|
||||||
),
|
),
|
||||||
|
|
||||||
async handler(interaction) {
|
async handler(interaction) {
|
||||||
const awaitedMapDefinitions = await mapDefinitions;
|
const awaitedMapDefinitions = await mapDefinitions;
|
||||||
const file = interaction.options.getAttachment('file')!;
|
const file = interaction.options.getAttachment("file")!;
|
||||||
// const file = {
|
|
||||||
// url: 'https://cdn.discordapp.com/ephemeral-attachments/1232434891652861972/1232781496016834581/20240328_1530__TresAbhi_M60_1157057448155406708.wotbreplay?ex=662ab4bc&is=6629633c&hm=c784cd10e80232350ddaf291fa987b879c4d0a8083b78298c9eee4fa0d507f6c&',
|
|
||||||
// };
|
|
||||||
const submissionData = (await fetch(
|
const submissionData = (await fetch(
|
||||||
`https://wotinspector.com/api/replay/upload/?url=${encodeURIComponent(
|
`https://wotinspector.com/api/replay/upload/?url=${encodeURIComponent(
|
||||||
file.url,
|
file.url,
|
||||||
)}`,
|
)}`,
|
||||||
).then((response) => response.json())) as WotInspectorReplaySubmission;
|
).then((response) => response.json())) as WotInspectorReplaySubmission;
|
||||||
|
|
||||||
if (submissionData.status === 'error') {
|
if (submissionData.status === "error") {
|
||||||
return `# Uh oh! WoT Inspector didn't like that.\n\nThere was an error processing your replay. Get help on [the official Discord server](https://discord.gg/nDt7AjGJQH).`;
|
return `# Uh oh! WoT Inspector didn't like that.\n\nThere was an error processing your replay. Get help on [the official Discord server](https://discord.gg/nDt7AjGJQH).`;
|
||||||
}
|
}
|
||||||
|
|
||||||
const replayId = submissionData.data.download_url.split('/').at(-1)!;
|
const replayId = submissionData.data.download_url.split("/").at(-1)!;
|
||||||
const replayData = (await fetch(
|
const replayData = (await fetch(
|
||||||
`https://api.wotinspector.com/v2/blitz/replays/${replayId}/`,
|
`https://api.wotinspector.com/v2/blitz/replays/${replayId}/`,
|
||||||
).then((response) => response.json())) as WotInspectorReplay;
|
).then((response) => response.json())) as WotInspectorReplay;
|
||||||
@@ -493,7 +508,7 @@ export const replayCommand = new Promise<CommandRegistry>((resolve) => {
|
|||||||
await getClanAccountInfo(
|
await getClanAccountInfo(
|
||||||
idToRegion(replayData.protagonist),
|
idToRegion(replayData.protagonist),
|
||||||
replayData.protagonist,
|
replayData.protagonist,
|
||||||
['clan'],
|
["clan"],
|
||||||
)
|
)
|
||||||
)?.clan;
|
)?.clan;
|
||||||
const clanImage = clan ? emblemURL(clan.emblem_set_id) : undefined;
|
const clanImage = clan ? emblemURL(clan.emblem_set_id) : undefined;
|
||||||
@@ -506,22 +521,22 @@ export const replayCommand = new Promise<CommandRegistry>((resolve) => {
|
|||||||
image={clanImage}
|
image={clanImage}
|
||||||
description={`${
|
description={`${
|
||||||
replayData.protagonist_team === replayData.winner_team
|
replayData.protagonist_team === replayData.winner_team
|
||||||
? 'Victory'
|
? "Victory"
|
||||||
: 'Defeat'
|
: "Defeat"
|
||||||
} • ${awaitedMapDefinitions.maps[replayData.map_id].name}`}
|
} • ${awaitedMapDefinitions.maps[replayData.map_id].name}`}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
style={{
|
style={{
|
||||||
display: 'flex',
|
display: "flex",
|
||||||
gap: 8,
|
gap: 8,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
style={{
|
style={{
|
||||||
flex: 1,
|
flex: 1,
|
||||||
display: 'flex',
|
display: "flex",
|
||||||
flexDirection: 'column',
|
flexDirection: "column",
|
||||||
gap: 4,
|
gap: 4,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
@@ -547,8 +562,8 @@ export const replayCommand = new Promise<CommandRegistry>((resolve) => {
|
|||||||
<div
|
<div
|
||||||
style={{
|
style={{
|
||||||
flex: 1,
|
flex: 1,
|
||||||
display: 'flex',
|
display: "flex",
|
||||||
flexDirection: 'column',
|
flexDirection: "column",
|
||||||
gap: 4,
|
gap: 4,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
@@ -569,8 +584,8 @@ export const replayCommand = new Promise<CommandRegistry>((resolve) => {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</CommandWrapper>,
|
</CommandWrapper>,
|
||||||
buttonLink(submissionData.data.view_url, 'WoT Inspector'),
|
buttonLink(submissionData.data.view_url, "WoT Inspector"),
|
||||||
buttonLink(submissionData.data.download_url, 'Download'),
|
buttonLink(submissionData.data.download_url, "Download"),
|
||||||
];
|
];
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,11 +1,13 @@
|
|||||||
import {
|
import {
|
||||||
|
fetchAverageDefinitions,
|
||||||
fetchDiscoveredIdsDefinitions,
|
fetchDiscoveredIdsDefinitions,
|
||||||
fetchGameDefinitions,
|
fetchGameDefinitions,
|
||||||
fetchMapDefinitions,
|
fetchMapDefinitions,
|
||||||
fetchTankDefinitions,
|
fetchTankDefinitions,
|
||||||
fetchTankNames,
|
fetchTankNames,
|
||||||
} from '@blitzkit/core';
|
} from "@blitzkit/core";
|
||||||
|
|
||||||
|
export const averageDefinitions = fetchAverageDefinitions();
|
||||||
export const tankDefinitions = fetchTankDefinitions();
|
export const tankDefinitions = fetchTankDefinitions();
|
||||||
export const gameDefinitions = fetchGameDefinitions();
|
export const gameDefinitions = fetchGameDefinitions();
|
||||||
export const tankNames = fetchTankNames();
|
export const tankNames = fetchTankNames();
|
||||||
|
|||||||
@@ -1,29 +1,37 @@
|
|||||||
import { usersDatabase } from '../db/users';
|
import { usersDatabase } from "../db/users";
|
||||||
import { client } from '../discord/client';
|
import { client } from "../discord/client";
|
||||||
|
|
||||||
const EXIT_EVENTS = [
|
const EXIT_EVENTS = ["SIGINT", "SIGTERM", "SIGUSR1", "SIGUSR2"];
|
||||||
'beforeExit',
|
|
||||||
'exit',
|
|
||||||
'SIGINT',
|
|
||||||
'SIGTERM',
|
|
||||||
'SIGUSR1',
|
|
||||||
'SIGUSR2',
|
|
||||||
];
|
|
||||||
|
|
||||||
async function cleanup() {
|
let cleaningUp = false;
|
||||||
console.log('Cleaning up...');
|
|
||||||
|
|
||||||
await Promise.all([usersDatabase.$disconnect(), client.destroy()]);
|
async function cleanup(signal: string) {
|
||||||
|
if (cleaningUp) return;
|
||||||
|
cleaningUp = true;
|
||||||
|
|
||||||
console.log('Gracefully exiting...');
|
console.log(`Cleaning up... (${signal})`);
|
||||||
|
|
||||||
|
try {
|
||||||
|
await Promise.all([usersDatabase.$disconnect(), client.destroy()]);
|
||||||
|
} catch (err) {
|
||||||
|
console.error("Cleanup error:", err);
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log("Gracefully exiting...");
|
||||||
|
|
||||||
EXIT_EVENTS.forEach((event) => process.off(event, cleanup));
|
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function registerProcesses() {
|
export function registerProcesses() {
|
||||||
process.on('uncaughtException', console.error);
|
process.on("uncaughtException", (err) => {
|
||||||
client.on('error', console.error);
|
console.error("uncaughtException:", err);
|
||||||
|
});
|
||||||
|
|
||||||
EXIT_EVENTS.forEach((event) => process.on(event, cleanup));
|
process.on("unhandledRejection", (err) => {
|
||||||
|
console.error("unhandledRejection:", err);
|
||||||
|
});
|
||||||
|
|
||||||
|
client.on("error", console.error);
|
||||||
|
|
||||||
|
EXIT_EVENTS.forEach((event) => process.on(event, () => cleanup(event)));
|
||||||
}
|
}
|
||||||
@@ -3,8 +3,10 @@ import type { SupplementaryStats } from "@blitzkit/core/src/blitz/getAccountInfo
|
|||||||
import { calculateWN8 } from "@blitzkit/core/src/statistics/calculateWN8";
|
import { calculateWN8 } from "@blitzkit/core/src/statistics/calculateWN8";
|
||||||
import type { BlitzStats } from "@blitzkit/core/src/statistics/compositeStats";
|
import type { BlitzStats } from "@blitzkit/core/src/statistics/compositeStats";
|
||||||
import { sumAllStats } from "@blitzkit/core/src/statistics/sumAllStats";
|
import { sumAllStats } from "@blitzkit/core/src/statistics/sumAllStats";
|
||||||
import { tankDefinitions } from "../blitzkit/nonBlockingPromises";
|
import {
|
||||||
import { blitzStarsTankAverages } from "./tankAverages";
|
averageDefinitions,
|
||||||
|
tankDefinitions,
|
||||||
|
} from "../blitzkit/nonBlockingPromises";
|
||||||
|
|
||||||
export interface StatFilters {
|
export interface StatFilters {
|
||||||
nation?: string;
|
nation?: string;
|
||||||
@@ -16,13 +18,13 @@ export interface StatFilters {
|
|||||||
|
|
||||||
export async function filterStats(
|
export async function filterStats(
|
||||||
{ diff, order }: DiffedTankStats,
|
{ diff, order }: DiffedTankStats,
|
||||||
filters: StatFilters
|
filters: StatFilters,
|
||||||
) {
|
) {
|
||||||
// tank, if provided, takes priority over all other filters
|
// tank, if provided, takes priority over all other filters
|
||||||
if (filters.tank) filters = { tank: filters.tank };
|
if (filters.tank) filters = { tank: filters.tank };
|
||||||
|
|
||||||
const awaitedTankDefinitions = await tankDefinitions;
|
const awaitedTankDefinitions = await tankDefinitions;
|
||||||
const awaitedTankAverages = await blitzStarsTankAverages;
|
const awaitedTankAverages = await averageDefinitions;
|
||||||
const filteredOrder = order.filter((id) => {
|
const filteredOrder = order.filter((id) => {
|
||||||
const entry = awaitedTankDefinitions.tanks[id];
|
const entry = awaitedTankDefinitions.tanks[id];
|
||||||
|
|
||||||
@@ -44,26 +46,28 @@ export async function filterStats(
|
|||||||
const stats = sumAllStats(filteredOrder.map((id) => diff[id]));
|
const stats = sumAllStats(filteredOrder.map((id) => diff[id]));
|
||||||
const battlesOfTanksWithAverages = filteredOrder.reduce<number>(
|
const battlesOfTanksWithAverages = filteredOrder.reduce<number>(
|
||||||
(accumulator, id) =>
|
(accumulator, id) =>
|
||||||
awaitedTankAverages[id] ? accumulator + diff[id].battles : accumulator,
|
awaitedTankAverages.averages[id]
|
||||||
0
|
? accumulator + diff[id].battles
|
||||||
|
: accumulator,
|
||||||
|
0,
|
||||||
);
|
);
|
||||||
const battlesOfTanksWithTankDefinition = filteredOrder.reduce<number>(
|
const battlesOfTanksWithTankDefinition = filteredOrder.reduce<number>(
|
||||||
(accumulator, id) =>
|
(accumulator, id) =>
|
||||||
awaitedTankDefinitions.tanks[id]
|
awaitedTankDefinitions.tanks[id]
|
||||||
? accumulator + diff[id].battles
|
? accumulator + diff[id].battles
|
||||||
: accumulator,
|
: accumulator,
|
||||||
0
|
0,
|
||||||
);
|
);
|
||||||
const supplementary = {
|
const supplementary = {
|
||||||
WN8:
|
WN8:
|
||||||
filteredOrder.reduce<number>(
|
filteredOrder.reduce<number>(
|
||||||
(accumulator, id) =>
|
(accumulator, id) =>
|
||||||
awaitedTankAverages[id]
|
awaitedTankAverages.averages[id]
|
||||||
? accumulator +
|
? accumulator +
|
||||||
calculateWN8(awaitedTankAverages[id].all, diff[id]) *
|
calculateWN8(awaitedTankAverages.averages[id].mu, diff[id]) *
|
||||||
diff[id].battles
|
diff[id].battles
|
||||||
: accumulator,
|
: accumulator,
|
||||||
0
|
0,
|
||||||
) / battlesOfTanksWithAverages,
|
) / battlesOfTanksWithAverages,
|
||||||
tier:
|
tier:
|
||||||
filteredOrder.reduce<number>(
|
filteredOrder.reduce<number>(
|
||||||
@@ -72,7 +76,7 @@ export async function filterStats(
|
|||||||
? accumulator +
|
? accumulator +
|
||||||
awaitedTankDefinitions.tanks[id]!.tier * diff[id].battles
|
awaitedTankDefinitions.tanks[id]!.tier * diff[id].battles
|
||||||
: accumulator,
|
: accumulator,
|
||||||
0
|
0,
|
||||||
) / battlesOfTanksWithTankDefinition,
|
) / battlesOfTanksWithTankDefinition,
|
||||||
} satisfies SupplementaryStats;
|
} satisfies SupplementaryStats;
|
||||||
|
|
||||||
|
|||||||
@@ -1,101 +0,0 @@
|
|||||||
import { BlitzStats } from '@blitzkit/core';
|
|
||||||
import { context } from '@blitzkit/core/src/blitzkit/context';
|
|
||||||
|
|
||||||
interface SpecialStats {
|
|
||||||
winrate: number;
|
|
||||||
damageRatio: number;
|
|
||||||
kdr: number;
|
|
||||||
damagePerBattle: number;
|
|
||||||
killsPerBattle: number;
|
|
||||||
hitsPerBattle: number;
|
|
||||||
spotsPerBattle: number;
|
|
||||||
wpm: number;
|
|
||||||
dpm: number;
|
|
||||||
kpm: number;
|
|
||||||
hitRate: number;
|
|
||||||
survivalRate: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
export type Percentiles = [
|
|
||||||
number,
|
|
||||||
number,
|
|
||||||
number,
|
|
||||||
number,
|
|
||||||
number,
|
|
||||||
number,
|
|
||||||
number,
|
|
||||||
number,
|
|
||||||
number,
|
|
||||||
];
|
|
||||||
|
|
||||||
export interface SpecialPercentiles {
|
|
||||||
winRate: Percentiles;
|
|
||||||
damageRatio: Percentiles;
|
|
||||||
kdr: Percentiles;
|
|
||||||
damagePerBattle: Percentiles;
|
|
||||||
killsPerBattle: Percentiles;
|
|
||||||
hitsPerBattle: Percentiles;
|
|
||||||
spotsPerBattle: Percentiles;
|
|
||||||
wpm: Percentiles;
|
|
||||||
dpm: Percentiles;
|
|
||||||
kpm: Percentiles;
|
|
||||||
hitRate: Percentiles;
|
|
||||||
survivalRate: Percentiles;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface MeanSd {
|
|
||||||
winrateMean: number;
|
|
||||||
winrateSd: number;
|
|
||||||
hitRateMean: number;
|
|
||||||
hitRateSd: number;
|
|
||||||
survivalRateMean: number;
|
|
||||||
survivalRateSd: number;
|
|
||||||
damageRatioMean: number;
|
|
||||||
damageRatioSd: number;
|
|
||||||
kdrMean: number;
|
|
||||||
kdrSd: number;
|
|
||||||
dpbMean: number;
|
|
||||||
dpbSd: number;
|
|
||||||
kpbMean: number;
|
|
||||||
kpbSd: number;
|
|
||||||
hpbMean: number;
|
|
||||||
hpbSd: number;
|
|
||||||
spbMean: number;
|
|
||||||
spbSd: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface IndividualTankAverage {
|
|
||||||
_id: number;
|
|
||||||
battle_life_time: number;
|
|
||||||
total_battle_life_time: number;
|
|
||||||
number_of_players: number;
|
|
||||||
tank_id: number;
|
|
||||||
all: BlitzStats;
|
|
||||||
special: SpecialStats;
|
|
||||||
percentiles: SpecialPercentiles;
|
|
||||||
percentiles_player_count: number;
|
|
||||||
meanSd: MeanSd;
|
|
||||||
shotEff: number;
|
|
||||||
last_update: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
export type BlitzStarsTankAverages = Record<number, IndividualTankAverage>;
|
|
||||||
|
|
||||||
export const blitzStarsTankAverages = fetch(
|
|
||||||
'https://www.blitzstars.com/api/tankaverages.json',
|
|
||||||
)
|
|
||||||
.then((response) => response.json())
|
|
||||||
.then((json) => {
|
|
||||||
if (context === 'server') {
|
|
||||||
const partialTankAverages: BlitzStarsTankAverages = {};
|
|
||||||
|
|
||||||
(json as IndividualTankAverage[]).forEach((individualTankAverage) => {
|
|
||||||
partialTankAverages[individualTankAverage.tank_id] =
|
|
||||||
individualTankAverage;
|
|
||||||
});
|
|
||||||
|
|
||||||
return partialTankAverages;
|
|
||||||
} else {
|
|
||||||
return json as BlitzStarsTankAverages;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
import { Client, GatewayIntentBits } from 'discord.js';
|
import { Client, GatewayIntentBits } from "discord.js";
|
||||||
import { interactionCreate } from '../../events/interactionCreate';
|
import { interactionCreate } from "../../events/interactionCreate";
|
||||||
import { ready } from '../../events/ready';
|
import { ready } from "../../events/ready";
|
||||||
|
|
||||||
export const client = new Client({
|
export const client = new Client({
|
||||||
intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMembers],
|
intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMembers],
|
||||||
})
|
})
|
||||||
.on('ready', ready)
|
.on("clientReady", ready)
|
||||||
.on('interactionCreate', interactionCreate);
|
.on("interactionCreate", interactionCreate);
|
||||||
@@ -22,11 +22,11 @@ export function createLocalizedCommand(
|
|||||||
command: string,
|
command: string,
|
||||||
sub?:
|
sub?:
|
||||||
| CreateLocalizedCommandSubcommand[]
|
| CreateLocalizedCommandSubcommand[]
|
||||||
| CreateLocalizedCommandSubcommandGroup[]
|
| CreateLocalizedCommandSubcommandGroup[],
|
||||||
) {
|
) {
|
||||||
const commandPathItem = command.replaceAll(
|
const commandPathItem = command.replaceAll(
|
||||||
"-",
|
"-",
|
||||||
"_"
|
"_",
|
||||||
) as keyof BlitzKitStrings["bot"]["commands"];
|
) as keyof BlitzKitStrings["bot"]["commands"];
|
||||||
const { strings } = translator(Locale.EnglishUS);
|
const { strings } = translator(Locale.EnglishUS);
|
||||||
const slashCommand = new SlashCommandBuilder()
|
const slashCommand = new SlashCommandBuilder()
|
||||||
@@ -35,14 +35,14 @@ export function createLocalizedCommand(
|
|||||||
localizationObject(
|
localizationObject(
|
||||||
(strings) => strings.bot.commands[commandPathItem].name,
|
(strings) => strings.bot.commands[commandPathItem].name,
|
||||||
undefined,
|
undefined,
|
||||||
true
|
true,
|
||||||
)
|
),
|
||||||
)
|
)
|
||||||
.setDescription(strings.bot.commands[commandPathItem].description)
|
.setDescription(strings.bot.commands[commandPathItem].description)
|
||||||
.setDescriptionLocalizations(
|
.setDescriptionLocalizations(
|
||||||
localizationObject(
|
localizationObject(
|
||||||
(strings) => strings.bot.commands[commandPathItem].description
|
(strings) => strings.bot.commands[commandPathItem].description,
|
||||||
)
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
if (sub) {
|
if (sub) {
|
||||||
@@ -56,7 +56,7 @@ export function createLocalizedCommand(
|
|||||||
}
|
}
|
||||||
).subcommands[subItem.subcommand].name,
|
).subcommands[subItem.subcommand].name,
|
||||||
undefined,
|
undefined,
|
||||||
true
|
true,
|
||||||
);
|
);
|
||||||
const subcommandDescriptionLocalizations = localizationObject(
|
const subcommandDescriptionLocalizations = localizationObject(
|
||||||
(strings) =>
|
(strings) =>
|
||||||
@@ -64,7 +64,7 @@ export function createLocalizedCommand(
|
|||||||
strings.bot.commands[commandPathItem] as unknown as {
|
strings.bot.commands[commandPathItem] as unknown as {
|
||||||
subcommands: Record<string, { description: string }>;
|
subcommands: Record<string, { description: string }>;
|
||||||
}
|
}
|
||||||
).subcommands[subItem.subcommand].description
|
).subcommands[subItem.subcommand].description,
|
||||||
);
|
);
|
||||||
|
|
||||||
slashCommand.addSubcommand((option) => {
|
slashCommand.addSubcommand((option) => {
|
||||||
@@ -78,7 +78,7 @@ export function createLocalizedCommand(
|
|||||||
strings.bot.commands[commandPathItem] as unknown as {
|
strings.bot.commands[commandPathItem] as unknown as {
|
||||||
subcommands: Record<string, { description: string }>;
|
subcommands: Record<string, { description: string }>;
|
||||||
}
|
}
|
||||||
).subcommands[subItem.subcommand].description
|
).subcommands[subItem.subcommand].description,
|
||||||
)
|
)
|
||||||
.setDescriptionLocalizations(subcommandDescriptionLocalizations);
|
.setDescriptionLocalizations(subcommandDescriptionLocalizations);
|
||||||
});
|
});
|
||||||
@@ -91,7 +91,7 @@ export function createLocalizedCommand(
|
|||||||
}
|
}
|
||||||
).groups[subItem.group].name,
|
).groups[subItem.group].name,
|
||||||
undefined,
|
undefined,
|
||||||
true
|
true,
|
||||||
);
|
);
|
||||||
const subcommandDescriptionLocalizations = localizationObject(
|
const subcommandDescriptionLocalizations = localizationObject(
|
||||||
(strings) =>
|
(strings) =>
|
||||||
@@ -99,7 +99,7 @@ export function createLocalizedCommand(
|
|||||||
strings.bot.commands[commandPathItem] as unknown as {
|
strings.bot.commands[commandPathItem] as unknown as {
|
||||||
groups: Record<string, { description: string }>;
|
groups: Record<string, { description: string }>;
|
||||||
}
|
}
|
||||||
).groups[subItem.group].description
|
).groups[subItem.group].description,
|
||||||
);
|
);
|
||||||
|
|
||||||
slashCommand.addSubcommandGroup((option) => {
|
slashCommand.addSubcommandGroup((option) => {
|
||||||
@@ -113,7 +113,7 @@ export function createLocalizedCommand(
|
|||||||
strings.bot.commands[commandPathItem] as unknown as {
|
strings.bot.commands[commandPathItem] as unknown as {
|
||||||
groups: Record<string, { description: string }>;
|
groups: Record<string, { description: string }>;
|
||||||
}
|
}
|
||||||
).groups[subItem.group].description
|
).groups[subItem.group].description,
|
||||||
)
|
)
|
||||||
.setDescriptionLocalizations(subcommandDescriptionLocalizations);
|
.setDescriptionLocalizations(subcommandDescriptionLocalizations);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
import { AutocompleteInteraction, CacheType } from 'discord.js';
|
import { AutocompleteInteraction, CacheType } from "discord.js";
|
||||||
import { commands } from '..';
|
import { commands } from "..";
|
||||||
|
|
||||||
export async function handleAutocomplete(
|
export async function handleAutocomplete(
|
||||||
interaction: AutocompleteInteraction<CacheType>,
|
interaction: AutocompleteInteraction<CacheType>,
|
||||||
) {
|
) {
|
||||||
const command = (await commands)[interaction.commandName];
|
const command = commands[interaction.commandName];
|
||||||
|
|
||||||
if (!command) {
|
if (!command) {
|
||||||
console.error(`No command matching ${interaction.commandName} was found.`);
|
console.error(`No command matching ${interaction.commandName} was found.`);
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
import { ButtonInteraction, CacheType } from 'discord.js';
|
import { ButtonInteraction, CacheType } from "discord.js";
|
||||||
import { commands } from '..';
|
import { commands } from "..";
|
||||||
import { normalizeInteractionReturnable } from '../../../core/discord/normalizeInteractionReturnable';
|
import { normalizeInteractionReturnable } from "../../../core/discord/normalizeInteractionReturnable";
|
||||||
|
|
||||||
export async function handleButton(interaction: ButtonInteraction<CacheType>) {
|
export async function handleButton(interaction: ButtonInteraction<CacheType>) {
|
||||||
await interaction.deferUpdate();
|
await interaction.deferUpdate();
|
||||||
|
|
||||||
const url = new URL(`https://example.com/${interaction.customId}`);
|
const url = new URL(`https://example.com/${interaction.customId}`);
|
||||||
const commandName = url.pathname.split('/')[1];
|
const commandName = url.pathname.split("/")[1];
|
||||||
const button = (await commands)[commandName]?.button;
|
const button = commands[commandName]?.button;
|
||||||
|
|
||||||
if (!button) {
|
if (!button) {
|
||||||
throw new Error(`Button handler not found for "${commandName}"`);
|
throw new Error(`Button handler not found for "${commandName}"`);
|
||||||
@@ -16,7 +16,7 @@ export async function handleButton(interaction: ButtonInteraction<CacheType>) {
|
|||||||
if (interaction.message.interaction?.user.id !== interaction.user.id) {
|
if (interaction.message.interaction?.user.id !== interaction.user.id) {
|
||||||
interaction.followUp({
|
interaction.followUp({
|
||||||
ephemeral: true,
|
ephemeral: true,
|
||||||
content: 'You are not the author of this command.',
|
content: "You are not the author of this command.",
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,12 +17,11 @@ import { translator } from "../../../core/localization/translator";
|
|||||||
import type { Writeable } from "../../../types/writable";
|
import type { Writeable } from "../../../types/writable";
|
||||||
|
|
||||||
export async function handleChatInputCommand(
|
export async function handleChatInputCommand(
|
||||||
interaction: ChatInputCommandInteraction<CacheType>
|
interaction: ChatInputCommandInteraction<CacheType>,
|
||||||
) {
|
) {
|
||||||
await interaction.deferReply();
|
await interaction.deferReply();
|
||||||
|
|
||||||
const awaitedCommands = await commands;
|
const registry = commands[interaction.commandName];
|
||||||
const registry = awaitedCommands[interaction.commandName];
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const returnable = await registry.handler(interaction);
|
const returnable = await registry.handler(interaction);
|
||||||
@@ -36,7 +35,7 @@ export async function handleChatInputCommand(
|
|||||||
if (typeof object === "string") {
|
if (typeof object === "string") {
|
||||||
chunks.push([object]);
|
chunks.push([object]);
|
||||||
} else chunks.at(-1)?.push(object!);
|
} else chunks.at(-1)?.push(object!);
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
let index = 0;
|
let index = 0;
|
||||||
@@ -59,7 +58,7 @@ export async function handleChatInputCommand(
|
|||||||
} else if (psa.data.type === "image") {
|
} else if (psa.data.type === "image") {
|
||||||
if (!reply.files) reply.files = [];
|
if (!reply.files) reply.files = [];
|
||||||
(reply.files as Writeable<typeof reply.files>).push(
|
(reply.files as Writeable<typeof reply.files>).push(
|
||||||
new AttachmentBuilder(psa.data.image)
|
new AttachmentBuilder(psa.data.image),
|
||||||
);
|
);
|
||||||
reply.content = reply.content ?? psa.data.title;
|
reply.content = reply.content ?? psa.data.title;
|
||||||
}
|
}
|
||||||
@@ -72,7 +71,7 @@ export async function handleChatInputCommand(
|
|||||||
(
|
(
|
||||||
reply.components[0] as ActionRowBuilder<ButtonBuilder>
|
reply.components[0] as ActionRowBuilder<ButtonBuilder>
|
||||||
).addComponents(
|
).addComponents(
|
||||||
psa.data.links.map(({ title, url }) => buttonLink(url, title))
|
psa.data.links.map(({ title, url }) => buttonLink(url, title)),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -103,7 +102,7 @@ export async function handleChatInputCommand(
|
|||||||
} else if (psa.data.type === "image") {
|
} else if (psa.data.type === "image") {
|
||||||
if (!followUp.files) followUp.files = [];
|
if (!followUp.files) followUp.files = [];
|
||||||
(followUp.files as Writeable<typeof followUp.files>).push(
|
(followUp.files as Writeable<typeof followUp.files>).push(
|
||||||
new AttachmentBuilder(psa.data.image)
|
new AttachmentBuilder(psa.data.image),
|
||||||
);
|
);
|
||||||
followUp.content = followUp.content ?? psa.data.title;
|
followUp.content = followUp.content ?? psa.data.title;
|
||||||
}
|
}
|
||||||
@@ -116,7 +115,7 @@ export async function handleChatInputCommand(
|
|||||||
(
|
(
|
||||||
followUp.components[0] as ActionRowBuilder<ButtonBuilder>
|
followUp.components[0] as ActionRowBuilder<ButtonBuilder>
|
||||||
).addComponents(
|
).addComponents(
|
||||||
psa.data.links.map(({ title, url }) => buttonLink(url, title))
|
psa.data.links.map(({ title, url }) => buttonLink(url, title)),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -133,7 +132,7 @@ export async function handleChatInputCommand(
|
|||||||
new ButtonBuilder()
|
new ButtonBuilder()
|
||||||
.setLabel(strings.bot.common.errors.get_help)
|
.setLabel(strings.bot.common.errors.get_help)
|
||||||
.setURL("https://discord.gg/nDt7AjGJQH")
|
.setURL("https://discord.gg/nDt7AjGJQH")
|
||||||
.setStyle(ButtonStyle.Link)
|
.setStyle(ButtonStyle.Link),
|
||||||
),
|
),
|
||||||
];
|
];
|
||||||
if (error instanceof UserError) {
|
if (error instanceof UserError) {
|
||||||
|
|||||||
@@ -72,13 +72,13 @@ interface CommandRegistryImplicit extends CommandRegistryBase {
|
|||||||
interface CommandRegistryExplicit extends CommandRegistryBase {
|
interface CommandRegistryExplicit extends CommandRegistryBase {
|
||||||
handlesInteraction?: false;
|
handlesInteraction?: false;
|
||||||
handler: (
|
handler: (
|
||||||
interaction: ChatInputCommandInteraction<CacheType>
|
interaction: ChatInputCommandInteraction<CacheType>,
|
||||||
) => InteractionReturnable;
|
) => InteractionReturnable;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type CommandRegistry = CommandRegistryImplicit | CommandRegistryExplicit;
|
export type CommandRegistry = CommandRegistryImplicit | CommandRegistryExplicit;
|
||||||
|
|
||||||
export const COMMANDS_RAW: Promise<CommandRegistry>[] = [
|
export const commandsArray: Promise<CommandRegistry>[] = [
|
||||||
// auctionCommand,
|
// auctionCommand,
|
||||||
permissionsCommand,
|
permissionsCommand,
|
||||||
debugCommand,
|
debugCommand,
|
||||||
@@ -101,34 +101,28 @@ export const COMMANDS_RAW: Promise<CommandRegistry>[] = [
|
|||||||
replayCommand,
|
replayCommand,
|
||||||
];
|
];
|
||||||
|
|
||||||
export const commands = Promise.allSettled(COMMANDS_RAW).then((rawCommands) => {
|
export const commands: Record<string, CommandRegistry> = {};
|
||||||
return rawCommands.reduce<Record<string, CommandRegistry>>(
|
const commandsFulfilled: CommandRegistry[] = [];
|
||||||
(commands, registry, index) => {
|
|
||||||
if (registry.status === "rejected") {
|
let index = 0;
|
||||||
console.warn(
|
for (const registry of await Promise.allSettled(commandsArray)) {
|
||||||
`Command ${index} failed to load; skipping...`,
|
if (registry.status === "rejected") {
|
||||||
registry.reason
|
console.warn(`Command ${index} rejected`, registry.reason);
|
||||||
);
|
continue;
|
||||||
return commands;
|
}
|
||||||
}
|
|
||||||
return { ...commands, [registry.value.command.name]: registry.value };
|
commandsFulfilled.push(registry.value);
|
||||||
},
|
commands[registry.value.command.name] = registry.value;
|
||||||
{}
|
index++;
|
||||||
);
|
}
|
||||||
});
|
|
||||||
|
|
||||||
const rest = new REST().setToken(assertSecret(import.meta.env.DISCORD_TOKEN));
|
const rest = new REST().setToken(assertSecret(import.meta.env.DISCORD_TOKEN));
|
||||||
|
const body = commandsFulfilled.map((registry) => registry.command.toJSON());
|
||||||
|
const applicationCommandsRoute = Routes.applicationCommands(
|
||||||
|
assertSecret(import.meta.env.DISCORD_CLIENT_ID),
|
||||||
|
);
|
||||||
|
|
||||||
commands.then((awaitedCommands) => {
|
await rest.put(applicationCommandsRoute, { body });
|
||||||
const body = Object.values(awaitedCommands).map((registry) =>
|
|
||||||
registry.command.toJSON()
|
|
||||||
);
|
|
||||||
|
|
||||||
rest.put(
|
|
||||||
Routes.applicationCommands(assertSecret(import.meta.env.DISCORD_CLIENT_ID)),
|
|
||||||
{ body }
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
export async function interactionCreate(interaction: Interaction<CacheType>) {
|
export async function interactionCreate(interaction: Interaction<CacheType>) {
|
||||||
if (interaction.isAutocomplete()) {
|
if (interaction.isAutocomplete()) {
|
||||||
|
|||||||
+14
-14
@@ -1,27 +1,27 @@
|
|||||||
import { assertSecret } from '@blitzkit/core';
|
import { assertSecret } from "@blitzkit/core";
|
||||||
import { ActivityType, ShardingManager } from 'discord.js';
|
import { ActivityType, ShardingManager } from "discord.js";
|
||||||
import {
|
import {
|
||||||
discoveredIdsDefinitions,
|
discoveredIdsDefinitions,
|
||||||
tankDefinitions,
|
tankDefinitions,
|
||||||
} from './core/blitzkit/nonBlockingPromises';
|
} from "./core/blitzkit/nonBlockingPromises";
|
||||||
|
|
||||||
|
let manager: ShardingManager;
|
||||||
let iteration = 0;
|
let iteration = 0;
|
||||||
const interval = setInterval(async () => {
|
const interval = setInterval(async () => {
|
||||||
iteration++;
|
console.log(`Attempting launch on iteration ${++iteration}`);
|
||||||
|
|
||||||
console.log(`Attempting launch on iteration ${iteration}`);
|
manager?.respawnAll();
|
||||||
|
manager = new ShardingManager("dist/bot/workers/bot.js", {
|
||||||
const manager = new ShardingManager('dist/bot/workers/bot.js', {
|
|
||||||
token: assertSecret(import.meta.env.DISCORD_TOKEN),
|
token: assertSecret(import.meta.env.DISCORD_TOKEN),
|
||||||
});
|
});
|
||||||
|
|
||||||
const shards = await manager
|
const shards = await manager
|
||||||
.on('shardCreate', (shard) => {
|
.on("shardCreate", (shard) => {
|
||||||
clearInterval(interval);
|
clearInterval(interval);
|
||||||
console.log(`🟡 Launching shard ${shard.id}`);
|
console.log(`🟡 Launching shard ${shard.id}`);
|
||||||
shard.on('ready', () => console.log(`🟢 Launched shard ${shard.id}`));
|
shard.on("ready", () => console.log(`🟢 Launched shard ${shard.id}`));
|
||||||
})
|
})
|
||||||
.spawn();
|
.spawn({ timeout: 60000 });
|
||||||
|
|
||||||
try {
|
try {
|
||||||
let servers = 0;
|
let servers = 0;
|
||||||
@@ -29,7 +29,7 @@ const interval = setInterval(async () => {
|
|||||||
let users = 0;
|
let users = 0;
|
||||||
|
|
||||||
for (const [, shard] of shards) {
|
for (const [, shard] of shards) {
|
||||||
const guilds = (await shard.fetchClientValue('guilds.cache')) as any;
|
const guilds = (await shard.fetchClientValue("guilds.cache")) as any;
|
||||||
|
|
||||||
servers += guilds.length;
|
servers += guilds.length;
|
||||||
|
|
||||||
@@ -66,7 +66,7 @@ const interval = setInterval(async () => {
|
|||||||
for (const guild of client.guilds.cache.values()) {
|
for (const guild of client.guilds.cache.values()) {
|
||||||
try {
|
try {
|
||||||
const botMember = await guild.members.fetch(client.user.id);
|
const botMember = await guild.members.fetch(client.user.id);
|
||||||
await botMember.setNickname('BlitzKit');
|
await botMember.setNickname("BlitzKit");
|
||||||
} catch {}
|
} catch {}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -74,8 +74,8 @@ const interval = setInterval(async () => {
|
|||||||
);
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.warn(
|
console.warn(
|
||||||
'An error occurred when setting up presence, ignoring to keep the process alive',
|
"An error occurred when setting up presence, ignoring to keep the process alive",
|
||||||
error,
|
error,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}, 5000);
|
}, 15000);
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import { assertSecret } from '@blitzkit/core';
|
import { assertSecret } from "@blitzkit/core";
|
||||||
import { registerProcesses } from '../core/blitzkit/processes';
|
import { registerProcesses } from "../core/blitzkit/processes";
|
||||||
import { client } from '../core/discord/client';
|
import { client } from "../core/discord/client";
|
||||||
|
|
||||||
console.log(`🟡 Launching bot ${client.shard?.ids[0]}`);
|
console.log(`🟡 Launching bot ${client.shard?.ids[0]}`);
|
||||||
|
|
||||||
|
|||||||
@@ -493,7 +493,7 @@
|
|||||||
"description": "Search clans",
|
"description": "Search clans",
|
||||||
"options": {
|
"options": {
|
||||||
"limit": {
|
"limit": {
|
||||||
"name": "limit",
|
"name": "",
|
||||||
"description": "The max number of clan results (default: {limit})"
|
"description": "The max number of clan results (default: {limit})"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -507,7 +507,7 @@
|
|||||||
"description": "Search players",
|
"description": "Search players",
|
||||||
"options": {
|
"options": {
|
||||||
"limit": {
|
"limit": {
|
||||||
"name": "limit",
|
"name": "",
|
||||||
"description": "The max number of player results (default: {limit})"
|
"description": "The max number of player results (default: {limit})"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -531,7 +531,7 @@
|
|||||||
},
|
},
|
||||||
"options": {
|
"options": {
|
||||||
"limit": {
|
"limit": {
|
||||||
"name": "limit",
|
"name": "",
|
||||||
"description": "How many neighbors to display (default: {count})"
|
"description": "How many neighbors to display (default: {count})"
|
||||||
},
|
},
|
||||||
"season": {
|
"season": {
|
||||||
@@ -675,7 +675,7 @@
|
|||||||
"active": "{name} (Active)",
|
"active": "{name} (Active)",
|
||||||
"no_tanks_found": {
|
"no_tanks_found": {
|
||||||
"body": "No tanks found.",
|
"body": "No tanks found.",
|
||||||
"search_again": "Try searching again.",
|
"search_again": "",
|
||||||
"clear_filters": "Try clearing filters."
|
"clear_filters": "Try clearing filters."
|
||||||
},
|
},
|
||||||
"sort": {
|
"sort": {
|
||||||
|
|||||||
@@ -24,7 +24,7 @@
|
|||||||
"shells": {
|
"shells": {
|
||||||
"ap": "ББ",
|
"ap": "ББ",
|
||||||
"ap_cr": "БП",
|
"ap_cr": "БП",
|
||||||
"hc": "ОФ",
|
"hc": "КС",
|
||||||
"he": "ОФ"
|
"he": "ОФ"
|
||||||
},
|
},
|
||||||
"player_count_period": {
|
"player_count_period": {
|
||||||
@@ -39,7 +39,7 @@
|
|||||||
"branches": {
|
"branches": {
|
||||||
"local": "dev",
|
"local": "dev",
|
||||||
"dev": "бета",
|
"dev": "бета",
|
||||||
"opentest": "открытый тест",
|
"opentest": "общий тест",
|
||||||
"preview": "превью"
|
"preview": "превью"
|
||||||
},
|
},
|
||||||
"locales": {
|
"locales": {
|
||||||
|
|||||||
@@ -1,15 +1,10 @@
|
|||||||
import { build } from "esbuild";
|
import { build } from "esbuild";
|
||||||
import { cp, readdir, rm } from "fs/promises";
|
import { cp, readdir, rm } from "fs/promises";
|
||||||
import { argv } from "process";
|
|
||||||
|
|
||||||
const dev = argv.includes("--dev");
|
|
||||||
|
|
||||||
const projectDir = "../..";
|
const projectDir = "../..";
|
||||||
const srcRoot = `${projectDir}/packages/bot`;
|
const srcRoot = `${projectDir}/packages/bot`;
|
||||||
const distRoot = `${projectDir}/dist/bot`;
|
const distRoot = `${projectDir}/dist/bot`;
|
||||||
const modulesRoot = dev
|
const modulesRoot = "../../node_modules";
|
||||||
? "../../packages/bot/node_modules"
|
|
||||||
: "../../node_modules";
|
|
||||||
const workers = await readdir(`${srcRoot}/src/workers`);
|
const workers = await readdir(`${srcRoot}/src/workers`);
|
||||||
|
|
||||||
await rm(distRoot, { recursive: true, force: true });
|
await rm(distRoot, { recursive: true, force: true });
|
||||||
@@ -30,9 +25,9 @@ build({
|
|||||||
},
|
},
|
||||||
external: ["sharp"],
|
external: ["sharp"],
|
||||||
minifyIdentifiers: false, // causes goofy ahh issues
|
minifyIdentifiers: false, // causes goofy ahh issues
|
||||||
minifySyntax: !dev,
|
minifySyntax: true,
|
||||||
minifyWhitespace: !dev,
|
minifyWhitespace: true,
|
||||||
sourcemap: !dev,
|
sourcemap: true,
|
||||||
jsxImportSource: "react",
|
jsxImportSource: "react",
|
||||||
jsx: "automatic",
|
jsx: "automatic",
|
||||||
});
|
});
|
||||||
@@ -44,18 +39,16 @@ for (const module of await readdir(`${modulesRoot}/@resvg`)) {
|
|||||||
.map((file) =>
|
.map((file) =>
|
||||||
cp(
|
cp(
|
||||||
`${modulesRoot}/@resvg/${module}/${file}`,
|
`${modulesRoot}/@resvg/${module}/${file}`,
|
||||||
`${distRoot}/workers/${file}`
|
`${distRoot}/workers/${file}`,
|
||||||
)
|
),
|
||||||
)
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!dev) {
|
await cp(`${projectDir}/prisma`, `${distRoot}/prisma`, { recursive: true });
|
||||||
await cp(`${projectDir}/prisma`, `${distRoot}/prisma`, { recursive: true });
|
|
||||||
|
|
||||||
for (const file of await readdir(`${modulesRoot}/prisma`).then((files) =>
|
for (const file of await readdir(`${modulesRoot}/prisma`).then((files) =>
|
||||||
files.filter((file) => file.endsWith(".node"))
|
files.filter((file) => file.endsWith(".node")),
|
||||||
)) {
|
)) {
|
||||||
cp(`${modulesRoot}/prisma/${file}`, `${distRoot}/prisma/${file}`);
|
cp(`${modulesRoot}/prisma/${file}`, `${distRoot}/prisma/${file}`);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -6,7 +6,7 @@ import {
|
|||||||
} from "@blitzkit/core";
|
} from "@blitzkit/core";
|
||||||
import { Accessor, Document, Node, Scene } from "@gltf-transform/core";
|
import { Accessor, Document, Node, Scene } from "@gltf-transform/core";
|
||||||
import { times } from "lodash-es";
|
import { times } from "lodash-es";
|
||||||
import { SteamVFS } from "../vfs/vfs";
|
import { SteamVFS } from "../vfs/steam";
|
||||||
import {
|
import {
|
||||||
vertexAttributeGLTFName,
|
vertexAttributeGLTFName,
|
||||||
vertexAttributeGltfVectorSizes,
|
vertexAttributeGltfVectorSizes,
|
||||||
@@ -16,10 +16,10 @@ export async function extractArmor(vfs: SteamVFS, fileName: string) {
|
|||||||
const sc2Path = `Data/3d/Tanks/CollisionMeshes/${fileName}.sc2`;
|
const sc2Path = `Data/3d/Tanks/CollisionMeshes/${fileName}.sc2`;
|
||||||
const scgPath = `Data/3d/Tanks/CollisionMeshes/${fileName}.scg`;
|
const scgPath = `Data/3d/Tanks/CollisionMeshes/${fileName}.scg`;
|
||||||
const sc2 = new Sc2ReadStream(
|
const sc2 = new Sc2ReadStream(
|
||||||
(await vfs.file(sc2Path)).buffer as ArrayBuffer
|
(await vfs.file(sc2Path)).buffer as ArrayBuffer,
|
||||||
).sc2();
|
).sc2();
|
||||||
const scg = new ScgReadStream(
|
const scg = new ScgReadStream(
|
||||||
(await vfs.file(scgPath)).buffer as ArrayBuffer
|
(await vfs.file(scgPath)).buffer as ArrayBuffer,
|
||||||
).scg();
|
).scg();
|
||||||
const document = new Document();
|
const document = new Document();
|
||||||
const scene = document.createScene();
|
const scene = document.createScene();
|
||||||
@@ -29,7 +29,7 @@ export async function extractArmor(vfs: SteamVFS, fileName: string) {
|
|||||||
hierarchies.forEach((hierarchy) => {
|
hierarchies.forEach((hierarchy) => {
|
||||||
const components = times(
|
const components = times(
|
||||||
hierarchy.components.count,
|
hierarchy.components.count,
|
||||||
(index) => hierarchy.components[index.toString().padStart(4, "0")]
|
(index) => hierarchy.components[index.toString().padStart(4, "0")],
|
||||||
);
|
);
|
||||||
|
|
||||||
components.forEach((component) => {
|
components.forEach((component) => {
|
||||||
@@ -43,7 +43,7 @@ export async function extractArmor(vfs: SteamVFS, fileName: string) {
|
|||||||
|
|
||||||
if (!polygonGroup) {
|
if (!polygonGroup) {
|
||||||
console.warn(
|
console.warn(
|
||||||
`Missing polygon group ${batch["rb.datasource"]} (${hierarchy.name}); skipping...`
|
`Missing polygon group ${batch["rb.datasource"]} (${hierarchy.name}); skipping...`,
|
||||||
);
|
);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@@ -73,7 +73,7 @@ export async function extractArmor(vfs: SteamVFS, fileName: string) {
|
|||||||
VertexAttribute.TANGENT,
|
VertexAttribute.TANGENT,
|
||||||
attributes
|
attributes
|
||||||
.get(VertexAttribute.TANGENT)!
|
.get(VertexAttribute.TANGENT)!
|
||||||
.map((tangent) => [...tangent, 1])
|
.map((tangent) => [...tangent, 1]),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -94,7 +94,7 @@ export async function extractArmor(vfs: SteamVFS, fileName: string) {
|
|||||||
|
|
||||||
hardJointIndices.forEach((hardJointIndex) => {
|
hardJointIndices.forEach((hardJointIndex) => {
|
||||||
const node = document.createNode(
|
const node = document.createNode(
|
||||||
`${hierarchy.name}_armor_${hardJointIndex}`
|
`${hierarchy.name}_armor_${hardJointIndex}`,
|
||||||
);
|
);
|
||||||
const mesh = document.createMesh(batch["##name"]);
|
const mesh = document.createMesh(batch["##name"]);
|
||||||
const indicesAccessor = document
|
const indicesAccessor = document
|
||||||
@@ -104,9 +104,9 @@ export async function extractArmor(vfs: SteamVFS, fileName: string) {
|
|||||||
new Uint16Array(
|
new Uint16Array(
|
||||||
polygonGroup.indices.filter(
|
polygonGroup.indices.filter(
|
||||||
(index) =>
|
(index) =>
|
||||||
vertexHardJointIndices.get(index) === hardJointIndex
|
vertexHardJointIndices.get(index) === hardJointIndex,
|
||||||
)
|
),
|
||||||
)
|
),
|
||||||
)
|
)
|
||||||
.setBuffer(buffer);
|
.setBuffer(buffer);
|
||||||
const primitive = document
|
const primitive = document
|
||||||
@@ -127,7 +127,7 @@ export async function extractArmor(vfs: SteamVFS, fileName: string) {
|
|||||||
|
|
||||||
default:
|
default:
|
||||||
throw new TypeError(
|
throw new TypeError(
|
||||||
`Unhandled component type: ${component["comp.typename"]}`
|
`Unhandled component type: ${component["comp.typename"]}`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import { Document, Material, Node, Scene } from "@gltf-transform/core";
|
|||||||
import { dedup, prune } from "@gltf-transform/functions";
|
import { dedup, prune } from "@gltf-transform/functions";
|
||||||
import { times } from "lodash-es";
|
import { times } from "lodash-es";
|
||||||
import { dirname } from "path";
|
import { dirname } from "path";
|
||||||
import { SteamVFS } from "../../vfs/vfs";
|
import { SteamVFS } from "../../vfs/steam";
|
||||||
import { readBaseColor } from "../readBaseColor";
|
import { readBaseColor } from "../readBaseColor";
|
||||||
import { readNormal } from "../readNormal";
|
import { readNormal } from "../readNormal";
|
||||||
import { readRoughnessMetallic } from "../readRoughnessMetallic";
|
import { readRoughnessMetallic } from "../readRoughnessMetallic";
|
||||||
@@ -29,10 +29,10 @@ export async function extractModel(vfs: SteamVFS, path: string) {
|
|||||||
const sc2Path = `Data/3d/${path}.sc2`;
|
const sc2Path = `Data/3d/${path}.sc2`;
|
||||||
const scgPath = `Data/3d/${path}.scg`;
|
const scgPath = `Data/3d/${path}.scg`;
|
||||||
const sc2 = new Sc2ReadStream(
|
const sc2 = new Sc2ReadStream(
|
||||||
(await vfs.file(sc2Path)).buffer as ArrayBuffer
|
(await vfs.file(sc2Path)).buffer as ArrayBuffer,
|
||||||
).sc2();
|
).sc2();
|
||||||
const scg = new ScgReadStream(
|
const scg = new ScgReadStream(
|
||||||
(await vfs.file(scgPath)).buffer as ArrayBuffer
|
(await vfs.file(scgPath)).buffer as ArrayBuffer,
|
||||||
).scg();
|
).scg();
|
||||||
const document = new Document();
|
const document = new Document();
|
||||||
const scene = document.createScene();
|
const scene = document.createScene();
|
||||||
@@ -61,20 +61,17 @@ export async function extractModel(vfs: SteamVFS, path: string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (textures) {
|
if (textures) {
|
||||||
|
const { image: baseColor, hasAlpha } = await readBaseColor(
|
||||||
|
`Data/3d/${dirname(path)}/${textures.baseColorMap ?? textures.albedo}`,
|
||||||
|
textures.miscMap
|
||||||
|
? `Data/3d/${dirname(path)}/${textures.miscMap}`
|
||||||
|
: undefined,
|
||||||
|
);
|
||||||
material.setBaseColorTexture(
|
material.setBaseColorTexture(
|
||||||
document
|
document
|
||||||
.createTexture(node.materialName)
|
.createTexture(node.materialName)
|
||||||
.setMimeType("image/webp")
|
.setMimeType("image/webp")
|
||||||
.setImage(
|
.setImage(baseColor),
|
||||||
await readBaseColor(
|
|
||||||
`Data/3d/${dirname(path)}/${
|
|
||||||
textures.baseColorMap ?? textures.albedo
|
|
||||||
}`,
|
|
||||||
textures.miscMap
|
|
||||||
? `Data/3d/${dirname(path)}/${textures.miscMap}`
|
|
||||||
: undefined
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
if (node.configCount) {
|
if (node.configCount) {
|
||||||
@@ -83,15 +80,7 @@ export async function extractModel(vfs: SteamVFS, path: string) {
|
|||||||
configIndex < node.configCount;
|
configIndex < node.configCount;
|
||||||
configIndex++
|
configIndex++
|
||||||
) {
|
) {
|
||||||
const archive = node[`configArchive_${configIndex}`];
|
if (!hasAlpha) continue;
|
||||||
|
|
||||||
if (
|
|
||||||
archive.configName !== "Default" ||
|
|
||||||
!archive.enabledPresets?.AlphaTest
|
|
||||||
) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
material.setAlphaMode("BLEND").setDoubleSided(true);
|
material.setAlphaMode("BLEND").setDoubleSided(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -103,9 +92,9 @@ export async function extractModel(vfs: SteamVFS, path: string) {
|
|||||||
.setMimeType("image/webp")
|
.setMimeType("image/webp")
|
||||||
.setImage(
|
.setImage(
|
||||||
await readRoughnessMetallic(
|
await readRoughnessMetallic(
|
||||||
`Data/3d/${dirname(path)}/${textures.baseRMMap}`
|
`Data/3d/${dirname(path)}/${textures.baseRMMap}`,
|
||||||
)
|
),
|
||||||
)
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -121,9 +110,9 @@ export async function extractModel(vfs: SteamVFS, path: string) {
|
|||||||
`Data/3d/${dirname(path)}/${
|
`Data/3d/${dirname(path)}/${
|
||||||
textures.baseNormalMap ?? textures.normalmap
|
textures.baseNormalMap ?? textures.normalmap
|
||||||
}`,
|
}`,
|
||||||
isBase
|
isBase,
|
||||||
)
|
),
|
||||||
)
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -157,7 +146,7 @@ export async function extractModel(vfs: SteamVFS, path: string) {
|
|||||||
const node = document.createNode(hierarchy.name);
|
const node = document.createNode(hierarchy.name);
|
||||||
const components = times(
|
const components = times(
|
||||||
hierarchy.components.count,
|
hierarchy.components.count,
|
||||||
(index) => hierarchy.components[index.toString().padStart(4, "0")]
|
(index) => hierarchy.components[index.toString().padStart(4, "0")],
|
||||||
);
|
);
|
||||||
|
|
||||||
components.forEach((component) => {
|
components.forEach((component) => {
|
||||||
@@ -194,7 +183,7 @@ export async function extractModel(vfs: SteamVFS, path: string) {
|
|||||||
}
|
}
|
||||||
if (polygonGroup === undefined) {
|
if (polygonGroup === undefined) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Missing polygon group ${batch["rb.datasource"]}`
|
`Missing polygon group ${batch["rb.datasource"]}`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -255,7 +244,7 @@ export async function extractModel(vfs: SteamVFS, path: string) {
|
|||||||
default: {
|
default: {
|
||||||
if (ERROR_ON_UNKNOWN_COMPONENT) {
|
if (ERROR_ON_UNKNOWN_COMPONENT) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Unhandled component type: ${component["comp.typename"]}`
|
`Unhandled component type: ${component["comp.typename"]}`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import sharp from "sharp";
|
|||||||
import { readTexture } from "./readTexture";
|
import { readTexture } from "./readTexture";
|
||||||
|
|
||||||
export async function readBaseColor(path: string, occlusionPath?: string) {
|
export async function readBaseColor(path: string, occlusionPath?: string) {
|
||||||
|
let hasAlpha = false;
|
||||||
const baseRaw = await readTexture(path);
|
const baseRaw = await readTexture(path);
|
||||||
const occlusionRaw = occlusionPath
|
const occlusionRaw = occlusionPath
|
||||||
? await readTexture(occlusionPath)
|
? await readTexture(occlusionPath)
|
||||||
@@ -30,10 +31,13 @@ export async function readBaseColor(path: string, occlusionPath?: string) {
|
|||||||
c = occlusion![occlusionI] / 255;
|
c = occlusion![occlusionI] / 255;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const alpha = base[i * 4 + 3];
|
||||||
|
hasAlpha ||= alpha < 255;
|
||||||
|
|
||||||
combined[i * 4 + 0] = Math.round(base[i * 4 + 0] * c);
|
combined[i * 4 + 0] = Math.round(base[i * 4 + 0] * c);
|
||||||
combined[i * 4 + 1] = Math.round(base[i * 4 + 1] * c);
|
combined[i * 4 + 1] = Math.round(base[i * 4 + 1] * c);
|
||||||
combined[i * 4 + 2] = Math.round(base[i * 4 + 2] * c);
|
combined[i * 4 + 2] = Math.round(base[i * 4 + 2] * c);
|
||||||
combined[i * 4 + 3] = base[i * 4 + 3];
|
combined[i * 4 + 3] = alpha;
|
||||||
}
|
}
|
||||||
|
|
||||||
const image = await sharp(combined, {
|
const image = await sharp(combined, {
|
||||||
@@ -42,5 +46,5 @@ export async function readBaseColor(path: string, occlusionPath?: string) {
|
|||||||
.webp()
|
.webp()
|
||||||
.toBuffer();
|
.toBuffer();
|
||||||
|
|
||||||
return image;
|
return { hasAlpha, image };
|
||||||
}
|
}
|
||||||
@@ -32,12 +32,13 @@
|
|||||||
"compare-versions": "^6.1.1",
|
"compare-versions": "^6.1.1",
|
||||||
"fuzzysort": "^3.1.0",
|
"fuzzysort": "^3.1.0",
|
||||||
"immer": "^10.1.3",
|
"immer": "^10.1.3",
|
||||||
|
"jimp": "^1.6.0",
|
||||||
"lodash-es": "^4.17.21",
|
"lodash-es": "^4.17.21",
|
||||||
"markdown-to-jsx": "^7.7.13",
|
"markdown-to-jsx": "^7.7.13",
|
||||||
"pwa-install-handler": "^2.6.3",
|
"pwa-install-handler": "^2.6.3",
|
||||||
"quicklime": "^1.2.0",
|
"quicklime": "^1.2.0",
|
||||||
"react": "^19.2.0",
|
"react": "^19.2.4",
|
||||||
"react-dom": "^19.2.0",
|
"react-dom": "^19.2.4",
|
||||||
"react-promise-suspense": "^0.3.4",
|
"react-promise-suspense": "^0.3.4",
|
||||||
"three": "^0.180.0",
|
"three": "^0.180.0",
|
||||||
"three-stdlib": "^2.36.0",
|
"three-stdlib": "^2.36.0",
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { I_HAT, J_HAT } from "@blitzkit/core";
|
import { I_HAT, J_HAT } from "@blitzkit/core";
|
||||||
import { useThree } from "@react-three/fiber";
|
import { invalidate, useThree } from "@react-three/fiber";
|
||||||
import { clamp } from "lodash-es";
|
import { clamp } from "lodash-es";
|
||||||
import type { QuicklimeEvent } from "quicklime";
|
import type { QuicklimeEvent } from "quicklime";
|
||||||
import { useEffect, useMemo, type ComponentProps } from "react";
|
import { useEffect, useMemo, type ComponentProps } from "react";
|
||||||
@@ -91,7 +91,7 @@ export function StaticArmorSceneComponent({
|
|||||||
color = new Color(
|
color = new Color(
|
||||||
clamp(1 - (7 / 8) * xClamped, 0, 1),
|
clamp(1 - (7 / 8) * xClamped, 0, 1),
|
||||||
0,
|
0,
|
||||||
clamp(1 - (1 / 8) * xClamped, 0, 1)
|
clamp(1 - (1 / 8) * xClamped, 0, 1),
|
||||||
);
|
);
|
||||||
opacity = clamp(x + 1 / 2, 0, 1);
|
opacity = clamp(x + 1 / 2, 0, 1);
|
||||||
break;
|
break;
|
||||||
@@ -115,7 +115,7 @@ export function StaticArmorSceneComponent({
|
|||||||
opacity: 0,
|
opacity: 0,
|
||||||
userData: { opacity0: opacity },
|
userData: { opacity0: opacity },
|
||||||
}),
|
}),
|
||||||
[thickness]
|
[thickness],
|
||||||
);
|
);
|
||||||
const outlineMaterial = useMemo(
|
const outlineMaterial = useMemo(
|
||||||
() =>
|
() =>
|
||||||
@@ -126,7 +126,7 @@ export function StaticArmorSceneComponent({
|
|||||||
opacity: 0,
|
opacity: 0,
|
||||||
transparent: true,
|
transparent: true,
|
||||||
}),
|
}),
|
||||||
[thickness]
|
[thickness],
|
||||||
);
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -165,8 +165,11 @@ export function StaticArmorSceneComponent({
|
|||||||
}
|
}
|
||||||
|
|
||||||
surfaceMaterial.needsUpdate = true;
|
surfaceMaterial.needsUpdate = true;
|
||||||
|
invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handleHighlightArmor();
|
||||||
|
|
||||||
function handleTransitionEvent(event: QuicklimeEvent<number>) {
|
function handleTransitionEvent(event: QuicklimeEvent<number>) {
|
||||||
surfaceMaterial.opacity = surfaceMaterial.userData.opacity0 * event.data;
|
surfaceMaterial.opacity = surfaceMaterial.userData.opacity0 * event.data;
|
||||||
outlineMaterial.opacity = event.data;
|
outlineMaterial.opacity = event.data;
|
||||||
@@ -180,7 +183,7 @@ export function StaticArmorSceneComponent({
|
|||||||
const unsubscribes = [
|
const unsubscribes = [
|
||||||
Tankopedia.on(
|
Tankopedia.on(
|
||||||
(state) => state.highlightArmor?.name,
|
(state) => state.highlightArmor?.name,
|
||||||
handleHighlightArmor
|
handleHighlightArmor,
|
||||||
),
|
),
|
||||||
() => transitionEvent.off(handleTransitionEvent),
|
() => transitionEvent.off(handleTransitionEvent),
|
||||||
];
|
];
|
||||||
@@ -194,14 +197,14 @@ export function StaticArmorSceneComponent({
|
|||||||
const { clip } = props;
|
const { clip } = props;
|
||||||
const gunOrigin = unrotateDavaVector(props.gunOrigin.clone());
|
const gunOrigin = unrotateDavaVector(props.gunOrigin.clone());
|
||||||
const neckOrigin = unrotateDavaVector(props.hullOrigin.clone()).add(
|
const neckOrigin = unrotateDavaVector(props.hullOrigin.clone()).add(
|
||||||
unrotateDavaVector(props.turretOrigin.clone())
|
unrotateDavaVector(props.turretOrigin.clone()),
|
||||||
);
|
);
|
||||||
const barrelOrigin = neckOrigin.clone().add(gunOrigin);
|
const barrelOrigin = neckOrigin.clone().add(gunOrigin);
|
||||||
const distanceToBarrel = clip.distanceToPoint(barrelOrigin);
|
const distanceToBarrel = clip.distanceToPoint(barrelOrigin);
|
||||||
const point = new Vector3();
|
const point = new Vector3();
|
||||||
|
|
||||||
function handleModelTransform(
|
function handleModelTransform(
|
||||||
event: QuicklimeEvent<ModelTransformEventData>
|
event: QuicklimeEvent<ModelTransformEventData>,
|
||||||
) {
|
) {
|
||||||
clip.normal
|
clip.normal
|
||||||
.set(0, 0, -1)
|
.set(0, 0, -1)
|
||||||
@@ -266,7 +269,7 @@ export function StaticArmorSceneComponent({
|
|||||||
const surfaceNormal = event
|
const surfaceNormal = event
|
||||||
.normal!.clone()
|
.normal!.clone()
|
||||||
.applyQuaternion(
|
.applyQuaternion(
|
||||||
event.object.getWorldQuaternion(new Quaternion())
|
event.object.getWorldQuaternion(new Quaternion()),
|
||||||
);
|
);
|
||||||
const angle = surfaceNormal.angleTo(cameraNormal);
|
const angle = surfaceNormal.angleTo(cameraNormal);
|
||||||
const thicknessAngled =
|
const thicknessAngled =
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ export function ConsumablesManager({
|
|||||||
timers
|
timers
|
||||||
? consumable.duration === undefined
|
? consumable.duration === undefined
|
||||||
? undefined
|
? undefined
|
||||||
: consumable.duration * (hasHighEndConsumables ? 1.7 : 1)
|
: consumable.duration * (hasHighEndConsumables ? 1.33 : 1)
|
||||||
: undefined
|
: undefined
|
||||||
}
|
}
|
||||||
cooldown={
|
cooldown={
|
||||||
|
|||||||
@@ -1,26 +1,3 @@
|
|||||||
<script>
|
<script>
|
||||||
import locales from "@blitzkit/i18n/locales.json";
|
|
||||||
import { getBestLocale } from "../core/i18n/getBestLocale";
|
|
||||||
|
|
||||||
const isAPI = window.location.pathname.startsWith("/api");
|
|
||||||
const isI18nPath = locales.supported.some(({ locale }) =>
|
|
||||||
window.location.pathname.startsWith(`/${locale}/`)
|
|
||||||
);
|
|
||||||
const bestLocale = getBestLocale();
|
|
||||||
const currentPath = locales.supported.find(({ locale }) =>
|
|
||||||
window.location.pathname.startsWith(`/${locale}/`)
|
|
||||||
);
|
|
||||||
|
|
||||||
if (
|
|
||||||
!isAPI && // not an api, duh!
|
|
||||||
localStorage.getItem("preferred-locale") !== null && // no preference, so probably google's crawler
|
|
||||||
bestLocale !== currentPath?.locale // we need to redirect
|
|
||||||
) {
|
|
||||||
window.location.pathname = isI18nPath
|
|
||||||
? window.location.pathname.replace(
|
|
||||||
`/${currentPath?.locale}`,
|
|
||||||
bestLocale === undefined ? "" : `/${bestLocale}`
|
|
||||||
)
|
|
||||||
: `/${bestLocale}${window.location.pathname}`;
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
@@ -6,7 +6,8 @@ import {
|
|||||||
Popover,
|
Popover,
|
||||||
type ButtonProps,
|
type ButtonProps,
|
||||||
} from "@radix-ui/themes";
|
} from "@radix-ui/themes";
|
||||||
import type { RefObject } from "react";
|
import { Jimp } from "jimp";
|
||||||
|
import { useCallback, type RefObject } from "react";
|
||||||
import { useLocale } from "../hooks/useLocale";
|
import { useLocale } from "../hooks/useLocale";
|
||||||
import { screenshotReadyEvent } from "./Tankopedia/HeroSection/components/TankSandbox/components/SceneProps";
|
import { screenshotReadyEvent } from "./Tankopedia/HeroSection/components/TankSandbox/components/SceneProps";
|
||||||
|
|
||||||
@@ -18,6 +19,35 @@ interface Props extends ButtonProps {
|
|||||||
export function ScreenshotButton({ canvas, name, children, ...props }: Props) {
|
export function ScreenshotButton({ canvas, name, children, ...props }: Props) {
|
||||||
const { strings } = useLocale();
|
const { strings } = useLocale();
|
||||||
|
|
||||||
|
const screenshot = useCallback(async () => {
|
||||||
|
if (!canvas.current) {
|
||||||
|
throw new Error("Canvas not found");
|
||||||
|
}
|
||||||
|
|
||||||
|
screenshotReadyEvent.dispatch(true);
|
||||||
|
|
||||||
|
const blob = await new Promise<Blob>((resolve, reject) => {
|
||||||
|
requestAnimationFrame(() => {
|
||||||
|
canvas.current.toBlob((blob) => {
|
||||||
|
screenshotReadyEvent.dispatch(false);
|
||||||
|
|
||||||
|
if (!blob) {
|
||||||
|
reject(new Error("Failed to capture screenshot"));
|
||||||
|
} else {
|
||||||
|
resolve(blob);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
const buffer = await blob.arrayBuffer();
|
||||||
|
const image = await Jimp.fromBuffer(buffer);
|
||||||
|
|
||||||
|
image.autocrop();
|
||||||
|
|
||||||
|
return image;
|
||||||
|
}, [canvas]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Popover.Root>
|
<Popover.Root>
|
||||||
<Popover.Trigger>
|
<Popover.Trigger>
|
||||||
@@ -37,23 +67,13 @@ export function ScreenshotButton({ canvas, name, children, ...props }: Props) {
|
|||||||
<Flex direction="column" gap="2">
|
<Flex direction="column" gap="2">
|
||||||
<Popover.Close>
|
<Popover.Close>
|
||||||
<Button
|
<Button
|
||||||
onClick={() => {
|
onClick={async () => {
|
||||||
screenshotReadyEvent.dispatch(true);
|
const image = await screenshot();
|
||||||
|
const anchor = document.createElement("a");
|
||||||
|
|
||||||
requestAnimationFrame(() => {
|
anchor.setAttribute("download", `${name}.png`);
|
||||||
if (!canvas.current) return;
|
anchor.setAttribute("href", await image.getBase64("image/png"));
|
||||||
|
anchor.click();
|
||||||
const anchor = document.createElement("a");
|
|
||||||
|
|
||||||
anchor.setAttribute("download", `${name}.png`);
|
|
||||||
anchor.setAttribute(
|
|
||||||
"href",
|
|
||||||
canvas.current.toDataURL("image/png")
|
|
||||||
);
|
|
||||||
anchor.click();
|
|
||||||
|
|
||||||
screenshotReadyEvent.dispatch(false);
|
|
||||||
});
|
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<DownloadIcon />
|
<DownloadIcon />
|
||||||
@@ -63,22 +83,16 @@ export function ScreenshotButton({ canvas, name, children, ...props }: Props) {
|
|||||||
<Popover.Close>
|
<Popover.Close>
|
||||||
<Button
|
<Button
|
||||||
variant="outline"
|
variant="outline"
|
||||||
onClick={() => {
|
onClick={async () => {
|
||||||
screenshotReadyEvent.dispatch(true);
|
const image = await screenshot();
|
||||||
|
const buffer = await image.getBuffer("image/png");
|
||||||
requestAnimationFrame(() => {
|
const blob = new Blob([buffer as unknown as ArrayBuffer], {
|
||||||
if (!canvas.current) return;
|
type: "image/png",
|
||||||
|
|
||||||
canvas.current.toBlob((blob) => {
|
|
||||||
if (!blob) return;
|
|
||||||
|
|
||||||
navigator.clipboard.write([
|
|
||||||
new ClipboardItem({ "image/png": blob }),
|
|
||||||
]);
|
|
||||||
});
|
|
||||||
|
|
||||||
screenshotReadyEvent.dispatch(false);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
navigator.clipboard.write([
|
||||||
|
new ClipboardItem({ "image/png": blob }),
|
||||||
|
]);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<CopyIcon />
|
<CopyIcon />
|
||||||
|
|||||||
@@ -3,12 +3,12 @@ import {
|
|||||||
resolveDpm,
|
resolveDpm,
|
||||||
unionBoundingBox,
|
unionBoundingBox,
|
||||||
type TankDefinition,
|
type TankDefinition,
|
||||||
} from '@blitzkit/core';
|
} from "@blitzkit/core";
|
||||||
import { useMemo } from 'react';
|
import { useMemo } from "react";
|
||||||
import { awaitableModelDefinitions } from '../../../core/awaitables/modelDefinitions';
|
import { awaitableModelDefinitions } from "../../../core/awaitables/modelDefinitions";
|
||||||
import { resolveReload } from '../../../core/blitzkit/resolveReload';
|
import { resolveReload } from "../../../core/blitzkit/resolveReload";
|
||||||
import { TankSort } from '../../../stores/tankopediaSort';
|
import { TankSort } from "../../../stores/tankopediaSort";
|
||||||
import { TankCard } from '../../TankCard';
|
import { TankCard } from "../../TankCard";
|
||||||
|
|
||||||
interface TankSearchCardProps {
|
interface TankSearchCardProps {
|
||||||
tank: TankDefinition;
|
tank: TankDefinition;
|
||||||
@@ -20,7 +20,7 @@ const modelDefinitions = await awaitableModelDefinitions;
|
|||||||
export function TankSearchCard({ tank, onSelect }: TankSearchCardProps) {
|
export function TankSearchCard({ tank, onSelect }: TankSearchCardProps) {
|
||||||
const by = TankSort.use((state) => state.by);
|
const by = TankSort.use((state) => state.by);
|
||||||
const discriminator = useMemo(() => {
|
const discriminator = useMemo(() => {
|
||||||
if (by.startsWith('meta')) return undefined;
|
if (by.startsWith("meta")) return undefined;
|
||||||
|
|
||||||
const turret = tank.turrets.at(-1)!;
|
const turret = tank.turrets.at(-1)!;
|
||||||
const gun = turret.guns.at(-1)!;
|
const gun = turret.guns.at(-1)!;
|
||||||
@@ -34,53 +34,53 @@ export function TankSearchCard({ tank, onSelect }: TankSearchCardProps) {
|
|||||||
const gunModelDefinition = turretModelDefinition.guns[gun.id];
|
const gunModelDefinition = turretModelDefinition.guns[gun.id];
|
||||||
|
|
||||||
switch (by) {
|
switch (by) {
|
||||||
case 'fire.aimTime':
|
case "fire.aimTime":
|
||||||
return gun.aim_time.toFixed(2);
|
return gun.aim_time.toFixed(2);
|
||||||
case 'fire.caliber':
|
case "fire.caliber":
|
||||||
return shell0.caliber.toFixed(0);
|
return shell0.caliber.toFixed(0);
|
||||||
case 'fire.damage':
|
case "fire.damage":
|
||||||
return shell0.armor_damage.toFixed(0);
|
return shell0.armor_damage.toFixed(0);
|
||||||
case 'fire.moduleDamage':
|
case "fire.moduleDamage":
|
||||||
return shell0.module_damage.toFixed(0);
|
return shell0.module_damage.toFixed(0);
|
||||||
case 'fire.dispersionMoving':
|
case "fire.dispersionMoving":
|
||||||
return tracks.dispersion_move.toFixed(3);
|
return tracks.dispersion_move.toFixed(3);
|
||||||
case 'fire.dispersionStill':
|
case "fire.dispersionStill":
|
||||||
return gun.dispersion_base.toFixed(3);
|
return gun.dispersion_base.toFixed(3);
|
||||||
case 'fire.dpm':
|
case "fire.dpm":
|
||||||
return resolveDpm(gun, shell0).toFixed(0);
|
return resolveDpm(gun, shell0).toFixed(0);
|
||||||
case 'fire.dpmPremium':
|
case "fire.dpmPremium":
|
||||||
return shell1 ? resolveDpm(gun, shell1).toFixed(0) : '--';
|
return shell1 ? resolveDpm(gun, shell1).toFixed(0) : "--";
|
||||||
case 'fire.reload':
|
case "fire.reload":
|
||||||
return resolveReload(gun).toFixed(2);
|
return resolveReload(gun).toFixed(2);
|
||||||
case 'fire.standardPenetration':
|
case "fire.standardPenetration":
|
||||||
return shell0.penetration.near.toFixed(0);
|
return shell0?.penetration.near.toFixed(0);
|
||||||
case 'fire.premiumPenetration':
|
case "fire.premiumPenetration":
|
||||||
return shell1 ? shell1.penetration.near.toFixed(0) : '--';
|
return shell1 ? shell1?.penetration.near.toFixed(0) : "--";
|
||||||
case 'fire.tertiaryPenetration':
|
case "fire.tertiaryPenetration":
|
||||||
return shell1 ? shell2.penetration.near.toFixed(0) : '--';
|
return shell1 ? shell2?.penetration.near.toFixed(0) : "--";
|
||||||
case 'fire.shellVelocity':
|
case "fire.shellVelocity":
|
||||||
return shell0.velocity.toFixed(0);
|
return shell0.velocity.toFixed(0);
|
||||||
case 'fire.shellCapacity':
|
case "fire.shellCapacity":
|
||||||
return gun.shell_capacity.toFixed(0);
|
return gun.shell_capacity.toFixed(0);
|
||||||
case 'fire.shellRange':
|
case "fire.shellRange":
|
||||||
return shell0.range.toFixed(0);
|
return shell0.range.toFixed(0);
|
||||||
case 'fire.gunDepression':
|
case "fire.gunDepression":
|
||||||
return (
|
return (
|
||||||
gunModelDefinition.pitch.max +
|
gunModelDefinition.pitch.max +
|
||||||
(tankModelDefinition.initial_turret_rotation?.pitch ?? 0)
|
(tankModelDefinition.initial_turret_rotation?.pitch ?? 0)
|
||||||
).toFixed(1);
|
).toFixed(1);
|
||||||
case 'fire.gunElevation':
|
case "fire.gunElevation":
|
||||||
return (
|
return (
|
||||||
-gunModelDefinition.pitch.min -
|
-gunModelDefinition.pitch.min -
|
||||||
(tankModelDefinition.initial_turret_rotation?.pitch ?? 0)
|
(tankModelDefinition.initial_turret_rotation?.pitch ?? 0)
|
||||||
).toFixed(1);
|
).toFixed(1);
|
||||||
case 'maneuverability.forwardsSpeed':
|
case "maneuverability.forwardsSpeed":
|
||||||
return tank.speed_forwards.toFixed(0);
|
return tank.speed_forwards.toFixed(0);
|
||||||
case 'maneuverability.backwardsSpeed':
|
case "maneuverability.backwardsSpeed":
|
||||||
return tank.speed_backwards.toFixed(0);
|
return tank.speed_backwards.toFixed(0);
|
||||||
case 'maneuverability.power':
|
case "maneuverability.power":
|
||||||
return engine.power.toFixed(0);
|
return engine.power.toFixed(0);
|
||||||
case 'maneuverability.powerToWeight':
|
case "maneuverability.powerToWeight":
|
||||||
return (
|
return (
|
||||||
(1000 * engine.power) /
|
(1000 * engine.power) /
|
||||||
(tank.weight +
|
(tank.weight +
|
||||||
@@ -89,7 +89,7 @@ export function TankSearchCard({ tank, onSelect }: TankSearchCardProps) {
|
|||||||
turret.weight +
|
turret.weight +
|
||||||
gun.weight)
|
gun.weight)
|
||||||
).toFixed(1);
|
).toFixed(1);
|
||||||
case 'maneuverability.weight':
|
case "maneuverability.weight":
|
||||||
return (
|
return (
|
||||||
(tank.weight +
|
(tank.weight +
|
||||||
engine.weight +
|
engine.weight +
|
||||||
@@ -98,19 +98,19 @@ export function TankSearchCard({ tank, onSelect }: TankSearchCardProps) {
|
|||||||
gun.weight) /
|
gun.weight) /
|
||||||
1000
|
1000
|
||||||
).toFixed(1);
|
).toFixed(1);
|
||||||
case 'maneuverability.traverseSpeed':
|
case "maneuverability.traverseSpeed":
|
||||||
return tracks.traverse_speed.toFixed(1);
|
return tracks.traverse_speed.toFixed(1);
|
||||||
case 'survivability.health':
|
case "survivability.health":
|
||||||
return (tank.health + turret.health).toFixed(0);
|
return (tank.health + turret.health).toFixed(0);
|
||||||
case 'survivability.viewRange':
|
case "survivability.viewRange":
|
||||||
return turret.view_range.toFixed(0);
|
return turret.view_range.toFixed(0);
|
||||||
case 'survivability.camouflageStill':
|
case "survivability.camouflageStill":
|
||||||
return (tank.camouflage_still * 100).toFixed(0);
|
return (tank.camouflage_still * 100).toFixed(0);
|
||||||
case 'survivability.camouflageMoving':
|
case "survivability.camouflageMoving":
|
||||||
return (tank.camouflage_moving * 100).toFixed(0);
|
return (tank.camouflage_moving * 100).toFixed(0);
|
||||||
case 'survivability.camouflageShooting':
|
case "survivability.camouflageShooting":
|
||||||
return (tank.camouflage_still * gun.camouflage_loss * 100).toFixed(0);
|
return (tank.camouflage_still * gun.camouflage_loss * 100).toFixed(0);
|
||||||
case 'survivability.volume': {
|
case "survivability.volume": {
|
||||||
const dimensions = normalizeBoundingBox(
|
const dimensions = normalizeBoundingBox(
|
||||||
unionBoundingBox(
|
unionBoundingBox(
|
||||||
tankModelDefinition.bounding_box,
|
tankModelDefinition.bounding_box,
|
||||||
@@ -121,7 +121,7 @@ export function TankSearchCard({ tank, onSelect }: TankSearchCardProps) {
|
|||||||
return (dimensions.x * dimensions.y * dimensions.z).toFixed(0);
|
return (dimensions.x * dimensions.y * dimensions.z).toFixed(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'survivability.length': {
|
case "survivability.length": {
|
||||||
const bounds = normalizeBoundingBox(
|
const bounds = normalizeBoundingBox(
|
||||||
unionBoundingBox(
|
unionBoundingBox(
|
||||||
tankModelDefinition.bounding_box,
|
tankModelDefinition.bounding_box,
|
||||||
|
|||||||
@@ -129,7 +129,7 @@ const consumablesArray = Object.values(consumableDefinitions.consumables)
|
|||||||
.filter(
|
.filter(
|
||||||
(consumable) =>
|
(consumable) =>
|
||||||
!consumable.game_mode_exclusive &&
|
!consumable.game_mode_exclusive &&
|
||||||
consumable.name.locales[locales.default]
|
consumable.name.locales[locales.default],
|
||||||
)
|
)
|
||||||
.map((consumable) => consumable.id);
|
.map((consumable) => consumable.id);
|
||||||
const provisionsArray = Array.from(
|
const provisionsArray = Array.from(
|
||||||
@@ -137,7 +137,7 @@ const provisionsArray = Array.from(
|
|||||||
.filter(
|
.filter(
|
||||||
(provision) =>
|
(provision) =>
|
||||||
!provision.game_mode_exclusive &&
|
!provision.game_mode_exclusive &&
|
||||||
provision.name.locales[locales.default]
|
provision.name.locales[locales.default],
|
||||||
)
|
)
|
||||||
.reduce((uniqueMap, consumable) => {
|
.reduce((uniqueMap, consumable) => {
|
||||||
if (!uniqueMap.has(consumable.name.locales[locales.default])) {
|
if (!uniqueMap.has(consumable.name.locales[locales.default])) {
|
||||||
@@ -146,7 +146,7 @@ const provisionsArray = Array.from(
|
|||||||
|
|
||||||
return uniqueMap;
|
return uniqueMap;
|
||||||
}, new Map<string, number>())
|
}, new Map<string, number>())
|
||||||
.values()
|
.values(),
|
||||||
);
|
);
|
||||||
const shellTypeIcons: Record<ShellType, string> = {
|
const shellTypeIcons: Record<ShellType, string> = {
|
||||||
[ShellType.AP]: "ap",
|
[ShellType.AP]: "ap",
|
||||||
@@ -171,7 +171,7 @@ const TANK_TYPE_COLORS: Record<TankType, string> = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const GUN_TYPES = Object.keys(
|
const GUN_TYPES = Object.keys(
|
||||||
GUN_TYPE_ICONS
|
GUN_TYPE_ICONS,
|
||||||
) as (keyof typeof GUN_TYPE_ICONS)[];
|
) as (keyof typeof GUN_TYPE_ICONS)[];
|
||||||
|
|
||||||
const MAX_ICONS = 4;
|
const MAX_ICONS = 4;
|
||||||
@@ -180,7 +180,12 @@ const TIERS = times(10, (i) => 10 - i);
|
|||||||
|
|
||||||
export function FilterControl() {
|
export function FilterControl() {
|
||||||
return (
|
return (
|
||||||
<Flex align="center" justify="center" gap="2" wrap="wrap">
|
<Flex
|
||||||
|
align="center"
|
||||||
|
justify={{ initial: "start", md: "center" }}
|
||||||
|
gap="2"
|
||||||
|
wrap="wrap"
|
||||||
|
>
|
||||||
<TiersFilter />
|
<TiersFilter />
|
||||||
<ClassFilter />
|
<ClassFilter />
|
||||||
<TypeFilter />
|
<TypeFilter />
|
||||||
@@ -346,7 +351,7 @@ function NationsFilter() {
|
|||||||
mr="-2"
|
mr="-2"
|
||||||
style={{
|
style={{
|
||||||
backgroundImage: `url(${asset(
|
backgroundImage: `url(${asset(
|
||||||
`flags/scratched/${nation}.webp`
|
`flags/scratched/${nation}.webp`,
|
||||||
)})`,
|
)})`,
|
||||||
backgroundSize: "100%",
|
backgroundSize: "100%",
|
||||||
backgroundRepeat: "no-repeat",
|
backgroundRepeat: "no-repeat",
|
||||||
@@ -437,7 +442,7 @@ function ClassFilter() {
|
|||||||
TankFilters.mutate((draft) => {
|
TankFilters.mutate((draft) => {
|
||||||
if (selected) {
|
if (selected) {
|
||||||
draft.classes = draft.classes.filter(
|
draft.classes = draft.classes.filter(
|
||||||
(c) => c !== tankClass
|
(c) => c !== tankClass,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
draft.classes = [...draft.classes, tankClass];
|
draft.classes = [...draft.classes, tankClass];
|
||||||
@@ -683,7 +688,7 @@ function IndividualShellFilter({
|
|||||||
src={asset(
|
src={asset(
|
||||||
`icons/shells/${shellTypeIcons[shells[index]]}${
|
`icons/shells/${shellTypeIcons[shells[index]]}${
|
||||||
premium ? "_premium" : ""
|
premium ? "_premium" : ""
|
||||||
}.webp`
|
}.webp`,
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
@@ -718,7 +723,7 @@ function IndividualShellFilter({
|
|||||||
src={asset(
|
src={asset(
|
||||||
`icons/shells/${shellTypeIcons[shellType]}${
|
`icons/shells/${shellTypeIcons[shellType]}${
|
||||||
premium ? "_premium" : ""
|
premium ? "_premium" : ""
|
||||||
}.webp`
|
}.webp`,
|
||||||
)}
|
)}
|
||||||
style={{ width: "1.25em", height: "1.25em" }}
|
style={{ width: "1.25em", height: "1.25em" }}
|
||||||
/>
|
/>
|
||||||
@@ -917,7 +922,7 @@ function ConsumablesFilter() {
|
|||||||
TankFilters.mutate((draft) => {
|
TankFilters.mutate((draft) => {
|
||||||
if (selected) {
|
if (selected) {
|
||||||
draft.consumables = draft.consumables.filter(
|
draft.consumables = draft.consumables.filter(
|
||||||
(n) => n !== consumable
|
(n) => n !== consumable,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
draft.consumables = [...draft.consumables, consumable];
|
draft.consumables = [...draft.consumables, consumable];
|
||||||
@@ -1011,7 +1016,7 @@ function ProvisionsFilter() {
|
|||||||
TankFilters.mutate((draft) => {
|
TankFilters.mutate((draft) => {
|
||||||
if (selected) {
|
if (selected) {
|
||||||
draft.provisions = draft.provisions.filter(
|
draft.provisions = draft.provisions.filter(
|
||||||
(n) => n !== provision
|
(n) => n !== provision,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
draft.provisions = [...draft.provisions, provision];
|
draft.provisions = [...draft.provisions, provision];
|
||||||
@@ -1140,7 +1145,7 @@ function GameModeAbilitiesFilter() {
|
|||||||
TankFilters.mutate((draft) => {
|
TankFilters.mutate((draft) => {
|
||||||
if (selected) {
|
if (selected) {
|
||||||
draft.abilities = draft.abilities.filter(
|
draft.abilities = draft.abilities.filter(
|
||||||
(n) => n !== consumable
|
(n) => n !== consumable,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
draft.abilities = [...draft.abilities, consumable];
|
draft.abilities = [...draft.abilities, consumable];
|
||||||
@@ -1189,7 +1194,7 @@ function GameModeAbilitiesFilter() {
|
|||||||
TankFilters.mutate((draft) => {
|
TankFilters.mutate((draft) => {
|
||||||
if (selected) {
|
if (selected) {
|
||||||
draft.powers = draft.powers.filter(
|
draft.powers = draft.powers.filter(
|
||||||
(n) => n !== provision
|
(n) => n !== provision,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
draft.powers = [...draft.powers, provision];
|
draft.powers = [...draft.powers, provision];
|
||||||
|
|||||||
+4
-2
@@ -30,9 +30,11 @@ export function RicochetVisualizer({ stats }: StatsAcceptorProps) {
|
|||||||
<Flex direction="column" mb="6" align="center">
|
<Flex direction="column" mb="6" align="center">
|
||||||
<VisualizerCard
|
<VisualizerCard
|
||||||
mb="0"
|
mb="0"
|
||||||
style={{ width: "100%" }}
|
style={{ width: "100%", touchAction: "none" }}
|
||||||
ref={container}
|
ref={container}
|
||||||
onPointerMove={(event) => {
|
onPointerMove={(event) => {
|
||||||
|
event.preventDefault();
|
||||||
|
|
||||||
if (!container.current || explodes) return;
|
if (!container.current || explodes) return;
|
||||||
|
|
||||||
const rect = container.current.getBoundingClientRect();
|
const rect = container.current.getBoundingClientRect();
|
||||||
@@ -174,7 +176,7 @@ export function RicochetVisualizer({ stats }: StatsAcceptorProps) {
|
|||||||
? "-"
|
? "-"
|
||||||
: literals(strings.common.units.deg, {
|
: literals(strings.common.units.deg, {
|
||||||
value: radToDeg(
|
value: radToDeg(
|
||||||
Math.min(normalization, Math.abs(angle))
|
Math.min(normalization, Math.abs(angle)),
|
||||||
).toFixed(0),
|
).toFixed(0),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
+15
-15
@@ -55,17 +55,17 @@ export function Controls({
|
|||||||
const protagonistHullOrigin = new Vector3(
|
const protagonistHullOrigin = new Vector3(
|
||||||
protagonistTrackModelDefinition.origin.x,
|
protagonistTrackModelDefinition.origin.x,
|
||||||
protagonistTrackModelDefinition.origin.y,
|
protagonistTrackModelDefinition.origin.y,
|
||||||
-protagonistTrackModelDefinition.origin.z
|
-protagonistTrackModelDefinition.origin.z,
|
||||||
);
|
);
|
||||||
const protagonistTurretOrigin = new Vector3(
|
const protagonistTurretOrigin = new Vector3(
|
||||||
protagonistModelDefinition.turret_origin.x,
|
protagonistModelDefinition.turret_origin.x,
|
||||||
protagonistModelDefinition.turret_origin.y,
|
protagonistModelDefinition.turret_origin.y,
|
||||||
-protagonistModelDefinition.turret_origin.z
|
-protagonistModelDefinition.turret_origin.z,
|
||||||
);
|
);
|
||||||
const protagonistGunOrigin = new Vector3(
|
const protagonistGunOrigin = new Vector3(
|
||||||
protagonistTurretModelDefinition.gun_origin.x,
|
protagonistTurretModelDefinition.gun_origin.x,
|
||||||
protagonistTurretModelDefinition.gun_origin.y,
|
protagonistTurretModelDefinition.gun_origin.y,
|
||||||
-protagonistTurretModelDefinition.gun_origin.z
|
-protagonistTurretModelDefinition.gun_origin.z,
|
||||||
);
|
);
|
||||||
const antagonistGunHeight =
|
const antagonistGunHeight =
|
||||||
protagonistTrackModelDefinition.origin.y +
|
protagonistTrackModelDefinition.origin.y +
|
||||||
@@ -106,12 +106,12 @@ export function Controls({
|
|||||||
const hasImprovedVerticalStabilizer = hasEquipment(
|
const hasImprovedVerticalStabilizer = hasEquipment(
|
||||||
122,
|
122,
|
||||||
Duel.state.protagonist.tank.equipment_preset,
|
Duel.state.protagonist.tank.equipment_preset,
|
||||||
Duel.state.protagonist.equipmentMatrix
|
Duel.state.protagonist.equipmentMatrix,
|
||||||
);
|
);
|
||||||
const hasDownImprovedVerticalStabilizer = hasEquipment(
|
const hasDownImprovedVerticalStabilizer = hasEquipment(
|
||||||
124,
|
124,
|
||||||
Duel.state.protagonist.tank.equipment_preset,
|
Duel.state.protagonist.tank.equipment_preset,
|
||||||
Duel.state.protagonist.equipmentMatrix
|
Duel.state.protagonist.equipmentMatrix,
|
||||||
);
|
);
|
||||||
|
|
||||||
switch (event) {
|
switch (event) {
|
||||||
@@ -122,7 +122,7 @@ export function Controls({
|
|||||||
protagonistGunModelDefinition.pitch,
|
protagonistGunModelDefinition.pitch,
|
||||||
protagonistTurretModelDefinition.yaw,
|
protagonistTurretModelDefinition.yaw,
|
||||||
hasImprovedVerticalStabilizer,
|
hasImprovedVerticalStabilizer,
|
||||||
hasDownImprovedVerticalStabilizer
|
hasDownImprovedVerticalStabilizer,
|
||||||
);
|
);
|
||||||
|
|
||||||
camera.position
|
camera.position
|
||||||
@@ -134,14 +134,14 @@ export function Controls({
|
|||||||
new Vector3(
|
new Vector3(
|
||||||
0,
|
0,
|
||||||
poseDistances[event] * Math.sin(pitch),
|
poseDistances[event] * Math.sin(pitch),
|
||||||
poseDistances[event] * -Math.cos(pitch)
|
poseDistances[event] * -Math.cos(pitch),
|
||||||
)
|
),
|
||||||
);
|
);
|
||||||
camera.lookAt(
|
camera.lookAt(
|
||||||
protagonistHullOrigin
|
protagonistHullOrigin
|
||||||
.clone()
|
.clone()
|
||||||
.add(protagonistTurretOrigin)
|
.add(protagonistTurretOrigin)
|
||||||
.add(protagonistGunOrigin)
|
.add(protagonistGunOrigin),
|
||||||
);
|
);
|
||||||
orbitControls.current?.target.set(0, antagonistGunHeight, 0);
|
orbitControls.current?.target.set(0, antagonistGunHeight, 0);
|
||||||
|
|
||||||
@@ -155,7 +155,7 @@ export function Controls({
|
|||||||
protagonistGunModelDefinition.pitch,
|
protagonistGunModelDefinition.pitch,
|
||||||
protagonistTurretModelDefinition.yaw,
|
protagonistTurretModelDefinition.yaw,
|
||||||
hasImprovedVerticalStabilizer,
|
hasImprovedVerticalStabilizer,
|
||||||
hasDownImprovedVerticalStabilizer
|
hasDownImprovedVerticalStabilizer,
|
||||||
);
|
);
|
||||||
|
|
||||||
camera.position
|
camera.position
|
||||||
@@ -167,8 +167,8 @@ export function Controls({
|
|||||||
new Vector3(
|
new Vector3(
|
||||||
0,
|
0,
|
||||||
poseDistances[event] * Math.sin(pitch),
|
poseDistances[event] * Math.sin(pitch),
|
||||||
poseDistances[event] * -Math.cos(pitch)
|
poseDistances[event] * -Math.cos(pitch),
|
||||||
)
|
),
|
||||||
);
|
);
|
||||||
orbitControls.current?.target
|
orbitControls.current?.target
|
||||||
.set(0, 0, 0)
|
.set(0, 0, 0)
|
||||||
@@ -179,8 +179,8 @@ export function Controls({
|
|||||||
new Vector3(
|
new Vector3(
|
||||||
0,
|
0,
|
||||||
0.5 * poseDistances[event] * Math.sin(pitch),
|
0.5 * poseDistances[event] * Math.sin(pitch),
|
||||||
0.5 * poseDistances[event] * -Math.cos(pitch)
|
0.5 * poseDistances[event] * -Math.cos(pitch),
|
||||||
)
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@@ -251,7 +251,7 @@ export function Controls({
|
|||||||
return (
|
return (
|
||||||
<OrbitControls
|
<OrbitControls
|
||||||
enableRotate={enableRotate}
|
enableRotate={enableRotate}
|
||||||
maxDistance={20}
|
maxDistance={40}
|
||||||
minDistance={5}
|
minDistance={5}
|
||||||
enableZoom={zoomable}
|
enableZoom={zoomable}
|
||||||
zoomSpeed={zoomable ? undefined : 0}
|
zoomSpeed={zoomable ? undefined : 0}
|
||||||
|
|||||||
+6
-8
@@ -47,7 +47,7 @@ export const TankSandbox = forwardRef<HTMLCanvasElement, TankSandboxProps>(
|
|||||||
const gunModelDefinition = turretModelDefinition.guns[protagonistGun.id];
|
const gunModelDefinition = turretModelDefinition.guns[protagonistGun.id];
|
||||||
const display = Tankopedia.use((state) => state.display);
|
const display = Tankopedia.use((state) => state.display);
|
||||||
const hideTankModelUnderArmor = TankopediaPersistent.use(
|
const hideTankModelUnderArmor = TankopediaPersistent.use(
|
||||||
(state) => state.hideTankModelUnderArmor
|
(state) => state.hideTankModelUnderArmor,
|
||||||
);
|
);
|
||||||
|
|
||||||
useImperativeHandle(ref, () => canvas.current!, []);
|
useImperativeHandle(ref, () => canvas.current!, []);
|
||||||
@@ -76,7 +76,7 @@ export const TankSandbox = forwardRef<HTMLCanvasElement, TankSandboxProps>(
|
|||||||
gunModelDefinition.pitch,
|
gunModelDefinition.pitch,
|
||||||
turretModelDefinition.yaw,
|
turretModelDefinition.yaw,
|
||||||
hasImprovedVerticalStabilizer,
|
hasImprovedVerticalStabilizer,
|
||||||
hasDownImprovedVerticalStabilizer
|
hasDownImprovedVerticalStabilizer,
|
||||||
);
|
);
|
||||||
|
|
||||||
modelTransformEvent.dispatch({ pitch, yaw });
|
modelTransformEvent.dispatch({ pitch, yaw });
|
||||||
@@ -90,7 +90,7 @@ export const TankSandbox = forwardRef<HTMLCanvasElement, TankSandboxProps>(
|
|||||||
0,
|
0,
|
||||||
gunModelDefinition.pitch,
|
gunModelDefinition.pitch,
|
||||||
turretModelDefinition.yaw,
|
turretModelDefinition.yaw,
|
||||||
hasImprovedVerticalStabilizer
|
hasImprovedVerticalStabilizer,
|
||||||
);
|
);
|
||||||
|
|
||||||
modelTransformEvent.dispatch({ pitch, yaw });
|
modelTransformEvent.dispatch({ pitch, yaw });
|
||||||
@@ -104,7 +104,7 @@ export const TankSandbox = forwardRef<HTMLCanvasElement, TankSandboxProps>(
|
|||||||
0,
|
0,
|
||||||
gunModelDefinition.pitch,
|
gunModelDefinition.pitch,
|
||||||
turretModelDefinition.yaw,
|
turretModelDefinition.yaw,
|
||||||
hasImprovedVerticalStabilizer
|
hasImprovedVerticalStabilizer,
|
||||||
);
|
);
|
||||||
|
|
||||||
modelTransformEvent.dispatch({ pitch, yaw });
|
modelTransformEvent.dispatch({ pitch, yaw });
|
||||||
@@ -126,7 +126,7 @@ export const TankSandbox = forwardRef<HTMLCanvasElement, TankSandboxProps>(
|
|||||||
modelTransformEvent.last!.yaw,
|
modelTransformEvent.last!.yaw,
|
||||||
gunModelDefinition.pitch,
|
gunModelDefinition.pitch,
|
||||||
turretModelDefinition.yaw,
|
turretModelDefinition.yaw,
|
||||||
hasImprovedVerticalStabilizer
|
hasImprovedVerticalStabilizer,
|
||||||
);
|
);
|
||||||
|
|
||||||
modelTransformEvent.dispatch({ pitch, yaw });
|
modelTransformEvent.dispatch({ pitch, yaw });
|
||||||
@@ -146,8 +146,6 @@ export const TankSandbox = forwardRef<HTMLCanvasElement, TankSandboxProps>(
|
|||||||
}
|
}
|
||||||
}, [display]);
|
}, [display]);
|
||||||
|
|
||||||
console.log(TankopediaDisplay[display]);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SmartCanvas
|
<SmartCanvas
|
||||||
resize={{ debounce: 0 }}
|
resize={{ debounce: 0 }}
|
||||||
@@ -196,5 +194,5 @@ export const TankSandbox = forwardRef<HTMLCanvasElement, TankSandboxProps>(
|
|||||||
<InitialAligner />
|
<InitialAligner />
|
||||||
</SmartCanvas>
|
</SmartCanvas>
|
||||||
);
|
);
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
@@ -2,9 +2,9 @@ import {
|
|||||||
normalizeAngleRad,
|
normalizeAngleRad,
|
||||||
type PitchLimits,
|
type PitchLimits,
|
||||||
type YawLimits,
|
type YawLimits,
|
||||||
} from '@blitzkit/core';
|
} from "@blitzkit/core";
|
||||||
import { clamp } from 'lodash-es';
|
import { clamp } from "lodash-es";
|
||||||
import { degToRad } from 'three/src/math/MathUtils.js';
|
import { degToRad } from "three/src/math/MathUtils.js";
|
||||||
|
|
||||||
export const DEFAULT_PITCH_TRANSITION = 15;
|
export const DEFAULT_PITCH_TRANSITION = 15;
|
||||||
|
|
||||||
@@ -87,5 +87,5 @@ export function applyPitchYawLimits(
|
|||||||
|
|
||||||
newPitch = clamp(newPitch, lowerPitch, upperPitch);
|
newPitch = clamp(newPitch, lowerPitch, upperPitch);
|
||||||
|
|
||||||
return [newPitch, newYaw] as const;
|
return [newPitch, normalizeAngleRad(newYaw)] as const;
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import type { ComponentProps, ReactNode } from "react";
|
import type { ComponentProps, ReactNode } from "react";
|
||||||
import { Mesh, Object3D } from "three";
|
import { Mesh, MeshStandardMaterial, Object3D } from "three";
|
||||||
|
|
||||||
export function jsxTree(
|
export function jsxTree(
|
||||||
node: Object3D,
|
node: Object3D,
|
||||||
@@ -7,14 +7,14 @@ export function jsxTree(
|
|||||||
mesh?: (
|
mesh?: (
|
||||||
mesh: Mesh,
|
mesh: Mesh,
|
||||||
props: ComponentProps<"mesh">,
|
props: ComponentProps<"mesh">,
|
||||||
key: string
|
key: string,
|
||||||
) => ReactNode;
|
) => ReactNode;
|
||||||
group?: (
|
group?: (
|
||||||
object3d: Object3D,
|
object3d: Object3D,
|
||||||
props: ComponentProps<"group">,
|
props: ComponentProps<"group">,
|
||||||
key: string
|
key: string,
|
||||||
) => ReactNode;
|
) => ReactNode;
|
||||||
}
|
},
|
||||||
): ReactNode {
|
): ReactNode {
|
||||||
if (node instanceof Mesh) {
|
if (node instanceof Mesh) {
|
||||||
const props = {
|
const props = {
|
||||||
@@ -25,6 +25,10 @@ export function jsxTree(
|
|||||||
scale: node.scale,
|
scale: node.scale,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (props.material instanceof MeshStandardMaterial) {
|
||||||
|
props.material.depthWrite = true;
|
||||||
|
}
|
||||||
|
|
||||||
return mergers?.mesh ? (
|
return mergers?.mesh ? (
|
||||||
mergers.mesh(node, props, node.uuid)
|
mergers.mesh(node, props, node.uuid)
|
||||||
) : (
|
) : (
|
||||||
|
|||||||
@@ -5,11 +5,11 @@ export function getBestLocale() {
|
|||||||
localStorage.getItem("preferred-locale") ??
|
localStorage.getItem("preferred-locale") ??
|
||||||
navigator.language.split("-")[0];
|
navigator.language.split("-")[0];
|
||||||
const isSupported = locales.supported.some(
|
const isSupported = locales.supported.some(
|
||||||
({ locale }) => locale === desiredLocale
|
({ locale }) => locale === desiredLocale,
|
||||||
);
|
);
|
||||||
const isDefault = desiredLocale === locales.default;
|
const isDefault = desiredLocale === locales.default;
|
||||||
|
|
||||||
if (!isSupported || isDefault) return undefined;
|
if (!isSupported || isDefault) return locales.default;
|
||||||
|
|
||||||
return desiredLocale;
|
return desiredLocale;
|
||||||
}
|
}
|
||||||
@@ -12,7 +12,8 @@ export const getStaticPaths = (async () => {
|
|||||||
.map((tank) =>
|
.map((tank) =>
|
||||||
parentPaths.map((parent) => ({
|
parentPaths.map((parent) => ({
|
||||||
params: { ...parent.params, id: tank.id },
|
params: { ...parent.params, id: tank.id },
|
||||||
}))
|
props: parent.props,
|
||||||
|
})),
|
||||||
)
|
)
|
||||||
.flat();
|
.flat();
|
||||||
}) satisfies GetStaticPaths;
|
}) satisfies GetStaticPaths;
|
||||||
|
|||||||
Reference in new issue
Block a user