@gamelearn/arcade-components 1.4.1 → 1.4.3
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.
|
@@ -88,7 +88,7 @@ var DecisionBody = function DecisionBody(_ref) {
|
|
|
88
88
|
type: "button",
|
|
89
89
|
className: "gat--btn gat--btn__primary ".concat(selectedChoice.id !== undefined ? '' : 'disabled'),
|
|
90
90
|
onClick: function onClick() {
|
|
91
|
-
return canNext ? onNext(selectedChoice) : onBack();
|
|
91
|
+
return canNext ? onNext(selectedChoice) : onBack(selectedChoice);
|
|
92
92
|
}
|
|
93
93
|
}, canNext || selectedChoice.id === undefined ? translate('screens.continue') : translate('tests.retry'))));
|
|
94
94
|
};
|
|
@@ -55,7 +55,7 @@ var DecisionComponent = function DecisionComponent(_ref) {
|
|
|
55
55
|
inheritProps = _props$inheritProps === void 0 ? {} : _props$inheritProps,
|
|
56
56
|
required = props.required,
|
|
57
57
|
question = props.question,
|
|
58
|
-
|
|
58
|
+
_onFinish = props.onFinish;
|
|
59
59
|
var inherited = Object.keys(inheritProps).length > 0;
|
|
60
60
|
|
|
61
61
|
var _useState = (0, _react.useState)('options'),
|
|
@@ -115,39 +115,72 @@ var DecisionComponent = function DecisionComponent(_ref) {
|
|
|
115
115
|
setResultChoice(option);
|
|
116
116
|
selectView('options');
|
|
117
117
|
},
|
|
118
|
-
onBack: function onBack() {
|
|
118
|
+
onBack: function onBack(choice) {
|
|
119
119
|
playSound('click-ui');
|
|
120
120
|
|
|
121
121
|
if (failed) {
|
|
122
|
-
|
|
123
|
-
|
|
122
|
+
emitEvent({
|
|
123
|
+
type: 'addPoints',
|
|
124
|
+
payload: choice.rewards,
|
|
125
|
+
finish: false,
|
|
126
|
+
complex: true,
|
|
127
|
+
onFinish: function onFinish() {
|
|
128
|
+
setResultChoice({});
|
|
129
|
+
selectView('options');
|
|
130
|
+
}
|
|
131
|
+
});
|
|
124
132
|
}
|
|
125
133
|
},
|
|
126
134
|
onNext: function onNext(choice) {
|
|
127
135
|
playSound('click-ui');
|
|
128
136
|
|
|
129
137
|
if (!failed && selectedView === 'results') {
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
138
|
+
if (inherited) {
|
|
139
|
+
emitEvent({
|
|
140
|
+
type: 'addPoints',
|
|
141
|
+
payload: choice.rewards,
|
|
142
|
+
finish: true,
|
|
143
|
+
complex: true,
|
|
144
|
+
onFinish: function onFinish() {
|
|
145
|
+
if (_onFinish) {
|
|
146
|
+
_onFinish();
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
setResultChoice({});
|
|
150
|
+
selectView('options');
|
|
151
|
+
}
|
|
152
|
+
});
|
|
142
153
|
} else {
|
|
143
|
-
playSound('fail');
|
|
144
154
|
emitEvent({
|
|
145
155
|
type: 'addPoints',
|
|
146
156
|
payload: choice.rewards,
|
|
147
|
-
finish:
|
|
157
|
+
finish: true,
|
|
148
158
|
complex: true
|
|
149
159
|
});
|
|
150
160
|
}
|
|
161
|
+
} else if (Object.keys(choice).length > 0) {
|
|
162
|
+
if (choice.right) {
|
|
163
|
+
playSound('score');
|
|
164
|
+
} else {
|
|
165
|
+
playSound('fail');
|
|
166
|
+
|
|
167
|
+
if (inherited) {
|
|
168
|
+
emitEvent({
|
|
169
|
+
type: 'addPoints',
|
|
170
|
+
payload: choice.rewards,
|
|
171
|
+
finish: false,
|
|
172
|
+
complex: true
|
|
173
|
+
});
|
|
174
|
+
} else if (!required) {
|
|
175
|
+
emitEvent({
|
|
176
|
+
type: 'addPoints',
|
|
177
|
+
payload: choice.rewards,
|
|
178
|
+
finish: true,
|
|
179
|
+
complex: true,
|
|
180
|
+
onFinish: _onFinish
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
}
|
|
151
184
|
|
|
152
185
|
setResultChoice(choice);
|
|
153
186
|
playCurrentAudio(choice);
|