👁️
at dev 49 lines 1.2 kB view raw
1/** 2 * Internal utilities for deck validation. 3 * These handle DFC/MDFC cards properly by checking all faces. 4 */ 5 6import type { Card } from "@/lib/scryfall-types"; 7 8/** 9 * Get combined oracle text from card, including all faces for DFCs/MDFCs. 10 */ 11export function getOracleText(card: Card): string { 12 if (card.oracle_text) { 13 return card.oracle_text; 14 } 15 16 if (card.card_faces) { 17 return card.card_faces.map((face) => face.oracle_text ?? "").join("\n"); 18 } 19 20 return ""; 21} 22 23/** 24 * Get type line from card, including all faces for DFCs/MDFCs. 25 */ 26export function getTypeLine(card: Card): string { 27 if (card.type_line) { 28 return card.type_line; 29 } 30 31 if (card.card_faces) { 32 return card.card_faces.map((face) => face.type_line ?? "").join(" // "); 33 } 34 35 return ""; 36} 37 38/** 39 * Get the front face type line only. 40 * For DFCs/MDFCs, commander legality is determined by the front face. 41 * A Saga that transforms into a creature (e.g., Behold the Unspeakable) 42 * is NOT a legal commander because the front face is a Saga. 43 */ 44export function getFrontFaceTypeLine(card: Card): string { 45 if (card.card_faces && card.card_faces.length > 0) { 46 return card.card_faces[0].type_line ?? ""; 47 } 48 return card.type_line ?? ""; 49}