Added gameMode
This commit is contained in:
@@ -6,12 +6,15 @@ import 'package:shared_preferences/shared_preferences.dart';
|
|||||||
class ConfigService {
|
class ConfigService {
|
||||||
static const String _keyPointLimit = 'pointLimit';
|
static const String _keyPointLimit = 'pointLimit';
|
||||||
static const String _keyCaboPenalty = 'caboPenalty';
|
static const String _keyCaboPenalty = 'caboPenalty';
|
||||||
|
static const String _keyGameMode = 'gameMode';
|
||||||
// Actual values used in the app
|
// Actual values used in the app
|
||||||
static int pointLimit = 100;
|
static int pointLimit = 100;
|
||||||
static int caboPenalty = 5;
|
static int caboPenalty = 5;
|
||||||
|
static int gameMode = -1;
|
||||||
// Default values
|
// Default values
|
||||||
static const int _defaultPointLimit = 100;
|
static const int _defaultPointLimit = 100;
|
||||||
static const int _defaultCaboPenalty = 5;
|
static const int _defaultCaboPenalty = 5;
|
||||||
|
static const int _defaultGameMode = -1;
|
||||||
|
|
||||||
static Future<void> initConfig() async {
|
static Future<void> initConfig() async {
|
||||||
final prefs = await SharedPreferences.getInstance();
|
final prefs = await SharedPreferences.getInstance();
|
||||||
@@ -21,6 +24,13 @@ class ConfigService {
|
|||||||
_keyPointLimit, prefs.getInt(_keyPointLimit) ?? _defaultPointLimit);
|
_keyPointLimit, prefs.getInt(_keyPointLimit) ?? _defaultPointLimit);
|
||||||
prefs.setInt(
|
prefs.setInt(
|
||||||
_keyCaboPenalty, prefs.getInt(_keyCaboPenalty) ?? _defaultCaboPenalty);
|
_keyCaboPenalty, prefs.getInt(_keyCaboPenalty) ?? _defaultCaboPenalty);
|
||||||
|
prefs.setInt(_keyGameMode, prefs.getInt(_keyGameMode) ?? _defaultGameMode);
|
||||||
|
}
|
||||||
|
|
||||||
|
static Future<void> setGameMode(int newGameMode) async {
|
||||||
|
final prefs = await SharedPreferences.getInstance();
|
||||||
|
await prefs.setInt(_keyGameMode, newGameMode);
|
||||||
|
gameMode = newGameMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Getter for the point limit.
|
/// Getter for the point limit.
|
||||||
@@ -34,6 +44,7 @@ class ConfigService {
|
|||||||
static Future<void> setPointLimit(int newPointLimit) async {
|
static Future<void> setPointLimit(int newPointLimit) async {
|
||||||
final prefs = await SharedPreferences.getInstance();
|
final prefs = await SharedPreferences.getInstance();
|
||||||
await prefs.setInt(_keyPointLimit, newPointLimit);
|
await prefs.setInt(_keyPointLimit, newPointLimit);
|
||||||
|
pointLimit = newPointLimit;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Getter for the cabo penalty.
|
/// Getter for the cabo penalty.
|
||||||
@@ -47,6 +58,7 @@ class ConfigService {
|
|||||||
static Future<void> setCaboPenalty(int newCaboPenalty) async {
|
static Future<void> setCaboPenalty(int newCaboPenalty) async {
|
||||||
final prefs = await SharedPreferences.getInstance();
|
final prefs = await SharedPreferences.getInstance();
|
||||||
await prefs.setInt(_keyCaboPenalty, newCaboPenalty);
|
await prefs.setInt(_keyCaboPenalty, newCaboPenalty);
|
||||||
|
caboPenalty = newCaboPenalty;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Resets the configuration to default values.
|
/// Resets the configuration to default values.
|
||||||
|
|||||||
Reference in New Issue
Block a user