mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-21 18:57:03 +02:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c8edd16eb3 | ||
|
|
b96ff2e239 | ||
|
|
a575da3005 | ||
|
|
3ca2dece3e | ||
|
|
191d6133b2 | ||
|
|
b15e73e3a8 | ||
|
|
9a6b8ab979 | ||
|
|
87786d41a7 | ||
|
|
ee7ffe7bc8 | ||
|
|
379a33375d | ||
|
|
bd3f5dea05 | ||
|
|
146d36234e | ||
|
|
f3edcb8077 | ||
|
|
9e492015ff | ||
|
|
d2977182d9 | ||
|
|
7d2d65bab8 | ||
|
|
415c3bd066 | ||
|
|
990ab1520c | ||
|
|
81cb1afeff | ||
|
|
dba5a0a2cd | ||
|
|
04cd205fee | ||
|
|
ec93d8e9ab | ||
|
|
56321d9e33 | ||
|
|
d39ab43e74 | ||
|
|
787d3ae6ea | ||
|
|
035f751bf1 | ||
|
|
43442ac829 | ||
|
|
da02a089b9 | ||
|
|
476d8e804a | ||
|
|
43e1d53d39 | ||
|
|
5372068830 | ||
|
|
025cec3687 | ||
|
|
c47c629a83 | ||
|
|
2b7907f8f7 | ||
|
|
903d4e4d95 | ||
|
|
8857b2baae | ||
|
|
f7bbb17f66 | ||
|
|
f407ffe4bb | ||
|
|
791a09daae | ||
|
|
9592c0b55f | ||
|
|
d9a34dc60e | ||
|
|
30e4e4e9b3 | ||
|
|
bd3ea9a8ec | ||
|
|
8131b69422 | ||
|
|
340d9c2666 | ||
|
|
2a169fac34 | ||
|
|
4819100ec6 | ||
|
|
f39a94cbe0 | ||
|
|
e61598f768 | ||
|
|
04ee3a0a44 | ||
|
|
8fa613f1e2 | ||
|
|
bdc240df08 | ||
|
|
7169e0d91a | ||
|
|
889ed7e191 | ||
|
|
1fb8dac805 | ||
|
|
9f71ac68b9 | ||
|
|
c1f3517a79 | ||
|
|
adb0af0f18 | ||
|
|
f79f1ffdc3 | ||
|
|
1c9b7463fc | ||
|
|
80741d66fc | ||
|
|
f02fb00e8c | ||
|
|
3d353cc3cf | ||
|
|
c54ceb944e | ||
|
|
37a2ba3566 | ||
|
|
caff7bb6d0 | ||
|
|
01c491aee0 | ||
|
|
fd408d6777 | ||
|
|
6d1ed1e56e | ||
|
|
46f9d605f7 | ||
|
|
a65ea42b81 | ||
|
|
40f8c6a915 | ||
|
|
4678359f36 | ||
|
|
f91bd63646 | ||
|
|
c1872262f5 | ||
|
|
082e112758 | ||
|
|
4cb7d50eb5 | ||
|
|
8c050add23 | ||
|
|
2610697d86 | ||
|
|
64f1de37ad | ||
|
|
58f6862279 | ||
|
|
b47f6fdb32 | ||
|
|
ce5a53d0ff | ||
|
|
6ee1fa13d3 |
No files matched your search
@@ -2,10 +2,9 @@ name: CD Build Assets
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: dev
|
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
# schedule:
|
schedule:
|
||||||
# - cron: '0 0 * * *'
|
- cron: '0 2 * * *'
|
||||||
|
|
||||||
concurrency:
|
concurrency:
|
||||||
group: ${{ github.workflow }}-${{ github.ref }}
|
group: ${{ github.workflow }}-${{ github.ref }}
|
||||||
@@ -18,6 +17,9 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
submodules: recursive
|
||||||
|
token: ${{ secrets.GH_TOKEN }}
|
||||||
|
|
||||||
- name: Use node
|
- name: Use node
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v4
|
||||||
@@ -44,10 +46,19 @@ jobs:
|
|||||||
run: yarn setup:depotdownloader
|
run: yarn setup:depotdownloader
|
||||||
|
|
||||||
- name: Run DepotDownloader
|
- name: Run DepotDownloader
|
||||||
run: ./temp/depotDownloader/DepotDownloader.exe -app 444202 -username ${{ secrets.DEPOT_DOWNLOADER_USERNAME }} -password "${{ secrets.DEPOT_DOWNLOADER_PASSWORD }}"
|
run: ./temp/depotDownloader/DepotDownloader.exe -app 444200 -username ${{ secrets.DEPOT_DOWNLOADER_USERNAME }} -password "${{ secrets.DEPOT_DOWNLOADER_PASSWORD }}"
|
||||||
|
|
||||||
|
- name: Apply patches
|
||||||
|
run: |
|
||||||
|
$env:GH_TOKEN = "${{ secrets.GH_TOKEN }}"
|
||||||
|
$env:DISCORD_TOKEN = "${{ secrets.DISCORD_TOKEN }}"
|
||||||
|
$env:DISCORD_BLITZ_DB = "${{ secrets.DISCORD_BLITZ_DB }}"
|
||||||
|
$env:WOTB_DLC_CDN = "${{ secrets.WOTB_DLC_CDN }}"
|
||||||
|
yarn setup:patches --depot
|
||||||
|
|
||||||
- name: Build assets
|
- name: Build assets
|
||||||
run: |
|
run: |
|
||||||
$env:GH_TOKEN = "${{ secrets.GH_TOKEN }}"
|
$env:GH_TOKEN = "${{ secrets.GH_TOKEN }}"
|
||||||
$env:DISCORD_TOKEN = "${{ secrets.DISCORD_TOKEN }}"
|
$env:DISCORD_TOKEN = "${{ secrets.DISCORD_TOKEN }}"
|
||||||
|
$env:DISCORD_BLITZ_DB = "${{ secrets.DISCORD_BLITZ_DB }}"
|
||||||
yarn build:assets --all-targets --depot ${{ github.ref == 'refs/heads/main' && '--production' || '' }}
|
yarn build:assets --all-targets --depot ${{ github.ref == 'refs/heads/main' && '--production' || '' }}
|
||||||
@@ -18,10 +18,10 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Use node
|
- name: Use node
|
||||||
uses: actions/setup-node@v3
|
uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: 18
|
node-version: 18
|
||||||
cache: 'npm'
|
cache: 'npm'
|
||||||
@@ -54,7 +54,7 @@ jobs:
|
|||||||
uses: actions/deploy-pages@v1
|
uses: actions/deploy-pages@v1
|
||||||
|
|
||||||
- name: Archive build
|
- name: Archive build
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: dist
|
name: dist
|
||||||
path: docs/.vitepress/dist
|
path: docs/.vitepress/dist
|
||||||
@@ -6,6 +6,8 @@ on:
|
|||||||
schedule:
|
schedule:
|
||||||
- cron: '0 */5 * * *'
|
- cron: '0 */5 * * *'
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
release:
|
||||||
|
types: [created, published, released, edited]
|
||||||
|
|
||||||
concurrency:
|
concurrency:
|
||||||
group: ${{ github.workflow }}-${{ github.ref }}
|
group: ${{ github.workflow }}-${{ github.ref }}
|
||||||
@@ -17,10 +19,16 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Use node
|
- name: Use node
|
||||||
uses: actions/setup-node@v2
|
uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: 18
|
node-version: 18
|
||||||
|
|
||||||
|
- name: Install Yarn
|
||||||
|
run: npm install --location=global yarn
|
||||||
|
|
||||||
|
- name: Add fixed sharp
|
||||||
|
run: yarn add [email protected] --ignore-engines
|
||||||
|
|
||||||
- name: Download release assets
|
- name: Download release assets
|
||||||
run: |
|
run: |
|
||||||
DOWNLOAD_URL=$(curl -s https://api.github.com/repos/tresabhi/blitzkrieg/releases/latest \
|
DOWNLOAD_URL=$(curl -s https://api.github.com/repos/tresabhi/blitzkrieg/releases/latest \
|
||||||
|
|||||||
@@ -14,10 +14,10 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Use node
|
- name: Use node
|
||||||
uses: actions/setup-node@v3
|
uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: 18
|
node-version: 18
|
||||||
cache: 'npm'
|
cache: 'npm'
|
||||||
@@ -35,4 +35,4 @@ jobs:
|
|||||||
run: yarn
|
run: yarn
|
||||||
|
|
||||||
- name: Generate leaderboard
|
- name: Generate leaderboard
|
||||||
run: GH_TOKEN=${{ secrets.GH_TOKEN }} DISCORD_TOKEN=${{ secrets.DISCORD_TOKEN }} yarn publish:ratingsleaderboard --region=asia --target=${{ github.event.schedule == '0 0 * * *' && 'latest' || 'midnight' }}
|
run: GH_TOKEN=${{ secrets.GH_TOKEN }} DISCORD_TOKEN=${{ secrets.DISCORD_TOKEN }} DISCORD_BLITZ_DB=${{ secrets.DISCORD_BLITZ_DB }} yarn publish:ratingsleaderboard --region=asia --target=${{ github.event.schedule == '0 0 * * *' && 'latest' || 'midnight' }}
|
||||||
@@ -14,10 +14,10 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Use node
|
- name: Use node
|
||||||
uses: actions/setup-node@v3
|
uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: 18
|
node-version: 18
|
||||||
cache: 'npm'
|
cache: 'npm'
|
||||||
@@ -35,4 +35,4 @@ jobs:
|
|||||||
run: yarn
|
run: yarn
|
||||||
|
|
||||||
- name: Generate leaderboard
|
- name: Generate leaderboard
|
||||||
run: GH_TOKEN=${{ secrets.GH_TOKEN }} DISCORD_TOKEN=${{ secrets.DISCORD_TOKEN }} yarn publish:ratingsleaderboard --region=eu --target=${{ github.event.schedule == '0 0 * * *' && 'latest' || 'midnight' }}
|
run: GH_TOKEN=${{ secrets.GH_TOKEN }} DISCORD_TOKEN=${{ secrets.DISCORD_TOKEN }} DISCORD_BLITZ_DB=${{ secrets.DISCORD_BLITZ_DB }} yarn publish:ratingsleaderboard --region=eu --target=${{ github.event.schedule == '0 0 * * *' && 'latest' || 'midnight' }}
|
||||||
@@ -14,10 +14,10 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Use node
|
- name: Use node
|
||||||
uses: actions/setup-node@v3
|
uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: 18
|
node-version: 18
|
||||||
cache: 'npm'
|
cache: 'npm'
|
||||||
@@ -35,4 +35,4 @@ jobs:
|
|||||||
run: yarn
|
run: yarn
|
||||||
|
|
||||||
- name: Generate leaderboard
|
- name: Generate leaderboard
|
||||||
run: GH_TOKEN=${{ secrets.GH_TOKEN }} DISCORD_TOKEN=${{ secrets.DISCORD_TOKEN }} yarn publish:ratingsleaderboard --region=na --target=${{ github.event.schedule == '0 0 * * *' && 'latest' || 'midnight' }}
|
run: GH_TOKEN=${{ secrets.GH_TOKEN }} DISCORD_TOKEN=${{ secrets.DISCORD_TOKEN }} DISCORD_BLITZ_DB=${{ secrets.DISCORD_BLITZ_DB }} yarn publish:ratingsleaderboard --region=na --target=${{ github.event.schedule == '0 0 * * *' && 'latest' || 'midnight' }}
|
||||||
@@ -13,10 +13,10 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Use node
|
- name: Use node
|
||||||
uses: actions/setup-node@v3
|
uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: 18
|
node-version: 18
|
||||||
cache: 'npm'
|
cache: 'npm'
|
||||||
@@ -33,11 +33,14 @@ jobs:
|
|||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: yarn
|
run: yarn
|
||||||
|
|
||||||
|
- name: Add fixed sharp
|
||||||
|
run: yarn add [email protected] --ignore-engines
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
run: yarn build:bot
|
run: yarn build:bot
|
||||||
|
|
||||||
- name: Archive build
|
- name: Archive build
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: bot
|
name: bot
|
||||||
path: dist/bot
|
path: dist/bot
|
||||||
@@ -13,10 +13,10 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Use node
|
- name: Use node
|
||||||
uses: actions/setup-node@v3
|
uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: 18
|
node-version: 18
|
||||||
cache: 'npm'
|
cache: 'npm'
|
||||||
@@ -37,7 +37,7 @@ jobs:
|
|||||||
run: yarn build:docs
|
run: yarn build:docs
|
||||||
|
|
||||||
- name: Archive build
|
- name: Archive build
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: docs
|
name: docs
|
||||||
path: dist/docs
|
path: dist/docs
|
||||||
@@ -13,10 +13,10 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Use node
|
- name: Use node
|
||||||
uses: actions/setup-node@v3
|
uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: 18
|
node-version: 18
|
||||||
cache: 'npm'
|
cache: 'npm'
|
||||||
@@ -37,7 +37,7 @@ jobs:
|
|||||||
run: yarn build:website
|
run: yarn build:website
|
||||||
|
|
||||||
- name: Archive build
|
- name: Archive build
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: website
|
name: website
|
||||||
path: dist/website
|
path: dist/website
|
||||||
+2
-1
@@ -17,4 +17,5 @@ tsconfig.tsbuildinfo
|
|||||||
temp/
|
temp/
|
||||||
/.yarn
|
/.yarn
|
||||||
/.VSCodeCounter
|
/.VSCodeCounter
|
||||||
/.yarn
|
/.yarn
|
||||||
|
depots
|
||||||
Vendored
+3
@@ -7,6 +7,7 @@
|
|||||||
"alphatest",
|
"alphatest",
|
||||||
"APAC",
|
"APAC",
|
||||||
"apcr",
|
"apcr",
|
||||||
|
"applypatches",
|
||||||
"artefacts",
|
"artefacts",
|
||||||
"atgm",
|
"atgm",
|
||||||
"AYUV",
|
"AYUV",
|
||||||
@@ -21,6 +22,7 @@
|
|||||||
"CDON",
|
"CDON",
|
||||||
"classname",
|
"classname",
|
||||||
"cleandist",
|
"cleandist",
|
||||||
|
"closedkrieg",
|
||||||
"cockroackdb",
|
"cockroackdb",
|
||||||
"Coef",
|
"Coef",
|
||||||
"cooldown",
|
"cooldown",
|
||||||
@@ -73,6 +75,7 @@
|
|||||||
"lods",
|
"lods",
|
||||||
"metallicness",
|
"metallicness",
|
||||||
"minitelrose",
|
"minitelrose",
|
||||||
|
"Minotauro",
|
||||||
"MIPMAPCOUNT",
|
"MIPMAPCOUNT",
|
||||||
"modeltransform",
|
"modeltransform",
|
||||||
"MURICA",
|
"MURICA",
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
# Blitzkrieg 1.16.3
|
||||||
|
|
||||||
|
Further polishing and corrections for the Tankopedia.
|
||||||
|
|
||||||
|
## Features
|
||||||
|
|
||||||
|
- Added a few more stats to view for the Tankopedia
|
||||||
|
- Added the count of shells in the magazine for auto-reloaders
|
||||||
|
- The optimal shell index was moved below this stats
|
||||||
|
- Shell reloads for auto-reloaders now abide crew stats
|
||||||
|
- Intra-clip is now also shown for auto-reloaders
|
||||||
|
- Added 1 more decimal place worth of precision when viewing and changing gun pitch and yaw
|
||||||
|
|
||||||
|
## Fixes
|
||||||
|
|
||||||
|
- "Inter-clip" is now correctly spelled as "intra-clip"
|
||||||
|
- Tanks with initial gun pitches (like the Minotauro) are now handled correctly
|
||||||
|
- The stats now reflect the fact that the gun is naturally pitched downwards
|
||||||
|
- The view model now compensates for the natural pitch
|
||||||
|
- Tanks with the improved vertical stabilizer equipment are now handled correctly
|
||||||
|
- The view model now allows you to pitch the gun further as intended when the equipment is on
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
# Blitzkrieg 1.16.4
|
||||||
|
|
||||||
|
A few issues here and there addressed for good measure.
|
||||||
|
|
||||||
|
## Changes
|
||||||
|
|
||||||
|
- Armor layer penetration indices are now much more compact.
|
||||||
|
|
||||||
|
## Fixes
|
||||||
|
|
||||||
|
- Reverted splash mechanics changes from `1.16.1` as it made them less accurate.
|
||||||
|
- Auto-reloaders now report their DPM stats correctly with crew training.
|
||||||
|
|
||||||
|
## Technical Changes
|
||||||
|
|
||||||
|
- All files in the project were reviewed and constant exports were isolated.
|
||||||
|
- The downloaded game in the workflow now also includes the latest patches.
|
||||||
|
- Asset building now uses sharp under the hood which should in theory be faster.
|
||||||
|
- Fetching CDON LZ4 files now uses `no-store` instead of `no-cache`
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
# Blitzkrieg 1.17.0
|
||||||
|
|
||||||
|
A preview command and a touchup.
|
||||||
|
|
||||||
|
## Features
|
||||||
|
|
||||||
|
- Added `/research` in preview only accessible in the official Discord server.
|
||||||
|
- More details will be posted when the command is made public.
|
||||||
|
|
||||||
|
## Changes
|
||||||
|
|
||||||
|
- `/owned-tanks` now returns a simple text message listing all the tanks instead of an image.
|
||||||
|
- This is meant to improve the readability and ease of copying.
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
# Blitzkrieg 1.17.1
|
||||||
|
|
||||||
|
Some stability fixes.
|
||||||
|
|
||||||
|
## Technical Changes
|
||||||
|
|
||||||
|
- `sharp` is now included in the build instead of having being installed before runtime.
|
||||||
|
- Png converter cache is now more memory efficient.
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
# Blitzkrieg 1.17.2
|
||||||
|
|
||||||
|
Introducing the new `/research` command!
|
||||||
|
|
||||||
|
## Features
|
||||||
|
|
||||||
|
- Added the `/research` command
|
||||||
|
- Type in the name of a tech tree tank you desire to research and this command will list all the expenses in researching all tanks in that line
|
||||||
|
- The starting tank is inferred automatically by the tanks you own
|
||||||
|
- This may be a bit inaccurate because of the lack of accurate information Wargaming provides about owned tanks
|
||||||
|
- You are also manually provide a starting tank and a user to see the progress on a line for
|
||||||
|
- Replaced Vercel Analytics (which collapsed under the insane amount of traffic on the website) with Google Analytics
|
||||||
|
- Spaced armor can now be toggled in the Tankopedia armor sandbox
|
||||||
+4
-4
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "blitzkrieg",
|
"name": "blitzkrieg",
|
||||||
"version": "1.16.2",
|
"version": "1.17.1",
|
||||||
"description": "🎉 Tools for everything World of Tanks Blitz",
|
"description": "🎉 Tools for everything World of Tanks Blitz",
|
||||||
"main": "src/server.ts",
|
"main": "src/server.ts",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
@@ -12,13 +12,14 @@
|
|||||||
"build:assets": "vite-node --max_old_space_size=16384 --script scripts/buildAssets/index",
|
"build:assets": "vite-node --max_old_space_size=16384 --script scripts/buildAssets/index",
|
||||||
"build:test": "vite-node --script scripts/buildTest",
|
"build:test": "vite-node --script scripts/buildTest",
|
||||||
"build:ratingsplot": "vite-node --script scripts/buildRatingsPlot",
|
"build:ratingsplot": "vite-node --script scripts/buildRatingsPlot",
|
||||||
"dev:bot": "yarn build:bot && yarn start:bot",
|
"dev:bot": "yarn build:bot --dev && yarn start:bot",
|
||||||
"dev:docs": "vitepress dev docs",
|
"dev:docs": "vitepress dev docs",
|
||||||
"dev:website": "next dev",
|
"dev:website": "next dev",
|
||||||
"start:bot": "node --enable-source-maps dist/bot/index.cjs",
|
"start:bot": "node --enable-source-maps dist/bot/index.cjs",
|
||||||
"start:website": "next start",
|
"start:website": "next start",
|
||||||
"host:docs": "vitepress preview docs",
|
"host:docs": "vitepress preview docs",
|
||||||
"publish:ratingsleaderboard": "vite-node --script scripts/buildRatingsLeaderboard --publish",
|
"publish:ratingsleaderboard": "vite-node --script scripts/buildRatingsLeaderboard --publish",
|
||||||
|
"setup:patches": "vite-node --script scripts/applyPatches",
|
||||||
"lint": "npx tsc",
|
"lint": "npx tsc",
|
||||||
"lint:website": "next lint",
|
"lint:website": "next lint",
|
||||||
"format": "prettier --write \"**/*.@(json|js|jsx|css|md|ts|tsx|html|xml|yml|gltf)\"",
|
"format": "prettier --write \"**/*.@(json|js|jsx|css|md|ts|tsx|html|xml|yml|gltf)\"",
|
||||||
@@ -34,7 +35,7 @@
|
|||||||
"@octokit/plugin-throttling": "^8.1.3",
|
"@octokit/plugin-throttling": "^8.1.3",
|
||||||
"@octokit/rest": "^20.0.1",
|
"@octokit/rest": "^20.0.1",
|
||||||
"@prisma/client": "^5.4.1",
|
"@prisma/client": "^5.4.1",
|
||||||
"@radix-ui/colors": "^3.0.0-rc.4",
|
"@radix-ui/colors": "^3.0.0",
|
||||||
"@radix-ui/react-icons": "^1.3.0",
|
"@radix-ui/react-icons": "^1.3.0",
|
||||||
"@radix-ui/themes": "^2.0.1",
|
"@radix-ui/themes": "^2.0.1",
|
||||||
"@react-three/drei": "^9.93.0",
|
"@react-three/drei": "^9.93.0",
|
||||||
@@ -42,7 +43,6 @@
|
|||||||
"@resvg/resvg-js": "^2.4.1",
|
"@resvg/resvg-js": "^2.4.1",
|
||||||
"@types/three": "^0.160.0",
|
"@types/three": "^0.160.0",
|
||||||
"@vanilla-extract/css": "^1.13.0",
|
"@vanilla-extract/css": "^1.13.0",
|
||||||
"@vercel/analytics": "^1.2.2",
|
|
||||||
"bepaint": "^0.1.0-beta.3",
|
"bepaint": "^0.1.0-beta.3",
|
||||||
"decompress": "^4.2.1",
|
"decompress": "^4.2.1",
|
||||||
"discord.js": "^14.13.0",
|
"discord.js": "^14.13.0",
|
||||||
|
|||||||
@@ -0,0 +1,48 @@
|
|||||||
|
import { mkdir, writeFile } from 'fs/promises';
|
||||||
|
import { parse as parsePath } from 'path';
|
||||||
|
import { parse as parseYaml } from 'yaml';
|
||||||
|
import { readStringDVPL } from '../src/core/blitz/readStringDVPL';
|
||||||
|
import { writeDVPL } from '../src/core/blitz/writeDVPL';
|
||||||
|
import { secrets } from '../src/core/blitzkrieg/secrets';
|
||||||
|
import { dvp } from '../submodules/closedkrieg/src/dvp';
|
||||||
|
import { DATA } from './buildAssets/constants';
|
||||||
|
|
||||||
|
const versionTextFile = await readStringDVPL(`${DATA}/version.txt.dvpl`);
|
||||||
|
const currentVersion = versionTextFile
|
||||||
|
.split(' ')[0]
|
||||||
|
.split('.')
|
||||||
|
.slice(0, 3)
|
||||||
|
.join('.');
|
||||||
|
|
||||||
|
console.log(`Installing patches for ${currentVersion}...`);
|
||||||
|
|
||||||
|
let patchIndex = 1;
|
||||||
|
while (true) {
|
||||||
|
const response = await fetch(
|
||||||
|
`${secrets.WOTB_DLC_CDN}/dlc/s${currentVersion}_${patchIndex}.yaml`,
|
||||||
|
);
|
||||||
|
|
||||||
|
if (response.status === 200) {
|
||||||
|
console.log(`Applying patch ${patchIndex}...`);
|
||||||
|
|
||||||
|
const data = parseYaml(await response.text());
|
||||||
|
const dvpm = await fetch(`${secrets.WOTB_DLC_CDN}/dlc/${data.dx11}`).then(
|
||||||
|
(response) => response.arrayBuffer(),
|
||||||
|
);
|
||||||
|
const dvpd = await fetch(
|
||||||
|
`${secrets.WOTB_DLC_CDN}/dlc/${data.dx11.replace('.dvpm', '.dvpd')}`,
|
||||||
|
).then((response) => response.arrayBuffer());
|
||||||
|
const files = await dvp(dvpm, dvpd);
|
||||||
|
|
||||||
|
await Promise.all(
|
||||||
|
files.map(async ({ path, data }) => {
|
||||||
|
const { dir } = parsePath(path);
|
||||||
|
|
||||||
|
await mkdir(`${DATA}/${dir}`, { recursive: true });
|
||||||
|
await writeFile(`${DATA}/${path}.dvpl`, writeDVPL(Buffer.from(data)));
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
|
patchIndex++;
|
||||||
|
} else break;
|
||||||
|
}
|
||||||
@@ -1,5 +1,8 @@
|
|||||||
import { build } from 'esbuild';
|
import { build } from 'esbuild';
|
||||||
import { cp, readdir } from 'fs/promises';
|
import { cp, readdir } from 'fs/promises';
|
||||||
|
import { argv } from 'process';
|
||||||
|
|
||||||
|
const isDev = argv.includes('--dev');
|
||||||
|
|
||||||
readdir('src/workers').then((workers) => {
|
readdir('src/workers').then((workers) => {
|
||||||
const files = [
|
const files = [
|
||||||
@@ -25,6 +28,7 @@ readdir('src/workers').then((workers) => {
|
|||||||
'.js': '.cjs',
|
'.js': '.cjs',
|
||||||
},
|
},
|
||||||
|
|
||||||
|
external: ['sharp'],
|
||||||
bundle: true,
|
bundle: true,
|
||||||
sourcemap: true,
|
sourcemap: true,
|
||||||
minifyIdentifiers: false, // causes goofy errors
|
minifyIdentifiers: false, // causes goofy errors
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
|
import { readdir } from 'fs/promises';
|
||||||
import { argv } from 'process';
|
import { argv } from 'process';
|
||||||
|
|
||||||
const isDepot = argv.includes('--depot');
|
const isDepot = argv.includes('--depot');
|
||||||
export const WOTB_WIN32_DEPOT = 444202;
|
export const WOTB_WIN32_DEPOT = 444202;
|
||||||
export const DATA = isDepot
|
export const DATA = isDepot
|
||||||
? // ? await (async () => {
|
? await (async () => {
|
||||||
// const [installationVersion] = await readdir(`depots/${WOTB_WIN32_DEPOT}`);
|
const [installationVersion] = await readdir(`depots/${WOTB_WIN32_DEPOT}`);
|
||||||
// return `depots/${WOTB_WIN32_DEPOT}/${installationVersion}/Data`;
|
return `depots/${WOTB_WIN32_DEPOT}/${installationVersion}/Data`;
|
||||||
// })()
|
})()
|
||||||
`depots/${WOTB_WIN32_DEPOT}/Data`
|
|
||||||
: 'C:/Program Files (x86)/Steam/steamapps/common/World of Tanks Blitz/Data';
|
: 'C:/Program Files (x86)/Steam/steamapps/common/World of Tanks Blitz/Data';
|
||||||
|
|
||||||
export const POI = {
|
export const POI = {
|
||||||
@@ -24,7 +24,7 @@ export const POI = {
|
|||||||
collisionMeshes: '3d/Tanks/CollisionMeshes',
|
collisionMeshes: '3d/Tanks/CollisionMeshes',
|
||||||
optionalDevices: 'XML/item_defs/vehicles/common/optional_devices.xml',
|
optionalDevices: 'XML/item_defs/vehicles/common/optional_devices.xml',
|
||||||
optionalDeviceSlots:
|
optionalDeviceSlots:
|
||||||
'XML/item_defs/vehicles/common/optional_device_slots.xml',
|
'XML/item_defs/vehicles/common/optional_device_slots.xml',
|
||||||
optionalDeviceImageMappings:
|
optionalDeviceImageMappings:
|
||||||
'UI/Screens3/Lobby/Inventory/OptionalDevices/OptionalDevicesItemImage.style.yaml',
|
'UI/Screens3/Lobby/Inventory/OptionalDevices/OptionalDevicesItemImage.style.yaml',
|
||||||
optionalDevicesImage:
|
optionalDevicesImage:
|
||||||
|
|||||||
@@ -0,0 +1,39 @@
|
|||||||
|
import sharp from 'sharp';
|
||||||
|
import { readDVPLFile } from '../../src/core/blitz/readDVPLFile';
|
||||||
|
import { commitAssets } from '../../src/core/blitzkrieg/commitAssets';
|
||||||
|
import { FileChange } from '../../src/core/blitzkrieg/commitMultipleFiles';
|
||||||
|
import { DATA } from './constants';
|
||||||
|
|
||||||
|
const ICONS = [
|
||||||
|
['currency_silver_m.packed.webp', 'silver'],
|
||||||
|
['currency_premium_xl.packed.webp', 'premium'],
|
||||||
|
['currency_gold_m.packed.webp', 'gold'],
|
||||||
|
['currency_free-xp_xl.packed.webp', 'free-xp'],
|
||||||
|
['currency_elite-xp_xl.packed.webp', 'elite-xp'],
|
||||||
|
['currency_crew-xp_xl.packed.webp', 'crew-xp'],
|
||||||
|
['currency_battle-xp_xl.packed.webp', 'xp'],
|
||||||
|
];
|
||||||
|
|
||||||
|
export async function currencies(production: boolean) {
|
||||||
|
console.log('Building currency icons...');
|
||||||
|
|
||||||
|
const changes = await Promise.all(
|
||||||
|
ICONS.map(async ([file, name]) => {
|
||||||
|
const content = (
|
||||||
|
await sharp(
|
||||||
|
await readDVPLFile(`${DATA}/Gfx/Lobby/currency/${file}.dvpl`),
|
||||||
|
)
|
||||||
|
.trim()
|
||||||
|
.toBuffer()
|
||||||
|
).toString('base64');
|
||||||
|
|
||||||
|
return {
|
||||||
|
content,
|
||||||
|
encoding: 'base64',
|
||||||
|
path: `icons/currencies/${name}.webp`,
|
||||||
|
} satisfies FileChange;
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
|
await commitAssets('currency icons', changes, production);
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import { readdir } from 'fs/promises';
|
import { readdir, writeFile } from 'fs/promises';
|
||||||
import { parse as parsePath } from 'path';
|
import { parse as parsePath } from 'path';
|
||||||
import { Vector3Tuple } from 'three';
|
import { Vector3Tuple } from 'three';
|
||||||
import { parse as parseYaml } from 'yaml';
|
import { parse as parseYaml } from 'yaml';
|
||||||
@@ -79,6 +79,16 @@ type VehicleDefinitionArmor = Record<
|
|||||||
string,
|
string,
|
||||||
number | { vehicleDamageFactor: 0; '#text': number }
|
number | { vehicleDamageFactor: 0; '#text': number }
|
||||||
>;
|
>;
|
||||||
|
interface UnlocksInner {
|
||||||
|
cost: number;
|
||||||
|
'#text': number;
|
||||||
|
}
|
||||||
|
type Unlocks = {
|
||||||
|
[key in 'vehicle' | 'engine' | 'chassis' | 'turret' | 'gun']:
|
||||||
|
| UnlocksInner
|
||||||
|
| UnlocksInner[];
|
||||||
|
};
|
||||||
|
type UnlocksListing = Unlocks | undefined;
|
||||||
interface VehicleDefinitions {
|
interface VehicleDefinitions {
|
||||||
invisibility: {
|
invisibility: {
|
||||||
moving: number;
|
moving: number;
|
||||||
@@ -92,7 +102,7 @@ interface VehicleDefinitions {
|
|||||||
};
|
};
|
||||||
consumableSlots: number;
|
consumableSlots: number;
|
||||||
provisionSlots: number;
|
provisionSlots: number;
|
||||||
optDevicePreset: string;
|
optDevicePreset: string | string[];
|
||||||
hull: {
|
hull: {
|
||||||
armor: VehicleDefinitionArmor;
|
armor: VehicleDefinitionArmor;
|
||||||
turretPositions: { turret: string };
|
turretPositions: { turret: string };
|
||||||
@@ -102,6 +112,7 @@ interface VehicleDefinitions {
|
|||||||
};
|
};
|
||||||
chassis: {
|
chassis: {
|
||||||
[key: string]: {
|
[key: string]: {
|
||||||
|
unlocks: UnlocksListing;
|
||||||
weight: number;
|
weight: number;
|
||||||
terrainResistance: string;
|
terrainResistance: string;
|
||||||
rotationSpeed: number;
|
rotationSpeed: number;
|
||||||
@@ -130,10 +141,13 @@ interface VehicleDefinitions {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
engines: {
|
engines: {
|
||||||
[key: string]: unknown;
|
[key: string]: {
|
||||||
|
unlocks: UnlocksListing;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
turrets0: {
|
turrets0: {
|
||||||
[key: string]: {
|
[key: string]: {
|
||||||
|
unlocks: UnlocksListing;
|
||||||
rotationSpeed: number;
|
rotationSpeed: number;
|
||||||
weight: number;
|
weight: number;
|
||||||
circularVisionRadius: number;
|
circularVisionRadius: number;
|
||||||
@@ -149,6 +163,7 @@ interface VehicleDefinitions {
|
|||||||
};
|
};
|
||||||
guns: {
|
guns: {
|
||||||
[key: string]: {
|
[key: string]: {
|
||||||
|
unlocks: UnlocksListing;
|
||||||
armor: VehicleDefinitionArmor & {
|
armor: VehicleDefinitionArmor & {
|
||||||
gun?:
|
gun?:
|
||||||
| number
|
| number
|
||||||
@@ -353,6 +368,8 @@ export async function definitions(production: boolean) {
|
|||||||
`${DATA}/${POI.provisionsCommon}.dvpl`,
|
`${DATA}/${POI.provisionsCommon}.dvpl`,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const tankXps = new Map<number, number>();
|
||||||
|
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
nations.map(async (nation) => {
|
nations.map(async (nation) => {
|
||||||
const tankList = await readXMLDVPL<{ root: VehicleDefinitionList }>(
|
const tankList = await readXMLDVPL<{ root: VehicleDefinitionList }>(
|
||||||
@@ -385,6 +402,10 @@ export async function definitions(production: boolean) {
|
|||||||
);
|
);
|
||||||
|
|
||||||
for (const tankKey in tankList.root) {
|
for (const tankKey in tankList.root) {
|
||||||
|
const gunXps = new Map<number, number>();
|
||||||
|
const turretXps = new Map<number, number>();
|
||||||
|
const engineXps = new Map<number, number>();
|
||||||
|
const trackXps = new Map<number, number>();
|
||||||
const tank = tankList.root[tankKey];
|
const tank = tankList.root[tankKey];
|
||||||
const tankPrice: TankDefinitionPrice =
|
const tankPrice: TankDefinitionPrice =
|
||||||
typeof tank.price === 'number'
|
typeof tank.price === 'number'
|
||||||
@@ -427,6 +448,7 @@ export async function definitions(production: boolean) {
|
|||||||
});
|
});
|
||||||
const crew: Crew[] = [];
|
const crew: Crew[] = [];
|
||||||
const fixedCamouflage = tankTags.includes('eventCamouflage_user');
|
const fixedCamouflage = tankTags.includes('eventCamouflage_user');
|
||||||
|
const totalUnlocks: UnlocksListing[] = [];
|
||||||
|
|
||||||
Object.entries(tankDefinition.root.crew).forEach(([key, value]) => {
|
Object.entries(tankDefinition.root.crew).forEach(([key, value]) => {
|
||||||
let entry: Crew;
|
let entry: Crew;
|
||||||
@@ -473,7 +495,8 @@ export async function definitions(production: boolean) {
|
|||||||
forwards: tankDefinition.root.speedLimits.forward,
|
forwards: tankDefinition.root.speedLimits.forward,
|
||||||
backwards: tankDefinition.root.speedLimits.backward,
|
backwards: tankDefinition.root.speedLimits.backward,
|
||||||
},
|
},
|
||||||
equipment,
|
equipment:
|
||||||
|
typeof equipment === 'string' ? equipment : equipment.at(-1)!,
|
||||||
consumables: tankDefinition.root.consumableSlots,
|
consumables: tankDefinition.root.consumableSlots,
|
||||||
provisions: tankDefinition.root.provisionSlots,
|
provisions: tankDefinition.root.provisionSlots,
|
||||||
name:
|
name:
|
||||||
@@ -531,6 +554,7 @@ export async function definitions(production: boolean) {
|
|||||||
.split(' ')
|
.split(' ')
|
||||||
.map(Number) as Vector3Tuple;
|
.map(Number) as Vector3Tuple;
|
||||||
|
|
||||||
|
totalUnlocks.push(track.unlocks);
|
||||||
tankDefinitions[tankId].tracks.push({
|
tankDefinitions[tankId].tracks.push({
|
||||||
id: trackId,
|
id: trackId,
|
||||||
weight: track.weight,
|
weight: track.weight,
|
||||||
@@ -557,16 +581,18 @@ export async function definitions(production: boolean) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
Object.keys(tankDefinition.root.engines).forEach((engineKey) => {
|
Object.keys(tankDefinition.root.engines).forEach((engineKey) => {
|
||||||
const engine = enginesList.root.shared[engineKey];
|
const engine = tankDefinition.root.engines[engineKey];
|
||||||
|
const engineListEntry = enginesList.root.shared[engineKey];
|
||||||
const engineId = toUniqueId(nation, enginesList.root.ids[engineKey]);
|
const engineId = toUniqueId(nation, enginesList.root.ids[engineKey]);
|
||||||
|
|
||||||
|
totalUnlocks.push(engine.unlocks);
|
||||||
tankDefinitions[tankId].engines.push({
|
tankDefinitions[tankId].engines.push({
|
||||||
id: engineId,
|
id: engineId,
|
||||||
name: strings[engine.userString],
|
name: strings[engineListEntry.userString],
|
||||||
fireChance: engine.fireStartingChance,
|
fireChance: engineListEntry.fireStartingChance,
|
||||||
tier: engine.level as Tier,
|
tier: engineListEntry.level as Tier,
|
||||||
weight: engine.weight,
|
weight: engineListEntry.weight,
|
||||||
power: engine.power,
|
power: engineListEntry.power,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -593,6 +619,7 @@ export async function definitions(production: boolean) {
|
|||||||
.map(Number) as Vector3Tuple;
|
.map(Number) as Vector3Tuple;
|
||||||
const turretArmor: ModelArmor = { thickness: {} };
|
const turretArmor: ModelArmor = { thickness: {} };
|
||||||
|
|
||||||
|
totalUnlocks.push(turret.unlocks);
|
||||||
Object.keys(turret.armor)
|
Object.keys(turret.armor)
|
||||||
.filter((name) => name.startsWith('armor_'))
|
.filter((name) => name.startsWith('armor_'))
|
||||||
.forEach((name) => {
|
.forEach((name) => {
|
||||||
@@ -645,11 +672,11 @@ export async function definitions(production: boolean) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
Object.keys(turret.guns).forEach((gunKey, gunIndex) => {
|
Object.keys(turret.guns).forEach((gunKey, gunIndex) => {
|
||||||
const turretGunEntry = turret.guns[gunKey];
|
const gun = turret.guns[gunKey];
|
||||||
const gunId = toUniqueId(nation, gunList.root.ids[gunKey]);
|
const gunId = toUniqueId(nation, gunList.root.ids[gunKey]);
|
||||||
const gunListEntry = gunList.root.shared[gunKey];
|
const gunListEntry = gunList.root.shared[gunKey];
|
||||||
const pitchLimitsRaw =
|
const pitchLimitsRaw =
|
||||||
turretGunEntry.pitchLimits ?? gunListEntry.pitchLimits;
|
gun.pitchLimits ?? gunListEntry.pitchLimits;
|
||||||
const gunPitch = (
|
const gunPitch = (
|
||||||
typeof pitchLimitsRaw === 'string'
|
typeof pitchLimitsRaw === 'string'
|
||||||
? pitchLimitsRaw
|
? pitchLimitsRaw
|
||||||
@@ -658,43 +685,41 @@ export async function definitions(production: boolean) {
|
|||||||
.split(' ')
|
.split(' ')
|
||||||
.map(Number) as [number, number];
|
.map(Number) as [number, number];
|
||||||
const gunModel = Number(
|
const gunModel = Number(
|
||||||
parsePath(turretGunEntry.models.undamaged).name.split('_')[1],
|
parsePath(gun.models.undamaged).name.split('_')[1],
|
||||||
);
|
);
|
||||||
const gunName =
|
const gunName =
|
||||||
strings[gunListEntry.userString] ?? gunKey.replaceAll('_', ' ');
|
strings[gunListEntry.userString] ?? gunKey.replaceAll('_', ' ');
|
||||||
const gunType =
|
const gunType =
|
||||||
'clip' in turretGunEntry
|
'clip' in gun
|
||||||
? turretGunEntry.pumpGunMode
|
? gun.pumpGunMode
|
||||||
? 'autoReloader'
|
? 'autoReloader'
|
||||||
: 'autoLoader'
|
: 'autoLoader'
|
||||||
: 'regular';
|
: 'regular';
|
||||||
const gunReload =
|
const gunReload =
|
||||||
gunType === 'autoReloader'
|
gunType === 'autoReloader'
|
||||||
? turretGunEntry.pumpGunReloadTimes!.split(' ').map(Number)
|
? gun.pumpGunReloadTimes!.split(' ').map(Number)
|
||||||
: turretGunEntry.reloadTime;
|
: gun.reloadTime;
|
||||||
const gunClipCount =
|
const gunClipCount =
|
||||||
gunType === 'regular' ? undefined : turretGunEntry.clip!.count;
|
gunType === 'regular' ? undefined : gun.clip!.count;
|
||||||
const gunInterClip =
|
const gunIntraClip =
|
||||||
gunType === 'regular'
|
gunType === 'regular' ? undefined : 60 / gun.clip!.rate;
|
||||||
? undefined
|
const front = gun.extraPitchLimits?.front
|
||||||
: 60 / turretGunEntry.clip!.rate;
|
? gun.extraPitchLimits.front.split(' ').map(Number)
|
||||||
const front = turretGunEntry.extraPitchLimits?.front
|
|
||||||
? turretGunEntry.extraPitchLimits.front.split(' ').map(Number)
|
|
||||||
: undefined;
|
: undefined;
|
||||||
const back = turretGunEntry.extraPitchLimits?.back
|
const back = gun.extraPitchLimits?.back
|
||||||
? turretGunEntry.extraPitchLimits.back.split(' ').map(Number)
|
? gun.extraPitchLimits.back.split(' ').map(Number)
|
||||||
: undefined;
|
: undefined;
|
||||||
const transition = turretGunEntry.extraPitchLimits?.transition
|
const transition = gun.extraPitchLimits?.transition
|
||||||
? typeof turretGunEntry.extraPitchLimits.transition === 'number'
|
? typeof gun.extraPitchLimits.transition === 'number'
|
||||||
? turretGunEntry.extraPitchLimits.transition
|
? gun.extraPitchLimits.transition
|
||||||
: turretGunEntry.extraPitchLimits.transition.at(-1)!
|
: gun.extraPitchLimits.transition.at(-1)!
|
||||||
: undefined;
|
: undefined;
|
||||||
const gunArmor: ModelArmor = { thickness: {} };
|
const gunArmor: ModelArmor = { thickness: {} };
|
||||||
const shotDispersionFactors =
|
const shotDispersionFactors =
|
||||||
turretGunEntry.shotDispersionFactors ??
|
gun.shotDispersionFactors ?? gunListEntry.shotDispersionFactors;
|
||||||
gunListEntry.shotDispersionFactors;
|
|
||||||
|
|
||||||
Object.keys(turretGunEntry.armor)
|
totalUnlocks.push(gun.unlocks);
|
||||||
|
Object.keys(gun.armor)
|
||||||
.filter((name) => name.startsWith('armor_'))
|
.filter((name) => name.startsWith('armor_'))
|
||||||
.forEach((name) => {
|
.forEach((name) => {
|
||||||
const armorIdString = name.match(/armor_(\d+)/)?.[1];
|
const armorIdString = name.match(/armor_(\d+)/)?.[1];
|
||||||
@@ -702,7 +727,7 @@ export async function definitions(production: boolean) {
|
|||||||
throw new SyntaxError(`Invalid armor id: ${name}`);
|
throw new SyntaxError(`Invalid armor id: ${name}`);
|
||||||
}
|
}
|
||||||
const armorId = parseInt(armorIdString);
|
const armorId = parseInt(armorIdString);
|
||||||
const armorRaw = turretGunEntry.armor[name];
|
const armorRaw = gun.armor[name];
|
||||||
if (typeof armorRaw === 'number') {
|
if (typeof armorRaw === 'number') {
|
||||||
gunArmor.thickness[armorId] = armorRaw;
|
gunArmor.thickness[armorId] = armorRaw;
|
||||||
} else {
|
} else {
|
||||||
@@ -722,15 +747,15 @@ export async function definitions(production: boolean) {
|
|||||||
type: gunType,
|
type: gunType,
|
||||||
reload: gunReload,
|
reload: gunReload,
|
||||||
count: gunClipCount,
|
count: gunClipCount,
|
||||||
interClip: gunInterClip,
|
intraClip: gunIntraClip,
|
||||||
camouflageLoss:
|
camouflageLoss:
|
||||||
typeof turretGunEntry.invisibilityFactorAtShot === 'number'
|
typeof gun.invisibilityFactorAtShot === 'number'
|
||||||
? turretGunEntry.invisibilityFactorAtShot
|
? gun.invisibilityFactorAtShot
|
||||||
: turretGunEntry.invisibilityFactorAtShot.at(-1)!,
|
: gun.invisibilityFactorAtShot.at(-1)!,
|
||||||
aimTime: turretGunEntry.aimingTime ?? gunListEntry.aimingTime,
|
aimTime: gun.aimingTime ?? gunListEntry.aimingTime,
|
||||||
dispersion: {
|
dispersion: {
|
||||||
base:
|
base:
|
||||||
turretGunEntry.shotDispersionRadius ??
|
gun.shotDispersionRadius ??
|
||||||
gunListEntry.shotDispersionRadius,
|
gunListEntry.shotDispersionRadius,
|
||||||
damaged: shotDispersionFactors.whileGunDamaged,
|
damaged: shotDispersionFactors.whileGunDamaged,
|
||||||
shot: shotDispersionFactors.afterShot,
|
shot: shotDispersionFactors.afterShot,
|
||||||
@@ -742,11 +767,11 @@ export async function definitions(production: boolean) {
|
|||||||
armor: gunArmor,
|
armor: gunArmor,
|
||||||
model: gunModel,
|
model: gunModel,
|
||||||
thickness:
|
thickness:
|
||||||
turretGunEntry.armor.gun === undefined
|
gun.armor.gun === undefined
|
||||||
? 0
|
? 0
|
||||||
: typeof turretGunEntry.armor.gun === 'number'
|
: typeof gun.armor.gun === 'number'
|
||||||
? turretGunEntry.armor.gun
|
? gun.armor.gun
|
||||||
: turretGunEntry.armor.gun['#text'],
|
: gun.armor.gun['#text'],
|
||||||
pitch: {
|
pitch: {
|
||||||
min: gunPitch[0],
|
min: gunPitch[0],
|
||||||
max: gunPitch[1],
|
max: gunPitch[1],
|
||||||
@@ -808,10 +833,100 @@ export async function definitions(production: boolean) {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
totalUnlocks.forEach((unlocks) => {
|
||||||
|
if (unlocks === undefined) return;
|
||||||
|
|
||||||
|
Object.entries(unlocks).forEach(([key, value]) => {
|
||||||
|
(Array.isArray(value) ? value : [value]).forEach((vehicle) => {
|
||||||
|
switch (key as keyof Unlocks) {
|
||||||
|
case 'vehicle': {
|
||||||
|
const tankListEntry = tankList.root[vehicle['#text']];
|
||||||
|
const currentTank = tankDefinitions[tankId];
|
||||||
|
const successorId = toUniqueId(nation, tankListEntry.id);
|
||||||
|
|
||||||
|
tankXps.set(successorId, vehicle.cost);
|
||||||
|
|
||||||
|
if (currentTank.successors === undefined) {
|
||||||
|
currentTank.successors = [];
|
||||||
|
}
|
||||||
|
if (!currentTank.successors!.includes(successorId)) {
|
||||||
|
currentTank.successors!.push(successorId);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 'gun': {
|
||||||
|
gunXps.set(
|
||||||
|
toUniqueId(nation, gunList.root.ids[vehicle['#text']]),
|
||||||
|
vehicle.cost,
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 'turret': {
|
||||||
|
turretXps.set(
|
||||||
|
toUniqueId(nation, turretList.root.ids[vehicle['#text']]),
|
||||||
|
vehicle.cost,
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 'engine': {
|
||||||
|
engineXps.set(
|
||||||
|
toUniqueId(nation, enginesList.root.ids[vehicle['#text']]),
|
||||||
|
vehicle.cost,
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 'chassis': {
|
||||||
|
trackXps.set(
|
||||||
|
toUniqueId(nation, chassisList.root.ids[vehicle['#text']]),
|
||||||
|
vehicle.cost,
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
Object.values(tankDefinitions[tankId].turrets).forEach((turret) => {
|
||||||
|
turret.xp = turretXps.get(turret.id);
|
||||||
|
|
||||||
|
Object.values(turret.guns).forEach((gun) => {
|
||||||
|
gun.xp = gunXps.get(gun.id);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
Object.values(tankDefinitions[tankId].engines).forEach((engine) => {
|
||||||
|
engine.xp = engineXps.get(engine.id);
|
||||||
|
});
|
||||||
|
|
||||||
|
Object.values(tankDefinitions[tankId].tracks).forEach((track) => {
|
||||||
|
track.xp = trackXps.get(track.id);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
Object.values(tankDefinitions).forEach((tank) => {
|
||||||
|
tank.xp = tankXps.get(tank.id);
|
||||||
|
});
|
||||||
|
|
||||||
|
Object.values(tankDefinitions).forEach((tank) => {
|
||||||
|
tank.successors?.forEach((predecessorId) => {
|
||||||
|
if (tankDefinitions[predecessorId].ancestors === undefined) {
|
||||||
|
tankDefinitions[predecessorId].ancestors = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!tankDefinitions[predecessorId].ancestors?.includes(tank.id)) {
|
||||||
|
tankDefinitions[predecessorId].ancestors?.push(tank.id);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
Object.entries(optionalDevices.root).forEach(
|
Object.entries(optionalDevices.root).forEach(
|
||||||
([optionalDeviceKey, optionalDeviceEntry]) => {
|
([optionalDeviceKey, optionalDeviceEntry]) => {
|
||||||
if (optionalDeviceKey === 'nextAvailableId') return;
|
if (optionalDeviceKey === 'nextAvailableId') return;
|
||||||
@@ -969,6 +1084,10 @@ export async function definitions(production: boolean) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
writeFile(
|
||||||
|
'test.tanks.cdon.lz4',
|
||||||
|
Buffer.from(superCompress(tankDefinitions), 'base64'),
|
||||||
|
);
|
||||||
await commitAssets(
|
await commitAssets(
|
||||||
'definitions',
|
'definitions',
|
||||||
[
|
[
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import { boosterIcons } from './boosterIcons';
|
|||||||
import { camouflageIcons } from './camouflageIcons';
|
import { camouflageIcons } from './camouflageIcons';
|
||||||
import { circleFlags } from './circleFlags';
|
import { circleFlags } from './circleFlags';
|
||||||
import { consumableProvisionIcons } from './consumableProvisionIcons';
|
import { consumableProvisionIcons } from './consumableProvisionIcons';
|
||||||
|
import { currencies } from './currencies';
|
||||||
import { definitions } from './definitions';
|
import { definitions } from './definitions';
|
||||||
import { equipmentIcons } from './equipmentIcons';
|
import { equipmentIcons } from './equipmentIcons';
|
||||||
import { moduleIcons } from './moduleIcons';
|
import { moduleIcons } from './moduleIcons';
|
||||||
@@ -38,6 +39,7 @@ const methods = [
|
|||||||
boosterIcons,
|
boosterIcons,
|
||||||
tankArmors,
|
tankArmors,
|
||||||
tankModels,
|
tankModels,
|
||||||
|
currencies,
|
||||||
];
|
];
|
||||||
|
|
||||||
for (const method of methods) {
|
for (const method of methods) {
|
||||||
|
|||||||
@@ -1,21 +1,15 @@
|
|||||||
import { NodeIO } from '@gltf-transform/core';
|
import { NodeIO } from '@gltf-transform/core';
|
||||||
import { readdir } from 'fs/promises';
|
import { readdir } from 'fs/promises';
|
||||||
import { Vector3Tuple } from 'three';
|
|
||||||
import { extractModel } from '../../src/core/blitz/extractModel';
|
import { extractModel } from '../../src/core/blitz/extractModel';
|
||||||
import { readXMLDVPL } from '../../src/core/blitz/readXMLDVPL';
|
import { readXMLDVPL } from '../../src/core/blitz/readXMLDVPL';
|
||||||
import { readYAMLDVPL } from '../../src/core/blitz/readYAMLDVPL';
|
import { readYAMLDVPL } from '../../src/core/blitz/readYAMLDVPL';
|
||||||
import { toUniqueId } from '../../src/core/blitz/toUniqueId';
|
import { toUniqueId } from '../../src/core/blitz/toUniqueId';
|
||||||
// import { AssetCommit } from '../../src/core/github/assetCommit';
|
|
||||||
import { commitAssets } from '../../src/core/blitzkrieg/commitAssets';
|
import { commitAssets } from '../../src/core/blitzkrieg/commitAssets';
|
||||||
import { FileChange } from '../../src/core/blitzkrieg/commitMultipleFiles';
|
import { FileChange } from '../../src/core/blitzkrieg/commitMultipleFiles';
|
||||||
import { DATA, POI } from './constants';
|
import { DATA, POI } from './constants';
|
||||||
import { VehicleDefinitionList } from './definitions';
|
import { VehicleDefinitionList } from './definitions';
|
||||||
import { TankParameters } from './tankIcons';
|
import { TankParameters } from './tankIcons';
|
||||||
|
|
||||||
interface VehicleCustomization {
|
|
||||||
armorColor: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function tankModels(production: boolean) {
|
export async function tankModels(production: boolean) {
|
||||||
console.log('Building tank models...');
|
console.log('Building tank models...');
|
||||||
|
|
||||||
@@ -27,18 +21,9 @@ export async function tankModels(production: boolean) {
|
|||||||
for (const nationIndex in nations) {
|
for (const nationIndex in nations) {
|
||||||
const nation = nations[nationIndex];
|
const nation = nations[nationIndex];
|
||||||
const changes: FileChange[] = [];
|
const changes: FileChange[] = [];
|
||||||
// const assetCommit = new AssetCommit(`tank models ${nation}`, production);
|
|
||||||
const tanks = await readXMLDVPL<{ root: VehicleDefinitionList }>(
|
const tanks = await readXMLDVPL<{ root: VehicleDefinitionList }>(
|
||||||
`${DATA}/${POI.vehicleDefinitions}/${nation}/list.xml.dvpl`,
|
`${DATA}/${POI.vehicleDefinitions}/${nation}/list.xml.dvpl`,
|
||||||
);
|
);
|
||||||
const customization = await readXMLDVPL<{ root: VehicleCustomization }>(
|
|
||||||
`${DATA}/${POI.vehicleDefinitions}/${nation}/customization.xml.dvpl`,
|
|
||||||
);
|
|
||||||
const baseColor = customization.root.armorColor
|
|
||||||
.split(' ')
|
|
||||||
.slice(0, 3)
|
|
||||||
.map(Number)
|
|
||||||
.map((channel) => channel / 255) as Vector3Tuple;
|
|
||||||
|
|
||||||
console.log(`Building models for ${nation}`);
|
console.log(`Building models for ${nation}`);
|
||||||
|
|
||||||
@@ -56,11 +41,8 @@ export async function tankModels(production: boolean) {
|
|||||||
const model = await extractModel(
|
const model = await extractModel(
|
||||||
DATA,
|
DATA,
|
||||||
parameters.resourcesPath.blitzModelPath.replace(/\.sc2$/, ''),
|
parameters.resourcesPath.blitzModelPath.replace(/\.sc2$/, ''),
|
||||||
baseColor,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// writeFile(`test.${tankKey}.glb`, await nodeIO.writeBinary(model));
|
|
||||||
|
|
||||||
changes.push({
|
changes.push({
|
||||||
path: `3d/tanks/models/${id}.glb`,
|
path: `3d/tanks/models/${id}.glb`,
|
||||||
content: Buffer.from(await nodeIO.writeBinary(model)).toString(
|
content: Buffer.from(await nodeIO.writeBinary(model)).toString(
|
||||||
@@ -71,7 +53,6 @@ export async function tankModels(production: boolean) {
|
|||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
// assetCommit.push();
|
|
||||||
await commitAssets(`tank models ${nation}`, changes, production);
|
await commitAssets(`tank models ${nation}`, changes, production);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"target": "ESNext",
|
||||||
|
"module": "ESNext",
|
||||||
|
"moduleResolution": "Node",
|
||||||
|
"esModuleInterop": true,
|
||||||
|
"forceConsistentCasingInFileNames": true,
|
||||||
|
"strict": true,
|
||||||
|
"skipLibCheck": true,
|
||||||
|
"noEmit": true,
|
||||||
|
"resolveJsonModule": true,
|
||||||
|
"jsx": "preserve",
|
||||||
|
"lib": ["dom", "dom.iterable", "esnext"],
|
||||||
|
"allowJs": true,
|
||||||
|
"incremental": true,
|
||||||
|
"isolatedModules": true
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,6 +5,7 @@ import { useEffect, useState } from 'react';
|
|||||||
import * as Breakdown from '../../../components/Breakdown';
|
import * as Breakdown from '../../../components/Breakdown';
|
||||||
import { WARGAMING_APPLICATION_ID } from '../../../constants/wargamingApplicationID';
|
import { WARGAMING_APPLICATION_ID } from '../../../constants/wargamingApplicationID';
|
||||||
import fetchBlitz from '../../../core/blitz/fetchBlitz';
|
import fetchBlitz from '../../../core/blitz/fetchBlitz';
|
||||||
|
import { resetSession } from '../../../core/blitzkrieg/resetSession';
|
||||||
import {
|
import {
|
||||||
TankDefinition,
|
TankDefinition,
|
||||||
tankDefinitions,
|
tankDefinitions,
|
||||||
@@ -13,10 +14,7 @@ import { tankAverages } from '../../../core/blitzstars/tankAverages';
|
|||||||
import calculateWN8 from '../../../core/statistics/calculateWN8';
|
import calculateWN8 from '../../../core/statistics/calculateWN8';
|
||||||
import { deltaTankStats } from '../../../core/statistics/deltaTankStats';
|
import { deltaTankStats } from '../../../core/statistics/deltaTankStats';
|
||||||
import getWN8Percentile from '../../../core/statistics/getWN8Percentile';
|
import getWN8Percentile from '../../../core/statistics/getWN8Percentile';
|
||||||
import mutateSession, {
|
import mutateSession, { useSession } from '../../../stores/session';
|
||||||
resetSession,
|
|
||||||
useSession,
|
|
||||||
} from '../../../stores/session';
|
|
||||||
import { IndividualTankStats, TanksStats } from '../../../types/tanksStats';
|
import { IndividualTankStats, TanksStats } from '../../../types/tanksStats';
|
||||||
import { CustomColumnDisplay } from '../../tools/session/components/CustomColumn';
|
import { CustomColumnDisplay } from '../../tools/session/components/CustomColumn';
|
||||||
import { Menu } from '../../tools/session/components/Menu';
|
import { Menu } from '../../tools/session/components/Menu';
|
||||||
|
|||||||
+2
-3
@@ -3,12 +3,12 @@
|
|||||||
import { CaretRightIcon } from '@radix-ui/react-icons';
|
import { CaretRightIcon } from '@radix-ui/react-icons';
|
||||||
import { AlertDialog, Button, Flex, Text, Theme } from '@radix-ui/themes';
|
import { AlertDialog, Button, Flex, Text, Theme } from '@radix-ui/themes';
|
||||||
import '@radix-ui/themes/styles.css';
|
import '@radix-ui/themes/styles.css';
|
||||||
import { Analytics } from '@vercel/analytics/react';
|
|
||||||
import { config } from 'dotenv';
|
import { config } from 'dotenv';
|
||||||
import { Roboto_Flex } from 'next/font/google';
|
import { Roboto_Flex } from 'next/font/google';
|
||||||
import { usePathname } from 'next/navigation';
|
import { usePathname } from 'next/navigation';
|
||||||
import { ReactNode, useEffect, useState } from 'react';
|
import { ReactNode, useEffect, useState } from 'react';
|
||||||
import { SkyLine } from '../assets/art/SkyLine';
|
import { SkyLine } from '../assets/art/SkyLine';
|
||||||
|
import { Analytics } from '../components/Analytics';
|
||||||
import Navbar from '../components/Navbar';
|
import Navbar from '../components/Navbar';
|
||||||
import PageWrapper from '../components/PageWrapper';
|
import PageWrapper from '../components/PageWrapper';
|
||||||
import isDev from '../core/blitzkrieg/isDev';
|
import isDev from '../core/blitzkrieg/isDev';
|
||||||
@@ -51,6 +51,7 @@ export default function RootLayout({ children }: RootLayoutProps) {
|
|||||||
name="description"
|
name="description"
|
||||||
content="🎉 Tools for everything World of Tanks Blitz"
|
content="🎉 Tools for everything World of Tanks Blitz"
|
||||||
/>
|
/>
|
||||||
|
<Analytics />
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body
|
<body
|
||||||
@@ -60,8 +61,6 @@ export default function RootLayout({ children }: RootLayoutProps) {
|
|||||||
backgroundColor: isEmbed ? 'transparent' : undefined,
|
backgroundColor: isEmbed ? 'transparent' : undefined,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Analytics />
|
|
||||||
|
|
||||||
<Theme
|
<Theme
|
||||||
appearance="dark"
|
appearance="dark"
|
||||||
panelBackground="translucent"
|
panelBackground="translucent"
|
||||||
|
|||||||
@@ -22,7 +22,9 @@ import { UNLOCALIZED_REGION_NAMES } from '../../../constants/regions';
|
|||||||
import searchPlayersAcrossRegions, {
|
import searchPlayersAcrossRegions, {
|
||||||
AccountListWithServer,
|
AccountListWithServer,
|
||||||
} from '../../../core/blitz/searchPlayersAcrossRegions';
|
} from '../../../core/blitz/searchPlayersAcrossRegions';
|
||||||
import { resetSession, setSession, useSession } from '../../../stores/session';
|
import { resetSession } from '../../../core/blitzkrieg/resetSession';
|
||||||
|
import { setSession } from '../../../core/blitzkrieg/setSession';
|
||||||
|
import { useSession } from '../../../stores/session';
|
||||||
import SessionPage from '../../embeds/session/page';
|
import SessionPage from '../../embeds/session/page';
|
||||||
import { Menu } from './components/Menu';
|
import { Menu } from './components/Menu';
|
||||||
import * as styles from './page.css';
|
import * as styles from './page.css';
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ import { pushTankopediaPath } from '../../../../../core/blitzkrieg/pushTankopedi
|
|||||||
import {
|
import {
|
||||||
SHELL_NAMES,
|
SHELL_NAMES,
|
||||||
TIER_ROMAN_NUMERALS,
|
TIER_ROMAN_NUMERALS,
|
||||||
} from '../../../../../core/blitzkrieg/tankDefinitions';
|
} from '../../../../../core/blitzkrieg/tankDefinitions/constants';
|
||||||
import { mutateDuel, useDuel } from '../../../../../stores/duel';
|
import { mutateDuel, useDuel } from '../../../../../stores/duel';
|
||||||
import {
|
import {
|
||||||
mutateTankopediaTemporary,
|
mutateTankopediaTemporary,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { Flex, Heading } from '@radix-ui/themes';
|
import { Flex, Heading } from '@radix-ui/themes';
|
||||||
import { ModuleButton } from '../../../../../../../components/ModuleButtons/ModuleButton';
|
import { ModuleButton } from '../../../../../../../components/ModuleButtons/ModuleButton';
|
||||||
import { TIER_ROMAN_NUMERALS } from '../../../../../../../core/blitzkrieg/tankDefinitions';
|
import { TIER_ROMAN_NUMERALS } from '../../../../../../../core/blitzkrieg/tankDefinitions/constants';
|
||||||
import { mutateDuel, useDuel } from '../../../../../../../stores/duel';
|
import { mutateDuel, useDuel } from '../../../../../../../stores/duel';
|
||||||
import { mutateTankopediaTemporary } from '../../../../../../../stores/tankopedia';
|
import { mutateTankopediaTemporary } from '../../../../../../../stores/tankopedia';
|
||||||
import { ConfigurationChildWrapper } from './ConfigurationChildWrapper';
|
import { ConfigurationChildWrapper } from './ConfigurationChildWrapper';
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import { debounce } from 'lodash';
|
|||||||
import { use, useEffect, useRef, useState } from 'react';
|
import { use, useEffect, useRef, useState } from 'react';
|
||||||
import { lerp } from 'three/src/math/MathUtils';
|
import { lerp } from 'three/src/math/MathUtils';
|
||||||
import { ShellButton } from '../../../../../../components/ModuleButtons/ShellButton';
|
import { ShellButton } from '../../../../../../components/ModuleButtons/ShellButton';
|
||||||
|
import { applyPitchYawLimits } from '../../../../../../core/blitz/applyPitchYawLimits';
|
||||||
import { isExplosive } from '../../../../../../core/blitz/isExplosive';
|
import { isExplosive } from '../../../../../../core/blitz/isExplosive';
|
||||||
import { resolveNearPenetration } from '../../../../../../core/blitz/resolveNearPenetration';
|
import { resolveNearPenetration } from '../../../../../../core/blitz/resolveNearPenetration';
|
||||||
import { coefficient } from '../../../../../../core/blitzkrieg/coefficient';
|
import { coefficient } from '../../../../../../core/blitzkrieg/coefficient';
|
||||||
@@ -17,7 +18,7 @@ import {
|
|||||||
CREW_MEMBER_NAMES,
|
CREW_MEMBER_NAMES,
|
||||||
GUN_TYPE_NAMES,
|
GUN_TYPE_NAMES,
|
||||||
SHELL_NAMES,
|
SHELL_NAMES,
|
||||||
} from '../../../../../../core/blitzkrieg/tankDefinitions';
|
} from '../../../../../../core/blitzkrieg/tankDefinitions/constants';
|
||||||
import { unionBoundingBox } from '../../../../../../core/blitzkrieg/unionBoundingBox';
|
import { unionBoundingBox } from '../../../../../../core/blitzkrieg/unionBoundingBox';
|
||||||
import { useConsumable } from '../../../../../../hooks/useConsumable';
|
import { useConsumable } from '../../../../../../hooks/useConsumable';
|
||||||
import { useEquipment } from '../../../../../../hooks/useEquipment';
|
import { useEquipment } from '../../../../../../hooks/useEquipment';
|
||||||
@@ -56,6 +57,7 @@ export function Characteristics() {
|
|||||||
turretModelDefinition.boundingBox,
|
turretModelDefinition.boundingBox,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
const gunDefaultPitch = tankModelDefinition.turretRotation?.pitch ?? 0;
|
||||||
const weight =
|
const weight =
|
||||||
tank.weight + engine.weight + track.weight + turret.weight + gun.weight;
|
tank.weight + engine.weight + track.weight + turret.weight + gun.weight;
|
||||||
const weightTons = weight / 1000;
|
const weightTons = weight / 1000;
|
||||||
@@ -113,7 +115,7 @@ export function Characteristics() {
|
|||||||
// TODO: add max rolls
|
// TODO: add max rolls
|
||||||
[hasTungsten, 0.15],
|
[hasTungsten, 0.15],
|
||||||
);
|
);
|
||||||
const interClipCoefficient = coefficient([hasShellReloadBoost, -0.3]);
|
const intraClipCoefficient = coefficient([hasShellReloadBoost, -0.3]);
|
||||||
const shellVelocityCoefficient = coefficient(
|
const shellVelocityCoefficient = coefficient(
|
||||||
[hasSupercharger, 0.3],
|
[hasSupercharger, 0.3],
|
||||||
[hasImprovedGunPowder, 0.3],
|
[hasImprovedGunPowder, 0.3],
|
||||||
@@ -210,7 +212,7 @@ export function Characteristics() {
|
|||||||
shell,
|
shell,
|
||||||
damageCoefficient,
|
damageCoefficient,
|
||||||
reloadCoefficient,
|
reloadCoefficient,
|
||||||
interClipCoefficient,
|
intraClipCoefficient,
|
||||||
);
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -218,6 +220,17 @@ export function Characteristics() {
|
|||||||
penetrationDistanceInput.current.value = `${penetrationDistance}`;
|
penetrationDistanceInput.current.value = `${penetrationDistance}`;
|
||||||
}
|
}
|
||||||
}, [penetrationDistance]);
|
}, [penetrationDistance]);
|
||||||
|
useEffect(() => {
|
||||||
|
mutateDuel((draft) => {
|
||||||
|
[draft.protagonist!.pitch, draft.protagonist!.yaw] = applyPitchYawLimits(
|
||||||
|
draft.protagonist!.pitch,
|
||||||
|
draft.protagonist!.yaw,
|
||||||
|
gunModelDefinition.pitch,
|
||||||
|
turretModelDefinition.yaw,
|
||||||
|
hasImprovedVerticalStabilizer,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}, [hasImprovedVerticalStabilizer]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Flex direction="column" gap="8" style={{ width: '100%' }}>
|
<Flex direction="column" gap="8" style={{ width: '100%' }}>
|
||||||
@@ -255,9 +268,13 @@ export function Characteristics() {
|
|||||||
<>
|
<>
|
||||||
<InfoWithDelta decimals={0} indent name="Maximum" unit="hp / min">
|
<InfoWithDelta decimals={0} indent name="Maximum" unit="hp / min">
|
||||||
{gun.reload.at(-1)! < gun.reload.at(-2)!
|
{gun.reload.at(-1)! < gun.reload.at(-2)!
|
||||||
? (shell.damage.armor / (gun.reload.at(-1)! + gun.interClip)) *
|
? ((damageCoefficient * shell.damage.armor) /
|
||||||
|
(gun.reload.at(-1)! * reloadCoefficient +
|
||||||
|
gun.intraClip * intraClipCoefficient)) *
|
||||||
60
|
60
|
||||||
: (shell.damage.armor / gun.reload[0]) * 60}
|
: ((damageCoefficient * shell.damage.armor) /
|
||||||
|
(gun.reload[0] * reloadCoefficient)) *
|
||||||
|
60}
|
||||||
</InfoWithDelta>
|
</InfoWithDelta>
|
||||||
<InfoWithDelta
|
<InfoWithDelta
|
||||||
decimals={0}
|
decimals={0}
|
||||||
@@ -266,13 +283,26 @@ export function Characteristics() {
|
|||||||
unit="hp / min"
|
unit="hp / min"
|
||||||
>
|
>
|
||||||
{gun.reload.at(-1)! < gun.reload.at(-2)!
|
{gun.reload.at(-1)! < gun.reload.at(-2)!
|
||||||
? (shell.damage.armor / (gun.reload.at(-1)! + gun.interClip)) *
|
? ((damageCoefficient * shell.damage.armor) /
|
||||||
|
(gun.reload.at(-1)! * reloadCoefficient +
|
||||||
|
gun.intraClip * intraClipCoefficient)) *
|
||||||
(60 -
|
(60 -
|
||||||
(gun.reload.slice(0, -1).length - 1) * gun.interClip) +
|
(gun.reload.slice(0, -1).length - 1) *
|
||||||
shell.damage.armor * gun.reload.slice(0, -1).length
|
gun.intraClip *
|
||||||
: (shell.damage.armor / (gun.reload[0] + gun.interClip)) *
|
intraClipCoefficient) +
|
||||||
(60 - (gun.reload.slice(1).length - 1) * gun.interClip) +
|
damageCoefficient *
|
||||||
shell.damage.armor * gun.reload.slice(1).length}
|
shell.damage.armor *
|
||||||
|
gun.reload.slice(0, -1).length
|
||||||
|
: ((damageCoefficient * shell.damage.armor) /
|
||||||
|
(gun.reload[0] * reloadCoefficient +
|
||||||
|
gun.intraClip * intraClipCoefficient)) *
|
||||||
|
(60 -
|
||||||
|
(gun.reload.slice(1).length - 1) *
|
||||||
|
gun.intraClip *
|
||||||
|
intraClipCoefficient) +
|
||||||
|
damageCoefficient *
|
||||||
|
shell.damage.armor *
|
||||||
|
gun.reload.slice(1).length}
|
||||||
</InfoWithDelta>
|
</InfoWithDelta>
|
||||||
<Info
|
<Info
|
||||||
indent
|
indent
|
||||||
@@ -285,14 +315,15 @@ export function Characteristics() {
|
|||||||
</a>
|
</a>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
<Info indent name="Optimal shell index">
|
|
||||||
{gun.reload.at(-1)! < gun.reload.at(-2)! ? gun.reload.length : 1}
|
|
||||||
</Info>
|
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
{gun.type === 'autoReloader' ? (
|
{gun.type === 'autoReloader' ? (
|
||||||
<>
|
<>
|
||||||
<Info name="Reload" unit="s" />
|
<InfoWithDelta name="Shells">{gun.reload.length}</InfoWithDelta>
|
||||||
|
<Info indent name="Most optimal">
|
||||||
|
{gun.reload.at(-1)! < gun.reload.at(-2)! ? gun.reload.length : 1}
|
||||||
|
</Info>
|
||||||
|
<Info name="Shell reloads" unit="s" />
|
||||||
{gun.reload.map((reload, index) => (
|
{gun.reload.map((reload, index) => (
|
||||||
<InfoWithDelta
|
<InfoWithDelta
|
||||||
key={index}
|
key={index}
|
||||||
@@ -301,7 +332,7 @@ export function Characteristics() {
|
|||||||
decimals={2}
|
decimals={2}
|
||||||
deltaType="lowerIsBetter"
|
deltaType="lowerIsBetter"
|
||||||
>
|
>
|
||||||
{reload}
|
{reload * reloadCoefficient}
|
||||||
</InfoWithDelta>
|
</InfoWithDelta>
|
||||||
))}
|
))}
|
||||||
</>
|
</>
|
||||||
@@ -315,17 +346,18 @@ export function Characteristics() {
|
|||||||
{gun.reload * reloadCoefficient}
|
{gun.reload * reloadCoefficient}
|
||||||
</InfoWithDelta>
|
</InfoWithDelta>
|
||||||
)}
|
)}
|
||||||
{gun.type === 'autoLoader' && (
|
{gun.type === 'autoLoader' ||
|
||||||
<InfoWithDelta
|
(gun.type === 'autoReloader' && (
|
||||||
indent
|
<InfoWithDelta
|
||||||
decimals={2}
|
indent
|
||||||
name="Inter-clip reload"
|
decimals={2}
|
||||||
unit="s"
|
name="Intra-clip"
|
||||||
deltaType="lowerIsBetter"
|
unit="s"
|
||||||
>
|
deltaType="lowerIsBetter"
|
||||||
{gun.interClip * interClipCoefficient}
|
>
|
||||||
</InfoWithDelta>
|
{gun.intraClip * intraClipCoefficient}
|
||||||
)}
|
</InfoWithDelta>
|
||||||
|
))}
|
||||||
<InfoWithDelta name="Caliber" decimals={0} unit="mm">
|
<InfoWithDelta name="Caliber" decimals={0} unit="mm">
|
||||||
{shell.caliber}
|
{shell.caliber}
|
||||||
</InfoWithDelta>
|
</InfoWithDelta>
|
||||||
@@ -457,10 +489,12 @@ export function Characteristics() {
|
|||||||
<Info name="Gun flexibility" unit="°" />
|
<Info name="Gun flexibility" unit="°" />
|
||||||
<InfoWithDelta decimals={1} indent name="Depression">
|
<InfoWithDelta decimals={1} indent name="Depression">
|
||||||
{gunModelDefinition.pitch.max +
|
{gunModelDefinition.pitch.max +
|
||||||
|
gunDefaultPitch +
|
||||||
(hasImprovedVerticalStabilizer ? 3 : 0)}
|
(hasImprovedVerticalStabilizer ? 3 : 0)}
|
||||||
</InfoWithDelta>
|
</InfoWithDelta>
|
||||||
<InfoWithDelta decimals={1} indent name="Elevation">
|
<InfoWithDelta decimals={1} indent name="Elevation">
|
||||||
{-gunModelDefinition.pitch.min +
|
{-gunModelDefinition.pitch.min -
|
||||||
|
gunDefaultPitch +
|
||||||
(hasImprovedVerticalStabilizer ? 3 : 0)}
|
(hasImprovedVerticalStabilizer ? 3 : 0)}
|
||||||
</InfoWithDelta>
|
</InfoWithDelta>
|
||||||
{gunModelDefinition.pitch.front && (
|
{gunModelDefinition.pitch.front && (
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import { useEffect, useRef } from 'react';
|
|||||||
import { Vector3 } from 'three';
|
import { Vector3 } from 'three';
|
||||||
import { OrbitControls as OrbitControlsClass } from 'three-stdlib';
|
import { OrbitControls as OrbitControlsClass } from 'three-stdlib';
|
||||||
import { applyPitchYawLimits } from '../../../../../core/blitz/applyPitchYawLimits';
|
import { applyPitchYawLimits } from '../../../../../core/blitz/applyPitchYawLimits';
|
||||||
|
import { hasEquipment } from '../../../../../core/blitzkrieg/hasEquipment';
|
||||||
import { modelDefinitions } from '../../../../../core/blitzkrieg/modelDefinitions';
|
import { modelDefinitions } from '../../../../../core/blitzkrieg/modelDefinitions';
|
||||||
import { Pose, poseEvent } from '../../../../../core/blitzkrieg/pose';
|
import { Pose, poseEvent } from '../../../../../core/blitzkrieg/pose';
|
||||||
import { useAwait } from '../../../../../hooks/useAwait';
|
import { useAwait } from '../../../../../hooks/useAwait';
|
||||||
@@ -67,7 +68,9 @@ export function Controls() {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
function handlePoseEvent(event: Pose) {
|
async function handlePoseEvent(event: Pose) {
|
||||||
|
const hasImprovedVerticalStabilizer = await hasEquipment(122);
|
||||||
|
|
||||||
switch (event) {
|
switch (event) {
|
||||||
case Pose.HullDown: {
|
case Pose.HullDown: {
|
||||||
const [pitch] = applyPitchYawLimits(
|
const [pitch] = applyPitchYawLimits(
|
||||||
@@ -75,6 +78,7 @@ export function Controls() {
|
|||||||
0,
|
0,
|
||||||
protagonistGunModelDefinition.pitch,
|
protagonistGunModelDefinition.pitch,
|
||||||
protagonistTurretModelDefinition.yaw,
|
protagonistTurretModelDefinition.yaw,
|
||||||
|
hasImprovedVerticalStabilizer,
|
||||||
);
|
);
|
||||||
|
|
||||||
camera.position
|
camera.position
|
||||||
@@ -106,6 +110,7 @@ export function Controls() {
|
|||||||
0,
|
0,
|
||||||
protagonistGunModelDefinition.pitch,
|
protagonistGunModelDefinition.pitch,
|
||||||
protagonistTurretModelDefinition.yaw,
|
protagonistTurretModelDefinition.yaw,
|
||||||
|
hasImprovedVerticalStabilizer,
|
||||||
);
|
);
|
||||||
|
|
||||||
camera.position
|
camera.position
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import { modelDefinitions } from '../../../../../../core/blitzkrieg/modelDefinit
|
|||||||
import { modelTransformEvent } from '../../../../../../core/blitzkrieg/modelTransform';
|
import { modelTransformEvent } from '../../../../../../core/blitzkrieg/modelTransform';
|
||||||
import { Pose, poseEvent } from '../../../../../../core/blitzkrieg/pose';
|
import { Pose, poseEvent } from '../../../../../../core/blitzkrieg/pose';
|
||||||
import { tankIcon } from '../../../../../../core/blitzkrieg/tankIcon';
|
import { tankIcon } from '../../../../../../core/blitzkrieg/tankIcon';
|
||||||
|
import { useEquipment } from '../../../../../../hooks/useEquipment';
|
||||||
import { useWideFormat } from '../../../../../../hooks/useWideFormat';
|
import { useWideFormat } from '../../../../../../hooks/useWideFormat';
|
||||||
import { mutateDuel, useDuel } from '../../../../../../stores/duel';
|
import { mutateDuel, useDuel } from '../../../../../../stores/duel';
|
||||||
import mutateTankopediaPersistent, {
|
import mutateTankopediaPersistent, {
|
||||||
@@ -29,6 +30,7 @@ import { TankModel } from './components/TankModel';
|
|||||||
|
|
||||||
export function TankSandbox() {
|
export function TankSandbox() {
|
||||||
const canvas = useRef<HTMLCanvasElement>(null);
|
const canvas = useRef<HTMLCanvasElement>(null);
|
||||||
|
const hasImprovedVerticalStabilizer = useEquipment(122);
|
||||||
const awaitedModelDefinitions = use(modelDefinitions);
|
const awaitedModelDefinitions = use(modelDefinitions);
|
||||||
const canvasWrapper = useRef<HTMLDivElement>(null);
|
const canvasWrapper = useRef<HTMLDivElement>(null);
|
||||||
const [isFullScreen, setIsFullScreen] = useState(false);
|
const [isFullScreen, setIsFullScreen] = useState(false);
|
||||||
@@ -70,6 +72,7 @@ export function TankSandbox() {
|
|||||||
0,
|
0,
|
||||||
gunModelDefinition.pitch,
|
gunModelDefinition.pitch,
|
||||||
turretModelDefinition.yaw,
|
turretModelDefinition.yaw,
|
||||||
|
hasImprovedVerticalStabilizer,
|
||||||
);
|
);
|
||||||
|
|
||||||
modelTransformEvent.emit({ pitch, yaw });
|
modelTransformEvent.emit({ pitch, yaw });
|
||||||
@@ -87,6 +90,7 @@ export function TankSandbox() {
|
|||||||
0,
|
0,
|
||||||
gunModelDefinition.pitch,
|
gunModelDefinition.pitch,
|
||||||
turretModelDefinition.yaw,
|
turretModelDefinition.yaw,
|
||||||
|
hasImprovedVerticalStabilizer,
|
||||||
);
|
);
|
||||||
|
|
||||||
modelTransformEvent.emit({ pitch, yaw });
|
modelTransformEvent.emit({ pitch, yaw });
|
||||||
@@ -104,6 +108,7 @@ export function TankSandbox() {
|
|||||||
0,
|
0,
|
||||||
gunModelDefinition.pitch,
|
gunModelDefinition.pitch,
|
||||||
turretModelDefinition.yaw,
|
turretModelDefinition.yaw,
|
||||||
|
hasImprovedVerticalStabilizer,
|
||||||
);
|
);
|
||||||
|
|
||||||
modelTransformEvent.emit({ pitch, yaw });
|
modelTransformEvent.emit({ pitch, yaw });
|
||||||
@@ -131,6 +136,7 @@ export function TankSandbox() {
|
|||||||
draft.protagonist!.yaw,
|
draft.protagonist!.yaw,
|
||||||
gunModelDefinition.pitch,
|
gunModelDefinition.pitch,
|
||||||
turretModelDefinition.yaw,
|
turretModelDefinition.yaw,
|
||||||
|
hasImprovedVerticalStabilizer,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
}, [protagonist.gun, protagonist.turret]);
|
}, [protagonist.gun, protagonist.turret]);
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import { Button, DropdownMenu, Flex } from '@radix-ui/themes';
|
|||||||
import { RefObject } from 'react';
|
import { RefObject } from 'react';
|
||||||
import { Pose, poseEvent } from '../../../../../../../core/blitzkrieg/pose';
|
import { Pose, poseEvent } from '../../../../../../../core/blitzkrieg/pose';
|
||||||
import mutateTankopediaPersistent, {
|
import mutateTankopediaPersistent, {
|
||||||
|
mutateTankopediaTemporary,
|
||||||
useTankopediaPersistent,
|
useTankopediaPersistent,
|
||||||
} from '../../../../../../../stores/tankopedia';
|
} from '../../../../../../../stores/tankopedia';
|
||||||
import { ENVIRONMENTS } from '../../Lighting';
|
import { ENVIRONMENTS } from '../../Lighting';
|
||||||
@@ -30,6 +31,9 @@ export function Options({ isFullScreen, canvasWrapper }: OptionsProps) {
|
|||||||
const wireframe = useTankopediaPersistent(
|
const wireframe = useTankopediaPersistent(
|
||||||
(state) => state.model.visual.wireframe,
|
(state) => state.model.visual.wireframe,
|
||||||
);
|
);
|
||||||
|
const showSpacedArmor = useTankopediaPersistent(
|
||||||
|
(state) => state.model.visual.showSpacedArmor,
|
||||||
|
);
|
||||||
const opaque = useTankopediaPersistent((state) => state.model.visual.opaque);
|
const opaque = useTankopediaPersistent((state) => state.model.visual.opaque);
|
||||||
const fullScreenAvailable =
|
const fullScreenAvailable =
|
||||||
typeof document !== 'undefined' && document.fullscreenEnabled;
|
typeof document !== 'undefined' && document.fullscreenEnabled;
|
||||||
@@ -81,6 +85,20 @@ export function Options({ isFullScreen, canvasWrapper }: OptionsProps) {
|
|||||||
<DropdownMenu.Content>
|
<DropdownMenu.Content>
|
||||||
<DropdownMenu.Label>Armor</DropdownMenu.Label>
|
<DropdownMenu.Label>Armor</DropdownMenu.Label>
|
||||||
|
|
||||||
|
<DropdownMenu.CheckboxItem
|
||||||
|
checked={showSpacedArmor}
|
||||||
|
onCheckedChange={(checked) => {
|
||||||
|
mutateTankopediaPersistent((draft) => {
|
||||||
|
draft.model.visual.showSpacedArmor = checked;
|
||||||
|
});
|
||||||
|
mutateTankopediaTemporary((draft) => {
|
||||||
|
draft.shot = undefined;
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Spaced armor
|
||||||
|
</DropdownMenu.CheckboxItem>
|
||||||
|
|
||||||
<DropdownMenu.CheckboxItem
|
<DropdownMenu.CheckboxItem
|
||||||
checked={greenPenetration}
|
checked={greenPenetration}
|
||||||
onCheckedChange={(checked) => {
|
onCheckedChange={(checked) => {
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import { Euler, Group, Vector3 } from 'three';
|
|||||||
import { degToRad } from 'three/src/math/MathUtils';
|
import { degToRad } from 'three/src/math/MathUtils';
|
||||||
import { I_HAT, J_HAT, K_HAT } from '../../../../../../../constants/axis';
|
import { I_HAT, J_HAT, K_HAT } from '../../../../../../../constants/axis';
|
||||||
import { applyPitchYawLimits } from '../../../../../../../core/blitz/applyPitchYawLimits';
|
import { applyPitchYawLimits } from '../../../../../../../core/blitz/applyPitchYawLimits';
|
||||||
|
import { hasEquipment } from '../../../../../../../core/blitzkrieg/hasEquipment';
|
||||||
import { jsxTree } from '../../../../../../../core/blitzkrieg/jsxTree';
|
import { jsxTree } from '../../../../../../../core/blitzkrieg/jsxTree';
|
||||||
import { modelDefinitions } from '../../../../../../../core/blitzkrieg/modelDefinitions';
|
import { modelDefinitions } from '../../../../../../../core/blitzkrieg/modelDefinitions';
|
||||||
import {
|
import {
|
||||||
@@ -106,7 +107,6 @@ export const TankModel = memo(() => {
|
|||||||
const turretModelDefinition =
|
const turretModelDefinition =
|
||||||
tankModelDefinition.turrets[protagonist.turret.id];
|
tankModelDefinition.turrets[protagonist.turret.id];
|
||||||
const gunModelDefinition = turretModelDefinition.guns[protagonist.gun.id];
|
const gunModelDefinition = turretModelDefinition.guns[protagonist.gun.id];
|
||||||
|
|
||||||
const { gltf } = useModel(protagonist.tank.id);
|
const { gltf } = useModel(protagonist.tank.id);
|
||||||
const nodes = Object.values(gltf.nodes);
|
const nodes = Object.values(gltf.nodes);
|
||||||
|
|
||||||
@@ -161,12 +161,14 @@ export const TankModel = memo(() => {
|
|||||||
window.addEventListener('pointerup', handlePointerUp);
|
window.addEventListener('pointerup', handlePointerUp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function handlePointerMove(event: PointerEvent) {
|
async function handlePointerMove(event: PointerEvent) {
|
||||||
|
const hasImprovedVerticalStabilizer = await hasEquipment(122);
|
||||||
[pitch, yaw] = applyPitchYawLimits(
|
[pitch, yaw] = applyPitchYawLimits(
|
||||||
pitch,
|
pitch,
|
||||||
yaw + event.movementX * (Math.PI / canvas.width),
|
yaw + event.movementX * (Math.PI / canvas.width),
|
||||||
gunModelDefinition.pitch,
|
gunModelDefinition.pitch,
|
||||||
turretModelDefinition.yaw,
|
turretModelDefinition.yaw,
|
||||||
|
hasImprovedVerticalStabilizer,
|
||||||
);
|
);
|
||||||
modelTransformEvent.emit({ pitch, yaw });
|
modelTransformEvent.emit({ pitch, yaw });
|
||||||
}
|
}
|
||||||
@@ -220,12 +222,14 @@ export const TankModel = memo(() => {
|
|||||||
window.addEventListener('pointermove', handlePointerMove);
|
window.addEventListener('pointermove', handlePointerMove);
|
||||||
window.addEventListener('pointerup', handlePointerUp);
|
window.addEventListener('pointerup', handlePointerUp);
|
||||||
}
|
}
|
||||||
function handlePointerMove(event: PointerEvent) {
|
async function handlePointerMove(event: PointerEvent) {
|
||||||
|
const hasImprovedVerticalStabilizer = await hasEquipment(122);
|
||||||
[pitch, yaw] = applyPitchYawLimits(
|
[pitch, yaw] = applyPitchYawLimits(
|
||||||
pitch - event.movementY * (Math.PI / canvas.height),
|
pitch - event.movementY * (Math.PI / canvas.height),
|
||||||
yaw + event.movementX * (Math.PI / canvas.width),
|
yaw + event.movementX * (Math.PI / canvas.width),
|
||||||
gunModelDefinition.pitch,
|
gunModelDefinition.pitch,
|
||||||
turretModelDefinition.yaw,
|
turretModelDefinition.yaw,
|
||||||
|
hasImprovedVerticalStabilizer,
|
||||||
);
|
);
|
||||||
modelTransformEvent.emit({ pitch, yaw });
|
modelTransformEvent.emit({ pitch, yaw });
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { Flex, TextField } from '@radix-ui/themes';
|
import { Flex, TextField } from '@radix-ui/themes';
|
||||||
import { use, useEffect, useRef } from 'react';
|
import { use, useEffect, useRef } from 'react';
|
||||||
|
import { degToRad, radToDeg } from 'three/src/math/MathUtils';
|
||||||
import { applyPitchYawLimits } from '../../../../../../core/blitz/applyPitchYawLimits';
|
import { applyPitchYawLimits } from '../../../../../../core/blitz/applyPitchYawLimits';
|
||||||
import { modelDefinitions } from '../../../../../../core/blitzkrieg/modelDefinitions';
|
import { modelDefinitions } from '../../../../../../core/blitzkrieg/modelDefinitions';
|
||||||
import { modelTransformEvent } from '../../../../../../core/blitzkrieg/modelTransform';
|
import { modelTransformEvent } from '../../../../../../core/blitzkrieg/modelTransform';
|
||||||
@@ -20,22 +21,21 @@ export function RotationInputs({ isFullScreen }: RotationInputsProps) {
|
|||||||
const mode = useTankopediaPersistent((state) => state.mode);
|
const mode = useTankopediaPersistent((state) => state.mode);
|
||||||
const hasCalibratedShells = useEquipment(103, true);
|
const hasCalibratedShells = useEquipment(103, true);
|
||||||
const hasEnhancedArmor = useEquipment(110);
|
const hasEnhancedArmor = useEquipment(110);
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
turretYawInput.current!.value = `${-Math.round(
|
|
||||||
protagonist.yaw * (180 / Math.PI),
|
|
||||||
)}`;
|
|
||||||
}, [protagonist.yaw]);
|
|
||||||
useEffect(() => {
|
|
||||||
gunPitchInput.current!.value = `${-Math.round(
|
|
||||||
protagonist.pitch * (180 / Math.PI),
|
|
||||||
)}`;
|
|
||||||
}, [protagonist.pitch]);
|
|
||||||
|
|
||||||
const tankModelDefinition = awaitedModelDefinitions[protagonist.tank.id];
|
const tankModelDefinition = awaitedModelDefinitions[protagonist.tank.id];
|
||||||
const turretModelDefinition =
|
const turretModelDefinition =
|
||||||
tankModelDefinition.turrets[protagonist.turret.id];
|
tankModelDefinition.turrets[protagonist.turret.id];
|
||||||
const gunModelDefinition = turretModelDefinition.guns[protagonist.gun.id];
|
const gunModelDefinition = turretModelDefinition.guns[protagonist.gun.id];
|
||||||
|
const initialGunPitch = tankModelDefinition.turretRotation?.pitch ?? 0;
|
||||||
|
const hasImprovedVerticalStabilizer = useEquipment(122);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
turretYawInput.current!.value = radToDeg(protagonist.yaw).toFixed(1);
|
||||||
|
}, [protagonist.yaw]);
|
||||||
|
useEffect(() => {
|
||||||
|
gunPitchInput.current!.value = (
|
||||||
|
-radToDeg(protagonist.pitch) + initialGunPitch
|
||||||
|
).toFixed(1);
|
||||||
|
}, [protagonist.pitch]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Flex
|
<Flex
|
||||||
@@ -68,22 +68,22 @@ export function RotationInputs({ isFullScreen }: RotationInputsProps) {
|
|||||||
Yaw
|
Yaw
|
||||||
</TextField.Slot>
|
</TextField.Slot>
|
||||||
<TextField.Input
|
<TextField.Input
|
||||||
defaultValue={Math.round(protagonist.yaw * (180 / Math.PI))}
|
|
||||||
onBlur={() => {
|
onBlur={() => {
|
||||||
const [pitch, yaw] = applyPitchYawLimits(
|
const [pitch, yaw] = applyPitchYawLimits(
|
||||||
protagonist.pitch,
|
protagonist.pitch,
|
||||||
-Number(turretYawInput.current?.value) * (Math.PI / 180),
|
degToRad(Number(turretYawInput.current!.value)),
|
||||||
gunModelDefinition.pitch,
|
gunModelDefinition.pitch,
|
||||||
turretModelDefinition.yaw,
|
turretModelDefinition.yaw,
|
||||||
|
hasImprovedVerticalStabilizer,
|
||||||
);
|
);
|
||||||
modelTransformEvent.emit({ pitch, yaw });
|
modelTransformEvent.emit({ pitch, yaw });
|
||||||
mutateDuel((state) => {
|
mutateDuel((state) => {
|
||||||
state.protagonist!.pitch = pitch;
|
state.protagonist!.pitch = pitch;
|
||||||
state.protagonist!.yaw = yaw;
|
state.protagonist!.yaw = yaw;
|
||||||
});
|
});
|
||||||
turretYawInput.current!.value = `${Math.round(
|
turretYawInput.current!.value = radToDeg(protagonist.yaw).toFixed(
|
||||||
yaw * (180 / Math.PI),
|
1,
|
||||||
)}`;
|
);
|
||||||
}}
|
}}
|
||||||
onKeyDown={(event) => {
|
onKeyDown={(event) => {
|
||||||
if (event.key === 'Enter') {
|
if (event.key === 'Enter') {
|
||||||
@@ -116,22 +116,24 @@ export function RotationInputs({ isFullScreen }: RotationInputsProps) {
|
|||||||
Pitch
|
Pitch
|
||||||
</TextField.Slot>
|
</TextField.Slot>
|
||||||
<TextField.Input
|
<TextField.Input
|
||||||
defaultValue={-Math.round(protagonist.pitch * (180 / Math.PI))}
|
|
||||||
onBlur={() => {
|
onBlur={() => {
|
||||||
const [pitch, yaw] = applyPitchYawLimits(
|
const [pitch, yaw] = applyPitchYawLimits(
|
||||||
-Number(gunPitchInput.current?.value) * (Math.PI / 180),
|
degToRad(
|
||||||
|
-Number(gunPitchInput.current!.value) + initialGunPitch,
|
||||||
|
),
|
||||||
protagonist.yaw,
|
protagonist.yaw,
|
||||||
gunModelDefinition.pitch,
|
gunModelDefinition.pitch,
|
||||||
turretModelDefinition.yaw,
|
turretModelDefinition.yaw,
|
||||||
|
hasImprovedVerticalStabilizer,
|
||||||
);
|
);
|
||||||
modelTransformEvent.emit({ pitch, yaw });
|
modelTransformEvent.emit({ pitch, yaw });
|
||||||
mutateDuel((state) => {
|
mutateDuel((state) => {
|
||||||
state.protagonist!.pitch = pitch;
|
state.protagonist!.pitch = pitch;
|
||||||
state.protagonist!.yaw = yaw;
|
state.protagonist!.yaw = yaw;
|
||||||
});
|
});
|
||||||
gunPitchInput.current!.value = `${Math.round(
|
gunPitchInput.current!.value = (
|
||||||
pitch * (180 / Math.PI),
|
-radToDeg(protagonist.pitch) + initialGunPitch
|
||||||
)}`;
|
).toFixed(1);
|
||||||
}}
|
}}
|
||||||
onKeyDown={(event) => {
|
onKeyDown={(event) => {
|
||||||
if (event.key === 'Enter') {
|
if (event.key === 'Enter') {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { UpdateIcon } from '@radix-ui/react-icons';
|
import { UpdateIcon } from '@radix-ui/react-icons';
|
||||||
import { Button, Dialog, Flex, Heading } from '@radix-ui/themes';
|
import { Button, Dialog, Flex, Heading } from '@radix-ui/themes';
|
||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import { TREE_TYPE_ICONS } from '../../../../../components/Tanks';
|
import { TREE_TYPE_ICONS } from '../../../../../components/Tanks/components/Item/constants';
|
||||||
import { assignDuelMember } from '../../../../../core/blitzkrieg/assignDuelMember';
|
import { assignDuelMember } from '../../../../../core/blitzkrieg/assignDuelMember';
|
||||||
import { pushTankopediaPath } from '../../../../../core/blitzkrieg/pushTankopediaPath';
|
import { pushTankopediaPath } from '../../../../../core/blitzkrieg/pushTankopediaPath';
|
||||||
import { useDuel } from '../../../../../stores/duel';
|
import { useDuel } from '../../../../../stores/duel';
|
||||||
|
|||||||
+2
-4
@@ -1,9 +1,7 @@
|
|||||||
import { Button, Flex, Text } from '@radix-ui/themes';
|
import { Button, Flex, Text } from '@radix-ui/themes';
|
||||||
import { SmallTankIcon } from '../../../../../../components/SmallTankIcon';
|
import { SmallTankIcon } from '../../../../../../components/SmallTankIcon';
|
||||||
import {
|
import { TankDefinition } from '../../../../../../core/blitzkrieg/tankDefinitions';
|
||||||
TIER_ROMAN_NUMERALS,
|
import { TIER_ROMAN_NUMERALS } from '../../../../../../core/blitzkrieg/tankDefinitions/constants';
|
||||||
TankDefinition,
|
|
||||||
} from '../../../../../../core/blitzkrieg/tankDefinitions';
|
|
||||||
|
|
||||||
interface CompactSearchResultRowProps {
|
interface CompactSearchResultRowProps {
|
||||||
tanks: TankDefinition[];
|
tanks: TankDefinition[];
|
||||||
|
|||||||
@@ -4,17 +4,18 @@ import { CaretDownIcon } from '@radix-ui/react-icons';
|
|||||||
import { Button, DropdownMenu, Flex } from '@radix-ui/themes';
|
import { Button, DropdownMenu, Flex } from '@radix-ui/themes';
|
||||||
import { use } from 'react';
|
import { use } from 'react';
|
||||||
import { Flag } from '../../../../../../../components/Flag';
|
import { Flag } from '../../../../../../../components/Flag';
|
||||||
|
import {} from '../../../../../../../components/Tanks';
|
||||||
import {
|
import {
|
||||||
TANK_CLASSES,
|
TANK_CLASSES,
|
||||||
TREE_TYPES,
|
TREE_TYPES,
|
||||||
TREE_TYPE_ICONS,
|
TREE_TYPE_ICONS,
|
||||||
TREE_TYPE_IMAGES,
|
TREE_TYPE_IMAGES,
|
||||||
} from '../../../../../../../components/Tanks';
|
} from '../../../../../../../components/Tanks/components/Item/constants';
|
||||||
|
import { NATIONS } from '../../../../../../../core/blitzkrieg/tankDefinitions';
|
||||||
import {
|
import {
|
||||||
NATIONS,
|
|
||||||
TIERS,
|
TIERS,
|
||||||
TIER_ROMAN_NUMERALS,
|
TIER_ROMAN_NUMERALS,
|
||||||
} from '../../../../../../../core/blitzkrieg/tankDefinitions';
|
} from '../../../../../../../core/blitzkrieg/tankDefinitions/constants';
|
||||||
import mutateTankopediaPersistent, {
|
import mutateTankopediaPersistent, {
|
||||||
TankopediaTestTankDisplay,
|
TankopediaTestTankDisplay,
|
||||||
useTankopediaPersistent,
|
useTankopediaPersistent,
|
||||||
|
|||||||
@@ -15,7 +15,8 @@ import {
|
|||||||
} from '@radix-ui/themes';
|
} from '@radix-ui/themes';
|
||||||
import { go } from 'fuzzysort';
|
import { go } from 'fuzzysort';
|
||||||
import { use, useEffect, useMemo, useRef, useState } from 'react';
|
import { use, useEffect, useMemo, useRef, useState } from 'react';
|
||||||
import { TANK_CLASSES, TreeType } from '../../../../../components/Tanks';
|
import { TreeType } from '../../../../../components/Tanks';
|
||||||
|
import { TANK_CLASSES } from '../../../../../components/Tanks/components/Item/constants';
|
||||||
import { resolveNearPenetration } from '../../../../../core/blitz/resolveNearPenetration';
|
import { resolveNearPenetration } from '../../../../../core/blitz/resolveNearPenetration';
|
||||||
import { asset } from '../../../../../core/blitzkrieg/asset';
|
import { asset } from '../../../../../core/blitzkrieg/asset';
|
||||||
import { modelDefinitions } from '../../../../../core/blitzkrieg/modelDefinitions';
|
import { modelDefinitions } from '../../../../../core/blitzkrieg/modelDefinitions';
|
||||||
@@ -24,13 +25,15 @@ import { resolveDpm } from '../../../../../core/blitzkrieg/resolveDpm';
|
|||||||
import { resolveReload } from '../../../../../core/blitzkrieg/resolveReload';
|
import { resolveReload } from '../../../../../core/blitzkrieg/resolveReload';
|
||||||
import {
|
import {
|
||||||
NATIONS,
|
NATIONS,
|
||||||
|
TankDefinition,
|
||||||
|
tanksDefinitionsArray,
|
||||||
|
} from '../../../../../core/blitzkrieg/tankDefinitions';
|
||||||
|
import {
|
||||||
TANK_ICONS,
|
TANK_ICONS,
|
||||||
TANK_ICONS_COLLECTOR,
|
TANK_ICONS_COLLECTOR,
|
||||||
TANK_ICONS_PREMIUM,
|
TANK_ICONS_PREMIUM,
|
||||||
TIER_ROMAN_NUMERALS,
|
TIER_ROMAN_NUMERALS,
|
||||||
TankDefinition,
|
} from '../../../../../core/blitzkrieg/tankDefinitions/constants';
|
||||||
tanksDefinitionsArray,
|
|
||||||
} from '../../../../../core/blitzkrieg/tankDefinitions';
|
|
||||||
import { tankIcon } from '../../../../../core/blitzkrieg/tankIcon';
|
import { tankIcon } from '../../../../../core/blitzkrieg/tankIcon';
|
||||||
import { unionBoundingBox } from '../../../../../core/blitzkrieg/unionBoundingBox';
|
import { unionBoundingBox } from '../../../../../core/blitzkrieg/unionBoundingBox';
|
||||||
import { theme } from '../../../../../stitches.config';
|
import { theme } from '../../../../../stitches.config';
|
||||||
|
|||||||
@@ -0,0 +1,71 @@
|
|||||||
|
import { getBlitzStarsLinkButton } from '../../core/blitzstars/getBlitzStarsLinkButton';
|
||||||
|
import addPeriodicFilterOptions from '../../core/discord/addPeriodicFilterOptions';
|
||||||
|
import addUsernameChoices from '../../core/discord/addUsernameChoices';
|
||||||
|
import autocompleteTanks from '../../core/discord/autocompleteTanks';
|
||||||
|
import autocompleteUsername from '../../core/discord/autocompleteUsername';
|
||||||
|
import { buttonRefresh } from '../../core/discord/buttonRefresh';
|
||||||
|
import commandToURL from '../../core/discord/commandToURL';
|
||||||
|
import { createLocalizedCommand } from '../../core/discord/createLocalizedCommand';
|
||||||
|
import { getCustomPeriodParams } from '../../core/discord/getCustomPeriodParams';
|
||||||
|
import { getFiltersFromButton } from '../../core/discord/getFiltersFromButton';
|
||||||
|
import { getFiltersFromCommand } from '../../core/discord/getFiltersFromCommand';
|
||||||
|
import resolvePeriodFromButton from '../../core/discord/resolvePeriodFromButton';
|
||||||
|
import resolvePeriodFromCommand from '../../core/discord/resolvePeriodFromCommand';
|
||||||
|
import resolvePlayerFromButton from '../../core/discord/resolvePlayerFromButton';
|
||||||
|
import resolvePlayerFromCommand from '../../core/discord/resolvePlayerFromCommand';
|
||||||
|
import { CommandRegistry } from '../../events/interactionCreate';
|
||||||
|
import { renderBreakdown } from './render';
|
||||||
|
|
||||||
|
export const breakdownCommand = new Promise<CommandRegistry>(
|
||||||
|
async (resolve) => {
|
||||||
|
resolve({
|
||||||
|
inProduction: true,
|
||||||
|
inPublic: true,
|
||||||
|
|
||||||
|
command: await addPeriodicFilterOptions(
|
||||||
|
createLocalizedCommand('breakdown'),
|
||||||
|
(option) => option.addStringOption(addUsernameChoices),
|
||||||
|
),
|
||||||
|
|
||||||
|
async handler(interaction) {
|
||||||
|
const player = await resolvePlayerFromCommand(interaction);
|
||||||
|
const period = resolvePeriodFromCommand(player.region, interaction);
|
||||||
|
const filters = await getFiltersFromCommand(interaction);
|
||||||
|
const path = commandToURL(interaction, {
|
||||||
|
...player,
|
||||||
|
...getCustomPeriodParams(interaction),
|
||||||
|
...filters,
|
||||||
|
});
|
||||||
|
|
||||||
|
return [
|
||||||
|
...(await renderBreakdown(
|
||||||
|
player,
|
||||||
|
period,
|
||||||
|
filters,
|
||||||
|
interaction.locale,
|
||||||
|
)),
|
||||||
|
buttonRefresh(interaction, path),
|
||||||
|
await getBlitzStarsLinkButton(player.region, player.id),
|
||||||
|
];
|
||||||
|
},
|
||||||
|
|
||||||
|
autocomplete: (interaction) => {
|
||||||
|
autocompleteUsername(interaction);
|
||||||
|
autocompleteTanks(interaction);
|
||||||
|
},
|
||||||
|
|
||||||
|
async button(interaction) {
|
||||||
|
const player = await resolvePlayerFromButton(interaction);
|
||||||
|
const period = resolvePeriodFromButton(player.region, interaction);
|
||||||
|
const filters = getFiltersFromButton(interaction);
|
||||||
|
|
||||||
|
return await renderBreakdown(
|
||||||
|
player,
|
||||||
|
period,
|
||||||
|
filters,
|
||||||
|
interaction.locale,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
},
|
||||||
|
);
|
||||||
@@ -1,43 +1,25 @@
|
|||||||
import { Locale } from 'discord.js';
|
import { Locale } from 'discord.js';
|
||||||
import { chunk } from 'lodash';
|
import { chunk } from 'lodash';
|
||||||
import * as Breakdown from '../components/Breakdown';
|
import * as Breakdown from '../../components/Breakdown';
|
||||||
import CommandWrapper from '../components/CommandWrapper';
|
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 { AllStats, getAccountInfo } from '../core/blitz/getAccountInfo';
|
import { AllStats, getAccountInfo } from '../../core/blitz/getAccountInfo';
|
||||||
import { getClanAccountInfo } from '../core/blitz/getClanAccountInfo';
|
import { getClanAccountInfo } from '../../core/blitz/getClanAccountInfo';
|
||||||
import getTankStats from '../core/blitz/getTankStats';
|
import getTankStats from '../../core/blitz/getTankStats';
|
||||||
import { filtersToDescription } from '../core/blitzkrieg/filtersToDescription';
|
import { filtersToDescription } from '../../core/blitzkrieg/filtersToDescription';
|
||||||
import {
|
import {
|
||||||
TankDefinition,
|
TankDefinition,
|
||||||
tankDefinitions,
|
tankDefinitions,
|
||||||
} from '../core/blitzkrieg/tankDefinitions';
|
} from '../../core/blitzkrieg/tankDefinitions';
|
||||||
import { getBlitzStarsLinkButton } from '../core/blitzstars/getBlitzStarsLinkButton';
|
import getStatsInPeriod from '../../core/blitzstars/getStatsInPeriod';
|
||||||
import getStatsInPeriod from '../core/blitzstars/getStatsInPeriod';
|
import { tankAverages } from '../../core/blitzstars/tankAverages';
|
||||||
import { tankAverages } from '../core/blitzstars/tankAverages';
|
import { ResolvedPeriod } from '../../core/discord/resolvePeriodFromCommand';
|
||||||
import addPeriodicFilterOptions from '../core/discord/addPeriodicFilterOptions';
|
import { ResolvedPlayer } from '../../core/discord/resolvePlayerFromCommand';
|
||||||
import addUsernameChoices from '../core/discord/addUsernameChoices';
|
import { translator } from '../../core/localization/translator';
|
||||||
import autocompleteTanks from '../core/discord/autocompleteTanks';
|
import calculateWN8 from '../../core/statistics/calculateWN8';
|
||||||
import autocompleteUsername from '../core/discord/autocompleteUsername';
|
import { StatFilters, filterStats } from '../../core/statistics/filterStats';
|
||||||
import { buttonRefresh } from '../core/discord/buttonRefresh';
|
import getWN8Percentile from '../../core/statistics/getWN8Percentile';
|
||||||
import commandToURL from '../core/discord/commandToURL';
|
|
||||||
import { createLocalizedCommand } from '../core/discord/createLocalizedCommand';
|
|
||||||
import { getCustomPeriodParams } from '../core/discord/getCustomPeriodParams';
|
|
||||||
import { getFiltersFromButton } from '../core/discord/getFiltersFromButton';
|
|
||||||
import { getFiltersFromCommand } from '../core/discord/getFiltersFromCommand';
|
|
||||||
import resolvePeriodFromButton from '../core/discord/resolvePeriodFromButton';
|
|
||||||
import resolvePeriodFromCommand, {
|
|
||||||
ResolvedPeriod,
|
|
||||||
} from '../core/discord/resolvePeriodFromCommand';
|
|
||||||
import resolvePlayerFromButton from '../core/discord/resolvePlayerFromButton';
|
|
||||||
import resolvePlayerFromCommand, {
|
|
||||||
ResolvedPlayer,
|
|
||||||
} from '../core/discord/resolvePlayerFromCommand';
|
|
||||||
import { translator } from '../core/localization/translator';
|
|
||||||
import calculateWN8 from '../core/statistics/calculateWN8';
|
|
||||||
import { StatFilters, filterStats } from '../core/statistics/filterStats';
|
|
||||||
import getWN8Percentile from '../core/statistics/getWN8Percentile';
|
|
||||||
import { CommandRegistry } from '../events/interactionCreate';
|
|
||||||
|
|
||||||
const ROWS_PER_PAGE = 8;
|
const ROWS_PER_PAGE = 8;
|
||||||
const MAX_PAGES = 9;
|
const MAX_PAGES = 9;
|
||||||
@@ -296,57 +278,3 @@ export async function renderBreakdown(
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const breakdownCommand = new Promise<CommandRegistry>(
|
|
||||||
async (resolve) => {
|
|
||||||
resolve({
|
|
||||||
inProduction: true,
|
|
||||||
inPublic: true,
|
|
||||||
|
|
||||||
command: await addPeriodicFilterOptions(
|
|
||||||
createLocalizedCommand('breakdown'),
|
|
||||||
(option) => option.addStringOption(addUsernameChoices),
|
|
||||||
),
|
|
||||||
|
|
||||||
async handler(interaction) {
|
|
||||||
const player = await resolvePlayerFromCommand(interaction);
|
|
||||||
const period = resolvePeriodFromCommand(player.region, interaction);
|
|
||||||
const filters = await getFiltersFromCommand(interaction);
|
|
||||||
const path = commandToURL(interaction, {
|
|
||||||
...player,
|
|
||||||
...getCustomPeriodParams(interaction),
|
|
||||||
...filters,
|
|
||||||
});
|
|
||||||
|
|
||||||
return [
|
|
||||||
...(await renderBreakdown(
|
|
||||||
player,
|
|
||||||
period,
|
|
||||||
filters,
|
|
||||||
interaction.locale,
|
|
||||||
)),
|
|
||||||
buttonRefresh(interaction, path),
|
|
||||||
await getBlitzStarsLinkButton(player.region, player.id),
|
|
||||||
];
|
|
||||||
},
|
|
||||||
|
|
||||||
autocomplete: (interaction) => {
|
|
||||||
autocompleteUsername(interaction);
|
|
||||||
autocompleteTanks(interaction);
|
|
||||||
},
|
|
||||||
|
|
||||||
async button(interaction) {
|
|
||||||
const player = await resolvePlayerFromButton(interaction);
|
|
||||||
const period = resolvePeriodFromButton(player.region, interaction);
|
|
||||||
const filters = getFiltersFromButton(interaction);
|
|
||||||
|
|
||||||
return await renderBreakdown(
|
|
||||||
player,
|
|
||||||
period,
|
|
||||||
filters,
|
|
||||||
interaction.locale,
|
|
||||||
);
|
|
||||||
},
|
|
||||||
});
|
|
||||||
},
|
|
||||||
);
|
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
import { Locale, SlashCommandSubcommandGroupBuilder } from 'discord.js';
|
import { Locale, SlashCommandSubcommandGroupBuilder } from 'discord.js';
|
||||||
import CommandWrapper from '../components/CommandWrapper';
|
import CommandWrapper from '../components/CommandWrapper';
|
||||||
import * as Graph from '../components/Graph';
|
import * as Graph from '../components/Graph';
|
||||||
|
import { LineColor } from '../components/Graph/components/Line/constants';
|
||||||
import NoData from '../components/NoData';
|
import NoData from '../components/NoData';
|
||||||
import TitleBar from '../components/TitleBar';
|
import TitleBar from '../components/TitleBar';
|
||||||
import { getAccountInfo } from '../core/blitz/getAccountInfo';
|
import { getAccountInfo } from '../core/blitz/getAccountInfo';
|
||||||
@@ -93,7 +94,7 @@ async function render(
|
|||||||
xMaxLabel={new Date(maxTime * 1000).toLocaleDateString(locale)}
|
xMaxLabel={new Date(maxTime * 1000).toLocaleDateString(locale)}
|
||||||
>
|
>
|
||||||
{Graph.Line({
|
{Graph.Line({
|
||||||
color: Graph.LineColor.Red,
|
color: LineColor.Red,
|
||||||
plot: plot,
|
plot: plot,
|
||||||
minY,
|
minY,
|
||||||
maxY,
|
maxY,
|
||||||
|
|||||||
+31
-78
@@ -1,18 +1,16 @@
|
|||||||
import CommandWrapper from '../components/CommandWrapper';
|
import { chunk } from 'lodash';
|
||||||
import NoData from '../components/NoData';
|
import markdownEscape from 'markdown-escape';
|
||||||
import * as Tanks from '../components/Tanks';
|
import { TANK_CLASSES } from '../components/Tanks/components/Item/constants';
|
||||||
import TitleBar from '../components/TitleBar';
|
|
||||||
import { getAccountInfo } from '../core/blitz/getAccountInfo';
|
import { getAccountInfo } from '../core/blitz/getAccountInfo';
|
||||||
import { getClanAccountInfo } from '../core/blitz/getClanAccountInfo';
|
|
||||||
import getTankStats from '../core/blitz/getTankStats';
|
import getTankStats from '../core/blitz/getTankStats';
|
||||||
import { emblemIdToURL } from '../core/blitzkrieg/emblemIdToURL';
|
|
||||||
import {
|
import {
|
||||||
TIER_ROMAN_NUMERALS,
|
NATIONS,
|
||||||
TankDefinition,
|
TankDefinition,
|
||||||
Tier,
|
Tier,
|
||||||
|
flags,
|
||||||
tankDefinitions,
|
tankDefinitions,
|
||||||
} from '../core/blitzkrieg/tankDefinitions';
|
} from '../core/blitzkrieg/tankDefinitions';
|
||||||
import { tankIcon } from '../core/blitzkrieg/tankIcon';
|
import { TIER_ROMAN_NUMERALS } from '../core/blitzkrieg/tankDefinitions/constants';
|
||||||
import addTierChoices from '../core/discord/addTierChoices';
|
import addTierChoices from '../core/discord/addTierChoices';
|
||||||
import addUsernameChoices from '../core/discord/addUsernameChoices';
|
import addUsernameChoices from '../core/discord/addUsernameChoices';
|
||||||
import autocompleteUsername from '../core/discord/autocompleteUsername';
|
import autocompleteUsername from '../core/discord/autocompleteUsername';
|
||||||
@@ -21,6 +19,8 @@ import resolvePlayerFromCommand from '../core/discord/resolvePlayerFromCommand';
|
|||||||
import { translator } from '../core/localization/translator';
|
import { translator } from '../core/localization/translator';
|
||||||
import { CommandRegistry } from '../events/interactionCreate';
|
import { CommandRegistry } from '../events/interactionCreate';
|
||||||
|
|
||||||
|
const TANKS_PER_MESSAGE = 64;
|
||||||
|
|
||||||
export const ownedTanksCommand = new Promise<CommandRegistry>((resolve) => {
|
export const ownedTanksCommand = new Promise<CommandRegistry>((resolve) => {
|
||||||
resolve({
|
resolve({
|
||||||
inProduction: true,
|
inProduction: true,
|
||||||
@@ -33,10 +33,9 @@ export const ownedTanksCommand = new Promise<CommandRegistry>((resolve) => {
|
|||||||
async handler(interaction) {
|
async handler(interaction) {
|
||||||
const { translate } = translator(interaction.locale);
|
const { translate } = translator(interaction.locale);
|
||||||
const tier = Number(interaction.options.getString('tier'));
|
const tier = Number(interaction.options.getString('tier'));
|
||||||
const account = await resolvePlayerFromCommand(interaction);
|
const { id, region } = await resolvePlayerFromCommand(interaction);
|
||||||
const { id, region: server } = account;
|
const accountInfo = await getAccountInfo(region, id);
|
||||||
const accountInfo = await getAccountInfo(server, id);
|
const tankStats = await getTankStats(region, id, interaction.locale);
|
||||||
const tankStats = await getTankStats(server, id, interaction.locale);
|
|
||||||
const filteredTanks = (
|
const filteredTanks = (
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
tankStats.map(async (tankData) => ({
|
tankStats.map(async (tankData) => ({
|
||||||
@@ -45,7 +44,6 @@ export const ownedTanksCommand = new Promise<CommandRegistry>((resolve) => {
|
|||||||
})),
|
})),
|
||||||
)
|
)
|
||||||
).filter((tank) => tank.tankDefinitions?.tier === tier);
|
).filter((tank) => tank.tankDefinitions?.tier === tier);
|
||||||
const clanAccountInfo = await getClanAccountInfo(server, id, ['clan']);
|
|
||||||
const groupedTanks: Record<string, TankDefinition[]> = {};
|
const groupedTanks: Record<string, TankDefinition[]> = {};
|
||||||
const nations: string[] = [];
|
const nations: string[] = [];
|
||||||
|
|
||||||
@@ -58,73 +56,28 @@ export const ownedTanksCommand = new Promise<CommandRegistry>((resolve) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
nations.sort();
|
const awaitedTankDefinitions = await tankDefinitions;
|
||||||
|
const awaitedNations = await NATIONS;
|
||||||
|
const lines = tankStats
|
||||||
|
.map(({ tank_id }) => awaitedTankDefinitions[tank_id])
|
||||||
|
.filter((tank) => tank.tier === tier)
|
||||||
|
.sort(
|
||||||
|
(a, b) =>
|
||||||
|
TANK_CLASSES.indexOf(a.class) - TANK_CLASSES.indexOf(b.class),
|
||||||
|
)
|
||||||
|
.sort(
|
||||||
|
(a, b) =>
|
||||||
|
awaitedNations.indexOf(a.nation) - awaitedNations.indexOf(b.nation),
|
||||||
|
)
|
||||||
|
.map((tank) => `${flags[tank.nation]} ${markdownEscape(tank.name)}`);
|
||||||
|
|
||||||
return (
|
return chunk(lines, TANKS_PER_MESSAGE).map((lines, index) =>
|
||||||
<CommandWrapper>
|
index === 0
|
||||||
<TitleBar
|
? `${translate('bot.commands.owned_tanks.body.title', [
|
||||||
title={accountInfo.nickname}
|
markdownEscape(accountInfo.nickname),
|
||||||
image={
|
|
||||||
clanAccountInfo?.clan
|
|
||||||
? emblemIdToURL(clanAccountInfo.clan.emblem_set_id)
|
|
||||||
: undefined
|
|
||||||
}
|
|
||||||
description={translate('bot.commands.owned_tanks.body.subtitle', [
|
|
||||||
TIER_ROMAN_NUMERALS[tier as Tier],
|
TIER_ROMAN_NUMERALS[tier as Tier],
|
||||||
])}
|
])}${lines.join('\n')}`
|
||||||
/>
|
: lines.join('\n'),
|
||||||
|
|
||||||
{filteredTanks.length === 0 && (
|
|
||||||
<NoData type="tanks_found" locale={interaction.locale} />
|
|
||||||
)}
|
|
||||||
|
|
||||||
{filteredTanks.length > 0 &&
|
|
||||||
(await Promise.all(
|
|
||||||
nations.map(async (nation) => {
|
|
||||||
const tanks = groupedTanks[nation];
|
|
||||||
const leftColumnSize = Math.ceil(tanks.length / 2);
|
|
||||||
const leftColumn = tanks.slice(0, leftColumnSize);
|
|
||||||
const rightColumn = tanks.slice(leftColumnSize);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Tanks.Root key={nation}>
|
|
||||||
<Tanks.Title>
|
|
||||||
{translate(`common.nations.${nation}`)}
|
|
||||||
</Tanks.Title>
|
|
||||||
|
|
||||||
<Tanks.Row>
|
|
||||||
<Tanks.Column>
|
|
||||||
{await Promise.all(
|
|
||||||
leftColumn.map(async (tank) => (
|
|
||||||
<Tanks.Item
|
|
||||||
key={tank.id}
|
|
||||||
name={tank.name}
|
|
||||||
tankType={tank.class}
|
|
||||||
image={tankIcon(tank.id)}
|
|
||||||
treeType={tank.treeType}
|
|
||||||
/>
|
|
||||||
)),
|
|
||||||
)}
|
|
||||||
</Tanks.Column>
|
|
||||||
<Tanks.Column>
|
|
||||||
{await Promise.all(
|
|
||||||
rightColumn.map(async (tank) => (
|
|
||||||
<Tanks.Item
|
|
||||||
key={tank.id}
|
|
||||||
name={tank.name}
|
|
||||||
tankType={tank.class}
|
|
||||||
image={tankIcon(tank.id)}
|
|
||||||
treeType={tank.treeType}
|
|
||||||
/>
|
|
||||||
)),
|
|
||||||
)}
|
|
||||||
</Tanks.Column>
|
|
||||||
</Tanks.Row>
|
|
||||||
</Tanks.Root>
|
|
||||||
);
|
|
||||||
}),
|
|
||||||
))}
|
|
||||||
</CommandWrapper>
|
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -27,6 +27,10 @@ export const permissionsCommand = new Promise<CommandRegistry>((resolve) => {
|
|||||||
interaction.appPermissions?.has('AttachFiles'),
|
interaction.appPermissions?.has('AttachFiles'),
|
||||||
t`bot.commands.permissions.body.attach_files`,
|
t`bot.commands.permissions.body.attach_files`,
|
||||||
],
|
],
|
||||||
|
[
|
||||||
|
interaction.appPermissions?.has('UseExternalEmojis'),
|
||||||
|
t`bot.commands.permissions.body.external_emojis`,
|
||||||
|
],
|
||||||
];
|
];
|
||||||
const body = permissions
|
const body = permissions
|
||||||
.map(([hasPermission, description]) => {
|
.map(([hasPermission, description]) => {
|
||||||
|
|||||||
@@ -0,0 +1,574 @@
|
|||||||
|
import { Locale, escapeMarkdown } from 'discord.js';
|
||||||
|
import CommandWrapper from '../components/CommandWrapper';
|
||||||
|
import TitleBar from '../components/TitleBar';
|
||||||
|
import { equipmentPriceMatrix } from '../constants/equipmentPrice';
|
||||||
|
import { getAccountInfo } from '../core/blitz/getAccountInfo';
|
||||||
|
import { getClanAccountInfo } from '../core/blitz/getClanAccountInfo';
|
||||||
|
import getTankStats from '../core/blitz/getTankStats';
|
||||||
|
import resolveTankId from '../core/blitz/resolveTankId';
|
||||||
|
import { asset } from '../core/blitzkrieg/asset';
|
||||||
|
import { buildTechTreeLine } from '../core/blitzkrieg/buildTechTreeLine';
|
||||||
|
import { emblemIdToURL } from '../core/blitzkrieg/emblemIdToURL';
|
||||||
|
import { iconPng } from '../core/blitzkrieg/iconPng';
|
||||||
|
import { resolveAncestry } from '../core/blitzkrieg/resolveAncestry';
|
||||||
|
import { tankDefinitions } from '../core/blitzkrieg/tankDefinitions';
|
||||||
|
import {
|
||||||
|
TANK_ICONS,
|
||||||
|
TIER_ROMAN_NUMERALS,
|
||||||
|
} from '../core/blitzkrieg/tankDefinitions/constants';
|
||||||
|
import { tankIconPng } from '../core/blitzkrieg/tankIconPng';
|
||||||
|
import addUsernameChoices from '../core/discord/addUsernameChoices';
|
||||||
|
import autocompleteTanks from '../core/discord/autocompleteTanks';
|
||||||
|
import { createLocalizedCommand } from '../core/discord/createLocalizedCommand';
|
||||||
|
import { localizationObject } from '../core/discord/localizationObject';
|
||||||
|
import resolvePlayerFromCommand from '../core/discord/resolvePlayerFromCommand';
|
||||||
|
import { translator } from '../core/localization/translator';
|
||||||
|
import { CommandRegistry } from '../events/interactionCreate';
|
||||||
|
import { theme } from '../stitches.config';
|
||||||
|
|
||||||
|
export const researchCommand = new Promise<CommandRegistry>((resolve) => {
|
||||||
|
const { t } = translator(Locale.EnglishUS);
|
||||||
|
|
||||||
|
resolve({
|
||||||
|
inProduction: true,
|
||||||
|
inPublic: true,
|
||||||
|
|
||||||
|
command: createLocalizedCommand('research')
|
||||||
|
.addStringOption((option) =>
|
||||||
|
option
|
||||||
|
.setName(t`bot.commands.research.options.target_tank`)
|
||||||
|
.setNameLocalizations(
|
||||||
|
localizationObject('bot.commands.research.options.target_tank'),
|
||||||
|
)
|
||||||
|
.setDescription(
|
||||||
|
t`bot.commands.research.options.target_tank.description`,
|
||||||
|
)
|
||||||
|
.setDescriptionLocalizations(
|
||||||
|
localizationObject(
|
||||||
|
'bot.commands.research.options.target_tank.description',
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.setAutocomplete(true)
|
||||||
|
.setRequired(true),
|
||||||
|
)
|
||||||
|
.addStringOption((option) =>
|
||||||
|
option
|
||||||
|
.setName(t`bot.commands.research.options.starting_tank`)
|
||||||
|
.setNameLocalizations(
|
||||||
|
localizationObject('bot.commands.research.options.starting_tank'),
|
||||||
|
)
|
||||||
|
.setDescription(
|
||||||
|
t`bot.commands.research.options.starting_tank.description`,
|
||||||
|
)
|
||||||
|
.setDescriptionLocalizations(
|
||||||
|
localizationObject(
|
||||||
|
'bot.commands.research.options.starting_tank.description',
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.setAutocomplete(true)
|
||||||
|
.setRequired(false),
|
||||||
|
)
|
||||||
|
.addStringOption(addUsernameChoices),
|
||||||
|
|
||||||
|
async handler(interaction) {
|
||||||
|
const { t, translate } = translator(interaction.locale);
|
||||||
|
const awaitedTankDefinitions = await tankDefinitions;
|
||||||
|
const targetTankId = await resolveTankId(
|
||||||
|
interaction.options.getString('target-tank', true),
|
||||||
|
interaction.locale,
|
||||||
|
true,
|
||||||
|
);
|
||||||
|
const startingTankRaw = interaction.options.getString('starting-tank');
|
||||||
|
const targetTank = awaitedTankDefinitions[targetTankId];
|
||||||
|
const { id, region } = await resolvePlayerFromCommand(interaction);
|
||||||
|
let startingTankId: number;
|
||||||
|
const targetTankAncestry = await resolveAncestry(targetTankId);
|
||||||
|
|
||||||
|
if (startingTankRaw) {
|
||||||
|
startingTankId = await resolveTankId(
|
||||||
|
startingTankRaw,
|
||||||
|
interaction.locale,
|
||||||
|
true,
|
||||||
|
);
|
||||||
|
|
||||||
|
if (targetTankId === startingTankId) {
|
||||||
|
return translate('bot.commands.research.errors.start_end_equal', [
|
||||||
|
escapeMarkdown(targetTank.name),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
const startingTank = awaitedTankDefinitions[startingTankId];
|
||||||
|
|
||||||
|
if (startingTank.tier > targetTank.tier) {
|
||||||
|
return translate('bot.commands.research.errors.unordered', [
|
||||||
|
escapeMarkdown(startingTank.name),
|
||||||
|
escapeMarkdown(targetTank.name),
|
||||||
|
escapeMarkdown(targetTank.name),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!targetTankAncestry.includes(startingTankId)) {
|
||||||
|
return translate('bot.commands.research.errors.tanks_not_on_line', [
|
||||||
|
escapeMarkdown(targetTank.name),
|
||||||
|
escapeMarkdown(startingTank.name),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (targetTank.treeType !== 'researchable') {
|
||||||
|
return translate('bot.commands.research.errors.non_tech_tree', [
|
||||||
|
escapeMarkdown(targetTank.name),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (targetTank.tier === 1) {
|
||||||
|
return translate('bot.commands.research.errors.tier_1', [
|
||||||
|
escapeMarkdown(targetTank.name),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
const tankStats = await getTankStats(region, id, interaction.locale);
|
||||||
|
|
||||||
|
if (tankStats.some(({ tank_id }) => tank_id === targetTankId)) {
|
||||||
|
return translate('bot.commands.research.errors.already_researched', [
|
||||||
|
escapeMarkdown(targetTank.name),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
const foundAncestor = targetTankAncestry.find(
|
||||||
|
(id) =>
|
||||||
|
awaitedTankDefinitions[id].tier === 1 ||
|
||||||
|
tankStats.some(({ tank_id }) => tank_id === id),
|
||||||
|
);
|
||||||
|
|
||||||
|
if (foundAncestor === undefined) {
|
||||||
|
throw new Error('No first owned tech tree found.');
|
||||||
|
}
|
||||||
|
|
||||||
|
startingTankId = foundAncestor;
|
||||||
|
}
|
||||||
|
|
||||||
|
const techTreeLine = await buildTechTreeLine(
|
||||||
|
startingTankId,
|
||||||
|
targetTankId,
|
||||||
|
);
|
||||||
|
|
||||||
|
const line = [...techTreeLine, startingTankId].reverse();
|
||||||
|
const { nickname } = await getAccountInfo(region, id);
|
||||||
|
const clan = (await getClanAccountInfo(region, id, ['clan']))?.clan;
|
||||||
|
const clanImage = clan ? emblemIdToURL(clan.emblem_set_id) : undefined;
|
||||||
|
const costs = await Promise.all(
|
||||||
|
line.map(async (id) => {
|
||||||
|
const tank = awaitedTankDefinitions[id];
|
||||||
|
const turretXps = new Map<number, number>();
|
||||||
|
const gunXps = new Map<number, number>();
|
||||||
|
const engineXps = new Map<number, number>();
|
||||||
|
const trackXps = new Map<number, number>();
|
||||||
|
|
||||||
|
tank.turrets.forEach((turret) => {
|
||||||
|
if (turret.xp !== undefined) {
|
||||||
|
turretXps.set(turret.id, turret.xp);
|
||||||
|
}
|
||||||
|
|
||||||
|
turret.guns.forEach((gun) => {
|
||||||
|
if (gun.xp !== undefined) {
|
||||||
|
gunXps.set(gun.id, gun.xp);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
tank.engines.forEach((engine) => {
|
||||||
|
if (engine.xp !== undefined) {
|
||||||
|
engineXps.set(engine.id, engine.xp);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
tank.tracks.forEach((track) => {
|
||||||
|
if (track.xp !== undefined) {
|
||||||
|
trackXps.set(track.id, track.xp);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
let moduleXp = 0;
|
||||||
|
turretXps.forEach((value) => {
|
||||||
|
moduleXp += value;
|
||||||
|
});
|
||||||
|
gunXps.forEach((value) => {
|
||||||
|
moduleXp += value;
|
||||||
|
});
|
||||||
|
engineXps.forEach((value) => {
|
||||||
|
moduleXp += value;
|
||||||
|
});
|
||||||
|
trackXps.forEach((value) => {
|
||||||
|
moduleXp += value;
|
||||||
|
});
|
||||||
|
|
||||||
|
return {
|
||||||
|
research: tank.xp,
|
||||||
|
upgrades: moduleXp,
|
||||||
|
purchase: tank.price.value,
|
||||||
|
equipment: equipmentPriceMatrix[tank.tier].reduce(
|
||||||
|
(a, b) => a + 3 * b,
|
||||||
|
0,
|
||||||
|
),
|
||||||
|
};
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
|
const image = (
|
||||||
|
<CommandWrapper>
|
||||||
|
<TitleBar
|
||||||
|
title={nickname}
|
||||||
|
image={clanImage}
|
||||||
|
description={`${t`bot.commands.research.body.subtitle`} • ${targetTank.name}`}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
display: 'flex',
|
||||||
|
flexDirection: 'column',
|
||||||
|
gap: 8,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
display: 'flex',
|
||||||
|
borderRadius: 4,
|
||||||
|
backgroundColor: theme.colors.appBackground2,
|
||||||
|
border: theme.borderStyles.subtle,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<div style={{ width: 48 }}></div>
|
||||||
|
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
flex: 1,
|
||||||
|
display: 'flex',
|
||||||
|
alignItems: 'center',
|
||||||
|
justifyContent: 'center',
|
||||||
|
position: 'relative',
|
||||||
|
right: 24,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
style={{
|
||||||
|
color: theme.colors.textHighContrast,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{t`bot.commands.research.body.total`}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
flex: 1,
|
||||||
|
display: 'flex',
|
||||||
|
flexDirection: 'column',
|
||||||
|
justifyContent: 'center',
|
||||||
|
gap: 8,
|
||||||
|
padding: '16px 0',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
display: 'flex',
|
||||||
|
gap: 4,
|
||||||
|
alignItems: 'center',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<img
|
||||||
|
src={await iconPng(asset('icons/currencies/xp.webp'))}
|
||||||
|
width={16}
|
||||||
|
height={16}
|
||||||
|
/>
|
||||||
|
<span
|
||||||
|
style={{
|
||||||
|
fontSize: 16,
|
||||||
|
color: theme.colors.textHighContrast,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Experience:{' '}
|
||||||
|
{costs
|
||||||
|
.reduce((a, b) => a + (b.research ?? 0) + b.upgrades, 0)
|
||||||
|
.toLocaleString(interaction.locale)}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
display: 'flex',
|
||||||
|
gap: 4,
|
||||||
|
alignItems: 'center',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<img
|
||||||
|
src={await iconPng(asset('icons/currencies/silver.webp'))}
|
||||||
|
width={16}
|
||||||
|
height={16}
|
||||||
|
/>
|
||||||
|
<span
|
||||||
|
style={{
|
||||||
|
fontSize: 16,
|
||||||
|
color: theme.colors.textHighContrast,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Purchase:{' '}
|
||||||
|
{costs
|
||||||
|
.reduce((a, b) => a + b.purchase, 0)
|
||||||
|
.toLocaleString(interaction.locale)}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
display: 'flex',
|
||||||
|
gap: 4,
|
||||||
|
alignItems: 'center',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<img
|
||||||
|
src={await iconPng(asset('icons/currencies/silver.webp'))}
|
||||||
|
width={16}
|
||||||
|
height={16}
|
||||||
|
/>
|
||||||
|
<span
|
||||||
|
style={{
|
||||||
|
fontSize: 16,
|
||||||
|
color: theme.colors.textHighContrast,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Equipment:{' '}
|
||||||
|
{costs
|
||||||
|
.reduce((a, b) => a + b.equipment, 0)
|
||||||
|
.toLocaleString(interaction.locale)}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{await Promise.all(
|
||||||
|
line.map(async (id, index) => {
|
||||||
|
const tank = awaitedTankDefinitions[id];
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
key={id}
|
||||||
|
style={{
|
||||||
|
display: 'flex',
|
||||||
|
borderRadius: 4,
|
||||||
|
backgroundColor: theme.colors.appBackground2,
|
||||||
|
border: theme.borderStyles.subtle,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
width: 48,
|
||||||
|
display: 'flex',
|
||||||
|
alignItems: 'center',
|
||||||
|
justifyContent: 'center',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
style={{
|
||||||
|
color: theme.colors.textLowContrast,
|
||||||
|
fontSize: 16,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{TIER_ROMAN_NUMERALS[tank.tier]}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
flex: 1,
|
||||||
|
display: 'flex',
|
||||||
|
position: 'relative',
|
||||||
|
right: '5%',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
height: 120,
|
||||||
|
width: 240,
|
||||||
|
display: 'flex',
|
||||||
|
alignItems: 'center',
|
||||||
|
justifyContent: 'flex-start',
|
||||||
|
left: '25%',
|
||||||
|
top: '5%',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<img
|
||||||
|
src={await tankIconPng(id)}
|
||||||
|
style={{
|
||||||
|
height: '100%',
|
||||||
|
position: 'absolute',
|
||||||
|
objectFit: 'contain',
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
display: 'flex',
|
||||||
|
gap: 4,
|
||||||
|
alignItems: 'center',
|
||||||
|
justifyContent: 'center',
|
||||||
|
position: 'absolute',
|
||||||
|
bottom: 8,
|
||||||
|
left: '50%',
|
||||||
|
transform: 'translateX(-50%)',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<img
|
||||||
|
src={TANK_ICONS[tank.class]}
|
||||||
|
width={16}
|
||||||
|
height={16}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<span
|
||||||
|
style={{
|
||||||
|
color: theme.colors.textHighContrast,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{tank.name}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
flex: 1,
|
||||||
|
display: 'flex',
|
||||||
|
flexDirection: 'column',
|
||||||
|
justifyContent: 'center',
|
||||||
|
gap: 8,
|
||||||
|
padding: '16px 0',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
display: 'flex',
|
||||||
|
gap: 4,
|
||||||
|
alignItems: 'center',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<img
|
||||||
|
src={await iconPng(asset('icons/currencies/xp.webp'))}
|
||||||
|
width={16}
|
||||||
|
height={16}
|
||||||
|
/>
|
||||||
|
<span
|
||||||
|
style={{
|
||||||
|
fontSize: 16,
|
||||||
|
color: theme.colors.textHighContrast,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{translate('bot.commands.research.body.research', [
|
||||||
|
`${costs[index].research?.toLocaleString(
|
||||||
|
interaction.locale,
|
||||||
|
)}`,
|
||||||
|
])}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{costs[index].upgrades > 0 && (
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
display: 'flex',
|
||||||
|
gap: 4,
|
||||||
|
alignItems: 'center',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<img
|
||||||
|
src={await iconPng(
|
||||||
|
asset('icons/currencies/free-xp.webp'),
|
||||||
|
)}
|
||||||
|
width={16}
|
||||||
|
height={16}
|
||||||
|
/>
|
||||||
|
<span
|
||||||
|
style={{
|
||||||
|
fontSize: 16,
|
||||||
|
color: theme.colors.textHighContrast,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{translate('bot.commands.research.body.upgrades', [
|
||||||
|
costs[index].upgrades.toLocaleString(),
|
||||||
|
])}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
display: 'flex',
|
||||||
|
gap: 4,
|
||||||
|
alignItems: 'center',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<img
|
||||||
|
src={await iconPng(
|
||||||
|
asset('icons/currencies/silver.webp'),
|
||||||
|
)}
|
||||||
|
width={16}
|
||||||
|
height={16}
|
||||||
|
/>
|
||||||
|
<span
|
||||||
|
style={{
|
||||||
|
fontSize: 16,
|
||||||
|
color: theme.colors.textHighContrast,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{translate('bot.commands.research.body.purchase', [
|
||||||
|
costs[index].purchase.toLocaleString(
|
||||||
|
interaction.locale,
|
||||||
|
),
|
||||||
|
])}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
display: 'flex',
|
||||||
|
gap: 4,
|
||||||
|
alignItems: 'center',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<img
|
||||||
|
src={await iconPng(
|
||||||
|
asset('icons/currencies/silver.webp'),
|
||||||
|
)}
|
||||||
|
width={16}
|
||||||
|
height={16}
|
||||||
|
/>
|
||||||
|
<span
|
||||||
|
style={{
|
||||||
|
fontSize: 16,
|
||||||
|
color: theme.colors.textHighContrast,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{translate('bot.commands.research.body.equipment', [
|
||||||
|
costs[index].equipment.toLocaleString(
|
||||||
|
interaction.locale,
|
||||||
|
),
|
||||||
|
])}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</CommandWrapper>
|
||||||
|
);
|
||||||
|
|
||||||
|
return startingTankRaw
|
||||||
|
? image
|
||||||
|
: [t`bot.commands.research.body.estimation`, image];
|
||||||
|
},
|
||||||
|
|
||||||
|
autocomplete(interaction) {
|
||||||
|
autocompleteTanks(interaction, true, ['target-tank', 'starting-tank']);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -3,10 +3,8 @@ import markdownEscape from 'markdown-escape';
|
|||||||
import { Region } from '../constants/regions';
|
import { Region } from '../constants/regions';
|
||||||
import { WARGAMING_APPLICATION_ID } from '../constants/wargamingApplicationID';
|
import { WARGAMING_APPLICATION_ID } from '../constants/wargamingApplicationID';
|
||||||
import fetchBlitz from '../core/blitz/fetchBlitz';
|
import fetchBlitz from '../core/blitz/fetchBlitz';
|
||||||
import {
|
import { AccountList } from '../core/blitz/searchPlayersAcrossRegions';
|
||||||
AccountList,
|
import { usernamePattern } from '../core/blitz/searchPlayersAcrossRegions/constants';
|
||||||
usernamePattern,
|
|
||||||
} from '../core/blitz/searchPlayersAcrossRegions';
|
|
||||||
import addRegionChoices from '../core/discord/addRegionChoices';
|
import addRegionChoices from '../core/discord/addRegionChoices';
|
||||||
import addUsernameChoices from '../core/discord/addUsernameChoices';
|
import addUsernameChoices from '../core/discord/addUsernameChoices';
|
||||||
import { createLocalizedCommand } from '../core/discord/createLocalizedCommand';
|
import { createLocalizedCommand } from '../core/discord/createLocalizedCommand';
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import resolvePeriodFromCommand from '../core/discord/resolvePeriodFromCommand';
|
|||||||
import resolvePlayerFromButton from '../core/discord/resolvePlayerFromButton';
|
import resolvePlayerFromButton from '../core/discord/resolvePlayerFromButton';
|
||||||
import resolvePlayerFromCommand from '../core/discord/resolvePlayerFromCommand';
|
import resolvePlayerFromCommand from '../core/discord/resolvePlayerFromCommand';
|
||||||
import { CommandRegistry } from '../events/interactionCreate';
|
import { CommandRegistry } from '../events/interactionCreate';
|
||||||
import { renderBreakdown } from './breakdown';
|
import { renderBreakdown } from './breakdown/render';
|
||||||
|
|
||||||
export const todayCommand = new Promise<CommandRegistry>(async (resolve) => {
|
export const todayCommand = new Promise<CommandRegistry>(async (resolve) => {
|
||||||
const nations = await NATIONS;
|
const nations = await NATIONS;
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { Percentile } from '../../../../constants/percentiles';
|
|||||||
import { translator } from '../../../../core/localization/translator';
|
import { translator } from '../../../../core/localization/translator';
|
||||||
import getWN8Percentile from '../../../../core/statistics/getWN8Percentile';
|
import getWN8Percentile from '../../../../core/statistics/getWN8Percentile';
|
||||||
import { theme } from '../../../../stitches.config';
|
import { theme } from '../../../../stitches.config';
|
||||||
import { PERCENTILE_COLORS } from '../../../PercentileIndicator';
|
import { PERCENTILE_COLORS } from '../../../PercentileIndicator/constants';
|
||||||
import { Glow } from './components/Glow';
|
import { Glow } from './components/Glow';
|
||||||
|
|
||||||
export interface WN8DisplayProps {
|
export interface WN8DisplayProps {
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ export function WN8SurroundingStat({
|
|||||||
style={{
|
style={{
|
||||||
color: theme.colors.textHighContrast,
|
color: theme.colors.textHighContrast,
|
||||||
fontSize: 24,
|
fontSize: 24,
|
||||||
fontWeight: 'bold',
|
fontWeight: 700,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{value}
|
{value}
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
export function Analytics() {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<script
|
||||||
|
async
|
||||||
|
src="https://www.googletagmanager.com/gtag/js?id=G-98NTMRHRP9"
|
||||||
|
/>
|
||||||
|
<script
|
||||||
|
dangerouslySetInnerHTML={{
|
||||||
|
__html: `
|
||||||
|
window.dataLayer = window.dataLayer || [];
|
||||||
|
function gtag(){dataLayer.push(arguments);}
|
||||||
|
gtag('js', new Date());
|
||||||
|
|
||||||
|
gtag('config', 'G-98NTMRHRP9');
|
||||||
|
`,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -1,12 +1,6 @@
|
|||||||
import { useFrame } from '@react-three/fiber';
|
import { useFrame } from '@react-three/fiber';
|
||||||
import { useEffect } from 'react';
|
import { useEffect } from 'react';
|
||||||
import {
|
import { MeshBasicMaterial, Object3D, ShaderMaterial, Vector2 } from 'three';
|
||||||
MeshBasicMaterial,
|
|
||||||
Object3D,
|
|
||||||
ShaderMaterial,
|
|
||||||
Vector2,
|
|
||||||
WebGLRenderTarget,
|
|
||||||
} from 'three';
|
|
||||||
import { degToRad } from 'three/src/math/MathUtils';
|
import { degToRad } from 'three/src/math/MathUtils';
|
||||||
import { canSplash } from '../../../../core/blitz/canSplash';
|
import { canSplash } from '../../../../core/blitz/canSplash';
|
||||||
import { isExplosive } from '../../../../core/blitz/isExplosive';
|
import { isExplosive } from '../../../../core/blitz/isExplosive';
|
||||||
@@ -21,8 +15,7 @@ import {
|
|||||||
} from '../../../../stores/tankopedia';
|
} from '../../../../stores/tankopedia';
|
||||||
import fragmentShader from './shaders/fragment.glsl';
|
import fragmentShader from './shaders/fragment.glsl';
|
||||||
import vertexShader from './shaders/vertex.glsl';
|
import vertexShader from './shaders/vertex.glsl';
|
||||||
|
import { spacedArmorRenderTarget } from './target';
|
||||||
export const spacedArmorRenderTarget = new WebGLRenderTarget();
|
|
||||||
|
|
||||||
interface CoreArmorSceneComponentProps {
|
interface CoreArmorSceneComponentProps {
|
||||||
thickness: number;
|
thickness: number;
|
||||||
@@ -55,6 +48,7 @@ export function CoreArmorSceneComponent({
|
|||||||
explosionRadius: { value: null },
|
explosionRadius: { value: null },
|
||||||
greenPenetration: { value: null },
|
greenPenetration: { value: null },
|
||||||
opaque: { value: null },
|
opaque: { value: null },
|
||||||
|
useSpacedArmor: { value: null },
|
||||||
|
|
||||||
resolution: { value: new Vector2() },
|
resolution: { value: new Vector2() },
|
||||||
spacedArmorBuffer: { value: null },
|
spacedArmorBuffer: { value: null },
|
||||||
@@ -82,6 +76,7 @@ export function CoreArmorSceneComponent({
|
|||||||
) {
|
) {
|
||||||
material.uniforms.greenPenetration.value = visual.greenPenetration;
|
material.uniforms.greenPenetration.value = visual.greenPenetration;
|
||||||
material.uniforms.opaque.value = visual.opaque || visual.wireframe;
|
material.uniforms.opaque.value = visual.opaque || visual.wireframe;
|
||||||
|
material.uniforms.useSpacedArmor.value = visual.showSpacedArmor;
|
||||||
material.wireframe = visual.wireframe;
|
material.wireframe = visual.wireframe;
|
||||||
}
|
}
|
||||||
async function handleProtagonistEquipmentChange(
|
async function handleProtagonistEquipmentChange(
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ uniform float damage;
|
|||||||
uniform float explosionRadius;
|
uniform float explosionRadius;
|
||||||
uniform bool greenPenetration;
|
uniform bool greenPenetration;
|
||||||
uniform bool opaque;
|
uniform bool opaque;
|
||||||
|
uniform bool useSpacedArmor;
|
||||||
|
|
||||||
uniform highp sampler2D spacedArmorBuffer;
|
uniform highp sampler2D spacedArmorBuffer;
|
||||||
uniform highp sampler2D spacedArmorDepth;
|
uniform highp sampler2D spacedArmorDepth;
|
||||||
@@ -49,11 +50,11 @@ void main() {
|
|||||||
float coreArmorDistance = depthToDistance(gl_FragCoord.z);
|
float coreArmorDistance = depthToDistance(gl_FragCoord.z);
|
||||||
float distanceFromSpacedArmor = coreArmorDistance - spacedArmorDistance;
|
float distanceFromSpacedArmor = coreArmorDistance - spacedArmorDistance;
|
||||||
|
|
||||||
if (isUnderSpacedArmor) {
|
if (useSpacedArmor && isUnderSpacedArmor) {
|
||||||
float spacedArmorThickness = spacedArmorBufferFragment.r * penetration;
|
float spacedArmorThickness = spacedArmorBufferFragment.r * penetration;
|
||||||
remainingPenetration -= spacedArmorThickness;
|
remainingPenetration -= spacedArmorThickness;
|
||||||
|
|
||||||
if (isExplosive && !canSplash && remainingPenetration > 0.0) {
|
if (isExplosive && remainingPenetration > 0.0) {
|
||||||
// there is a 50% penetration loss per meter for HEAT shells
|
// there is a 50% penetration loss per meter for HEAT shells
|
||||||
remainingPenetration -= 0.5 * remainingPenetration * distanceFromSpacedArmor;
|
remainingPenetration -= 0.5 * remainingPenetration * distanceFromSpacedArmor;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
import { WebGLRenderTarget } from 'three';
|
||||||
|
|
||||||
|
export const spacedArmorRenderTarget = new WebGLRenderTarget();
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import { Card, Flex, Inset, Text } from '@radix-ui/themes';
|
import { Card, Flex, Text } from '@radix-ui/themes';
|
||||||
import { Html } from '@react-three/drei';
|
import { Html } from '@react-three/drei';
|
||||||
import { useFrame } from '@react-three/fiber';
|
import { useFrame } from '@react-three/fiber';
|
||||||
import { useEffect, useRef } from 'react';
|
import { useEffect, useRef } from 'react';
|
||||||
@@ -182,33 +182,38 @@ export function ShotDisplay() {
|
|||||||
pointerEvents: 'none',
|
pointerEvents: 'none',
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Card
|
<div
|
||||||
style={{
|
style={{
|
||||||
backgroundColor:
|
backgroundColor:
|
||||||
trueStatus === 'penetration'
|
trueStatus === 'penetration'
|
||||||
? '#00ff00c0'
|
? '#00ff0080'
|
||||||
: trueStatus === 'blocked'
|
: trueStatus === 'blocked'
|
||||||
? '#ff0000c0'
|
? '#ff000080'
|
||||||
: '#ffff00c0',
|
: '#ffff0080',
|
||||||
|
borderRadius: 8,
|
||||||
border: 'none',
|
border: 'none',
|
||||||
|
padding: 4,
|
||||||
|
width: hasMultipleLayers ? undefined : 8,
|
||||||
|
height: hasMultipleLayers ? undefined : 8,
|
||||||
|
display: 'flex',
|
||||||
|
alignItems: 'center',
|
||||||
|
justifyContent: 'center',
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Inset>
|
{hasMultipleLayers && (
|
||||||
{hasMultipleLayers && (
|
<Text
|
||||||
<Text
|
size="2"
|
||||||
style={{
|
style={{
|
||||||
width: '100%',
|
width: '100%',
|
||||||
display: 'block',
|
display: 'block',
|
||||||
textAlign: 'center',
|
textAlign: 'center',
|
||||||
color:
|
color: trueStatus === 'ricochet' ? 'black' : undefined,
|
||||||
trueStatus === 'ricochet' ? 'black' : undefined,
|
}}
|
||||||
}}
|
>
|
||||||
>
|
<b>{layer.index + 1}</b>
|
||||||
<b>{layer.index + 1}</b>
|
</Text>
|
||||||
</Text>
|
)}
|
||||||
)}
|
</div>
|
||||||
</Inset>
|
|
||||||
</Card>
|
|
||||||
</Html>
|
</Html>
|
||||||
</group>
|
</group>
|
||||||
</>
|
</>
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ import { useDuel } from '../../../../stores/duel';
|
|||||||
import {
|
import {
|
||||||
Shot,
|
Shot,
|
||||||
ShotLayerBase,
|
ShotLayerBase,
|
||||||
|
useTankopediaPersistent,
|
||||||
useTankopediaTemporary,
|
useTankopediaTemporary,
|
||||||
} from '../../../../stores/tankopedia';
|
} from '../../../../stores/tankopedia';
|
||||||
import { ArmorType } from '../SpacedArmorScene';
|
import { ArmorType } from '../SpacedArmorScene';
|
||||||
@@ -115,12 +116,20 @@ export function SpacedArmorSceneComponent({
|
|||||||
pushLogs(shellNormal, filterIntersections(event.intersections), 0);
|
pushLogs(shellNormal, filterIntersections(event.intersections), 0);
|
||||||
|
|
||||||
function filterIntersections(intersectionsRaw: Intersection[]) {
|
function filterIntersections(intersectionsRaw: Intersection[]) {
|
||||||
const intersectionsAll = intersectionsRaw.filter(
|
const showSpacedArmor =
|
||||||
|
useTankopediaPersistent.getState().model.visual.showSpacedArmor;
|
||||||
|
const intersectionsTyped = intersectionsRaw.filter(
|
||||||
({ object }) => object.userData.type !== undefined,
|
({ object }) => object.userData.type !== undefined,
|
||||||
) as ArmorMeshIntersection[];
|
) as ArmorMeshIntersection[];
|
||||||
const intersectionsWithDuplicates = intersectionsAll.slice(
|
const intersectionsFiltered = intersectionsTyped.filter(
|
||||||
|
({ object }) =>
|
||||||
|
showSpacedArmor
|
||||||
|
? true
|
||||||
|
: object.userData.type === ArmorType.Core,
|
||||||
|
);
|
||||||
|
const intersectionsWithDuplicates = intersectionsFiltered.slice(
|
||||||
0,
|
0,
|
||||||
intersectionsAll.findIndex(
|
intersectionsFiltered.findIndex(
|
||||||
({ object }) => object.userData.type === ArmorType.Core,
|
({ object }) => object.userData.type === ArmorType.Core,
|
||||||
) + 1,
|
) + 1,
|
||||||
);
|
);
|
||||||
@@ -170,7 +179,7 @@ export function SpacedArmorSceneComponent({
|
|||||||
const distance = (
|
const distance = (
|
||||||
shot.layers.at(-1) as ShotLayerBase
|
shot.layers.at(-1) as ShotLayerBase
|
||||||
).point.distanceTo(intersections[0].point);
|
).point.distanceTo(intersections[0].point);
|
||||||
if (explosive && !splashing)
|
if (explosive)
|
||||||
remainingPenetration -= 0.5 * remainingPenetration * distance;
|
remainingPenetration -= 0.5 * remainingPenetration * distance;
|
||||||
const blocked = remainingPenetration < 0;
|
const blocked = remainingPenetration < 0;
|
||||||
|
|
||||||
@@ -196,7 +205,7 @@ export function SpacedArmorSceneComponent({
|
|||||||
const previousIntersection = intersections[layerIndex - 1];
|
const previousIntersection = intersections[layerIndex - 1];
|
||||||
const distance =
|
const distance =
|
||||||
intersection.distance - previousIntersection.distance;
|
intersection.distance - previousIntersection.distance;
|
||||||
if (explosive && !splashing)
|
if (explosive)
|
||||||
remainingPenetration -=
|
remainingPenetration -=
|
||||||
0.5 * remainingPenetration * distance;
|
0.5 * remainingPenetration * distance;
|
||||||
const wasted = remainingPenetration < 0;
|
const wasted = remainingPenetration < 0;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { createPortal, useFrame } from '@react-three/fiber';
|
|||||||
import { memo, useState } from 'react';
|
import { memo, useState } from 'react';
|
||||||
import { DepthTexture, Scene, Vector2 } from 'three';
|
import { DepthTexture, Scene, Vector2 } from 'three';
|
||||||
import { CoreArmorScene } from './components/CoreArmorScene';
|
import { CoreArmorScene } from './components/CoreArmorScene';
|
||||||
import { spacedArmorRenderTarget } from './components/CoreArmorSceneComponent';
|
import { spacedArmorRenderTarget } from './components/CoreArmorSceneComponent/target';
|
||||||
import { SpacedArmorScene } from './components/SpacedArmorScene';
|
import { SpacedArmorScene } from './components/SpacedArmorScene';
|
||||||
|
|
||||||
export const Armor = memo(() => {
|
export const Armor = memo(() => {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { ReactNode } from 'react';
|
import { ReactNode } from 'react';
|
||||||
|
|
||||||
export interface RootProps {
|
interface RootProps {
|
||||||
children: ReactNode;
|
children: ReactNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,8 @@ import {
|
|||||||
GrayColor,
|
GrayColor,
|
||||||
PALETTES,
|
PALETTES,
|
||||||
} from '../../../constants/radixColors';
|
} from '../../../constants/radixColors';
|
||||||
import { TREE_TYPE_ICONS, TankClass, TreeType } from '../../Tanks';
|
import { TankClass, TreeType } from '../../Tanks';
|
||||||
|
import { TREE_TYPE_ICONS } from '../../Tanks/components/Item/constants';
|
||||||
import { RowStat } from './RowStat';
|
import { RowStat } from './RowStat';
|
||||||
|
|
||||||
export interface RowStatItem {
|
export interface RowStatItem {
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import {
|
|||||||
} from '../../../constants/radixColors';
|
} from '../../../constants/radixColors';
|
||||||
import PercentileIndicator from '../../PercentileIndicator';
|
import PercentileIndicator from '../../PercentileIndicator';
|
||||||
|
|
||||||
export interface RowStatProps {
|
interface RowStatProps {
|
||||||
name: string;
|
name: string;
|
||||||
value?: string | number;
|
value?: string | number;
|
||||||
delta?: number;
|
delta?: number;
|
||||||
@@ -63,7 +63,7 @@ export function RowStat({
|
|||||||
<span
|
<span
|
||||||
style={{
|
style={{
|
||||||
color: theme.textHighContrast,
|
color: theme.textHighContrast,
|
||||||
fontWeight: 'bold',
|
fontWeight: 700,
|
||||||
fontSize: 16,
|
fontSize: 16,
|
||||||
textAlign: 'center',
|
textAlign: 'center',
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ export default function CommandWrapper({ children, fat }: CommandWrapperProps) {
|
|||||||
gap: 16,
|
gap: 16,
|
||||||
width: 480,
|
width: 480,
|
||||||
color: theme.colors.textHighContrast,
|
color: theme.colors.textHighContrast,
|
||||||
background: 'url(https://i.imgur.com/PhS06NJ.png)',
|
background: theme.colors.appBackground1,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{children}
|
{children}
|
||||||
|
|||||||
@@ -2,13 +2,13 @@ import { Percentile } from '../../../constants/percentiles';
|
|||||||
import { theme } from '../../../stitches.config';
|
import { theme } from '../../../stitches.config';
|
||||||
import PercentileIndicator from '../../PercentileIndicator';
|
import PercentileIndicator from '../../PercentileIndicator';
|
||||||
|
|
||||||
export interface CardItem {
|
interface CardItem {
|
||||||
label: string;
|
label: string;
|
||||||
value: string | number | undefined;
|
value: string | number | undefined;
|
||||||
percentile?: Percentile;
|
percentile?: Percentile;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface CardProps {
|
interface CardProps {
|
||||||
items: CardItem[];
|
items: CardItem[];
|
||||||
title: string;
|
title: string;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
export interface RootProps {
|
interface RootProps {
|
||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
export interface RowProps {
|
interface RowProps {
|
||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import { Card } from './components/Card';
|
|||||||
import { Root } from './components/Root';
|
import { Root } from './components/Root';
|
||||||
import { Row } from './components/Row';
|
import { Row } from './components/Row';
|
||||||
|
|
||||||
export interface GenericAllStatsProps {
|
interface GenericAllStatsProps {
|
||||||
stats: AllStats;
|
stats: AllStats;
|
||||||
supplementaryStats?: SupplementaryStats;
|
supplementaryStats?: SupplementaryStats;
|
||||||
locale: Locale;
|
locale: Locale;
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import { Stat } from '..';
|
import { GenericStat } from '..';
|
||||||
import GenericStatsRow from './GenericStatsRow';
|
import GenericStatsRow from './GenericStatsRow';
|
||||||
|
|
||||||
export interface GenericStatsColumnProps {
|
interface GenericStatsColumnProps {
|
||||||
stats: Stat[];
|
stats: GenericStat[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function GenericStatsColumn({ stats }: GenericStatsColumnProps) {
|
export default function GenericStatsColumn({ stats }: GenericStatsColumnProps) {
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import { Stat } from '..';
|
import { GenericStat } from '..';
|
||||||
import { theme } from '../../../stitches.config';
|
import { theme } from '../../../stitches.config';
|
||||||
import PercentileIndicator from '../../PercentileIndicator';
|
import PercentileIndicator from '../../PercentileIndicator';
|
||||||
|
|
||||||
export interface GenericStatsRowProps {
|
interface GenericStatsRowProps {
|
||||||
stat: Stat;
|
stat: GenericStat;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function GenericStatsRow({ stat }: GenericStatsRowProps) {
|
export default function GenericStatsRow({ stat }: GenericStatsRowProps) {
|
||||||
@@ -30,7 +30,7 @@ export default function GenericStatsRow({ stat }: GenericStatsRowProps) {
|
|||||||
<span
|
<span
|
||||||
style={{
|
style={{
|
||||||
color: theme.colors.textHighContrast,
|
color: theme.colors.textHighContrast,
|
||||||
fontWeight: 'bold',
|
fontWeight: 700,
|
||||||
fontSize: 16,
|
fontSize: 16,
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
import { Percentile } from '../../constants/percentiles';
|
import { Percentile } from '../../constants/percentiles';
|
||||||
import GenericStatsColumn from './components/GenericStatsColumn';
|
import GenericStatsColumn from './components/GenericStatsColumn';
|
||||||
|
|
||||||
export type Stat =
|
export type GenericStat =
|
||||||
| [string, string | number | undefined]
|
| [string, string | number | undefined]
|
||||||
| [string, string | number | undefined, Percentile | undefined];
|
| [string, string | number | undefined, Percentile | undefined];
|
||||||
|
|
||||||
export interface GenericStatsProps {
|
export interface GenericStatsProps {
|
||||||
stats: Stat[];
|
stats: GenericStat[];
|
||||||
columnCount?: number;
|
columnCount?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -16,7 +16,7 @@ export default function GenericStats({
|
|||||||
}: GenericStatsProps) {
|
}: GenericStatsProps) {
|
||||||
const filteredStats = stats.filter(([, value]) => value !== undefined);
|
const filteredStats = stats.filter(([, value]) => value !== undefined);
|
||||||
const itemsPerRow = Math.ceil(filteredStats.length / columnCount);
|
const itemsPerRow = Math.ceil(filteredStats.length / columnCount);
|
||||||
const columns: Stat[][] = [];
|
const columns: GenericStat[][] = [];
|
||||||
|
|
||||||
filteredStats.forEach((stat, index) => {
|
filteredStats.forEach((stat, index) => {
|
||||||
const column = Math.floor(index / itemsPerRow);
|
const column = Math.floor(index / itemsPerRow);
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
export enum LineColor {
|
||||||
|
Red,
|
||||||
|
Green,
|
||||||
|
Blue,
|
||||||
|
White,
|
||||||
|
}
|
||||||
|
export enum LineStyle {
|
||||||
|
Solid,
|
||||||
|
Dashes,
|
||||||
|
DashesAndDots,
|
||||||
|
}
|
||||||
+4
-16
@@ -1,12 +1,6 @@
|
|||||||
import { blue, green, red, slateDark } from '@radix-ui/colors';
|
import { blue, green, red, slateDark } from '@radix-ui/colors';
|
||||||
import { GRAPH_HEIGHT, GRAPH_WIDTH } from './Root';
|
import { GRAPH_HEIGHT, GRAPH_WIDTH } from '../Root/constants';
|
||||||
|
import { LineColor, LineStyle } from './constants';
|
||||||
export enum LineColor {
|
|
||||||
Red,
|
|
||||||
Green,
|
|
||||||
Blue,
|
|
||||||
White,
|
|
||||||
}
|
|
||||||
|
|
||||||
const LINE_COLORS = {
|
const LINE_COLORS = {
|
||||||
[LineColor.Red]: red.red9,
|
[LineColor.Red]: red.red9,
|
||||||
@@ -15,12 +9,6 @@ const LINE_COLORS = {
|
|||||||
[LineColor.White]: slateDark.slate11,
|
[LineColor.White]: slateDark.slate11,
|
||||||
};
|
};
|
||||||
|
|
||||||
export enum LineStyle {
|
|
||||||
Solid,
|
|
||||||
Dashes,
|
|
||||||
DashesAndDots,
|
|
||||||
}
|
|
||||||
|
|
||||||
const LINE_STYLES = {
|
const LINE_STYLES = {
|
||||||
[LineStyle.Solid]: undefined,
|
[LineStyle.Solid]: undefined,
|
||||||
[LineStyle.Dashes]: '8, 8',
|
[LineStyle.Dashes]: '8, 8',
|
||||||
@@ -28,9 +16,9 @@ const LINE_STYLES = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export type PlotItem = [number, number];
|
export type PlotItem = [number, number];
|
||||||
export type Plot = PlotItem[];
|
type Plot = PlotItem[];
|
||||||
|
|
||||||
export interface LineProps {
|
interface LineProps {
|
||||||
plot: Plot;
|
plot: Plot;
|
||||||
minY?: number;
|
minY?: number;
|
||||||
maxY?: number;
|
maxY?: number;
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
export enum MarginOrientation {
|
||||||
|
Vertical,
|
||||||
|
Horizontal,
|
||||||
|
}
|
||||||
+4
-8
@@ -1,13 +1,9 @@
|
|||||||
import { times } from 'lodash';
|
import { times } from 'lodash';
|
||||||
import { theme } from '../../../stitches.config';
|
import { theme } from '../../../../stitches.config';
|
||||||
import { MarginInputProps } from './Root';
|
import { MarginInputProps } from '../Root';
|
||||||
|
import { MarginOrientation } from './constants';
|
||||||
|
|
||||||
export enum MarginOrientation {
|
interface MarginProps extends MarginInputProps {
|
||||||
Vertical,
|
|
||||||
Horizontal,
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface MarginProps extends MarginInputProps {
|
|
||||||
verticalSeparations: number;
|
verticalSeparations: number;
|
||||||
orientation?: MarginOrientation;
|
orientation?: MarginOrientation;
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
export const GRAPH_WIDTH = 384;
|
||||||
|
export const GRAPH_HEIGHT = 320;
|
||||||
+5
-6
@@ -1,10 +1,9 @@
|
|||||||
import { times } from 'lodash';
|
import { times } from 'lodash';
|
||||||
import { ReactNode } from 'react';
|
import { ReactNode } from 'react';
|
||||||
import { theme } from '../../../stitches.config';
|
import { theme } from '../../../../stitches.config';
|
||||||
import { Margin, MarginOrientation } from './Margin';
|
import { Margin } from '../Margin';
|
||||||
|
import { MarginOrientation } from '../Margin/constants';
|
||||||
export const GRAPH_WIDTH = 384;
|
import { GRAPH_HEIGHT, GRAPH_WIDTH } from './constants';
|
||||||
export const GRAPH_HEIGHT = 320;
|
|
||||||
|
|
||||||
export interface MarginInputProps {
|
export interface MarginInputProps {
|
||||||
min: number;
|
min: number;
|
||||||
@@ -13,7 +12,7 @@ export interface MarginInputProps {
|
|||||||
precision?: number;
|
precision?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface RootProps {
|
interface RootProps {
|
||||||
children: ReactNode;
|
children: ReactNode;
|
||||||
verticalMargin?: MarginInputProps;
|
verticalMargin?: MarginInputProps;
|
||||||
horizontalMargin?: MarginInputProps;
|
horizontalMargin?: MarginInputProps;
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import { theme } from '../../../stitches.config';
|
import { theme } from '../../../stitches.config';
|
||||||
|
|
||||||
export interface GapProps {
|
interface GapProps {
|
||||||
message: string;
|
message: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { ComponentProps } from 'react';
|
|||||||
import { RatingsReward } from '../../../commands/ratings';
|
import { RatingsReward } from '../../../commands/ratings';
|
||||||
import { theme } from '../../../stitches.config';
|
import { theme } from '../../../stitches.config';
|
||||||
|
|
||||||
export interface ItemProps extends ComponentProps<'div'> {
|
interface ItemProps extends ComponentProps<'div'> {
|
||||||
position: number;
|
position: number;
|
||||||
deltaPosition?: number;
|
deltaPosition?: number;
|
||||||
score?: number;
|
score?: number;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { ReactNode } from 'react';
|
import { ReactNode } from 'react';
|
||||||
|
|
||||||
export interface RootProps {
|
interface RootProps {
|
||||||
children: ReactNode;
|
children: ReactNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import { DiscordLogoIcon } from '@radix-ui/react-icons';
|
import { DiscordLogoIcon } from '@radix-ui/react-icons';
|
||||||
import { Flex, Text, Theme } from '@radix-ui/themes';
|
import { Flex, Text, Theme } from '@radix-ui/themes';
|
||||||
import Link from 'next/link';
|
import Link from 'next/link';
|
||||||
import { theme } from '../../stitches.config';
|
|
||||||
import { BlitzkriegWormWide } from '../../icons/BlitzkriegWormWide';
|
import { BlitzkriegWormWide } from '../../icons/BlitzkriegWormWide';
|
||||||
|
import { theme } from '../../stitches.config';
|
||||||
|
|
||||||
export default function Navbar() {
|
export default function Navbar() {
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
export enum NoDataType {
|
||||||
|
BattlesInPeriod,
|
||||||
|
PlayersInPeriod,
|
||||||
|
TanksFound,
|
||||||
|
}
|
||||||
@@ -1,14 +1,8 @@
|
|||||||
import { Locale } from 'discord.js';
|
import { Locale } from 'discord.js';
|
||||||
import { translator } from '../core/localization/translator';
|
import { translator } from '../../core/localization/translator';
|
||||||
import { theme } from '../stitches.config';
|
import { theme } from '../../stitches.config';
|
||||||
|
|
||||||
export enum NoDataType {
|
interface NoDataProps {
|
||||||
BattlesInPeriod,
|
|
||||||
PlayersInPeriod,
|
|
||||||
TanksFound,
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface NoDataProps {
|
|
||||||
type: 'battles_in_period' | 'players_in_period' | 'tanks_found';
|
type: 'battles_in_period' | 'players_in_period' | 'tanks_found';
|
||||||
locale: Locale;
|
locale: Locale;
|
||||||
}
|
}
|
||||||
+1
-20
@@ -10,11 +10,7 @@ import {
|
|||||||
slate,
|
slate,
|
||||||
teal,
|
teal,
|
||||||
} from '@radix-ui/colors';
|
} from '@radix-ui/colors';
|
||||||
import { Percentile } from '../constants/percentiles';
|
import { Percentile } from '../../constants/percentiles';
|
||||||
|
|
||||||
export interface PercentileIndicatorProps {
|
|
||||||
percentile: Percentile;
|
|
||||||
}
|
|
||||||
|
|
||||||
export const PERCENTILE_COLORS = {
|
export const PERCENTILE_COLORS = {
|
||||||
[Percentile.VeryBad]: slate.slate9,
|
[Percentile.VeryBad]: slate.slate9,
|
||||||
@@ -28,18 +24,3 @@ export const PERCENTILE_COLORS = {
|
|||||||
[Percentile.Unicum]: pink.pink9,
|
[Percentile.Unicum]: pink.pink9,
|
||||||
[Percentile.SuperUnicum]: purple.purple9,
|
[Percentile.SuperUnicum]: purple.purple9,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function PercentileIndicator({
|
|
||||||
percentile,
|
|
||||||
}: PercentileIndicatorProps) {
|
|
||||||
return (
|
|
||||||
<div
|
|
||||||
style={{
|
|
||||||
width: 8,
|
|
||||||
height: 8,
|
|
||||||
borderRadius: 4,
|
|
||||||
backgroundColor: PERCENTILE_COLORS[percentile],
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
import { Percentile } from '../../constants/percentiles';
|
||||||
|
import { PERCENTILE_COLORS } from './constants';
|
||||||
|
|
||||||
|
interface PercentileIndicatorProps {
|
||||||
|
percentile: Percentile;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function PercentileIndicator({
|
||||||
|
percentile,
|
||||||
|
}: PercentileIndicatorProps) {
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
width: 8,
|
||||||
|
height: 8,
|
||||||
|
borderRadius: 4,
|
||||||
|
backgroundColor: PERCENTILE_COLORS[percentile],
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import { ReactNode } from 'react';
|
import { ReactNode } from 'react';
|
||||||
|
|
||||||
export interface ColumnProps {
|
interface ColumnProps {
|
||||||
children: ReactNode;
|
children: ReactNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,31 @@
|
|||||||
|
import { TankClass, TreeType } from '.';
|
||||||
|
import {
|
||||||
|
TANK_ICONS,
|
||||||
|
TANK_ICONS_COLLECTOR,
|
||||||
|
TANK_ICONS_PREMIUM,
|
||||||
|
} from '../../../../core/blitzkrieg/tankDefinitions/constants';
|
||||||
|
|
||||||
|
export const TREE_TYPES = ['researchable', 'premium', 'collector'] as const; // BIG TODO: REMOVE THIS AFTER LOCALIZATION
|
||||||
|
|
||||||
|
export const TANK_CLASSES = [
|
||||||
|
'lightTank',
|
||||||
|
'mediumTank',
|
||||||
|
'heavyTank',
|
||||||
|
'AT-SPG',
|
||||||
|
] as const;
|
||||||
|
|
||||||
|
export const TREE_TYPE_NAMES: Record<TreeType, string> = {
|
||||||
|
researchable: 'Tech tree',
|
||||||
|
premium: 'Premium',
|
||||||
|
collector: 'Collector',
|
||||||
|
};
|
||||||
|
export const TREE_TYPE_IMAGES: Record<TreeType, string> = {
|
||||||
|
researchable: 'https://i.imgur.com/pJxO2XY.png',
|
||||||
|
premium: 'https://i.imgur.com/mZzSwOU.png',
|
||||||
|
collector: 'https://i.imgur.com/7A0RsG5.png',
|
||||||
|
};
|
||||||
|
export const TREE_TYPE_ICONS: Record<TreeType, Record<TankClass, string>> = {
|
||||||
|
researchable: TANK_ICONS,
|
||||||
|
premium: TANK_ICONS_PREMIUM,
|
||||||
|
collector: TANK_ICONS_COLLECTOR,
|
||||||
|
};
|
||||||
+3
-36
@@ -1,37 +1,10 @@
|
|||||||
import {
|
import { theme } from '../../../../stitches.config';
|
||||||
TANK_ICONS,
|
import { TANK_CLASSES, TREE_TYPES, TREE_TYPE_ICONS } from './constants';
|
||||||
TANK_ICONS_COLLECTOR,
|
|
||||||
TANK_ICONS_PREMIUM,
|
|
||||||
} from '../../../core/blitzkrieg/tankDefinitions';
|
|
||||||
import { theme } from '../../../stitches.config';
|
|
||||||
|
|
||||||
export const TANK_CLASSES = [
|
|
||||||
'lightTank',
|
|
||||||
'mediumTank',
|
|
||||||
'heavyTank',
|
|
||||||
'AT-SPG',
|
|
||||||
] as const;
|
|
||||||
|
|
||||||
export const TREE_TYPES = ['researchable', 'premium', 'collector'] as const;
|
|
||||||
|
|
||||||
export type TankClass = (typeof TANK_CLASSES)[number];
|
export type TankClass = (typeof TANK_CLASSES)[number];
|
||||||
export type TreeType = (typeof TREE_TYPES)[number];
|
export type TreeType = (typeof TREE_TYPES)[number];
|
||||||
|
|
||||||
// BIG TODO: REMOVE THIS AFTER LOCALIZATION
|
|
||||||
export const TREE_TYPE_NAMES: Record<TreeType, string> = {
|
|
||||||
researchable: 'Tech tree',
|
|
||||||
premium: 'Premium',
|
|
||||||
collector: 'Collector',
|
|
||||||
};
|
|
||||||
|
|
||||||
export const TREE_TYPE_IMAGES: Record<TreeType, string> = {
|
|
||||||
researchable: 'https://i.imgur.com/pJxO2XY.png',
|
|
||||||
premium: 'https://i.imgur.com/mZzSwOU.png',
|
|
||||||
collector: 'https://i.imgur.com/7A0RsG5.png',
|
|
||||||
};
|
|
||||||
|
|
||||||
export interface ItemProps {
|
export interface ItemProps {
|
||||||
image?: string;
|
|
||||||
tankType?: TankClass;
|
tankType?: TankClass;
|
||||||
name: string;
|
name: string;
|
||||||
treeType: TreeType;
|
treeType: TreeType;
|
||||||
@@ -43,13 +16,7 @@ const TREE_TYPE_COLOR = {
|
|||||||
collector: '_blue',
|
collector: '_blue',
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
export const TREE_TYPE_ICONS: Record<TreeType, Record<TankClass, string>> = {
|
export function Item({ tankType, name, treeType }: ItemProps) {
|
||||||
researchable: TANK_ICONS,
|
|
||||||
premium: TANK_ICONS_PREMIUM,
|
|
||||||
collector: TANK_ICONS_COLLECTOR,
|
|
||||||
};
|
|
||||||
|
|
||||||
export function Item({ image, tankType, name, treeType }: ItemProps) {
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
style={{
|
style={{
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import { ReactNode } from 'react';
|
import { ReactNode } from 'react';
|
||||||
|
|
||||||
export interface RootProps {
|
interface RootProps {
|
||||||
children: ReactNode;
|
children: ReactNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { ReactNode } from 'react';
|
import { ReactNode } from 'react';
|
||||||
|
|
||||||
export interface RowProps {
|
interface RowProps {
|
||||||
children: ReactNode;
|
children: ReactNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { theme } from '../../../stitches.config';
|
import { theme } from '../../../stitches.config';
|
||||||
|
|
||||||
export interface TitleProps {
|
interface TitleProps {
|
||||||
children: string;
|
children: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { theme } from '../stitches.config';
|
|||||||
|
|
||||||
export type TierWeightsRecord = Partial<Record<Tier, number>>;
|
export type TierWeightsRecord = Partial<Record<Tier, number>>;
|
||||||
|
|
||||||
export interface TierWeightsProps {
|
interface TierWeightsProps {
|
||||||
weights: TierWeightsRecord;
|
weights: TierWeightsRecord;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { theme } from '../stitches.config';
|
import { theme } from '../stitches.config';
|
||||||
|
|
||||||
export interface TitleBarProps {
|
interface TitleBarProps {
|
||||||
title: string;
|
title: string;
|
||||||
image?: string;
|
image?: string;
|
||||||
description?: string;
|
description?: string;
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
import { Vector3Tuple } from 'three';
|
||||||
|
import { Tier } from '../core/blitzkrieg/tankDefinitions';
|
||||||
|
|
||||||
|
export const equipmentPriceMatrix: Record<Tier, Vector3Tuple> = {
|
||||||
|
1: [100, 200, 300],
|
||||||
|
2: [200, 300, 400],
|
||||||
|
3: [400, 500, 600],
|
||||||
|
4: [4000, 5000, 6000],
|
||||||
|
5: [40_000, 50_000, 60_000],
|
||||||
|
6: [100_000, 120_000, 140_000],
|
||||||
|
7: [150_000, 170_000, 190_000],
|
||||||
|
8: [200_000, 225_000, 250_000],
|
||||||
|
9: [250_000, 275_000, 300_000],
|
||||||
|
10: [300_000, 350_000, 400_000],
|
||||||
|
};
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
import { clamp } from 'lodash';
|
import { clamp } from 'lodash';
|
||||||
|
import { degToRad } from 'three/src/math/MathUtils';
|
||||||
import { PitchLimits, YawLimits } from '../blitzkrieg/modelDefinitions';
|
import { PitchLimits, YawLimits } from '../blitzkrieg/modelDefinitions';
|
||||||
import { normalizeAngleRad } from '../math/normalizeAngleRad';
|
import { normalizeAngleRad } from '../math/normalizeAngleRad';
|
||||||
|
|
||||||
@@ -7,33 +8,31 @@ export function applyPitchYawLimits(
|
|||||||
yaw: number, // rad
|
yaw: number, // rad
|
||||||
pitchLimits: PitchLimits, // deg
|
pitchLimits: PitchLimits, // deg
|
||||||
yawLimits?: YawLimits, // deg
|
yawLimits?: YawLimits, // deg
|
||||||
|
verticalStabilizer = false,
|
||||||
) {
|
) {
|
||||||
let newPitch = pitch;
|
let newPitch = pitch;
|
||||||
let newYaw = yaw;
|
let newYaw = yaw;
|
||||||
|
|
||||||
if (yawLimits) {
|
if (yawLimits) {
|
||||||
newYaw = normalizeAngleRad(
|
newYaw = normalizeAngleRad(
|
||||||
clamp(
|
clamp(newYaw, -degToRad(yawLimits.max), -degToRad(yawLimits.min)),
|
||||||
newYaw,
|
|
||||||
-yawLimits.max * (Math.PI / 180),
|
|
||||||
-yawLimits.min * (Math.PI / 180),
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
let lowerPitch = -pitchLimits.max * (Math.PI / 180);
|
const pitchBuff = verticalStabilizer ? degToRad(3) : 0;
|
||||||
let upperPitch = -pitchLimits.min * (Math.PI / 180);
|
let lowerPitch = -degToRad(pitchLimits.max) - pitchBuff;
|
||||||
const transition = (pitchLimits.transition ?? 10) * (Math.PI / 180);
|
let upperPitch = -degToRad(pitchLimits.min) + pitchBuff;
|
||||||
|
const transition = degToRad(pitchLimits.transition ?? 10);
|
||||||
|
|
||||||
if (pitchLimits.back) {
|
if (pitchLimits.back) {
|
||||||
const range = pitchLimits.back.range * (Math.PI / 180);
|
const range = degToRad(pitchLimits.back.range);
|
||||||
const yawRotatedAbs = Math.abs(normalizeAngleRad(newYaw - Math.PI));
|
const yawRotatedAbs = Math.abs(normalizeAngleRad(newYaw - Math.PI));
|
||||||
|
|
||||||
if (yawRotatedAbs <= range + transition) {
|
if (yawRotatedAbs <= range + transition) {
|
||||||
if (yawRotatedAbs <= range) {
|
if (yawRotatedAbs <= range) {
|
||||||
// inside range
|
// inside range
|
||||||
lowerPitch = -pitchLimits.back.max * (Math.PI / 180);
|
lowerPitch = -degToRad(pitchLimits.back.max);
|
||||||
upperPitch = -pitchLimits.back.min * (Math.PI / 180);
|
upperPitch = -degToRad(pitchLimits.back.min);
|
||||||
} else {
|
} else {
|
||||||
// inside transition
|
// inside transition
|
||||||
const transitionProgress = (yawRotatedAbs - range) / transition;
|
const transitionProgress = (yawRotatedAbs - range) / transition;
|
||||||
@@ -44,21 +43,21 @@ export function applyPitchYawLimits(
|
|||||||
(1 - transitionProgress) * pitchLimits.back.min +
|
(1 - transitionProgress) * pitchLimits.back.min +
|
||||||
transitionProgress * pitchLimits.min;
|
transitionProgress * pitchLimits.min;
|
||||||
|
|
||||||
lowerPitch = -maxInterpolatedPitch * (Math.PI / 180);
|
lowerPitch = -degToRad(maxInterpolatedPitch);
|
||||||
upperPitch = -minInterpolatedPitch * (Math.PI / 180);
|
upperPitch = -degToRad(minInterpolatedPitch);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pitchLimits.front) {
|
if (pitchLimits.front) {
|
||||||
const range = pitchLimits.front.range * (Math.PI / 180);
|
const range = degToRad(pitchLimits.front.range);
|
||||||
const yawAbs = Math.abs(normalizeAngleRad(newYaw));
|
const yawAbs = Math.abs(normalizeAngleRad(newYaw));
|
||||||
|
|
||||||
if (yawAbs <= range + transition) {
|
if (yawAbs <= range + transition) {
|
||||||
if (yawAbs <= range) {
|
if (yawAbs <= range) {
|
||||||
// inside range
|
// inside range
|
||||||
lowerPitch = -pitchLimits.front.max * (Math.PI / 180);
|
lowerPitch = -degToRad(pitchLimits.front.max);
|
||||||
upperPitch = -pitchLimits.front.min * (Math.PI / 180);
|
upperPitch = -degToRad(pitchLimits.front.min);
|
||||||
} else {
|
} else {
|
||||||
// inside transition
|
// inside transition
|
||||||
const transitionProgress = (yawAbs - range) / transition;
|
const transitionProgress = (yawAbs - range) / transition;
|
||||||
@@ -69,8 +68,8 @@ export function applyPitchYawLimits(
|
|||||||
(1 - transitionProgress) * pitchLimits.front.min +
|
(1 - transitionProgress) * pitchLimits.front.min +
|
||||||
transitionProgress * pitchLimits.min;
|
transitionProgress * pitchLimits.min;
|
||||||
|
|
||||||
lowerPitch = -maxInterpolatedPitch * (Math.PI / 180);
|
lowerPitch = -degToRad(maxInterpolatedPitch);
|
||||||
upperPitch = -minInterpolatedPitch * (Math.PI / 180);
|
upperPitch = -degToRad(minInterpolatedPitch);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,15 +0,0 @@
|
|||||||
import { WARGAMING_APPLICATION_ID } from '../../constants/wargamingApplicationID';
|
|
||||||
import fetchBlitz from './fetchBlitz';
|
|
||||||
|
|
||||||
export interface EncyclopediaInfo {
|
|
||||||
achievement_sections: Record<string, { name: string; order: number }>;
|
|
||||||
tanks_updated_at: number;
|
|
||||||
languages: Record<string, string>;
|
|
||||||
vehicle_types: Record<string, string>;
|
|
||||||
vehicle_nations: Record<string, string>;
|
|
||||||
game_version: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export const encyclopediaInfo = fetchBlitz<EncyclopediaInfo>(
|
|
||||||
`https://api.wotblitz.com/wotb/encyclopedia/info/?application_id=${WARGAMING_APPLICATION_ID}`,
|
|
||||||
);
|
|
||||||
@@ -6,13 +6,9 @@ import { VertexAttribute } from '../streams/scpg';
|
|||||||
import {
|
import {
|
||||||
vertexAttributeGLTFName,
|
vertexAttributeGLTFName,
|
||||||
vertexAttributeGltfVectorSizes,
|
vertexAttributeGltfVectorSizes,
|
||||||
} from './extractModel';
|
} from './extractModel/constants';
|
||||||
import { readDVPLFile } from './readDVPLFile';
|
import { readDVPLFile } from './readDVPLFile';
|
||||||
|
|
||||||
Buffer.prototype.toJSON = function () {
|
|
||||||
return [...(this as Buffer)].map((int) => int.toString(16)).join('');
|
|
||||||
};
|
|
||||||
|
|
||||||
export async function extractArmor(data: string, fileName: string) {
|
export async function extractArmor(data: string, fileName: string) {
|
||||||
const sc2Path = `${data}/3d/Tanks/CollisionMeshes/${fileName}.sc2.dvpl`;
|
const sc2Path = `${data}/3d/Tanks/CollisionMeshes/${fileName}.sc2.dvpl`;
|
||||||
const scgPath = `${data}/3d/Tanks/CollisionMeshes/${fileName}.scg.dvpl`;
|
const scgPath = `${data}/3d/Tanks/CollisionMeshes/${fileName}.scg.dvpl`;
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
import { vertexAttributeVectorSizes } from '../../streams/scg';
|
||||||
|
import { VertexAttribute } from '../../streams/scpg';
|
||||||
|
|
||||||
|
export const vertexAttributeGLTFName: Partial<Record<VertexAttribute, string>> =
|
||||||
|
{
|
||||||
|
[VertexAttribute.VERTEX]: 'POSITION',
|
||||||
|
[VertexAttribute.NORMAL]: 'NORMAL',
|
||||||
|
[VertexAttribute.TEXCOORD0]: 'TEXCOORD_0',
|
||||||
|
[VertexAttribute.TEXCOORD1]: 'TEXCOORD_0',
|
||||||
|
[VertexAttribute.TEXCOORD2]: 'TEXCOORD_0',
|
||||||
|
[VertexAttribute.TEXCOORD3]: 'TEXCOORD_0',
|
||||||
|
[VertexAttribute.TANGENT]: 'TANGENT',
|
||||||
|
[VertexAttribute.JOINTINDEX]: 'JOINT_0',
|
||||||
|
[VertexAttribute.JOINTWEIGHT]: 'WEIGHT_0',
|
||||||
|
};
|
||||||
|
export const vertexAttributeGltfVectorSizes = {
|
||||||
|
...vertexAttributeVectorSizes,
|
||||||
|
[VertexAttribute.TANGENT]: 4,
|
||||||
|
} as const;
|
||||||
@@ -1,51 +1,26 @@
|
|||||||
import { Document, Material, Node, Scene } from '@gltf-transform/core';
|
import { Document, Material, Node, Scene } from '@gltf-transform/core';
|
||||||
import { times } from 'lodash';
|
import { times } from 'lodash';
|
||||||
import { dirname } from 'path';
|
import { dirname } from 'path';
|
||||||
|
import { Matrix4, Quaternion, Vector3, Vector4Tuple } from 'three';
|
||||||
|
import { readTexture } from '../../blitzkrieg/readTexture';
|
||||||
|
import { TextureMutation } from '../../blitzkrieg/readTexture/constants';
|
||||||
|
import { Hierarchy, Sc2ReadStream, Textures } from '../../streams/sc2';
|
||||||
|
import { ScgReadStream } from '../../streams/scg';
|
||||||
|
import { VertexAttribute } from '../../streams/scpg';
|
||||||
|
import { readDVPLFile } from '../readDVPLFile';
|
||||||
import {
|
import {
|
||||||
Matrix4,
|
vertexAttributeGLTFName,
|
||||||
Quaternion,
|
vertexAttributeGltfVectorSizes,
|
||||||
Vector3,
|
} from './constants';
|
||||||
Vector3Tuple,
|
|
||||||
Vector4Tuple,
|
|
||||||
} from 'three';
|
|
||||||
import { TextureMutation, readTexture } from '../blitzkrieg/readTexture';
|
|
||||||
import { Hierarchy, Sc2ReadStream, Textures } from '../streams/sc2';
|
|
||||||
import { ScgReadStream, vertexAttributeVectorSizes } from '../streams/scg';
|
|
||||||
import { VertexAttribute } from '../streams/scpg';
|
|
||||||
import { readDVPLFile } from './readDVPLFile';
|
|
||||||
|
|
||||||
const ERROR_ON_UNKNOWN_COMPONENT = false;
|
const ERROR_ON_UNKNOWN_COMPONENT = false;
|
||||||
const MAX_FLOAT32 = 2 ** 127 * (2 - 2 ** -23);
|
|
||||||
|
|
||||||
export const vertexAttributeGLTFName: Partial<Record<VertexAttribute, string>> =
|
|
||||||
{
|
|
||||||
[VertexAttribute.VERTEX]: 'POSITION',
|
|
||||||
[VertexAttribute.NORMAL]: 'NORMAL',
|
|
||||||
[VertexAttribute.TEXCOORD0]: 'TEXCOORD_0',
|
|
||||||
[VertexAttribute.TEXCOORD1]: 'TEXCOORD_0',
|
|
||||||
[VertexAttribute.TEXCOORD2]: 'TEXCOORD_0',
|
|
||||||
[VertexAttribute.TEXCOORD3]: 'TEXCOORD_0',
|
|
||||||
[VertexAttribute.TANGENT]: 'TANGENT',
|
|
||||||
[VertexAttribute.JOINTINDEX]: 'JOINT_0',
|
|
||||||
[VertexAttribute.JOINTWEIGHT]: 'WEIGHT_0',
|
|
||||||
};
|
|
||||||
|
|
||||||
export const vertexAttributeGltfVectorSizes = {
|
|
||||||
...vertexAttributeVectorSizes,
|
|
||||||
|
|
||||||
[VertexAttribute.TANGENT]: 4,
|
|
||||||
} as const;
|
|
||||||
|
|
||||||
const omitMeshNames = {
|
const omitMeshNames = {
|
||||||
start: ['chassis_chassis_', 'chassis_track_crash_', 'HP_'],
|
start: ['chassis_chassis_', 'chassis_track_crash_', 'HP_'],
|
||||||
end: ['_POINT'],
|
end: ['_POINT'],
|
||||||
};
|
};
|
||||||
|
|
||||||
export async function extractModel(
|
export async function extractModel(data: string, path: string) {
|
||||||
data: string,
|
|
||||||
path: string,
|
|
||||||
baseColor?: Vector3Tuple,
|
|
||||||
) {
|
|
||||||
const sc2Path = `${data}/3d/${path}.sc2.dvpl`;
|
const sc2Path = `${data}/3d/${path}.sc2.dvpl`;
|
||||||
const scgPath = `${data}/3d/${path}.scg.dvpl`;
|
const scgPath = `${data}/3d/${path}.scg.dvpl`;
|
||||||
const sc2 = new Sc2ReadStream((await readDVPLFile(sc2Path)).buffer).sc2();
|
const sc2 = new Sc2ReadStream((await readDVPLFile(sc2Path)).buffer).sc2();
|
||||||
@@ -82,13 +57,11 @@ export async function extractModel(
|
|||||||
material.setBaseColorTexture(
|
material.setBaseColorTexture(
|
||||||
document
|
document
|
||||||
.createTexture(node.materialName)
|
.createTexture(node.materialName)
|
||||||
.setMimeType('image/png')
|
.setMimeType('image/jpeg')
|
||||||
.setImage(
|
.setImage(
|
||||||
await readTexture(
|
await readTexture(
|
||||||
`${data}/3d/${dirname(path)}/${textures.albedo}`,
|
`${data}/3d/${dirname(path)}/${textures.albedo}`,
|
||||||
baseColor
|
TextureMutation.Albedo,
|
||||||
? { mutation: TextureMutation.BaseColor, baseColor }
|
|
||||||
: undefined,
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@@ -97,11 +70,11 @@ export async function extractModel(
|
|||||||
material.setMetallicRoughnessTexture(
|
material.setMetallicRoughnessTexture(
|
||||||
document
|
document
|
||||||
.createTexture(node.materialName)
|
.createTexture(node.materialName)
|
||||||
.setMimeType('image/png')
|
.setMimeType('image/jpeg')
|
||||||
.setImage(
|
.setImage(
|
||||||
await readTexture(
|
await readTexture(
|
||||||
`${data}/3d/${dirname(path)}/${textures.baseRMMap}`,
|
`${data}/3d/${dirname(path)}/${textures.baseRMMap}`,
|
||||||
{ mutation: TextureMutation.RoughnessMetallicness },
|
TextureMutation.RoughnessMetallicness,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@@ -113,13 +86,13 @@ export async function extractModel(
|
|||||||
material.setNormalTexture(
|
material.setNormalTexture(
|
||||||
document
|
document
|
||||||
.createTexture(node.materialName)
|
.createTexture(node.materialName)
|
||||||
.setMimeType('image/png')
|
.setMimeType('image/jpeg')
|
||||||
.setImage(
|
.setImage(
|
||||||
await readTexture(
|
await readTexture(
|
||||||
`${data}/3d/${dirname(path)}/${
|
`${data}/3d/${dirname(path)}/${
|
||||||
textures.baseNormalMap ?? textures.normalmap
|
textures.baseNormalMap ?? textures.normalmap
|
||||||
}`,
|
}`,
|
||||||
isBase ? { mutation: TextureMutation.Normal } : undefined,
|
isBase ? TextureMutation.Normal : undefined,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@@ -129,11 +102,11 @@ export async function extractModel(
|
|||||||
material.setOcclusionTexture(
|
material.setOcclusionTexture(
|
||||||
document
|
document
|
||||||
.createTexture(node.materialName)
|
.createTexture(node.materialName)
|
||||||
.setMimeType('image/png')
|
.setMimeType('image/jpeg')
|
||||||
.setImage(
|
.setImage(
|
||||||
await readTexture(
|
await readTexture(
|
||||||
`${data}/3d/${dirname(path)}/${textures.miscMap}`,
|
`${data}/3d/${dirname(path)}/${textures.miscMap}`,
|
||||||
{ mutation: TextureMutation.Miscellaneous },
|
TextureMutation.Miscellaneous,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
export type BlitzResponse<Data extends object> =
|
type BlitzResponse<Data extends object> =
|
||||||
| {
|
| {
|
||||||
status: 'error';
|
status: 'error';
|
||||||
error: { field: string; message: string; code: 402; value: null };
|
error: { field: string; message: string; code: 402; value: null };
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import fetchBlitz from './fetchBlitz';
|
|||||||
import { normalizeExtra } from './normalizeExtra';
|
import { normalizeExtra } from './normalizeExtra';
|
||||||
import { normalizeIds } from './normalizeIds';
|
import { normalizeIds } from './normalizeIds';
|
||||||
|
|
||||||
export type IndividualClanAccountInfo = {
|
type IndividualClanAccountInfo = {
|
||||||
account_id: number;
|
account_id: number;
|
||||||
joined_at: number;
|
joined_at: number;
|
||||||
clan_id: number;
|
clan_id: number;
|
||||||
@@ -21,7 +21,7 @@ export type IndividualClanAccountInfo = {
|
|||||||
};
|
};
|
||||||
} | null;
|
} | null;
|
||||||
|
|
||||||
export interface ClanAccountInfo {
|
interface ClanAccountInfo {
|
||||||
[accountId: number]: IndividualClanAccountInfo;
|
[accountId: number]: IndividualClanAccountInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { WARGAMING_APPLICATION_ID } from '../../constants/wargamingApplicationID
|
|||||||
import fetchBlitz from './fetchBlitz';
|
import fetchBlitz from './fetchBlitz';
|
||||||
import { normalizeIds } from './normalizeIds';
|
import { normalizeIds } from './normalizeIds';
|
||||||
|
|
||||||
export interface IndividualClanInfo {
|
interface IndividualClanInfo {
|
||||||
recruiting_options: {
|
recruiting_options: {
|
||||||
vehicles_level: number;
|
vehicles_level: number;
|
||||||
wins_ratio: number;
|
wins_ratio: number;
|
||||||
@@ -32,7 +32,7 @@ export interface IndividualClanInfo {
|
|||||||
description: string;
|
description: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ClanInfo {
|
interface ClanInfo {
|
||||||
[clanId: number]: IndividualClanInfo;
|
[clanId: number]: IndividualClanInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,24 +2,27 @@ import { Locale } from 'discord.js';
|
|||||||
import { go } from 'fuzzysort';
|
import { go } from 'fuzzysort';
|
||||||
import markdownEscape from 'markdown-escape';
|
import markdownEscape from 'markdown-escape';
|
||||||
import { UserError } from '../../hooks/userError';
|
import { UserError } from '../../hooks/userError';
|
||||||
import {
|
import { tankDefinitions, tankNames } from '../blitzkrieg/tankDefinitions';
|
||||||
tankDefinitions,
|
import { tankNamesTechTreeOnly } from '../discord/autocompleteTanks';
|
||||||
tanksDefinitionsArray,
|
|
||||||
} from '../blitzkrieg/tankDefinitions';
|
|
||||||
import { translator } from '../localization/translator';
|
import { translator } from '../localization/translator';
|
||||||
|
|
||||||
export default async function resolveTankId(
|
export default async function resolveTankId(
|
||||||
tank: string | number,
|
tank: string | number,
|
||||||
locale: Locale,
|
locale: Locale,
|
||||||
|
techTreeOnly = false,
|
||||||
) {
|
) {
|
||||||
const { translate } = translator(locale);
|
const { translate } = translator(locale);
|
||||||
const number = typeof tank === 'string' ? Number(tank) : tank;
|
const number = typeof tank === 'string' ? Number(tank) : tank;
|
||||||
|
|
||||||
if (Number.isNaN(number)) {
|
if (Number.isNaN(number)) {
|
||||||
const searchResult = go(`${tank}`, await tanksDefinitionsArray, {
|
const searchResult = go(
|
||||||
keys: ['name'],
|
`${tank}`,
|
||||||
limit: 1,
|
await (techTreeOnly ? tankNamesTechTreeOnly : tankNames),
|
||||||
});
|
{
|
||||||
|
keys: ['combined'],
|
||||||
|
limit: 1,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
if (searchResult.length === 0) {
|
if (searchResult.length === 0) {
|
||||||
throw new UserError(
|
throw new UserError(
|
||||||
|
|||||||
Loaded 100 of 168 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user