feat(profile): add unlock purchases and showcases

Load unlock prices from unlocks.blk and expose them in Common/unlocks.
Support purchasing unlocks and saving showcases, and count qualified
crews for the ace showcase.

Read charRequestBlk action parameters from HTTP headers and apply this
to cln_get_users_terse_info.
This commit is contained in:
N0VAN0M4LY committed 2026-11-25 02:49:13 +08:00
1 parent 1e7dc2447f
commit f463f3e325
14 files changed
+315 -13

No files matched your search

@@ -0,0 +1,32 @@
/**
* Dataset: the unlocks that can be bought: ship flags, profile icons
* and frames, awards, some achievements.
*
* char.vromfs.bin config/unlocks.blk: unlockable{ id:t type:t cost:i costGold:i mode{...} ... }.
* Only unlocks with a positive cost or costGold are recorded.
*/
import type { BlkBlock } from '@wto/blk';
import { numberField, stringField } from './blk-fields.ts';
import type { Dataset } from './dataset.ts';
const UNLOCKS = 'config/unlocks.blk';
export interface UnlockPrice {
readonly id: string;
readonly silverLions: number;
readonly goldenEagles: number;
}
export const unlockPrices: Dataset<readonly UnlockPrice[]> = {
id: 'unlock-prices',
version: 1,
extract: (source) => source.readBlk('char.vromfs.bin', UNLOCKS).blocks.flatMap(priceOf),
};
function priceOf(entry: BlkBlock): UnlockPrice[] {
const id = stringField(entry, 'id');
const silverLions = Math.max(0, numberField(entry, 'cost') ?? 0);
const goldenEagles = Math.max(0, numberField(entry, 'costGold') ?? 0);
if (id === undefined || (silverLions === 0 && goldenEagles === 0)) return [];
return [{ id, silverLions, goldenEagles }];
}