mons-rules 0.2.3 → 0.3.0

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "mons-rules",
3
- "version": "0.2.3",
4
- "description": "super metal mons",
3
+ "version": "0.3.0",
4
+ "description": "TypeScript rules engine for Super Metal Mons",
5
5
  "type": "module",
6
6
  "license": "CC0-1.0",
7
7
  "repository": {
@@ -13,26 +13,29 @@
13
13
  },
14
14
  "files": [
15
15
  "dist/mons-rules.js",
16
- "mons-rules.d.ts",
16
+ "dist/entrypoints/mons-rules.d.ts",
17
+ "dist/api/game.d.ts",
18
+ "dist/api/types.d.ts",
19
+ "dist/api/winner.d.ts",
17
20
  "LICENSE",
18
- "README.md"
21
+ "README.md",
22
+ "MIGRATION.md"
19
23
  ],
20
24
  "main": "./dist/mons-rules.js",
21
- "module": "./dist/mons-rules.js",
22
- "browser": "./dist/mons-rules.js",
23
- "types": "./mons-rules.d.ts",
25
+ "types": "./dist/entrypoints/mons-rules.d.ts",
26
+ "sideEffects": false,
24
27
  "exports": {
25
28
  ".": {
26
- "types": "./mons-rules.d.ts",
27
- "import": "./dist/mons-rules.js",
28
- "require": "./dist/mons-rules.js",
29
- "default": "./dist/mons-rules.js"
29
+ "types": "./dist/entrypoints/mons-rules.d.ts",
30
+ "import": "./dist/mons-rules.js"
30
31
  }
31
32
  },
32
33
  "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
+ "build": "npm run clean && tsc -p tsconfig.build.json && 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
35
  "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
+ "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 check:corpora && npm run build && node ./scripts/check-package.mjs .",
37
+ "check:corpora": "node ./scripts/check-protected-corpora.mjs",
38
+ "clean": "node --input-type=module --eval \"import { rmSync } from 'node:fs'; rmSync('dist', { recursive: true, force: true });\"",
36
39
  "format": "prettier --write .",
37
40
  "format:check": "prettier --check .",
38
41
  "lint": "eslint .",
