diff --git a/lib/services/config_service.dart b/lib/services/config_service.dart index 70f6133..02edc7d 100644 --- a/lib/services/config_service.dart +++ b/lib/services/config_service.dart @@ -6,12 +6,15 @@ import 'package:shared_preferences/shared_preferences.dart'; class ConfigService { static const String _keyPointLimit = 'pointLimit'; static const String _keyCaboPenalty = 'caboPenalty'; + static const String _keyGameMode = 'gameMode'; // Actual values used in the app static int pointLimit = 100; static int caboPenalty = 5; + static int gameMode = -1; // Default values static const int _defaultPointLimit = 100; static const int _defaultCaboPenalty = 5; + static const int _defaultGameMode = -1; static Future initConfig() async { final prefs = await SharedPreferences.getInstance(); @@ -21,6 +24,13 @@ class ConfigService { _keyPointLimit, prefs.getInt(_keyPointLimit) ?? _defaultPointLimit); prefs.setInt( _keyCaboPenalty, prefs.getInt(_keyCaboPenalty) ?? _defaultCaboPenalty); + prefs.setInt(_keyGameMode, prefs.getInt(_keyGameMode) ?? _defaultGameMode); + } + + static Future setGameMode(int newGameMode) async { + final prefs = await SharedPreferences.getInstance(); + await prefs.setInt(_keyGameMode, newGameMode); + gameMode = newGameMode; } /// Getter for the point limit. @@ -34,6 +44,7 @@ class ConfigService { static Future setPointLimit(int newPointLimit) async { final prefs = await SharedPreferences.getInstance(); await prefs.setInt(_keyPointLimit, newPointLimit); + pointLimit = newPointLimit; } /// Getter for the cabo penalty. @@ -47,6 +58,7 @@ class ConfigService { static Future setCaboPenalty(int newCaboPenalty) async { final prefs = await SharedPreferences.getInstance(); await prefs.setInt(_keyCaboPenalty, newCaboPenalty); + caboPenalty = newCaboPenalty; } /// Resets the configuration to default values.