1 | import _sum from "lodash/fp/sum";
|
2 | import _size from "lodash/fp/size";
|
3 | import _multiply from "lodash/fp/multiply";
|
4 | import _min from "lodash/fp/min";
|
5 | import _map from "lodash/fp/map";
|
6 | import _get from "lodash/fp/get";
|
7 | import _pipe from "lodash/fp/pipe";
|
8 |
|
9 | const 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 |
|
39 | export default getFastSlideExitNode;
|
40 |
|
\ | No newline at end of file |