@gamelearn/arcade-components 1.4.15 → 1.4.16
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.
- package/dist/components/cards-selector-puzzle-component/components/Board/index.js +7 -15
- package/dist/components/cards-selector-puzzle-component/components/CardsSelectorPuzzleComponent.js +34 -13
- package/dist/components/cards-selector-puzzle-component/mocks/mockForStory.js +95 -2
- package/package.json +1 -1
|
@@ -9,8 +9,6 @@ exports.default = void 0;
|
|
|
9
9
|
|
|
10
10
|
var _react = _interopRequireWildcard(require("react"));
|
|
11
11
|
|
|
12
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
13
|
-
|
|
14
12
|
var _Card = _interopRequireDefault(require("../Card"));
|
|
15
13
|
|
|
16
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -47,7 +45,8 @@ var Board = function Board(_ref) {
|
|
|
47
45
|
endPuzzle = _ref.endPuzzle,
|
|
48
46
|
feedbackIsShown = _ref.feedbackIsShown,
|
|
49
47
|
resolvePuzzle = _ref.resolvePuzzle,
|
|
50
|
-
soundActions = _ref.soundActions
|
|
48
|
+
soundActions = _ref.soundActions,
|
|
49
|
+
handleSuccess = _ref.handleSuccess;
|
|
51
50
|
|
|
52
51
|
var _useState = (0, _react.useState)(_toConsumableArray(Array(cards.length)).fill(false)),
|
|
53
52
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -117,10 +116,10 @@ var Board = function Board(_ref) {
|
|
|
117
116
|
|
|
118
117
|
var handleCorrect = function handleCorrect(index) {
|
|
119
118
|
flipACard(index);
|
|
119
|
+
handleSuccess(cards[index].id || null);
|
|
120
120
|
setCorrectCards(correctCards + 1);
|
|
121
121
|
|
|
122
122
|
if (correctCards === numberOfCorrectCards) {
|
|
123
|
-
// random click, we check if correct if not reset
|
|
124
123
|
endPuzzle();
|
|
125
124
|
}
|
|
126
125
|
};
|
|
@@ -148,8 +147,10 @@ var Board = function Board(_ref) {
|
|
|
148
147
|
flipACard(index);
|
|
149
148
|
}
|
|
150
149
|
} else {
|
|
150
|
+
var _cards$index;
|
|
151
|
+
|
|
151
152
|
// fails and resets
|
|
152
|
-
handleError();
|
|
153
|
+
handleError(((_cards$index = cards[index]) === null || _cards$index === void 0 ? void 0 : _cards$index.id) || null);
|
|
153
154
|
flipACard(index);
|
|
154
155
|
timedFlipped();
|
|
155
156
|
}
|
|
@@ -177,21 +178,12 @@ Board.defaultProps = {
|
|
|
177
178
|
setCurrentOrder: function setCurrentOrder() {},
|
|
178
179
|
handleError: function handleError() {},
|
|
179
180
|
endPuzzle: function endPuzzle() {},
|
|
181
|
+
handleSuccess: function handleSuccess() {},
|
|
180
182
|
documentsDict: {},
|
|
181
183
|
cards: [],
|
|
182
184
|
currentOrder: 1,
|
|
183
185
|
resolvePuzzle: false,
|
|
184
186
|
feedbackIsShown: false
|
|
185
187
|
};
|
|
186
|
-
Board.propTypes = {
|
|
187
|
-
endPuzzle: _propTypes.default.func,
|
|
188
|
-
handleError: _propTypes.default.func,
|
|
189
|
-
feedbackIsShown: _propTypes.default.bool,
|
|
190
|
-
resolvePuzzle: _propTypes.default.bool,
|
|
191
|
-
currentOrder: _propTypes.default.number,
|
|
192
|
-
documentsDict: _propTypes.default.shape({}),
|
|
193
|
-
setCurrentOrder: _propTypes.default.func,
|
|
194
|
-
cards: _propTypes.default.arrayOf(_propTypes.default.shape)
|
|
195
|
-
};
|
|
196
188
|
var _default = Board;
|
|
197
189
|
exports.default = _default;
|
package/dist/components/cards-selector-puzzle-component/components/CardsSelectorPuzzleComponent.js
CHANGED
|
@@ -43,6 +43,7 @@ var CardsSelectorPuzzleComponent = function CardsSelectorPuzzleComponent(_ref) {
|
|
|
43
43
|
var emitEvent = _ref.emitEvent,
|
|
44
44
|
info = _ref.info,
|
|
45
45
|
cards = _ref.cards,
|
|
46
|
+
specificFeedbacks = _ref.specificFeedbacks,
|
|
46
47
|
disableExit = _ref.disableExit,
|
|
47
48
|
setResolveAction = _ref.setResolveAction,
|
|
48
49
|
soundActions = _ref.soundActions,
|
|
@@ -108,7 +109,7 @@ var CardsSelectorPuzzleComponent = function CardsSelectorPuzzleComponent(_ref) {
|
|
|
108
109
|
});
|
|
109
110
|
}, [emitEvent]);
|
|
110
111
|
|
|
111
|
-
var
|
|
112
|
+
var endPuzzle = function endPuzzle() {
|
|
112
113
|
emitEvent({
|
|
113
114
|
type: 'hidePuzzleButtons',
|
|
114
115
|
payload: true
|
|
@@ -151,9 +152,29 @@ var CardsSelectorPuzzleComponent = function CardsSelectorPuzzleComponent(_ref) {
|
|
|
151
152
|
setFeedBackText('');
|
|
152
153
|
};
|
|
153
154
|
|
|
154
|
-
var
|
|
155
|
-
|
|
156
|
-
|
|
155
|
+
var handleSuccessPick = function handleSuccessPick(cardId) {
|
|
156
|
+
if (specificFeedbacks !== null && specificFeedbacks !== void 0 && specificFeedbacks.specificCorrectFeedbacks) {
|
|
157
|
+
var pickedCard = specificFeedbacks.correctFeedbacks.find(function (greenCard) {
|
|
158
|
+
return greenCard.id === cardId;
|
|
159
|
+
});
|
|
160
|
+
setFeedBackText(pickedCard.text);
|
|
161
|
+
setFeedbackResult(true);
|
|
162
|
+
setFeedbackIsShown(true);
|
|
163
|
+
setRewards([].concat(_toConsumableArray(accRewards), [pickedCard === null || pickedCard === void 0 ? void 0 : pickedCard.rewards]));
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
var handleError = function handleError(cardId) {
|
|
168
|
+
// si hay feedback específico
|
|
169
|
+
if (specificFeedbacks !== null && specificFeedbacks !== void 0 && specificFeedbacks.specificWrongFeedbacks) {
|
|
170
|
+
var failedCard = specificFeedbacks.wrongFeedbacks.find(function (redCard) {
|
|
171
|
+
return redCard.id === cardId;
|
|
172
|
+
});
|
|
173
|
+
setFeedBackText(failedCard.text);
|
|
174
|
+
setFeedbackIsShown(true);
|
|
175
|
+
setRewards([].concat(_toConsumableArray(accRewards), [failedCard === null || failedCard === void 0 ? void 0 : failedCard.rewards]));
|
|
176
|
+
} // si hay feedback definido
|
|
177
|
+
else if (info.solution.wrong.desc) {
|
|
157
178
|
setFeedBackText(info.solution.wrong.desc);
|
|
158
179
|
setFeedbackIsShown(true);
|
|
159
180
|
} // si no hay feedback definido, se muestra feedback por defecto
|
|
@@ -169,7 +190,11 @@ var CardsSelectorPuzzleComponent = function CardsSelectorPuzzleComponent(_ref) {
|
|
|
169
190
|
}
|
|
170
191
|
|
|
171
192
|
disableExit(true);
|
|
172
|
-
|
|
193
|
+
|
|
194
|
+
if (!(specificFeedbacks !== null && specificFeedbacks !== void 0 && specificFeedbacks.specificWrongFeedbacks)) {
|
|
195
|
+
setRewards([].concat(_toConsumableArray(accRewards), _toConsumableArray(info.solution.wrong.rewards)));
|
|
196
|
+
}
|
|
197
|
+
|
|
173
198
|
playSound('fail');
|
|
174
199
|
emitEvent({
|
|
175
200
|
type: 'hidePuzzleButtons',
|
|
@@ -204,17 +229,13 @@ var CardsSelectorPuzzleComponent = function CardsSelectorPuzzleComponent(_ref) {
|
|
|
204
229
|
setCurrentOrder: setCurrentOrder,
|
|
205
230
|
currentOrder: currentOrder,
|
|
206
231
|
cards: cards,
|
|
207
|
-
endPuzzle:
|
|
208
|
-
|
|
209
|
-
},
|
|
210
|
-
handleError: function handleError() {
|
|
211
|
-
return _handleError();
|
|
212
|
-
},
|
|
232
|
+
endPuzzle: endPuzzle,
|
|
233
|
+
handleError: handleError,
|
|
213
234
|
feedbackIsShown: feedbackIsShown,
|
|
214
235
|
resolvePuzzle: resolvePuzzle,
|
|
215
|
-
soundActions: soundActions
|
|
236
|
+
soundActions: soundActions,
|
|
237
|
+
handleSuccess: handleSuccessPick
|
|
216
238
|
})), feedbackIsShown && /*#__PURE__*/_react.default.createElement(_feedbackComponent.default, {
|
|
217
|
-
playSound: playSound,
|
|
218
239
|
success: feedbackResult,
|
|
219
240
|
text: feedBackText,
|
|
220
241
|
translate: translate,
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.mockProps5 = exports.mockProps4 = exports.mockProps3 = exports.mockProps2 = exports.mockProps = void 0;
|
|
6
|
+
exports.mockProps6 = exports.mockProps5 = exports.mockProps4 = exports.mockProps3 = exports.mockProps2 = exports.mockProps = void 0;
|
|
7
7
|
|
|
8
8
|
var _mocker = require("helpers/mocker");
|
|
9
9
|
|
|
@@ -352,4 +352,97 @@ var mockProps5 = _objectSpread(_objectSpread({}, mockProps), {}, {
|
|
|
352
352
|
}
|
|
353
353
|
});
|
|
354
354
|
|
|
355
|
-
exports.mockProps5 = mockProps5;
|
|
355
|
+
exports.mockProps5 = mockProps5;
|
|
356
|
+
|
|
357
|
+
var mockProps6 = _objectSpread(_objectSpread({}, mockProps), {}, {
|
|
358
|
+
cards: [{
|
|
359
|
+
id: 'bCPlOr',
|
|
360
|
+
text: 'si ',
|
|
361
|
+
correct: true,
|
|
362
|
+
text_labelId: 'text_0_nV3LRBvB',
|
|
363
|
+
imgId: '',
|
|
364
|
+
img: null,
|
|
365
|
+
imgId_labelId: 'imgId_0_nV3LR0tI'
|
|
366
|
+
}, {
|
|
367
|
+
id: 'RlcXAh',
|
|
368
|
+
text: 'no',
|
|
369
|
+
correct: false,
|
|
370
|
+
text_labelId: 'text_1_nV3LReKp',
|
|
371
|
+
imgId: '',
|
|
372
|
+
img: null,
|
|
373
|
+
imgId_labelId: 'imgId_1_nV3LRPvU'
|
|
374
|
+
}, {
|
|
375
|
+
id: 'SBhcdU',
|
|
376
|
+
correct: true,
|
|
377
|
+
text: 'tambien',
|
|
378
|
+
text_labelId: 'text_2_nV3LROGC',
|
|
379
|
+
imgId: '',
|
|
380
|
+
img: null,
|
|
381
|
+
imgId_labelId: 'imgId_2_nV3LRelK'
|
|
382
|
+
}, {
|
|
383
|
+
id: 'Sgcqps',
|
|
384
|
+
text: 'tampoco',
|
|
385
|
+
correct: false,
|
|
386
|
+
text_labelId: 'text_3_nV3LRx2G',
|
|
387
|
+
imgId: '',
|
|
388
|
+
img: null,
|
|
389
|
+
imgId_labelId: 'imgId_3_nV3LSvEZ'
|
|
390
|
+
}],
|
|
391
|
+
info: {
|
|
392
|
+
solution: {
|
|
393
|
+
right: {
|
|
394
|
+
desc: '',
|
|
395
|
+
rewards: [],
|
|
396
|
+
desc_labelId: 'desc_nV3LRHVB'
|
|
397
|
+
},
|
|
398
|
+
wrong: {
|
|
399
|
+
desc: '',
|
|
400
|
+
rewards: [],
|
|
401
|
+
desc_labelId: 'desc_nV3LR5vi'
|
|
402
|
+
}
|
|
403
|
+
},
|
|
404
|
+
hint: {
|
|
405
|
+
active: false,
|
|
406
|
+
desc: '',
|
|
407
|
+
rewards: [],
|
|
408
|
+
desc_labelId: 'desc_nV3LQH3e'
|
|
409
|
+
},
|
|
410
|
+
resolve: {
|
|
411
|
+
rewards: []
|
|
412
|
+
},
|
|
413
|
+
description: 'chimo',
|
|
414
|
+
description_labelId: 'description_nV3LQVvh',
|
|
415
|
+
title: '',
|
|
416
|
+
title_labelId: 'title_nV3LQuNg',
|
|
417
|
+
instructions: '',
|
|
418
|
+
instructions_labelId: 'instructions_nV3LQPBH'
|
|
419
|
+
},
|
|
420
|
+
specificFeedbacks: {
|
|
421
|
+
correctFeedbacks: [{
|
|
422
|
+
id: 'bCPlOr',
|
|
423
|
+
text: 'si ',
|
|
424
|
+
desc: 'esta si',
|
|
425
|
+
rewards: []
|
|
426
|
+
}, {
|
|
427
|
+
id: 'SBhcdU',
|
|
428
|
+
text: 'tambien',
|
|
429
|
+
desc: 'esta me gusta',
|
|
430
|
+
rewards: []
|
|
431
|
+
}],
|
|
432
|
+
wrongFeedbacks: [{
|
|
433
|
+
id: 'RlcXAh',
|
|
434
|
+
text: 'no',
|
|
435
|
+
desc: 'esta no',
|
|
436
|
+
rewards: []
|
|
437
|
+
}, {
|
|
438
|
+
id: 'Sgcqps',
|
|
439
|
+
text: 'tampoco',
|
|
440
|
+
desc: 'me voy de baretas',
|
|
441
|
+
rewards: []
|
|
442
|
+
}],
|
|
443
|
+
specificCorrectFeedbacks: true,
|
|
444
|
+
specificWrongFeedbacks: true
|
|
445
|
+
}
|
|
446
|
+
});
|
|
447
|
+
|
|
448
|
+
exports.mockProps6 = mockProps6;
|