games/packages/feature_game_tracing/lib/models/tracing_difficulty.dart

70 lines
2.6 KiB
Dart
Raw Normal View History

2025-12-15 18:18:17 +09:00
import 'dart:math';
enum TracingContentType {
text, // 글자/단어 (생성기 사용)
image, // 이미지 (에셋 로드, 추후 사용)
}
class TracingContent {
final String data; // 텍스트 내용 또는 이미지 경로
final TracingContentType type;
TracingContent({required this.data, required this.type});
}
class TracingDifficultyRepository {
static final Random _random = Random();
// 난이도별 데이터 뱅크
static final Map<int, List<String>> _textLevels = {
// Level 1: ㄱㄴㄷ, 숫자 (단순 자모/숫자)
1: ['', '', '', '', '', '', '', '', '', '1', '2', '3', '4', '5', '7'],
// Level 2: 가, 나, 다 (한글 한 글자)
2: ['', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''],
// Level 3: 알파벳 한 글자
3: ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'K', 'M', 'N', 'S', 'R', 'T'],
// Level 4: 3자 이하 한글 단어
4: ['사과', '포도', '나무', '바다', '하늘', '구름', '사랑', '친구', '가족', '대한민국', '무궁화'],
// Level 5: 5자 이하 영어 단어
5: ['CAT', 'DOG', 'BIRD', 'LOVE', 'MILK', 'BOOK', 'HAND', 'BLUE', 'ROSE', 'HAPPY'],
// Level 6: 복합 (한글 5자 이하 + 영어 8자 이하)
6: ['아이스크림', '코끼리', '바나나', '텔레비전', 'COMPUTER', 'ELEPHANT', 'MORNING', 'TEACHER', 'SUMMER'],
};
// 추후 이미지 레벨 (7, 8단계)
static final Map<int, List<String>> _imageLevels = {
7: ['assets/images/shapes/circle.png', 'assets/images/shapes/rect.png'], // 단순 도형
8: ['assets/images/shapes/star.png', 'assets/images/shapes/heart.png'], // 복잡 도형
};
/// 해당 레벨의 랜덤 콘텐츠 반환
static TracingContent getContent(int level) {
// 7단계 이상은 이미지 모드로 처리 (준비된 경우)
if (level >= 7) {
// 이미지가 준비되지 않았으면 6단계 텍스트로 대체 (안전장치)
if (!_imageLevels.containsKey(level)) return getContent(6);
final list = _imageLevels[level]!;
return TracingContent(
data: list[_random.nextInt(list.length)],
type: TracingContentType.image,
);
}
// 1~6단계 텍스트 모드
else {
// 레벨 범위를 벗어나면 최대 레벨로 고정
int targetLevel = level.clamp(1, 6);
final list = _textLevels[targetLevel]!;
return TracingContent(
data: list[_random.nextInt(list.length)],
type: TracingContentType.text,
);
}
}
}