This commit is contained in:
2025-11-07 17:07:22 +09:00
parent db5bb090f4
commit 9225ee6026
138 changed files with 6041 additions and 0 deletions
+15
View File
@@ -0,0 +1,15 @@
// lib/models/game_rank_dto.dart
class GameRankDto {
final String playerName;
final int primaryScore; // 스도쿠에서는 시간(초)
GameRankDto({required this.playerName, required this.primaryScore});
factory GameRankDto.fromJson(Map<String, dynamic> json) {
return GameRankDto(
playerName: json['playerName'],
primaryScore: (json['primaryScore'] as num).toInt(),
);
}
}
+26
View File
@@ -0,0 +1,26 @@
// lib/models/sudoku_game_dto.dart
// 🔽 [수정] PuzzleData.kt의 새 DTO (puzzleId -> blockSize)
class SudokuGameDto {
final String question;
final String solution;
final int blockSize; // 예: 3 (3x3 블록)
// 🔽 [추가] blockSize로부터 gridSize 계산 (예: 9)
final int gridSize;
SudokuGameDto({
required this.question,
required this.solution,
required this.blockSize,
}) : gridSize = blockSize * blockSize; // 생성 시 gridSize 자동 계산
factory SudokuGameDto.fromJson(Map<String, dynamic> json) {
int bs = json['blockSize'] ?? 3;
return SudokuGameDto(
question: json['question'],
solution: json['solution'],
blockSize: bs,
);
}
}
+112
View File
@@ -0,0 +1,112 @@
// lib/models/sudoku_theme.dart
import 'package:flutter/material.dart';
// 1. SudokuTheme 클래스
// '게임 시작' 시점에 동적으로 생성될 객체입니다.
class SudokuTheme {
final String name; // "숫자", "알파벳", "과일"
final List<String> symbols; // 👈 '게임에 실제 사용할' 무작위로 뽑힌 기호 리스트
const SudokuTheme({required this.name, required this.symbols});
// 1-based 정수(1)를 테마 기호("🍎")로 변환
String getSymbol(int value) {
if (value > 0 && value <= symbols.length) {
return symbols[value - 1]; // 1 -> index 0
}
return '?';
}
// 테마 기호("🍎")를 1-based 정수(1)로 변환
int getValue(String symbol) {
int index = symbols.indexOf(symbol);
if (index != -1) {
return index + 1; // index 0 -> 1
}
return 0;
}
}
// 2. AppThemes 클래스 (테마 저장소 역할)
class AppThemes {
// --- 테마 이름 정의 ---
static const String random = "랜덤";
static const String numbers = "숫자";
static const String letters = "알파벳";
static const String fruits = "과일";
static const String korean = "한글";
static const String animals = "동물";
// --- 1. 거대한 '상징 풀' 정의 (25개 이상) ---
static const List<String> _numberPool = [
"1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16",
"17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30"
];
static const List<String> _letterPool = [
"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P",
"Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"
];
static const List<String> _fruitPool = [
"🍎", "🍌", "🍇", "🍓", "🍊", "🍋", "🍉", "🍑", "🍒", "🥝", "🥥", "🍍", "🥑", "🍆", "🍅", "🌽",
"🥕", "🫑", "🌶️", "🥦", "🥬", "🥒", "🍄", "🥜", "🫘", "🍏", "🍐", "🍈", "🥭", "🫒"
];
static const List<String> _koreanPool = [
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
"", "", "", "", "", "", "", "", "", "", "", "", "", ""
];
static const List<String> _animalPool = [
"🐶", "🐱", "🐭", "🐹", "🐰", "🦊", "🐻", "🐼", "🐨", "🐯", "🦁", "🐮", "🐷", "🐸", "🐵", "🐔",
"🐧", "🐦", "🐤", "🦆", "🦅", "🦉", "🦇", "🐺", "🐗", "🐴", "🦄", "🐝", "🐛", "🦋"
];
// --- 2. 홈 화면 '선택' 메뉴에 표시될 이름 리스트 ---
static final List<String> selectableThemeNames = [
random,
numbers,
letters,
fruits,
korean,
animals
];
// --- 3. 테마 이름과 실제 '상징 풀'을 매핑 ---
static final Map<String, List<String>> _themePools = {
numbers: _numberPool,
letters: _letterPool,
fruits: _fruitPool,
korean: _koreanPool,
animals: _animalPool,
};
// --- 4. [핵심] 게임 시작 시 호출될 테마 '빌더' 함수 ---
static SudokuTheme buildGameTheme(String themeName, int gridSize) {
String effectiveThemeName = themeName;
// 1. "랜덤"이 선택된 경우
if (themeName == random) {
// "랜덤"을 제외한 실제 테마 이름 리스트에서 무작위로 하나 선택
final actualThemes = _themePools.keys.toList();
effectiveThemeName = (actualThemes..shuffle()).first;
}
// 2. 해당 테마의 '거대 풀'을 가져옴 (없으면 숫자로 대체)
final List<String> pool = _themePools[effectiveThemeName] ?? _numberPool;
// 3. 거대 풀을 섞은 뒤, 게임에 필요한 만큼(gridSize)만 뽑음
if (pool.length < gridSize) {
throw Exception("$effectiveThemeName 테마의 상징이 ${pool.length}개뿐입니다. $gridSize개가 필요합니다.");
}
final List<String> selectedSymbols = (pool.toList()..shuffle()).sublist(0, gridSize);
// 4. 이 게임만을 위한 '일회용' SudokuTheme 객체를 생성하여 반환
return SudokuTheme(
name: effectiveThemeName, // 실제 사용된 테마 이름 (예: "과일")
symbols: selectedSymbols, // 무작위로 뽑힌 기호 리스트
);
}
}
+28
View File
@@ -0,0 +1,28 @@
// lib/models/unified_rank_dto.dart
class UnifiedRankDto {
final String gameType;
final String? contextId;
final String playerName;
final int primaryScore;
final int? secondaryScore;
UnifiedRankDto({
required this.gameType,
this.contextId,
required this.playerName,
required this.primaryScore,
this.secondaryScore,
});
// Dart 객체를 JSON으로 변환 (서버 전송용)
Map<String, dynamic> toJson() {
return {
'gameType': gameType,
'contextId': contextId,
'playerName': playerName,
'primaryScore': primaryScore,
'secondaryScore': secondaryScore,
};
}
}
+11
View File
@@ -0,0 +1,11 @@
class ValidateResultDto {
final bool isCorrect;
ValidateResultDto({required this.isCorrect});
factory ValidateResultDto.fromJson(Map<String, dynamic> json) {
return ValidateResultDto(
isCorrect: json['correct'] ?? false,
);
}
}