@gamelearn/arcade-components 2.17.13 → 2.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -63,6 +63,9 @@ var ChainedImageClickPuzzleComponent = function ChainedImageClickPuzzleComponent
63
63
  payload: puzzleId
64
64
  });
65
65
  }, [emitEvent, puzzleId]);
66
+ var totalCorrects = list.reduce(function (acc, current) {
67
+ return acc + current.areas.length;
68
+ }, 0);
66
69
  var currentPuzzleProps = {
67
70
  list: list,
68
71
  description: description,
@@ -79,11 +82,9 @@ var ChainedImageClickPuzzleComponent = function ChainedImageClickPuzzleComponent
79
82
  slidesCompleted: slidesCompleted,
80
83
  setSlidesCompleted: setSlidesCompleted,
81
84
  loadPuzzleStatus: loadPuzzleStatus,
82
- keyboardControl: keyboardControl
85
+ keyboardControl: keyboardControl,
86
+ totalCorrects: totalCorrects
83
87
  };
84
- var totalCorrects = list.reduce(function (acc, current) {
85
- return acc + current.areas.length;
86
- }, 0);
87
88
  return /*#__PURE__*/_react.default.createElement("div", {
88
89
  className: "puzzle--image__click"
89
90
  }, showFrames ? /*#__PURE__*/_react.default.createElement("div", {
@@ -62,7 +62,8 @@ var CurrentImageClickPuzzle = function CurrentImageClickPuzzle(_ref) {
62
62
  setIndex = _ref.setIndex,
63
63
  slidesCompleted = _ref.slidesCompleted,
64
64
  setSlidesCompleted = _ref.setSlidesCompleted,
65
- keyboardControl = _ref.keyboardControl;
65
+ keyboardControl = _ref.keyboardControl,
66
+ totalCorrects = _ref.totalCorrects;
66
67
  var accRewards = (0, _react.useRef)([]);
67
68
  var correctClicked = (0, _react.useRef)(0);
68
69
  var currentSelected = (0, _react.useRef)(0);
@@ -160,6 +161,10 @@ var CurrentImageClickPuzzle = function CurrentImageClickPuzzle(_ref) {
160
161
  }, [slidesCompleted, specificFeedbacks, currentImageProps.hasClickOnce, currentImageProps.areas.length, currentImageProps.hasClickOrder, selected, setSelected, index, list.length, setSlidesCompleted, handleFinish, setIndex, emitEvent]);
161
162
 
162
163
  var onResolve = function onResolve() {
164
+ if (index >= list.length - 1) {
165
+ setSelected(totalCorrects);
166
+ }
167
+
163
168
  playSound('score');
164
169
  emitEvent({
165
170
  type: 'puzzleAction',
@@ -178,10 +183,10 @@ var CurrentImageClickPuzzle = function CurrentImageClickPuzzle(_ref) {
178
183
  }));
179
184
  }, [info, puzzleId, setInfo]);
180
185
  (0, _react.useEffect)(function () {
181
- if (loadPuzzleStatus) {
182
- onComplete([], true, true);
186
+ if (loadPuzzleStatus && index !== list.length - 1) {
187
+ onComplete([], true, false);
183
188
  }
184
- }, [slidesCompleted, loadPuzzleStatus, onComplete]);
189
+ }, [index, list.length, loadPuzzleStatus, onComplete]);
185
190
 
186
191
  var checkSelectedAreas = function checkSelectedAreas() {
187
192
  var areasSelected = currentImageProps.hasClickOnce ? currentImageProps.areas.length : 1;
@@ -67,7 +67,8 @@ var CurrentFramePuzzle = function CurrentFramePuzzle(_ref) {
67
67
  resetValues = _ref.resetValues,
68
68
  setResetValues = _ref.setResetValues,
69
69
  pause = _ref.pause,
70
- keyboardControl = _ref.keyboardControl;
70
+ keyboardControl = _ref.keyboardControl,
71
+ totalCorrects = _ref.totalCorrects;
71
72
 
72
73
  var _soundActions = _slicedToArray(soundActions, 1),
73
74
  playSound = _soundActions[0];
@@ -154,6 +155,10 @@ var CurrentFramePuzzle = function CurrentFramePuzzle(_ref) {
154
155
  }
155
156
  }, [framesCompleted, specificFeedbacks === null || specificFeedbacks === void 0 ? void 0 : (_specificFeedbacks$co2 = specificFeedbacks.correctFeedbacks) === null || _specificFeedbacks$co2 === void 0 ? void 0 : _specificFeedbacks$co2.length, props.hasClickOnce, props.areas.length, props.hasClickOrder, setRewards, selected, puzzlesAutoCompleted, setSelected, index, list.length, setFramesCompleted, setIndex, handleFinish, emitEvent]);
156
157
  var handleResolve = (0, _react.useCallback)(function () {
158
+ if (index >= list.length - 1) {
159
+ setSelected(totalCorrects);
160
+ }
161
+
157
162
  playSound('score');
158
163
  emitEvent({
159
164
  type: 'hidePuzzleButtons',
@@ -167,10 +172,11 @@ var CurrentFramePuzzle = function CurrentFramePuzzle(_ref) {
167
172
  action: 'resolve',
168
173
  payload: {
169
174
  element: puzzleId,
170
- rewards: info.resolve.rewards
175
+ rewards: info.resolve.rewards,
176
+ finish: index + 1 >= list.length
171
177
  }
172
178
  });
173
- }, [playSound, emitEvent, setPuzzlesAutoCompleted, puzzleId, info.resolve.rewards, index]);
179
+ }, [index, list.length, playSound, emitEvent, setPuzzlesAutoCompleted, puzzleId, info.resolve.rewards, setSelected, totalCorrects]);
174
180
  var handleResetPuzzle = (0, _react.useCallback)(function () {
175
181
  setFramesCompleted({});
176
182
  correctClicked.current = 0;
@@ -178,10 +184,10 @@ var CurrentFramePuzzle = function CurrentFramePuzzle(_ref) {
178
184
  emitResetPuzzle();
179
185
  }, [emitResetPuzzle, setFramesCompleted]);
180
186
  (0, _react.useEffect)(function () {
181
- if (loadPuzzleStatus) {
182
- onComplete([], true, true);
187
+ if (loadPuzzleStatus && index !== list.length - 1) {
188
+ onComplete([], true, false);
183
189
  }
184
- }, [framesCompleted, loadPuzzleStatus, onComplete]);
190
+ }, [framesCompleted, index, list.length, loadPuzzleStatus, onComplete]);
185
191
 
