fix level progress calculation for level 1
This commit is contained in:
parent
66a59d233a
commit
62cec74cab
2 changed files with 11 additions and 6 deletions
|
|
@ -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…
Add table
Reference in a new issue