mons-rust 0.1.5 → 0.1.14

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