mons-web 0.1.7 → 0.1.9

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
@@ -1,10 +1,6 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
3
  /**
4
- * @returns {string}
5
- */
6
- export function hello(): string;
7
- /**
8
4
  * @param {string} fen_w
9
5
  * @param {string} fen_b
10
6
  * @param {string} flat_moves_string_w
@@ -14,6 +10,29 @@ export function hello(): string;
14
10
  export function winner(fen_w: string, fen_b: string, flat_moves_string_w: string, flat_moves_string_b: string): string;
15
11
  /**
16
12
  */
13
+ export enum AvailableMoveKind {
14
+ MonMove = 0,
15
+ ManaMove = 1,
16
+ Action = 2,
17
+ Potion = 3,
18
+ }
19
+ /**
20
+ */
21
+ export enum MonKind {
22
+ Demon = 0,
23
+ Drainer = 1,
24
+ Angel = 2,
25
+ Spirit = 3,
26
+ Mystic = 4,
27
+ }
28
+ /**
29
+ */
30
+ export enum Color {
31
+ White = 0,
32
+ Black = 1,
33
+ }
34
+ /**
35
+ */
17
36
  export enum Modifier {
18
37
  SelectPotion = 0,
19
38
  SelectBomb = 1,
@@ -21,37 +40,115 @@ export enum Modifier {
21
40
  }
22
41
  /**
23
42
  */
24
- export enum Color {
25
- White = 0,
26
- Black = 1,
43
+ export enum Consumable {
44
+ Potion = 0,
45
+ Bomb = 1,
46
+ BombOrPotion = 2,
47
+ }
48
+ /**
49
+ */
50
+ export enum NextInputKind {
51
+ MonMove = 0,
52
+ ManaMove = 1,
53
+ MysticAction = 2,
54
+ DemonAction = 3,
55
+ DemonAdditionalStep = 4,
56
+ SpiritTargetCapture = 5,
57
+ SpiritTargetMove = 6,
58
+ SelectConsumable = 7,
59
+ BombAttack = 8,
27
60
  }
28
61
  /**
29
62
  */
30
63
  export class Location {
31
64
  free(): void;
32
65
  /**
66
+ * @param {number} i
67
+ * @param {number} j
68
+ */
69
+ constructor(i: number, j: number);
70
+ /**
33
71
  */
34
72
  i: number;
35
73
  /**
36
74
  */
37
75
  j: number;
38
76
  }
77
+ /**
78
+ */
79
+ export class Mon {
80
+ free(): void;
81
+ /**
82
+ * @param {MonKind} kind
83
+ * @param {Color} color
84
+ * @param {number} cooldown
85
+ * @returns {Mon}
86
+ */
87
+ static new(kind: MonKind, color: Color, cooldown: number): Mon;
88
+ /**
89
+ * @returns {boolean}
90
+ */
91
+ is_fainted(): boolean;
92
+ /**
93
+ */
94
+ faint(): void;
95
+ /**
96
+ */
97
+ decrease_cooldown(): void;
98
+ /**
99
+ */
100
+ color: Color;
101
+ /**
102
+ */
103
+ cooldown: number;
104
+ /**
105
+ */
106
+ kind: MonKind;
107
+ }
108
+ /**
109
+ */
110
+ export class MonsGameModel {
111
+ free(): void;
112
+ /**
113
+ * @param {string} fen
114
+ * @returns {MonsGameModel | undefined}
115
+ */
116
+ static from_fen(fen: string): MonsGameModel | undefined;
117
+ /**
118
+ * @returns {string}
119
+ */
120
+ fen(): string;
121
+ }
39
122
 
40
123
  export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
41
124
 
42
125
  export interface InitOutput {
43
126
  readonly memory: WebAssembly.Memory;
127
+ readonly winner: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => void;
128
+ readonly __wbg_mon_free: (a: number) => void;
129
+ readonly __wbg_get_mon_kind: (a: number) => number;
130
+ readonly __wbg_set_mon_kind: (a: number, b: number) => void;
131
+ readonly __wbg_get_mon_color: (a: number) => number;
132
+ readonly __wbg_set_mon_color: (a: number, b: number) => void;
133
+ readonly __wbg_get_mon_cooldown: (a: number) => number;
134
+ readonly __wbg_set_mon_cooldown: (a: number, b: number) => void;
135
+ readonly mon_new: (a: number, b: number, c: number) => number;
136
+ readonly mon_is_fainted: (a: number) => number;
137
+ readonly mon_faint: (a: number) => void;
138
+ readonly mon_decrease_cooldown: (a: number) => void;
139
+ readonly __wbg_monsgamemodel_free: (a: number) => void;
140
+ readonly monsgamemodel_from_fen: (a: number, b: number) => number;
141
+ readonly monsgamemodel_fen: (a: number, b: number) => void;
44
142
  readonly __wbg_location_free: (a: number) => void;
45
143
  readonly __wbg_get_location_i: (a: number) => number;
46
144
  readonly __wbg_set_location_i: (a: number, b: number) => void;
47
145
  readonly __wbg_get_location_j: (a: number) => number;
48
146
  readonly __wbg_set_location_j: (a: number, b: number) => void;
49
- readonly hello: (a: number) => void;
50
- readonly winner: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => void;
147
+ readonly location_new: (a: number, b: number) => number;
51
148
  readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
52
- readonly __wbindgen_free: (a: number, b: number, c: number) => void;
53
149
  readonly __wbindgen_malloc: (a: number, b: number) => number;
54
150
  readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
151
+ readonly __wbindgen_free: (a: number, b: number, c: number) => void;
55
152
  }
56
153
 
57
154
  export type SyncInitInput = BufferSource | WebAssembly.Module;
package/mons_rust.js CHANGED
@@ -18,34 +18,6 @@ function getStringFromWasm0(ptr, len) {
18
18
  return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
19
19
  }
20
20
 
21
- let cachedInt32Memory0 = null;
22
-
23
- function getInt32Memory0() {
24
- if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) {
25
- cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);
26
- }
27
- return cachedInt32Memory0;
28
- }
29
- /**
30
- * @returns {string}
31
- */
32
- export function hello() {
33
- let deferred1_0;
34
- let deferred1_1;
35
- try {
36
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
37
- wasm.hello(retptr);
38
- var r0 = getInt32Memory0()[retptr / 4 + 0];
39
- var r1 = getInt32Memory0()[retptr / 4 + 1];
40
- deferred1_0 = r0;
41
- deferred1_1 = r1;
42
- return getStringFromWasm0(r0, r1);
43
- } finally {
44
- wasm.__wbindgen_add_to_stack_pointer(16);
45
- wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
46
- }
47
- }
48
-
49
21
  let WASM_VECTOR_LEN = 0;
