Implement vehicle research and purchases
Recompute unlocked ranks, prerequisites, and unit states before serving profiles. Add research target selection, research conversion, vehicle and slot purchases, and the price table. Support editing convertible RP and restrict hidden vehicle visibility to eligible entries. The client still displays zero purchase prices pending price table integration.
This commit is contained in:
1 parent
8b31277c58
commit
7a08fff85e
37 files changed
+1336
-75
No files matched your search
@@ -3,22 +3,19 @@
|
||||
* 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>]
|
||||
* --player <login or user id> [--silver <n>] [--gold <n>] [--free-rp <n>]
|
||||
*
|
||||
* Without --silver / --gold it only prints the balance. The edit is written to the save; the
|
||||
* --free-rp sets the free research points. Without any amount 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';
|
||||
import { freeResearchPoints, setFreeResearchPoints } from './profile/profile-research-points.ts';
|
||||
import { setUpProfiles } from './profiles-setup.ts';
|
||||
|
||||
function main(): number {
|
||||
const { values } = parseArgs({
|
||||
@@ -28,16 +25,18 @@ function main(): number {
|
||||
player: { type: 'string' },
|
||||
silver: { type: 'string' },
|
||||
gold: { type: 'string' },
|
||||
'free-rp': { 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>]');
|
||||
console.error('usage: save-cli.ts --game <game folder> --data <data folder> --player <login or user id> [--silver <n>] [--gold <n>] [--free-rp <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');
|
||||
const freeRp = optionalAmount(values['free-rp']);
|
||||
if (silver === null || gold === null || freeRp === null) {
|
||||
console.error('--silver, --gold and --free-rp take a whole number of 0 or more');
|
||||
return 2;
|
||||
}
|
||||
|
||||
@@ -49,17 +48,17 @@ function main(): number {
|
||||
}
|
||||
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 { profiles } = setUpProfiles(values.data, gameFiles, datasets);
|
||||
|
||||
const profile = silver === undefined && gold === undefined
|
||||
const profile = silver === undefined && gold === undefined && freeRp === undefined
|
||||
? profiles.profileOf(account.userId)
|
||||
: profiles.update(account.userId, (saved) => {
|
||||
if (silver !== undefined) setSilverLions(saved, silver);
|
||||
if (gold !== undefined) setGoldenEagles(saved, gold);
|
||||
if (freeRp !== undefined) setFreeResearchPoints(saved, freeRp);
|
||||
});
|
||||
const balance = balanceOf(profile);
|
||||
console.log(`${account.login} (${account.userId}): ${balance.silverLions} silver lions, ${balance.goldenEagles} golden eagles`);
|
||||
console.log(`${account.login} (${account.userId}): ${balance.silverLions} silver lions, ${balance.goldenEagles} golden eagles, ${freeResearchPoints(profile)} free research points`);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user