40 lines
1.8 KiB
TypeScript
40 lines
1.8 KiB
TypeScript
import {
|
|
PhaseBidPromiseError,
|
|
phaseBidPromiseModeSupported,
|
|
type PhaseBidClaim,
|
|
type PhaseBidOpportunity,
|
|
type PhaseBidPromise,
|
|
} from './turn-bid-promises';
|
|
|
|
/** A new, separate receipt: unlike legacy phaseBid, a qualifying declaration
|
|
* can occur in an ordinary, Richese cache, or Black Market auction. */
|
|
export type PhaseAnyBidClaim = PhaseBidClaim;
|
|
export type PhaseAnyBidPromise = PhaseBidPromise;
|
|
export type PhaseAnyBidOpportunity = PhaseBidOpportunity;
|
|
export { PhaseBidPromiseError as PhaseAnyBidPromiseError };
|
|
export {
|
|
livePhaseBidPromises as livePhaseAnyBidPromises,
|
|
phaseBidAllowedRange as phaseAnyBidAllowedRange,
|
|
phaseBidCompletionRange as phaseAnyBidCompletionRange,
|
|
recordPhaseBid as recordPhaseAnyBid,
|
|
reconcilePhaseBidPromises as reconcilePhaseAnyBidPromises,
|
|
finishPhaseBidPhase as finishPhaseAnyBidPhase,
|
|
validatePhaseBidPromises as validatePhaseAnyBidPromises,
|
|
} from './turn-bid-promises';
|
|
|
|
export const phaseAnyBidPromiseModeSupported = phaseBidPromiseModeSupported;
|
|
|
|
export function parsePhaseAnyBidClaim(value: unknown): PhaseAnyBidClaim {
|
|
if (!value || typeof value !== 'object' || Array.isArray(value))
|
|
throw new PhaseBidPromiseError('Choose a Bidding phase bid question.');
|
|
const input = value as Record<string, unknown>;
|
|
if (typeof input.turn !== 'number' || !Number.isSafeInteger(input.turn) || input.turn <= 0 ||
|
|
typeof input.minimum !== 'number' || !Number.isSafeInteger(input.minimum) || input.minimum <= 0)
|
|
throw new PhaseBidPromiseError('Choose the current turn and a positive whole bid minimum.');
|
|
return {turn:input.turn, minimum:input.minimum};
|
|
}
|
|
|
|
export function phaseAnyBidClaimText(claim: PhaseAnyBidClaim): string {
|
|
return `place a bid of at least ${claim.minimum} spice in an ordinary, Richese cache, or Black Market auction from now until this turn's Bidding phase closes`;
|
|
}
|