@coorpacademy/progression-engine
Version:
18 lines (16 loc) • 524 B
JavaScript
export default 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