164 lines
6.1 KiB
Dart
164 lines
6.1 KiB
Dart
// lib/screens/game_results_screen.dart
|
|
|
|
import 'package:flutter/material.dart';
|
|
import 'package:provider/provider.dart';
|
|
import 'package:kzeduca_app/providers/game_state_provider.dart';
|
|
import 'package:kzeduca_app/models/attributes.dart';
|
|
import 'package:kzeduca_app/screens/start_screen.dart'; // Para voltar ao início
|
|
|
|
class GameResultsScreen extends StatelessWidget {
|
|
const GameResultsScreen({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
backgroundColor: Colors.black,
|
|
body: Consumer<GameStateProvider>(
|
|
builder: (context, gameState, child) {
|
|
final character = gameState.playerCharacter;
|
|
|
|
if (character == null) {
|
|
return const Center(
|
|
child: Text(
|
|
"Erro: Dados do jogador não encontrados.",
|
|
style: TextStyle(color: Colors.white),
|
|
),
|
|
);
|
|
}
|
|
|
|
final attributes = character.attributes;
|
|
final resultTitle = _determineGameResult(attributes);
|
|
final resultDescription = _generateResultDescription(attributes);
|
|
|
|
return Padding(
|
|
padding: const EdgeInsets.all(24.0),
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
children: [
|
|
const Icon(
|
|
Icons.emoji_events,
|
|
color: Colors.white,
|
|
size: 80,
|
|
),
|
|
const SizedBox(height: 20),
|
|
Text(
|
|
resultTitle,
|
|
style: const TextStyle(
|
|
color: Colors.white,
|
|
fontSize: 32,
|
|
fontWeight: FontWeight.bold,
|
|
),
|
|
textAlign: TextAlign.center,
|
|
),
|
|
const SizedBox(height: 10),
|
|
Text(
|
|
resultDescription,
|
|
style: const TextStyle(
|
|
color: Colors.white70,
|
|
fontSize: 18,
|
|
),
|
|
textAlign: TextAlign.center,
|
|
),
|
|
const SizedBox(height: 40),
|
|
_buildFinalAttributes(attributes),
|
|
const SizedBox(height: 40),
|
|
ElevatedButton(
|
|
onPressed: () {
|
|
// Reinicia o jogo
|
|
Navigator.pushAndRemoveUntil(
|
|
context,
|
|
MaterialPageRoute(builder: (context) => const StartScreen()),
|
|
(Route<dynamic> route) => false,
|
|
);
|
|
},
|
|
style: ElevatedButton.styleFrom(
|
|
foregroundColor: Colors.white,
|
|
backgroundColor: const Color(0xFF8A2BE2),
|
|
padding: const EdgeInsets.symmetric(vertical: 15),
|
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)),
|
|
),
|
|
child: const Text(
|
|
"Jogar Novamente",
|
|
style: TextStyle(fontSize: 18),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
},
|
|
),
|
|
);
|
|
}
|
|
|
|
String _determineGameResult(Attributes attributes) {
|
|
if (attributes.money < 0 || attributes.health <= 0.2 || attributes.happiness <= 0.2) {
|
|
return "Fim de Jogo: Jornada Interrompida";
|
|
}
|
|
if (attributes.professionalExperience >= 0.8 && attributes.education >= 0.8) {
|
|
return "Vitória: Sucesso Financeiro e Profissional!";
|
|
}
|
|
if (attributes.money >= 50000 && attributes.happiness >= 0.7) {
|
|
return "Vitória: Vida Confortável e Feliz!";
|
|
}
|
|
return "Fim de Jogo: Uma Jornada Concluída";
|
|
}
|
|
|
|
String _generateResultDescription(Attributes attributes) {
|
|
if (attributes.money < 0) {
|
|
return "A sua falta de controlo financeiro levou à ruína. Não conseguiu suportar as suas despesas.";
|
|
}
|
|
if (attributes.health <= 0.2) {
|
|
return "O stress e a exaustão minaram a sua saúde. Não conseguiu continuar a sua jornada.";
|
|
}
|
|
if (attributes.happiness <= 0.2) {
|
|
return "As suas decisões levaram a uma vida infeliz. O desânimo e a tristeza puseram fim à sua aventura.";
|
|
}
|
|
if (attributes.professionalExperience >= 0.8) {
|
|
return "Com muita dedicação, alcançou o auge da sua carreira. O seu sucesso profissional é inquestionável.";
|
|
}
|
|
if (attributes.money >= 50000) {
|
|
return "Acumulou uma quantia considerável de dinheiro, garantindo uma vida confortável e sem preocupações.";
|
|
}
|
|
return "A sua jornada foi uma montanha-russa de experiências. Nem tudo foi perfeito, mas você aprendeu e cresceu com cada decisão.";
|
|
}
|
|
|
|
Widget _buildFinalAttributes(Attributes attributes) {
|
|
return Card(
|
|
color: const Color(0xFF1C1C1C),
|
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(15)),
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(20.0),
|
|
child: Column(
|
|
children: [
|
|
_buildAttributeItem("Dinheiro", "${attributes.money.toStringAsFixed(2)} Kz", Colors.green),
|
|
_buildAttributeItem("Saúde", "${(attributes.health * 100).toStringAsFixed(0)}%", Colors.red),
|
|
_buildAttributeItem("Felicidade", "${(attributes.happiness * 100).toStringAsFixed(0)}%", Colors.yellow),
|
|
_buildAttributeItem("Educação", "${(attributes.education * 100).toStringAsFixed(0)}%", Colors.blue),
|
|
_buildAttributeItem("Experiência Profissional", "${(attributes.professionalExperience * 100).toStringAsFixed(0)}%", Colors.orange),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget _buildAttributeItem(String label, String value, Color color) {
|
|
return Padding(
|
|
padding: const EdgeInsets.symmetric(vertical: 8.0),
|
|
child: Row(
|
|
children: [
|
|
Expanded(
|
|
child: Text(
|
|
"$label:",
|
|
style: const TextStyle(color: Colors.white70, fontSize: 16),
|
|
),
|
|
),
|
|
Text(
|
|
value,
|
|
style: TextStyle(color: color, fontSize: 16, fontWeight: FontWeight.bold),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
} |