50
22
 
51
23
  const cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available') } } );
@@ -101,6 +73,15 @@ function passStringToWasm0(arg, malloc, realloc) {
101
73
  WASM_VECTOR_LEN = offset;
102
74
  return ptr;
103
75
  }
76
+
77
+ let cachedInt32Memory0 = null;
78
+
79
+ function getInt32Memory0() {
80
+ if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) {
81
+ cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);
82
+ }
83
+ return cachedInt32Memory0;
84
+ }
104
85
  /**
105
86
  * @param {string} fen_w
106
87
  * @param {string} fen_b
@@ -135,10 +116,22 @@ export function winner(fen_w, fen_b, flat_moves_string_w, flat_moves_string_b) {
135
116
 
136
117
  /**
137
118
  */
138
- export const Modifier = Object.freeze({ SelectPotion:0,"0":"SelectPotion",SelectBomb:1,"1":"SelectBomb",Cancel:2,"2":"Cancel", });
119
+ export const AvailableMoveKind = Object.freeze({ MonMove:0,"0":"MonMove",ManaMove:1,"1":"ManaMove",Action:2,"2":"Action",Potion:3,"3":"Potion", });
120
+ /**
121
+ */
122
+ 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", });
139
123
  /**
140
124
  */
141
125
  export const Color = Object.freeze({ White:0,"0":"White",Black:1,"1":"Black", });
126
+ /**
127
+ */
128
+ export const Modifier = Object.freeze({ SelectPotion:0,"0":"SelectPotion",SelectBomb:1,"1":"SelectBomb",Cancel:2,"2":"Cancel", });
129
+ /**
130
+ */
131
+ export const Consumable = Object.freeze({ Potion:0,"0":"Potion",Bomb:1,"1":"Bomb",BombOrPotion:2,"2":"BombOrPotion", });
132
+ /**
133
+ */
134
+ 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", });
142
135
 
143
136
  const LocationFinalization = (typeof FinalizationRegistry === 'undefined')
144
137
  ? { register: () => {}, unregister: () => {} }
