@gamelearn/arcade-components 0.22.3 → 0.22.4

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.
@@ -38,7 +38,8 @@ var ChainedImageClickPuzzleComponent = function ChainedImageClickPuzzleComponent
38
38
  soundActions = props.soundActions,
39
39
  showFrames = props.showFrames,
40
40
  disableExit = props.disableExit,
41
- setResolveAction = props.setResolveAction;
41
+ setResolveAction = props.setResolveAction,
42
+ setShowPoints = props.setShowPoints;
42
43
 
43
44
  var _useState = (0, _react.useState)(0),
44
45
  _useState2 = _slicedToArray(_useState, 2),
@@ -55,7 +56,8 @@ var ChainedImageClickPuzzleComponent = function ChainedImageClickPuzzleComponent
55
56
  soundActions: soundActions,
56
57
  setInfo: setInfo,
57
58
  setSelected: setSelected,
58
- selected: selected
59
+ selected: selected,
60
+ setShowPoints: setShowPoints
59
61
  };
60
62
  var totalCorrects = list.reduce(function (acc, current) {
61
63
  return acc + current.areas.length;
@@ -55,7 +55,8 @@ var CurrentImageClickPuzzle = function CurrentImageClickPuzzle(_ref) {
55
55
  setResolveAction = _ref.setResolveAction,
56
56
  soundActions = _ref.soundActions,
57
57
  setSelected = _ref.setSelected,
58
- selected = _ref.selected;
58
+ selected = _ref.selected,
59
+ setShowPoints = _ref.setShowPoints;
59
60
  var accRewards = (0, _react.useRef)([]);
60
61
 
61
62
  var _useState = (0, _react.useState)(0),
@@ -82,10 +83,11 @@ var CurrentImageClickPuzzle = function CurrentImageClickPuzzle(_ref) {
82
83
  var handleFinish = (0, _react.useCallback)(function (rewards) {
83
84
  playSound('score');
84
85
  emitEvent({
85
- type: 'addPoints',
86
- payload: [].concat(_toConsumableArray(accRewards.current), _toConsumableArray(rewards))
86
+ type: 'hidePuzzleButtons',
87
+ payload: false
87
88
  });
88
- }, [emitEvent, playSound]);
89
+ setShowPoints([].concat(_toConsumableArray(accRewards.current), _toConsumableArray(rewards)));
90
+ }, [playSound, emitEvent, setShowPoints]);
89
91
  var currentImageProps = list[index];
90
92
  var info = currentImageProps.info;
91
93
  info.description = description;
@@ -133,7 +133,6 @@ var ImageClickWrapperComponent = function ImageClickWrapperComponent(props) {
133
133
  });
134
134
  var handleFinish = (0, _react.useCallback)(function () {
135
135
  var rewards = solution.right.rewards;
136
- playSound('score');
137
136
 
138
137
  if (emitFinish) {
139
138
  emitFinish(rewards);
@@ -143,7 +142,7 @@ var ImageClickWrapperComponent = function ImageClickWrapperComponent(props) {
143
142
  payload: rewards
144
143
  });
145
144
  }
146
- }, [emitEvent, emitFinish, solution.right, playSound]);
145
+ }, [emitEvent, emitFinish, solution.right]);
147
146
  (0, _react.useEffect)(function () {
148
147
  if (completed) {
149
148
  disableExit(true);
@@ -154,16 +153,13 @@ var ImageClickWrapperComponent = function ImageClickWrapperComponent(props) {
154
153
  }, [defaultCompleted]);
155
154
  (0, _react.useEffect)(function () {
156
155
  if (areas.length === clickedZones.length && !completed) {
157
- playSound('score');
158
156
  setCompleted(true);
159
157
  setDisableClick(true);
160
158
  setResolveClass('success');
161
159
  }
162
- }, [clickedZones, areas.length, handleFinish, completed, info.solution.right.desc, playSound, emitEvent]);
160
+ }, [clickedZones, areas.length, handleFinish, completed, info.solution.right.desc, emitEvent]);
163
161
  (0, _react.useEffect)(function () {
164
- //autoResolve
165
162
  setResolveAction(function (resolve) {
166
- playSound('score');
167
163
  setCompleted(true);
168
164
  setDisableClick(true);
169
165
  setFinished(true);
@@ -15,8 +15,14 @@ var emitEvent = function emitEvent(_ref) {
15
15
  }
16
16
  };
17
17
 
18
+ var audio = {
19
+ fail: new Audio('https://www.soundjay.com/buttons/button-10.mp3'),
20
+ 'click-ui': new Audio('https://www.soundjay.com/buttons/button-16.mp3'),
21
+ score: new Audio('https://www.soundjay.com/mechanical/camera-shutter-click-01.mp3')
22
+ };
18
23
  var soundActions = [function (sound) {
19
24
  console.log('PlaySound called :', sound);
25
+ sound && audio[sound].play();
20
26
  }, function () {}];
21
27
  var mockProps = {
22
28
  emitEvent: emitEvent,
@@ -87,7 +93,34 @@ var mockProps = {
87
93
  fill: 'rgba(68, 215, 171, 0.56)',
88
94
  closed: true
89
95
  }],
90
- badAreas: [],
96
+ badAreas: [{
97
+ name: 'Bad1',
98
+ x: 0,
99
+ y: 0,
100
+ fill: 'rgba(255, 255, 255, 0.1)',
101
+ draggable: true,
102
+ points: [700, 200, 800, 190, 900, 450, 640.8, 396],
103
+ stroke: 'rgb(101,154,93)',
104
+ closed: true
105
+ }, {
106
+ name: 'Bad',
107
+ x: 0,
108
+ y: 0,
109
+ fill: 'rgba(255, 255, 255, 0.1)',
110
+ draggable: true,
111
+ points: [900, 300, 900, 233, 1200, 555, 777, 555],
112
+ stroke: 'rgb(101,154,93)',
113
+ closed: true
114
+ }, {
115
+ name: 'Bad',
116
+ x: 0,
117
+ y: 0,
118
+ fill: 'rgba(255, 255, 255, 0.1)',
119
+ draggable: true,
120
+ points: [111, 111, 222, 111, 666, 450, 640.8, 396],
121
+ stroke: 'rgb(101,154,93)',
122
+ closed: true
123
+ }],
91
124
  hasClickOrder: true,
92
125
  hasHighlights: true
93
126
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@gamelearn/arcade-components",
3
3
  "license": "Gamelearn",
4
- "version": "0.22.3",
4
+ "version": "0.22.4",
5
5
  "main": "dist/index.js",
6
6
  "files": [
7
7
  "dist",