/** * Crew training fee: putting a vehicle into a crew that is not trained * for it yet costs the vehicle's wpcost.blk trainCost in silver lions (scripts crew/crew.nut * getCrewTrainCost; reserve vehicles cost 0). Charged by cln_train_aircraft and * cln_bulk_train_aircraft for every new crew/vehicle pair. */ import type { BlkBlock } from '@wto/blk'; import type { Price } from '../profile/profile-currency.ts'; import { isTrainedFor } from '../profile/profile-crew-skills.ts'; import { crewOf } from '../profile/profile-crews.ts'; import type { CrewSlotAssignment } from '../profile/crew-slots.ts'; import type { CrewSkillCatalogue } from './crew-skill-rules.ts'; export function trainingFee(profile: BlkBlock, catalogue: CrewSkillCatalogue, assignments: readonly CrewSlotAssignment[]): Price { const counted = new Set(); let silverLions = 0; for (const { crewId, vehicle } of assignments) { const crew = crewOf(profile, crewId); const key = `${crewId}/${vehicle}`; if (vehicle === '' || !crew || isTrainedFor(crew, vehicle) || counted.has(key)) continue; counted.add(key); silverLions += catalogue.training(vehicle)?.training ?? 0; } return { silverLions, goldenEagles: 0 }; }