fix level progress calculation for level 1

pull/1490/head
ggurdin 1 year ago
parent 66a59d233a
commit 62cec74cab
No known key found for this signature in database
GPG Key ID: A01CB41737CBB478

@ -35,13 +35,19 @@ class GetAnalyticsController {
Client get _client => _pangeaController.matrixState.client;
// the minimum XP required for a given level
double get _minXPForLevel {
return 12.5 * (2 * pow(constructListModel.level - 1, 2) - 1);
int get _minXPForLevel {
return _calculateMinXpForLevel(constructListModel.level);
}
// the minimum XP required for the next level
double get _minXPForNextLevel {
return 12.5 * (2 * pow(constructListModel.level, 2) - 1);
int get _minXPForNextLevel {
return _calculateMinXpForLevel(constructListModel.level + 1);
}
/// Calculates the minimum XP required for a specific level.
int _calculateMinXpForLevel(int level) {
if (level == 1) return 0; // Ensure level 1 starts at 0 XP
return ((100 / 8) * (2 * pow(level - 1, 2))).floor();
}
// the progress within the current level as a percentage (0.0 to 1.0)
@ -75,7 +81,6 @@ class GetAnalyticsController {
constructListModel.dispose();
_analyticsUpdateSubscription?.cancel();
_analyticsUpdateSubscription = null;
analyticsStream.close();
initCompleter = null;
_cache.clear();
}

@ -146,7 +146,7 @@ class PutAnalyticsController extends BaseController<AnalyticsStream> {
);
}
Future<void> _onUpdateLanguages(String previousL2) async {
Future<void> _onUpdateLanguages(String? previousL2) async {
await sendLocalAnalyticsToAnalyticsRoom(
l2Override: previousL2,
);

Loading…
Cancel
Save