import type { Card, CardType, MonsterCard, MonsterCardType, SpellCard, SpellCardType, TrapCard, TrapCardType } from "../api/openapi"; export const getCardType = (card: Card) => { switch (card.cardType) { case "MONSTER": return getMonsterCardType(card as MonsterCard) case "SPELL": return getSpellCardType(card as SpellCard) case "TRAP": return getTrapCardType(card as TrapCard) default: return "UNKNOWN" } } export const isMonsterCard = (card: Card): card is MonsterCard => { return card.cardType === "MONSTER" } export const isSpellCard = (card: Card): card is SpellCard => { return card.cardType === "SPELL" } export const isTrapCard = (card: Card): card is TrapCard => { return card.cardType === "TRAP" } export const getMonsterCardType = (monsterCard: MonsterCard) => { return `${monsterCard.type} MONSTER ` } export const getSpellCardType = (spellCard: SpellCard) => { return `${spellCard.type} SPELL` } export const getTrapCardType = (trapCard: TrapCard) => { return `${trapCard.type} TRAP` } export const getCardSeverity = (cardType: CardType): string => { switch (cardType) { case "MONSTER": return "warn" case "SPELL": return "success" case "TRAP": return "danger" default: return "warning" } } export const getCardTypeSeverity = (card: Card) => { switch (card.cardType) { case "MONSTER": return getSeverityFromMonsterCardType((card as MonsterCard).type) case "SPELL": return getSeverityFromSpellCardType((card as SpellCard).type) case "TRAP": return getSeverityFromTrapCardType((card as TrapCard).type) default: return "CONSTRAST" } } export const getSeverityFromMonsterCardType = (monsterCardType: MonsterCardType) => { switch (monsterCardType) { case 'NORMAL': return "secondary" case 'EFFECT': return "warn" case 'RITUAL': return "info" case 'FUSION': return "info" case 'SYNCHRO': return "contrast" case 'XYZ': return "danger" case 'LINK': return "info" } } export const getSeverityFromSpellCardType = (spellCardType: SpellCardType) => { switch (spellCardType) { case 'NORMAL': return "secondary" case 'CONTINUOUS': return "warn" case 'EQUIP': return "info" case 'QUICK_PLAY': return "success" case 'FIELD': return "success" case 'RITUAL': return "danger" } } export const getSeverityFromTrapCardType = (trapCardType: TrapCardType) => { switch (trapCardType) { case 'NORMAL': return "secondary" case 'CONTINUOUS': return "warn" case 'COUNTER': return "danger" } }