@@ -184,6 +177,166 @@ export class Location {
184
177
  set j(arg0) {
185
178
  wasm.__wbg_set_location_j(this.__wbg_ptr, arg0);
186
179
  }
180
+ /**
181
+ * @param {number} i
182
+ * @param {number} j
183
+ */
184
+ constructor(i, j) {
185
+ const ret = wasm.location_new(i, j);
186
+ this.__wbg_ptr = ret >>> 0;
187
+ return this;
188
+ }
189
+ }
190
+
191
+ const MonFinalization = (typeof FinalizationRegistry === 'undefined')
192
+ ? { register: () => {}, unregister: () => {} }
193
+ : new FinalizationRegistry(ptr => wasm.__wbg_mon_free(ptr >>> 0));
194
+ /**
195
+ */
196
+ export class Mon {
197
+
198
+ static __wrap(ptr) {
199
+ ptr = ptr >>> 0;
200
+ const obj = Object.create(Mon.prototype);
201
+ obj.__wbg_ptr = ptr;
202
+ MonFinalization.register(obj, obj.__wbg_ptr, obj);
203
+ return obj;
204
+ }
205
+
206
+ __destroy_into_raw() {
207
+ const ptr = this.__wbg_ptr;
208
+ this.__wbg_ptr = 0;
209
+ MonFinalization.unregister(this);
210
+ return ptr;
211
+ }
212
+
213
+ free() {
214
+ const ptr = this.__destroy_into_raw();
215
+ wasm.__wbg_mon_free(ptr);
216
+ }
217
+ /**
218
+ * @returns {MonKind}
219
+ */
220
+ get kind() {
221
+ const ret = wasm.__wbg_get_mon_kind(this.__wbg_ptr);
222
+ return ret;
223
+ }
224
+ /**
225
+ * @param {MonKind} arg0
226
+ */
227
+ set kind(arg0) {
228
+ wasm.__wbg_set_mon_kind(this.__wbg_ptr, arg0);
229
+ }
230
+ /**
231
+ * @returns {Color}
232
+ */
233
+ get color() {
234
+ const ret = wasm.__wbg_get_mon_color(this.__wbg_ptr);
235
+ return ret;
236
+ }
237
+ /**
238
+ * @param {Color} arg0
239
+ */
240
+ set color(arg0) {
241
+ wasm.__wbg_set_mon_color(this.__wbg_ptr, arg0);
242
+ }
243
+ /**
244
+ * @returns {number}
245
+ */
246
+ get cooldown() {
247
+ const ret = wasm.__wbg_get_mon_cooldown(this.__wbg_ptr);
248
+ return ret;
249
+ }
250
+ /**
251
+ * @param {number} arg0
252
+ */
253
+ set cooldown(arg0) {
254
+ wasm.__wbg_set_mon_cooldown(this.__wbg_ptr, arg0);
255
+ }
256
+ /**
257
+ * @param {MonKind} kind
258
+ * @param {Color} color
259
+ * @param {number} cooldown
260
+ * @returns {Mon}
261
+ */
262
+ static new(kind, color, cooldown) {
263
+ const ret = wasm.mon_new(kind, color, cooldown);
264
+ return Mon.__wrap(ret);
265
+ }
266
+ /**
267
+ * @returns {boolean}
268
+ */
269
+ is_fainted() {
270
+ const ret = wasm.mon_is_fainted(this.__wbg_ptr);
271
+ return ret !== 0;
272
+ }
273
+ /**
274
+ */
275
+ faint() {
276
+ wasm.mon_faint(this.__wbg_ptr);
277
+ }
278
+ /**
279
+ */
280
+ decrease_cooldown() {
281
+ wasm.mon_decrease_cooldown(this.__wbg_ptr);
282
+ }
283
+ }
284
+
285
+ const MonsGameModelFinalization = (typeof FinalizationRegistry === 'undefined')
286
+ ? { register: () => {}, unregister: () => {} }
287
+ : new FinalizationRegistry(ptr => wasm.__wbg_monsgamemodel_free(ptr >>> 0));
288
+ /**
289
+ */
290
+ export class MonsGameModel {
291
+
292
+ static __wrap(ptr) {
293
+ ptr = ptr >>> 0;
294
+ const obj = Object.create(MonsGameModel.prototype);
295
+ obj.__wbg_ptr = ptr;
296
+ MonsGameModelFinalization.register(obj, obj.__wbg_ptr, obj);
297
+ return obj;
298
+ }
299
+
300
+ __destroy_into_raw() {
301
+ const ptr = this.__wbg_ptr;
302
+ this.__wbg_ptr = 0;
303
+ MonsGameModelFinalization.unregister(this);
304
+ return ptr;
305
+ }
306
+
307
+ free() {
308
+ const ptr = this.__destroy_into_raw();
309
+ wasm.__wbg_monsgamemodel_free(ptr);
310
+ }
311
+ /**
312
+ * @param {string} fen
313
+ * @returns {MonsGameModel | undefined}
314
+ */
315
+ static from_fen(fen) {
316
+ const ptr0 = passStringToWasm0(fen, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
317
+ const len0 = WASM_VECTOR_LEN;
318
+ const ret = wasm.monsgamemodel_from_fen(ptr0, len0);
319
+ return ret === 0 ? undefined : MonsGameModel.__wrap(ret);
320
+ }
321
+ /**
322
+ * @returns {string}
323
+ */
324
+ fen() {
325
+ let deferred1_0;
326
+ let deferred1_1;
327
+ try {
328
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
329
+ wasm.monsgamemodel_fen(retptr, this.__wbg_ptr);
330
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
331
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
332
+ deferred1_0 = r0;
333
+ deferred1_1 = r1;
334
+ return getStringFromWasm0(r0, r1);
335
+ } finally {
336
+ wasm.__wbindgen_add_to_stack_pointer(16);
337
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
338
+ }
339
+ }
187
340
  }
188
341
 
189
342
  async function __wbg_load(module, imports) {
package/mons_rust_bg.wasm CHANGED
Binary file
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "mons-web",
3
3
  "description": "super metal mons",
4
- "version": "0.1.7",
4
+ "version": "0.1.9",
5
5
  "license": "CC0-1.0",
6
6
  "files": [
7
7
  "mons_rust_bg.wasm",