fix(battle): exclude mission support planes from settlement

Online the time flown in the nuclear carrier (gameplay.blk
missionSupportPlane) and its kills are not settled, while other aircraft
are. Its lives were settled like any vehicle when it was spawned from
the lineup slot: battle time, research points and repair for a unit the
player does not own.

Collect the support plane units from missionSupportPlane and drop their
lives and combat events from the battle facts before the settlement and
the live award judging. The nuclear strike fact and its award are kept.

Checked with typecheck; not yet verified in game.
This commit is contained in:
N0VAN0M4LY committed 2026-11-28 22:25:19 +08:00
1 parent 426dcf8adc
commit 394091e518
4 files changed
+40 -6

No files matched your search

@@ -0,0 +1,26 @@
/**
* The mission support planes (gameplay.blk missionSupportPlane, the nuclear carriers: the unit the
* action bar launches and the lineup's support plane slot spawns) earn nothing in a battle: online
* the time flown in one and its kills are not settled, other aircraft are (player observation of
* the live game). Their lives and combat events are taken out of the battle facts before awards
* and the settlement; the nuclear strike itself is a separate fact and stays.
*/
import type { BattleSpawnRulesData } from '../game-data/datasets/battle-spawn-rules.ts';
import type { BattleLife, ReportedCombatEvent } from './battle-report.ts';
export function supportPlaneUnits(rules: Pick<BattleSpawnRulesData, 'supportPlanes'>): ReadonlySet<string> {
return new Set(Object.values(rules.supportPlanes).flatMap((presets) =>
presets.flatMap((preset) => Object.values(preset.units).map((unit) => unit.unitName))));
}
/** The facts without the support planes' lives and combat events. */
export function withoutSupportPlanes<T extends { readonly lives: readonly BattleLife[]; readonly events: readonly ReportedCombatEvent[] }>(
facts: T,
supportPlanes: ReadonlySet<string>,
): T {
return {
...facts,
lives: facts.lives.filter((life) => !supportPlanes.has(life.unit)),
events: facts.events.filter((event) => !supportPlanes.has(event.unit)),
};
}
@@ -9,6 +9,7 @@ import type { BattleSessionStore } from '../../battle/battle-session-store.ts';
import { settleBattle, type BattleSettlementDeps } from '../../battle/battle-settlement.ts';
import type { BattleEconomy } from '../../battle/battle-economy.ts';
import type { BattleStreaks } from '../../battle/battle-streaks.ts';
import { withoutSupportPlanes } from '../../battle/battle-support-planes.ts';
import type { CrewSkillCatalogue } from '../../crew/crew-skill-rules.ts';
import type { ItemCatalogue } from '../../items/item-catalogue.ts';
import type { EquipmentCatalogue } from '../../modifications/equipment-catalogue.ts';
@@ -25,6 +26,8 @@ export interface BattleActionDependencies {
readonly economy: BattleEconomy;
readonly efficiency: ResearchEfficiency;
readonly streaks: BattleStreaks;
/** Units whose lives and events are not settled (battle-support-planes.ts). */
readonly supportPlanes: ReadonlySet<string>;
}
export interface FinishBattleContext {
@@ -49,8 +52,9 @@ export function finishBattleAction(ctx: FinishBattleContext, battle: BattleActio
repair: ctx.repair,
};
return (context) => withAccount(context, ctx.accounts, (account) => {
const report = context.payload && parseBattleReport(context.payload);
if (!report) return { kind: 'error', code: 'BAD_PARAMS' };
const parsed = context.payload && parseBattleReport(context.payload);
if (!parsed) return { kind: 'error', code: 'BAD_PARAMS' };
const report = withoutSupportPlanes(parsed, battle.supportPlanes);
const session = battle.sessions.findForUser(report.sessionId, account.userId);
if (!session) return { kind: 'error', code: 'BAD_PARAMS' };
if (session.settled) {
+4 -2
View File
@@ -21,6 +21,7 @@ import { ResearchEfficiency } from './research/research-efficiency.ts';
import { battleStreaks } from './game-data/datasets/battle-streaks.ts';
import { BattleStreaks } from './battle/battle-streaks.ts';
import { BattleLiveLogs } from './battle/battle-live-log.ts';
import { supportPlaneUnits } from './battle/battle-support-planes.ts';
import { clanEconomy } from './game-data/datasets/clan-economy.ts';
import { crewSkillData } from './game-data/datasets/crew-skills.ts';
import { DatasetCache } from './game-data/datasets/dataset-cache.ts';
@@ -113,6 +114,7 @@ export async function startLocalService(options: LocalServiceOptions): Promise<R
);
const streaks = new BattleStreaks(streakDefinitions, vehicles, economy);
const supportPlanes = supportPlaneUnits(spawnRules);
const router = new Router([
webUi,
@@ -129,7 +131,7 @@ export async function startLocalService(options: LocalServiceOptions): Promise<R
...catalogues,
clans: { store: clans, economy: squadronEconomy },
cloudSettings,
battle: { sessions: battleSessions, economy, efficiency: new ResearchEfficiency(efficiencyData, research.techTree), streaks },
battle: { sessions: battleSessions, economy, efficiency: new ResearchEfficiency(efficiencyData, research.techTree), streaks, supportPlanes },
notifyInventoryChanged,
})),
new DownloadableContentService(),
@@ -148,7 +150,7 @@ export async function startLocalService(options: LocalServiceOptions): Promise<R
economy,
notifyLaunch: (userId, payload) => matching?.notifyUser(userId, 'mrpc.generic_notify', payload),
},
battleLive: { sessions: battleSessions, liveLogs: new BattleLiveLogs(tuning.limits.battleSessionsKept), streaks },
battleLive: { sessions: battleSessions, liveLogs: new BattleLiveLogs(tuning.limits.battleSessionsKept), streaks, supportPlanes },
}),
log,
loadOrCreateCredentials(options.dataFolder),
@@ -14,12 +14,15 @@
import type { BattleLiveLogs } from '../battle/battle-live-log.ts';
import type { BattleSessionStore } from '../battle/battle-session-store.ts';
import type { BattleStreaks } from '../battle/battle-streaks.ts';
import { withoutSupportPlanes } from '../battle/battle-support-planes.ts';
import type { MatchingRequestHandler } from './matching-requests.ts';
export interface BattleLiveDependencies {
readonly sessions: BattleSessionStore;
readonly liveLogs: BattleLiveLogs;
readonly streaks: BattleStreaks;
/** Units whose lives and events earn no awards (battle-support-planes.ts). */
readonly supportPlanes: ReadonlySet<string>;
}
export function battleLiveRequests(deps: BattleLiveDependencies): Array<[string, MatchingRequestHandler]> {
@@ -32,8 +35,7 @@ export function battleLiveRequests(deps: BattleLiveDependencies): Array<[string,
const log = deps.liveLogs.of(session.sessionId);
if (!recordFact(log, p)) return { streaks: [] };
const awarded = deps.streaks.evaluate({
events: log.events,
lives: log.lives,
...withoutSupportPlanes({ events: log.events, lives: log.lives }, deps.supportPlanes),
feed: log.feed,
nuclearStrikes: log.nuclearStrikes,
localPlayerId: int(p.localPlayerId, -1),