@urso/core 0.6.16-dev → 0.6.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.
Files changed (156) hide show
  1. package/.babelrc +11 -11
  2. package/LICENSE +20 -20
  3. package/README.md +227 -227
  4. package/build/js/index.js +1 -1
  5. package/build/js/index.js.LICENSE.txt +38 -270
  6. package/package.json +52 -52
  7. package/src/js/app.js +79 -79
  8. package/src/js/components/_info.js +11 -11
  9. package/src/js/components/base/_info.js +3 -3
  10. package/src/js/components/base/controller.js +78 -78
  11. package/src/js/components/debug/_info.js +7 -7
  12. package/src/js/components/debug/controller.js +38 -38
  13. package/src/js/components/debug/coords.js +23 -23
  14. package/src/js/components/debug/fps.js +36 -36
  15. package/src/js/components/debug/template.js +55 -55
  16. package/src/js/components/debug/timescale.js +60 -60
  17. package/src/js/components/deviceRotate/_info.js +3 -3
  18. package/src/js/components/deviceRotate/controller.js +86 -86
  19. package/src/js/components/fullscreen/_info.js +6 -6
  20. package/src/js/components/fullscreen/android.js +104 -104
  21. package/src/js/components/fullscreen/controller.js +76 -76
  22. package/src/js/components/fullscreen/desktop.js +49 -49
  23. package/src/js/components/fullscreen/ios.js +115 -115
  24. package/src/js/components/layersSwitcher/_info.js +4 -4
  25. package/src/js/components/layersSwitcher/config.js +26 -26
  26. package/src/js/components/layersSwitcher/controller.js +34 -34
  27. package/src/js/components/loader/_info.js +4 -4
  28. package/src/js/components/loader/controller.js +65 -65
  29. package/src/js/components/loader/template.js +70 -70
  30. package/src/js/components/soundInitialPopup/_info.js +3 -3
  31. package/src/js/components/soundInitialPopup/controller.js +42 -42
  32. package/src/js/components/soundInitialPopup/template.js +109 -109
  33. package/src/js/components/stateDriven/_info.js +3 -3
  34. package/src/js/components/stateDriven/controller.js +118 -118
  35. package/src/js/config/load.js +5 -5
  36. package/src/js/config/main.js +16 -16
  37. package/src/js/extra/_info.js +26 -26
  38. package/src/js/extra/browserEvents.js +51 -51
  39. package/src/js/extra/pixiPatch.js +150 -150
  40. package/src/js/extra/setTimeout.js +7 -7
  41. package/src/js/index.js +8 -8
  42. package/src/js/lib/_info.js +13 -13
  43. package/src/js/lib/cache.js +105 -105
  44. package/src/js/lib/composition.js +85 -85
  45. package/src/js/lib/device.js +1286 -1286
  46. package/src/js/lib/helper.js +556 -556
  47. package/src/js/lib/loader.js +136 -136
  48. package/src/js/lib/localData.js +15 -15
  49. package/src/js/lib/logger.js +69 -69
  50. package/src/js/lib/math.js +35 -35
  51. package/src/js/lib/objectPool.js +203 -203
  52. package/src/js/lib/time.js +18 -18
  53. package/src/js/lib/tween.js +147 -147
  54. package/src/js/modules/_info.js +12 -12
  55. package/src/js/modules/assets/_info.js +7 -7
  56. package/src/js/modules/assets/baseModel.js +20 -20
  57. package/src/js/modules/assets/config.js +37 -37
  58. package/src/js/modules/assets/controller.js +46 -46
  59. package/src/js/modules/assets/models/_info.js +11 -11
  60. package/src/js/modules/assets/models/atlas.js +8 -8
  61. package/src/js/modules/assets/models/audiosprite.js +27 -27
  62. package/src/js/modules/assets/models/bitmapFont.js +8 -8
  63. package/src/js/modules/assets/models/container.js +16 -16
  64. package/src/js/modules/assets/models/font.js +8 -8
  65. package/src/js/modules/assets/models/image.js +15 -15
  66. package/src/js/modules/assets/models/json.js +8 -8
  67. package/src/js/modules/assets/models/sound.js +14 -14
  68. package/src/js/modules/assets/models/spine.js +14 -14
  69. package/src/js/modules/assets/service.js +366 -366
  70. package/src/js/modules/i18n/_info.js +4 -4
  71. package/src/js/modules/i18n/config.js +17 -17
  72. package/src/js/modules/i18n/controller.js +79 -79
  73. package/src/js/modules/instances/_info.js +3 -3
  74. package/src/js/modules/instances/controller.js +357 -357
  75. package/src/js/modules/logic/_info.js +4 -4
  76. package/src/js/modules/logic/config/_info.js +2 -2
  77. package/src/js/modules/logic/config/sounds.js +23 -23
  78. package/src/js/modules/logic/controller.js +48 -48
  79. package/src/js/modules/logic/sounds.js +103 -103
  80. package/src/js/modules/objects/_info.js +13 -13
  81. package/src/js/modules/objects/baseModel.js +200 -200
  82. package/src/js/modules/objects/cache.js +99 -99
  83. package/src/js/modules/objects/controller.js +131 -131
  84. package/src/js/modules/objects/find.js +58 -58
  85. package/src/js/modules/objects/models/_info.js +27 -27
  86. package/src/js/modules/objects/models/atlasImage.js +50 -50
  87. package/src/js/modules/objects/models/bitmapText.js +37 -37
  88. package/src/js/modules/objects/models/button.js +189 -189
  89. package/src/js/modules/objects/models/buttonComposite.js +35 -35
  90. package/src/js/modules/objects/models/checkbox.js +96 -96
  91. package/src/js/modules/objects/models/collection.js +54 -54
  92. package/src/js/modules/objects/models/component.js +46 -46
  93. package/src/js/modules/objects/models/container.js +19 -19
  94. package/src/js/modules/objects/models/dragContainer.js +667 -667
  95. package/src/js/modules/objects/models/emitter.js +67 -67
  96. package/src/js/modules/objects/models/emitterFx.js +99 -99
  97. package/src/js/modules/objects/models/graphics.js +38 -38
  98. package/src/js/modules/objects/models/group.js +19 -19
  99. package/src/js/modules/objects/models/hitArea.js +104 -104
  100. package/src/js/modules/objects/models/image.js +34 -34
  101. package/src/js/modules/objects/models/imagesAnimation.js +113 -113
  102. package/src/js/modules/objects/models/mask.js +38 -38
  103. package/src/js/modules/objects/models/nineSlicePlane.js +30 -30
  104. package/src/js/modules/objects/models/scrollbox.js +64 -64
  105. package/src/js/modules/objects/models/slider.js +253 -253
  106. package/src/js/modules/objects/models/spine.js +296 -287
  107. package/src/js/modules/objects/models/text.js +59 -59
  108. package/src/js/modules/objects/models/textInput.js +66 -66
  109. package/src/js/modules/objects/models/toggle.js +180 -180
  110. package/src/js/modules/objects/models/world.js +19 -19
  111. package/src/js/modules/objects/propertyAdapter.js +588 -587
  112. package/src/js/modules/objects/proxy.js +294 -294
  113. package/src/js/modules/objects/selector.js +136 -136
  114. package/src/js/modules/objects/service.js +242 -242
  115. package/src/js/modules/objects/styles.js +210 -210
  116. package/src/js/modules/observer/_info.js +4 -4
  117. package/src/js/modules/observer/controller.js +99 -99
  118. package/src/js/modules/observer/events.js +52 -52
  119. package/src/js/modules/scenes/_info.js +8 -8
  120. package/src/js/modules/scenes/controller.js +119 -119
  121. package/src/js/modules/scenes/model.js +28 -28
  122. package/src/js/modules/scenes/pixiWrapper.js +336 -336
  123. package/src/js/modules/scenes/resolutions.js +173 -173
  124. package/src/js/modules/scenes/resolutionsConfig.js +73 -73
  125. package/src/js/modules/scenes/service.js +142 -142
  126. package/src/js/modules/soundManager/_info.js +3 -3
  127. package/src/js/modules/soundManager/controller.js +100 -100
  128. package/src/js/modules/soundManager/soundSprite.js +251 -251
  129. package/src/js/modules/statesManager/_info.js +12 -12
  130. package/src/js/modules/statesManager/action.js +68 -68
  131. package/src/js/modules/statesManager/actions/_info.js +3 -3
  132. package/src/js/modules/statesManager/all.js +23 -23
  133. package/src/js/modules/statesManager/configStates.js +71 -71
  134. package/src/js/modules/statesManager/controller.js +170 -170
  135. package/src/js/modules/statesManager/functionsStorage.js +82 -82
  136. package/src/js/modules/statesManager/helper.js +27 -27
  137. package/src/js/modules/statesManager/race.js +75 -75
  138. package/src/js/modules/statesManager/sequence.js +47 -47
  139. package/src/js/modules/template/_info.js +6 -6
  140. package/src/js/modules/template/controller.js +28 -28
  141. package/src/js/modules/template/model.js +11 -11
  142. package/src/js/modules/template/service.js +137 -137
  143. package/src/js/modules/template/types.js +46 -46
  144. package/src/js/modules/transport/_info.js +8 -8
  145. package/src/js/modules/transport/baseConnectionType.js +24 -24
  146. package/src/js/modules/transport/config.js +13 -13
  147. package/src/js/modules/transport/connectionTypes/_info.js +3 -3
  148. package/src/js/modules/transport/connectionTypes/websocket.js +74 -74
  149. package/src/js/modules/transport/connectionTypes/xhr.js +44 -44
  150. package/src/js/modules/transport/controller.js +48 -48
  151. package/src/js/modules/transport/decorator.js +17 -17
  152. package/src/js/modules/transport/service.js +153 -153
  153. package/src/js/templates/_info.js +4 -4
  154. package/src/js/templates/groups/_info.js +1 -1
  155. package/src/js/templates/scenes/_info.js +1 -1
  156. package/webpack.config.js +47 -47
