use of com.ichi2.utils.JSONObject in project AnkiChinaAndroid by ankichinateam.
the class SchedV2 method _startingLeft.
// Overriden: V1 has type rev for relearinng
protected int _startingLeft(@NonNull Card card) {
JSONObject conf;
if (card.getType() == Consts.CARD_TYPE_RELEARNING) {
conf = _lapseConf(card);
} else {
conf = _lrnConf(card);
}
int tot = conf.getJSONArray("delays").length();
int tod = _leftToday(conf.getJSONArray("delays"), tot);
return tot + tod * 1000;
}
use of com.ichi2.utils.JSONObject in project AnkiChinaAndroid by ankichinateam.
the class SchedV2 method _rescheduleLapse.
// Overriden
protected int _rescheduleLapse(@NonNull Card card) {
JSONObject conf;
conf = _lapseConf(card);
card.setLapses(card.getLapses() + 1);
card.setFactor(Math.max(1300, card.getFactor() - 200));
int delay;
boolean suspended = _checkLeech(card, conf) && card.getQueue() == Consts.QUEUE_TYPE_SUSPENDED;
if (conf.getJSONArray("delays").length() != 0 && !suspended) {
card.setType(Consts.CARD_TYPE_RELEARNING);
delay = _moveToFirstStep(card, conf);
} else {
// no relearning steps
_updateRevIvlOnFail(card, conf);
_rescheduleAsRev(card, conf, false);
// need to reset the queue after rescheduling
if (suspended) {
card.setQueue(Consts.QUEUE_TYPE_SUSPENDED);
}
delay = 0;
}
return delay;
}
use of com.ichi2.utils.JSONObject in project AnkiChinaAndroid by ankichinateam.
the class SchedV2 method _nextRevIvl.
/**
* Interval management ******************************************************
* *****************************************
*/
/**
* Next interval for CARD, given EASE.
*/
protected int _nextRevIvl(@NonNull Card card, @Consts.BUTTON_TYPE int ease, boolean fuzz) {
long delay = _daysLate(card);
JSONObject conf = _revConf(card);
double fct = card.getFactor() / 1000.0;
double hardFactor = conf.optDouble("hardFactor", 1.2);
int hardMin;
if (hardFactor > 1) {
hardMin = card.getIvl();
} else {
hardMin = 0;
}
int ivl2 = _constrainedIvl(card.getIvl() * hardFactor, conf, hardMin, fuzz);
if (ease == Consts.BUTTON_TWO) {
return ivl2;
}
int ivl3 = _constrainedIvl((card.getIvl() + delay / 2) * fct, conf, ivl2, fuzz);
if (ease == Consts.BUTTON_THREE) {
return ivl3;
}
int ivl4 = _constrainedIvl(((card.getIvl() + delay) * fct * conf.getDouble("ease4")), conf, ivl3, fuzz);
return ivl4;
}
use of com.ichi2.utils.JSONObject in project AnkiChinaAndroid by ankichinateam.
the class SchedV2 method _lapseConf.
// Overridden: different delays for filtered cards.
@NonNull
protected JSONObject _lapseConf(@NonNull Card card) {
DeckConfig conf = _cardConf(card);
// normal deck
if (card.getODid() == 0) {
return conf.getJSONObject("lapse");
}
// dynamic deck; override some attributes, use original deck for others
DeckConfig oconf = mCol.getDecks().confForDid(card.getODid());
JSONObject dict = new JSONObject();
// original deck
dict.put("minInt", oconf.getJSONObject("lapse").getInt("minInt"));
dict.put("leechFails", oconf.getJSONObject("lapse").getInt("leechFails"));
dict.put("leechAction", oconf.getJSONObject("lapse").getInt("leechAction"));
dict.put("mult", oconf.getJSONObject("lapse").getDouble("mult"));
dict.put("delays", oconf.getJSONObject("lapse").getJSONArray("delays"));
// overrides
dict.put("resched", conf.getBoolean("resched"));
return dict;
}
use of com.ichi2.utils.JSONObject in project AnkiChinaAndroid by ankichinateam.
the class SchedV2 method _answerLrnCard.
// Overriden
protected void _answerLrnCard(@NonNull Card card, @Consts.BUTTON_TYPE int ease) {
JSONObject conf = _lrnConf(card);
@Consts.CARD_TYPE int type;
if (card.getType() == Consts.CARD_TYPE_REV || card.getType() == Consts.CARD_TYPE_RELEARNING) {
type = Consts.CARD_TYPE_REV;
} else {
type = Consts.CARD_TYPE_NEW;
}
// lrnCount was decremented once when card was fetched
int lastLeft = card.getLeft();
boolean leaving = false;
// immediate graduate?
if (ease == Consts.BUTTON_FOUR) {
_rescheduleAsRev(card, conf, true);
leaving = true;
// next step?
} else if (ease == Consts.BUTTON_THREE) {
// graduation time?
if ((card.getLeft() % 1000) - 1 <= 0) {
_rescheduleAsRev(card, conf, false);
leaving = true;
} else {
_moveToNextStep(card, conf);
}
} else if (ease == Consts.BUTTON_TWO) {
_repeatStep(card, conf);
} else {
// move back to first step
_moveToFirstStep(card, conf);
}
_logLrn(card, ease, conf, leaving, type, lastLeft);
}
Aggregations