...
This commit is contained in:
@@ -17,7 +17,6 @@ class CardFlipGameScreen extends StatefulWidget {
|
||||
class _CardFlipGameScreenState extends State<CardFlipGameScreen> {
|
||||
bool _isDialogShowing = false;
|
||||
|
||||
// 아이콘 풀
|
||||
static const List<IconData> _iconPool = [
|
||||
Icons.home, Icons.favorite, Icons.star, Icons.person, Icons.settings,
|
||||
Icons.lock, Icons.map, Icons.camera_alt, Icons.phone, Icons.music_note,
|
||||
@@ -31,13 +30,11 @@ class _CardFlipGameScreenState extends State<CardFlipGameScreen> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
// [🔥 신규] 게임 시작 전 가이드 표시
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
_showGameGuide();
|
||||
});
|
||||
}
|
||||
|
||||
// 🔽 [🔥 신규] 게임 가이드 다이얼로그
|
||||
void _showGameGuide() {
|
||||
final controller = context.read<CardFlipController>();
|
||||
final difficulty = controller.difficulty;
|
||||
@@ -55,7 +52,7 @@ class _CardFlipGameScreenState extends State<CardFlipGameScreen> {
|
||||
|
||||
showDialog(
|
||||
context: context,
|
||||
barrierDismissible: false, // 반드시 확인을 눌러야 함
|
||||
barrierDismissible: false,
|
||||
builder: (context) => AlertDialog(
|
||||
title: Text(title, style: const TextStyle(fontWeight: FontWeight.bold)),
|
||||
content: Text(message, style: const TextStyle(fontSize: 16), textAlign: TextAlign.center),
|
||||
@@ -63,7 +60,6 @@ class _CardFlipGameScreenState extends State<CardFlipGameScreen> {
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
// [🔥 핵심] 가이드 닫으면 타이머 시작
|
||||
controller.startGameTimer();
|
||||
},
|
||||
child: const Text("시작하기"),
|
||||
@@ -74,8 +70,17 @@ class _CardFlipGameScreenState extends State<CardFlipGameScreen> {
|
||||
}
|
||||
|
||||
void _showGameCompletion(CardFlipController controller) async {
|
||||
// [🔥 수정] 점수 포맷터: secondaryScore를 디코딩하여 표시
|
||||
// (secondary = matched * 1000 + (999 - flips))
|
||||
String formatScore(int primary, int? secondary) {
|
||||
return '남은 시간: ${primary}초 (시도: $secondary회)';
|
||||
if (secondary == null) return '${primary}초';
|
||||
|
||||
final int matched = secondary ~/ 1000;
|
||||
final int flips = 999 - (secondary % 1000);
|
||||
// (실패 횟수 = (총 뒤집기 - 정답매칭*2) / 2)
|
||||
final int mistakes = (flips - (matched * 2)) ~/ 2;
|
||||
|
||||
return '시간: ${primary}초 (성공:$matched / 실수:$mistakes)';
|
||||
}
|
||||
|
||||
Future<void> saveProgress(String playerName) async {
|
||||
@@ -94,6 +99,10 @@ class _CardFlipGameScreenState extends State<CardFlipGameScreen> {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// [🔥 수정] secondaryScore에 매칭 수와 클릭 수를 함께 인코딩 (정렬을 위해)
|
||||
// (많은 매칭 + 적은 클릭일수록 높은 값이 되도록 설계)
|
||||
final int encodedScore = (controller.matchedPairsCount * 1000) + (999 - controller.flipCount);
|
||||
|
||||
await Navigator.push(
|
||||
context,
|
||||
@@ -103,7 +112,7 @@ class _CardFlipGameScreenState extends State<CardFlipGameScreen> {
|
||||
gameType: 'CARD_FLIP',
|
||||
contextId: controller.difficulty.contextId,
|
||||
primaryScore: controller.remainingTime,
|
||||
secondaryScore: controller.flipCount,
|
||||
secondaryScore: encodedScore, // 👈 인코딩된 점수 전달
|
||||
userId: controller.userId,
|
||||
userName: controller.userName,
|
||||
scoreFormatter: formatScore,
|
||||
@@ -149,10 +158,24 @@ class _CardFlipGameScreenState extends State<CardFlipGameScreen> {
|
||||
),
|
||||
body: Column(
|
||||
children: [
|
||||
// 🔽 [🔥 수정] 상단 정보: 매칭 수 / 시도 횟수 표시
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Text("뒤집은 횟수: ${controller.flipCount}", style: TextStyle(fontSize: 16, color: theme.textTheme.bodyMedium?.color)),
|
||||
padding: const EdgeInsets.all(12.0),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
Text(
|
||||
"찾은 짝: ${controller.matchedPairsCount} / ${controller.totalPairsCount}",
|
||||
style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold, color: theme.primaryColor)
|
||||
),
|
||||
Text(
|
||||
"뒤집기: ${controller.flipCount}",
|
||||
style: const TextStyle(fontSize: 16, color: Colors.grey)
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
Expanded(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
@@ -206,7 +229,6 @@ class _CardFlipGameScreenState extends State<CardFlipGameScreen> {
|
||||
);
|
||||
}
|
||||
|
||||
// 🔽 [🔥 수정] displayContent 사용
|
||||
Widget _buildCardContent(CardItem card) {
|
||||
if (card.displayContent.startsWith("ICON_")) {
|
||||
final int iconIndex = int.tryParse(card.displayContent.split('_')[1]) ?? 0;
|
||||
@@ -218,7 +240,7 @@ class _CardFlipGameScreenState extends State<CardFlipGameScreen> {
|
||||
child: FittedBox(
|
||||
fit: BoxFit.scaleDown,
|
||||
child: Text(
|
||||
card.displayContent, // 👈 displayContent 표시
|
||||
card.displayContent,
|
||||
style: const TextStyle(fontSize: 32, fontWeight: FontWeight.bold),
|
||||
),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user