@gamelearn/arcade-components 2.14.7 → 2.15.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.
|
@@ -103,6 +103,13 @@ var DecisionComponent = function DecisionComponent(_ref) {
|
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
105
|
|
|
106
|
+
var emitGameData = function emitGameData(choice) {
|
|
107
|
+
emitEvent({
|
|
108
|
+
type: 'decisionJournal',
|
|
109
|
+
payload: choice
|
|
110
|
+
});
|
|
111
|
+
};
|
|
112
|
+
|
|
106
113
|
var onNext = function onNext(choice) {
|
|
107
114
|
if (!failed && selectedView === 'results') {
|
|
108
115
|
playSound('click-ui');
|
|
@@ -110,12 +117,15 @@ var DecisionComponent = function DecisionComponent(_ref) {
|
|
|
110
117
|
if (inherited) {
|
|
111
118
|
if (simplifiedOptions) {
|
|
112
119
|
if (_onFinish) {
|
|
120
|
+
emitGameData(choice);
|
|
121
|
+
|
|
113
122
|
_onFinish(choice, function () {
|
|
114
123
|
setResultChoice({});
|
|
115
124
|
selectView('options');
|
|
116
125
|
});
|
|
117
126
|
}
|
|
118
127
|
} else {
|
|
128
|
+
emitGameData(choice);
|
|
119
129
|
emitEvent({
|
|
120
130
|
type: 'addPoints',
|
|
121
131
|
payload: choice.rewards,
|
|
@@ -139,6 +149,7 @@ var DecisionComponent = function DecisionComponent(_ref) {
|
|
|
139
149
|
});
|
|
140
150
|
}
|
|
141
151
|
} else {
|
|
152
|
+
emitGameData(choice);
|
|
142
153
|
emitEvent({
|
|
143
154
|
type: 'addPoints',
|
|
144
155
|
payload: choice.rewards,
|
|
@@ -157,6 +168,7 @@ var DecisionComponent = function DecisionComponent(_ref) {
|
|
|
157
168
|
|
|
158
169
|
if (!branched) {
|
|
159
170
|
if (inherited || required) {
|
|
171
|
+
emitGameData(choice);
|
|
160
172
|
emitEvent({
|
|
161
173
|
type: 'addPoints',
|
|
162
174
|
payload: choice.rewards,
|
|
@@ -174,6 +186,10 @@ var DecisionComponent = function DecisionComponent(_ref) {
|
|
|
174
186
|
playCurrentAudio(choice);
|
|
175
187
|
selectView('results');
|
|
176
188
|
} else {
|
|
189
|
+
emitGameData(_objectSpread(_objectSpread({}, choice), {}, {
|
|
190
|
+
simplified: true
|
|
191
|
+
}));
|
|
192
|
+
|
|
177
193
|
_onFinish(choice, function () {
|
|
178
194
|
setResultChoice({});
|
|
179
195
|
selectView('options');
|
|
@@ -58,6 +58,8 @@ var WriterPuzzleComponent = function WriterPuzzleComponent(_ref) {
|
|
|
58
58
|
retry = _ref.retry,
|
|
59
59
|
skip = _ref.skip,
|
|
60
60
|
type = _ref.type,
|
|
61
|
+
info = _ref.info,
|
|
62
|
+
setResolveAction = _ref.setResolveAction,
|
|
61
63
|
documentTitle = _ref.documentTitle,
|
|
62
64
|
documentTitleLabel = _ref.documentTitle_labelId,
|
|
63
65
|
texts = _ref.texts,
|
|
@@ -139,11 +141,6 @@ var WriterPuzzleComponent = function WriterPuzzleComponent(_ref) {
|
|
|
139
141
|
playSound = _soundActions[0];
|
|
140
142
|
|
|
141
143
|
var rewardedCorrectAnswers = (0, _react.useRef)({});
|
|
142
|
-
(0, _react.useEffect)(function () {
|
|
143
|
-
if (finished) {
|
|
144
|
-
setDisableExit(false);
|
|
145
|
-
}
|
|
146
|
-
}, [finished]);
|
|
147
144
|
|
|
148
145
|
var getCorrectElection = function getCorrectElection(element) {
|
|
149
146
|
var electionIndex;
|
|
@@ -155,14 +152,13 @@ var WriterPuzzleComponent = function WriterPuzzleComponent(_ref) {
|
|
|
155
152
|
return electionIndex;
|
|
156
153
|
};
|
|
157
154
|
|
|
158
|
-
var getFullTextFormDecisionList = function
|
|
155
|
+
var getFullTextFormDecisionList = (0, _react.useCallback)(function (indexOfText) {
|
|
159
156
|
var currentDecision = decisionsList.filter(function (obj) {
|
|
160
157
|
return obj.currenTextParagraph === indexOfText;
|
|
161
158
|
});
|
|
162
159
|
return currentDecision[0].fullText_labelId;
|
|
163
|
-
};
|
|
164
|
-
|
|
165
|
-
var createLecture = function createLecture() {
|
|
160
|
+
}, [decisionsList]);
|
|
161
|
+
var createLecture = (0, _react.useCallback)(function () {
|
|
166
162
|
return texts.map(function (element, indexOfText) {
|
|
167
163
|
if (element.type === 'fixed') {
|
|
168
164
|
var _element$fullText_lab;
|
|
@@ -183,8 +179,7 @@ var WriterPuzzleComponent = function WriterPuzzleComponent(_ref) {
|
|
|
183
179
|
|
|
184
180
|
return '';
|
|
185
181
|
});
|
|
186
|
-
};
|
|
187
|
-
|
|
182
|
+
}, [getFullTextFormDecisionList, texts]);
|
|
188
183
|
var fixedDelay = 12;
|
|
189
184
|
|
|
190
185
|
var checkAllDecisionsRightWrong = function checkAllDecisionsRightWrong() {
|
|
@@ -204,7 +199,7 @@ var WriterPuzzleComponent = function WriterPuzzleComponent(_ref) {
|
|
|
204
199
|
return true;
|
|
205
200
|
};
|
|
206
201
|
|
|
207
|
-
var checkAllDecisionsAreCorrect = function
|
|
202
|
+
var checkAllDecisionsAreCorrect = (0, _react.useCallback)(function () {
|
|
208
203
|
if (decisionsList) {
|
|
209
204
|
var maxCounter = decisionsList.length;
|
|
210
205
|
var rightCounter = 0;
|
|
@@ -219,7 +214,7 @@ var WriterPuzzleComponent = function WriterPuzzleComponent(_ref) {
|
|
|
219
214
|
}
|
|
220
215
|
|
|
221
216
|
return true;
|
|
222
|
-
};
|
|
217
|
+
}, [decisionsList]);
|
|
223
218
|
|
|
224
219
|
var checkIfFeedbackNeeded = function checkIfFeedbackNeeded() {
|
|
225
220
|
return !!(decisionsList && decisionsList.length);
|
|
@@ -232,7 +227,7 @@ var WriterPuzzleComponent = function WriterPuzzleComponent(_ref) {
|
|
|
232
227
|
});
|
|
233
228
|
};
|
|
234
229
|
|
|
235
|
-
var handleLectures = function
|
|
230
|
+
var handleLectures = (0, _react.useCallback)(function () {
|
|
236
231
|
var text = createLecture();
|
|
237
232
|
emitEvent({
|
|
238
233
|
type: 'finishMedia',
|
|
@@ -243,10 +238,10 @@ var WriterPuzzleComponent = function WriterPuzzleComponent(_ref) {
|
|
|
243
238
|
type: 'text'
|
|
244
239
|
}
|
|
245
240
|
});
|
|
246
|
-
};
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
var AllDecisionsCorrect = checkAllDecisionsAreCorrect();
|
|
241
|
+
}, [createLecture, documentTitleLabel, emitEvent, type]);
|
|
242
|
+
var endGame = (0, _react.useCallback)(function (reward) {
|
|
243
|
+
// if any is wrong count as wrong if there are no individual points assigned
|
|
244
|
+
var AllDecisionsCorrect = checkAllDecisionsAreCorrect();
|
|
250
245
|
|
|
251
246
|
if (failed) {
|
|
252
247
|
playSound('fail');
|
|
@@ -258,13 +253,22 @@ var WriterPuzzleComponent = function WriterPuzzleComponent(_ref) {
|
|
|
258
253
|
type: 'addPoints',
|
|
259
254
|
complex: true,
|
|
260
255
|
finish: true,
|
|
261
|
-
payload: rewardsStack,
|
|
256
|
+
payload: reward || rewardsStack,
|
|
262
257
|
onFinish: type !== 'view' ? handleLectures : null
|
|
263
258
|
});
|
|
264
259
|
emitEvent({
|
|
265
260
|
type: 'passPuzzle'
|
|
266
261
|
});
|
|
267
|
-
};
|
|
262
|
+
}, [checkAllDecisionsAreCorrect, emitEvent, failed, handleLectures, playSound, rewardsStack, type]);
|
|
263
|
+
(0, _react.useEffect)(function () {
|
|
264
|
+
if (finished) {
|
|
265
|
+
setDisableExit(false);
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
setResolveAction(function () {
|
|
269
|
+
endGame(info.resolve.rewards);
|
|
270
|
+
});
|
|
271
|
+
}, [emitEvent, endGame, finished, handleLectures, info.resolve.rewards, setResolveAction, type]);
|
|
268
272
|
|
|
269
273
|
var retryPuzzle = function retryPuzzle() {
|
|
270
274
|
setFinished(false);
|
|
@@ -56,6 +56,7 @@ exports.messages = messages;
|
|
|
56
56
|
var mock = {
|
|
57
57
|
emitEvent: _mocker.emitEvent,
|
|
58
58
|
soundActions: _mocker.soundActions,
|
|
59
|
+
setResolveAction: function setResolveAction() {},
|
|
59
60
|
keyboardControl: _mocker.keyboardControl,
|
|
60
61
|
texts: [{
|
|
61
62
|
type: 'fixed',
|
|
@@ -165,6 +166,7 @@ exports.mock = mock;
|
|
|
165
166
|
var mock2 = {
|
|
166
167
|
emitEvent: _mocker.emitEvent,
|
|
167
168
|
soundActions: _mocker.soundActions,
|
|
169
|
+
setResolveAction: function setResolveAction() {},
|
|
168
170
|
keyboardControl: _mocker.keyboardControl,
|
|
169
171
|
texts: [{
|
|
170
172
|
type: 'fixed',
|