mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-12-04 23:32:54 +01:00
order conumables
This commit is contained in:
5 files changed
+37
-2
No files matched your search
@@ -1,8 +1,19 @@
|
||||
import { BlitzTankFilterDefinitionCategory } from "@blitzkit/core";
|
||||
import { Consumable, ConsumableDefinitions } from "@blitzkit/protos";
|
||||
import {
|
||||
Consumable,
|
||||
ConsumableCategory,
|
||||
ConsumableDefinitions,
|
||||
} from "@blitzkit/protos";
|
||||
import { Cache } from "../cache";
|
||||
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 {
|
||||
@Cache()
|
||||
async consumables() {
|
||||
@@ -19,9 +30,21 @@ export abstract class ServerBlitzKitAPI6 extends ServerBlitzKitAPI5 {
|
||||
(includeRaw !== undefined &&
|
||||
"minLevel" in includeRaw &&
|
||||
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 = {
|
||||
id: consumable.id,
|
||||
game_mode_exclusive,
|
||||
category,
|
||||
name: this.getString(consumable.userString),
|
||||
exclude: [],
|
||||
include: [],
|
||||
|
||||
@@ -7,7 +7,8 @@ export interface ConsumablesCommon {
|
||||
userString: string;
|
||||
description: string;
|
||||
icon: string;
|
||||
category: string;
|
||||
// absent on built-in vehicle abilities
|
||||
category?: string;
|
||||
tags: string;
|
||||
vehicleFilter?: {
|
||||
include: { vehicle: ConsumablesVehicleFilter; nations?: string };
|
||||
|
||||
@@ -14,6 +14,15 @@ message Consumable {
|
||||
bool game_mode_exclusive = 5;
|
||||
repeated TankInclusivityFilter include = 6;
|
||||
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 {
|
||||
|
||||
@@ -119,6 +119,7 @@ const consumablesArray = Object.values(consumableDefinitions.consumables)
|
||||
!consumable.game_mode_exclusive &&
|
||||
consumable.name!.locales[locales.default],
|
||||
)
|
||||
.sort((a, b) => b.category - a.category)
|
||||
.map((consumable) => consumable.id);
|
||||
const provisionsArray = Array.from(
|
||||
Object.values(provisionDefinitions.provisions)
|
||||
|
||||
Reference in new issue
Block a user