Implemented previous rounds points getting shown when opened again
This commit is contained in:
@@ -1,5 +1,3 @@
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:cabo_counter/data/game_session.dart';
|
||||
import 'package:cabo_counter/views/active_game_view.dart';
|
||||
import 'package:cabo_counter/views/create_game_view.dart';
|
||||
@@ -41,7 +39,7 @@ class _MainMenuViewState extends State<MainMenuView> {
|
||||
];
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
randomizeRoundNumbers();
|
||||
calculateRoundNumbers();
|
||||
|
||||
return CupertinoPageScaffold(
|
||||
navigationBar: CupertinoNavigationBar(
|
||||
@@ -118,10 +116,9 @@ class _MainMenuViewState extends State<MainMenuView> {
|
||||
}
|
||||
}
|
||||
|
||||
void randomizeRoundNumbers() {
|
||||
var random = Random();
|
||||
void calculateRoundNumbers() {
|
||||
for (var s in gameSessionArray) {
|
||||
s.round = random.nextInt(20);
|
||||
s.round = s.playerScores[0].length - 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,6 +39,20 @@ class _RoundViewState extends State<RoundView> {
|
||||
@override
|
||||
void initState() {
|
||||
print('Runde ${widget.roundNumber} geöffnet');
|
||||
print(
|
||||
'Schon gespielte Runden: ${widget.gameSession.playerScores[0].length}');
|
||||
if (widget.gameSession.round < widget.gameSession.playerScores[0].length) {
|
||||
print(
|
||||
'Die Länge ist ${widget.gameSession.playerScores[0].length} und somit kleiner als '
|
||||
'die Runde ${widget.gameSession.round}');
|
||||
|
||||
// If the current round has already been played, the text fields are filled
|
||||
// with the scores from this round
|
||||
for (int i = 0; i < _pointControllers.length; i++) {
|
||||
_pointControllers[i].text =
|
||||
gameSession.playerScores[i][widget.roundNumber].toString();
|
||||
}
|
||||
}
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@@ -263,18 +277,19 @@ class _RoundViewState extends State<RoundView> {
|
||||
}
|
||||
|
||||
bool _areRoundInputsValid() {
|
||||
if (_kamikazePlayerIndex == null) {
|
||||
return false;
|
||||
} else {
|
||||
for (TextEditingController c in _pointControllers) {
|
||||
if (c.text.isEmpty) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (_areTextFieldsEmpty() && _kamikazePlayerIndex == null) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool _areTextFieldsEmpty() {
|
||||
for (TextEditingController t in _pointControllers) {
|
||||
if (t.text.isEmpty) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void _finishRound() {
|
||||
print('====================================');
|
||||
print('Runde ${widget.roundNumber} beendet');
|
||||
|
||||
Reference in New Issue
Block a user