@@ -1,556 +1,556 @@
1
- class LibHelper {
2
-
3
- constructor() {
4
-
5
- /**
6
- * angle radian factor
7
- * @type Number
8
- */
9
- this._arFactor = (Math.PI / 180);
10
- }
11
-
12
- /**
13
- * getting GET param(s) by name or all params list
14
- *
15
- * @param {string} [name] - get param name
16
- * @returns {Object}
17
- */
18
- parseGetParams(name) {
19
- let $_GET = {};
20
- const _GET = window.location.href.substring(1).split("?");
21
-
22
- if (_GET[1]) {
23
- const __GET = _GET[1].split("&");
24
-
25
- for (let i = 0; i < __GET.length; i++) {
26
- let getVar = __GET[i].split("=");
27
- $_GET[getVar[0]] = typeof getVar[1] === "undefined" ? "" : getVar[1];
28
- }
29
- }
30
-
31
- if (!name)
32
- return $_GET;
33
-
34
- return $_GET[name];
35
- }
36
-
37
- /**
38
- * get uniq elements from two arrays
39
- * @param {Array} array1
40
- * @param {Array} array2
41
- * @example arraysGetUniqElements([1,2,3], [2,3,4]) returns [1, 4]
42
- */
43
- arraysGetUniqElements(array1, array2) {
44
- const result = [];
45
- const tempObject = {};
46
- let key, element;
47
-
48
- const parseArray = function (arrayObject) {
49
- for (element of arrayObject) {
50
- if (!tempObject[element])
51
- tempObject[element] = { counter: 1, value: element };
52
- else
53
- tempObject[element].counter++;
54
- }
55
- };
56
-
57
- parseArray(array1);
58
- parseArray(array2);
59
-
60
- for (key in tempObject)
61
- if (tempObject[key].counter === 1)
62
- result.push(tempObject[key].value);
63
-
64
- return result;
65
- }
66
-
67
- /**
68
- * replase string pattern in the string
69
- * @param {String} needle
70
- * @param {String} replacement
71
- * @param {String} haystack
72
- * @returns {String}
73
- */
74
- stringReplace(needle, replacement, haystack) {
75
- return haystack.split(needle).join(replacement);
76
- }
77
-
78
- /**
79
- * capitalise first letter in the string
80
- * @param {String} str
81
- * @returns {String}
82
- */
83
- capitaliseFirstLetter(str) {
84
- return str.charAt(0).toUpperCase() + str.slice(1);
85
- }
86
-
87
- /**
88
- * returns array without last element
89
- * @param {Array} array
90
- * @returns {Array}
91
- */
92
- initial(array) {
93
- array.pop();
94
- return array;
95
- }
96
-
97
- /**
98
- * lead degree zero
99
- * @param {Number} num
100
- * @param {Number} count
101
- * @returns {String}
102
- */
103
- ldgZero(num, count) {
104
- let numZeropad = num + '';
105
-
106
- while (numZeropad.length < count) {
107
- numZeropad = "0" + numZeropad;
108
- }
109
-
110
- return numZeropad;
111
- }
112
-
113
- /**
114
- * merge two arrays into new array
115
- * @param {Array} a
116
- * @param {Array} b
117
- */
118
- mergeArrays(a, b) {
119
- let c = a.concat(b.filter(function (item) {
120
- return a.indexOf(item) < 0;
121
- }));
122
-
123
- return c;
124
- }
125
-
126
- /**
127
- * Swap key with value in object
128
- * @param {Object} obj
129
- * @returns {Object}
130
- */
131
- objectFlip(obj) {
132
- const ret = {};
133
-
134
- Object.keys(obj).forEach(key => {
135
- ret[obj[key]] = key;
136
- });
137
-
138
- return ret;
139
- }
140
-
141
- /**
142
- * recursive set value to object by key
143
- * @param {String} key
144
- * @param {Mixed} value
145
- * @param {Object} object
146
- * @returns {Boolean}
147
- */
148
- recursiveSet(key, value, object) {
149
- key = (typeof key === 'string') ? key.split(".") : key;
150
-
151
- let firstKey = key.shift();
152
-
153
- if (key.length > 0) {
154
- if (!object[firstKey])
155
- object[firstKey] = {};
156
-
157
- this.recursiveSet(key, value, object[firstKey]);
158
- } else
159
- object[firstKey] = value;
160
-
161
- return true;
162
- }
163
-
164
- /**
165
- * @param {Array} matrix
166
- * @returns {Array}
167
- */
168
- rowsToCols(matrix) {
169
- return Object.keys(matrix[0])
170
- .map(colNumber => matrix.map(rowNumber => rowNumber[colNumber]));
171
- }
172
-
173
- /**
174
- * recursive get value from object by key
175
- * @param {String} key
176
- * @param {Object} object
177
- * @returns {Mixed}
178
- */
179
- recursiveGet(key, object, defaultResult) {
180
- if (object === undefined)
181
- return defaultResult;
182
-
183
- key = (typeof key === 'string') ? key.split(".") : key;
184
-
185
- for (let k of key) {
186
- if (typeof object[k] === 'undefined')
187
- return defaultResult;
188
-
189
- object = object[k];
190
- }
191
-
192
- return object;
193
- }
194
-
195
- /**
196
- * recursive delete value from object by key
197
- * @param {String} key
198
- * @param {Object} object
199
- * @returns {Boolean}
200
- */
201
- recursiveDelete(key, obj) {
202
- key = (typeof key === 'string') ? key.split(".") : key;
203
-
204
- for (let k = 0; k < key.length; k++) {
205
- let ok = key[k];
206
-
207
- if (typeof obj[ok] === 'undefined')
208
- return false;
209
-
210
- if (k === (key.length - 1))
211
- delete (obj[ok]);
212
- else
213
- obj = obj[ok];
214
- }
215
-
216
- return true;
217
- }
218
-
219
- /**
220
- * tranpose matrix (rows to cols)
221
- * @param {Array} matrix
222
- * @returns {Array}
223
- */
224
- transpose(matrix) {
225
- return Object.keys(matrix[0])
226
- .map(colNumber => matrix
227
- .map(rowNumber => rowNumber[colNumber]));
228
- }
229
-
230
- /**
231
- * recursive merge two objects into one
232
- * @param {Object} obj1
233
- * @param {Object} obj2
234
- * @param {Boolean} mergeInFirstFlag
235
- * @returns {Object}
236
- */
237
- mergeObjectsRecursive(obj1, obj2, mergeInFirstFlag) {
238
- let newObj = (mergeInFirstFlag) ? obj1 : this.objectClone(obj1);
239
-
240
- for (let k in obj2) {
241
- if (typeof obj2[k] === 'object' && typeof obj1[k] === 'object')
242
- newObj[k] = this.mergeObjectsRecursive(obj1[k], obj2[k], mergeInFirstFlag);
243
- else
244
- newObj[k] = obj2[k];
245
- }
246
-
247
- return newObj;
248
- }
249
-
250
- /**
251
- * rename objects key
252
- * @param {Object} obj
253
- * @param {String} oldKey
254
- * @param {String} newKey
255
- */
256
- renameObjectsKey(obj, oldKey, newKey) {
257
- if (oldKey !== newKey) {
258
- Object.defineProperty(
259
- obj, newKey,
260
- Object.getOwnPropertyDescriptor(obj, oldKey)
261
- );
262
-
263
- delete obj[oldKey];
264
- }
265
- }
266
-
267
- /**
268
- * clone object
269
- * @param {Object} obj
270
- * @param {Number} recursiveCalls
271
- * @returns {Object}
272
- */
273
- objectClone(obj, recursiveCalls) {
274
- if (!obj || "object" !== typeof obj)
275
- return obj;
276
-
277
- if (typeof recursiveCalls === 'undefined')
278
- recursiveCalls = 999;
279
-
280
- let clone = "function" === typeof obj.pop ? [] : {}; //object o array
281
- let prop, propValue;
282
-
283
- if (obj.hasOwnProperty)
284
- for (prop in obj) {
285
- if (obj.hasOwnProperty(prop)) {
286
- propValue = obj[prop];
287
-
288
- if (prop === "imageSrc")
289
- clone[prop] = propValue;
290
- else if (propValue && "object" === typeof propValue)
291
- clone[prop] = (recursiveCalls) ? this.objectClone(propValue, recursiveCalls - 1) : '[object Object]';
292
- else
293
- clone[prop] = propValue;
294
- }
295
- }
296
-
297
- return clone;
298
- }
299
-
300
- /**
301
- * get object size (keys length)
302
- * @param {Object} obj
303
- * @returns {Number}
304
- */
305
- getObjectSize(obj) {
306
- return Object.keys(obj).length;
307
- }
308
-
309
- /**
310
- * object apply
311
- * @param {Object} fromObj
312
- * @param {Object} toObj
313
- * @returns {Object}
314
- */
315
- objectApply(fromObj, toObj, recursiveCalls = 999) {
316
- if (!recursiveCalls)
317
- return fromObj;
318
-
319
- for (let k in toObj) {
320
- let paramTo = toObj[k];
321
-
322
- if (!fromObj[k]) {
323
- fromObj[k] = paramTo;
324
- } else if (typeof paramTo === "array" || typeof paramTo === "object") {
325
- fromObj[k] = this.objectApply(fromObj[k], toObj[k], recursiveCalls - 1);
326
- } else {
327
- if (toObj[k] !== fromObj[k]) {
328
- fromObj[k] = paramTo;
329
- }
330
- }
331
- }
332
-
333
- return fromObj;
334
- }
335
-
336
- /**
337
- * check deep objects equal
338
- * @param {Object} obj1
339
- * @param {Object} obj2
340
- * @returns {Boolean}
341
- */
342
- checkDeepEqual(obj1, obj2) {
343
- return JSON.stringify(obj1) === JSON.stringify(obj2);
344
- }
345
-
346
- /**
347
- * check objects equal
348
- * @param {Object} obj1
349
- * @param {Object} obj2
350
- * @returns {Boolean}
351
- */
352
- checkEqual(obj1, obj2) {
353
- const objSort = (o) => {
354
- const sortedObj = {};
355
- const keys = Object.keys(o);
356
- keys.sort();
357
-
358
- for (let index in keys) {
359
- if (keys.hasOwnProperty(index)) {
360
- let key = keys[index];
361
- let value = o[key];
362
-
363
- if (typeof o[key] === 'object')
364
- value = objSort(value);
365
-
366
- sortedObj[key] = value;
367
- }
368
- }
369
-
370
- return sortedObj;
371
- };
372
-
373
- const o1s = objSort(obj1);
374
- const o2s = objSort(obj2);
375
-
376
- return this.checkDeepEqual(o1s, o2s);
377
- }
378
-
379
- /**
380
- * check Arrays Partial Entry
381
- * @param {Object} main
382
- * @param {Object} partial
383
- * @returns {Boolean}
384
- */
385
- checkArraysPartialEntry(main, partial) {
386
- if (!main || !partial)
387
- return false;
388
-
389
- main = main.sort();
390
- partial = partial.sort();
391
-
392
- let kPartial = partial.length - 1;
393
-
394
- for (let i = main.length - 1; i >= 0; i--) {
395
- if (JSON.stringify(main[i]) === JSON.stringify(partial[kPartial]))
396
- kPartial--;
397
-
398
- if (kPartial === -1)
399
- return true;
400
- }
401
-
402
- return false;
403
- }
404
-
405
- /**
406
- * check is device mobile or tablet
407
- * @returns {Boolean}
408
- */
409
- mobileAndTabletCheck() {
410
- let check = false;
411
- (function (a) {
412
- if (/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino|android|ipad|playbook|silk/i.test(a) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0, 4)))
413
- check = true;
414
- })(navigator.userAgent || navigator.vendor || window.opera);
415
-
416
- return check;
417
- }
418
-
419
- /**
420
- * make objects property reactive
421
- * @param {Object} targetObject
422
- * @param {String} key
423
- * @param {Function} callback
424
- * @returns
425
- */
426
- reactive(targetObject, key, callback) {
427
- let descriptor = Object.getOwnPropertyDescriptor(targetObject, key);
428
- let targetObjectTemp = targetObject;
429
-
430
- while (!descriptor && targetObjectTemp.__proto__) {
431
- targetObjectTemp = targetObjectTemp.__proto__;
432
- let descriptorTemp = Object.getOwnPropertyDescriptor(targetObjectTemp, key);
433
-
434
- if (descriptorTemp && (descriptorTemp.value || descriptorTemp.set || descriptorTemp.get)) {
435
- descriptor = descriptorTemp;
436
- }
437
- }
438
-
439
- if (!descriptor) // bad descriptors and its IOS mobile
440
- return false;
441
-
442
- if (typeof descriptor.value !== 'undefined') {
443
- let value = descriptor.value;
444
- descriptor.get = function () { return value; };
445
- descriptor.set = function (v) { value = v; };
446
-
447
- delete descriptor.value;
448
- delete descriptor.writable;
449
- }
450
-
451
- let setter = descriptor.set;
452
-
453
- descriptor.set = function (v) {
454
- if (setter)
455
- setter.call(targetObject, v);
456
-
457
- callback.call(targetObject, v);
458
- };
459
-
460
- Object.defineProperty(targetObject, key, descriptor);
461
-
462
- return true;
463
- }
464
-
465
-
466
- /**
467
- * calc length between two points
468
- *
469
- * @param {Object} point1
470
- * @param {Object} point1
471
- * @return {Number}
472
- */
473
- getLengthBy2Points(point1, point2) {
474
- return Math.sqrt((point2.x - point1.x) * (point2.x - point1.x) +
475
- (point2.y - point1.y) * (point2.y - point1.y));
476
- }
477
-
478
- /**
479
- * calc angle between three points (in radians)
480
- *
481
- * @param {Object} point1
482
- * @param {Object} point2
483
- * @param {Object} point3
484
- * @return {Number}
485
- */
486
- getAngleBy3Points(point1, point2, point3) {
487
- let angle = 0;
488
- const c = this.getLengthBy2Points(point1, point3);
489
- const a = this.getLengthBy2Points(point1, point2);
490
- const b = this.getLengthBy2Points(point2, point3);
491
-
492
- if (a !== 0 && b !== 0) {
493
- const cornerRcos = (a * a + b * b - c * c) / (2 * a * b);
494
- angle = Math.acos(cornerRcos);
495
- }
496
-
497
- return angle;
498
- }
499
-
500
-
501
- /**
502
- * get angle in radians from degrees
503
- *
504
- * @param {Number} angle
505
- * @return {Number}
506
- */
507
- getRadian(angle) {
508
- return (angle * this._arFactor);
509
- }
510
-
511
- /**
512
- * get angle in degrees from radians
513
- *
514
- * @param {Number} radian
515
- * @return {Number}
516
- */
517
- getAngle(radian) {
518
- return (radian / this._arFactor);
519
- }
520
-
521
- /**
522
- * arguments {oblect} (ClassInstance, functionName, param1, param2, ...)
523
- * needs {Object} obj._logicBlocks;
524
- * creates {Object} obj._logicBlocksInstances;
525
- * @returns {Array} execution results
526
- */
527
- logicBlocksDo() {
528
- const params = Array.prototype.slice.call(arguments);
529
- const entity = params.shift();
530
- const funcName = params.shift();
531
-
532
- //if no instances we will create them
533
- if (!entity._logicBlocksInstances) {
534
- entity._logicBlocksInstances = {};
535
-
536
- for (let k in entity._logicBlocks) {
537
- const name = entity._logicBlocks[k];
538
- const nameCap = this.capitaliseFirstLetter(name);
539
- entity._logicBlocksInstances[name] = entity.getInstance(nameCap);
540
- }
541
- }
542
-
543
- let results = [];
544
- //game
545
- for (let name in entity._logicBlocksInstances) {
546
- if (entity._logicBlocksInstances[name][funcName]) {
547
- const res = entity._logicBlocksInstances[name][funcName].apply(this, params);
548
- results.push(res);
549
- }
550
- }
551
-
552
- return results;
553
- }
554
- }
555
-
556
- module.exports = LibHelper;
1
+ class LibHelper {
2
+
3
+ constructor() {
4
+
5
+ /**
6
+ * angle radian factor
7
+ * @type Number
8
+ */
9
+ this._arFactor = (Math.PI / 180);
10
+ }
11
+
12
+ /**
13
+ * getting GET param(s) by name or all params list
14
+ *
15
+ * @param {string} [name] - get param name
16
+ * @returns {Object}
17
+ */
18
+ parseGetParams(name) {
19
+ let $_GET = {};
20
+ const _GET = window.location.href.substring(1).split("?");
21
+
22
+ if (_GET[1]) {
23
+ const __GET = _GET[1].split("&");
24
+
25
+ for (let i = 0; i < __GET.length; i++) {
26
+ let getVar = __GET[i].split("=");
27
+ $_GET[getVar[0]] = typeof getVar[1] === "undefined" ? "" : getVar[1];
28
+ }
29
+ }
30
+
31
+ if (!name)
32
+ return $_GET;
33
+
34
+ return $_GET[name];
35
+ }
36
+
37
+ /**
38
+ * get uniq elements from two arrays
39
+ * @param {Array} array1
40
+ * @param {Array} array2
41
+ * @example arraysGetUniqElements([1,2,3], [2,3,4]) returns [1, 4]
42
+ */
43
+ arraysGetUniqElements(array1, array2) {
44
+ const result = [];
45
+ const tempObject = {};
46
+ let key, element;
47
+
48
+ const parseArray = function (arrayObject) {
49
+ for (element of arrayObject) {
50
+ if (!tempObject[element])
51
+ tempObject[element] = { counter: 1, value: element };
52
+ else
53
+ tempObject[element].counter++;
54
+ }
55
+ };
56
+
57
+ parseArray(array1);
58
+ parseArray(array2);
59
+
60
+ for (key in tempObject)
61
+ if (tempObject[key].counter === 1)
62
+ result.push(tempObject[key].value);
63
+
64
+ return result;
65
+ }
66
+
67
+ /**
68
+ * replase string pattern in the string
69
+ * @param {String} needle
70
+ * @param {String} replacement
71
+ * @param {String} haystack
72
+ * @returns {String}
73
+ */
74
+ stringReplace(needle, replacement, haystack) {
75
+ return haystack.split(needle).join(replacement);
76
+ }
77
+
78
+ /**
79
+ * capitalise first letter in the string
80
+ * @param {String} str
81
+ * @returns {String}
82
+ */
83
+ capitaliseFirstLetter(str) {
84
+ return str.charAt(0).toUpperCase() + str.slice(1);
85
+ }
86
+
87
+ /**
88
+ * returns array without last element
89
+ * @param {Array} array
90
+ * @returns {Array}
91
+ */
92
+ initial(array) {
93
+ array.pop();
94
+ return array;
95
+ }
96
+
97
+ /**
98
+ * lead degree zero
99
+ * @param {Number} num
100
+ * @param {Number} count
101
+ * @returns {String}
102
+ */
103
+ ldgZero(num, count) {
104
+ let numZeropad = num + '';
105
+
106
+ while (numZeropad.length < count) {
107
+ numZeropad = "0" + numZeropad;
108
+ }
109
+
110
+ return numZeropad;
111
+ }
112
+
113
+ /**
114
+ * merge two arrays into new array
115
+ * @param {Array} a
116
+ * @param {Array} b
117
+ */
118
+ mergeArrays(a, b) {
119
+ let c = a.concat(b.filter(function (item) {
120
+ return a.indexOf(item) < 0;
121
+ }));
122
+
123
+ return c;
124
+ }
125
+
126
+ /**
127
+ * Swap key with value in object
128
+ * @param {Object} obj
129
+ * @returns {Object}
130
+ */
131
+ objectFlip(obj) {
132
+ const ret = {};
133
+
134
+ Object.keys(obj).forEach(key => {
135
+ ret[obj[key]] = key;
136
+ });
137
+
138
+ return ret;
139
+ }
140
+
141
+ /**
142
+ * recursive set value to object by key
143
+ * @param {String} key
144
+ * @param {Mixed} value
145
+ * @param {Object} object
146
+ * @returns {Boolean}
147
+ */
148
+ recursiveSet(key, value, object) {
149
+ key = (typeof key === 'string') ? key.split(".") : key;
150
+
151
+ let firstKey = key.shift();
152
+
153
+ if (key.length > 0) {
154
+ if (!object[firstKey])
155
+ object[firstKey] = {};
156
+
157
+ this.recursiveSet(key, value, object[firstKey]);
158
+ } else
159
+ object[firstKey] = value;
160
+
161
+ return true;
162
+ }
163
+
164
+ /**
165
+ * @param {Array} matrix
166
+ * @returns {Array}
167
+ */
168
+ rowsToCols(matrix) {
169
+ return Object.keys(matrix[0])
170
+ .map(colNumber => matrix.map(rowNumber => rowNumber[colNumber]));
171
+ }
172
+
173
+ /**
174
+ * recursive get value from object by key
175
+ * @param {String} key
176
+ * @param {Object} object
177
+ * @returns {Mixed}
178
+ */
179
+ recursiveGet(key, object, defaultResult) {
180
+ if (object === undefined)
181
+ return defaultResult;
182
+
183
+ key = (typeof key === 'string') ? key.split(".") : key;
184
+
185
+ for (let k of key) {
186
+ if (typeof object[k] === 'undefined')
187
+ return defaultResult;
188
+
189
+ object = object[k];
190
+ }
191
+
192
+ return object;
193
+ }
194
+
195
+ /**
196
+ * recursive delete value from object by key
197
+ * @param {String} key
198
+ * @param {Object} object
199
+ * @returns {Boolean}
200
+ */
201
+ recursiveDelete(key, obj) {
202
+ key = (typeof key === 'string') ? key.split(".") : key;
203
+
204
+ for (let k = 0; k < key.length; k++) {
205
+ let ok = key[k];
206
+
207
+ if (typeof obj[ok] === 'undefined')
208
+ return false;
209
+
210
+ if (k === (key.length - 1))
211
+ delete (obj[ok]);
212
+ else
213
+ obj = obj[ok];
214
+ }
215
+
216
+ return true;
217
+ }
218
+
219
+ /**
220
+ * tranpose matrix (rows to cols)
221
+ * @param {Array} matrix
222
+ * @returns {Array}
223
+ */
224
+ transpose(matrix) {
225
+ return Object.keys(matrix[0])
226
+ .map(colNumber => matrix
227
+ .map(rowNumber => rowNumber[colNumber]));
228
+ }
229
+
230
+ /**
231
+ * recursive merge two objects into one
232
+ * @param {Object} obj1
233
+ * @param {Object} obj2
234
+ * @param {Boolean} mergeInFirstFlag
235
+ * @returns {Object}
236
+ */
237
+ mergeObjectsRecursive(obj1, obj2, mergeInFirstFlag) {
238
+ let newObj = (mergeInFirstFlag) ? obj1 : this.objectClone(obj1);
239
+
240
+ for (let k in obj2) {
241
+ if (typeof obj2[k] === 'object' && typeof obj1[k] === 'object')
242
+ newObj[k] = this.mergeObjectsRecursive(obj1[k], obj2[k], mergeInFirstFlag);
243
+ else
244
+ newObj[k] = obj2[k];
245
+ }
246
+
247
+ return newObj;
248
+ }
249
+
250
+ /**
251
+ * rename objects key
252
+ * @param {Object} obj
253
+ * @param {String} oldKey
254
+ * @param {String} newKey
255
+ */
256
+ renameObjectsKey(obj, oldKey, newKey) {
257
+ if (oldKey !== newKey) {
258
+ Object.defineProperty(
259
+ obj, newKey,
260
+ Object.getOwnPropertyDescriptor(obj, oldKey)
261
+ );
262
+
263
+ delete obj[oldKey];
264
+ }
265
+ }
266
+
267
+ /**
268
+ * clone object
269
+ * @param {Object} obj
270
+ * @param {Number} recursiveCalls
271
+ * @returns {Object}
272
+ */
273
+ objectClone(obj, recursiveCalls) {
274
+ if (!obj || "object" !== typeof obj)
275
+ return obj;
276
+
277
+ if (typeof recursiveCalls === 'undefined')
278
+ recursiveCalls = 999;
279
+
280
+ let clone = "function" === typeof obj.pop ? [] : {}; //object o array
281
+ let prop, propValue;
282
+
283
+ if (obj.hasOwnProperty)
284
+ for (prop in obj) {
285
+ if (obj.hasOwnProperty(prop)) {
286
+ propValue = obj[prop];
287
+
288
+ if (prop === "imageSrc")
289
+ clone[prop] = propValue;
290
+ else if (propValue && "object" === typeof propValue)
291
+ clone[prop] = (recursiveCalls) ? this.objectClone(propValue, recursiveCalls - 1) : '[object Object]';
292
+ else
293
+ clone[prop] = propValue;
294
+ }
295
+ }
296
+
297
+ return clone;
298
+ }
299
+
300
+ /**
301
+ * get object size (keys length)
302
+ * @param {Object} obj
303
+ * @returns {Number}
304
+ */
305
+ getObjectSize(obj) {
306
+ return Object.keys(obj).length;
307
+ }
308
+
309
+ /**
310
+ * object apply
311
+ * @param {Object} fromObj
312
+ * @param {Object} toObj
313
+ * @returns {Object}
314
+ */
315
+ objectApply(fromObj, toObj, recursiveCalls = 999) {
316
+ if (!recursiveCalls)
317
+ return fromObj;
318
+
319
+ for (let k in toObj) {
320
+ let paramTo = toObj[k];
321
+
322
+ if (!fromObj[k]) {
323
+ fromObj[k] = paramTo;
324
+ } else if (typeof paramTo === "array" || typeof paramTo === "object") {
325
+ fromObj[k] = this.objectApply(fromObj[k], toObj[k], recursiveCalls - 1);
326
+ } else {
327
+ if (toObj[k] !== fromObj[k]) {
328
+ fromObj[k] = paramTo;
329
+ }
330
+ }
331
+ }
332
+
333
+ return fromObj;
334
+ }
335
+
336
+ /**
337
+ * check deep objects equal
338
+ * @param {Object} obj1
339
+ * @param {Object} obj2
340
+ * @returns {Boolean}
341
+ */
342
+ checkDeepEqual(obj1, obj2) {
343
+ return JSON.stringify(obj1) === JSON.stringify(obj2);
344
+ }
345
+
346
+ /**
347
+ * check objects equal
348
+ * @param {Object} obj1
349
+ * @param {Object} obj2
350
+ * @returns {Boolean}
351
+ */
352
+ checkEqual(obj1, obj2) {
353
+ const objSort = (o) => {
354
+ const sortedObj = {};
355
+ const keys = Object.keys(o);
356
+ keys.sort();
357
+
358
+ for (let index in keys) {
359
+ if (keys.hasOwnProperty(index)) {
360
+ let key = keys[index];
361
+ let value = o[key];
362
+
363
+ if (typeof o[key] === 'object')
364
+ value = objSort(value);
365
+
366
+ sortedObj[key] = value;
367
+ }
368
+ }
369
+
370
+ return sortedObj;
371
+ };
372
+
373
+ const o1s = objSort(obj1);
374
+ const o2s = objSort(obj2);
375
+
376
+ return this.checkDeepEqual(o1s, o2s);
377
+ }
378
+
379
+ /**
380
+ * check Arrays Partial Entry
381
+ * @param {Object} main
382
+ * @param {Object} partial
383
+ * @returns {Boolean}
384
+ */
385
+ checkArraysPartialEntry(main, partial) {
386
+ if (!main || !partial)
387
+ return false;
388
+
389
+ main = main.sort();
390
+ partial = partial.sort();
391
+
392
+ let kPartial = partial.length - 1;
393
+
394
+ for (let i = main.length - 1; i >= 0; i--) {
395
+ if (JSON.stringify(main[i]) === JSON.stringify(partial[kPartial]))
396
+ kPartial--;
397
+
398
+ if (kPartial === -1)
399
+ return true;
400
+ }
401
+
402
+ return false;
403
+ }
404
+
405
+ /**
406
+ * check is device mobile or tablet
407
+ * @returns {Boolean}
408
+ */
409
+ mobileAndTabletCheck() {
410
+ let check = false;
411
+ (function (a) {
412
+ if (/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino|android|ipad|playbook|silk/i.test(a) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0, 4)))
413
+ check = true;
414
+ })(navigator.userAgent || navigator.vendor || window.opera);
415
+
416
+ return check;
417
+ }
418
+
419
+ /**
420
+ * make objects property reactive
421
+ * @param {Object} targetObject
422
+ * @param {String} key
423
+ * @param {Function} callback
424
+ * @returns
425
+ */
426
+ reactive(targetObject, key, callback) {
427
+ let descriptor = Object.getOwnPropertyDescriptor(targetObject, key);
428
+ let targetObjectTemp = targetObject;
429
+
430
+ while (!descriptor && targetObjectTemp.__proto__) {
431
+ targetObjectTemp = targetObjectTemp.__proto__;
432
+ let descriptorTemp = Object.getOwnPropertyDescriptor(targetObjectTemp, key);
433
+
434
+ if (descriptorTemp && (descriptorTemp.value || descriptorTemp.set || descriptorTemp.get)) {
435
+ descriptor = descriptorTemp;
436
+ }
437
+ }
438
+
439
+ if (!descriptor) // bad descriptors and its IOS mobile
440
+ return false;
441
+
442
+ if (typeof descriptor.value !== 'undefined') {
443
+ let value = descriptor.value;
444
+ descriptor.get = function () { return value; };
445
+ descriptor.set = function (v) { value = v; };
446
+
447
+ delete descriptor.value;
448
+ delete descriptor.writable;
449
+ }
450
+
451
+ let setter = descriptor.set;
452
+
453
+ descriptor.set = function (v) {
454
+ if (setter)
455
+ setter.call(targetObject, v);
456
+
457
+ callback.call(targetObject, v);
458
+ };
459
+
460
+ Object.defineProperty(targetObject, key, descriptor);
461
+
462
+ return true;
463
+ }
464
+
465
+
466
+ /**
467
+ * calc length between two points
468
+ *
469
+ * @param {Object} point1
470
+ * @param {Object} point1
471
+ * @return {Number}
472
+ */
473
+ getLengthBy2Points(point1, point2) {
474
+ return Math.sqrt((point2.x - point1.x) * (point2.x - point1.x) +
475
+ (point2.y - point1.y) * (point2.y - point1.y));
476
+ }
477
+
478
+ /**
479
+ * calc angle between three points (in radians)
480
+ *
481
+ * @param {Object} point1
482
+ * @param {Object} point2
483
+ * @param {Object} point3
484
+ * @return {Number}
485
+ */
486
+ getAngleBy3Points(point1, point2, point3) {
487
+ let angle = 0;
488
+ const c = this.getLengthBy2Points(point1, point3);
489
+ const a = this.getLengthBy2Points(point1, point2);
490
+ const b = this.getLengthBy2Points(point2, point3);
491
+
492
+ if (a !== 0 && b !== 0) {
493
+ const cornerRcos = (a * a + b * b - c * c) / (2 * a * b);
494
+ angle = Math.acos(cornerRcos);
495
+ }
496
+
497
+ return angle;
498
+ }
499
+
500
+
501
+ /**
502
+ * get angle in radians from degrees
503
+ *
504
+ * @param {Number} angle
505
+ * @return {Number}
506
+ */
507
+ getRadian(angle) {
508
+ return (angle * this._arFactor);
509
+ }
510
+
511
+ /**
512
+ * get angle in degrees from radians
513
+ *
514
+ * @param {Number} radian
515
+ * @return {Number}
516
+ */
517
+ getAngle(radian) {
518
+ return (radian / this._arFactor);
519
+ }
520
+
521
+ /**
522
+ * arguments {oblect} (ClassInstance, functionName, param1, param2, ...)
523
+ * needs {Object} obj._logicBlocks;
524
+ * creates {Object} obj._logicBlocksInstances;
525
+ * @returns {Array} execution results
526
+ */
527
+ logicBlocksDo() {
528
+ const params = Array.prototype.slice.call(arguments);
529
+ const entity = params.shift();
530
+ const funcName = params.shift();
531
+
532
+ //if no instances we will create them
533
+ if (!entity._logicBlocksInstances) {
534
+ entity._logicBlocksInstances = {};
535
+
536
+ for (let k in entity._logicBlocks) {
537
+ const name = entity._logicBlocks[k];
538
+ const nameCap = this.capitaliseFirstLetter(name);
539
+ entity._logicBlocksInstances[name] = entity.getInstance(nameCap);
540
+ }
541
+ }
542
+
543
+ let results = [];
544
+ //game
545
+ for (let name in entity._logicBlocksInstances) {
546
+ if (entity._logicBlocksInstances[name][funcName]) {
547
+ const res = entity._logicBlocksInstances[name][funcName].apply(this, params);
548
+ results.push(res);
549
+ }
550
+ }
551
+
552
+ return results;
553
+ }
554
+ }
555
+
556
+ module.exports = LibHelper;