feat(store): sell multi-vehicle packs and localize country names

Offer the five three-vehicle packs and nine starter packs as bundles.
Grant their unowned vehicles and bonuses on purchase. Encode each
vehicle in an aircraftGift field and validate duplicate IDs and
vehicle assignments.

Read group labels from units.csv and country names from
_common_languages.csv. Use those names in packs and browser filters.

Type checking and local catalogue and price response checks passed.
In-game acceptance is pending.
This commit is contained in:
N0VAN0M4LY committed 2026-11-25 13:41:32 +08:00
1 parent 78f1857918
commit 259cd0f32c
12 files changed
+412 -104

No files matched your search

@@ -1,24 +1,26 @@
/**
* 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
*:
* lang/_common_languages.csv: country_usa, country_germany, ... country names
* lang/menu.csv: mainmenu/type_aircraft, 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 LABEL_FILES = ['lang/_common_languages.csv', 'lang/menu.csv'] as const;
const KEY_PREFIXES = ['country_', 'mainmenu/type_'];
export type UiLabels = Readonly<Record<string, LocalizedCsvText>>;
export const uiLabels: Dataset<UiLabels> = {
id: 'ui-labels',
version: 1,
version: 2,
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;
for (const file of LABEL_FILES) {
for (const [key, text] of parseLocalizedCsvMap(source.readText('lang.vromfs.bin', file))) {
if (KEY_PREFIXES.some((prefix) => key.startsWith(prefix))) labels[key] = text;
}
}
return labels;
},
@@ -14,7 +14,7 @@ export type UnitNamesMap = Readonly<Record<string, LocalizedText>>;
export const unitNames: Dataset<UnitNamesMap> = {
id: 'unit-names',
version: 1,
version: 2,
extract: (source) => {
const lines = source.readText('lang.vromfs.bin', UNITS_CSV).split(/\r?\n/);
const header = parseSemicolonCsvRow(lines[0] ?? '');
@@ -24,28 +24,35 @@ export const unitNames: Dataset<UnitNamesMap> = {
const shopNames = new Map<string, LocalizedText>();
const fullNames = new Map<string, LocalizedText>();
const groupNames = new Map<string, LocalizedText>();
for (let i = 1; i < lines.length; i++) {
const line = lines[i]!;
if (!line.startsWith('"')) continue;
const firstSemi = line.indexOf(';');
if (firstSemi <= 2) continue;
const key = line.slice(1, firstSemi - 1);
const isShop = key.endsWith('_shop');
const isFull = !isShop && key.endsWith('_0');
if (!isShop && !isFull) continue;
const isGroup = key.startsWith('shop/group/');
const isShop = !isGroup && key.endsWith('_shop');
const isFull = !isGroup && !isShop && key.endsWith('_0');
if (!isGroup && !isShop && !isFull) continue;
const cols = parseSemicolonCsvRow(line);
const en = cleanLangText(cols[enCol] ?? '');
if (!en) continue;
const zh = cleanLangText((hzhCol >= 0 ? cols[hzhCol] : '') || (zhCol >= 0 ? cols[zhCol] : '') || en);
const unitId = key.slice(0, isShop ? -5 : -2);
if (isShop) shopNames.set(unitId, { en, zh });
else fullNames.set(unitId, { en, zh });
if (isGroup) {
groupNames.set(key, { en, zh });
} else {
const unitId = key.slice(0, isShop ? -5 : -2);
if (isShop) shopNames.set(unitId, { en, zh });
else fullNames.set(unitId, { en, zh });
}
}
const result: Record<string, LocalizedText> = {};
for (const [unitId, text] of fullNames) result[unitId] = text;
for (const [unitId, text] of shopNames) result[unitId] = text;
for (const [groupKey, text] of groupNames) result[groupKey] = text;
return result;
},
};