mons-rust 0.1.25 → 0.1.27

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 ADDED
@@ -0,0 +1,339 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ /**
4
+ * @param {string} fen_w
5
+ * @param {string} fen_b
6
+ * @param {string} flat_moves_string_w
7
+ * @param {string} flat_moves_string_b
8
+ * @returns {string}
9
+ */
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 MonKind {
14
+ Demon = 0,
15
+ Drainer = 1,
16
+ Angel = 2,
17
+ Spirit = 3,
18
+ Mystic = 4,
19
+ }
20
+ /**
21
+ */
22
+ export enum Modifier {
23
+ SelectPotion = 0,
24
+ SelectBomb = 1,
25
+ Cancel = 2,
26
+ }
27
+ /**
28
+ */
29
+ export enum ManaKind {
30
+ Regular = 0,
31
+ Supermana = 1,
32
+ }
33
+ /**
34
+ */
35
+ export enum NextInputKind {
36
+ MonMove = 0,
37
+ ManaMove = 1,
38
+ MysticAction = 2,
39
+ DemonAction = 3,
40
+ DemonAdditionalStep = 4,
41
+ SpiritTargetCapture = 5,
42
+ SpiritTargetMove = 6,
43
+ SelectConsumable = 7,
44
+ BombAttack = 8,
45
+ }
46
+ /**
47
+ */
48
+ export enum OutputModelKind {
49
+ InvalidInput = 0,
50
+ LocationsToStartFrom = 1,
51
+ NextInputOptions = 2,
52
+ Events = 3,
53
+ }
54
+ /**
55
+ */
56
+ export enum Consumable {
57
+ Potion = 0,
58
+ Bomb = 1,
59
+ BombOrPotion = 2,
60
+ }
61
+ /**
62
+ */
63
+ export enum ItemModelKind {
64
+ Mon = 0,
65
+ Mana = 1,
66
+ MonWithMana = 2,
67
+ MonWithConsumable = 3,
68
+ Consumable = 4,
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 AvailableMoveKind {
95
+ MonMove = 0,
96
+ ManaMove = 1,
97
+ Action = 2,
98
+ Potion = 3,
99
+ }
100
+ /**
101
+ */
102
+ export enum SquareModelKind {
103
+ Regular = 0,
104
+ ConsumableBase = 1,
105
+ SupermanaBase = 2,
106
+ ManaBase = 3,
107
+ ManaPool = 4,
108
+ MonBase = 5,
109
+ }
110
+ /**
111
+ */
112
+ export enum Color {
113
+ White = 0,
114
+ Black = 1,
115
+ }
116
+ /**
117
+ */
118
+ export class EventModel {
119
+ free(): void;
120
+ /**
121
+ */
122
+ color?: Color;
123
+ /**
124
+ */
125
+ item?: ItemModel;
126
+ /**
127
+ */
128
+ kind: EventModelKind;
129
+ /**
130
+ */
131
+ loc1?: Location;
132
+ /**
133
+ */
134
+ loc2?: Location;
135
+ /**
136
+ */
137
+ mana?: ManaModel;
138
+ /**
139
+ */
140
+ mon?: Mon;
141
+ }
142
+ /**
143
+ */
144
+ export class ItemModel {
145
+ free(): void;
146
+ /**
147
+ */
148
+ consumable?: Consumable;
149
+ /**
150
+ */
151
+ kind: ItemModelKind;
152
+ /**
153
+ */
154
+ mana?: ManaModel;
155
+ /**
156
+ */
157
+ mon?: Mon;
158
+ }
159
+ /**
160
+ */
161
+ export class Location {
162
+ free(): void;
163
+ /**
164
+ * @param {number} i
165
+ * @param {number} j
166
+ */
167
+ constructor(i: number, j: number);
168
+ /**
169
+ */
170
+ i: number;
171
+ /**
172
+ */
173
+ j: number;
174
+ }
175
+ /**
176
+ */
177
+ export class ManaModel {
178
+ free(): void;
179
+ /**
180
+ */
181
+ color: Color;
182
+ /**
183
+ */
184
+ kind: ManaKind;
185
+ }
186
+ /**
187
+ */
188
+ export class Mon {
189
+ free(): void;
190
+ /**
191
+ * @param {MonKind} kind
192
+ * @param {Color} color
193
+ * @param {number} cooldown
194
+ * @returns {Mon}
195
+ */
196
+ static new(kind: MonKind, color: Color, cooldown: number): Mon;
197
+ /**
198
+ * @returns {boolean}
199
+ */
200
+ is_fainted(): boolean;
201
+ /**
202
+ */
203
+ faint(): void;
204
+ /**
205
+ */
206
+ decrease_cooldown(): void;
207
+ /**
208
+ */
209
+ color: Color;
210
+ /**
211
+ */
212
+ cooldown: number;
213
+ /**
214
+ */
215
+ kind: MonKind;
216
+ }
217
+ /**
218
+ */
219
+ export class MonsGameModel {
220
+ free(): void;
221
+ /**
222
+ * @returns {MonsGameModel}
223
+ */
224
+ static new(): MonsGameModel;
225
+ /**
226
+ * @param {string} fen
227
+ * @returns {MonsGameModel | undefined}
228
+ */
229
+ static from_fen(fen: string): MonsGameModel | undefined;
230
+ /**
231
+ * @returns {string}
232
+ */
233
+ fen(): string;
234
+ /**
235
+ * @param {(Location)[]} locations
236
+ * @param {Modifier | undefined} [modifier]
237
+ * @returns {OutputModel}
238
+ */
239
+ process_input(locations: (Location)[], modifier?: Modifier): OutputModel;
240
+ /**
241
+ * @param {string} input_fen
242
+ * @returns {OutputModel}
243
+ */
244
+ process_input_fen(input_fen: string): OutputModel;
245
+ /**
246
+ * @param {Location} at
247
+ * @returns {ItemModel | undefined}
248
+ */
249
+ item(at: Location): ItemModel | undefined;
250
+ /**
251
+ * @param {Location} at
252
+ * @returns {SquareModel}
253
+ */
254
+ square(at: Location): SquareModel;
255
+ /**
256
+ * @param {string} other_fen
257
+ * @returns {boolean}
258
+ */
259
+ is_later_than(other_fen: string): boolean;
260
+ /**
261
+ * @returns {Color}
262
+ */
263
+ active_color(): Color;
264
+ /**
265
+ * @returns {Color | undefined}
266
+ */
267
+ winner_color(): Color | undefined;
268
+ /**
269
+ * @returns {number}
270
+ */
271
+ black_score(): number;
272
+ /**
273
+ * @returns {number}
274
+ */
275
+ white_score(): number;
276
+ /**
277
+ * @returns {Int32Array}
278
+ */
279
+ available_move_kinds(): Int32Array;
280
+ /**
281
+ * @returns {(Location)[]}
282
+ */
283
+ locations_with_content(): (Location)[];
284
+ }
285
+ /**
286
+ */
287
+ export class NextInputModel {
288
+ free(): void;
289
+ /**
290
+ */
291
+ actor_mon_item?: ItemModel;
292
+ /**
293
+ */
294
+ kind: NextInputKind;
295
+ /**
296
+ */
297
+ location?: Location;
298
+ /**
299
+ */
300
+ modifier?: Modifier;
301
+ }
302
+ /**
303
+ */
304
+ export class OutputModel {
305
+ free(): void;
306
+ /**
307
+ * @returns {(Location)[]}
308
+ */
309
+ locations(): (Location)[];
310
+ /**
311
+ * @returns {(NextInputModel)[]}
312
+ */
313
+ next_inputs(): (NextInputModel)[];
314
+ /**
315
+ * @returns {(EventModel)[]}
316
+ */
317
+ events(): (EventModel)[];
318
+ /**
319
+ * @returns {string}
320
+ */
321
+ input_fen(): string;
322
+ /**
323
+ */
324
+ kind: OutputModelKind;
325
+ }
326
+ /**
327
+ */
328
+ export class SquareModel {
329
+ free(): void;
330
+ /**
331
+ */
332
+ color?: Color;
333
+ /**
334
+ */
335
+ kind: SquareModelKind;
336
+ /**
337
+ */
338
+ mon_kind?: MonKind;
339
+ }
@@ -1,8 +1,11 @@
1
+ let imports = {};
2
+ imports['__wbindgen_placeholder__'] = module.exports;
1
3
  let wasm;
4
+ const { TextDecoder, TextEncoder } = require(`util`);
2
5
 
3
- const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );
6
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
4
7
 
