@gamelearn/arcade-components 0.22.9 → 0.22.11
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/chained-image-click-puzzle-component/components/CurrentImagePuzzle.js +12 -26
- package/dist/components/frame-click-puzzle-component/components/CurrentFramePuzzle.js +4 -5
- package/dist/components/image-click-wrapper-component/components/ImageClickWrapperComponent.js +37 -23
- package/package.json +1 -1
package/dist/components/chained-image-click-puzzle-component/components/CurrentImagePuzzle.js
CHANGED
|
@@ -93,26 +93,17 @@ var CurrentImageClickPuzzle = function CurrentImageClickPuzzle(_ref) {
|
|
|
93
93
|
var info = currentImageProps.info,
|
|
94
94
|
specificFeedbacks = currentImageProps.specificFeedbacks;
|
|
95
95
|
info.description = description;
|
|
96
|
-
var handleResolve = (0, _react.useCallback)(function () {
|
|
97
|
-
emitEvent({
|
|
98
|
-
type: 'puzzleAction',
|
|
99
|
-
action: 'resolve',
|
|
100
|
-
payload: {
|
|
101
|
-
element: puzzleId,
|
|
102
|
-
rewards: info.resolve.rewards
|
|
103
|
-
}
|
|
104
|
-
});
|
|
105
|
-
}, [emitEvent, puzzleId, info.resolve.rewards]);
|
|
106
96
|
(0, _react.useEffect)(function () {
|
|
107
97
|
correctClicked.current = 0;
|
|
108
98
|
}, [index]);
|
|
109
99
|
var onComplete = (0, _react.useCallback)(function (rw) {
|
|
110
100
|
var correct = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
101
|
+
var finish = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
111
102
|
|
|
112
103
|
if (correct) {
|
|
113
104
|
var _specificFeedbacks$co;
|
|
114
105
|
|
|
115
|
-
if ((_specificFeedbacks$co = specificFeedbacks.correctFeedbacks) !== null && _specificFeedbacks$co !== void 0 && _specificFeedbacks$co.length) {
|
|
106
|
+
if (specificFeedbacks !== null && specificFeedbacks !== void 0 && (_specificFeedbacks$co = specificFeedbacks.correctFeedbacks) !== null && _specificFeedbacks$co !== void 0 && _specificFeedbacks$co.length && !currentImageProps.hasClickOnce && !finish) {
|
|
116
107
|
correctClicked.current += 1;
|
|
117
108
|
setSelected(selected + 1);
|
|
118
109
|
} else {
|
|
@@ -141,13 +132,18 @@ var CurrentImageClickPuzzle = function CurrentImageClickPuzzle(_ref) {
|
|
|
141
132
|
correctClicked.current = 0;
|
|
142
133
|
}
|
|
143
134
|
}
|
|
144
|
-
}, [index, list.length, currentImageProps.hasClickOrder, currentImageProps.areas.length, handleFinish, specificFeedbacks, setSelected, selected, emitEvent]);
|
|
135
|
+
}, [index, list.length, currentImageProps.hasClickOrder, currentImageProps.hasClickOnce, currentImageProps.areas.length, handleFinish, specificFeedbacks, setSelected, selected, emitEvent]);
|
|
145
136
|
|
|
146
137
|
var onResolve = function onResolve() {
|
|
147
138
|
playSound('score');
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
139
|
+
emitEvent({
|
|
140
|
+
type: 'puzzleAction',
|
|
141
|
+
action: 'resolve',
|
|
142
|
+
payload: {
|
|
143
|
+
element: puzzleId,
|
|
144
|
+
rewards: info.resolve.rewards
|
|
145
|
+
}
|
|
146
|
+
});
|
|
151
147
|
};
|
|
152
148
|
|
|
153
149
|
(0, _react.useEffect)(function () {
|
|
@@ -156,19 +152,9 @@ var CurrentImageClickPuzzle = function CurrentImageClickPuzzle(_ref) {
|
|
|
156
152
|
}));
|
|
157
153
|
}, [info, setInfo, puzzleId]);
|
|
158
154
|
(0, _react.useEffect)(function () {
|
|
159
|
-
var timeout;
|
|
160
|
-
|
|
161
155
|
if (currentPuzzleStatus) {
|
|
162
|
-
|
|
163
|
-
onComplete([], false);
|
|
164
|
-
}, 2000);
|
|
156
|
+
onComplete([], true, true);
|
|
165
157
|
}
|
|
166
|
-
|
|
167
|
-
return function () {
|
|
168
|
-
if (timeout) {
|
|
169
|
-
clearTimeout(timeout);
|
|
170
|
-
}
|
|
171
|
-
};
|
|
172
158
|
}, [onComplete, puzzleId, currentPuzzleStatus]);
|
|
173
159
|
return /*#__PURE__*/_react.default.createElement(_imageClickWrapperComponent.default, _extends({
|
|
174
160
|
key: index
|
|
@@ -80,13 +80,14 @@ var CurrentFramePuzzle = function CurrentFramePuzzle(_ref) {
|
|
|
80
80
|
}, [index]);
|
|
81
81
|
var onComplete = (0, _react.useCallback)(function (rw) {
|
|
82
82
|
var correct = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
83
|
+
var finish = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
83
84
|
|
|
84
85
|
var updatedCompleted = _objectSpread({}, framesCompleted);
|
|
85
86
|
|
|
86
87
|
if (correct) {
|
|
87
88
|
var _specificFeedbacks$co;
|
|
88
89
|
|
|
89
|
-
if ((_specificFeedbacks$co = specificFeedbacks.correctFeedbacks) !== null && _specificFeedbacks$co !== void 0 && _specificFeedbacks$co.length) {
|
|
90
|
+
if (specificFeedbacks !== null && specificFeedbacks !== void 0 && (_specificFeedbacks$co = specificFeedbacks.correctFeedbacks) !== null && _specificFeedbacks$co !== void 0 && _specificFeedbacks$co.length && !props.hasClickOnce && !finish) {
|
|
90
91
|
correctClicked.current += 1;
|
|
91
92
|
setSelected(selected + 1);
|
|
92
93
|
} else {
|
|
@@ -117,7 +118,7 @@ var CurrentFramePuzzle = function CurrentFramePuzzle(_ref) {
|
|
|
117
118
|
correctClicked.current = 0;
|
|
118
119
|
}
|
|
119
120
|
}
|
|
120
|
-
}, [emitEvent, specificFeedbacks, framesCompleted, props.hasClickOrder, props.areas.length, list.length, selected, setSelected, setRewards, index, setFramesCompleted, setIndex, handleFinish]);
|
|
121
|
+
}, [emitEvent, specificFeedbacks, framesCompleted, props.hasClickOrder, props.hasClickOnce, props.areas.length, list.length, selected, setSelected, setRewards, index, setFramesCompleted, setIndex, handleFinish]);
|
|
121
122
|
var handleResolve = (0, _react.useCallback)(function () {
|
|
122
123
|
playSound('score');
|
|
123
124
|
emitEvent({
|
|
@@ -135,9 +136,7 @@ var CurrentFramePuzzle = function CurrentFramePuzzle(_ref) {
|
|
|
135
136
|
}, [emitEvent, puzzleId, playSound, info.resolve.rewards]);
|
|
136
137
|
(0, _react.useEffect)(function () {
|
|
137
138
|
if (loadPuzzleStatus) {
|
|
138
|
-
|
|
139
|
-
onComplete([]);
|
|
140
|
-
}, 2000);
|
|
139
|
+
onComplete([], true, true);
|
|
141
140
|
}
|
|
142
141
|
}, [loadPuzzleStatus, onComplete]);
|
|
143
142
|
return /*#__PURE__*/_react.default.createElement(_imageClickWrapperComponent.default, _extends({
|
package/dist/components/image-click-wrapper-component/components/ImageClickWrapperComponent.js
CHANGED
|
@@ -128,16 +128,16 @@ var ImageClickWrapperComponent = function ImageClickWrapperComponent(props) {
|
|
|
128
128
|
shape: 'poly'
|
|
129
129
|
}, area);
|
|
130
130
|
});
|
|
131
|
-
var handleFinish = (0, _react.useCallback)(function (rewards) {
|
|
131
|
+
var handleFinish = (0, _react.useCallback)(function (rewards, success) {
|
|
132
132
|
if (emitFinish) {
|
|
133
|
-
emitFinish(rewards,
|
|
133
|
+
emitFinish(rewards, success);
|
|
134
134
|
} else {
|
|
135
135
|
emitEvent({
|
|
136
136
|
type: 'addPoints',
|
|
137
137
|
payload: rewards
|
|
138
138
|
});
|
|
139
139
|
}
|
|
140
|
-
}, [emitEvent, emitFinish
|
|
140
|
+
}, [emitEvent, emitFinish]);
|
|
141
141
|
(0, _react.useEffect)(function () {
|
|
142
142
|
if (completed) {
|
|
143
143
|
disableExit(true);
|
|
@@ -147,18 +147,24 @@ var ImageClickWrapperComponent = function ImageClickWrapperComponent(props) {
|
|
|
147
147
|
setCompleted(defaultCompleted);
|
|
148
148
|
}, [defaultCompleted]);
|
|
149
149
|
(0, _react.useEffect)(function () {
|
|
150
|
-
if (areas.length === clickedZones.length
|
|
150
|
+
if ((areas.length === clickedZones.length || hasClickOnce && clickedZones.length > 0) && !completed) {
|
|
151
151
|
var _specificFeedbacks$co;
|
|
152
152
|
|
|
153
153
|
setCompleted(true);
|
|
154
|
+
var lastClicked = clickedZones[clickedZones.length - 1];
|
|
155
|
+
var lastSpecific = specificFeedbacks.correctFeedbacks.find(function (feed) {
|
|
156
|
+
return feed.id === lastClicked.id;
|
|
157
|
+
});
|
|
154
158
|
|
|
155
|
-
if (!((_specificFeedbacks$co = specificFeedbacks.correctFeedbacks) !== null && _specificFeedbacks$co !== void 0 && _specificFeedbacks$co.length)) {
|
|
159
|
+
if (!(specificFeedbacks !== null && specificFeedbacks !== void 0 && (_specificFeedbacks$co = specificFeedbacks.correctFeedbacks) !== null && _specificFeedbacks$co !== void 0 && _specificFeedbacks$co.length) || specificFeedbacks !== null && specificFeedbacks !== void 0 && specificFeedbacks.correctFeedbacks.some(function (feed) {
|
|
160
|
+
return !feed.desc;
|
|
161
|
+
}) || hasClickOnce) {
|
|
156
162
|
setFeedbackData(function (oldState) {
|
|
157
163
|
return _objectSpread(_objectSpread({}, oldState), {}, {
|
|
158
164
|
show: true,
|
|
159
165
|
success: true,
|
|
160
|
-
text: info.solution.right.desc,
|
|
161
|
-
rewards: info.solution.right.rewards
|
|
166
|
+
text: lastSpecific ? lastSpecific.desc : info.solution.right.desc,
|
|
167
|
+
rewards: lastSpecific ? lastSpecific.rewards : info.solution.right.rewards
|
|
162
168
|
});
|
|
163
169
|
});
|
|
164
170
|
}
|
|
@@ -188,10 +194,6 @@ var ImageClickWrapperComponent = function ImageClickWrapperComponent(props) {
|
|
|
188
194
|
desc = _solution$wrong.desc;
|
|
189
195
|
var feedback = desc;
|
|
190
196
|
var rewards = wrongRewards;
|
|
191
|
-
emitEvent({
|
|
192
|
-
type: 'hidePuzzleButtons',
|
|
193
|
-
payload: true
|
|
194
|
-
});
|
|
195
197
|
var specific = (_specificFeedbacks$wr = specificFeedbacks.wrongFeedbacks) === null || _specificFeedbacks$wr === void 0 ? void 0 : _specificFeedbacks$wr.find(function (feed) {
|
|
196
198
|
return feed.id === area.id;
|
|
197
199
|
});
|
|
@@ -206,7 +208,14 @@ var ImageClickWrapperComponent = function ImageClickWrapperComponent(props) {
|
|
|
206
208
|
}
|
|
207
209
|
|
|
208
210
|
if (hasClickOrder) {
|
|
211
|
+
var _info$orderFeedback;
|
|
212
|
+
|
|
209
213
|
setClickedZones([]);
|
|
214
|
+
|
|
215
|
+
if (info !== null && info !== void 0 && (_info$orderFeedback = info.orderFeedback) !== null && _info$orderFeedback !== void 0 && _info$orderFeedback.desc) {
|
|
216
|
+
feedback = info.orderFeedback.desc;
|
|
217
|
+
rewards = info.orderFeedback.rewards;
|
|
218
|
+
}
|
|
210
219
|
}
|
|
211
220
|
|
|
212
221
|
setFeedbackData(function (oldState) {
|
|
@@ -221,8 +230,8 @@ var ImageClickWrapperComponent = function ImageClickWrapperComponent(props) {
|
|
|
221
230
|
}
|
|
222
231
|
};
|
|
223
232
|
|
|
224
|
-
var handleOnClose = function
|
|
225
|
-
handleFinish(feedbackData.rewards);
|
|
233
|
+
var handleOnClose = (0, _react.useCallback)(function () {
|
|
234
|
+
handleFinish(feedbackData.rewards, feedbackData.success);
|
|
226
235
|
playSound('click-ui');
|
|
227
236
|
setFeedbackData(function (oldState) {
|
|
228
237
|
return _objectSpread(_objectSpread({}, oldState), {}, {
|
|
@@ -232,7 +241,7 @@ var ImageClickWrapperComponent = function ImageClickWrapperComponent(props) {
|
|
|
232
241
|
rewards: []
|
|
233
242
|
});
|
|
234
243
|
});
|
|
235
|
-
};
|
|
244
|
+
}, [feedbackData.rewards, feedbackData.success, handleFinish, playSound]);
|
|
236
245
|
|
|
237
246
|
var handleCorrectAreaClick = function handleCorrectAreaClick(area) {
|
|
238
247
|
if (!clickedZones.some(function (zone) {
|
|
@@ -241,11 +250,12 @@ var ImageClickWrapperComponent = function ImageClickWrapperComponent(props) {
|
|
|
241
250
|
playSound('click-ui');
|
|
242
251
|
var feedback = solution.right.desc;
|
|
243
252
|
var rewards = solution.right.rewards;
|
|
253
|
+
var updatedZones = [].concat(_toConsumableArray(clickedZones), [area]);
|
|
244
254
|
|
|
245
255
|
if (hasClickOrder && area.index === clickedZones.length || !hasClickOrder) {
|
|
246
256
|
var _specificFeedbacks$co2;
|
|
247
257
|
|
|
248
|
-
if ((_specificFeedbacks$co2 = specificFeedbacks.correctFeedbacks) !== null && _specificFeedbacks$co2 !== void 0 && _specificFeedbacks$co2.length) {
|
|
258
|
+
if (specificFeedbacks !== null && specificFeedbacks !== void 0 && (_specificFeedbacks$co2 = specificFeedbacks.correctFeedbacks) !== null && _specificFeedbacks$co2 !== void 0 && _specificFeedbacks$co2.length) {
|
|
249
259
|
var _specificFeedbacks$co3;
|
|
250
260
|
|
|
251
261
|
var specific = (_specificFeedbacks$co3 = specificFeedbacks.correctFeedbacks) === null || _specificFeedbacks$co3 === void 0 ? void 0 : _specificFeedbacks$co3.find(function (feed) {
|
|
@@ -257,17 +267,21 @@ var ImageClickWrapperComponent = function ImageClickWrapperComponent(props) {
|
|
|
257
267
|
rewards = specific.rewards;
|
|
258
268
|
}
|
|
259
269
|
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
270
|
+
if (!feedback && areas.length > updatedZones.length && !hasClickOnce) {
|
|
271
|
+
handleFinish(rewards, true);
|
|
272
|
+
} else if (feedback && !hasClickOnce) {
|
|
273
|
+
setFeedbackData(function (oldState) {
|
|
274
|
+
return _objectSpread(_objectSpread({}, oldState), {}, {
|
|
275
|
+
show: true,
|
|
276
|
+
success: true,
|
|
277
|
+
text: feedback,
|
|
278
|
+
rewards: rewards
|
|
279
|
+
});
|
|
266
280
|
});
|
|
267
|
-
}
|
|
281
|
+
}
|
|
268
282
|
}
|
|
269
283
|
|
|
270
|
-
setClickedZones(
|
|
284
|
+
setClickedZones(updatedZones);
|
|
271
285
|
} else {
|
|
272
286
|
handleIncorrectAreaClick(area);
|
|
273
287
|
}
|