...
This commit is contained in:
parent
3228e370c5
commit
64f3fb8adf
@ -35,10 +35,7 @@ class CardFlipController with ChangeNotifier {
|
|||||||
bool _isGameStarted = false;
|
bool _isGameStarted = false;
|
||||||
bool get isGameStarted => _isGameStarted;
|
bool get isGameStarted => _isGameStarted;
|
||||||
|
|
||||||
// [🔥 신규] 매칭된 쌍의 개수
|
|
||||||
int get matchedPairsCount => _cards.where((c) => c.isMatched).length ~/ 2;
|
int get matchedPairsCount => _cards.where((c) => c.isMatched).length ~/ 2;
|
||||||
|
|
||||||
// [🔥 신규] 총 쌍의 개수
|
|
||||||
int get totalPairsCount => _cards.length ~/ 2;
|
int get totalPairsCount => _cards.length ~/ 2;
|
||||||
|
|
||||||
void setUserInfo(String userId, String? userName) {
|
void setUserInfo(String userId, String? userName) {
|
||||||
@ -91,32 +88,56 @@ class CardFlipController with ChangeNotifier {
|
|||||||
final Random random = Random();
|
final Random random = Random();
|
||||||
|
|
||||||
if (difficulty.contentType == CardContentType.calculation) {
|
if (difficulty.contentType == CardContentType.calculation) {
|
||||||
|
// [🔥 수정] 연산 모드
|
||||||
final Set<int> usedResults = {};
|
final Set<int> usedResults = {};
|
||||||
|
|
||||||
|
// 레벨 4인지 확인 (한 자릿수 덧셈/뺄셈만)
|
||||||
|
final bool isLevel4 = difficulty.levelIndex == 4;
|
||||||
|
|
||||||
for (int i = 0; i < pairsCount; i++) {
|
for (int i = 0; i < pairsCount; i++) {
|
||||||
String equation;
|
String equation;
|
||||||
String answer;
|
String answer;
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
final int opType = random.nextInt(3);
|
// Lv 4: 0(덧셈), 1(뺄셈)만 선택 / 그 외: 0, 1, 2(곱셈) 선택
|
||||||
|
final int opType = isLevel4 ? random.nextInt(2) : random.nextInt(3);
|
||||||
int a, b;
|
int a, b;
|
||||||
if (opType == 0) { // +
|
|
||||||
|
if (opType == 0) { // 덧셈 (+)
|
||||||
|
if (isLevel4) {
|
||||||
|
// 한 자릿수 (1~9)
|
||||||
|
a = random.nextInt(9) + 1;
|
||||||
|
b = random.nextInt(9) + 1;
|
||||||
|
} else {
|
||||||
|
// 두 자릿수 포함 (1~15)
|
||||||
a = random.nextInt(15) + 1;
|
a = random.nextInt(15) + 1;
|
||||||
b = random.nextInt(15) + 1;
|
b = random.nextInt(15) + 1;
|
||||||
|
}
|
||||||
result = a + b;
|
result = a + b;
|
||||||
equation = "$a + $b";
|
equation = "$a + $b";
|
||||||
} else if (opType == 1) { // -
|
|
||||||
|
} else if (opType == 1) { // 뺄셈 (-)
|
||||||
|
if (isLevel4) {
|
||||||
|
// 결과가 양수이고 한 자릿수 내에서 처리되도록
|
||||||
|
a = random.nextInt(9) + 2; // 2~10
|
||||||
|
b = random.nextInt(a - 1) + 1;
|
||||||
|
} else {
|
||||||
a = random.nextInt(20) + 5;
|
a = random.nextInt(20) + 5;
|
||||||
b = random.nextInt(a - 1) + 1;
|
b = random.nextInt(a - 1) + 1;
|
||||||
|
}
|
||||||
result = a - b;
|
result = a - b;
|
||||||
equation = "$a - $b";
|
equation = "$a - $b";
|
||||||
} else { // *
|
|
||||||
|
} else { // 곱셈 (*)
|
||||||
|
// Lv 4에서는 이 블록에 들어오지 않음
|
||||||
a = random.nextInt(9) + 2;
|
a = random.nextInt(9) + 2;
|
||||||
b = random.nextInt(5) + 2;
|
b = random.nextInt(5) + 2;
|
||||||
result = a * b;
|
result = a * b;
|
||||||
equation = "$a x $b";
|
equation = "$a x $b";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 정답 중복 방지
|
||||||
if (!usedResults.contains(result)) {
|
if (!usedResults.contains(result)) {
|
||||||
usedResults.add(result);
|
usedResults.add(result);
|
||||||
answer = result.toString();
|
answer = result.toString();
|
||||||
@ -130,6 +151,7 @@ class CardFlipController with ChangeNotifier {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (difficulty.contentType == CardContentType.pairWord) {
|
else if (difficulty.contentType == CardContentType.pairWord) {
|
||||||
|
// 연상 모드
|
||||||
var entries = CardFlipDifficulties.wordPairs.entries.toList()..shuffle();
|
var entries = CardFlipDifficulties.wordPairs.entries.toList()..shuffle();
|
||||||
for (int i = 0; i < pairsCount; i++) {
|
for (int i = 0; i < pairsCount; i++) {
|
||||||
var entry = entries[i % entries.length];
|
var entry = entries[i % entries.length];
|
||||||
@ -139,6 +161,7 @@ class CardFlipController with ChangeNotifier {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
// 동일 매칭 모드
|
||||||
List<String> pool = List.of(CardFlipDifficulties.emojis)..shuffle();
|
List<String> pool = List.of(CardFlipDifficulties.emojis)..shuffle();
|
||||||
for (int i = 0; i < pairsCount; i++) {
|
for (int i = 0; i < pairsCount; i++) {
|
||||||
String content;
|
String content;
|
||||||
|
|||||||
@ -7,7 +7,7 @@ enum CardContentType {
|
|||||||
emoji, // 🐰 ↔ 🐰
|
emoji, // 🐰 ↔ 🐰
|
||||||
icon, // ⭐️ ↔ ⭐️
|
icon, // ⭐️ ↔ ⭐️
|
||||||
number, // 1 ↔ 1
|
number, // 1 ↔ 1
|
||||||
calculation, // 3+4 ↔ 7 (동적 생성)
|
calculation, // 3+4 ↔ 7
|
||||||
pairWord, // 토끼 ↔ 당근
|
pairWord, // 토끼 ↔ 당근
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,7 +49,7 @@ class CardFlipDifficulty extends GameDifficulty {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class CardFlipDifficulties {
|
class CardFlipDifficulties {
|
||||||
// 이모지 풀
|
// --- 콘텐츠 풀 ---
|
||||||
static const List<String> emojis = [
|
static const List<String> emojis = [
|
||||||
"🐶", "🐱", "🐭", "🐹", "🐰", "🦊", "🐻", "🐼", "🐨", "🐯",
|
"🐶", "🐱", "🐭", "🐹", "🐰", "🦊", "🐻", "🐼", "🐨", "🐯",
|
||||||
"🦁", "🐮", "🐷", "🐸", "🐵", "🐔", "🐧", "🐦", "🐤", "🦆",
|
"🦁", "🐮", "🐷", "🐸", "🐵", "🐔", "🐧", "🐦", "🐤", "🦆",
|
||||||
@ -57,44 +57,84 @@ class CardFlipDifficulties {
|
|||||||
"⚽", "🏀", "🏈", "⚾", "🎾", "🏐", "🏉", "🎱", "🏓", "🏸"
|
"⚽", "🏀", "🏈", "⚾", "🎾", "🏐", "🏉", "🎱", "🏓", "🏸"
|
||||||
];
|
];
|
||||||
|
|
||||||
// ❌ [삭제됨] calculationPairs (컨트롤러에서 동적 생성하므로 제거)
|
// 연상 단어 풀 (총 80+쌍)
|
||||||
|
|
||||||
// 연상 단어 풀 (A : B)
|
|
||||||
static const Map<String, String> wordPairs = {
|
static const Map<String, String> wordPairs = {
|
||||||
"토끼": "당근", "원숭이": "바나나", "한국": "서울", "미국": "워싱턴",
|
"토끼": "당근", "원숭이": "바나나", "다람쥐": "도토리", "고양이": "생선",
|
||||||
"해": "달", "여름": "겨울", "남자": "여자", "학교": "학생",
|
"개": "뼈다귀", "소": "여물", "닭": "달걀", "벌": "꿀",
|
||||||
"병원": "의사", "바늘": "실", "우산": "비", "책상": "의자",
|
"거미": "거미줄", "개구리": "올챙이", "팬더": "대나무", "호랑이": "가죽",
|
||||||
"봄": "꽃", "가을": "단풍", "숟가락": "젓가락"
|
"누에": "뽕잎", "양": "양털", "펭귄": "남극", "사자": "초원",
|
||||||
|
|
||||||
|
"바늘": "실", "망치": "못", "활": "화살", "자물쇠": "열쇠",
|
||||||
|
"숟가락": "젓가락", "책상": "의자", "신발": "양말", "장갑": "목도리",
|
||||||
|
"지우개": "연필", "칠판": "분필", "붓": "물감", "도장": "인주",
|
||||||
|
"냄비": "뚜껑", "샴푸": "린스", "치약": "칫솔", "비누": "수건",
|
||||||
|
"배게": "이불", "항아리": "뚜껑", "안경": "안경집", "핸드폰": "충전기",
|
||||||
|
|
||||||
|
"해": "달", "하늘": "구름", "비": "우산", "눈": "눈사람",
|
||||||
|
"봄": "꽃", "여름": "부채", "가을": "단풍", "겨울": "눈",
|
||||||
|
"바다": "파도", "산": "나무", "사막": "선인장", "밤": "별",
|
||||||
|
"번개": "천둥", "무지개": "비온뒤", "화산": "용암", "지진": "진동",
|
||||||
|
|
||||||
|
"밥": "국", "빵": "우유", "삼겹살": "상추", "짜장면": "단무지",
|
||||||
|
"치킨": "무", "떡볶이": "오뎅", "피자": "콜라", "회": "초장",
|
||||||
|
"감자": "고구마", "소금": "설탕", "간장": "고추장", "된장": "쌈장",
|
||||||
|
|
||||||
|
"남자": "여자", "부모": "자식", "할아버지": "할머니", "형": "동생",
|
||||||
|
"선생님": "학생", "의사": "환자", "경찰": "도둑", "가수": "마이크",
|
||||||
|
"화가": "그림", "요리사": "주방", "어부": "낚시대", "군인": "총",
|
||||||
|
"왕": "왕비", "왕자": "공주", "신랑": "신부", "주인": "손님",
|
||||||
|
|
||||||
|
"한국": "서울", "미국": "워싱턴", "프랑스": "파리", "영국": "런던",
|
||||||
|
"일본": "도쿄", "중국": "베이징", "학교": "교실", "병원": "주사기",
|
||||||
|
"은행": "돈", "우체국": "편지", "극장": "영화", "도서관": "책",
|
||||||
|
"공항": "비행기", "항구": "배", "역": "기차", "정류장": "버스",
|
||||||
|
|
||||||
|
"시계": "시간", "달력": "날짜", "거울": "얼굴", "빗": "머리카락",
|
||||||
|
"가방": "책", "모자": "머리", "안경": "눈", "마스크": "입",
|
||||||
};
|
};
|
||||||
|
|
||||||
// 난이도 목록 (15단계)
|
// [🔥 수정] 21단계 난이도 목록 (6x6 헬모드 추가)
|
||||||
static final List<CardFlipDifficulty> allDifficulties = [
|
static final List<CardFlipDifficulty> allDifficulties = [
|
||||||
// Phase 1: 입문 (동일 매칭)
|
// --- Phase 1: 입문 (6~8장) ---
|
||||||
const CardFlipDifficulty(levelIndex: 1, name: 'Lv. 1: 입문 (이모지 12)', contextId: 'FLIP_L1_EMOJI', rows: 4, cols: 3, timeLimitSeconds: 40, contentType: CardContentType.emoji),
|
const CardFlipDifficulty(levelIndex: 1, name: 'Lv. 1: 입문 (숫자 6장)', contextId: 'FLIP_L1_2x3_NUM', rows: 3, cols: 2, timeLimitSeconds: 30, contentType: CardContentType.number),
|
||||||
const CardFlipDifficulty(levelIndex: 2, name: 'Lv. 2: 초급 (아이콘 12)', contextId: 'FLIP_L2_ICON', rows: 4, cols: 3, timeLimitSeconds: 30, contentType: CardContentType.icon),
|
const CardFlipDifficulty(levelIndex: 2, name: 'Lv. 2: 입문 (이모지 6장)', contextId: 'FLIP_L2_2x3_EMOJI', rows: 3, cols: 2, timeLimitSeconds: 25, contentType: CardContentType.emoji),
|
||||||
const CardFlipDifficulty(levelIndex: 3, name: 'Lv. 3: 기초 (숫자 16)', contextId: 'FLIP_L3_NUM', rows: 4, cols: 4, timeLimitSeconds: 50, contentType: CardContentType.number),
|
const CardFlipDifficulty(levelIndex: 3, name: 'Lv. 3: 기초 (숫자 8장)', contextId: 'FLIP_L3_2x4_NUM', rows: 4, cols: 2, timeLimitSeconds: 40, contentType: CardContentType.number),
|
||||||
|
const CardFlipDifficulty(levelIndex: 4, name: 'Lv. 4: 기초 (이모지 8장)', contextId: 'FLIP_L4_2x4_EMOJI', rows: 4, cols: 2, timeLimitSeconds: 35, contentType: CardContentType.emoji),
|
||||||
|
|
||||||
// Phase 2: 연산/연상 (기억 + 사고)
|
// --- Phase 2: 초급 (12장) ---
|
||||||
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: 초급 (이모지 12장)', contextId: 'FLIP_L5_3x4_EMOJI', rows: 4, cols: 3, timeLimitSeconds: 50, contentType: CardContentType.emoji),
|
||||||
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: 초급 (아이콘 12장)', contextId: 'FLIP_L6_3x4_ICON', rows: 4, cols: 3, timeLimitSeconds: 45, contentType: CardContentType.icon),
|
||||||
const CardFlipDifficulty(levelIndex: 6, name: 'Lv. 6: 도전 (이모지 20)', contextId: 'FLIP_L6_EMOJI_20', rows: 5, cols: 4, timeLimitSeconds: 70, contentType: CardContentType.emoji),
|
const CardFlipDifficulty(levelIndex: 7, name: 'Lv. 7: 초급 (연산 12장)', contextId: 'FLIP_L7_3x4_CALC', rows: 4, cols: 3, timeLimitSeconds: 60, contentType: CardContentType.calculation),
|
||||||
|
const CardFlipDifficulty(levelIndex: 8, name: 'Lv. 8: 초급 (단어 12장)', contextId: 'FLIP_L8_3x4_PAIR', rows: 4, cols: 3, timeLimitSeconds: 60, contentType: CardContentType.pairWord),
|
||||||
|
|
||||||
// Phase 3: 상급 (혼합/확장)
|
// --- Phase 3: 중급 (16장) ---
|
||||||
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: 9, name: 'Lv. 9: 중급 (숫자 16장)', contextId: 'FLIP_L9_4x4_NUM', rows: 4, cols: 4, timeLimitSeconds: 70, contentType: CardContentType.number),
|
||||||
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: 10, name: 'Lv. 10: 중급 (아이콘 16장)', contextId: 'FLIP_L10_4x4_ICON', rows: 4, cols: 4, timeLimitSeconds: 65, contentType: CardContentType.icon),
|
||||||
const CardFlipDifficulty(levelIndex: 9, name: 'Lv. 9: 엘리트 (아이콘 24)', contextId: 'FLIP_L9_ICON_24', rows: 6, cols: 4, timeLimitSeconds: 100, contentType: CardContentType.icon),
|
const CardFlipDifficulty(levelIndex: 11, name: 'Lv. 11: 중급 (연산 16장)', contextId: 'FLIP_L11_4x4_CALC', rows: 4, cols: 4, timeLimitSeconds: 90, contentType: CardContentType.calculation),
|
||||||
|
const CardFlipDifficulty(levelIndex: 12, name: 'Lv. 12: 중급 (단어 16장)', contextId: 'FLIP_L12_4x4_PAIR', rows: 4, cols: 4, timeLimitSeconds: 90, contentType: CardContentType.pairWord),
|
||||||
|
|
||||||
// Phase 4: 마스터 (대형 그리드)
|
// --- Phase 4: 상급 (20~24장) ---
|
||||||
const CardFlipDifficulty(levelIndex: 10, name: 'Lv. 10: 마스터 (24장)', contextId: 'FLIP_L10_6x4', rows: 6, cols: 4, timeLimitSeconds: 100, contentType: CardContentType.emoji),
|
const CardFlipDifficulty(levelIndex: 13, name: 'Lv. 13: 상급 (이모지 20장)', contextId: 'FLIP_L13_5x4_EMOJI', rows: 5, 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: 14, name: 'Lv. 14: 상급 (연산 20장)', contextId: 'FLIP_L14_5x4_CALC', rows: 5, cols: 4, timeLimitSeconds: 120, contentType: CardContentType.calculation),
|
||||||
const CardFlipDifficulty(levelIndex: 12, name: 'Lv. 12: 레전드', contextId: 'FLIP_L12_6x4_PAIR', rows: 6, cols: 4, timeLimitSeconds: 110, contentType: CardContentType.pairWord),
|
const CardFlipDifficulty(levelIndex: 15, name: 'Lv. 15: 전문가 (아이콘 24장)', contextId: 'FLIP_L15_6x4_ICON', rows: 6, cols: 4, timeLimitSeconds: 120, contentType: CardContentType.icon),
|
||||||
|
const CardFlipDifficulty(levelIndex: 16, name: 'Lv. 16: 전문가 (단어 24장)', contextId: 'FLIP_L16_6x4_PAIR', rows: 6, cols: 4, timeLimitSeconds: 150, contentType: CardContentType.pairWord),
|
||||||
|
|
||||||
// Phase 5: 신의 영역
|
// --- Phase 5: 마스터 (30장) ---
|
||||||
const CardFlipDifficulty(levelIndex: 13, name: 'Lv. 13: 갓모드 (30장)', contextId: 'FLIP_L13_6x5', rows: 6, cols: 5, timeLimitSeconds: 130, contentType: CardContentType.emoji),
|
const CardFlipDifficulty(levelIndex: 17, name: 'Lv. 17: 마스터 (숫자 30장)', contextId: 'FLIP_L17_6x5_NUM', rows: 6, cols: 5, timeLimitSeconds: 150, contentType: CardContentType.number),
|
||||||
const CardFlipDifficulty(levelIndex: 14, name: 'Lv. 14: 타임어택 (연산)', contextId: 'FLIP_L14_6x5_CALC', rows: 6, cols: 5, timeLimitSeconds: 120, contentType: CardContentType.calculation),
|
const CardFlipDifficulty(levelIndex: 18, name: 'Lv. 18: 마스터 (연산 30장)', contextId: 'FLIP_L18_6x5_CALC', rows: 6, cols: 5, timeLimitSeconds: 180, 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: 19, name: 'Lv. 19: 레전드 (단어 30장)', contextId: 'FLIP_L19_6x5_PAIR', rows: 6, cols: 5, timeLimitSeconds: 180, contentType: CardContentType.pairWord),
|
||||||
|
const CardFlipDifficulty(levelIndex: 20, name: 'Lv. 20: 갓모드 (이모지 30장)', contextId: 'FLIP_L20_6x5_EMOJI', rows: 6, cols: 5, timeLimitSeconds: 120, contentType: CardContentType.emoji),
|
||||||
|
|
||||||
const CardFlipDifficulty(levelIndex: 16, name: 'Lv. 15: 헬 (연상)', contextId: 'FLIP_L16_6x6_PAIR', rows: 6, cols: 6, timeLimitSeconds: 120, contentType: CardContentType.pairWord),
|
// --- [🔥 신규] Phase 6: 헬모드 (6x6 = 36장) ---
|
||||||
|
const CardFlipDifficulty(
|
||||||
|
levelIndex: 21,
|
||||||
|
name: 'Lv. 21: 헬모드 (36장)',
|
||||||
|
contextId: 'FLIP_L21_6x6_HELL',
|
||||||
|
rows: 6,
|
||||||
|
cols: 6,
|
||||||
|
timeLimitSeconds: 240,
|
||||||
|
contentType: CardContentType.pairWord
|
||||||
|
),
|
||||||
];
|
];
|
||||||
|
|
||||||
static CardFlipDifficulty getLevel(int levelIndex) {
|
static CardFlipDifficulty getLevel(int levelIndex) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user