5
- if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); };
8
+ cachedTextDecoder.decode();
6
9
 
7
10
  let cachedUint8Memory0 = null;
8
11
 
@@ -20,7 +23,7 @@ function getStringFromWasm0(ptr, len) {
20
23
 
21
24
  let WASM_VECTOR_LEN = 0;
22
25
 
23
- const cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available') } } );
26
+ let cachedTextEncoder = new TextEncoder('utf-8');
24
27
 
25
28
  const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
26
29
  ? function (arg, view) {
@@ -164,7 +167,7 @@ function getArrayJsValueFromWasm0(ptr, len) {
164
167
  * @param {string} flat_moves_string_b
165
168
  * @returns {string}
166
169
  */
167
- export function winner(fen_w, fen_b, flat_moves_string_w, flat_moves_string_b) {
170
+ module.exports.winner = function(fen_w, fen_b, flat_moves_string_w, flat_moves_string_b) {
168
171
  let deferred5_0;
169
172
  let deferred5_1;
170
173
  try {
@@ -187,48 +190,48 @@ export function winner(fen_w, fen_b, flat_moves_string_w, flat_moves_string_b) {
187
190
  wasm.__wbindgen_add_to_stack_pointer(16);
188
191
  wasm.__wbindgen_free(deferred5_0, deferred5_1, 1);
189
192
  }
190
- }
193
+ };
191
194
 
192
195
  /**
193
196
  */
194
- 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", });
197
+ 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", });
195
198
  /**
196
199
  */
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", });
200
+ module.exports.Modifier = Object.freeze({ SelectPotion:0,"0":"SelectPotion",SelectBomb:1,"1":"SelectBomb",Cancel:2,"2":"Cancel", });
198
201
  /**
199
202
  */
200
- export const ManaKind = Object.freeze({ Regular:0,"0":"Regular",Supermana:1,"1":"Supermana", });
203
+ module.exports.ManaKind = Object.freeze({ Regular:0,"0":"Regular",Supermana:1,"1":"Supermana", });
201
204
  /**
202
205
  */
203
- export const Modifier = Object.freeze({ SelectPotion:0,"0":"SelectPotion",SelectBomb:1,"1":"SelectBomb",Cancel:2,"2":"Cancel", });
206
+ 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", });
204
207
  /**
205
208
  */
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", });
209
+ module.exports.OutputModelKind = Object.freeze({ InvalidInput:0,"0":"InvalidInput",LocationsToStartFrom:1,"1":"LocationsToStartFrom",NextInputOptions:2,"2":"NextInputOptions",Events:3,"3":"Events", });
207
210
  /**
208
211
  */
209
- export const Color = Object.freeze({ White:0,"0":"White",Black:1,"1":"Black", });
212
+ module.exports.Consumable = Object.freeze({ Potion:0,"0":"Potion",Bomb:1,"1":"Bomb",BombOrPotion:2,"2":"BombOrPotion", });
210
213
  /**
211
214
  */
212
- export const AvailableMoveKind = Object.freeze({ MonMove:0,"0":"MonMove",ManaMove:1,"1":"ManaMove",Action:2,"2":"Action",Potion:3,"3":"Potion", });
215
+ 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", });
213
216
  /**
214
217
  */
215
- export const OutputModelKind = Object.freeze({ InvalidInput:0,"0":"InvalidInput",LocationsToStartFrom:1,"1":"LocationsToStartFrom",NextInputOptions:2,"2":"NextInputOptions",Events:3,"3":"Events", });
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", });
216
219
  /**
217
220
  */
218
- export const Consumable = Object.freeze({ Potion:0,"0":"Potion",Bomb:1,"1":"Bomb",BombOrPotion:2,"2":"BombOrPotion", });
221
+ module.exports.AvailableMoveKind = Object.freeze({ MonMove:0,"0":"MonMove",ManaMove:1,"1":"ManaMove",Action:2,"2":"Action",Potion:3,"3":"Potion", });
219
222
  /**
220
223
  */
221
- 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", });
224
+ 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", });
222
225
  /**
223
226
  */
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", });
227
+ module.exports.Color = Object.freeze({ White:0,"0":"White",Black:1,"1":"Black", });
225
228
 
226
229
  const EventModelFinalization = (typeof FinalizationRegistry === 'undefined')
227
230
  ? { register: () => {}, unregister: () => {} }
228
231
  : new FinalizationRegistry(ptr => wasm.__wbg_eventmodel_free(ptr >>> 0));
229
232
  /**
230
233
  */
231
- export class EventModel {
234
+ class EventModel {
232
235
 
233
236
  static __wrap(ptr) {
234
237
  ptr = ptr >>> 0;
@@ -366,13 +369,14 @@ export class EventModel {
366
369
  wasm.__wbg_set_eventmodel_color(this.__wbg_ptr, isLikeNone(arg0) ? 2 : arg0);
367
370
  }
368
371
  }
372
+ module.exports.EventModel = EventModel;
369
373
 
370
374
  const ItemModelFinalization = (typeof FinalizationRegistry === 'undefined')
371
375
  ? { register: () => {}, unregister: () => {} }
372
376
  : new FinalizationRegistry(ptr => wasm.__wbg_itemmodel_free(ptr >>> 0));
373
377
  /**
374
378
  */
375
- export class ItemModel {
379
+ class ItemModel {
376
380
 
377
381
  static __wrap(ptr) {
378
382
  ptr = ptr >>> 0;
@@ -456,13 +460,14 @@ export class ItemModel {
456
460
  wasm.__wbg_set_itemmodel_consumable(this.__wbg_ptr, isLikeNone(arg0) ? 3 : arg0);
457
461
  }
458
462
  }
463
+ module.exports.ItemModel = ItemModel;
459
464
 
460
465
  const LocationFinalization = (typeof FinalizationRegistry === 'undefined')
461
466
  ? { register: () => {}, unregister: () => {} }
462
467
  : new FinalizationRegistry(ptr => wasm.__wbg_location_free(ptr >>> 0));
463
468
  /**
464
469
  */
465
- export class Location {
470
+ class Location {
466
471
 
467
472
  static __wrap(ptr) {
468
473
  ptr = ptr >>> 0;
@@ -526,13 +531,14 @@ export class Location {
526
531
  return this;
527
532
  }
528
533
  }
534
+ module.exports.Location = Location;
529
535
 
530
536
  const ManaModelFinalization = (typeof FinalizationRegistry === 'undefined')
531
537
  ? { register: () => {}, unregister: () => {} }
532
538
  : new FinalizationRegistry(ptr => wasm.__wbg_manamodel_free(ptr >>> 0));
533
539
  /**
534
540
  */
535
- export class ManaModel {
541
+ class ManaModel {
536
542
 
537
543
  static __wrap(ptr) {
538
544
  ptr = ptr >>> 0;
@@ -580,13 +586,14 @@ export class ManaModel {
580
586
  wasm.__wbg_set_manamodel_color(this.__wbg_ptr, arg0);
581
587
  }
582
588
  }
589
+ module.exports.ManaModel = ManaModel;
583
590
 
584
591
  const MonFinalization = (typeof FinalizationRegistry === 'undefined')
585
592
  ? { register: () => {}, unregister: () => {} }
586
593
  : new FinalizationRegistry(ptr => wasm.__wbg_mon_free(ptr >>> 0));
587
594
  /**
588
595
  */
589
- export class Mon {
596
+ class Mon {
590
597
 
591
598
  static __wrap(ptr) {
592
599
  ptr = ptr >>> 0;
@@ -674,13 +681,14 @@ export class Mon {
674
681
  wasm.mon_decrease_cooldown(this.__wbg_ptr);
675
682
  }
676
683
  }
684
+ module.exports.Mon = Mon;
677
685
 
678
686
  const MonsGameModelFinalization = (typeof FinalizationRegistry === 'undefined')
679
687
  ? { register: () => {}, unregister: () => {} }
680
688
  : new FinalizationRegistry(ptr => wasm.__wbg_monsgamemodel_free(ptr >>> 0));
681
689
  /**
682
690
  */
683
- export class MonsGameModel {
691
+ class MonsGameModel {
684
692
 
685
693
  static __wrap(ptr) {
686
694
  ptr = ptr >>> 0;
@@ -849,13 +857,14 @@ export class MonsGameModel {
849
857
  }
850
858
  }
851
859
  }
860
+ module.exports.MonsGameModel = MonsGameModel;
852
861
 
853
862
  const NextInputModelFinalization = (typeof FinalizationRegistry === 'undefined')
854
863
  ? { register: () => {}, unregister: () => {} }
855
864
  : new FinalizationRegistry(ptr => wasm.__wbg_nextinputmodel_free(ptr >>> 0));
856
865
  /**
857
866
  */
858
- export class NextInputModel {
867
+ class NextInputModel {
859
868
 
860
869
  static __wrap(ptr) {
861
870
  ptr = ptr >>> 0;
@@ -939,13 +948,14 @@ export class NextInputModel {
939
948
  wasm.__wbg_set_nextinputmodel_actor_mon_item(this.__wbg_ptr, ptr0);
940
949
  }
941
950
  }
951
+ module.exports.NextInputModel = NextInputModel;
942
952
 
943
953
  const OutputModelFinalization = (typeof FinalizationRegistry === 'undefined')
944
954
  ? { register: () => {}, unregister: () => {} }
945
955
  : new FinalizationRegistry(ptr => wasm.__wbg_outputmodel_free(ptr >>> 0));
946
956
  /**
947
957
  */
948
- export class OutputModel {
958
+ class OutputModel {
949
959
 
950
960
  static __wrap(ptr) {
951
961
  ptr = ptr >>> 0;
@@ -1047,13 +1057,14 @@ export class OutputModel {
1047
1057
  }
1048
1058
  }
1049
1059
  }
1060
+ module.exports.OutputModel = OutputModel;
1050
1061
 
1051
1062
  const SquareModelFinalization = (typeof FinalizationRegistry === 'undefined')
1052
1063
  ? { register: () => {}, unregister: () => {} }
1053
1064
  : new FinalizationRegistry(ptr => wasm.__wbg_squaremodel_free(ptr >>> 0));
1054
1065
  /**
1055
1066
  */
1056
- export class SquareModel {
1067
+ class SquareModel {
1057
1068
 
1058
1069
  static __wrap(ptr) {
1059
1070
  ptr = ptr >>> 0;
@@ -1114,113 +1125,37 @@ export class SquareModel {
1114
1125
  wasm.__wbg_set_squaremodel_mon_kind(this.__wbg_ptr, isLikeNone(arg0) ? 5 : arg0);
1115
1126
  }
1116
1127
  }
1128
+ module.exports.SquareModel = SquareModel;
1117
1129
 
1118
- async function __wbg_load(module, imports) {
1119
- if (typeof Response === 'function' && module instanceof Response) {
1120
- if (typeof WebAssembly.instantiateStreaming === 'function') {
1121
- try {
1122
- return await WebAssembly.instantiateStreaming(module, imports);
1123
-
1124
- } catch (e) {
1125
- if (module.headers.get('Content-Type') != 'application/wasm') {
1126
- 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);
1127
-
1128
- } else {
1129
- throw e;
1130
- }
1131
- }
1132
- }
1133
-
1134
- const bytes = await module.arrayBuffer();
1135
- return await WebAssembly.instantiate(bytes, imports);
1136
-
1137
- } else {
1138
- const instance = await WebAssembly.instantiate(module, imports);
1139
-
1140
- if (instance instanceof WebAssembly.Instance) {
1141
- return { instance, module };
1142
-
1143
- } else {
1144
- return instance;
1145
- }
1146
- }
1147
- }
1148
-
1149
- function __wbg_get_imports() {
1150
- const imports = {};
1151
- imports.wbg = {};
1152
- imports.wbg.__wbg_eventmodel_new = function(arg0) {
1153
- const ret = EventModel.__wrap(arg0);
1154
- return addHeapObject(ret);
1155
- };
1156
- imports.wbg.__wbg_nextinputmodel_new = function(arg0) {
1157
- const ret = NextInputModel.__wrap(arg0);
1158
- return addHeapObject(ret);
1159
- };
1160
- imports.wbg.__wbg_location_new = function(arg0) {
1161
- const ret = Location.__wrap(arg0);
1162
- return addHeapObject(ret);
1163
- };
1164
- imports.wbg.__wbg_location_unwrap = function(arg0) {
1165
- const ret = Location.__unwrap(takeObject(arg0));
1166
- return ret;
1167
- };
1168
- imports.wbg.__wbindgen_throw = function(arg0, arg1) {
1169
- throw new Error(getStringFromWasm0(arg0, arg1));
1170
- };
1130
+ module.exports.__wbg_location_new = function(arg0) {
1131
+ const ret = Location.__wrap(arg0);
1132
+ return addHeapObject(ret);
1133
+ };
1171
1134
 
1172
- return imports;
1173
- }
1135
+ module.exports.__wbg_nextinputmodel_new = function(arg0) {
1136
+ const ret = NextInputModel.__wrap(arg0);
1137
+ return addHeapObject(ret);
1138
+ };
1174
1139
 
1175
- function __wbg_init_memory(imports, maybe_memory) {
1140
+ module.exports.__wbg_eventmodel_new = function(arg0) {
1141
+ const ret = EventModel.__wrap(arg0);
1142
+ return addHeapObject(ret);
1143
+ };
1176
1144
 
1177
- }
1178
-
1179
- function __wbg_finalize_init(instance, module) {
1180
- wasm = instance.exports;
1181
- __wbg_init.__wbindgen_wasm_module = module;
1182
- cachedInt32Memory0 = null;
1183
- cachedUint32Memory0 = null;
1184
- cachedUint8Memory0 = null;
1185
-
1186
-
1187
- return wasm;
1188
- }
1189
-
1190
- function initSync(module) {
1191
- if (wasm !== undefined) return wasm;
1192
-
1193
- const imports = __wbg_get_imports();
1194
-
1195
- __wbg_init_memory(imports);
1196
-
1197
- if (!(module instanceof WebAssembly.Module)) {
1198
- module = new WebAssembly.Module(module);
1199
- }
1200
-
1201
- const instance = new WebAssembly.Instance(module, imports);
1202
-
1203
- return __wbg_finalize_init(instance, module);
1204
- }
1205
-
1206
- async function __wbg_init(input) {
1207
- if (wasm !== undefined) return wasm;
1208
-
1209
- if (typeof input === 'undefined') {
1210
- input = new URL('mons-web_bg.wasm', import.meta.url);
1211
- }
1212
- const imports = __wbg_get_imports();
1213
-
1214
- if (typeof input === 'string' || (typeof Request === 'function' && input instanceof Request) || (typeof URL === 'function' && input instanceof URL)) {
1215
- input = fetch(input);
1216
- }
1145
+ module.exports.__wbg_location_unwrap = function(arg0) {
1146
+ const ret = Location.__unwrap(takeObject(arg0));
1147
+ return ret;
1148
+ };
1217
1149
 
1218
- __wbg_init_memory(imports);
1150
+ module.exports.__wbindgen_throw = function(arg0, arg1) {
1151
+ throw new Error(getStringFromWasm0(arg0, arg1));
1152
+ };
1219
1153
 
1220
- const { instance, module } = await __wbg_load(await input, imports);
1154
+ const path = require('path').join(__dirname, 'mons-rust_bg.wasm');
1155
+ const bytes = require('fs').readFileSync(path);
1221
1156
 
1222
- return __wbg_finalize_init(instance, module);
1223
- }
1157
+ const wasmModule = new WebAssembly.Module(bytes);
1158
+ const wasmInstance = new WebAssembly.Instance(wasmModule, imports);
1159
+ wasm = wasmInstance.exports;
1160
+ module.exports.__wasm = wasm;
1224
1161
 
1225
- export { initSync }
1226
- export default __wbg_init;
package/package.json CHANGED
@@ -1,20 +1,17 @@
1
1
  {
2
2
  "name": "mons-rust",
3
3
  "description": "super metal mons",
4
- "version": "0.1.25",
4
+ "version": "0.1.27",
5
5
  "license": "CC0-1.0",
6
6
  "repository": {
7
7
  "type": "git",
8
8
  "url": "https://github.com/supermetalmons/mons-rust"
9
9
  },
10
10
  "files": [
11
- "mons-web_bg.wasm",
12
- "mons-web.js",
13
- "mons-web.d.ts"
11
+ "mons-rust_bg.wasm",
12
+ "mons-rust.js",
13
+ "mons-rust.d.ts"
14
14
  ],
15
- "module": "mons-web.js",
16
- "types": "mons-web.d.ts",
17
- "sideEffects": [
18
- "./snippets/*"
19
- ]
15
+ "main": "mons-rust.js",
16
+ "types": "mons-rust.d.ts"
20
17
  }
package/mons-web.d.ts DELETED
@@ -1,455 +0,0 @@
1
- /* tslint:disable */
2
- /* eslint-disable */
3
- /**
4
- * @param {string} fen_w
5
- * @param {string} fen_b
6
- * @param {string} flat_moves_string_w
7
- * @param {string} flat_moves_string_b
8
- * @returns {string}
9
- */
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 EventModelKind {
14
- MonMove = 0,
15
- ManaMove = 1,
16
- ManaScored = 2,
17
- MysticAction = 3,
18
- DemonAction = 4,
19
- DemonAdditionalStep = 5,
20
- SpiritTargetMove = 6,
21
- PickupBomb = 7,
22
- PickupPotion = 8,
23
- PickupMana = 9,
24
- MonFainted = 10,
25
- ManaDropped = 11,
26
- SupermanaBackToBase = 12,
27
- BombAttack = 13,
28
- MonAwake = 14,
29
- BombExplosion = 15,
30
- NextTurn = 16,
31
- GameOver = 17,
32
- }
33
- /**
34
- */
35
- export enum NextInputKind {
36
- MonMove = 0,
37
- ManaMove = 1,
38
- MysticAction = 2,
39
- DemonAction = 3,
40
- DemonAdditionalStep = 4,
41
- SpiritTargetCapture = 5,
42
- SpiritTargetMove = 6,
43
- SelectConsumable = 7,
44
- BombAttack = 8,
45
- }
46
- /**
47
- */
48
- export enum ManaKind {
49
- Regular = 0,
50
- Supermana = 1,
51
- }
52
- /**
53
- */
54
- export enum Modifier {
55
- SelectPotion = 0,
56
- SelectBomb = 1,
57
- Cancel = 2,
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 Color {
72
- White = 0,
73
- Black = 1,
74
- }
75
- /**
76
- */
77
- export enum AvailableMoveKind {
78
- MonMove = 0,
79
- ManaMove = 1,
80
- Action = 2,
81
- Potion = 3,
82
- }
83
- /**
84
- */
85
- export enum OutputModelKind {
86
- InvalidInput = 0,
87
- LocationsToStartFrom = 1,
88
- NextInputOptions = 2,
89
- Events = 3,
90
- }
91
- /**
92
- */
93
- export enum Consumable {
94
- Potion = 0,
95
- Bomb = 1,
96
- BombOrPotion = 2,
97
- }
98
- /**
99
- */
100
- export enum ItemModelKind {
101
- Mon = 0,
102
- Mana = 1,
103
- MonWithMana = 2,
104
- MonWithConsumable = 3,
105
- Consumable = 4,
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
- color?: Color;
123
- /**
124
- */
125
- item?: ItemModel;
126
- /**
127
- */
128
- kind: EventModelKind;
129
- /**
130
- */
131
- loc1?: Location;
132
- /**
133
- */
134
- loc2?: Location;
135
- /**
136
- */
137
- mana?: ManaModel;
138
- /**
139
- */
140
- mon?: Mon;
141
- }
142
- /**
143
- */
144
- export class ItemModel {
145
- free(): void;
146
- /**
147
- */
148
- consumable?: Consumable;
149
- /**
150
- */
151
- kind: ItemModelKind;
152
- /**
153
- */
154
- mana?: ManaModel;
155
- /**
156
- */
157
- mon?: Mon;
158
- }
159
- /**
160
- */
161
- export class Location {
162
- free(): void;
163
- /**
164
- * @param {number} i
165
- * @param {number} j
166
- */
167
- constructor(i: number, j: number);
168
- /**
169
- */
170
- i: number;
171
- /**
172
- */
173
- j: number;
174
- }
175
- /**
176
- */
177
- export class ManaModel {
178
- free(): void;
179
- /**
180
- */
181
- color: Color;
182
- /**
183
- */
184
- kind: ManaKind;
185
- }
186
- /**
187
- */
188
- export class Mon {
189
- free(): void;
190
- /**
191
- * @param {MonKind} kind
192
- * @param {Color} color
193
- * @param {number} cooldown
194
- * @returns {Mon}
195
- */
196
- static new(kind: MonKind, color: Color, cooldown: number): Mon;
197
- /**
198
- * @returns {boolean}
199
- */
200
- is_fainted(): boolean;
201
- /**
202
- */
203
- faint(): void;
204
- /**
205
- */
206
- decrease_cooldown(): void;
207
- /**
208
- */
209
- color: Color;
210
- /**
211
- */
212
- cooldown: number;
213
- /**
214
- */
215
- kind: MonKind;
216
- }
217
- /**
218
- */
219
- export class MonsGameModel {
220
- free(): void;
221
- /**
222
- * @returns {MonsGameModel}
223
- */
224
- static new(): MonsGameModel;
225
- /**
226
- * @param {string} fen
227
- * @returns {MonsGameModel | undefined}
228
- */
229
- static from_fen(fen: string): MonsGameModel | undefined;
230
- /**
231
- * @returns {string}
232
- */
233
- fen(): string;
234
- /**
235
- * @param {(Location)[]} locations
236
- * @param {Modifier | undefined} [modifier]
237
- * @returns {OutputModel}
238
- */
239
- process_input(locations: (Location)[], modifier?: Modifier): OutputModel;
240
- /**
241
- * @param {string} input_fen
242
- * @returns {OutputModel}
243
- */
244
- process_input_fen(input_fen: string): OutputModel;
245
- /**
246
- * @param {Location} at
247
- * @returns {ItemModel | undefined}
248
- */
249
- item(at: Location): ItemModel | undefined;
250
- /**
251
- * @param {Location} at
252
- * @returns {SquareModel}
253
- */
254
- square(at: Location): SquareModel;
255
- /**
256
- * @param {string} other_fen
257
- * @returns {boolean}
258
- */
259
- is_later_than(other_fen: string): boolean;
260
- /**
261
- * @returns {Color}
262
- */
263
- active_color(): Color;
264
- /**
265
- * @returns {Color | undefined}
266
- */
267
- winner_color(): Color | undefined;
268
- /**
269
- * @returns {number}
270
- */
271
- black_score(): number;
272
- /**
273
- * @returns {number}
274
- */
275
- white_score(): number;
276
- /**
277
- * @returns {Int32Array}
278
- */
279
- available_move_kinds(): Int32Array;
280
- /**
281
- * @returns {(Location)[]}
282
- */
283
- locations_with_content(): (Location)[];
284
- }
285
- /**
286
- */
287
- export class NextInputModel {
288
- free(): void;
289
- /**
290
- */
291
- actor_mon_item?: ItemModel;
292
- /**
293
- */
294
- kind: NextInputKind;
295
- /**
296
- */
297
- location?: Location;
298
- /**
299
- */
300
- modifier?: Modifier;
301
- }
302
- /**
303
- */
304
- export class OutputModel {
305
- free(): void;
306
- /**
307
- * @returns {(Location)[]}
308
- */
309
- locations(): (Location)[];
310
- /**
311
- * @returns {(NextInputModel)[]}
312
- */
313
- next_inputs(): (NextInputModel)[];
314
- /**
315
- * @returns {(EventModel)[]}
316
- */
317
- events(): (EventModel)[];
318
- /**
319
- * @returns {string}
320
- */
321
- input_fen(): string;
322
- /**
323
- */
324
- kind: OutputModelKind;
325
- }
326
- /**
327
- */
328
- export class SquareModel {
329
- free(): void;
330
- /**
331
- */
332
- color?: Color;
333
- /**
334
- */
335
- kind: SquareModelKind;
336
- /**
337
- */
338
- mon_kind?: MonKind;
339
- }
340
-
341
- export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
342
-
343
- export interface InitOutput {
344
- readonly memory: WebAssembly.Memory;
345
- readonly __wbg_monsgamemodel_free: (a: number) => void;
346
- readonly monsgamemodel_new: () => number;
347
- readonly monsgamemodel_from_fen: (a: number, b: number) => number;
348
- readonly monsgamemodel_fen: (a: number, b: number) => void;
349
- readonly monsgamemodel_process_input: (a: number, b: number, c: number, d: number) => number;
350
- readonly monsgamemodel_process_input_fen: (a: number, b: number, c: number) => number;
351
- readonly monsgamemodel_item: (a: number, b: number) => number;
352
- readonly monsgamemodel_square: (a: number, b: number) => number;
353
- readonly monsgamemodel_is_later_than: (a: number, b: number, c: number) => number;
354
- readonly monsgamemodel_active_color: (a: number) => number;
355
- readonly monsgamemodel_winner_color: (a: number) => number;
356
- readonly monsgamemodel_black_score: (a: number) => number;
357
- readonly monsgamemodel_white_score: (a: number) => number;
358
- readonly monsgamemodel_available_move_kinds: (a: number, b: number) => void;
359
- readonly monsgamemodel_locations_with_content: (a: number, b: number) => void;
360
- readonly __wbg_outputmodel_free: (a: number) => void;
361
- readonly __wbg_get_outputmodel_kind: (a: number) => number;
362
- readonly __wbg_set_outputmodel_kind: (a: number, b: number) => void;
363
- readonly outputmodel_locations: (a: number, b: number) => void;
364
- readonly outputmodel_next_inputs: (a: number, b: number) => void;
365
- readonly outputmodel_events: (a: number, b: number) => void;
366
- readonly outputmodel_input_fen: (a: number, b: number) => void;
367
- readonly __wbg_get_squaremodel_kind: (a: number) => number;
368
- readonly __wbg_set_squaremodel_kind: (a: number, b: number) => void;
369
- readonly __wbg_get_squaremodel_color: (a: number) => number;
370
- readonly __wbg_set_squaremodel_color: (a: number, b: number) => void;
371
- readonly __wbg_get_squaremodel_mon_kind: (a: number) => number;
372
- readonly __wbg_set_squaremodel_mon_kind: (a: number, b: number) => void;
373
- readonly __wbg_itemmodel_free: (a: number) => void;
374
- readonly __wbg_get_itemmodel_kind: (a: number) => number;
375
- readonly __wbg_set_itemmodel_kind: (a: number, b: number) => void;
376
- readonly __wbg_get_itemmodel_mon: (a: number) => number;
377
- readonly __wbg_set_itemmodel_mon: (a: number, b: number) => void;
378
- readonly __wbg_get_itemmodel_mana: (a: number) => number;
379
- readonly __wbg_set_itemmodel_mana: (a: number, b: number) => void;
380
- readonly __wbg_get_itemmodel_consumable: (a: number) => number;
381
- readonly __wbg_set_itemmodel_consumable: (a: number, b: number) => void;
382
- readonly __wbg_manamodel_free: (a: number) => void;
383
- readonly __wbg_get_manamodel_kind: (a: number) => number;
384
- readonly __wbg_set_manamodel_kind: (a: number, b: number) => void;
385
- readonly __wbg_get_manamodel_color: (a: number) => number;
386
- readonly __wbg_set_manamodel_color: (a: number, b: number) => void;
387
- readonly __wbg_nextinputmodel_free: (a: number) => void;
388
- readonly __wbg_get_nextinputmodel_modifier: (a: number) => number;
389
- readonly __wbg_set_nextinputmodel_modifier: (a: number, b: number) => void;
390
- readonly __wbg_get_nextinputmodel_kind: (a: number) => number;
391
- readonly __wbg_set_nextinputmodel_kind: (a: number, b: number) => void;
392
- readonly __wbg_get_nextinputmodel_actor_mon_item: (a: number) => number;
393
- readonly __wbg_set_nextinputmodel_actor_mon_item: (a: number, b: number) => void;
394
- readonly __wbg_eventmodel_free: (a: number) => void;
395
- readonly __wbg_get_eventmodel_kind: (a: number) => number;
396
- readonly __wbg_set_eventmodel_kind: (a: number, b: number) => void;
397
- readonly __wbg_get_eventmodel_item: (a: number) => number;
398
- readonly __wbg_set_eventmodel_item: (a: number, b: number) => void;
399
- readonly __wbg_get_eventmodel_mon: (a: number) => number;
400
- readonly __wbg_set_eventmodel_mon: (a: number, b: number) => void;
401
- readonly __wbg_get_eventmodel_mana: (a: number) => number;
402
- readonly __wbg_set_eventmodel_mana: (a: number, b: number) => void;
403
- readonly __wbg_get_eventmodel_loc1: (a: number) => number;
404
- readonly __wbg_set_eventmodel_loc1: (a: number, b: number) => void;
405
- readonly __wbg_get_eventmodel_loc2: (a: number) => number;
406
- readonly __wbg_set_eventmodel_loc2: (a: number, b: number) => void;
407
- readonly __wbg_get_eventmodel_color: (a: number) => number;
408
- readonly __wbg_set_eventmodel_color: (a: number, b: number) => void;
409
- readonly __wbg_get_nextinputmodel_location: (a: number) => number;
410
- readonly __wbg_set_nextinputmodel_location: (a: number, b: number) => void;
411
- readonly __wbg_squaremodel_free: (a: number) => void;
412
- readonly __wbg_mon_free: (a: number) => void;
413
- readonly __wbg_get_mon_kind: (a: number) => number;
414
- readonly __wbg_set_mon_kind: (a: number, b: number) => void;
415
- readonly __wbg_get_mon_color: (a: number) => number;
416
- readonly __wbg_set_mon_color: (a: number, b: number) => void;
417
- readonly __wbg_get_mon_cooldown: (a: number) => number;
418
- readonly __wbg_set_mon_cooldown: (a: number, b: number) => void;
419
- readonly mon_new: (a: number, b: number, c: number) => number;
420
- readonly mon_is_fainted: (a: number) => number;
421
- readonly mon_faint: (a: number) => void;
422
- readonly mon_decrease_cooldown: (a: number) => void;
423
- readonly __wbg_location_free: (a: number) => void;
424
- readonly __wbg_get_location_i: (a: number) => number;
425
- readonly __wbg_set_location_i: (a: number, b: number) => void;
426
- readonly __wbg_get_location_j: (a: number) => number;
427
- readonly __wbg_set_location_j: (a: number, b: number) => void;
428
- readonly location_new: (a: number, b: number) => number;
429
- readonly winner: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => void;
430
- readonly __wbindgen_malloc: (a: number, b: number) => number;
431
- readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
432
- readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
433
- readonly __wbindgen_free: (a: number, b: number, c: number) => void;
434
- }
435
-
436
- export type SyncInitInput = BufferSource | WebAssembly.Module;
437
- /**
438
- * Instantiates the given `module`, which can either be bytes or
439
- * a precompiled `WebAssembly.Module`.
440
- *
441
- * @param {SyncInitInput} module
442
- *
443
- * @returns {InitOutput}
444
- */
445
- export function initSync(module: SyncInitInput): InitOutput;
446
-
447
- /**
448
- * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
449
- * for everything else, calls `WebAssembly.instantiate` directly.
450
- *
451
- * @param {InitInput | Promise<InitInput>} module_or_path
452
- *
453
- * @returns {Promise<InitOutput>}
454
- */
455
- export default function __wbg_init (module_or_path?: InitInput | Promise<InitInput>): Promise<InitOutput>;