react-chessboard-ui 0.3.0 → 0.4.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.
- package/dist/index.js +34 -5
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +34 -5
- package/dist/index.modern.js.map +1 -1
- package/package.json +1 -1
package/dist/index.modern.js
CHANGED
|
@@ -1,6 +1,28 @@
|
|
|
1
1
|
import React, { useState, useEffect, useMemo, useCallback } from 'react';
|
|
2
2
|
import cn from 'classnames';
|
|
3
3
|
|
|
4
|
+
function _arrayLikeToArray(r, a) {
|
|
5
|
+
(null == a || a > r.length) && (a = r.length);
|
|
6
|
+
for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
|
|
7
|
+
return n;
|
|
8
|
+
}
|
|
9
|
+
function _createForOfIteratorHelperLoose(r, e) {
|
|
10
|
+
var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
|
|
11
|
+
if (t) return (t = t.call(r)).next.bind(t);
|
|
12
|
+
if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) {
|
|
13
|
+
t && (r = t);
|
|
14
|
+
var o = 0;
|
|
15
|
+
return function () {
|
|
16
|
+
return o >= r.length ? {
|
|
17
|
+
done: !0
|
|
18
|
+
} : {
|
|
19
|
+
done: !1,
|
|
20
|
+
value: r[o++]
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
25
|
+
}
|
|
4
26
|
function _extends() {
|
|
5
27
|
return _extends = Object.assign ? Object.assign.bind() : function (n) {
|
|
6
28
|
for (var e = 1; e < arguments.length; e++) {
|
|
@@ -10,6 +32,13 @@ function _extends() {
|
|
|
10
32
|
return n;
|
|
11
33
|
}, _extends.apply(null, arguments);
|
|
12
34
|
}
|
|
35
|
+
function _unsupportedIterableToArray(r, a) {
|
|
36
|
+
if (r) {
|
|
37
|
+
if ("string" == typeof r) return _arrayLikeToArray(r, a);
|
|
38
|
+
var t = {}.toString.call(r).slice(8, -1);
|
|
39
|
+
return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
13
42
|
|
|
14
43
|
var DIRECTIONS_D = ['top-right', 'bottom-right', 'bottom-left', 'top-left'];
|
|
15
44
|
var DIRECTIONS_VH = ['top', 'right', 'bottom', 'left'];
|
|
@@ -148,11 +177,11 @@ JSChessEngine.checkFigureIsLongRange = function (state, figurePos) {
|
|
|
148
177
|
};
|
|
149
178
|
JSChessEngine.getCountEnemys = function (state, figurePos, positions) {
|
|
150
179
|
var count = 0;
|
|
151
|
-
positions
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
}
|
|
180
|
+
for (var _iterator = _createForOfIteratorHelperLoose(positions), _step; !(_step = _iterator()).done;) {
|
|
181
|
+
var pos = _step.value;
|
|
182
|
+
if (JSChessEngine.checkEnemyKing(state, figurePos, pos)) break;
|
|
183
|
+
if (JSChessEngine.checkEnemy(state, figurePos, pos) && !JSChessEngine.checkEnemyKing(state, figurePos, pos)) count += 1;
|
|
184
|
+
}
|
|
156
185
|
return count;
|
|
157
186
|
};
|
|
158
187
|
JSChessEngine.getTeammateKingPos = function (state, figurePos) {
|