@coorpacademy/progression-engine
Version:
20 lines (19 loc) • 574 B
JavaScript
;
exports.__esModule = true;
exports.default = lives;
function lives(config) {
return (amount = config.lives, action, state) => {
if (state.livesDisabled) {
return amount;
}
switch (action.type) {
case 'answer':
return !action.payload.instructions && action.payload.isCorrect === false ? amount - 1 : amount;
case 'extraLifeAccepted':
return !action.payload.instructions && state.remainingLifeRequests > 0 ? amount + 1 : amount;
default:
return amount;
}
};
}
//# sourceMappingURL=lives.js.map