2025-11-19 17:16:43 +09:00

106 lines
5.5 KiB
Dart

// packages/feature_game_cardflip/lib/models/cardflip_models.dart
import 'package:flutter/material.dart';
import 'package:service_api/service_api.dart';
enum CardContentType {
emoji, // 🐰 ↔ 🐰
icon, // ⭐️ ↔ ⭐️
number, // 1 ↔ 1
calculation, // 3+4 ↔ 7 (동적 생성)
pairWord, // 토끼 ↔ 당근
}
class CardItem {
final int id;
final String matchId;
final String displayContent;
bool isFaceUp;
bool isMatched;
CardItem({
required this.id,
required this.matchId,
required this.displayContent,
this.isFaceUp = false,
this.isMatched = false,
});
}
class CardFlipDifficulty extends GameDifficulty {
final int levelIndex;
final int rows;
final int cols;
final int timeLimitSeconds;
final CardContentType contentType;
const CardFlipDifficulty({
required this.levelIndex,
required super.name,
required super.contextId,
required this.rows,
required this.cols,
required this.timeLimitSeconds,
required this.contentType,
});
int get totalCards => rows * cols;
}
class CardFlipDifficulties {
// 이모지 풀
static const List<String> emojis = [
"🐶", "🐱", "🐭", "🐹", "🐰", "🦊", "🐻", "🐼", "🐨", "🐯",
"🦁", "🐮", "🐷", "🐸", "🐵", "🐔", "🐧", "🐦", "🐤", "🦆",
"🍎", "🍌", "🍇", "🍓", "🍊", "🍋", "🍉", "🍑", "🍒", "🥝",
"", "🏀", "🏈", "", "🎾", "🏐", "🏉", "🎱", "🏓", "🏸"
];
// ❌ [삭제됨] calculationPairs (컨트롤러에서 동적 생성하므로 제거)
// 연상 단어 풀 (A : B)
static const Map<String, String> wordPairs = {
"토끼": "당근", "원숭이": "바나나", "한국": "서울", "미국": "워싱턴",
"": "", "여름": "겨울", "남자": "여자", "학교": "학생",
"병원": "의사", "바늘": "", "우산": "", "책상": "의자",
"": "", "가을": "단풍", "숟가락": "젓가락"
};
// 난이도 목록 (15단계)
static final List<CardFlipDifficulty> allDifficulties = [
// Phase 1: 입문 (동일 매칭)
const CardFlipDifficulty(levelIndex: 1, name: 'Lv. 1: 입문 (이모지 12)', contextId: 'FLIP_L1_EMOJI', rows: 4, cols: 3, timeLimitSeconds: 40, contentType: CardContentType.emoji),
const CardFlipDifficulty(levelIndex: 2, name: 'Lv. 2: 초급 (아이콘 12)', contextId: 'FLIP_L2_ICON', rows: 4, cols: 3, timeLimitSeconds: 30, contentType: CardContentType.icon),
const CardFlipDifficulty(levelIndex: 3, name: 'Lv. 3: 기초 (숫자 16)', contextId: 'FLIP_L3_NUM', rows: 4, cols: 4, timeLimitSeconds: 50, contentType: CardContentType.number),
// Phase 2: 연산/연상 (기억 + 사고)
const CardFlipDifficulty(levelIndex: 4, name: 'Lv. 4: 연산 (덧셈/뺄셈)', contextId: 'FLIP_L4_CALC', rows: 4, cols: 4, timeLimitSeconds: 60, contentType: CardContentType.calculation),
const CardFlipDifficulty(levelIndex: 5, name: 'Lv. 5: 연상 (짝꿍 단어)', contextId: 'FLIP_L5_PAIR', rows: 4, cols: 4, timeLimitSeconds: 60, contentType: CardContentType.pairWord),
const CardFlipDifficulty(levelIndex: 6, name: 'Lv. 6: 도전 (이모지 20)', contextId: 'FLIP_L6_EMOJI_20', rows: 5, cols: 4, timeLimitSeconds: 70, contentType: CardContentType.emoji),
// Phase 3: 상급 (혼합/확장)
const CardFlipDifficulty(levelIndex: 7, name: 'Lv. 7: 상급 (연산 20)', contextId: 'FLIP_L7_CALC_20', rows: 5, cols: 4, timeLimitSeconds: 90, contentType: CardContentType.calculation),
const CardFlipDifficulty(levelIndex: 8, name: 'Lv. 8: 전문가 (연상 20)', contextId: 'FLIP_L8_PAIR_20', rows: 5, cols: 4, timeLimitSeconds: 90, contentType: CardContentType.pairWord),
const CardFlipDifficulty(levelIndex: 9, name: 'Lv. 9: 엘리트 (아이콘 24)', contextId: 'FLIP_L9_ICON_24', rows: 6, cols: 4, timeLimitSeconds: 100, contentType: CardContentType.icon),
// Phase 4: 마스터 (대형 그리드)
const CardFlipDifficulty(levelIndex: 10, name: 'Lv. 10: 마스터 (24장)', contextId: 'FLIP_L10_6x4', rows: 6, cols: 4, timeLimitSeconds: 100, contentType: CardContentType.emoji),
const CardFlipDifficulty(levelIndex: 11, name: 'Lv. 11: 그랜드마스터', contextId: 'FLIP_L11_6x4_CALC', rows: 6, cols: 4, timeLimitSeconds: 110, contentType: CardContentType.calculation),
const CardFlipDifficulty(levelIndex: 12, name: 'Lv. 12: 레전드', contextId: 'FLIP_L12_6x4_PAIR', rows: 6, cols: 4, timeLimitSeconds: 110, contentType: CardContentType.pairWord),
// Phase 5: 신의 영역
const CardFlipDifficulty(levelIndex: 13, name: 'Lv. 13: 갓모드 (30장)', contextId: 'FLIP_L13_6x5', rows: 6, cols: 5, timeLimitSeconds: 130, contentType: CardContentType.emoji),
const CardFlipDifficulty(levelIndex: 14, name: 'Lv. 14: 타임어택 (연산)', contextId: 'FLIP_L14_6x5_CALC', rows: 6, cols: 5, timeLimitSeconds: 120, contentType: CardContentType.calculation),
const CardFlipDifficulty(levelIndex: 15, name: 'Lv. 15: 엔드게임 (연상)', contextId: 'FLIP_L15_6x5_PAIR', rows: 6, cols: 5, timeLimitSeconds: 120, contentType: CardContentType.pairWord),
const CardFlipDifficulty(levelIndex: 16, name: 'Lv. 15: 헬 (연상)', contextId: 'FLIP_L16_6x6_PAIR', rows: 6, cols: 6, timeLimitSeconds: 120, contentType: CardContentType.pairWord),
];
static CardFlipDifficulty getLevel(int levelIndex) {
if (levelIndex < 1) levelIndex = 1;
if (levelIndex > allDifficulties.length) levelIndex = allDifficulties.length;
return allDifficulties.firstWhere((level) => level.levelIndex == levelIndex,
orElse: () => allDifficulties[0]);
}
}