Merge pull request #144 from flixcoo/bug/140-game-stays-finished
Game stays finished
This commit is contained in:
@@ -247,17 +247,23 @@ class GameSession extends ChangeNotifier {
|
|||||||
List<int> updatePoints() {
|
List<int> updatePoints() {
|
||||||
List<int> bonusPlayers = [];
|
List<int> bonusPlayers = [];
|
||||||
_sumPoints();
|
_sumPoints();
|
||||||
|
bool limitExceeded = false;
|
||||||
|
|
||||||
if (isPointsLimitEnabled) {
|
if (isPointsLimitEnabled) {
|
||||||
bonusPlayers = _checkHundredPointsReached();
|
bonusPlayers = _checkHundredPointsReached();
|
||||||
|
|
||||||
for (int i = 0; i < playerScores.length; i++) {
|
for (int i = 0; i < playerScores.length; i++) {
|
||||||
if (playerScores[i] > pointLimit) {
|
if (playerScores[i] > pointLimit) {
|
||||||
isGameFinished = true;
|
isGameFinished = true;
|
||||||
|
limitExceeded = true;
|
||||||
print('${players[i]} hat die 100 Punkte ueberschritten, '
|
print('${players[i]} hat die 100 Punkte ueberschritten, '
|
||||||
'deswegen wurde das Spiel beendet');
|
'deswegen wurde das Spiel beendet');
|
||||||
setWinner();
|
setWinner();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!limitExceeded) {
|
||||||
|
isGameFinished = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
return bonusPlayers;
|
return bonusPlayers;
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import 'package:cabo_counter/core/constants.dart';
|
import 'package:cabo_counter/core/constants.dart';
|
||||||
import 'package:cabo_counter/core/custom_theme.dart';
|
import 'package:cabo_counter/core/custom_theme.dart';
|
||||||
import 'package:cabo_counter/data/game_manager.dart';
|
import 'package:cabo_counter/data/game_manager.dart';
|
||||||
|
import 'package:cabo_counter/data/game_session.dart';
|
||||||
import 'package:cabo_counter/l10n/generated/app_localizations.dart';
|
import 'package:cabo_counter/l10n/generated/app_localizations.dart';
|
||||||
import 'package:cabo_counter/presentation/views/active_game_view.dart';
|
import 'package:cabo_counter/presentation/views/active_game_view.dart';
|
||||||
import 'package:cabo_counter/presentation/views/create_game_view.dart';
|
import 'package:cabo_counter/presentation/views/create_game_view.dart';
|
||||||
@@ -135,7 +136,7 @@ class _MainMenuViewState extends State<MainMenuView> {
|
|||||||
subtitle: Visibility(
|
subtitle: Visibility(
|
||||||
visible: session.isGameFinished,
|
visible: session.isGameFinished,
|
||||||
replacement: Text(
|
replacement: Text(
|
||||||
'${AppLocalizations.of(context).mode}: ${_translateGameMode(session.isPointsLimitEnabled)}',
|
'${AppLocalizations.of(context).mode}: ${_translateGameMode(session)}',
|
||||||
style: const TextStyle(fontSize: 14),
|
style: const TextStyle(fontSize: 14),
|
||||||
),
|
),
|
||||||
child: Text(
|
child: Text(
|
||||||
@@ -216,9 +217,9 @@ class _MainMenuViewState extends State<MainMenuView> {
|
|||||||
|
|
||||||
/// Translates the game mode boolean into the corresponding String.
|
/// Translates the game mode boolean into the corresponding String.
|
||||||
/// If [pointLimit] is true, it returns '101 Punkte', otherwise it returns 'Unbegrenzt'.
|
/// If [pointLimit] is true, it returns '101 Punkte', otherwise it returns 'Unbegrenzt'.
|
||||||
String _translateGameMode(bool isPointLimitEnabled) {
|
String _translateGameMode(GameSession gameSession) {
|
||||||
if (isPointLimitEnabled) {
|
if (gameSession.isPointsLimitEnabled) {
|
||||||
return '${ConfigService.getPointLimit()} ${AppLocalizations.of(context).points}';
|
return '${gameSession.pointLimit} ${AppLocalizations.of(context).points}';
|
||||||
}
|
}
|
||||||
return AppLocalizations.of(context).unlimited;
|
return AppLocalizations.of(context).unlimited;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ name: cabo_counter
|
|||||||
description: "Mobile app for the card game Cabo"
|
description: "Mobile app for the card game Cabo"
|
||||||
publish_to: 'none'
|
publish_to: 'none'
|
||||||
|
|
||||||
version: 0.5.3+596
|
version: 0.5.3+598
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ^3.5.4
|
sdk: ^3.5.4
|
||||||
|
|||||||
Reference in New Issue
Block a user