INNER CODE UNIT · JavaScript
normalizeCards
Sisyphe42/ReignsAgent · packages/core/src/index.js:232
export function normalizeCards(cards) {
if (!Array.isArray(cards)) {
throw new CoreError("cards must be an array");
}
const seenCardIds = new Set();
return cards.map((card) => {
if (!card?.id) {
throw new CoreError("Each card requires an id");
}
if (seenCardIds.has(card.id)) {
throw new CoreError(`Duplicate card id '${card.id}'`);
}
seenCardIds.add(card.id);
if (!Array.isArray(card.choices) || card.choices.length === 0) {