package/mons-rules.d.ts DELETED
@@ -1,226 +0,0 @@
1
- // prettier-ignore
2
- export function winner(fen_w: string, fen_b: string, flat_moves_string_w: string, flat_moves_string_b: string): string;
3
-
4
- export enum EventModelKind {
5
- MonMove = 0,
6
- ManaMove = 1,
7
- ManaScored = 2,
8
- MysticAction = 3,
9
- DemonAction = 4,
10
- DemonAdditionalStep = 5,
11
- SpiritTargetMove = 6,
12
- PickupBomb = 7,
13
- PickupPotion = 8,
14
- PickupMana = 9,
15
- MonFainted = 10,
16
- ManaDropped = 11,
17
- SupermanaBackToBase = 12,
18
- BombAttack = 13,
19
- MonAwake = 14,
20
- BombExplosion = 15,
21
- NextTurn = 16,
22
- GameOver = 17,
23
- Takeback = 18,
24
- UsePotion = 19,
25
- }
26
-
27
- export enum Consumable {
28
- Potion = 0,
29
- Bomb = 1,
30
- BombOrPotion = 2,
31
- }
32
-
33
- export enum SquareModelKind {
34
- Regular = 0,
35
- ConsumableBase = 1,
36
- SupermanaBase = 2,
37
- ManaBase = 3,
38
- ManaPool = 4,
39
- MonBase = 5,
40
- }
41
-
42
- export enum NextInputKind {
43
- MonMove = 0,
44
- ManaMove = 1,
45
- MysticAction = 2,
46
- DemonAction = 3,
47
- DemonAdditionalStep = 4,
48
- SpiritTargetCapture = 5,
49
- SpiritTargetMove = 6,
50
- SelectConsumable = 7,
51
- BombAttack = 8,
52
- }
53
-
54
- export enum OutputModelKind {
55
- InvalidInput = 0,
56
- LocationsToStartFrom = 1,
57
- NextInputOptions = 2,
58
- Events = 3,
59
- }
60
-
61
- export enum ManaKind {
62
- Regular = 0,
63
- Supermana = 1,
64
- }
65
-
66
- export enum AvailableMoveKind {
67
- MonMove = 0,
68
- ManaMove = 1,
69
- Action = 2,
70
- Potion = 3,
71
- }
72
-
73
- export enum MonKind {
74
- Demon = 0,
75
- Drainer = 1,
76
- Angel = 2,
77
- Spirit = 3,
78
- Mystic = 4,
79
- }
80
-
81
- export enum GameVariant {
82
- Classic = 0,
83
- SwappedManaRows = 1,
84
- OffsetArcManaRows = 2,
85
- CenterSpokeManaRows = 3,
86
- AlternatingManaRows = 4,
87
- InnerWedgeManaRows = 5,
88
- OuterWedgeManaRows = 6,
89
- BentCenterManaRows = 7,
90
- OuterEdgeManaRows = 8,
91
- SplitFlankManaRows = 9,
92
- ForwardBridgeManaRows = 10,
93
- CornerChainManaRows = 11,
94
- }
95
-
96
- export enum ItemModelKind {
97
- Mon = 0,
98
- Mana = 1,
99
- MonWithMana = 2,
100
- MonWithConsumable = 3,
101
- Consumable = 4,
102
- }
103
-
104
- export enum Modifier {
105
- SelectPotion = 0,
106
- SelectBomb = 1,
107
- Cancel = 2,
108
- }
109
-
110
- export enum Color {
111
- White = 0,
112
- Black = 1,
113
- }
114
-
115
- export class EventModel {
116
- free(): void;
117
- color?: Color;
118
- item?: ItemModel;
119
- kind: EventModelKind;
120
- loc1?: Location;
121
- loc2?: Location;
122
- mana?: ManaModel;
123
- mon?: Mon;
124
- }
125
-
126
- export class ItemModel {
127
- free(): void;
128
- consumable?: Consumable;
129
- kind: ItemModelKind;
130
- mana?: ManaModel;
131
- mon?: Mon;
132
- }
133
-
134
- export class Location {
135
- free(): void;
136
- constructor(i: number, j: number);
137
- i: number;
138
- j: number;
139
- }
140
-
141
- export class ManaModel {
142
- free(): void;
143
- color: Color;
144
- kind: ManaKind;
145
- }
146
-
147
- export class Mon {
148
- free(): void;
149
- is_fainted(): boolean;
150
- decrease_cooldown(): void;
151
- static new(kind: MonKind, color: Color, cooldown: number): Mon;
152
- faint(): void;
153
- color: Color;
154
- cooldown: number;
155
- kind: MonKind;
156
- }
157
-
158
- // prettier-ignore
159
- export class MonsGameModel {
160
- free(): void;
161
- black_score(): number;
162
- remove_item(location: Location): void;
163
- turn_number(): number;
164
- white_score(): number;
165
- active_color(): Color;
166
- can_takeback(color: Color): boolean;
167
- // prettier-ignore
168
- verify_moves(flat_moves_string_w: string, flat_moves_string_b: string): boolean;
169
- winner_color(): Color | undefined;
170
- is_later_than(other_fen: string): boolean;
171
- process_input(locations: (Location)[], modifier?: Modifier): OutputModel;
172
- takeback_fens(): (string)[];
173
- clearTracking(): void;
174
- smartAutomove(preference: string): OutputModel;
175
- is_moves_verified(): boolean;
176
- process_input_fen(input_fen: string): OutputModel;
177
- without_last_turn(takeback_fens: (string)[]): MonsGameModel | undefined;
178
- static newForSimulation(variant: GameVariant): MonsGameModel;
179
- available_move_kinds(): Int32Array;
180
- setVerboseTracking(enabled: boolean): void;
181
- locations_with_content(): (Location)[];
182
- static fromFenForSimulation(fen: string): MonsGameModel | undefined;
183
- verbose_tracking_entities(): (VerboseTrackingEntityModel)[];
184
- inactive_player_items_counters(): Int32Array;
185
- fen(): string;
186
- static new(variant: GameVariant): MonsGameModel;
187
- item(at: Location): ItemModel | undefined;
188
- square(at: Location): SquareModel;
189
- automove(): OutputModel;
190
- static from_fen(fen: string): MonsGameModel | undefined;
191
- takeback(): OutputModel;
192
- }
193
-
194
- export class NextInputModel {
195
- free(): void;
196
- actor_mon_item?: ItemModel;
197
- kind: NextInputKind;
198
- location?: Location;
199
- modifier?: Modifier;
200
- }
201
-
202
- // prettier-ignore
203
- export class OutputModel {
204
- free(): void;
205
- next_inputs(): (NextInputModel)[];
206
- events(): (EventModel)[];
207
- input_fen(): string;
208
- locations(): (Location)[];
209
- kind: OutputModelKind;
210
- }
211
-
212
- export class SquareModel {
213
- free(): void;
214
- color?: Color;
215
- kind: SquareModelKind;
216
- mon_kind?: MonKind;
217
- }
218
-
219
- // prettier-ignore
220
- export class VerboseTrackingEntityModel {
221
- free(): void;
222
- events_fen(): string;
223
- fen(): string;
224
- color(): Color;
225
- events(): (EventModel)[];
226
- }