order conumables

This commit is contained in:
tresabhi committed 2026-12-03 23:14:24 -06:00
1 parent 0e268288e6
commit b1fb689918
5 files changed
+37 -2

No files matched your search

+1
View File
@@ -31,6 +31,7 @@ Pages that are not migrated yet are named `_index.astro` so Astro skips them. Mi
- No return type annotations. Put `satisfies Type` on the returned expression instead. - No return type annotations. Put `satisfies Type` on the returned expression instead.
- Wrap functions defined inside React components in `useCallback`. - Wrap functions defined inside React components in `useCallback`.
- Never inline a complex type (a union of object shapes, etc.) in a signature; name it as an interface or type. - Never inline a complex type (a union of object shapes, etc.) in a signature; name it as an interface or type.
- A lookup table that is read by key and checked for missing keys is a `Map`, not an object literal.
- Use a string `enum` (`Page = "page"`) instead of a union of string literals (`"page" | "dialog"`) whenever the values can be enumerated. - Use a string `enum` (`Page = "page"`) instead of a union of string literals (`"page" | "dialog"`) whenever the values can be enumerated.
- In object literals, `...spread` entries come first, each on its own line, followed by a blank line, then the custom entries. A single-line object with a spread becomes multi-line. - In object literals, `...spread` entries come first, each on its own line, followed by a blank line, then the custom entries. A single-line object with a spread becomes multi-line.
- When an object literal's values are long expressions, compute them first into `const`s named after their keys, then build the object with shorthand (`{ name, color, tanks: [] }`). Short values stay inline. - When an object literal's values are long expressions, compute them first into `const`s named after their keys, then build the object with shorthand (`{ name, color, tanks: [] }`). Short values stay inline.
@@ -1,8 +1,19 @@
import { BlitzTankFilterDefinitionCategory } from "@blitzkit/core"; import { BlitzTankFilterDefinitionCategory } from "@blitzkit/core";
import { Consumable, ConsumableDefinitions } from "@blitzkit/protos"; import {
Consumable,
ConsumableCategory,
ConsumableDefinitions,
} from "@blitzkit/protos";
import { Cache } from "../cache"; import { Cache } from "../cache";
import { ServerBlitzKitAPI5 } from "./5_equipments"; import { ServerBlitzKitAPI5 } from "./5_equipments";
const CATEGORIES = new Map([
["free", ConsumableCategory.CONSUMABLE_CATEGORY_FREE],
["common", ConsumableCategory.CONSUMABLE_CATEGORY_COMMON],
["potent", ConsumableCategory.CONSUMABLE_CATEGORY_POTENT],
["radical", ConsumableCategory.CONSUMABLE_CATEGORY_RADICAL],
]);
export abstract class ServerBlitzKitAPI6 extends ServerBlitzKitAPI5 { export abstract class ServerBlitzKitAPI6 extends ServerBlitzKitAPI5 {
@Cache() @Cache()
async consumables() { async consumables() {
@@ -19,9 +30,21 @@ export abstract class ServerBlitzKitAPI6 extends ServerBlitzKitAPI5 {
(includeRaw !== undefined && (includeRaw !== undefined &&
"minLevel" in includeRaw && "minLevel" in includeRaw &&
includeRaw.minLevel > includeRaw.maxLevel); includeRaw.minLevel > includeRaw.maxLevel);
const category =
consumable.category === undefined
? ConsumableCategory.CONSUMABLE_CATEGORY_FREE
: CATEGORIES.get(consumable.category);
if (category === undefined) {
throw new SyntaxError(
`Unhandled consumable category ${consumable.category}`,
);
}
const entry: Consumable = { const entry: Consumable = {
id: consumable.id, id: consumable.id,
game_mode_exclusive, game_mode_exclusive,
category,
name: this.getString(consumable.userString), name: this.getString(consumable.userString),
exclude: [], exclude: [],
include: [], include: [],
+2 -1
View File
@@ -7,7 +7,8 @@ export interface ConsumablesCommon {
userString: string; userString: string;
description: string; description: string;
icon: string; icon: string;
category: string; // absent on built-in vehicle abilities
category?: string;
tags: string; tags: string;
vehicleFilter?: { vehicleFilter?: {
include: { vehicle: ConsumablesVehicleFilter; nations?: string }; include: { vehicle: ConsumablesVehicleFilter; nations?: string };
@@ -14,6 +14,15 @@ message Consumable {
bool game_mode_exclusive = 5; bool game_mode_exclusive = 5;
repeated TankInclusivityFilter include = 6; repeated TankInclusivityFilter include = 6;
repeated TankInclusivityFilter exclude = 7; repeated TankInclusivityFilter exclude = 7;
ConsumableCategory category = 8;
}
// ordered by in-game price, cheapest first
enum ConsumableCategory {
CONSUMABLE_CATEGORY_FREE = 0;
CONSUMABLE_CATEGORY_COMMON = 1;
CONSUMABLE_CATEGORY_POTENT = 2;
CONSUMABLE_CATEGORY_RADICAL = 3;
} }
message TankInclusivityFilter { message TankInclusivityFilter {
@@ -119,6 +119,7 @@ const consumablesArray = Object.values(consumableDefinitions.consumables)
!consumable.game_mode_exclusive && !consumable.game_mode_exclusive &&
consumable.name!.locales[locales.default], consumable.name!.locales[locales.default],
) )
.sort((a, b) => b.category - a.category)
.map((consumable) => consumable.id); .map((consumable) => consumable.id);
const provisionsArray = Array.from( const provisionsArray = Array.from(
Object.values(provisionDefinitions.provisions) Object.values(provisionDefinitions.provisions)