mons-rust 0.1.5 → 0.1.13
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/mons_rust.d.ts +370 -0
- package/mons_rust.js +884 -16
- package/mons_rust_bg.wasm +0 -0
- package/package.json +6 -3
package/mons_rust.d.ts
CHANGED
|
@@ -8,3 +8,373 @@
|
|
|
8
8
|
* @returns {string}
|
|
9
9
|
*/
|
|
10
10
|
export function winner(fen_w: string, fen_b: string, flat_moves_string_w: string, flat_moves_string_b: string): string;
|
|
11
|
+
/**
|
|
12
|
+
*/
|
|
13
|
+
export enum Modifier {
|
|
14
|
+
SelectPotion = 0,
|
|
15
|
+
SelectBomb = 1,
|
|
16
|
+
Cancel = 2,
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
*/
|
|
20
|
+
export enum NextInputKind {
|
|
21
|
+
MonMove = 0,
|
|
22
|
+
ManaMove = 1,
|
|
23
|
+
MysticAction = 2,
|
|
24
|
+
DemonAction = 3,
|
|
25
|
+
DemonAdditionalStep = 4,
|
|
26
|
+
SpiritTargetCapture = 5,
|
|
27
|
+
SpiritTargetMove = 6,
|
|
28
|
+
SelectConsumable = 7,
|
|
29
|
+
BombAttack = 8,
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
*/
|
|
33
|
+
export enum EventModelKind {
|
|
34
|
+
MonMove = 0,
|
|
35
|
+
ManaMove = 1,
|
|
36
|
+
ManaScored = 2,
|
|
37
|
+
MysticAction = 3,
|
|
38
|
+
DemonAction = 4,
|
|
39
|
+
DemonAdditionalStep = 5,
|
|
40
|
+
SpiritTargetMove = 6,
|
|
41
|
+
PickupBomb = 7,
|
|
42
|
+
PickupPotion = 8,
|
|
43
|
+
PickupMana = 9,
|
|
44
|
+
MonFainted = 10,
|
|
45
|
+
ManaDropped = 11,
|
|
46
|
+
SupermanaBackToBase = 12,
|
|
47
|
+
BombAttack = 13,
|
|
48
|
+
MonAwake = 14,
|
|
49
|
+
BombExplosion = 15,
|
|
50
|
+
NextTurn = 16,
|
|
51
|
+
GameOver = 17,
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
*/
|
|
55
|
+
export enum ManaKind {
|
|
56
|
+
Regular = 0,
|
|
57
|
+
Supermana = 1,
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
*/
|
|
61
|
+
export enum SquareModelKind {
|
|
62
|
+
Regular = 0,
|
|
63
|
+
ConsumableBase = 1,
|
|
64
|
+
SupermanaBase = 2,
|
|
65
|
+
ManaBase = 3,
|
|
66
|
+
ManaPool = 4,
|
|
67
|
+
MonBase = 5,
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
*/
|
|
71
|
+
export enum ItemModelKind {
|
|
72
|
+
Mon = 0,
|
|
73
|
+
Mana = 1,
|
|
74
|
+
MonWithMana = 2,
|
|
75
|
+
MonWithConsumable = 3,
|
|
76
|
+
Consumable = 4,
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
*/
|
|
80
|
+
export enum Color {
|
|
81
|
+
White = 0,
|
|
82
|
+
Black = 1,
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
*/
|
|
86
|
+
export enum Consumable {
|
|
87
|
+
Potion = 0,
|
|
88
|
+
Bomb = 1,
|
|
89
|
+
BombOrPotion = 2,
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
*/
|
|
93
|
+
export enum AvailableMoveKind {
|
|
94
|
+
MonMove = 0,
|
|
95
|
+
ManaMove = 1,
|
|
96
|
+
Action = 2,
|
|
97
|
+
Potion = 3,
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
*/
|
|
101
|
+
export enum OutputModelKind {
|
|
102
|
+
InvalidInput = 0,
|
|
103
|
+
LocationsToStartFrom = 1,
|
|
104
|
+
NextInputOptions = 2,
|
|
105
|
+
Events = 3,
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
*/
|
|
109
|
+
export enum MonKind {
|
|
110
|
+
Demon = 0,
|
|
111
|
+
Drainer = 1,
|
|
112
|
+
Angel = 2,
|
|
113
|
+
Spirit = 3,
|
|
114
|
+
Mystic = 4,
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
*/
|
|
118
|
+
export class EventModel {
|
|
119
|
+
free(): void;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
*/
|
|
123
|
+
export class ItemModel {
|
|
124
|
+
free(): void;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
*/
|
|
128
|
+
export class Location {
|
|
129
|
+
free(): void;
|
|
130
|
+
/**
|
|
131
|
+
* @param {number} i
|
|
132
|
+
* @param {number} j
|
|
133
|
+
*/
|
|
134
|
+
constructor(i: number, j: number);
|
|
135
|
+
/**
|
|
136
|
+
*/
|
|
137
|
+
i: number;
|
|
138
|
+
/**
|
|
139
|
+
*/
|
|
140
|
+
j: number;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
*/
|
|
144
|
+
export class ManaModel {
|
|
145
|
+
free(): void;
|
|
146
|
+
/**
|
|
147
|
+
*/
|
|
148
|
+
color: Color;
|
|
149
|
+
/**
|
|
150
|
+
*/
|
|
151
|
+
kind: ManaKind;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
*/
|
|
155
|
+
export class Mon {
|
|
156
|
+
free(): void;
|
|
157
|
+
/**
|
|
158
|
+
* @param {MonKind} kind
|
|
159
|
+
* @param {Color} color
|
|
160
|
+
* @param {number} cooldown
|
|
161
|
+
* @returns {Mon}
|
|
162
|
+
*/
|
|
163
|
+
static new(kind: MonKind, color: Color, cooldown: number): Mon;
|
|
164
|
+
/**
|
|
165
|
+
* @returns {boolean}
|
|
166
|
+
*/
|
|
167
|
+
is_fainted(): boolean;
|
|
168
|
+
/**
|
|
169
|
+
*/
|
|
170
|
+
faint(): void;
|
|
171
|
+
/**
|
|
172
|
+
*/
|
|
173
|
+
decrease_cooldown(): void;
|
|
174
|
+
/**
|
|
175
|
+
*/
|
|
176
|
+
color: Color;
|
|
177
|
+
/**
|
|
178
|
+
*/
|
|
179
|
+
cooldown: number;
|
|
180
|
+
/**
|
|
181
|
+
*/
|
|
182
|
+
kind: MonKind;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
*/
|
|
186
|
+
export class MonsGameModel {
|
|
187
|
+
free(): void;
|
|
188
|
+
/**
|
|
189
|
+
* @param {string} fen
|
|
190
|
+
* @returns {MonsGameModel | undefined}
|
|
191
|
+
*/
|
|
192
|
+
static from_fen(fen: string): MonsGameModel | undefined;
|
|
193
|
+
/**
|
|
194
|
+
* @returns {string}
|
|
195
|
+
*/
|
|
196
|
+
fen(): string;
|
|
197
|
+
/**
|
|
198
|
+
* @param {(Location)[]} locations
|
|
199
|
+
* @param {Modifier | undefined} [modifier]
|
|
200
|
+
* @returns {OutputModel}
|
|
201
|
+
*/
|
|
202
|
+
process_input(locations: (Location)[], modifier?: Modifier): OutputModel;
|
|
203
|
+
/**
|
|
204
|
+
* @param {string} input_fen
|
|
205
|
+
* @returns {OutputModel}
|
|
206
|
+
*/
|
|
207
|
+
process_input_fen(input_fen: string): OutputModel;
|
|
208
|
+
/**
|
|
209
|
+
* @param {Location} at
|
|
210
|
+
* @returns {ItemModel | undefined}
|
|
211
|
+
*/
|
|
212
|
+
item(at: Location): ItemModel | undefined;
|
|
213
|
+
/**
|
|
214
|
+
* @param {Location} at
|
|
215
|
+
* @returns {SquareModel}
|
|
216
|
+
*/
|
|
217
|
+
square(at: Location): SquareModel;
|
|
218
|
+
/**
|
|
219
|
+
* @param {string} other_fen
|
|
220
|
+
* @returns {boolean}
|
|
221
|
+
*/
|
|
222
|
+
is_later_than(other_fen: string): boolean;
|
|
223
|
+
/**
|
|
224
|
+
* @returns {Color}
|
|
225
|
+
*/
|
|
226
|
+
active_color(): Color;
|
|
227
|
+
/**
|
|
228
|
+
* @returns {Color | undefined}
|
|
229
|
+
*/
|
|
230
|
+
winner_color(): Color | undefined;
|
|
231
|
+
/**
|
|
232
|
+
* @returns {number}
|
|
233
|
+
*/
|
|
234
|
+
black_score(): number;
|
|
235
|
+
/**
|
|
236
|
+
* @returns {number}
|
|
237
|
+
*/
|
|
238
|
+
white_score(): number;
|
|
239
|
+
/**
|
|
240
|
+
* @returns {Int32Array}
|
|
241
|
+
*/
|
|
242
|
+
available_move_kinds(): Int32Array;
|
|
243
|
+
/**
|
|
244
|
+
* @returns {(Location)[]}
|
|
245
|
+
*/
|
|
246
|
+
locations_with_content(): (Location)[];
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
*/
|
|
250
|
+
export class NextInputModel {
|
|
251
|
+
free(): void;
|
|
252
|
+
/**
|
|
253
|
+
*/
|
|
254
|
+
actor_mon_item?: ItemModel;
|
|
255
|
+
/**
|
|
256
|
+
*/
|
|
257
|
+
kind: NextInputKind;
|
|
258
|
+
/**
|
|
259
|
+
*/
|
|
260
|
+
location?: Location;
|
|
261
|
+
/**
|
|
262
|
+
*/
|
|
263
|
+
modifier?: Modifier;
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
*/
|
|
267
|
+
export class OutputModel {
|
|
268
|
+
free(): void;
|
|
269
|
+
/**
|
|
270
|
+
* @returns {(Location)[]}
|
|
271
|
+
*/
|
|
272
|
+
locations(): (Location)[];
|
|
273
|
+
/**
|
|
274
|
+
* @returns {(NextInputModel)[]}
|
|
275
|
+
*/
|
|
276
|
+
next_inputs(): (NextInputModel)[];
|
|
277
|
+
/**
|
|
278
|
+
* @returns {(EventModel)[]}
|
|
279
|
+
*/
|
|
280
|
+
events(): (EventModel)[];
|
|
281
|
+
/**
|
|
282
|
+
* @returns {string}
|
|
283
|
+
*/
|
|
284
|
+
input_fen(): string;
|
|
285
|
+
/**
|
|
286
|
+
*/
|
|
287
|
+
kind: OutputModelKind;
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
*/
|
|
291
|
+
export class SquareModel {
|
|
292
|
+
free(): void;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
296
|
+
|
|
297
|
+
export interface InitOutput {
|
|
298
|
+
readonly memory: WebAssembly.Memory;
|
|
299
|
+
readonly __wbg_monsgamemodel_free: (a: number) => void;
|
|
300
|
+
readonly monsgamemodel_from_fen: (a: number, b: number) => number;
|
|
301
|
+
readonly monsgamemodel_fen: (a: number, b: number) => void;
|
|
302
|
+
readonly monsgamemodel_process_input: (a: number, b: number, c: number, d: number) => number;
|
|
303
|
+
readonly monsgamemodel_process_input_fen: (a: number, b: number, c: number) => number;
|
|
304
|
+
readonly monsgamemodel_item: (a: number, b: number) => number;
|
|
305
|
+
readonly monsgamemodel_square: (a: number, b: number) => number;
|
|
306
|
+
readonly monsgamemodel_is_later_than: (a: number, b: number, c: number) => number;
|
|
307
|
+
readonly monsgamemodel_active_color: (a: number) => number;
|
|
308
|
+
readonly monsgamemodel_winner_color: (a: number) => number;
|
|
309
|
+
readonly monsgamemodel_black_score: (a: number) => number;
|
|
310
|
+
readonly monsgamemodel_white_score: (a: number) => number;
|
|
311
|
+
readonly monsgamemodel_available_move_kinds: (a: number, b: number) => void;
|
|
312
|
+
readonly monsgamemodel_locations_with_content: (a: number, b: number) => void;
|
|
313
|
+
readonly __wbg_outputmodel_free: (a: number) => void;
|
|
314
|
+
readonly __wbg_get_outputmodel_kind: (a: number) => number;
|
|
315
|
+
readonly __wbg_set_outputmodel_kind: (a: number, b: number) => void;
|
|
316
|
+
readonly outputmodel_locations: (a: number, b: number) => void;
|
|
317
|
+
readonly outputmodel_next_inputs: (a: number, b: number) => void;
|
|
318
|
+
readonly outputmodel_events: (a: number, b: number) => void;
|
|
319
|
+
readonly outputmodel_input_fen: (a: number, b: number) => void;
|
|
320
|
+
readonly __wbg_itemmodel_free: (a: number) => void;
|
|
321
|
+
readonly __wbg_manamodel_free: (a: number) => void;
|
|
322
|
+
readonly __wbg_get_manamodel_kind: (a: number) => number;
|
|
323
|
+
readonly __wbg_set_manamodel_kind: (a: number, b: number) => void;
|
|
324
|
+
readonly __wbg_get_manamodel_color: (a: number) => number;
|
|
325
|
+
readonly __wbg_set_manamodel_color: (a: number, b: number) => void;
|
|
326
|
+
readonly __wbg_nextinputmodel_free: (a: number) => void;
|
|
327
|
+
readonly __wbg_get_nextinputmodel_location: (a: number) => number;
|
|
328
|
+
readonly __wbg_set_nextinputmodel_location: (a: number, b: number) => void;
|
|
329
|
+
readonly __wbg_get_nextinputmodel_modifier: (a: number) => number;
|
|
330
|
+
readonly __wbg_set_nextinputmodel_modifier: (a: number, b: number) => void;
|
|
331
|
+
readonly __wbg_get_nextinputmodel_kind: (a: number) => number;
|
|
332
|
+
readonly __wbg_set_nextinputmodel_kind: (a: number, b: number) => void;
|
|
333
|
+
readonly __wbg_get_nextinputmodel_actor_mon_item: (a: number) => number;
|
|
334
|
+
readonly __wbg_set_nextinputmodel_actor_mon_item: (a: number, b: number) => void;
|
|
335
|
+
readonly __wbg_eventmodel_free: (a: number) => void;
|
|
336
|
+
readonly __wbg_squaremodel_free: (a: number) => void;
|
|
337
|
+
readonly __wbg_mon_free: (a: number) => void;
|
|
338
|
+
readonly __wbg_get_mon_kind: (a: number) => number;
|
|
339
|
+
readonly __wbg_set_mon_kind: (a: number, b: number) => void;
|
|
340
|
+
readonly __wbg_get_mon_color: (a: number) => number;
|
|
341
|
+
readonly __wbg_set_mon_color: (a: number, b: number) => void;
|
|
342
|
+
readonly __wbg_get_mon_cooldown: (a: number) => number;
|
|
343
|
+
readonly __wbg_set_mon_cooldown: (a: number, b: number) => void;
|
|
344
|
+
readonly mon_new: (a: number, b: number, c: number) => number;
|
|
345
|
+
readonly mon_is_fainted: (a: number) => number;
|
|
346
|
+
readonly mon_faint: (a: number) => void;
|
|
347
|
+
readonly mon_decrease_cooldown: (a: number) => void;
|
|
348
|
+
readonly __wbg_location_free: (a: number) => void;
|
|
349
|
+
readonly __wbg_get_location_i: (a: number) => number;
|
|
350
|
+
readonly __wbg_set_location_i: (a: number, b: number) => void;
|
|
351
|
+
readonly __wbg_get_location_j: (a: number) => number;
|
|
352
|
+
readonly __wbg_set_location_j: (a: number, b: number) => void;
|
|
353
|
+
readonly location_new: (a: number, b: number) => number;
|
|
354
|
+
readonly winner: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => void;
|
|
355
|
+
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
356
|
+
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
357
|
+
readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
|
|
358
|
+
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
|
362
|
+
/**
|
|
363
|
+
* Instantiates the given `module`, which can either be bytes or
|
|
364
|
+
* a precompiled `WebAssembly.Module`.
|
|
365
|
+
*
|
|
366
|
+
* @param {SyncInitInput} module
|
|
367
|
+
*
|
|
368
|
+
* @returns {InitOutput}
|
|
369
|
+
*/
|
|
370
|
+
export function initSync(module: SyncInitInput): InitOutput;
|
|
371
|
+
|
|
372
|
+
/**
|
|
373
|
+
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
|
374
|
+
* for everything else, calls `WebAssembly.instantiate` directly.
|
|
375
|
+
*
|
|
376
|
+
* @param {InitInput | Promise<InitInput>} module_or_path
|
|
377
|
+
*
|
|
378
|
+
* @returns {Promise<InitOutput>}
|
|
379
|
+
*/
|
|
380
|
+
export default function __wbg_init (module_or_path?: InitInput | Promise<InitInput>): Promise<InitOutput>;
|
package/mons_rust.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
let imports = {};
|
|
2
1
|
let wasm;
|
|
3
|
-
const { TextEncoder, TextDecoder } = require(`util`);
|
|
4
2
|
|
|
5
|
-
|
|
3
|
+
const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );
|
|
4
|
+
|
|
5
|
+
if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); };
|
|
6
6
|
|
|
7
7
|
let cachedUint8Memory0 = null;
|
|
8
8
|
|
|
@@ -13,7 +13,14 @@ function getUint8Memory0() {
|
|
|
13
13
|
return cachedUint8Memory0;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
function getStringFromWasm0(ptr, len) {
|
|
17
|
+
ptr = ptr >>> 0;
|
|
18
|
+
return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
let WASM_VECTOR_LEN = 0;
|
|
22
|
+
|
|
23
|
+
const cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available') } } );
|
|
17
24
|
|
|
18
25
|
const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
|
|
19
26
|
? function (arg, view) {
|
|
@@ -76,13 +83,79 @@ function getInt32Memory0() {
|
|
|
76
83
|
return cachedInt32Memory0;
|
|
77
84
|
}
|
|
78
85
|
|
|
79
|
-
let
|
|
86
|
+
let cachedUint32Memory0 = null;
|
|
80
87
|
|
|
81
|
-
|
|
88
|
+
function getUint32Memory0() {
|
|
89
|
+
if (cachedUint32Memory0 === null || cachedUint32Memory0.byteLength === 0) {
|
|
90
|
+
cachedUint32Memory0 = new Uint32Array(wasm.memory.buffer);
|
|
91
|
+
}
|
|
92
|
+
return cachedUint32Memory0;
|
|
93
|
+
}
|
|
82
94
|
|
|
83
|
-
|
|
95
|
+
const heap = new Array(128).fill(undefined);
|
|
96
|
+
|
|
97
|
+
heap.push(undefined, null, true, false);
|
|
98
|
+
|
|
99
|
+
let heap_next = heap.length;
|
|
100
|
+
|
|
101
|
+
function addHeapObject(obj) {
|
|
102
|
+
if (heap_next === heap.length) heap.push(heap.length + 1);
|
|
103
|
+
const idx = heap_next;
|
|
104
|
+
heap_next = heap[idx];
|
|
105
|
+
|
|
106
|
+
heap[idx] = obj;
|
|
107
|
+
return idx;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function passArrayJsValueToWasm0(array, malloc) {
|
|
111
|
+
const ptr = malloc(array.length * 4, 4) >>> 0;
|
|
112
|
+
const mem = getUint32Memory0();
|
|
113
|
+
for (let i = 0; i < array.length; i++) {
|
|
114
|
+
mem[ptr / 4 + i] = addHeapObject(array[i]);
|
|
115
|
+
}
|
|
116
|
+
WASM_VECTOR_LEN = array.length;
|
|
117
|
+
return ptr;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function isLikeNone(x) {
|
|
121
|
+
return x === undefined || x === null;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
function _assertClass(instance, klass) {
|
|
125
|
+
if (!(instance instanceof klass)) {
|
|
126
|
+
throw new Error(`expected instance of ${klass.name}`);
|
|
127
|
+
}
|
|
128
|
+
return instance.ptr;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
function getArrayI32FromWasm0(ptr, len) {
|
|
84
132
|
ptr = ptr >>> 0;
|
|
85
|
-
return
|
|
133
|
+
return getInt32Memory0().subarray(ptr / 4, ptr / 4 + len);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
function getObject(idx) { return heap[idx]; }
|
|
137
|
+
|
|
138
|
+
function dropObject(idx) {
|
|
139
|
+
if (idx < 132) return;
|
|
140
|
+
heap[idx] = heap_next;
|
|
141
|
+
heap_next = idx;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
function takeObject(idx) {
|
|
145
|
+
const ret = getObject(idx);
|
|
146
|
+
dropObject(idx);
|
|
147
|
+
return ret;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
function getArrayJsValueFromWasm0(ptr, len) {
|
|
151
|
+
ptr = ptr >>> 0;
|
|
152
|
+
const mem = getUint32Memory0();
|
|
153
|
+
const slice = mem.subarray(ptr / 4, ptr / 4 + len);
|
|
154
|
+
const result = [];
|
|
155
|
+
for (let i = 0; i < slice.length; i++) {
|
|
156
|
+
result.push(takeObject(slice[i]));
|
|
157
|
+
}
|
|
158
|
+
return result;
|
|
86
159
|
}
|
|
87
160
|
/**
|
|
88
161
|
* @param {string} fen_w
|
|
@@ -91,7 +164,7 @@ function getStringFromWasm0(ptr, len) {
|
|
|
91
164
|
* @param {string} flat_moves_string_b
|
|
92
165
|
* @returns {string}
|
|
93
166
|
*/
|
|
94
|
-
|
|
167
|
+
export function winner(fen_w, fen_b, flat_moves_string_w, flat_moves_string_b) {
|
|
95
168
|
let deferred5_0;
|
|
96
169
|
let deferred5_1;
|
|
97
170
|
try {
|
|
@@ -114,13 +187,808 @@ module.exports.winner = function(fen_w, fen_b, flat_moves_string_w, flat_moves_s
|
|
|
114
187
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
115
188
|
wasm.__wbindgen_free(deferred5_0, deferred5_1, 1);
|
|
116
189
|
}
|
|
117
|
-
}
|
|
190
|
+
}
|
|
118
191
|
|
|
119
|
-
|
|
120
|
-
|
|
192
|
+
/**
|
|
193
|
+
*/
|
|
194
|
+
export const Modifier = Object.freeze({ SelectPotion:0,"0":"SelectPotion",SelectBomb:1,"1":"SelectBomb",Cancel:2,"2":"Cancel", });
|
|
195
|
+
/**
|
|
196
|
+
*/
|
|
197
|
+
export const NextInputKind = Object.freeze({ MonMove:0,"0":"MonMove",ManaMove:1,"1":"ManaMove",MysticAction:2,"2":"MysticAction",DemonAction:3,"3":"DemonAction",DemonAdditionalStep:4,"4":"DemonAdditionalStep",SpiritTargetCapture:5,"5":"SpiritTargetCapture",SpiritTargetMove:6,"6":"SpiritTargetMove",SelectConsumable:7,"7":"SelectConsumable",BombAttack:8,"8":"BombAttack", });
|
|
198
|
+
/**
|
|
199
|
+
*/
|
|
200
|
+
export const EventModelKind = Object.freeze({ MonMove:0,"0":"MonMove",ManaMove:1,"1":"ManaMove",ManaScored:2,"2":"ManaScored",MysticAction:3,"3":"MysticAction",DemonAction:4,"4":"DemonAction",DemonAdditionalStep:5,"5":"DemonAdditionalStep",SpiritTargetMove:6,"6":"SpiritTargetMove",PickupBomb:7,"7":"PickupBomb",PickupPotion:8,"8":"PickupPotion",PickupMana:9,"9":"PickupMana",MonFainted:10,"10":"MonFainted",ManaDropped:11,"11":"ManaDropped",SupermanaBackToBase:12,"12":"SupermanaBackToBase",BombAttack:13,"13":"BombAttack",MonAwake:14,"14":"MonAwake",BombExplosion:15,"15":"BombExplosion",NextTurn:16,"16":"NextTurn",GameOver:17,"17":"GameOver", });
|
|
201
|
+
/**
|
|
202
|
+
*/
|
|
203
|
+
export const ManaKind = Object.freeze({ Regular:0,"0":"Regular",Supermana:1,"1":"Supermana", });
|
|
204
|
+
/**
|
|
205
|
+
*/
|
|
206
|
+
export const SquareModelKind = Object.freeze({ Regular:0,"0":"Regular",ConsumableBase:1,"1":"ConsumableBase",SupermanaBase:2,"2":"SupermanaBase",ManaBase:3,"3":"ManaBase",ManaPool:4,"4":"ManaPool",MonBase:5,"5":"MonBase", });
|
|
207
|
+
/**
|
|
208
|
+
*/
|
|
209
|
+
export const ItemModelKind = Object.freeze({ Mon:0,"0":"Mon",Mana:1,"1":"Mana",MonWithMana:2,"2":"MonWithMana",MonWithConsumable:3,"3":"MonWithConsumable",Consumable:4,"4":"Consumable", });
|
|
210
|
+
/**
|
|
211
|
+
*/
|
|
212
|
+
export const Color = Object.freeze({ White:0,"0":"White",Black:1,"1":"Black", });
|
|
213
|
+
/**
|
|
214
|
+
*/
|
|
215
|
+
export const Consumable = Object.freeze({ Potion:0,"0":"Potion",Bomb:1,"1":"Bomb",BombOrPotion:2,"2":"BombOrPotion", });
|
|
216
|
+
/**
|
|
217
|
+
*/
|
|
218
|
+
export const AvailableMoveKind = Object.freeze({ MonMove:0,"0":"MonMove",ManaMove:1,"1":"ManaMove",Action:2,"2":"Action",Potion:3,"3":"Potion", });
|
|
219
|
+
/**
|
|
220
|
+
*/
|
|
221
|
+
export const OutputModelKind = Object.freeze({ InvalidInput:0,"0":"InvalidInput",LocationsToStartFrom:1,"1":"LocationsToStartFrom",NextInputOptions:2,"2":"NextInputOptions",Events:3,"3":"Events", });
|
|
222
|
+
/**
|
|
223
|
+
*/
|
|
224
|
+
export const MonKind = Object.freeze({ Demon:0,"0":"Demon",Drainer:1,"1":"Drainer",Angel:2,"2":"Angel",Spirit:3,"3":"Spirit",Mystic:4,"4":"Mystic", });
|
|
225
|
+
|
|
226
|
+
const EventModelFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
227
|
+
? { register: () => {}, unregister: () => {} }
|
|
228
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_eventmodel_free(ptr >>> 0));
|
|
229
|
+
/**
|
|
230
|
+
*/
|
|
231
|
+
export class EventModel {
|
|
232
|
+
|
|
233
|
+
static __wrap(ptr) {
|
|
234
|
+
ptr = ptr >>> 0;
|
|
235
|
+
const obj = Object.create(EventModel.prototype);
|
|
236
|
+
obj.__wbg_ptr = ptr;
|
|
237
|
+
EventModelFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
238
|
+
return obj;
|
|
239
|
+
}
|
|
121
240
|
|
|
122
|
-
|
|
123
|
-
const
|
|
124
|
-
|
|
125
|
-
|
|
241
|
+
__destroy_into_raw() {
|
|
242
|
+
const ptr = this.__wbg_ptr;
|
|
243
|
+
this.__wbg_ptr = 0;
|
|
244
|
+
EventModelFinalization.unregister(this);
|
|
245
|
+
return ptr;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
free() {
|
|
249
|
+
const ptr = this.__destroy_into_raw();
|
|
250
|
+
wasm.__wbg_eventmodel_free(ptr);
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
const ItemModelFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
255
|
+
? { register: () => {}, unregister: () => {} }
|
|
256
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_itemmodel_free(ptr >>> 0));
|
|
257
|
+
/**
|
|
258
|
+
*/
|
|
259
|
+
export class ItemModel {
|
|
260
|
+
|
|
261
|
+
static __wrap(ptr) {
|
|
262
|
+
ptr = ptr >>> 0;
|
|
263
|
+
const obj = Object.create(ItemModel.prototype);
|
|
264
|
+
obj.__wbg_ptr = ptr;
|
|
265
|
+
ItemModelFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
266
|
+
return obj;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
__destroy_into_raw() {
|
|
270
|
+
const ptr = this.__wbg_ptr;
|
|
271
|
+
this.__wbg_ptr = 0;
|
|
272
|
+
ItemModelFinalization.unregister(this);
|
|
273
|
+
return ptr;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
free() {
|
|
277
|
+
const ptr = this.__destroy_into_raw();
|
|
278
|
+
wasm.__wbg_itemmodel_free(ptr);
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
const LocationFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
283
|
+
? { register: () => {}, unregister: () => {} }
|
|
284
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_location_free(ptr >>> 0));
|
|
285
|
+
/**
|
|
286
|
+
*/
|
|
287
|
+
export class Location {
|
|
288
|
+
|
|
289
|
+
static __wrap(ptr) {
|
|
290
|
+
ptr = ptr >>> 0;
|
|
291
|
+
const obj = Object.create(Location.prototype);
|
|
292
|
+
obj.__wbg_ptr = ptr;
|
|
293
|
+
LocationFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
294
|
+
return obj;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
static __unwrap(jsValue) {
|
|
298
|
+
if (!(jsValue instanceof Location)) {
|
|
299
|
+
return 0;
|
|
300
|
+
}
|
|
301
|
+
return jsValue.__destroy_into_raw();
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
__destroy_into_raw() {
|
|
305
|
+
const ptr = this.__wbg_ptr;
|
|
306
|
+
this.__wbg_ptr = 0;
|
|
307
|
+
LocationFinalization.unregister(this);
|
|
308
|
+
return ptr;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
free() {
|
|
312
|
+
const ptr = this.__destroy_into_raw();
|
|
313
|
+
wasm.__wbg_location_free(ptr);
|
|
314
|
+
}
|
|
315
|
+
/**
|
|
316
|
+
* @returns {number}
|
|
317
|
+
*/
|
|
318
|
+
get i() {
|
|
319
|
+
const ret = wasm.__wbg_get_location_i(this.__wbg_ptr);
|
|
320
|
+
return ret;
|
|
321
|
+
}
|
|
322
|
+
/**
|
|
323
|
+
* @param {number} arg0
|
|
324
|
+
*/
|
|
325
|
+
set i(arg0) {
|
|
326
|
+
wasm.__wbg_set_location_i(this.__wbg_ptr, arg0);
|
|
327
|
+
}
|
|
328
|
+
/**
|
|
329
|
+
* @returns {number}
|
|
330
|
+
*/
|
|
331
|
+
get j() {
|
|
332
|
+
const ret = wasm.__wbg_get_location_j(this.__wbg_ptr);
|
|
333
|
+
return ret;
|
|
334
|
+
}
|
|
335
|
+
/**
|
|
336
|
+
* @param {number} arg0
|
|
337
|
+
*/
|
|
338
|
+
set j(arg0) {
|
|
339
|
+
wasm.__wbg_set_location_j(this.__wbg_ptr, arg0);
|
|
340
|
+
}
|
|
341
|
+
/**
|
|
342
|
+
* @param {number} i
|
|
343
|
+
* @param {number} j
|
|
344
|
+
*/
|
|
345
|
+
constructor(i, j) {
|
|
346
|
+
const ret = wasm.location_new(i, j);
|
|
347
|
+
this.__wbg_ptr = ret >>> 0;
|
|
348
|
+
return this;
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
const ManaModelFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
353
|
+
? { register: () => {}, unregister: () => {} }
|
|
354
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_manamodel_free(ptr >>> 0));
|
|
355
|
+
/**
|
|
356
|
+
*/
|
|
357
|
+
export class ManaModel {
|
|
358
|
+
|
|
359
|
+
__destroy_into_raw() {
|
|
360
|
+
const ptr = this.__wbg_ptr;
|
|
361
|
+
this.__wbg_ptr = 0;
|
|
362
|
+
ManaModelFinalization.unregister(this);
|
|
363
|
+
return ptr;
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
free() {
|
|
367
|
+
const ptr = this.__destroy_into_raw();
|
|
368
|
+
wasm.__wbg_manamodel_free(ptr);
|
|
369
|
+
}
|
|
370
|
+
/**
|
|
371
|
+
* @returns {ManaKind}
|
|
372
|
+
*/
|
|
373
|
+
get kind() {
|
|
374
|
+
const ret = wasm.__wbg_get_manamodel_kind(this.__wbg_ptr);
|
|
375
|
+
return ret;
|
|
376
|
+
}
|
|
377
|
+
/**
|
|
378
|
+
* @param {ManaKind} arg0
|
|
379
|
+
*/
|
|
380
|
+
set kind(arg0) {
|
|
381
|
+
wasm.__wbg_set_manamodel_kind(this.__wbg_ptr, arg0);
|
|
382
|
+
}
|
|
383
|
+
/**
|
|
384
|
+
* @returns {Color}
|
|
385
|
+
*/
|
|
386
|
+
get color() {
|
|
387
|
+
const ret = wasm.__wbg_get_manamodel_color(this.__wbg_ptr);
|
|
388
|
+
return ret;
|
|
389
|
+
}
|
|
390
|
+
/**
|
|
391
|
+
* @param {Color} arg0
|
|
392
|
+
*/
|
|
393
|
+
set color(arg0) {
|
|
394
|
+
wasm.__wbg_set_manamodel_color(this.__wbg_ptr, arg0);
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
const MonFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
399
|
+
? { register: () => {}, unregister: () => {} }
|
|
400
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_mon_free(ptr >>> 0));
|
|
401
|
+
/**
|
|
402
|
+
*/
|
|
403
|
+
export class Mon {
|
|
404
|
+
|
|
405
|
+
static __wrap(ptr) {
|
|
406
|
+
ptr = ptr >>> 0;
|
|
407
|
+
const obj = Object.create(Mon.prototype);
|
|
408
|
+
obj.__wbg_ptr = ptr;
|
|
409
|
+
MonFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
410
|
+
return obj;
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
__destroy_into_raw() {
|
|
414
|
+
const ptr = this.__wbg_ptr;
|
|
415
|
+
this.__wbg_ptr = 0;
|
|
416
|
+
MonFinalization.unregister(this);
|
|
417
|
+
return ptr;
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
free() {
|
|
421
|
+
const ptr = this.__destroy_into_raw();
|
|
422
|
+
wasm.__wbg_mon_free(ptr);
|
|
423
|
+
}
|
|
424
|
+
/**
|
|
425
|
+
* @returns {MonKind}
|
|
426
|
+
*/
|
|
427
|
+
get kind() {
|
|
428
|
+
const ret = wasm.__wbg_get_mon_kind(this.__wbg_ptr);
|
|
429
|
+
return ret;
|
|
430
|
+
}
|
|
431
|
+
/**
|
|
432
|
+
* @param {MonKind} arg0
|
|
433
|
+
*/
|
|
434
|
+
set kind(arg0) {
|
|
435
|
+
wasm.__wbg_set_mon_kind(this.__wbg_ptr, arg0);
|
|
436
|
+
}
|
|
437
|
+
/**
|
|
438
|
+
* @returns {Color}
|
|
439
|
+
*/
|
|
440
|
+
get color() {
|
|
441
|
+
const ret = wasm.__wbg_get_mon_color(this.__wbg_ptr);
|
|
442
|
+
return ret;
|
|
443
|
+
}
|
|
444
|
+
/**
|
|
445
|
+
* @param {Color} arg0
|
|
446
|
+
*/
|
|
447
|
+
set color(arg0) {
|
|
448
|
+
wasm.__wbg_set_mon_color(this.__wbg_ptr, arg0);
|
|
449
|
+
}
|
|
450
|
+
/**
|
|
451
|
+
* @returns {number}
|
|
452
|
+
*/
|
|
453
|
+
get cooldown() {
|
|
454
|
+
const ret = wasm.__wbg_get_mon_cooldown(this.__wbg_ptr);
|
|
455
|
+
return ret;
|
|
456
|
+
}
|
|
457
|
+
/**
|
|
458
|
+
* @param {number} arg0
|
|
459
|
+
*/
|
|
460
|
+
set cooldown(arg0) {
|
|
461
|
+
wasm.__wbg_set_mon_cooldown(this.__wbg_ptr, arg0);
|
|
462
|
+
}
|
|
463
|
+
/**
|
|
464
|
+
* @param {MonKind} kind
|
|
465
|
+
* @param {Color} color
|
|
466
|
+
* @param {number} cooldown
|
|
467
|
+
* @returns {Mon}
|
|
468
|
+
*/
|
|
469
|
+
static new(kind, color, cooldown) {
|
|
470
|
+
const ret = wasm.mon_new(kind, color, cooldown);
|
|
471
|
+
return Mon.__wrap(ret);
|
|
472
|
+
}
|
|
473
|
+
/**
|
|
474
|
+
* @returns {boolean}
|
|
475
|
+
*/
|
|
476
|
+
is_fainted() {
|
|
477
|
+
const ret = wasm.mon_is_fainted(this.__wbg_ptr);
|
|
478
|
+
return ret !== 0;
|
|
479
|
+
}
|
|
480
|
+
/**
|
|
481
|
+
*/
|
|
482
|
+
faint() {
|
|
483
|
+
wasm.mon_faint(this.__wbg_ptr);
|
|
484
|
+
}
|
|
485
|
+
/**
|
|
486
|
+
*/
|
|
487
|
+
decrease_cooldown() {
|
|
488
|
+
wasm.mon_decrease_cooldown(this.__wbg_ptr);
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
const MonsGameModelFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
493
|
+
? { register: () => {}, unregister: () => {} }
|
|
494
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_monsgamemodel_free(ptr >>> 0));
|
|
495
|
+
/**
|
|
496
|
+
*/
|
|
497
|
+
export class MonsGameModel {
|
|
498
|
+
|
|
499
|
+
static __wrap(ptr) {
|
|
500
|
+
ptr = ptr >>> 0;
|
|
501
|
+
const obj = Object.create(MonsGameModel.prototype);
|
|
502
|
+
obj.__wbg_ptr = ptr;
|
|
503
|
+
MonsGameModelFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
504
|
+
return obj;
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
__destroy_into_raw() {
|
|
508
|
+
const ptr = this.__wbg_ptr;
|
|
509
|
+
this.__wbg_ptr = 0;
|
|
510
|
+
MonsGameModelFinalization.unregister(this);
|
|
511
|
+
return ptr;
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
free() {
|
|
515
|
+
const ptr = this.__destroy_into_raw();
|
|
516
|
+
wasm.__wbg_monsgamemodel_free(ptr);
|
|
517
|
+
}
|
|
518
|
+
/**
|
|
519
|
+
* @param {string} fen
|
|
520
|
+
* @returns {MonsGameModel | undefined}
|
|
521
|
+
*/
|
|
522
|
+
static from_fen(fen) {
|
|
523
|
+
const ptr0 = passStringToWasm0(fen, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
524
|
+
const len0 = WASM_VECTOR_LEN;
|
|
525
|
+
const ret = wasm.monsgamemodel_from_fen(ptr0, len0);
|
|
526
|
+
return ret === 0 ? undefined : MonsGameModel.__wrap(ret);
|
|
527
|
+
}
|
|
528
|
+
/**
|
|
529
|
+
* @returns {string}
|
|
530
|
+
*/
|
|
531
|
+
fen() {
|
|
532
|
+
let deferred1_0;
|
|
533
|
+
let deferred1_1;
|
|
534
|
+
try {
|
|
535
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
536
|
+
wasm.monsgamemodel_fen(retptr, this.__wbg_ptr);
|
|
537
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
538
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
539
|
+
deferred1_0 = r0;
|
|
540
|
+
deferred1_1 = r1;
|
|
541
|
+
return getStringFromWasm0(r0, r1);
|
|
542
|
+
} finally {
|
|
543
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
544
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
/**
|
|
548
|
+
* @param {(Location)[]} locations
|
|
549
|
+
* @param {Modifier | undefined} [modifier]
|
|
550
|
+
* @returns {OutputModel}
|
|
551
|
+
*/
|
|
552
|
+
process_input(locations, modifier) {
|
|
553
|
+
const ptr0 = passArrayJsValueToWasm0(locations, wasm.__wbindgen_malloc);
|
|
554
|
+
const len0 = WASM_VECTOR_LEN;
|
|
555
|
+
const ret = wasm.monsgamemodel_process_input(this.__wbg_ptr, ptr0, len0, isLikeNone(modifier) ? 3 : modifier);
|
|
556
|
+
return OutputModel.__wrap(ret);
|
|
557
|
+
}
|
|
558
|
+
/**
|
|
559
|
+
* @param {string} input_fen
|
|
560
|
+
* @returns {OutputModel}
|
|
561
|
+
*/
|
|
562
|
+
process_input_fen(input_fen) {
|
|
563
|
+
const ptr0 = passStringToWasm0(input_fen, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
564
|
+
const len0 = WASM_VECTOR_LEN;
|
|
565
|
+
const ret = wasm.monsgamemodel_process_input_fen(this.__wbg_ptr, ptr0, len0);
|
|
566
|
+
return OutputModel.__wrap(ret);
|
|
567
|
+
}
|
|
568
|
+
/**
|
|
569
|
+
* @param {Location} at
|
|
570
|
+
* @returns {ItemModel | undefined}
|
|
571
|
+
*/
|
|
572
|
+
item(at) {
|
|
573
|
+
_assertClass(at, Location);
|
|
574
|
+
var ptr0 = at.__destroy_into_raw();
|
|
575
|
+
const ret = wasm.monsgamemodel_item(this.__wbg_ptr, ptr0);
|
|
576
|
+
return ret === 0 ? undefined : ItemModel.__wrap(ret);
|
|
577
|
+
}
|
|
578
|
+
/**
|
|
579
|
+
* @param {Location} at
|
|
580
|
+
* @returns {SquareModel}
|
|
581
|
+
*/
|
|
582
|
+
square(at) {
|
|
583
|
+
_assertClass(at, Location);
|
|
584
|
+
var ptr0 = at.__destroy_into_raw();
|
|
585
|
+
const ret = wasm.monsgamemodel_square(this.__wbg_ptr, ptr0);
|
|
586
|
+
return SquareModel.__wrap(ret);
|
|
587
|
+
}
|
|
588
|
+
/**
|
|
589
|
+
* @param {string} other_fen
|
|
590
|
+
* @returns {boolean}
|
|
591
|
+
*/
|
|
592
|
+
is_later_than(other_fen) {
|
|
593
|
+
const ptr0 = passStringToWasm0(other_fen, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
594
|
+
const len0 = WASM_VECTOR_LEN;
|
|
595
|
+
const ret = wasm.monsgamemodel_is_later_than(this.__wbg_ptr, ptr0, len0);
|
|
596
|
+
return ret !== 0;
|
|
597
|
+
}
|
|
598
|
+
/**
|
|
599
|
+
* @returns {Color}
|
|
600
|
+
*/
|
|
601
|
+
active_color() {
|
|
602
|
+
const ret = wasm.monsgamemodel_active_color(this.__wbg_ptr);
|
|
603
|
+
return ret;
|
|
604
|
+
}
|
|
605
|
+
/**
|
|
606
|
+
* @returns {Color | undefined}
|
|
607
|
+
*/
|
|
608
|
+
winner_color() {
|
|
609
|
+
const ret = wasm.monsgamemodel_winner_color(this.__wbg_ptr);
|
|
610
|
+
return ret === 2 ? undefined : ret;
|
|
611
|
+
}
|
|
612
|
+
/**
|
|
613
|
+
* @returns {number}
|
|
614
|
+
*/
|
|
615
|
+
black_score() {
|
|
616
|
+
const ret = wasm.monsgamemodel_black_score(this.__wbg_ptr);
|
|
617
|
+
return ret;
|
|
618
|
+
}
|
|
619
|
+
/**
|
|
620
|
+
* @returns {number}
|
|
621
|
+
*/
|
|
622
|
+
white_score() {
|
|
623
|
+
const ret = wasm.monsgamemodel_white_score(this.__wbg_ptr);
|
|
624
|
+
return ret;
|
|
625
|
+
}
|
|
626
|
+
/**
|
|
627
|
+
* @returns {Int32Array}
|
|
628
|
+
*/
|
|
629
|
+
available_move_kinds() {
|
|
630
|
+
try {
|
|
631
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
632
|
+
wasm.monsgamemodel_available_move_kinds(retptr, this.__wbg_ptr);
|
|
633
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
634
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
635
|
+
var v1 = getArrayI32FromWasm0(r0, r1).slice();
|
|
636
|
+
wasm.__wbindgen_free(r0, r1 * 4, 4);
|
|
637
|
+
return v1;
|
|
638
|
+
} finally {
|
|
639
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
640
|
+
}
|
|
641
|
+
}
|
|
642
|
+
/**
|
|
643
|
+
* @returns {(Location)[]}
|
|
644
|
+
*/
|
|
645
|
+
locations_with_content() {
|
|
646
|
+
try {
|
|
647
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
648
|
+
wasm.monsgamemodel_locations_with_content(retptr, this.__wbg_ptr);
|
|
649
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
650
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
651
|
+
var v1 = getArrayJsValueFromWasm0(r0, r1).slice();
|
|
652
|
+
wasm.__wbindgen_free(r0, r1 * 4, 4);
|
|
653
|
+
return v1;
|
|
654
|
+
} finally {
|
|
655
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
const NextInputModelFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
661
|
+
? { register: () => {}, unregister: () => {} }
|
|
662
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_nextinputmodel_free(ptr >>> 0));
|
|
663
|
+
/**
|
|
664
|
+
*/
|
|
665
|
+
export class NextInputModel {
|
|
666
|
+
|
|
667
|
+
static __wrap(ptr) {
|
|
668
|
+
ptr = ptr >>> 0;
|
|
669
|
+
const obj = Object.create(NextInputModel.prototype);
|
|
670
|
+
obj.__wbg_ptr = ptr;
|
|
671
|
+
NextInputModelFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
672
|
+
return obj;
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
__destroy_into_raw() {
|
|
676
|
+
const ptr = this.__wbg_ptr;
|
|
677
|
+
this.__wbg_ptr = 0;
|
|
678
|
+
NextInputModelFinalization.unregister(this);
|
|
679
|
+
return ptr;
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
free() {
|
|
683
|
+
const ptr = this.__destroy_into_raw();
|
|
684
|
+
wasm.__wbg_nextinputmodel_free(ptr);
|
|
685
|
+
}
|
|
686
|
+
/**
|
|
687
|
+
* @returns {Location | undefined}
|
|
688
|
+
*/
|
|
689
|
+
get location() {
|
|
690
|
+
const ret = wasm.__wbg_get_nextinputmodel_location(this.__wbg_ptr);
|
|
691
|
+
return ret === 0 ? undefined : Location.__wrap(ret);
|
|
692
|
+
}
|
|
693
|
+
/**
|
|
694
|
+
* @param {Location | undefined} [arg0]
|
|
695
|
+
*/
|
|
696
|
+
set location(arg0) {
|
|
697
|
+
let ptr0 = 0;
|
|
698
|
+
if (!isLikeNone(arg0)) {
|
|
699
|
+
_assertClass(arg0, Location);
|
|
700
|
+
ptr0 = arg0.__destroy_into_raw();
|
|
701
|
+
}
|
|
702
|
+
wasm.__wbg_set_nextinputmodel_location(this.__wbg_ptr, ptr0);
|
|
703
|
+
}
|
|
704
|
+
/**
|
|
705
|
+
* @returns {Modifier | undefined}
|
|
706
|
+
*/
|
|
707
|
+
get modifier() {
|
|
708
|
+
const ret = wasm.__wbg_get_nextinputmodel_modifier(this.__wbg_ptr);
|
|
709
|
+
return ret === 3 ? undefined : ret;
|
|
710
|
+
}
|
|
711
|
+
/**
|
|
712
|
+
* @param {Modifier | undefined} [arg0]
|
|
713
|
+
*/
|
|
714
|
+
set modifier(arg0) {
|
|
715
|
+
wasm.__wbg_set_nextinputmodel_modifier(this.__wbg_ptr, isLikeNone(arg0) ? 3 : arg0);
|
|
716
|
+
}
|
|
717
|
+
/**
|
|
718
|
+
* @returns {NextInputKind}
|
|
719
|
+
*/
|
|
720
|
+
get kind() {
|
|
721
|
+
const ret = wasm.__wbg_get_nextinputmodel_kind(this.__wbg_ptr);
|
|
722
|
+
return ret;
|
|
723
|
+
}
|
|
724
|
+
/**
|
|
725
|
+
* @param {NextInputKind} arg0
|
|
726
|
+
*/
|
|
727
|
+
set kind(arg0) {
|
|
728
|
+
wasm.__wbg_set_nextinputmodel_kind(this.__wbg_ptr, arg0);
|
|
729
|
+
}
|
|
730
|
+
/**
|
|
731
|
+
* @returns {ItemModel | undefined}
|
|
732
|
+
*/
|
|
733
|
+
get actor_mon_item() {
|
|
734
|
+
const ret = wasm.__wbg_get_nextinputmodel_actor_mon_item(this.__wbg_ptr);
|
|
735
|
+
return ret === 0 ? undefined : ItemModel.__wrap(ret);
|
|
736
|
+
}
|
|
737
|
+
/**
|
|
738
|
+
* @param {ItemModel | undefined} [arg0]
|
|
739
|
+
*/
|
|
740
|
+
set actor_mon_item(arg0) {
|
|
741
|
+
let ptr0 = 0;
|
|
742
|
+
if (!isLikeNone(arg0)) {
|
|
743
|
+
_assertClass(arg0, ItemModel);
|
|
744
|
+
ptr0 = arg0.__destroy_into_raw();
|
|
745
|
+
}
|
|
746
|
+
wasm.__wbg_set_nextinputmodel_actor_mon_item(this.__wbg_ptr, ptr0);
|
|
747
|
+
}
|
|
748
|
+
}
|
|
749
|
+
|
|
750
|
+
const OutputModelFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
751
|
+
? { register: () => {}, unregister: () => {} }
|
|
752
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_outputmodel_free(ptr >>> 0));
|
|
753
|
+
/**
|
|
754
|
+
*/
|
|
755
|
+
export class OutputModel {
|
|
756
|
+
|
|
757
|
+
static __wrap(ptr) {
|
|
758
|
+
ptr = ptr >>> 0;
|
|
759
|
+
const obj = Object.create(OutputModel.prototype);
|
|
760
|
+
obj.__wbg_ptr = ptr;
|
|
761
|
+
OutputModelFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
762
|
+
return obj;
|
|
763
|
+
}
|
|
764
|
+
|
|
765
|
+
__destroy_into_raw() {
|
|
766
|
+
const ptr = this.__wbg_ptr;
|
|
767
|
+
this.__wbg_ptr = 0;
|
|
768
|
+
OutputModelFinalization.unregister(this);
|
|
769
|
+
return ptr;
|
|
770
|
+
}
|
|
771
|
+
|
|
772
|
+
free() {
|
|
773
|
+
const ptr = this.__destroy_into_raw();
|
|
774
|
+
wasm.__wbg_outputmodel_free(ptr);
|
|
775
|
+
}
|
|
776
|
+
/**
|
|
777
|
+
* @returns {OutputModelKind}
|
|
778
|
+
*/
|
|
779
|
+
get kind() {
|
|
780
|
+
const ret = wasm.__wbg_get_outputmodel_kind(this.__wbg_ptr);
|
|
781
|
+
return ret;
|
|
782
|
+
}
|
|
783
|
+
/**
|
|
784
|
+
* @param {OutputModelKind} arg0
|
|
785
|
+
*/
|
|
786
|
+
set kind(arg0) {
|
|
787
|
+
wasm.__wbg_set_outputmodel_kind(this.__wbg_ptr, arg0);
|
|
788
|
+
}
|
|
789
|
+
/**
|
|
790
|
+
* @returns {(Location)[]}
|
|
791
|
+
*/
|
|
792
|
+
locations() {
|
|
793
|
+
try {
|
|
794
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
795
|
+
wasm.outputmodel_locations(retptr, this.__wbg_ptr);
|
|
796
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
797
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
798
|
+
var v1 = getArrayJsValueFromWasm0(r0, r1).slice();
|
|
799
|
+
wasm.__wbindgen_free(r0, r1 * 4, 4);
|
|
800
|
+
return v1;
|
|
801
|
+
} finally {
|
|
802
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
803
|
+
}
|
|
804
|
+
}
|
|
805
|
+
/**
|
|
806
|
+
* @returns {(NextInputModel)[]}
|
|
807
|
+
*/
|
|
808
|
+
next_inputs() {
|
|
809
|
+
try {
|
|
810
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
811
|
+
wasm.outputmodel_next_inputs(retptr, this.__wbg_ptr);
|
|
812
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
813
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
814
|
+
var v1 = getArrayJsValueFromWasm0(r0, r1).slice();
|
|
815
|
+
wasm.__wbindgen_free(r0, r1 * 4, 4);
|
|
816
|
+
return v1;
|
|
817
|
+
} finally {
|
|
818
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
819
|
+
}
|
|
820
|
+
}
|
|
821
|
+
/**
|
|
822
|
+
* @returns {(EventModel)[]}
|
|
823
|
+
*/
|
|
824
|
+
events() {
|
|
825
|
+
try {
|
|
826
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
827
|
+
wasm.outputmodel_events(retptr, this.__wbg_ptr);
|
|
828
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
829
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
830
|
+
var v1 = getArrayJsValueFromWasm0(r0, r1).slice();
|
|
831
|
+
wasm.__wbindgen_free(r0, r1 * 4, 4);
|
|
832
|
+
return v1;
|
|
833
|
+
} finally {
|
|
834
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
835
|
+
}
|
|
836
|
+
}
|
|
837
|
+
/**
|
|
838
|
+
* @returns {string}
|
|
839
|
+
*/
|
|
840
|
+
input_fen() {
|
|
841
|
+
let deferred1_0;
|
|
842
|
+
let deferred1_1;
|
|
843
|
+
try {
|
|
844
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
845
|
+
wasm.outputmodel_input_fen(retptr, this.__wbg_ptr);
|
|
846
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
847
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
848
|
+
deferred1_0 = r0;
|
|
849
|
+
deferred1_1 = r1;
|
|
850
|
+
return getStringFromWasm0(r0, r1);
|
|
851
|
+
} finally {
|
|
852
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
853
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
854
|
+
}
|
|
855
|
+
}
|
|
856
|
+
}
|
|
857
|
+
|
|
858
|
+
const SquareModelFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
859
|
+
? { register: () => {}, unregister: () => {} }
|
|
860
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_squaremodel_free(ptr >>> 0));
|
|
861
|
+
/**
|
|
862
|
+
*/
|
|
863
|
+
export class SquareModel {
|
|
864
|
+
|
|
865
|
+
static __wrap(ptr) {
|
|
866
|
+
ptr = ptr >>> 0;
|
|
867
|
+
const obj = Object.create(SquareModel.prototype);
|
|
868
|
+
obj.__wbg_ptr = ptr;
|
|
869
|
+
SquareModelFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
870
|
+
return obj;
|
|
871
|
+
}
|
|
872
|
+
|
|
873
|
+
__destroy_into_raw() {
|
|
874
|
+
const ptr = this.__wbg_ptr;
|
|
875
|
+
this.__wbg_ptr = 0;
|
|
876
|
+
SquareModelFinalization.unregister(this);
|
|
877
|
+
return ptr;
|
|
878
|
+
}
|
|
879
|
+
|
|
880
|
+
free() {
|
|
881
|
+
const ptr = this.__destroy_into_raw();
|
|
882
|
+
wasm.__wbg_squaremodel_free(ptr);
|
|
883
|
+
}
|
|
884
|
+
}
|
|
885
|
+
|
|
886
|
+
async function __wbg_load(module, imports) {
|
|
887
|
+
if (typeof Response === 'function' && module instanceof Response) {
|
|
888
|
+
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
889
|
+
try {
|
|
890
|
+
return await WebAssembly.instantiateStreaming(module, imports);
|
|
891
|
+
|
|
892
|
+
} catch (e) {
|
|
893
|
+
if (module.headers.get('Content-Type') != 'application/wasm') {
|
|
894
|
+
console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
|
|
895
|
+
|
|
896
|
+
} else {
|
|
897
|
+
throw e;
|
|
898
|
+
}
|
|
899
|
+
}
|
|
900
|
+
}
|
|
901
|
+
|
|
902
|
+
const bytes = await module.arrayBuffer();
|
|
903
|
+
return await WebAssembly.instantiate(bytes, imports);
|
|
904
|
+
|
|
905
|
+
} else {
|
|
906
|
+
const instance = await WebAssembly.instantiate(module, imports);
|
|
907
|
+
|
|
908
|
+
if (instance instanceof WebAssembly.Instance) {
|
|
909
|
+
return { instance, module };
|
|
910
|
+
|
|
911
|
+
} else {
|
|
912
|
+
return instance;
|
|
913
|
+
}
|
|
914
|
+
}
|
|
915
|
+
}
|
|
916
|
+
|
|
917
|
+
function __wbg_get_imports() {
|
|
918
|
+
const imports = {};
|
|
919
|
+
imports.wbg = {};
|
|
920
|
+
imports.wbg.__wbg_eventmodel_new = function(arg0) {
|
|
921
|
+
const ret = EventModel.__wrap(arg0);
|
|
922
|
+
return addHeapObject(ret);
|
|
923
|
+
};
|
|
924
|
+
imports.wbg.__wbg_nextinputmodel_new = function(arg0) {
|
|
925
|
+
const ret = NextInputModel.__wrap(arg0);
|
|
926
|
+
return addHeapObject(ret);
|
|
927
|
+
};
|
|
928
|
+
imports.wbg.__wbg_location_new = function(arg0) {
|
|
929
|
+
const ret = Location.__wrap(arg0);
|
|
930
|
+
return addHeapObject(ret);
|
|
931
|
+
};
|
|
932
|
+
imports.wbg.__wbg_location_unwrap = function(arg0) {
|
|
933
|
+
const ret = Location.__unwrap(takeObject(arg0));
|
|
934
|
+
return ret;
|
|
935
|
+
};
|
|
936
|
+
imports.wbg.__wbindgen_throw = function(arg0, arg1) {
|
|
937
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
938
|
+
};
|
|
939
|
+
|
|
940
|
+
return imports;
|
|
941
|
+
}
|
|
942
|
+
|
|
943
|
+
function __wbg_init_memory(imports, maybe_memory) {
|
|
944
|
+
|
|
945
|
+
}
|
|
946
|
+
|
|
947
|
+
function __wbg_finalize_init(instance, module) {
|
|
948
|
+
wasm = instance.exports;
|
|
949
|
+
__wbg_init.__wbindgen_wasm_module = module;
|
|
950
|
+
cachedInt32Memory0 = null;
|
|
951
|
+
cachedUint32Memory0 = null;
|
|
952
|
+
cachedUint8Memory0 = null;
|
|
953
|
+
|
|
954
|
+
|
|
955
|
+
return wasm;
|
|
956
|
+
}
|
|
957
|
+
|
|
958
|
+
function initSync(module) {
|
|
959
|
+
if (wasm !== undefined) return wasm;
|
|
960
|
+
|
|
961
|
+
const imports = __wbg_get_imports();
|
|
962
|
+
|
|
963
|
+
__wbg_init_memory(imports);
|
|
964
|
+
|
|
965
|
+
if (!(module instanceof WebAssembly.Module)) {
|
|
966
|
+
module = new WebAssembly.Module(module);
|
|
967
|
+
}
|
|
968
|
+
|
|
969
|
+
const instance = new WebAssembly.Instance(module, imports);
|
|
970
|
+
|
|
971
|
+
return __wbg_finalize_init(instance, module);
|
|
972
|
+
}
|
|
973
|
+
|
|
974
|
+
async function __wbg_init(input) {
|
|
975
|
+
if (wasm !== undefined) return wasm;
|
|
976
|
+
|
|
977
|
+
if (typeof input === 'undefined') {
|
|
978
|
+
input = new URL('mons_rust_bg.wasm', import.meta.url);
|
|
979
|
+
}
|
|
980
|
+
const imports = __wbg_get_imports();
|
|
981
|
+
|
|
982
|
+
if (typeof input === 'string' || (typeof Request === 'function' && input instanceof Request) || (typeof URL === 'function' && input instanceof URL)) {
|
|
983
|
+
input = fetch(input);
|
|
984
|
+
}
|
|
985
|
+
|
|
986
|
+
__wbg_init_memory(imports);
|
|
987
|
+
|
|
988
|
+
const { instance, module } = await __wbg_load(await input, imports);
|
|
989
|
+
|
|
990
|
+
return __wbg_finalize_init(instance, module);
|
|
991
|
+
}
|
|
126
992
|
|
|
993
|
+
export { initSync }
|
|
994
|
+
export default __wbg_init;
|
package/mons_rust_bg.wasm
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mons-rust",
|
|
3
3
|
"description": "super metal mons",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.13",
|
|
5
5
|
"license": "CC0-1.0",
|
|
6
6
|
"files": [
|
|
7
7
|
"mons_rust_bg.wasm",
|
|
8
8
|
"mons_rust.js",
|
|
9
9
|
"mons_rust.d.ts"
|
|
10
10
|
],
|
|
11
|
-
"
|
|
12
|
-
"types": "mons_rust.d.ts"
|
|
11
|
+
"module": "mons_rust.js",
|
|
12
|
+
"types": "mons_rust.d.ts",
|
|
13
|
+
"sideEffects": [
|
|
14
|
+
"./snippets/*"
|
|
15
|
+
]
|
|
13
16
|
}
|