feat(saves): seed new saves and reveal eligible hidden vehicles

Set initial Silver Lions and Golden Eagles balances and add a save
editing command. Open rank I for each nation and branch and migrate
older saves to format 3. Reveal eligible hidden vehicles while keeping
split air-defense launchers out of the tech tree.

Document the currency, rank, and unit status fields observed in the offline client.
This commit is contained in:
N0VAN0M4LY committed 2026-11-24 14:45:28 +08:00
1 parent ed0136f5fc
commit e5452e925f
12 files changed
+282 -12

No files matched your search

+72
View File
@@ -0,0 +1,72 @@
/**
* Development entry point for editing a save (the save editor of docs/implementation notes
* section A; the launcher will call the same profile functions).
*
* node packages/local-service/src/save-cli.ts --game <game folder> --data <data folder>
* --player <login or user id> [--silver <n>] [--gold <n>]
*
* Without --silver / --gold it only prints the balance. The edit is written to the save; the
* game shows it after its next profile update (any action, or signing in again).
*/
import { parseArgs } from 'node:util';
import { AccountStore } from './accounts/account-store.ts';
import { DatasetCache } from './game-data/datasets/dataset-cache.ts';
import { reserveVehicles } from './game-data/datasets/reserve-vehicles.ts';
import { shopBranches } from './game-data/datasets/shop-branches.ts';
import { GameFiles } from './game-data/game-files.ts';
import { PlayerProfiles } from './profile/player-profiles.ts';
import { balanceOf, setGoldenEagles, setSilverLions } from './profile/profile-currency.ts';
import { profileUpgrades } from './profile/profile-upgrades.ts';
import type { StartingContent } from './profile/starting-content.ts';
import { SaveStore } from './saves/save-store.ts';
function main(): number {
const { values } = parseArgs({
options: {
game: { type: 'string' },
data: { type: 'string' },
player: { type: 'string' },
silver: { type: 'string' },
gold: { type: 'string' },
},
});
if (!values.game || !values.data || !values.player) {
console.error('usage: save-cli.ts --game <game folder> --data <data folder> --player <login or user id> [--silver <n>] [--gold <n>]');
return 2;
}
const silver = optionalAmount(values.silver);
const gold = optionalAmount(values.gold);
if (silver === null || gold === null) {
console.error('--silver and --gold take a whole number of 0 or more');
return 2;
}
const accounts = new AccountStore(values.data);
const account = accounts.byLogin(values.player) ?? accounts.byUserId(values.player);
if (!account) {
console.error(`no player "${values.player}" in ${values.data}`);
return 1;
}
const gameFiles = new GameFiles(values.game);
const datasets = new DatasetCache(values.data, gameFiles, () => {});
const startingContent: StartingContent = { reserveVehicles: datasets.load(reserveVehicles), branches: datasets.load(shopBranches) };
const profiles = new PlayerProfiles(new SaveStore(values.data, profileUpgrades(startingContent)), gameFiles, startingContent);
const profile = silver === undefined && gold === undefined
? profiles.profileOf(account.userId)
: profiles.update(account.userId, (saved) => {
if (silver !== undefined) setSilverLions(saved, silver);
if (gold !== undefined) setGoldenEagles(saved, gold);
});
const balance = balanceOf(profile);
console.log(`${account.login} (${account.userId}): ${balance.silverLions} silver lions, ${balance.goldenEagles} golden eagles`);
return 0;
}
/** undefined when not given, null when not a valid amount. */
function optionalAmount(text: string | undefined): number | undefined | null {
if (text === undefined) return undefined;
return /^\d+$/.test(text) && Number.isSafeInteger(Number(text)) ? Number(text) : null;
}
process.exitCode = main();