mons-rules 0.2.0 → 0.2.3

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-rules.d.ts CHANGED
@@ -1,15 +1,6 @@
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
- */
1
+ // prettier-ignore
10
2
  export function winner(fen_w: string, fen_b: string, flat_moves_string_w: string, flat_moves_string_b: string): string;
11
- /**
12
- */
3
+
13
4
  export enum EventModelKind {
14
5
  MonMove = 0,
15
6
  ManaMove = 1,
@@ -32,15 +23,13 @@ export enum EventModelKind {
32
23
  Takeback = 18,
33
24
  UsePotion = 19,
34
25
  }
35
- /**
36
- */
26
+
37
27
  export enum Consumable {
38
28
  Potion = 0,
39
29
  Bomb = 1,
40
30
  BombOrPotion = 2,
41
31
  }
42
- /**
43
- */
32
+
44
33
  export enum SquareModelKind {
45
34
  Regular = 0,
46
35
  ConsumableBase = 1,
@@ -49,8 +38,7 @@ export enum SquareModelKind {
49
38
  ManaPool = 4,
50
39
  MonBase = 5,
51
40
  }
52
- /**
53
- */
41
+
54
42
  export enum NextInputKind {
55
43
  MonMove = 0,
56
44
  ManaMove = 1,
@@ -62,30 +50,26 @@ export enum NextInputKind {
62
50
  SelectConsumable = 7,
63
51
  BombAttack = 8,
64
52
  }
65
- /**
66
- */
53
+
67
54
  export enum OutputModelKind {
68
55
  InvalidInput = 0,
69
56
  LocationsToStartFrom = 1,
70
57
  NextInputOptions = 2,
71
58
  Events = 3,
72
59
  }
73
- /**
74
- */
60
+
75
61
  export enum ManaKind {
76
62
  Regular = 0,
77
63
  Supermana = 1,
78
64
  }
79
- /**
80
- */
65
+
81
66
  export enum AvailableMoveKind {
82
67
  MonMove = 0,
83
68
  ManaMove = 1,
84
69
  Action = 2,
85
70
  Potion = 3,
86
71
  }
87
- /**
88
- */
72
+
89
73
  export enum MonKind {
90
74
  Demon = 0,
91
75
  Drainer = 1,
@@ -93,8 +77,7 @@ export enum MonKind {
93
77
  Spirit = 3,
94
78
  Mystic = 4,
95
79
  }
96
- /**
97
- */
80
+
98
81
  export enum GameVariant {
99
82
  Classic = 0,
100
83
  SwappedManaRows = 1,
@@ -109,8 +92,7 @@ export enum GameVariant {
109
92
  ForwardBridgeManaRows = 10,
110
93
  CornerChainManaRows = 11,
111
94
  }
112
- /**
113
- */
95
+
114
96
  export enum ItemModelKind {
115
97
  Mon = 0,
116
98
  Mana = 1,
@@ -118,332 +100,127 @@ export enum ItemModelKind {
118
100
  MonWithConsumable = 3,
119
101
  Consumable = 4,
120
102
  }
121
- /**
122
- */
103
+
123
104
  export enum Modifier {
124
105
  SelectPotion = 0,
125
106
  SelectBomb = 1,
126
107
  Cancel = 2,
127
108
  }
128
- /**
129
- */
109
+
130
110
  export enum Color {
131
111
  White = 0,
132
112
  Black = 1,
133
113
  }
134
- /**
135
- */
114
+
136
115
  export class EventModel {
137
116
  free(): void;
138
- /**
139
- */
140
117
  color?: Color;
141
- /**
142
- */
143
118
  item?: ItemModel;
144
- /**
145
- */
146
119
  kind: EventModelKind;
147
- /**
148
- */
149
120
  loc1?: Location;
150
- /**
151
- */
152
121
  loc2?: Location;
153
- /**
154
- */
155
122
  mana?: ManaModel;
156
- /**
157
- */
158
123
  mon?: Mon;
159
124
  }
160
- /**
161
- */
125
+
162
126
  export class ItemModel {
163
127
  free(): void;
164
- /**
165
- */
166
128
  consumable?: Consumable;
167
- /**
168
- */
169
129
  kind: ItemModelKind;
170
- /**
171
- */
172
130
  mana?: ManaModel;
173
- /**
174
- */
175
131
  mon?: Mon;
176
132
  }
177
- /**
178
- */
133
+
179
134
  export class Location {
180
135
  free(): void;
181
- /**
182
- * @param {number} i
183
- * @param {number} j
184
- */
185
136
  constructor(i: number, j: number);
186
- /**
187
- */
188
137
  i: number;
189
- /**
190
- */
191
138
  j: number;
192
139
  }
193
- /**
194
- */
140
+
195
141
  export class ManaModel {
196
142
  free(): void;
197
- /**
198
- */
199
143
  color: Color;
200
- /**
201
- */
202
144
  kind: ManaKind;
203
145
  }
204
- /**
205
- */
146
+
206
147
  export class Mon {
207
148
  free(): void;
208
- /**
209
- * @returns {boolean}
210
- */
211
149
  is_fainted(): boolean;
212
- /**
213
- */
214
150
  decrease_cooldown(): void;
215
- /**
216
- * @param {MonKind} kind
217
- * @param {Color} color
218
- * @param {number} cooldown
219
- * @returns {Mon}
220
- */
221
151
  static new(kind: MonKind, color: Color, cooldown: number): Mon;
222
- /**
223
- */
224
152
  faint(): void;
225
- /**
226
- */
227
153
  color: Color;
228
- /**
229
- */
230
154
  cooldown: number;
231
- /**
232
- */
233
155
  kind: MonKind;
234
156
  }
235
- /**
236
- */
157
+
158
+ // prettier-ignore
237
159
  export class MonsGameModel {
238
160
  free(): void;
239
- /**
240
- * @returns {number}
241
- */
242
161
  black_score(): number;
243
- /**
244
- * @param {Location} location
245
- */
246
162
  remove_item(location: Location): void;
247
- /**
248
- * @returns {number}
249
- */
250
163
  turn_number(): number;
251
- /**
252
- * @returns {number}
253
- */
254
164
  white_score(): number;
255
- /**
256
- * @returns {Color}
257
- */
258
165
  active_color(): Color;
259
- /**
260
- * @param {Color} color
261
- * @returns {boolean}
262
- */
263
166
  can_takeback(color: Color): boolean;
264
- /**
265
- * @param {string} flat_moves_string_w
266
- * @param {string} flat_moves_string_b
267
- * @returns {boolean}
268
- */
167
+ // prettier-ignore
269
168
  verify_moves(flat_moves_string_w: string, flat_moves_string_b: string): boolean;
270
- /**
271
- * @returns {Color | undefined}
272
- */
273
169
  winner_color(): Color | undefined;
274
- /**
275
- * @param {string} other_fen
276
- * @returns {boolean}
277
- */
278
170
  is_later_than(other_fen: string): boolean;
279
- /**
280
- * @param {(Location)[]} locations
281
- * @param {Modifier | undefined} [modifier]
282
- * @returns {OutputModel}
283
- */
284
171
  process_input(locations: (Location)[], modifier?: Modifier): OutputModel;
285
- /**
286
- * @returns {(string)[]}
287
- */
288
172
  takeback_fens(): (string)[];
289
- /**
290
- */
291
173
  clearTracking(): void;
292
- /**
293
- * @param {string} preference
294
- * @returns {OutputModel}
295
- */
296
174
  smartAutomove(preference: string): OutputModel;
297
- /**
298
- * @returns {boolean}
299
- */
300
175
  is_moves_verified(): boolean;
301
- /**
302
- * @param {string} input_fen
303
- * @returns {OutputModel}
304
- */
305
176
  process_input_fen(input_fen: string): OutputModel;
306
- /**
307
- * @param {(string)[]} takeback_fens
308
- * @returns {MonsGameModel | undefined}
309
- */
310
177
  without_last_turn(takeback_fens: (string)[]): MonsGameModel | undefined;
311
- /**
312
- * @param {GameVariant} variant
313
- * @returns {MonsGameModel}
314
- */
315
178
  static newForSimulation(variant: GameVariant): MonsGameModel;
316
- /**
317
- * @returns {Int32Array}
318
- */
319
179
  available_move_kinds(): Int32Array;
320
- /**
321
- * @param {boolean} enabled
322
- */
323
180
  setVerboseTracking(enabled: boolean): void;
324
- /**
325
- * @returns {(Location)[]}
326
- */
327
181
  locations_with_content(): (Location)[];
328
- /**
329
- * @param {string} fen
330
- * @returns {MonsGameModel | undefined}
331
- */
332
182
  static fromFenForSimulation(fen: string): MonsGameModel | undefined;
333
- /**
334
- * @returns {(VerboseTrackingEntityModel)[]}
335
- */
336
183
  verbose_tracking_entities(): (VerboseTrackingEntityModel)[];
337
- /**
338
- * @returns {Int32Array}
339
- */
340
184
  inactive_player_items_counters(): Int32Array;
341
- /**
342
- * @returns {string}
343
- */
344
185
  fen(): string;
345
- /**
346
- * @param {GameVariant} variant
347
- * @returns {MonsGameModel}
348
- */
349
186
  static new(variant: GameVariant): MonsGameModel;
350
- /**
351
- * @param {Location} at
352
- * @returns {ItemModel | undefined}
353
- */
354
187
  item(at: Location): ItemModel | undefined;
355
- /**
356
- * @param {Location} at
357
- * @returns {SquareModel}
358
- */
359
188
  square(at: Location): SquareModel;
360
- /**
361
- * @returns {OutputModel}
362
- */
363
189
  automove(): OutputModel;
364
- /**
365
- * @param {string} fen
366
- * @returns {MonsGameModel | undefined}
367
- */
368
190
  static from_fen(fen: string): MonsGameModel | undefined;
369
- /**
370
- * @returns {OutputModel}
371
- */
372
191
  takeback(): OutputModel;
373
192
  }
374
- /**
375
- */
193
+
376
194
  export class NextInputModel {
377
195
  free(): void;
378
- /**
379
- */
380
196
  actor_mon_item?: ItemModel;
381
- /**
382
- */
383
197
  kind: NextInputKind;
384
- /**
385
- */
386
198
  location?: Location;
387
- /**
388
- */
389
199
  modifier?: Modifier;
390
200
  }
391
- /**
392
- */
201
+
202
+ // prettier-ignore
393
203
  export class OutputModel {
394
204
  free(): void;
395
- /**
396
- * @returns {(NextInputModel)[]}
397
- */
398
205
  next_inputs(): (NextInputModel)[];
399
- /**
400
- * @returns {(EventModel)[]}
401
- */
402
206
  events(): (EventModel)[];
403
- /**
404
- * @returns {string}
405
- */
406
207
  input_fen(): string;
407
- /**
408
- * @returns {(Location)[]}
409
- */
410
208
  locations(): (Location)[];
411
- /**
412
- */
413
209
  kind: OutputModelKind;
414
210
  }
415
- /**
416
- */
211
+
417
212
  export class SquareModel {
418
213
  free(): void;
419
- /**
420
- */
421
214
  color?: Color;
422
- /**
423
- */
424
215
  kind: SquareModelKind;
425
- /**
426
- */
427
216
  mon_kind?: MonKind;
428
217
  }
429
- /**
430
- */
218
+
219
+ // prettier-ignore
431
220
  export class VerboseTrackingEntityModel {
432
221
  free(): void;
433
- /**
434
- * @returns {string}
435
- */
436
222
  events_fen(): string;
437
- /**
438
- * @returns {string}
439
- */
440
223
  fen(): string;
441
- /**
442
- * @returns {Color}
443
- */
444
224
  color(): Color;
445
- /**
446
- * @returns {(EventModel)[]}
447
- */
448
225
  events(): (EventModel)[];
449
226
  }
package/package.json CHANGED
@@ -1,32 +1,56 @@
1
1
  {
2
2
  "name": "mons-rules",
3
- "type": "module",
3
+ "version": "0.2.3",
4
4
  "description": "super metal mons",
5
- "version": "0.2.0",
5
+ "type": "module",
6
6
  "license": "CC0-1.0",
7
7
  "repository": {
8
8
  "type": "git",
9
9
  "url": "git+https://github.com/supermetalmons/rules.git"
10
10
  },
11
+ "engines": {
12
+ "node": "^22.13.0 || >=24.0.0"
13
+ },
11
14
  "files": [
12
- "mons-rules.js",
15
+ "dist/mons-rules.js",
13
16
  "mons-rules.d.ts",
14
17
  "LICENSE",
15
18
  "README.md"
16
19
  ],
17
- "main": "./mons-rules.js",
18
- "module": "./mons-rules.js",
19
- "browser": "./mons-rules.js",
20
+ "main": "./dist/mons-rules.js",
21
+ "module": "./dist/mons-rules.js",
22
+ "browser": "./dist/mons-rules.js",
20
23
  "types": "./mons-rules.d.ts",
21
- "engines": {
22
- "node": "^22.13.0 || >=24.0.0"
23
- },
24
24
  "exports": {
25
25
  ".": {
26
26
  "types": "./mons-rules.d.ts",
27
- "import": "./mons-rules.js",
28
- "require": "./mons-rules.js",
29
- "default": "./mons-rules.js"
27
+ "import": "./dist/mons-rules.js",
28
+ "require": "./dist/mons-rules.js",
29
+ "default": "./dist/mons-rules.js"
30
30
  }
31
+ },
32
+ "scripts": {
33
+ "build": "esbuild ./src/entrypoints/mons-rules.ts --bundle --format=esm --platform=browser --target=es2020 --minify --keep-names --legal-comments=none --outfile=./dist/mons-rules.js",
34
+ "bump": "npm version patch --no-git-tag-version",
35
+ "check": "npm run format:check && npm run lint && npm run typecheck && npm test && ./scripts/run-rules-tests.sh && npm run test:complete-games && npm run build && node ./scripts/check-package.mjs .",
36
+ "format": "prettier --write .",
37
+ "format:check": "prettier --check .",
38
+ "lint": "eslint .",
39
+ "publish": "./scripts/publish.sh",
40
+ "test": "vitest run",
41
+ "test:complete-games": "node ./scripts/run-complete-games.mjs",
42
+ "typecheck": "tsc -p tsconfig.json --noEmit"
43
+ },
44
+ "devDependencies": {
45
+ "@eslint/js": "9.39.5",
46
+ "@types/node": "22.20.1",
47
+ "esbuild": "0.28.1",
48
+ "eslint": "9.39.5",
49
+ "globals": "17.7.0",
50
+ "prettier": "3.9.5",
51
+ "semver": "7.8.5",
52
+ "typescript": "6.0.3",
53
+ "typescript-eslint": "8.64.0",
54
+ "vitest": "4.1.10"
31
55
  }
32
56
  }