186
192
  var checkSelectedAreas = function checkSelectedAreas() {
187
193
  var areasSelected = props.hasClickOnce ? props.areas.length : 1;
@@ -173,7 +173,8 @@ var FrameImageClickComponent = function FrameImageClickComponent(_ref) {
173
173
  puzzlesAutoCompleted: puzzlesAutoCompleted,
174
174
  emitOpenPopupCounterInfo: onInitPuzzle,
175
175
  pause: pause,
176
- keyboardControl: keyboardControl
176
+ keyboardControl: keyboardControl,
177
+ totalCorrects: totalCorrects
177
178
  };
178
179
  return /*#__PURE__*/_react.default.createElement("div", {
179
180
  className: "puzzle-frame"
@@ -469,15 +469,18 @@ var ImageClickWrapperComponent = function ImageClickWrapperComponent(props) {
469
469
  }, [createStartAndEndDate, defaultCompleted, firstTryForFrame, puzzlesAutoCompleted, slideNumber, timer]);
470
470
  (0, _react.useEffect)(function () {
471
471
  if (timer && countDownTime === 0) feedbackError();
472
- }, [countDownTime, feedbackError, timer]);
472
+ }, [countDownTime, feedbackError, timer]); // only for frameclick
473
+
473
474
  (0, _react.useEffect)(function () {
474
- if (pause) {
475
- clearIntervalForCountDown();
476
- pauseTheCounter();
477
- } else {
478
- startCountDown();
475
+ if (timer) {
476
+ if (pause) {
477
+ clearIntervalForCountDown();
478
+ pauseTheCounter();
479
+ } else {
480
+ startCountDown();
481
+ }
479
482
  }
480
- }, [clearIntervalForCountDown, listenerForActualDate, pause, pauseTheCounter, startCountDown]);
483
+ }, [clearIntervalForCountDown, listenerForActualDate, pause, pauseTheCounter, startCountDown, timer]);
481
484
  return /*#__PURE__*/_react.default.createElement("div", {
482
485
  className: className
483
486
  }, feedbackData.show ? /*#__PURE__*/_react.default.createElement(_FeedbackComponent.default, {
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@gamelearn/arcade-components",
3
3
  "author": "Gamelearn",
4
4
  "license": "unlicense",
5
- "version": "2.17.13",
5
+ "version": "2.18.0",
6
6
  "main": "dist/index.js",
7
7
  "files": [
8
8
  "dist",
@@ -14,7 +14,7 @@
14
14
  },
15
15
  "dependencies": {
16
16
  "@babel/runtime": "^7.18.6",
17
- "@gamelearn/arcade-styles": "2.11.2",
17
+ "@gamelearn/arcade-styles": "2.12.0",
18
18
  "@gamelearn/arcade-three-core": "1.17.2",
19
19
  "@react-three/drei": "9.4.3",
20
20
  "@react-three/fiber": "8.0.17",