mahjong-seatings-rs-node 2.0.0 → 2.1.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/README.md +93 -45
- package/mahjong_seatings_rs.d.ts +9 -5
- package/mahjong_seatings_rs.js +316 -362
- package/mahjong_seatings_rs_bg.wasm +0 -0
- package/mahjong_seatings_rs_node.js +29 -3
- package/mahjong_seatings_rs_node.mjs +68 -0
- package/package.json +9 -2
package/README.md
CHANGED
|
@@ -9,59 +9,107 @@ wasm, node version.
|
|
|
9
9
|
- Invoke function as follows:
|
|
10
10
|
|
|
11
11
|
```typescript
|
|
12
|
-
const {
|
|
12
|
+
const {
|
|
13
|
+
make_seating_shuffled,
|
|
14
|
+
make_seating_interval,
|
|
15
|
+
make_seating_swiss,
|
|
16
|
+
} = require("mahjong-seatings-rs-node");
|
|
13
17
|
|
|
14
|
-
console.log(
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
[
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
18
|
+
console.log(
|
|
19
|
+
"Shuffled seating",
|
|
20
|
+
make_seating_shuffled({
|
|
21
|
+
playersMap: {
|
|
22
|
+
"1": 1500,
|
|
23
|
+
"2": 1500,
|
|
24
|
+
"3": 1500,
|
|
25
|
+
"4": 1500,
|
|
26
|
+
"5": 1500,
|
|
27
|
+
"6": 1500,
|
|
28
|
+
"7": 1500,
|
|
29
|
+
"8": 1500,
|
|
30
|
+
},
|
|
31
|
+
previousSeatings: [
|
|
32
|
+
[1, 2, 3, 4],
|
|
33
|
+
[5, 6, 7, 8],
|
|
34
|
+
],
|
|
35
|
+
groupsCount: 1,
|
|
36
|
+
randFactor: 1234455,
|
|
37
|
+
windShuffle: "random", // other options: 'balanced'
|
|
38
|
+
}),
|
|
39
|
+
);
|
|
32
40
|
|
|
33
|
-
console.log(
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
41
|
+
console.log(
|
|
42
|
+
"Interval seating",
|
|
43
|
+
make_seating_interval({
|
|
44
|
+
playersMap: {
|
|
45
|
+
"1": 1510,
|
|
46
|
+
"2": 1508,
|
|
47
|
+
"3": 1506,
|
|
48
|
+
"4": 1504,
|
|
49
|
+
"5": 1496,
|
|
50
|
+
"6": 1494,
|
|
51
|
+
"7": 1492,
|
|
52
|
+
"8": 1490,
|
|
53
|
+
},
|
|
54
|
+
previousSeatings: [
|
|
55
|
+
[1, 2, 3, 4],
|
|
56
|
+
[5, 6, 7, 8],
|
|
57
|
+
],
|
|
58
|
+
step: 2,
|
|
59
|
+
randFactor: 1234455,
|
|
60
|
+
windShuffle: "random", // other options: 'balanced'
|
|
61
|
+
}),
|
|
62
|
+
);
|
|
47
63
|
|
|
48
|
-
console.log(
|
|
64
|
+
console.log(
|
|
65
|
+
"Swiss seating",
|
|
66
|
+
make_seating_swiss({
|
|
67
|
+
playersMap: {
|
|
68
|
+
"1": 1510,
|
|
69
|
+
"2": 1508,
|
|
70
|
+
"3": 1506,
|
|
71
|
+
"4": 1504,
|
|
72
|
+
"5": 1496,
|
|
73
|
+
"6": 1494,
|
|
74
|
+
"7": 1492,
|
|
75
|
+
"8": 1490,
|
|
76
|
+
},
|
|
77
|
+
previousSeatings: [
|
|
78
|
+
[1, 2, 3, 4],
|
|
79
|
+
[5, 6, 7, 8],
|
|
80
|
+
],
|
|
81
|
+
randFactor: 1234455,
|
|
82
|
+
windShuffle: "random", // other options: 'balanced'
|
|
83
|
+
}),
|
|
84
|
+
);
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
Note that returned lists contain player ids and their rating. First four elements are first table, next four are second table, etc.## Riichi-rs-node
|
|
88
|
+
|
|
89
|
+
In case you already have the prepared seating and just want to randomize seatings by wind, you can use `update_wind_placing_only` function:
|
|
90
|
+
|
|
91
|
+
```javascript
|
|
92
|
+
const { update_wind_placing_only } = require("mahjong-seatings-rs-node");
|
|
93
|
+
|
|
94
|
+
const updatedSeatings = update_wind_placing_only({
|
|
49
95
|
playersMap: {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
96
|
+
1: 1510,
|
|
97
|
+
2: 1508,
|
|
98
|
+
3: 1506,
|
|
99
|
+
4: 1504,
|
|
100
|
+
5: 1496,
|
|
101
|
+
6: 1494,
|
|
102
|
+
7: 1492,
|
|
103
|
+
8: 1490,
|
|
58
104
|
},
|
|
59
105
|
previousSeatings: [
|
|
60
106
|
[1, 2, 3, 4],
|
|
61
107
|
[5, 6, 7, 8],
|
|
62
108
|
],
|
|
63
|
-
|
|
64
|
-
})
|
|
109
|
+
windShuffle: "random", // other options: 'balanced', 'prescripted'
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
console.log(updatedSeatings);
|
|
65
113
|
```
|
|
66
114
|
|
|
67
|
-
Note that
|
|
115
|
+
Note that `windShuffle: 'prescripted'` option just returns input array as is, considering it being already shuffled manually.
|
package/mahjong_seatings_rs.d.ts
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
export type PlayersMap = Record<string | number, number>;
|
|
2
2
|
export type Seating = Array<[number, number]>;
|
|
3
|
-
export
|
|
4
|
-
Random = 0,
|
|
5
|
-
Balanced = 1,
|
|
6
|
-
Prescripted = 2,
|
|
7
|
-
}
|
|
3
|
+
export type WindShuffle = "random" | "balanced" | "prescripted";
|
|
8
4
|
|
|
9
5
|
export type ShuffledSeatingInput = {
|
|
10
6
|
playersMap: PlayersMap;
|
|
@@ -29,6 +25,14 @@ export type SwissSeatingInput = {
|
|
|
29
25
|
windShuffle: WindShuffle;
|
|
30
26
|
};
|
|
31
27
|
|
|
28
|
+
export type UpdateWindPlacingInput = {
|
|
29
|
+
playersMap: PlayersMap;
|
|
30
|
+
previousSeatings: number[][];
|
|
31
|
+
randFactor: number;
|
|
32
|
+
windShuffle: WindShuffle;
|
|
33
|
+
};
|
|
34
|
+
|
|
32
35
|
export function make_seating_shuffled(val: ShuffledSeatingInput): Seating;
|
|
33
36
|
export function make_seating_interval(val: IntervalSeatingInput): Seating;
|
|
34
37
|
export function make_seating_swiss(val: SwissSeatingInput): Seating;
|
|
38
|
+
export function update_wind_placing_only(val: UpdateWindPlacingInput): Seating;
|
package/mahjong_seatings_rs.js
CHANGED
|
@@ -1,102 +1,254 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @param {any} val
|
|
3
|
+
* @returns {any}
|
|
4
|
+
*/
|
|
5
|
+
function make_seating_interval(val) {
|
|
6
|
+
const ret = wasm.make_seating_interval(val);
|
|
7
|
+
return ret;
|
|
8
|
+
}
|
|
9
|
+
exports.make_seating_interval = make_seating_interval;
|
|
1
10
|
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
let cachedUint8ArrayMemory0 = null;
|
|
10
|
-
|
|
11
|
-
function getUint8ArrayMemory0() {
|
|
12
|
-
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
13
|
-
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
14
|
-
}
|
|
15
|
-
return cachedUint8ArrayMemory0;
|
|
11
|
+
/**
|
|
12
|
+
* @param {any} val
|
|
13
|
+
* @returns {any}
|
|
14
|
+
*/
|
|
15
|
+
function make_seating_shuffled(val) {
|
|
16
|
+
const ret = wasm.make_seating_shuffled(val);
|
|
17
|
+
return ret;
|
|
16
18
|
}
|
|
19
|
+
exports.make_seating_shuffled = make_seating_shuffled;
|
|
17
20
|
|
|
18
|
-
|
|
21
|
+
/**
|
|
22
|
+
* @param {any} val
|
|
23
|
+
* @returns {any}
|
|
24
|
+
*/
|
|
25
|
+
function make_seating_swiss(val) {
|
|
26
|
+
const ret = wasm.make_seating_swiss(val);
|
|
27
|
+
return ret;
|
|
28
|
+
}
|
|
29
|
+
exports.make_seating_swiss = make_seating_swiss;
|
|
19
30
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
31
|
+
/**
|
|
32
|
+
* @param {any} val
|
|
33
|
+
* @returns {any}
|
|
34
|
+
*/
|
|
35
|
+
function update_wind_placing_only(val) {
|
|
36
|
+
const ret = wasm.update_wind_placing_only(val);
|
|
37
|
+
return ret;
|
|
23
38
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
39
|
+
exports.update_wind_placing_only = update_wind_placing_only;
|
|
40
|
+
function __wbg_get_imports() {
|
|
41
|
+
const import0 = {
|
|
42
|
+
__proto__: null,
|
|
43
|
+
__wbg_Error_bce6d499ff0a4aff: function(arg0, arg1) {
|
|
44
|
+
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
45
|
+
return ret;
|
|
46
|
+
},
|
|
47
|
+
__wbg_Number_b7972a139bfbfdf0: function(arg0) {
|
|
48
|
+
const ret = Number(arg0);
|
|
49
|
+
return ret;
|
|
50
|
+
},
|
|
51
|
+
__wbg_String_8564e559799eccda: function(arg0, arg1) {
|
|
52
|
+
const ret = String(arg1);
|
|
53
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
54
|
+
const len1 = WASM_VECTOR_LEN;
|
|
55
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
56
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
57
|
+
},
|
|
58
|
+
__wbg___wbindgen_bigint_get_as_i64_410e28c7b761ad83: function(arg0, arg1) {
|
|
59
|
+
const v = arg1;
|
|
60
|
+
const ret = typeof(v) === 'bigint' ? v : undefined;
|
|
61
|
+
getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true);
|
|
62
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
63
|
+
},
|
|
64
|
+
__wbg___wbindgen_boolean_get_2304fb8c853028c8: function(arg0) {
|
|
65
|
+
const v = arg0;
|
|
66
|
+
const ret = typeof(v) === 'boolean' ? v : undefined;
|
|
67
|
+
return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
|
|
68
|
+
},
|
|
69
|
+
__wbg___wbindgen_debug_string_edece8177ad01481: function(arg0, arg1) {
|
|
70
|
+
const ret = debugString(arg1);
|
|
71
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
72
|
+
const len1 = WASM_VECTOR_LEN;
|
|
73
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
74
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
75
|
+
},
|
|
76
|
+
__wbg___wbindgen_in_07056af4f902c445: function(arg0, arg1) {
|
|
77
|
+
const ret = arg0 in arg1;
|
|
78
|
+
return ret;
|
|
79
|
+
},
|
|
80
|
+
__wbg___wbindgen_is_bigint_aeae3893f30ed54e: function(arg0) {
|
|
81
|
+
const ret = typeof(arg0) === 'bigint';
|
|
82
|
+
return ret;
|
|
83
|
+
},
|
|
84
|
+
__wbg___wbindgen_is_function_5cd60d5cf78b4eef: function(arg0) {
|
|
85
|
+
const ret = typeof(arg0) === 'function';
|
|
86
|
+
return ret;
|
|
87
|
+
},
|
|
88
|
+
__wbg___wbindgen_is_object_b4593df85baada48: function(arg0) {
|
|
89
|
+
const val = arg0;
|
|
90
|
+
const ret = typeof(val) === 'object' && val !== null;
|
|
91
|
+
return ret;
|
|
92
|
+
},
|
|
93
|
+
__wbg___wbindgen_is_undefined_35bb9f4c7fd651d5: function(arg0) {
|
|
94
|
+
const ret = arg0 === undefined;
|
|
95
|
+
return ret;
|
|
96
|
+
},
|
|
97
|
+
__wbg___wbindgen_jsval_eq_c0ed08b3e0f393b9: function(arg0, arg1) {
|
|
98
|
+
const ret = arg0 === arg1;
|
|
99
|
+
return ret;
|
|
100
|
+
},
|
|
101
|
+
__wbg___wbindgen_jsval_loose_eq_0ad77b7717db155c: function(arg0, arg1) {
|
|
102
|
+
const ret = arg0 == arg1;
|
|
103
|
+
return ret;
|
|
104
|
+
},
|
|
105
|
+
__wbg___wbindgen_number_get_f73a1244370fcc2c: function(arg0, arg1) {
|
|
106
|
+
const obj = arg1;
|
|
107
|
+
const ret = typeof(obj) === 'number' ? obj : undefined;
|
|
108
|
+
getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
|
|
109
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
110
|
+
},
|
|
111
|
+
__wbg___wbindgen_string_get_d109740c0d18f4d7: function(arg0, arg1) {
|
|
112
|
+
const obj = arg1;
|
|
113
|
+
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
114
|
+
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
115
|
+
var len1 = WASM_VECTOR_LEN;
|
|
116
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
117
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
118
|
+
},
|
|
119
|
+
__wbg___wbindgen_throw_9c31b086c2b26051: function(arg0, arg1) {
|
|
120
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
121
|
+
},
|
|
122
|
+
__wbg_call_13665d9f14390edc: function() { return handleError(function (arg0, arg1) {
|
|
123
|
+
const ret = arg0.call(arg1);
|
|
124
|
+
return ret;
|
|
125
|
+
}, arguments); },
|
|
126
|
+
__wbg_done_54b8da57023b7ed2: function(arg0) {
|
|
127
|
+
const ret = arg0.done;
|
|
128
|
+
return ret;
|
|
129
|
+
},
|
|
130
|
+
__wbg_get_3e9a707ab7d352eb: function() { return handleError(function (arg0, arg1) {
|
|
131
|
+
const ret = Reflect.get(arg0, arg1);
|
|
132
|
+
return ret;
|
|
133
|
+
}, arguments); },
|
|
134
|
+
__wbg_get_unchecked_1dfe6d05ad91d9b7: function(arg0, arg1) {
|
|
135
|
+
const ret = arg0[arg1 >>> 0];
|
|
136
|
+
return ret;
|
|
137
|
+
},
|
|
138
|
+
__wbg_get_with_ref_key_6412cf3094599694: function(arg0, arg1) {
|
|
139
|
+
const ret = arg0[arg1];
|
|
140
|
+
return ret;
|
|
141
|
+
},
|
|
142
|
+
__wbg_instanceof_ArrayBuffer_53db37b06f6b9afe: function(arg0) {
|
|
143
|
+
let result;
|
|
144
|
+
try {
|
|
145
|
+
result = arg0 instanceof ArrayBuffer;
|
|
146
|
+
} catch (_) {
|
|
147
|
+
result = false;
|
|
148
|
+
}
|
|
149
|
+
const ret = result;
|
|
150
|
+
return ret;
|
|
151
|
+
},
|
|
152
|
+
__wbg_instanceof_Uint8Array_abd07d4bd221d50b: function(arg0) {
|
|
153
|
+
let result;
|
|
154
|
+
try {
|
|
155
|
+
result = arg0 instanceof Uint8Array;
|
|
156
|
+
} catch (_) {
|
|
157
|
+
result = false;
|
|
158
|
+
}
|
|
159
|
+
const ret = result;
|
|
160
|
+
return ret;
|
|
161
|
+
},
|
|
162
|
+
__wbg_isArray_94898ed3aad6947b: function(arg0) {
|
|
163
|
+
const ret = Array.isArray(arg0);
|
|
164
|
+
return ret;
|
|
165
|
+
},
|
|
166
|
+
__wbg_isSafeInteger_01e964d144ad3a55: function(arg0) {
|
|
167
|
+
const ret = Number.isSafeInteger(arg0);
|
|
168
|
+
return ret;
|
|
169
|
+
},
|
|
170
|
+
__wbg_iterator_1441b47f341dc34f: function() {
|
|
171
|
+
const ret = Symbol.iterator;
|
|
172
|
+
return ret;
|
|
173
|
+
},
|
|
174
|
+
__wbg_length_2591a0f4f659a55c: function(arg0) {
|
|
175
|
+
const ret = arg0.length;
|
|
176
|
+
return ret;
|
|
177
|
+
},
|
|
178
|
+
__wbg_length_56fcd3e2b7e0299d: function(arg0) {
|
|
179
|
+
const ret = arg0.length;
|
|
180
|
+
return ret;
|
|
181
|
+
},
|
|
182
|
+
__wbg_new_02d162bc6cf02f60: function() {
|
|
183
|
+
const ret = new Object();
|
|
184
|
+
return ret;
|
|
185
|
+
},
|
|
186
|
+
__wbg_new_310879b66b6e95e1: function() {
|
|
187
|
+
const ret = new Array();
|
|
188
|
+
return ret;
|
|
189
|
+
},
|
|
190
|
+
__wbg_new_7ddec6de44ff8f5d: function(arg0) {
|
|
191
|
+
const ret = new Uint8Array(arg0);
|
|
192
|
+
return ret;
|
|
193
|
+
},
|
|
194
|
+
__wbg_next_2a4e19f4f5083b0f: function(arg0) {
|
|
195
|
+
const ret = arg0.next;
|
|
196
|
+
return ret;
|
|
197
|
+
},
|
|
198
|
+
__wbg_next_6429a146bf756f93: function() { return handleError(function (arg0) {
|
|
199
|
+
const ret = arg0.next();
|
|
200
|
+
return ret;
|
|
201
|
+
}, arguments); },
|
|
202
|
+
__wbg_prototypesetcall_5f9bdc8d75e07276: function(arg0, arg1, arg2) {
|
|
203
|
+
Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
|
|
204
|
+
},
|
|
205
|
+
__wbg_set_6be42768c690e380: function(arg0, arg1, arg2) {
|
|
206
|
+
arg0[arg1] = arg2;
|
|
207
|
+
},
|
|
208
|
+
__wbg_set_78ea6a19f4818587: function(arg0, arg1, arg2) {
|
|
209
|
+
arg0[arg1 >>> 0] = arg2;
|
|
210
|
+
},
|
|
211
|
+
__wbg_value_9cc0518af87a489c: function(arg0) {
|
|
212
|
+
const ret = arg0.value;
|
|
213
|
+
return ret;
|
|
214
|
+
},
|
|
215
|
+
__wbindgen_cast_0000000000000001: function(arg0) {
|
|
216
|
+
// Cast intrinsic for `F64 -> Externref`.
|
|
217
|
+
const ret = arg0;
|
|
218
|
+
return ret;
|
|
219
|
+
},
|
|
220
|
+
__wbindgen_cast_0000000000000002: function(arg0, arg1) {
|
|
221
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
222
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
223
|
+
return ret;
|
|
224
|
+
},
|
|
225
|
+
__wbindgen_cast_0000000000000003: function(arg0) {
|
|
226
|
+
// Cast intrinsic for `U64 -> Externref`.
|
|
227
|
+
const ret = BigInt.asUintN(64, arg0);
|
|
228
|
+
return ret;
|
|
229
|
+
},
|
|
230
|
+
__wbindgen_init_externref_table: function() {
|
|
231
|
+
const table = wasm.__wbindgen_externrefs;
|
|
232
|
+
const offset = table.grow(4);
|
|
233
|
+
table.set(0, undefined);
|
|
234
|
+
table.set(offset + 0, undefined);
|
|
235
|
+
table.set(offset + 1, null);
|
|
236
|
+
table.set(offset + 2, true);
|
|
237
|
+
table.set(offset + 3, false);
|
|
238
|
+
},
|
|
239
|
+
};
|
|
27
240
|
return {
|
|
28
|
-
|
|
29
|
-
|
|
241
|
+
__proto__: null,
|
|
242
|
+
"./mahjong_seatings_rs_bg.js": import0,
|
|
30
243
|
};
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
function passStringToWasm0(arg, malloc, realloc) {
|
|
34
|
-
|
|
35
|
-
if (realloc === undefined) {
|
|
36
|
-
const buf = cachedTextEncoder.encode(arg);
|
|
37
|
-
const ptr = malloc(buf.length, 1) >>> 0;
|
|
38
|
-
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
39
|
-
WASM_VECTOR_LEN = buf.length;
|
|
40
|
-
return ptr;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
let len = arg.length;
|
|
44
|
-
let ptr = malloc(len, 1) >>> 0;
|
|
45
|
-
|
|
46
|
-
const mem = getUint8ArrayMemory0();
|
|
47
|
-
|
|
48
|
-
let offset = 0;
|
|
49
|
-
|
|
50
|
-
for (; offset < len; offset++) {
|
|
51
|
-
const code = arg.charCodeAt(offset);
|
|
52
|
-
if (code > 0x7F) break;
|
|
53
|
-
mem[ptr + offset] = code;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
if (offset !== len) {
|
|
57
|
-
if (offset !== 0) {
|
|
58
|
-
arg = arg.slice(offset);
|
|
59
|
-
}
|
|
60
|
-
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
61
|
-
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
62
|
-
const ret = encodeString(arg, view);
|
|
63
|
-
|
|
64
|
-
offset += ret.written;
|
|
65
|
-
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
WASM_VECTOR_LEN = offset;
|
|
69
|
-
return ptr;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
let cachedDataViewMemory0 = null;
|
|
73
|
-
|
|
74
|
-
function getDataViewMemory0() {
|
|
75
|
-
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
76
|
-
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
77
|
-
}
|
|
78
|
-
return cachedDataViewMemory0;
|
|
79
244
|
}
|
|
80
245
|
|
|
81
246
|
function addToExternrefTable0(obj) {
|
|
82
247
|
const idx = wasm.__externref_table_alloc();
|
|
83
|
-
wasm.
|
|
248
|
+
wasm.__wbindgen_externrefs.set(idx, obj);
|
|
84
249
|
return idx;
|
|
85
250
|
}
|
|
86
251
|
|
|
87
|
-
function handleError(f, args) {
|
|
88
|
-
try {
|
|
89
|
-
return f.apply(this, args);
|
|
90
|
-
} catch (e) {
|
|
91
|
-
const idx = addToExternrefTable0(e);
|
|
92
|
-
wasm.__wbindgen_exn_store(idx);
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
function isLikeNone(x) {
|
|
97
|
-
return x === undefined || x === null;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
252
|
function debugString(val) {
|
|
101
253
|
// primitive types
|
|
102
254
|
const type = typeof val;
|
|
@@ -162,303 +314,105 @@ function debugString(val) {
|
|
|
162
314
|
return className;
|
|
163
315
|
}
|
|
164
316
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
cachedTextDecoder.decode();
|
|
168
|
-
|
|
169
|
-
function getStringFromWasm0(ptr, len) {
|
|
317
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
170
318
|
ptr = ptr >>> 0;
|
|
171
|
-
return
|
|
319
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
172
320
|
}
|
|
173
|
-
/**
|
|
174
|
-
* @param {any} val
|
|
175
|
-
* @returns {any}
|
|
176
|
-
*/
|
|
177
|
-
module.exports.make_seating_shuffled = function(val) {
|
|
178
|
-
const ret = wasm.make_seating_shuffled(val);
|
|
179
|
-
return ret;
|
|
180
|
-
};
|
|
181
|
-
|
|
182
|
-
/**
|
|
183
|
-
* @param {any} val
|
|
184
|
-
* @returns {any}
|
|
185
|
-
*/
|
|
186
|
-
module.exports.make_seating_swiss = function(val) {
|
|
187
|
-
const ret = wasm.make_seating_swiss(val);
|
|
188
|
-
return ret;
|
|
189
|
-
};
|
|
190
|
-
|
|
191
|
-
/**
|
|
192
|
-
* @param {any} val
|
|
193
|
-
* @returns {any}
|
|
194
|
-
*/
|
|
195
|
-
module.exports.make_seating_interval = function(val) {
|
|
196
|
-
const ret = wasm.make_seating_interval(val);
|
|
197
|
-
return ret;
|
|
198
|
-
};
|
|
199
|
-
|
|
200
|
-
module.exports.__wbg_String_8f0eb39a4a4c2f66 = function(arg0, arg1) {
|
|
201
|
-
const ret = String(arg1);
|
|
202
|
-
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
203
|
-
const len1 = WASM_VECTOR_LEN;
|
|
204
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
205
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
206
|
-
};
|
|
207
|
-
|
|
208
|
-
module.exports.__wbg_buffer_609cc3eee51ed158 = function(arg0) {
|
|
209
|
-
const ret = arg0.buffer;
|
|
210
|
-
return ret;
|
|
211
|
-
};
|
|
212
|
-
|
|
213
|
-
module.exports.__wbg_call_672a4d21634d4a24 = function() { return handleError(function (arg0, arg1) {
|
|
214
|
-
const ret = arg0.call(arg1);
|
|
215
|
-
return ret;
|
|
216
|
-
}, arguments) };
|
|
217
|
-
|
|
218
|
-
module.exports.__wbg_done_769e5ede4b31c67b = function(arg0) {
|
|
219
|
-
const ret = arg0.done;
|
|
220
|
-
return ret;
|
|
221
|
-
};
|
|
222
|
-
|
|
223
|
-
module.exports.__wbg_entries_3265d4158b33e5dc = function(arg0) {
|
|
224
|
-
const ret = Object.entries(arg0);
|
|
225
|
-
return ret;
|
|
226
|
-
};
|
|
227
|
-
|
|
228
|
-
module.exports.__wbg_get_67b2ba62fc30de12 = function() { return handleError(function (arg0, arg1) {
|
|
229
|
-
const ret = Reflect.get(arg0, arg1);
|
|
230
|
-
return ret;
|
|
231
|
-
}, arguments) };
|
|
232
321
|
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
322
|
+
let cachedDataViewMemory0 = null;
|
|
323
|
+
function getDataViewMemory0() {
|
|
324
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
325
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
326
|
+
}
|
|
327
|
+
return cachedDataViewMemory0;
|
|
328
|
+
}
|
|
237
329
|
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
};
|
|
330
|
+
function getStringFromWasm0(ptr, len) {
|
|
331
|
+
return decodeText(ptr >>> 0, len);
|
|
332
|
+
}
|
|
242
333
|
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
} catch (_) {
|
|
248
|
-
result = false;
|
|
334
|
+
let cachedUint8ArrayMemory0 = null;
|
|
335
|
+
function getUint8ArrayMemory0() {
|
|
336
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
337
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
249
338
|
}
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
};
|
|
339
|
+
return cachedUint8ArrayMemory0;
|
|
340
|
+
}
|
|
253
341
|
|
|
254
|
-
|
|
255
|
-
let result;
|
|
342
|
+
function handleError(f, args) {
|
|
256
343
|
try {
|
|
257
|
-
|
|
258
|
-
} catch (
|
|
259
|
-
|
|
344
|
+
return f.apply(this, args);
|
|
345
|
+
} catch (e) {
|
|
346
|
+
const idx = addToExternrefTable0(e);
|
|
347
|
+
wasm.__wbindgen_exn_store(idx);
|
|
260
348
|
}
|
|
261
|
-
|
|
262
|
-
return ret;
|
|
263
|
-
};
|
|
264
|
-
|
|
265
|
-
module.exports.__wbg_isArray_a1eab7e0d067391b = function(arg0) {
|
|
266
|
-
const ret = Array.isArray(arg0);
|
|
267
|
-
return ret;
|
|
268
|
-
};
|
|
269
|
-
|
|
270
|
-
module.exports.__wbg_isSafeInteger_343e2beeeece1bb0 = function(arg0) {
|
|
271
|
-
const ret = Number.isSafeInteger(arg0);
|
|
272
|
-
return ret;
|
|
273
|
-
};
|
|
274
|
-
|
|
275
|
-
module.exports.__wbg_iterator_9a24c88df860dc65 = function() {
|
|
276
|
-
const ret = Symbol.iterator;
|
|
277
|
-
return ret;
|
|
278
|
-
};
|
|
279
|
-
|
|
280
|
-
module.exports.__wbg_length_a446193dc22c12f8 = function(arg0) {
|
|
281
|
-
const ret = arg0.length;
|
|
282
|
-
return ret;
|
|
283
|
-
};
|
|
284
|
-
|
|
285
|
-
module.exports.__wbg_length_e2d2a49132c1b256 = function(arg0) {
|
|
286
|
-
const ret = arg0.length;
|
|
287
|
-
return ret;
|
|
288
|
-
};
|
|
289
|
-
|
|
290
|
-
module.exports.__wbg_new_405e22f390576ce2 = function() {
|
|
291
|
-
const ret = new Object();
|
|
292
|
-
return ret;
|
|
293
|
-
};
|
|
294
|
-
|
|
295
|
-
module.exports.__wbg_new_78feb108b6472713 = function() {
|
|
296
|
-
const ret = new Array();
|
|
297
|
-
return ret;
|
|
298
|
-
};
|
|
299
|
-
|
|
300
|
-
module.exports.__wbg_new_a12002a7f91c75be = function(arg0) {
|
|
301
|
-
const ret = new Uint8Array(arg0);
|
|
302
|
-
return ret;
|
|
303
|
-
};
|
|
304
|
-
|
|
305
|
-
module.exports.__wbg_next_25feadfc0913fea9 = function(arg0) {
|
|
306
|
-
const ret = arg0.next;
|
|
307
|
-
return ret;
|
|
308
|
-
};
|
|
309
|
-
|
|
310
|
-
module.exports.__wbg_next_6574e1a8a62d1055 = function() { return handleError(function (arg0) {
|
|
311
|
-
const ret = arg0.next();
|
|
312
|
-
return ret;
|
|
313
|
-
}, arguments) };
|
|
314
|
-
|
|
315
|
-
module.exports.__wbg_set_37837023f3d740e8 = function(arg0, arg1, arg2) {
|
|
316
|
-
arg0[arg1 >>> 0] = arg2;
|
|
317
|
-
};
|
|
318
|
-
|
|
319
|
-
module.exports.__wbg_set_3f1d0b984ed272ed = function(arg0, arg1, arg2) {
|
|
320
|
-
arg0[arg1] = arg2;
|
|
321
|
-
};
|
|
322
|
-
|
|
323
|
-
module.exports.__wbg_set_65595bdd868b3009 = function(arg0, arg1, arg2) {
|
|
324
|
-
arg0.set(arg1, arg2 >>> 0);
|
|
325
|
-
};
|
|
326
|
-
|
|
327
|
-
module.exports.__wbg_value_cd1ffa7b1ab794f1 = function(arg0) {
|
|
328
|
-
const ret = arg0.value;
|
|
329
|
-
return ret;
|
|
330
|
-
};
|
|
331
|
-
|
|
332
|
-
module.exports.__wbindgen_as_number = function(arg0) {
|
|
333
|
-
const ret = +arg0;
|
|
334
|
-
return ret;
|
|
335
|
-
};
|
|
336
|
-
|
|
337
|
-
module.exports.__wbindgen_bigint_from_u64 = function(arg0) {
|
|
338
|
-
const ret = BigInt.asUintN(64, arg0);
|
|
339
|
-
return ret;
|
|
340
|
-
};
|
|
341
|
-
|
|
342
|
-
module.exports.__wbindgen_bigint_get_as_i64 = function(arg0, arg1) {
|
|
343
|
-
const v = arg1;
|
|
344
|
-
const ret = typeof(v) === 'bigint' ? v : undefined;
|
|
345
|
-
getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true);
|
|
346
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
347
|
-
};
|
|
348
|
-
|
|
349
|
-
module.exports.__wbindgen_boolean_get = function(arg0) {
|
|
350
|
-
const v = arg0;
|
|
351
|
-
const ret = typeof(v) === 'boolean' ? (v ? 1 : 0) : 2;
|
|
352
|
-
return ret;
|
|
353
|
-
};
|
|
354
|
-
|
|
355
|
-
module.exports.__wbindgen_debug_string = function(arg0, arg1) {
|
|
356
|
-
const ret = debugString(arg1);
|
|
357
|
-
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
358
|
-
const len1 = WASM_VECTOR_LEN;
|
|
359
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
360
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
361
|
-
};
|
|
362
|
-
|
|
363
|
-
module.exports.__wbindgen_error_new = function(arg0, arg1) {
|
|
364
|
-
const ret = new Error(getStringFromWasm0(arg0, arg1));
|
|
365
|
-
return ret;
|
|
366
|
-
};
|
|
367
|
-
|
|
368
|
-
module.exports.__wbindgen_in = function(arg0, arg1) {
|
|
369
|
-
const ret = arg0 in arg1;
|
|
370
|
-
return ret;
|
|
371
|
-
};
|
|
372
|
-
|
|
373
|
-
module.exports.__wbindgen_init_externref_table = function() {
|
|
374
|
-
const table = wasm.__wbindgen_export_4;
|
|
375
|
-
const offset = table.grow(4);
|
|
376
|
-
table.set(0, undefined);
|
|
377
|
-
table.set(offset + 0, undefined);
|
|
378
|
-
table.set(offset + 1, null);
|
|
379
|
-
table.set(offset + 2, true);
|
|
380
|
-
table.set(offset + 3, false);
|
|
381
|
-
;
|
|
382
|
-
};
|
|
383
|
-
|
|
384
|
-
module.exports.__wbindgen_is_bigint = function(arg0) {
|
|
385
|
-
const ret = typeof(arg0) === 'bigint';
|
|
386
|
-
return ret;
|
|
387
|
-
};
|
|
388
|
-
|
|
389
|
-
module.exports.__wbindgen_is_function = function(arg0) {
|
|
390
|
-
const ret = typeof(arg0) === 'function';
|
|
391
|
-
return ret;
|
|
392
|
-
};
|
|
393
|
-
|
|
394
|
-
module.exports.__wbindgen_is_object = function(arg0) {
|
|
395
|
-
const val = arg0;
|
|
396
|
-
const ret = typeof(val) === 'object' && val !== null;
|
|
397
|
-
return ret;
|
|
398
|
-
};
|
|
349
|
+
}
|
|
399
350
|
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
};
|
|
351
|
+
function isLikeNone(x) {
|
|
352
|
+
return x === undefined || x === null;
|
|
353
|
+
}
|
|
404
354
|
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
355
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
356
|
+
if (realloc === undefined) {
|
|
357
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
358
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
359
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
360
|
+
WASM_VECTOR_LEN = buf.length;
|
|
361
|
+
return ptr;
|
|
362
|
+
}
|
|
409
363
|
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
return ret;
|
|
413
|
-
};
|
|
364
|
+
let len = arg.length;
|
|
365
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
414
366
|
|
|
415
|
-
|
|
416
|
-
const ret = arg0 == arg1;
|
|
417
|
-
return ret;
|
|
418
|
-
};
|
|
367
|
+
const mem = getUint8ArrayMemory0();
|
|
419
368
|
|
|
420
|
-
|
|
421
|
-
const ret = wasm.memory;
|
|
422
|
-
return ret;
|
|
423
|
-
};
|
|
369
|
+
let offset = 0;
|
|
424
370
|
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
371
|
+
for (; offset < len; offset++) {
|
|
372
|
+
const code = arg.charCodeAt(offset);
|
|
373
|
+
if (code > 0x7F) break;
|
|
374
|
+
mem[ptr + offset] = code;
|
|
375
|
+
}
|
|
376
|
+
if (offset !== len) {
|
|
377
|
+
if (offset !== 0) {
|
|
378
|
+
arg = arg.slice(offset);
|
|
379
|
+
}
|
|
380
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
381
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
382
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
431
383
|
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
};
|
|
384
|
+
offset += ret.written;
|
|
385
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
386
|
+
}
|
|
436
387
|
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
441
|
-
var len1 = WASM_VECTOR_LEN;
|
|
442
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
443
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
444
|
-
};
|
|
388
|
+
WASM_VECTOR_LEN = offset;
|
|
389
|
+
return ptr;
|
|
390
|
+
}
|
|
445
391
|
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
392
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
393
|
+
cachedTextDecoder.decode();
|
|
394
|
+
function decodeText(ptr, len) {
|
|
395
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
396
|
+
}
|
|
450
397
|
|
|
451
|
-
|
|
452
|
-
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
453
|
-
};
|
|
398
|
+
const cachedTextEncoder = new TextEncoder();
|
|
454
399
|
|
|
455
|
-
|
|
456
|
-
|
|
400
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
401
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
402
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
403
|
+
view.set(buf);
|
|
404
|
+
return {
|
|
405
|
+
read: arg.length,
|
|
406
|
+
written: buf.length
|
|
407
|
+
};
|
|
408
|
+
};
|
|
409
|
+
}
|
|
457
410
|
|
|
458
|
-
|
|
459
|
-
const wasmInstance = new WebAssembly.Instance(wasmModule, imports);
|
|
460
|
-
wasm = wasmInstance.exports;
|
|
461
|
-
module.exports.__wasm = wasm;
|
|
411
|
+
let WASM_VECTOR_LEN = 0;
|
|
462
412
|
|
|
413
|
+
const wasmPath = `${__dirname}/mahjong_seatings_rs_bg.wasm`;
|
|
414
|
+
const wasmBytes = require('fs').readFileSync(wasmPath);
|
|
415
|
+
const wasmModule = new WebAssembly.Module(wasmBytes);
|
|
416
|
+
let wasmInstance = new WebAssembly.Instance(wasmModule, __wbg_get_imports());
|
|
417
|
+
let wasm = wasmInstance.exports;
|
|
463
418
|
wasm.__wbindgen_start();
|
|
464
|
-
|
|
Binary file
|
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
const orig = require("./mahjong_seatings_rs.js");
|
|
2
2
|
|
|
3
|
+
function _toWindShuffle(val) {
|
|
4
|
+
switch (val) {
|
|
5
|
+
case "random":
|
|
6
|
+
return 0;
|
|
7
|
+
case "balanced":
|
|
8
|
+
return 1;
|
|
9
|
+
case "prescripted":
|
|
10
|
+
return 2;
|
|
11
|
+
default:
|
|
12
|
+
return 0;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
3
16
|
module.exports = {
|
|
4
17
|
make_seating_shuffled: function (val) {
|
|
5
18
|
const input = {
|
|
@@ -10,7 +23,7 @@ module.exports = {
|
|
|
10
23
|
previous_seatings: val.previousSeatings,
|
|
11
24
|
groups_count: val.groupsCount,
|
|
12
25
|
rand_factor: val.randFactor,
|
|
13
|
-
wind_shuffle: val.windShuffle,
|
|
26
|
+
wind_shuffle: _toWindShuffle(val.windShuffle),
|
|
14
27
|
};
|
|
15
28
|
return orig.make_seating_shuffled(input).result;
|
|
16
29
|
},
|
|
@@ -24,7 +37,7 @@ module.exports = {
|
|
|
24
37
|
previous_seatings: val.previousSeatings,
|
|
25
38
|
step: val.step,
|
|
26
39
|
rand_factor: val.randFactor,
|
|
27
|
-
wind_shuffle: val.windShuffle,
|
|
40
|
+
wind_shuffle: _toWindShuffle(val.windShuffle),
|
|
28
41
|
};
|
|
29
42
|
return orig.make_seating_interval(input).result;
|
|
30
43
|
},
|
|
@@ -37,8 +50,21 @@ module.exports = {
|
|
|
37
50
|
]),
|
|
38
51
|
previous_seatings: val.previousSeatings,
|
|
39
52
|
rand_factor: val.randFactor,
|
|
40
|
-
wind_shuffle: val.windShuffle,
|
|
53
|
+
wind_shuffle: _toWindShuffle(val.windShuffle),
|
|
41
54
|
};
|
|
42
55
|
return orig.make_seating_swiss(input).result;
|
|
43
56
|
},
|
|
57
|
+
|
|
58
|
+
update_wind_placing_only: function (val) {
|
|
59
|
+
const input = {
|
|
60
|
+
players_map: Object.entries(val.playersMap).map(([k, v]) => [
|
|
61
|
+
parseInt(k.toString(), 10),
|
|
62
|
+
v,
|
|
63
|
+
]),
|
|
64
|
+
previous_seatings: val.previousSeatings,
|
|
65
|
+
rand_factor: val.randFactor,
|
|
66
|
+
wind_shuffle: _toWindShuffle(val.windShuffle),
|
|
67
|
+
};
|
|
68
|
+
return orig.update_wind_placing_only(input).result;
|
|
69
|
+
},
|
|
44
70
|
};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import orig from "./mahjong_seatings_rs.js";
|
|
2
|
+
|
|
3
|
+
function _toWindShuffle(val) {
|
|
4
|
+
switch (val) {
|
|
5
|
+
case "random":
|
|
6
|
+
return 0;
|
|
7
|
+
case "balanced":
|
|
8
|
+
return 1;
|
|
9
|
+
case "prescripted":
|
|
10
|
+
return 2;
|
|
11
|
+
default:
|
|
12
|
+
return 0;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function make_seating_shuffled(val) {
|
|
17
|
+
const input = {
|
|
18
|
+
players_map: Object.entries(val.playersMap).map(([k, v]) => [
|
|
19
|
+
parseInt(k.toString(), 10),
|
|
20
|
+
v,
|
|
21
|
+
]),
|
|
22
|
+
previous_seatings: val.previousSeatings,
|
|
23
|
+
groups_count: val.groupsCount,
|
|
24
|
+
rand_factor: val.randFactor,
|
|
25
|
+
wind_shuffle: _toWindShuffle(val.windShuffle),
|
|
26
|
+
};
|
|
27
|
+
return orig.make_seating_shuffled(input).result;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function make_seating_interval(val) {
|
|
31
|
+
const input = {
|
|
32
|
+
players_map: Object.entries(val.playersMap).map(([k, v]) => [
|
|
33
|
+
parseInt(k.toString(), 10),
|
|
34
|
+
v,
|
|
35
|
+
]),
|
|
36
|
+
previous_seatings: val.previousSeatings,
|
|
37
|
+
step: val.step,
|
|
38
|
+
rand_factor: val.randFactor,
|
|
39
|
+
wind_shuffle: _toWindShuffle(val.windShuffle),
|
|
40
|
+
};
|
|
41
|
+
return orig.make_seating_interval(input).result;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export function make_seating_swiss(val) {
|
|
45
|
+
const input = {
|
|
46
|
+
players_map: Object.entries(val.playersMap).map(([k, v]) => [
|
|
47
|
+
parseInt(k.toString(), 10),
|
|
48
|
+
v,
|
|
49
|
+
]),
|
|
50
|
+
previous_seatings: val.previousSeatings,
|
|
51
|
+
rand_factor: val.randFactor,
|
|
52
|
+
wind_shuffle: _toWindShuffle(val.windShuffle),
|
|
53
|
+
};
|
|
54
|
+
return orig.make_seating_swiss(input).result;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export function update_wind_placing_only(val) {
|
|
58
|
+
const input = {
|
|
59
|
+
players_map: Object.entries(val.playersMap).map(([k, v]) => [
|
|
60
|
+
parseInt(k.toString(), 10),
|
|
61
|
+
v,
|
|
62
|
+
]),
|
|
63
|
+
previous_seatings: val.previousSeatings,
|
|
64
|
+
rand_factor: val.randFactor,
|
|
65
|
+
wind_shuffle: _toWindShuffle(val.windShuffle),
|
|
66
|
+
};
|
|
67
|
+
return orig.update_wind_placing_only(input).result;
|
|
68
|
+
}
|
package/package.json
CHANGED
|
@@ -3,13 +3,20 @@
|
|
|
3
3
|
"collaborators": [
|
|
4
4
|
"Oleg Klimenko <me@ctizen.dev>"
|
|
5
5
|
],
|
|
6
|
-
"version": "2.
|
|
6
|
+
"version": "2.1.0",
|
|
7
7
|
"files": [
|
|
8
8
|
"mahjong_seatings_rs_node.js",
|
|
9
|
+
"mahjong_seatings_rs_node.mjs",
|
|
9
10
|
"mahjong_seatings_rs.d.ts",
|
|
10
11
|
"mahjong_seatings_rs_bg.wasm",
|
|
11
12
|
"mahjong_seatings_rs.js"
|
|
12
13
|
],
|
|
13
14
|
"main": "mahjong_seatings_rs_node.js",
|
|
14
|
-
"types": "mahjong_seatings_rs.d.ts"
|
|
15
|
+
"types": "mahjong_seatings_rs.d.ts",
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"types": "./mahjong_seatings_rs.d.ts",
|
|
19
|
+
"default": "./mahjong_seatings_rs_node.mjs"
|
|
20
|
+
}
|
|
21
|
+
}
|
|
15
22
|
}
|