feat(store): open store pages in-game and centralize economy tuning
Use the native embedded browser and pass the game language through auto_local. Share web assets and extract vehicle icons, flags, and localized names from the installed client. Load and validate per-domain JSONC tuning and merge local overrides by field. Use official store USD prices for GJN products, keep GJN balances in integer cents, and split the native and web store handlers by protocol. Multi-vehicle packs are still listed as single vehicles at this point. Type checking, patch checks, and configuration loading passed. In-game acceptance is pending.
This commit is contained in:
1 parent
8d9cca9d05
commit
9cf7df5299
74 files changed
+2904
-1455
No files matched your search
@@ -33,37 +33,43 @@ export interface ClanEconomy {
|
||||
|
||||
export const clanEconomy: Dataset<ClanEconomy> = {
|
||||
id: 'clan-economy',
|
||||
version: 2,
|
||||
version: 3,
|
||||
extract: (source) => {
|
||||
const wp = source.readBlk('char.vromfs.bin', WARPOINTS);
|
||||
const required = (key: string): number => {
|
||||
const value = numberField(wp, key);
|
||||
if (value === undefined) throw new Error(`${WARPOINTS} has no ${key}; this game build differs from the verified ones`);
|
||||
return value;
|
||||
};
|
||||
// scripts/clans/clanType.nut reads these costs as `blk?[name] ?? 0`; 2.61.0.37 has no
|
||||
// clanCreateWPCost, costWPPrimaryInfo or costWPSecondaryInfo, so they are 0 there too.
|
||||
const clientDefaultZero = (key: string): number => numberField(wp, key) ?? 0;
|
||||
return {
|
||||
normalCreateGold: numberField(wp, 'clanCreateGoldCost') ?? 2500,
|
||||
normalCreateSilver: numberField(wp, 'clanCreateWPCost') ?? 0,
|
||||
normalPrimaryEditGold: numberField(wp, 'costGoldPrimaryInfo') ?? 2500,
|
||||
normalPrimaryEditSilver: numberField(wp, 'costWPPrimaryInfo') ?? 0,
|
||||
normalSecondaryEditGold: numberField(wp, 'costGoldSecondaryInfo') ?? 0,
|
||||
normalSecondaryEditSilver: numberField(wp, 'costWPSecondaryInfo') ?? 0,
|
||||
battalionCreateGold: numberField(wp, 'battalionCreateGoldCost') ?? 0,
|
||||
battalionCreateSilver: numberField(wp, 'battalionCreateWPCost') ?? 1_000_000,
|
||||
battalionPrimaryEditGold: numberField(wp, 'battalionCostGoldPrimaryInfo') ?? 0,
|
||||
battalionPrimaryEditSilver: numberField(wp, 'battalionCostWPPrimaryInfo') ?? 1_000_000,
|
||||
battalionSecondaryEditGold: numberField(wp, 'battalionCostGoldSecondaryInfo') ?? 0,
|
||||
battalionSecondaryEditSilver: numberField(wp, 'battalionCostWPSecondaryInfo') ?? 0,
|
||||
battalionMembersUpgradeGold: numberField(wp, 'battalionMembersUpgradeCost') ?? 225,
|
||||
battalionMembersUpgradeStep: numberField(wp, 'battalionMembersUpgradeStep') ?? 10,
|
||||
battalionMembersUpgradeLimit: numberField(wp, 'battalionMembersUpgradeLimit') ?? 110,
|
||||
upgradeBattalionToNormalGold: numberField(wp, 'clanUpgradeCostGoldBattalionToNormal') ?? 2500,
|
||||
upgradeBattalionToNormalSilver: numberField(wp, 'clanUpgradeCostWPBattalionToNormal') ?? 0,
|
||||
normalFreeDecorators: readDecorList(findBlock(wp, 'clanTagDecorators'), ['--', '..', '==', '^^', '[]']),
|
||||
battalionFreeDecorators: readDecorList(findBlock(wp, 'battalionTagDecorators'), ['**']),
|
||||
normalCreateGold: required('clanCreateGoldCost'),
|
||||
normalCreateSilver: clientDefaultZero('clanCreateWPCost'),
|
||||
normalPrimaryEditGold: clientDefaultZero('costGoldPrimaryInfo'),
|
||||
normalPrimaryEditSilver: clientDefaultZero('costWPPrimaryInfo'),
|
||||
normalSecondaryEditGold: required('costGoldSecondaryInfo'),
|
||||
normalSecondaryEditSilver: clientDefaultZero('costWPSecondaryInfo'),
|
||||
battalionCreateGold: required('battalionCreateGoldCost'),
|
||||
battalionCreateSilver: clientDefaultZero('battalionCreateWPCost'),
|
||||
battalionPrimaryEditGold: clientDefaultZero('battalionCostGoldPrimaryInfo'),
|
||||
battalionPrimaryEditSilver: required('battalionCostWPPrimaryInfo'),
|
||||
battalionSecondaryEditGold: required('battalionCostGoldSecondaryInfo'),
|
||||
battalionSecondaryEditSilver: required('battalionCostWPSecondaryInfo'),
|
||||
battalionMembersUpgradeGold: required('battalionMembersUpgradeCost'),
|
||||
battalionMembersUpgradeStep: required('battalionMembersUpgradeStep'),
|
||||
battalionMembersUpgradeLimit: required('battalionMembersUpgradeLimit'),
|
||||
upgradeBattalionToNormalGold: required('clanUpgradeCostGoldBattalionToNormal'),
|
||||
upgradeBattalionToNormalSilver: clientDefaultZero('clanUpgradeCostWPBattalionToNormal'),
|
||||
normalFreeDecorators: readDecorList(wp, 'clanTagDecorators'),
|
||||
battalionFreeDecorators: readDecorList(wp, 'battalionTagDecorators'),
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
function readDecorList(block: BlkBlock | undefined, fallback: readonly string[]): readonly string[] {
|
||||
if (!block) return fallback;
|
||||
const values = block.params
|
||||
.filter((p) => p.name === 'decor' && p.value.type === 'string')
|
||||
.map((p) => (p.value as { type: 'string'; value: string }).value);
|
||||
return values.length > 0 ? values : fallback;
|
||||
function readDecorList(wp: BlkBlock, blockName: string): readonly string[] {
|
||||
const block = findBlock(wp, blockName);
|
||||
if (!block) throw new Error(`${WARPOINTS} has no ${blockName}; this game build differs from the verified ones`);
|
||||
return block.params.flatMap((p) => (p.name === 'decor' && p.value.type === 'string' ? [p.value.value] : []));
|
||||
}
|
||||
@@ -6,11 +6,10 @@
|
||||
* scripts/shop/shopCountriesList.nut, updateShopCountriesList).
|
||||
*/
|
||||
import type { Dataset } from './dataset.ts';
|
||||
|
||||
const SHOP = 'config/shop.blk';
|
||||
import { shopCountryNames } from './shop-tree.ts';
|
||||
|
||||
export const shopCountries: Dataset<readonly string[]> = {
|
||||
id: 'shop-countries',
|
||||
version: 1,
|
||||
extract: (source) => source.readBlk('char.vromfs.bin', SHOP).blocks.map((block) => block.name),
|
||||
extract: shopCountryNames,
|
||||
};
|
||||
@@ -0,0 +1,27 @@
|
||||
/**
|
||||
* Walk char.vromfs.bin config/shop.blk: one top-level block per country, below it branches,
|
||||
* columns, groups and vehicles. Shared by the datasets that need the
|
||||
* per-vehicle shop entries.
|
||||
*/
|
||||
import type { BlkBlock } from '@wto/blk';
|
||||
import type { DatasetSource } from './dataset.ts';
|
||||
|
||||
export const SHOP = 'config/shop.blk';
|
||||
|
||||
/** Every shop entry by name; the first entry wins when a name repeats. Non-vehicle entries are included and simply never looked up. */
|
||||
export function shopEntriesByName(source: DatasetSource): Map<string, BlkBlock> {
|
||||
const entries = new Map<string, BlkBlock>();
|
||||
for (const country of source.readBlk('char.vromfs.bin', SHOP).blocks) {
|
||||
for (const entry of entriesBelow(country)) if (!entries.has(entry.name)) entries.set(entry.name, entry);
|
||||
}
|
||||
return entries;
|
||||
}
|
||||
|
||||
/** The countries in tech-tree order (the top-level block names). */
|
||||
export function shopCountryNames(source: DatasetSource): string[] {
|
||||
return source.readBlk('char.vromfs.bin', SHOP).blocks.map((block) => block.name);
|
||||
}
|
||||
|
||||
function entriesBelow(block: BlkBlock): BlkBlock[] {
|
||||
return block.blocks.flatMap((child) => [child, ...entriesBelow(child)]);
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
/**
|
||||
* Dataset: the game's own names for countries and vehicle types, from lang.vromfs.bin
|
||||
* lang/menu.csv, for the local web pages:
|
||||
* country_usa, country_germany, ... country names
|
||||
* mainmenu/type_aircraft, mainmenu/type_tank, ... vehicle type names
|
||||
*/
|
||||
import type { Dataset } from './dataset.ts';
|
||||
import { parseLocalizedCsvMap, type LocalizedCsvText } from './lang-csv.ts';
|
||||
|
||||
const MENU_CSV = 'lang/menu.csv';
|
||||
const KEY_PREFIXES = ['country_', 'mainmenu/type_'];
|
||||
|
||||
export type UiLabels = Readonly<Record<string, LocalizedCsvText>>;
|
||||
|
||||
export const uiLabels: Dataset<UiLabels> = {
|
||||
id: 'ui-labels',
|
||||
version: 1,
|
||||
extract: (source) => {
|
||||
const labels: Record<string, LocalizedCsvText> = {};
|
||||
for (const [key, text] of parseLocalizedCsvMap(source.readText('lang.vromfs.bin', MENU_CSV))) {
|
||||
if (KEY_PREFIXES.some((prefix) => key.startsWith(prefix))) labels[key] = text;
|
||||
}
|
||||
return labels;
|
||||
},
|
||||
};
|
||||
@@ -25,9 +25,9 @@
|
||||
import type { BlkBlock } from '@wto/blk';
|
||||
import { boolField, numberField, stringField } from './blk-fields.ts';
|
||||
import type { Dataset } from './dataset.ts';
|
||||
import { shopEntriesByName } from './shop-tree.ts';
|
||||
|
||||
const VEHICLE_ECONOMY = 'config/wpcost.blk';
|
||||
const SHOP = 'config/shop.blk';
|
||||
|
||||
export interface CatalogueVehicle {
|
||||
readonly name: string;
|
||||
@@ -64,10 +64,7 @@ export const vehicleCatalogue: Dataset<readonly CatalogueVehicle[]> = {
|
||||
id: 'vehicle-catalogue',
|
||||
version: 4,
|
||||
extract: (source) => {
|
||||
const shopEntries = new Map<string, BlkBlock>();
|
||||
for (const country of source.readBlk('char.vromfs.bin', SHOP).blocks) {
|
||||
for (const entry of entriesBelow(country)) if (!shopEntries.has(entry.name)) shopEntries.set(entry.name, entry);
|
||||
}
|
||||
const shopEntries = shopEntriesByName(source);
|
||||
return source.readBlk('char.vromfs.bin', VEHICLE_ECONOMY).blocks.map((vehicle) => catalogueVehicle(vehicle, shopEntries.get(vehicle.name)));
|
||||
},
|
||||
};
|
||||
@@ -99,8 +96,3 @@ function catalogueVehicle(vehicle: BlkBlock, shopEntry: BlkBlock | undefined): C
|
||||
minOpenCostGold: numberField(vehicle, 'minOpenCostGold') ?? 0,
|
||||
};
|
||||
}
|
||||
|
||||
/** Every block below a country: branches, columns, groups and vehicles (non-vehicles have no wpcost entry and are never looked up). */
|
||||
function entriesBelow(block: BlkBlock): BlkBlock[] {
|
||||
return block.blocks.flatMap((child) => [child, ...entriesBelow(child)]);
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
/**
|
||||
* Dataset: the game's own SVG icons that the local web pages (store and marketplace, shown in
|
||||
* the in-game browser; implementation notes) display, taken from the player's
|
||||
* ui/atlases.vromfs.bin so nothing of Gaijin's is shipped with the service (local verification):
|
||||
* gameuiskin/<vehicle>_ico.svg the tech-tree silhouette of a vehicle
|
||||
* gameuiskin/<country>.svg a country flag (country_usa, ...)
|
||||
*
|
||||
* All 3349 vehicle icons together are about 26 MB, so only the vehicles the stock game sells
|
||||
* for real money are kept: gift vehicles (wpcost.blk gift:t, the store's packs) and
|
||||
* marketplace vehicles (shop.blk marketplaceItemdefId).
|
||||
*/
|
||||
import { numberField, stringField } from './blk-fields.ts';
|
||||
import type { Dataset } from './dataset.ts';
|
||||
import { shopCountryNames, shopEntriesByName } from './shop-tree.ts';
|
||||
|
||||
const ATLASES = 'ui/atlases.vromfs.bin';
|
||||
const VEHICLE_ECONOMY = 'config/wpcost.blk';
|
||||
const ICON_FOLDER = 'gameuiskin/';
|
||||
|
||||
export interface WebIcons {
|
||||
/** Vehicle name -> SVG text. */
|
||||
readonly vehicles: Readonly<Record<string, string>>;
|
||||
/** Country (country_usa, ...) -> SVG text. */
|
||||
readonly flags: Readonly<Record<string, string>>;
|
||||
}
|
||||
|
||||
export const webIcons: Dataset<WebIcons> = {
|
||||
id: 'web-icons',
|
||||
version: 1,
|
||||
extract: (source) => {
|
||||
const available = new Set(source.listFiles(ATLASES));
|
||||
const readIcon = (name: string): string | undefined => {
|
||||
const path = `${ICON_FOLDER}${name}.svg`;
|
||||
return available.has(path) ? source.readText(ATLASES, path) : undefined;
|
||||
};
|
||||
|
||||
const shopEntries = shopEntriesByName(source);
|
||||
const vehicles: Record<string, string> = {};
|
||||
for (const vehicle of source.readBlk('char.vromfs.bin', VEHICLE_ECONOMY).blocks) {
|
||||
const soldForMoney = stringField(vehicle, 'gift') !== undefined
|
||||
|| numberField(shopEntries.get(vehicle.name), 'marketplaceItemdefId') !== undefined;
|
||||
const icon = soldForMoney ? readIcon(`${vehicle.name}_ico`) : undefined;
|
||||
if (icon) vehicles[vehicle.name] = icon;
|
||||
}
|
||||
|
||||
const flags: Record<string, string> = {};
|
||||
for (const country of shopCountryNames(source)) {
|
||||
const flag = readIcon(country);
|
||||
if (flag) flags[country] = flag;
|
||||
}
|
||||
return { vehicles, flags };
|
||||
},
|
||||
};
|
||||
Reference in new issue
Block a user