// packages/feature_game_spider/lib/models/spider_card.dart /// 카드의 4가지 무늬 enum SpiderSuit { spade, // ♠️ heart, // ♥️ club, // ♣️ diamond // ♦️ } /// 스파이더 카드 1장의 데이터 모델 class SpiderCard { /// 카드의 고유 ID (Draggable 위젯의 Key로 사용) final int id; /// 무늬 (spade, heart 등) final SpiderSuit suit; /// 숫자 (1 = A, 11 = J, 12 = Q, 13 = K) final int rank; /// 현재 앞면이 보이는지 여부 bool isFaceUp; /// [UI용] 카드가 현재 드래그 중인지 여부 bool isBeingDragged; SpiderCard({ required this.id, required this.suit, required this.rank, this.isFaceUp = false, this.isBeingDragged = false, }); /// 카드가 빨간색(하트, 다이아)인지 확인 bool get isRed => suit == SpiderSuit.heart || suit == SpiderSuit.diamond; /// 랭크를 텍스트(A, K, Q, J, 10...)로 변환 String get rankText { switch (rank) { case 1: return 'A'; case 11: return 'J'; case 12: return 'Q'; case 13: return 'K'; default: return rank.toString(); } } /// 무늬를 심볼(♠️, ♥️...)로 변환 String get suitSymbol { switch (suit) { case SpiderSuit.spade: return '♠️'; case SpiderSuit.heart: return '♥️'; case SpiderSuit.club: return '♣️'; case SpiderSuit.diamond: return '♦️'; } } // 객체 비교를 위한 == 및 hashCode 오버라이드 @override bool operator ==(Object other) => identical(this, other) || other is SpiderCard && runtimeType == other.runtimeType && id == other.id; // 고유 ID로만 비교 @override int get hashCode => id.hashCode; /// 디버깅용 @override String toString() { return '$rankText-$suitSymbol ($id)'; } }