@@ -26,39 +26,42 @@ class FSRS {
26
26
final s = SchedulingCards (card);
27
27
s.updateState (card.state);
28
28
29
- if (card.state == State .newState) {
30
- _initDS (s);
31
-
32
- s.again.due = now.add (Duration (minutes: 1 ));
33
- s.hard.due = now.add (Duration (minutes: 5 ));
34
- s.good.due = now.add (Duration (minutes: 10 ));
35
- final easyInterval = _nextInterval (s.easy.stability);
36
- s.easy.scheduledDays = easyInterval;
37
- s.easy.due = now.add (Duration (days: easyInterval));
38
- } else if (card.state == State .learning || card.state == State .relearning) {
39
- final hardInterval = 0 ;
40
- final goodInterval = _nextInterval (s.good.stability);
41
- final easyInterval =
42
- max (_nextInterval (s.easy.stability), goodInterval + 1 );
43
-
44
- s.schedule (now, hardInterval.toDouble (), goodInterval.toDouble (),
45
- easyInterval.toDouble ());
46
- } else if (card.state == State .review) {
47
- final interval = card.elapsedDays;
48
- final lastD = card.difficulty;
49
- final lastS = card.stability;
50
- final retrievability = _forgettingCurve (interval, lastS);
51
- _nextDS (s, lastD, lastS, retrievability);
52
-
53
- var hardInterval = _nextInterval (s.hard.stability);
54
- var goodInterval = _nextInterval (s.good.stability);
55
- hardInterval = min (hardInterval, goodInterval);
56
- goodInterval = max (goodInterval, hardInterval + 1 );
57
- final easyInterval =
58
- max (_nextInterval (s.easy.stability), goodInterval + 1 );
59
- s.schedule (now, hardInterval.toDouble (), goodInterval.toDouble (),
60
- easyInterval.toDouble ());
29
+ switch (card.state) {
30
+ case State .newState:
31
+ _initDS (s);
32
+
33
+ s.again.due = now.add (Duration (minutes: 1 ));
34
+ s.hard.due = now.add (Duration (minutes: 5 ));
35
+ s.good.due = now.add (Duration (minutes: 10 ));
36
+ final easyInterval = _nextInterval (s.easy.stability);
37
+ s.easy.scheduledDays = easyInterval;
38
+ s.easy.due = now.add (Duration (days: easyInterval));
39
+ case State .learning:
40
+ case State .relearning:
41
+ final hardInterval = 0 ;
42
+ final goodInterval = _nextInterval (s.good.stability);
43
+ final easyInterval =
44
+ max (_nextInterval (s.easy.stability), goodInterval + 1 );
45
+
46
+ s.schedule (now, hardInterval.toDouble (), goodInterval.toDouble (),
47
+ easyInterval.toDouble ());
48
+ case State .review:
49
+ final interval = card.elapsedDays;
50
+ final lastD = card.difficulty;
51
+ final lastS = card.stability;
52
+ final retrievability = _forgettingCurve (interval, lastS);
53
+ _nextDS (s, lastD, lastS, retrievability);
54
+
55
+ var hardInterval = _nextInterval (s.hard.stability);
56
+ var goodInterval = _nextInterval (s.good.stability);
57
+ hardInterval = min (hardInterval, goodInterval);
58
+ goodInterval = max (goodInterval, hardInterval + 1 );
59
+ final easyInterval =
60
+ max (_nextInterval (s.easy.stability), goodInterval + 1 );
61
+ s.schedule (now, hardInterval.toDouble (), goodInterval.toDouble (),
62
+ easyInterval.toDouble ());
61
63
}
64
+
62
65
return s.recordLog (card, now);
63
66
}
64
67
0 commit comments