fix(training): persist tutorial completions and grant first-time rewards

On returning from a stock training mission, the client reports the outcome in
cln_update under missionAwards while sending an empty pveProgress block. Because
the local server did not record this completion, the hangar repeated tutorial
prompts after restart and never credited first-completion rewards.

Add a cached training-missions dataset (config/mislist.blk,
config/pve_awards.blk, config/unlocks.blk), pure completion rules in
TrainingCatalogue, and missionAwards parsing in clientUpdateAction. Completed
tutorials now persist pveProgress/missions and grant per-mission decals, the
shared first-basic-tutorial Golden Eagles unlock, and per-difficulty first-win
Silver Lions once per account during cln_update before replying.

Credit to duduyagame for identifying the cln_update missionAwards reporting flow
and stock reward definitions (PR #6).

Checks: root `npm run typecheck` passed; verified training-missions dataset
extraction/caching and TrainingCatalogue idempotency against read-only stock
2.61.0.37 files in a temporary data folder. In-game acceptance pending on an
isolated client copy.

Co-authored-by: duduyagame <[email protected]>
This commit is contained in:
N0VAN0M4LYandduduyagame committed 2026-12-03 05:23:18 +08:00
1 parent 42b8275151
commit 4e99d2c484
6 files changed
+240 -8

No files matched your search

+3 -1
View File
@@ -12,6 +12,7 @@ import type { EquipmentCatalogue } from '../../modifications/equipment-catalogue
import type { PlayerProfiles } from '../../profile/player-profiles.ts';
import type { ResearchRules } from '../../research/research-rules.ts';
import type { StoreCatalogue } from '../../store/store-catalogue.ts';
import type { TrainingCatalogue } from '../../training/training-completion.ts';
import type { UnlockShop } from '../../unlocks/unlock-purchase.ts';
import type { CharActionHandler } from '../char-action.ts';
import { acceptEula } from './agreement-actions.ts';
@@ -94,6 +95,7 @@ export interface ActionDependencies {
readonly store: StoreCatalogue;
readonly inventory: InventoryCatalogue;
readonly trophies: TrophyCatalogue;
readonly training?: TrainingCatalogue;
readonly clans?: ClanActionDependencies;
readonly cloudSettings?: CloudSettingsStore;
readonly battle?: BattleActionDependencies;
@@ -118,7 +120,7 @@ function coreActionEntries(deps: ActionDependencies): Array<[string, CharActionH
['cln_get_initial_meta', initialMeta(deps.accounts, deps.cloudSettings)],
['cln_upd_entitlements_full', entitlementsFull(deps.profiles, deps.accounts)],
['cln_legacy_get_userdata', legacyUserData(deps.profiles, deps.accounts)],
['cln_update', clientUpdateAction(deps.profiles, deps.accounts)],
['cln_update', clientUpdateAction(deps.profiles, deps.accounts, deps.training)],
['cln_accept_eula', acceptEula(deps.profiles, deps.accounts)],
['cln_set_starting_info', setStartingInfo(deps.profiles, deps.accounts)],
['cln_bulk_train_aircraft', bulkTrainCrews(deps.profiles, deps.accounts, deps.crew)],
@@ -2,19 +2,48 @@
* `cln_update` (aces.exe 2.61.0.37 0x29f3ee, job type 3 -> `onUpdateProfile`):
* triggered by `save_online_single_job` when the client marks seen user logs as disabled
* (`scripts/userLog/userlogUtils.nut` `disableSeenUserlogs`, tag 223) or updates hangar
* auto-repair / auto-refill / auto-buy-modifications and map preferences. Answers the whole
* updated profile.
* auto-repair / auto-refill / auto-buy-modifications and map preferences. On returning from
* a stock training mission, the client also reports completion in `missionAwards` while
* `pveProgress` is empty. Answers the whole updated profile.
*/
import { findBlock, findParam, type BlkBlock } from '@wto/blk';
import type { AccountStore } from '../../accounts/account-store.ts';
import { boolField, stringField } from '../../game-data/datasets/blk-fields.ts';
import { applyClientProfileUpdate } from '../../profile/profile-client-settings.ts';
import type { PlayerProfiles } from '../../profile/player-profiles.ts';
import { ACCEPTED } from '../../research/rule-outcome.ts';
import type { TrainingCatalogue, TrainingCompletionReport } from '../../training/training-completion.ts';
import type { CharActionHandler } from '../char-action.ts';
import { ruleAction } from './rule-answer.ts';
export function clientUpdateAction(profiles: PlayerProfiles, accounts: AccountStore): CharActionHandler {
return ruleAction(profiles, accounts, (payload) => (profile) => {
applyClientProfileUpdate(profile, payload);
return ACCEPTED;
export function clientUpdateAction(
profiles: PlayerProfiles,
accounts: AccountStore,
training?: TrainingCatalogue,
): CharActionHandler {
return ruleAction(profiles, accounts, (payload) => {
const completion = training ? readTrainingCompletion(payload) : undefined;
return (profile) => {
applyClientProfileUpdate(profile, payload);
if (completion && training) training.applyCompletion(profile, completion);
return ACCEPTED;
};
});
}
function readTrainingCompletion(request: BlkBlock): TrainingCompletionReport | undefined {
const awards = findBlock(request, 'missionAwards');
if (!awards
|| stringField(awards, 'gameModeName') !== 'training'
|| boolField(awards, 'success') !== true
|| boolField(awards, 'early') !== false
|| boolField(awards, 'onlineGame') !== false) return undefined;
const chapter = stringField(awards, 'chapterName');
const mission = stringField(awards, 'missionName');
const difficulty = findParam(awards, 'difficulty')?.value;
if (!chapter || !mission || difficulty?.type !== 'int'
|| (difficulty.value !== 0 && difficulty.value !== 1 && difficulty.value !== 2)) return undefined;
return { chapter, mission, difficulty: difficulty.value };
}