From 394091e51813d2128bd89d0f2eaf867bbc5bcd70 Mon Sep 17 00:00:00 2001 From: N0VAN0M4LY <224130499+N0VAN0M4LY@users.noreply.github.com> Date: Sat, 28 Nov 2026 22:25:19 +0800 Subject: [PATCH] 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. --- .../src/battle/battle-support-planes.ts | 26 +++++++++++++++++++ .../src/char/actions/battle-actions.ts | 8 ++++-- packages/local-service/src/local-service.ts | 6 +++-- .../src/matching/battle-live-requests.ts | 6 +++-- 4 files changed, 40 insertions(+), 6 deletions(-) create mode 100644 packages/local-service/src/battle/battle-support-planes.ts diff --git a/packages/local-service/src/battle/battle-support-planes.ts b/packages/local-service/src/battle/battle-support-planes.ts new file mode 100644 index 0000000..fade9d7 --- /dev/null +++ b/packages/local-service/src/battle/battle-support-planes.ts @@ -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): ReadonlySet { + 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( + facts: T, + supportPlanes: ReadonlySet, +): T { + return { + ...facts, + lives: facts.lives.filter((life) => !supportPlanes.has(life.unit)), + events: facts.events.filter((event) => !supportPlanes.has(event.unit)), + }; +} diff --git a/packages/local-service/src/char/actions/battle-actions.ts b/packages/local-service/src/char/actions/battle-actions.ts index 1f25550..228a960 100644 --- a/packages/local-service/src/char/actions/battle-actions.ts +++ b/packages/local-service/src/char/actions/battle-actions.ts @@ -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; } 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) { diff --git a/packages/local-service/src/local-service.ts b/packages/local-service/src/local-service.ts index c109be7..d7e95e5 100644 --- a/packages/local-service/src/local-service.ts +++ b/packages/local-service/src/local-service.ts @@ -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 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), diff --git a/packages/local-service/src/matching/battle-live-requests.ts b/packages/local-service/src/matching/battle-live-requests.ts index 961c172..340a17a 100644 --- a/packages/local-service/src/matching/battle-live-requests.ts +++ b/packages/local-service/src/matching/battle-live-requests.ts @@ -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; } 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),