@gamelearn/arcade-components 2.36.0 → 2.37.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.
@@ -26,7 +26,8 @@ var Board = function Board(_ref) {
26
26
  soundActions = _ref.soundActions,
27
27
  onFinish = _ref.onFinish,
28
28
  handleSuccess = _ref.handleSuccess,
29
- resolveWithAnyCard = _ref.resolveWithAnyCard;
29
+ resolveWithAnyCard = _ref.resolveWithAnyCard,
30
+ selectCard = _ref.selectCard;
30
31
  var _useState = (0, _react.useState)(Array(cards.length).fill(false)),
31
32
  _useState2 = _slicedToArray(_useState, 2),
32
33
  flipped = _useState2[0],
@@ -97,6 +98,7 @@ var Board = function Board(_ref) {
97
98
  if (finished) return;
98
99
  if (!feedbackIsShown) {
99
100
  play('click-ui');
101
+ selectCard(cards[index]);
100
102
  if (cards[index].correct && !isOrderBased) {
101
103
  handleCorrect(index);
102
104
  } else if (isOrderBased) {
@@ -145,6 +147,7 @@ Board.defaultProps = {
145
147
  handleError: function handleError() {},
146
148
  onFinish: function onFinish() {},
147
149
  handleSuccess: function handleSuccess() {},
150
+ selectCard: function selectCard() {},
148
151
  documentsDict: {},
149
152
  cards: [],
150
153
  currentOrder: 1,
@@ -66,6 +66,10 @@ var CardsSelectorPuzzleComponent = function CardsSelectorPuzzleComponent(_ref) {
66
66
  _useState16 = _slicedToArray(_useState15, 2),
67
67
  feedBackText = _useState16[0],
68
68
  setFeedBackText = _useState16[1];
69
+ var _useState17 = (0, _react.useState)(),
70
+ _useState18 = _slicedToArray(_useState17, 2),
71
+ cardSelected = _useState18[0],
72
+ selectCard = _useState18[1];
69
73
  var _soundActions = _slicedToArray(soundActions, 1),
70
74
  playSound = _soundActions[0];
71
75
  var translate = function translate(id) {
@@ -104,10 +108,20 @@ var CardsSelectorPuzzleComponent = function CardsSelectorPuzzleComponent(_ref) {
104
108
  var specificRewards = (specificFeedbacks === null || specificFeedbacks === void 0 ? void 0 : (_specificFeedbacks$co = specificFeedbacks.correctFeedbacks) === null || _specificFeedbacks$co === void 0 ? void 0 : _specificFeedbacks$co.map(function (spReward) {
105
109
  return spReward.rewards;
106
110
  }).flat()) || [];
107
- var rewardsData = [].concat(_toConsumableArray(accRewards), _toConsumableArray(rewards), _toConsumableArray(specificRewards));
111
+ var rewardsData = [];
108
112
  playSound('score');
113
+ if (resolveWithAnyCard) {
114
+ rewardsData = [].concat(_toConsumableArray(accRewards), _toConsumableArray(rewards), _toConsumableArray(specificRewards));
115
+ } else {
116
+ var _specificRewards$corr;
117
+ var cardFeedback = (specificRewards === null || specificRewards === void 0 ? void 0 : (_specificRewards$corr = specificRewards.correctFeedbacks) === null || _specificRewards$corr === void 0 ? void 0 : _specificRewards$corr.find(function (feedback) {
118
+ return cardSelected.id === feedback.id;
119
+ })) || {};
120
+ var cardReward = cardFeedback && cardFeedback.rewards ? cardFeedback.rewards : [];
121
+ rewardsData = [].concat(_toConsumableArray(accRewards), _toConsumableArray(rewards), _toConsumableArray(cardReward));
122
+ }
109
123
  closeFeedbackAndShowPoints(rewardsData);
110
- }, [accRewards, closeFeedbackAndShowPoints, emitEvent, info === null || info === void 0 ? void 0 : (_info$solution2 = info.solution) === null || _info$solution2 === void 0 ? void 0 : _info$solution2.right, playSound, specificFeedbacks === null || specificFeedbacks === void 0 ? void 0 : specificFeedbacks.correctFeedbacks]);
124
+ }, [accRewards, closeFeedbackAndShowPoints, emitEvent, info === null || info === void 0 ? void 0 : (_info$solution2 = info.solution) === null || _info$solution2 === void 0 ? void 0 : _info$solution2.right, playSound, specificFeedbacks === null || specificFeedbacks === void 0 ? void 0 : specificFeedbacks.correctFeedbacks, resolveWithAnyCard, cardSelected]);
111
125
  var onFinish = function onFinish() {
112
126
  setFinished(true);
113
127
  if (info.solution.right.desc && !(specificFeedbacks !== null && specificFeedbacks !== void 0 && specificFeedbacks.specificCorrectFeedbacks)) {
@@ -251,7 +265,8 @@ var CardsSelectorPuzzleComponent = function CardsSelectorPuzzleComponent(_ref) {
251
265
  feedbackIsShown: feedbackIsShown,
252
266
  resolvePuzzle: resolvePuzzle,
253
267
  soundActions: soundActions,
254
- handleSuccess: handleSuccessPick
268
+ handleSuccess: handleSuccessPick,
269
+ selectCard: selectCard
255
270
  })), feedbackIsShown && /*#__PURE__*/_react.default.createElement(_feedbackComponent.default, {
256
271
  success: feedbackResult || rightPick,
257
272
  text: feedBackText,
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.36.0",
5
+ "version": "2.37.0",
6
6
  "main": "dist/index.js",
7
7
  "files": [
8
8
  "dist",