fix(presentation): recover from game-over back gesture, show final score, guard hint, constants
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
e62c8a9034
commit
dc7e681508
@ -39,6 +39,7 @@ class _GameOverPageState extends ConsumerState<GameOverPage> {
|
|||||||
final String pokemonImage = args?['pokemonImage'] ?? '';
|
final String pokemonImage = args?['pokemonImage'] ?? '';
|
||||||
final String pokemonName = args?['pokemonName'] ?? 'Unknown';
|
final String pokemonName = args?['pokemonName'] ?? 'Unknown';
|
||||||
final int streak = args?['streak'] ?? 0;
|
final int streak = args?['streak'] ?? 0;
|
||||||
|
final int score = args?['score'] ?? 0;
|
||||||
|
|
||||||
// Pad streak with zeroes to 3 digits as in mockup (e.g. 004)
|
// Pad streak with zeroes to 3 digits as in mockup (e.g. 004)
|
||||||
final String streakText = streak.toString().padLeft(3, '0');
|
final String streakText = streak.toString().padLeft(3, '0');
|
||||||
@ -241,6 +242,35 @@ class _GameOverPageState extends ConsumerState<GameOverPage> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
const SizedBox(width: 16),
|
||||||
|
Expanded(
|
||||||
|
child: Container(
|
||||||
|
color: statBoxBg,
|
||||||
|
padding: const EdgeInsets.symmetric(vertical: 12),
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
const Text(
|
||||||
|
"SCORE",
|
||||||
|
style: TextStyle(
|
||||||
|
color: Colors.red,
|
||||||
|
fontSize: 10,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
letterSpacing: 1,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 4),
|
||||||
|
Text(
|
||||||
|
"$score",
|
||||||
|
style: const TextStyle(
|
||||||
|
color: Colors.black,
|
||||||
|
fontSize: 16,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
|
import '../../core/config/app_constants.dart';
|
||||||
import '../../domain/game/game_state.dart';
|
import '../../domain/game/game_state.dart';
|
||||||
import '../providers/game_provider.dart';
|
import '../providers/game_provider.dart';
|
||||||
import '../providers/navigation_provider.dart';
|
import '../providers/navigation_provider.dart';
|
||||||
@ -75,12 +76,17 @@ class _GuessPageState extends ConsumerState<GuessPage> {
|
|||||||
) as bool?;
|
) as bool?;
|
||||||
|
|
||||||
if (!mounted) return;
|
if (!mounted) return;
|
||||||
if (playAgain == true) {
|
if (playAgain == false) {
|
||||||
await ref.read(gameProvider.notifier).startNewGame();
|
|
||||||
} else if (playAgain == false) {
|
|
||||||
ref.read(selectedTabProvider.notifier).set(0); // onglet LIST
|
ref.read(selectedTabProvider.notifier).set(0); // onglet LIST
|
||||||
|
}
|
||||||
|
// true (Try Again), false (Back to Pokédex) et null (geste retour système)
|
||||||
|
// relancent tous une nouvelle partie pour ne pas rester bloqué en game over.
|
||||||
await ref.read(gameProvider.notifier).startNewGame();
|
await ref.read(gameProvider.notifier).startNewGame();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String _maskedName(String name) {
|
||||||
|
if (name.length <= 2) return name; // trop court pour masquer utilement
|
||||||
|
return '${name[0]}${List.filled(name.length - 2, '_').join()}${name[name.length - 1]}';
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -167,7 +173,7 @@ class _GuessPageState extends ConsumerState<GuessPage> {
|
|||||||
// Lives
|
// Lives
|
||||||
Row(
|
Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: List.generate(3, (index) {
|
children: List.generate(AppConstants.startingLives, (index) {
|
||||||
return Icon(
|
return Icon(
|
||||||
index < state.lives ? Icons.favorite : Icons.favorite_border,
|
index < state.lives ? Icons.favorite : Icons.favorite_border,
|
||||||
color: Colors.red,
|
color: Colors.red,
|
||||||
@ -196,7 +202,7 @@ class _GuessPageState extends ConsumerState<GuessPage> {
|
|||||||
borderRadius: BorderRadius.circular(8),
|
borderRadius: BorderRadius.circular(8),
|
||||||
),
|
),
|
||||||
child: Text(
|
child: Text(
|
||||||
"HINT: ${pokemon.formatedName[0]}${List.filled(pokemon.formatedName.length - 2, '_').join()}${pokemon.formatedName[pokemon.formatedName.length - 1]}",
|
"HINT: ${_maskedName(pokemon.formatedName)}",
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
style: TextStyle(fontSize: 22, fontWeight: FontWeight.bold, color: Colors.amber[900], letterSpacing: 4),
|
style: TextStyle(fontSize: 22, fontWeight: FontWeight.bold, color: Colors.amber[900], letterSpacing: 4),
|
||||||
),
|
),
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user