mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-21 10:47:04 +02:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
72c4cd664b | ||
|
|
f907c79d68 | ||
|
|
ae3d0a08cd | ||
|
|
fb66027de0 |
No files matched your search
@@ -0,0 +1,12 @@
|
|||||||
|
# Blitzkrieg 1.9.4
|
||||||
|
|
||||||
|
Haha, I lied. More fixes.
|
||||||
|
|
||||||
|
## Fixes
|
||||||
|
|
||||||
|
- Tank names once again show when searching for tank stats
|
||||||
|
- Tier weights now ignore tanks without entries in the `tankopedia`
|
||||||
|
|
||||||
|
## Technical Changes
|
||||||
|
|
||||||
|
- All `tankopedia` derivatives are now promises
|
||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "blitzkrieg",
|
"name": "blitzkrieg",
|
||||||
"version": "1.9.3",
|
"version": "1.9.4",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "src/server.ts",
|
"main": "src/server.ts",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ export const searchTanksCommand: CommandRegistry = {
|
|||||||
async handler(interaction) {
|
async handler(interaction) {
|
||||||
const tank = interaction.options.getString('tank')!;
|
const tank = interaction.options.getString('tank')!;
|
||||||
const limit = interaction.options.getInteger('limit') ?? 25;
|
const limit = interaction.options.getInteger('limit') ?? 25;
|
||||||
const results = go(tank, TANK_NAMES, { limit }).map(
|
const results = go(tank, await TANK_NAMES, { limit }).map(
|
||||||
(result) => result.target,
|
(result) => result.target,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ export default async function resolveTankId(tank: string) {
|
|||||||
const number = parseInt(tank);
|
const number = parseInt(tank);
|
||||||
|
|
||||||
if (Number.isNaN(number)) {
|
if (Number.isNaN(number)) {
|
||||||
const searchResult = go(tank, TANKS, { keys: ['name'], limit: 1 });
|
const searchResult = go(tank, await TANKS, { keys: ['name'], limit: 1 });
|
||||||
|
|
||||||
if (searchResult.length === 0) {
|
if (searchResult.length === 0) {
|
||||||
throw throwError(
|
throw throwError(
|
||||||
|
|||||||
@@ -23,10 +23,15 @@ export const tankopedia = fetch('https://www.blitzstars.com/bs-tankopedia.json')
|
|||||||
console.log('Tankopedia cached');
|
console.log('Tankopedia cached');
|
||||||
return (wrapperTankopedia as { data: Tankopedia }).data;
|
return (wrapperTankopedia as { data: Tankopedia }).data;
|
||||||
});
|
});
|
||||||
const entries = Object.entries(tankopedia);
|
const entries = new Promise<TankopediaEntry[]>(async (resolve) => {
|
||||||
export const TANK_IDS = entries.map(([, { tank_id }]) => tank_id as number);
|
resolve(Object.entries(await tankopedia).map(([, entry]) => entry));
|
||||||
export const TANKS = entries.map(([, entry]) => entry as TankopediaEntry);
|
});
|
||||||
export const TANK_NAMES = entries.map(([, { name }]) => name);
|
export const TANKS = new Promise<TankopediaEntry[]>(async (resolve) => {
|
||||||
|
resolve((await entries).map((entry) => entry));
|
||||||
|
});
|
||||||
|
export const TANK_NAMES = new Promise<string[]>(async (resolve) => {
|
||||||
|
resolve((await entries).map(({ name }) => name));
|
||||||
|
});
|
||||||
|
|
||||||
export const TANK_ICONS: Record<TankType, string> = {
|
export const TANK_ICONS: Record<TankType, string> = {
|
||||||
'AT-SPG': 'https://i.imgur.com/BIHSEH0.png',
|
'AT-SPG': 'https://i.imgur.com/BIHSEH0.png',
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ export default async function autocompleteTanks(
|
|||||||
await interaction.respond(
|
await interaction.respond(
|
||||||
focusedOption.value
|
focusedOption.value
|
||||||
? await Promise.all(
|
? await Promise.all(
|
||||||
go(focusedOption.value, TANKS, { keys: ['name'], limit: 10 }).map(
|
go(focusedOption.value, await TANKS, { keys: ['name'], limit: 10 }).map(
|
||||||
async (item) =>
|
async (item) =>
|
||||||
({
|
({
|
||||||
name: item.obj.name
|
name: item.obj.name
|
||||||
|
|||||||
@@ -107,6 +107,10 @@ export default async function statsfull<Type extends StatType>(
|
|||||||
tierWeights = await entries.reduce<PossiblyPromise<TierWeightsRecord>>(
|
tierWeights = await entries.reduce<PossiblyPromise<TierWeightsRecord>>(
|
||||||
async (accumulator, [tankIdString, stats]) => {
|
async (accumulator, [tankIdString, stats]) => {
|
||||||
const tankId = parseInt(tankIdString);
|
const tankId = parseInt(tankIdString);
|
||||||
|
const tankopediaEntry = (await tankopedia)[tankId];
|
||||||
|
|
||||||
|
if (!tankopediaEntry) return accumulator;
|
||||||
|
|
||||||
const tier = (await tankopedia)[tankId].tier as Tier;
|
const tier = (await tankopedia)[tankId].tier as Tier;
|
||||||
|
|
||||||
if ((await accumulator)[tier]) {
|
if ((await accumulator)[tier]) {
|
||||||
|
|||||||
Reference in new issue
Block a user