16 lines
801 B
TypeScript
16 lines
801 B
TypeScript
import type { Game } from './engine';
|
|
|
|
/** Physical card identity is not a lot identity: the same card can later
|
|
* re-enter an ordinary auction. Return null when no current lot exists. */
|
|
export function originalAuctionInspectionLot(
|
|
game: Pick<Game, 'richeseAuction' | 'auction' | 'turn'>,
|
|
): string | null {
|
|
if (game.richeseAuction) return typeof game.richeseAuction.event === 'string'
|
|
? game.richeseAuction.event : null;
|
|
const auction = game.auction;
|
|
if (!auction || !Number.isSafeInteger(auction.index) || auction.index < 0 ||
|
|
!Array.isArray(auction.cards) || !auction.cards[auction.index] ||
|
|
typeof auction.cards[auction.index].id !== 'string') return null;
|
|
return JSON.stringify([auction.occupiedEvent ?? game.turn, auction.index, auction.cards[auction.index].id]);
|
|
}
|