/** * Purchase actions; the client applies each answer as a profile * update, so each answers the whole profile. * * cln_buy_aircraft (char_send_blk, job type 13; gui.vromfs.bin scripts/unit/unitActions.nut * impl_buyUnit): * name:t the vehicle * cost:i the silver lion price the client showed * costGold:i the golden eagle price the client showed * cln_buy_slot (purchase_crew_slot, aces.exe 2.61.0.37 0x1555a90 -> 0x2998f0, job type 10): * country:t the country that gets one more crew slot */ import type { AccountStore } from '../../accounts/account-store.ts'; import type { PlayerProfiles } from '../../profile/player-profiles.ts'; import { buyCrewSlot } from '../../research/crew-slot-purchase.ts'; import type { ResearchRules } from '../../research/research-rules.ts'; import { buyVehicle } from '../../research/vehicle-purchase.ts'; import type { CharActionHandler } from '../char-action.ts'; import { intParam, stringParam } from './payload-params.ts'; import { ruleAction } from './rule-answer.ts'; export function buyAircraft(profiles: PlayerProfiles, accounts: AccountStore, rules: ResearchRules): CharActionHandler { return ruleAction(profiles, accounts, (payload) => { const vehicle = stringParam(payload, 'name'); const silverLions = intParam(payload, 'cost') ?? 0; const goldenEagles = intParam(payload, 'costGold') ?? 0; if (vehicle === undefined) return undefined; return (profile) => buyVehicle(profile, rules, vehicle, { silverLions, goldenEagles }); }); } export function buySlot(profiles: PlayerProfiles, accounts: AccountStore, rules: ResearchRules): CharActionHandler { return ruleAction(profiles, accounts, (payload) => { const country = stringParam(payload, 'country'); if (country === undefined) return undefined; return (profile) => buyCrewSlot(profile, rules, country); }); }