UNPKG

984 BJavaScriptView Raw
1import _sum from "lodash/fp/sum";
2import _size from "lodash/fp/size";
3import _multiply from "lodash/fp/multiply";
4import _min from "lodash/fp/min";
5import _map from "lodash/fp/map";
6import _get from "lodash/fp/get";
7import _pipe from "lodash/fp/pipe";
8
9const getFastSlideExitNode = (config, godMode, availableContent) => {
10 const {
11 slidesToComplete,
12 starsPerCorrectAnswer
13 } = config;
14 const nextContent = godMode ? {
15 type: 'success',
16 ref: 'successExitNode'
17 } : {
18 type: 'failure',
19 ref: 'failExitNode'
20 };
21
22 const starsMax = _pipe(_map(_pipe(_get('slides'), _size, length => _min([length, slidesToComplete]))), _sum, _multiply(starsPerCorrectAnswer))(availableContent);
23
24 const instructions = godMode ? [{
25 field: 'stars',
26 type: 'set',
27 value: starsMax
28 }] : [{
29 field: 'lives',
30 type: 'set',
31 value: 0
32 }];
33 return {
34 instructions,
35 nextContent
36 };
37};
38
39export default getFastSlideExitNode;
40//# sourceMappingURL=index.js.map
\No newline at end of file