/** What a research or purchase rule says about a player's request. */ export type Refusal = /** The request names something that does not exist or does not fit (unknown vehicle, wrong type ...). */ | 'BAD_PARAMS' /** The vehicle's status does not allow it (locked, not researchable, already owned ...). */ | 'NOT_AVAILABLE' /** The price the client offered is not the current price. */ | 'PRICE_CHANGED' | 'NOT_ENOUGH_MONEY' | 'NOT_ENOUGH_RESEARCH_POINTS' /** A crew does not have the skill points the upgrade costs. */ | 'NOT_ENOUGH_SKILL_POINTS'; export type RuleOutcome = { readonly ok: true } | { readonly ok: false; readonly refusal: Refusal }; export const ACCEPTED: RuleOutcome = { ok: true }; export function refused(refusal: Refusal): RuleOutcome { return { ok: false, refusal }; }