-
Notifications
You must be signed in to change notification settings - Fork 22
/
sm.dart
40 lines (36 loc) · 871 Bytes
/
sm.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import 'package:sm2/SmResponse.dart';
class Sm {
SmResponse calc({
int quality,
int repetitions,
int previousInterval,
double previousEaseFactor,
}) {
int interval;
double easeFactor;
if (quality >= 3) {
switch (repetitions) {
case 0:
interval = 1;
break;
case 1:
interval = 6;
break;
default:
interval = (previousInterval * previousEaseFactor).round();
}
repetitions++;
easeFactor = previousEaseFactor +
(0.1 - (5 - quality) * (0.08 + (5 - quality) * 0.02));
} else {
repetitions = 0;
interval = 1;
easeFactor = previousEaseFactor;
}
if (easeFactor < 1.3) {
easeFactor = 1.3;
}
return SmResponse(
interval: interval, repetitions: repetitions, easeFactor: easeFactor);
}
}