@pkmn/engine 0.1.0-dev.84cc1a02 → 0.1.0-dev.89cc1c98

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.
Files changed (60) hide show
  1. package/README.md +98 -59
  2. package/build/pkg/addon.d.ts +7 -0
  3. package/build/pkg/addon.js +112 -0
  4. package/build/pkg/addon.js.map +1 -0
  5. package/build/pkg/data/ids.json +12 -12
  6. package/build/pkg/data/layout.json +27 -5
  7. package/build/pkg/data/protocol.json +69 -12
  8. package/build/pkg/data.d.ts +3 -4
  9. package/build/pkg/data.js +3 -5
  10. package/build/pkg/data.js.map +1 -1
  11. package/build/pkg/gen1.d.ts +5 -4
  12. package/build/pkg/gen1.js +49 -33
  13. package/build/pkg/gen1.js.map +1 -1
  14. package/build/pkg/index.d.ts +15 -12
  15. package/build/pkg/index.js.map +1 -1
  16. package/build/pkg/protocol.d.ts +4 -2
  17. package/build/pkg/protocol.js +60 -39
  18. package/build/pkg/protocol.js.map +1 -1
  19. package/build/test/display.js +400 -0
  20. package/build/test/display.js.map +1 -0
  21. package/build/tools/debug.js +133 -0
  22. package/build/tools/debug.js.map +1 -0
  23. package/build.zig +103 -87
  24. package/package.json +72 -40
  25. package/src/bin/install-pkmn-engine +55 -31
  26. package/src/bin/pkmn-debug +62 -0
  27. package/src/lib/binding/node.zig +47 -142
  28. package/src/lib/binding/wasm.zig +6 -4
  29. package/src/lib/common/battle.zig +17 -0
  30. package/src/lib/common/data.zig +19 -31
  31. package/src/lib/common/debug.zig +21 -11
  32. package/src/lib/common/js.zig +118 -0
  33. package/src/lib/common/optional.zig +67 -0
  34. package/src/lib/common/options.zig +12 -3
  35. package/src/lib/common/protocol.zig +788 -246
  36. package/src/lib/common/rational.zig +353 -0
  37. package/src/lib/common/rng.zig +15 -15
  38. package/src/lib/common/util.zig +12 -0
  39. package/src/lib/gen1/README.md +297 -181
  40. package/src/lib/gen1/calc.zig +426 -0
  41. package/src/lib/gen1/chance.zig +1060 -0
  42. package/src/lib/gen1/data/moves.zig +202 -190
  43. package/src/lib/gen1/data/species.zig +4 -4
  44. package/src/lib/gen1/data/types.zig +10 -10
  45. package/src/lib/gen1/data.zig +90 -76
  46. package/src/lib/gen1/helpers.zig +577 -32
  47. package/src/lib/gen1/mechanics.zig +1048 -712
  48. package/src/lib/gen2/README.md +106 -85
  49. package/src/lib/gen2/calc.zig +143 -0
  50. package/src/lib/gen2/chance.zig +1314 -0
  51. package/src/lib/gen2/data/items.zig +14 -20
  52. package/src/lib/gen2/data/moves.zig +664 -570
  53. package/src/lib/gen2/data/species.zig +2 -2
  54. package/src/lib/gen2/data/types.zig +137 -34
  55. package/src/lib/gen2/data.zig +125 -89
  56. package/src/lib/gen2/generated.zig +857 -0
  57. package/src/lib/gen2/helpers.zig +16 -22
  58. package/src/lib/gen2/mechanics.zig +2998 -12
  59. package/src/lib/pkmn.zig +68 -9
  60. package/src/test/display/pkmn.html.tmpl +368 -0
package/build.zig CHANGED
@@ -1,13 +1,20 @@
1
1
  const std = @import("std");
2
2
  const builtin = @import("builtin");
3
3
 
4
- pub const Options = struct { showdown: ?bool = null, trace: ?bool = null };
4
+ pub const Options = struct {
5
+ showdown: ?bool = null,
6
+ log: ?bool = null,
7
+ chance: ?bool = null,
8
+ calc: ?bool = null,
9
+ };
5
10
 
6
11
  pub fn module(b: *std.Build, options: Options) *std.Build.Module {
7
12
  const dirname = comptime std.fs.path.dirname(@src().file) orelse ".";
8
13
  const build_options = b.addOptions();
9
14
  build_options.addOption(?bool, "showdown", options.showdown);
10
- build_options.addOption(?bool, "trace", options.trace);
15
+ build_options.addOption(?bool, "log", options.log);
16
+ build_options.addOption(?bool, "chance", options.chance);
17
+ build_options.addOption(?bool, "calc", options.calc);
11
18
  return b.createModule(.{
12
19
  .source_file = .{ .path = dirname ++ "/src/lib/pkmn.zig" },
13
20
  .dependencies = &.{.{ .name = "build_options", .module = build_options.createModule() }},
@@ -27,25 +34,30 @@ pub fn build(b: *std.Build) !void {
27
34
  const dynamic = b.option(bool, "dynamic", "Build a dynamic library") orelse false;
28
35
  const strip = b.option(bool, "strip", "Strip debugging symbols from binary") orelse false;
29
36
  const pic = b.option(bool, "pic", "Force position independent code") orelse false;
37
+ const emit_asm = b.option(bool, "emit-asm", "Output .s (assembly code)") orelse false;
38
+ const emit_ll = b.option(bool, "emit-ll", "Output .ll (LLVM IR)") orelse false;
30
39
 
31
- const cmd = b.findProgram(&[_][]const u8{"strip"}, &[_][]const u8{}) catch null;
40
+ const cmd = b.findProgram(&.{"strip"}, &.{}) catch null;
32
41
 
33
- var parser = std.json.Parser.init(b.allocator, false);
34
- defer parser.deinit();
35
- var tree = try parser.parse(@embedFile("package.json"));
36
- defer tree.deinit();
37
- const version = tree.root.Object.get("version").?.String;
38
- const description = tree.root.Object.get("description").?.String;
39
- var repository = std.mem.split(u8, tree.root.Object.get("repository").?.String, ":");
42
+ const json = @embedFile("package.json");
43
+ var parsed = try std.json.parseFromSlice(std.json.Value, b.allocator, json, .{});
44
+ defer parsed.deinit();
45
+ const version = parsed.value.object.get("version").?.string;
46
+ const description = parsed.value.object.get("description").?.string;
47
+ var repository = std.mem.split(u8, parsed.value.object.get("repository").?.string, ":");
40
48
  std.debug.assert(std.mem.eql(u8, repository.first(), "github"));
41
49
 
42
50
  const showdown =
43
51
  b.option(bool, "showdown", "Enable Pokémon Showdown compatibility mode") orelse false;
44
- const trace = b.option(bool, "trace", "Enable trace logs") orelse false;
52
+ const log = b.option(bool, "log", "Enable protocol message logging") orelse false;
53
+ const chance = b.option(bool, "chance", "Enable update probability tracking") orelse false;
54
+ const calc = b.option(bool, "calc", "Enable damage calculator support") orelse false;
45
55
 
46
56
  const options = b.addOptions();
47
57
  options.addOption(?bool, "showdown", showdown);
48
- options.addOption(?bool, "trace", trace);
58
+ options.addOption(?bool, "log", log);
59
+ options.addOption(?bool, "chance", chance);
60
+ options.addOption(?bool, "calc", calc);
49
61
 
50
62
  const name = if (showdown) "pkmn-showdown" else "pkmn";
51
63
 
@@ -54,16 +66,16 @@ pub fn build(b: *std.Build) !void {
54
66
  const addon = b.fmt("{s}.node", .{name});
55
67
  const lib = b.addSharedLibrary(.{
56
68
  .name = addon,
69
+ .main_pkg_path = .{ .path = "." },
57
70
  .root_source_file = .{ .path = "src/lib/binding/node.zig" },
58
71
  .optimize = optimize,
59
72
  .target = target,
60
73
  });
61
74
  lib.addOptions("build_options", options);
62
- lib.setMainPkgPath("./");
63
- lib.addSystemIncludePath(headers);
75
+ lib.addSystemIncludePath(.{ .path = headers });
64
76
  lib.linkLibC();
65
77
  if (node_import_lib) |il| {
66
- lib.addObjectFile(il);
78
+ lib.addObjectFile(.{ .path = il });
67
79
  } else if ((try std.zig.system.NativeTargetInfo.detect(target)).target.os.tag == .windows) {
68
80
  try std.io.getStdErr().writeAll("Must provide --node-import-library path on Windows\n");
69
81
  std.process.exit(1);
@@ -72,17 +84,18 @@ pub fn build(b: *std.Build) !void {
72
84
  maybeStrip(b, lib, b.getInstallStep(), strip, cmd);
73
85
  if (pic) lib.force_pic = pic;
74
86
  // Always emit to build/lib because this is where the driver code expects to find it
75
- // TODO(ziglang/zig#2231): using the following used to work (though be hacky):
87
+ // TODO(ziglang/zig#2231): using the following used to work (though was hacky):
76
88
  //
77
89
  // lib.emit_bin = .{ .emit_to = b.fmt("build/lib/{s}", .{addon}) };
78
90
  // b.getInstallStep().dependOn(&lib.step);
79
91
  //
80
92
  // But ziglang/zig#14647 broke this so we now need to do an install() and then manually
81
93
  // rename the file ourself in install-pkmn-engine
82
- lib.install();
94
+ b.installArtifact(lib);
83
95
  } else if (wasm) {
84
96
  const lib = b.addSharedLibrary(.{
85
97
  .name = name,
98
+ .main_pkg_path = .{ .path = "." },
86
99
  .root_source_file = .{ .path = "src/lib/binding/wasm.zig" },
87
100
  .optimize = switch (optimize) {
88
101
  .ReleaseFast, .ReleaseSafe => .ReleaseSmall,
@@ -91,53 +104,63 @@ pub fn build(b: *std.Build) !void {
91
104
  .target = .{ .cpu_arch = .wasm32, .os_tag = .freestanding },
92
105
  });
93
106
  lib.addOptions("build_options", options);
94
- lib.setMainPkgPath("./");
95
107
  lib.stack_size = wasm_stack_size;
96
108
  lib.rdynamic = true;
97
109
  lib.strip = strip;
98
110
  if (pic) lib.force_pic = pic;
99
- const opt = b.findProgram(
100
- &[_][]const u8{"wasm-opt"},
101
- &[_][]const u8{"./node_modules/.bin"},
102
- ) catch null;
111
+ const opt = b.findProgram(&.{"wasm-opt"}, &.{"./node_modules/.bin"}) catch null;
103
112
  if (optimize != .Debug and opt != null) {
104
113
  const out = b.fmt("build/lib/{s}.wasm", .{name});
105
- const sh = b.addSystemCommand(&[_][]const u8{ opt.?, "-O4" });
114
+ const sh = b.addSystemCommand(&.{ opt.?, "-O4" });
106
115
  sh.addArtifactArg(lib);
107
116
  sh.addArg("-o");
108
117
  sh.addFileSourceArg(.{ .path = out });
109
118
  b.getInstallStep().dependOn(&sh.step);
110
119
  }
111
- lib.install();
120
+ b.installArtifact(lib);
112
121
  } else if (dynamic) {
113
122
  const lib = b.addSharedLibrary(.{
114
123
  .name = name,
124
+ .main_pkg_path = .{ .path = "." },
115
125
  .root_source_file = .{ .path = "src/lib/binding/c.zig" },
116
- .version = try std.builtin.Version.parse(version),
126
+ .version = try std.SemanticVersion.parse(version),
117
127
  .optimize = optimize,
118
128
  .target = target,
119
129
  });
120
130
  lib.addOptions("build_options", options);
121
- lib.setMainPkgPath("./");
122
- lib.addIncludePath("src/include");
131
+ lib.addIncludePath(.{ .path = "src/include" });
123
132
  maybeStrip(b, lib, b.getInstallStep(), strip, cmd);
124
133
  if (pic) lib.force_pic = pic;
125
- lib.install();
134
+ b.installArtifact(lib);
126
135
  c = true;
127
136
  } else {
128
137
  const lib = b.addStaticLibrary(.{
129
138
  .name = name,
139
+ .main_pkg_path = .{ .path = "." },
130
140
  .root_source_file = .{ .path = "src/lib/binding/c.zig" },
131
141
  .optimize = optimize,
132
142
  .target = target,
133
143
  });
134
144
  lib.addOptions("build_options", options);
135
- lib.setMainPkgPath("./");
136
- lib.addIncludePath("src/include");
145
+ lib.addIncludePath(.{ .path = "src/include" });
137
146
  lib.bundle_compiler_rt = true;
138
147
  maybeStrip(b, lib, b.getInstallStep(), strip, cmd);
139
148
  if (pic) lib.force_pic = pic;
140
- lib.install();
149
+ if (emit_asm) {
150
+ b.getInstallStep().dependOn(&b.addInstallFileWithDir(
151
+ lib.getEmittedAsm(),
152
+ .prefix,
153
+ b.fmt("{s}.s", .{name}),
154
+ ).step);
155
+ }
156
+ if (emit_ll) {
157
+ b.getInstallStep().dependOn(&b.addInstallFileWithDir(
158
+ lib.getEmittedLlvmIr(),
159
+ .prefix,
160
+ b.fmt("{s}.ll", .{name}),
161
+ ).step);
162
+ }
163
+ b.installArtifact(lib);
141
164
  c = true;
142
165
  }
143
166
 
@@ -179,14 +202,20 @@ pub fn build(b: *std.Build) !void {
179
202
  .strip = strip,
180
203
  .cmd = cmd,
181
204
  };
205
+
206
+ // TODO: tests can be run multiple times due to @imports
182
207
  const tests = TestStep.create(b, options, config);
183
208
 
184
209
  var exes = std.ArrayList(*std.Build.CompileStep).init(b.allocator);
185
210
  const tools: ToolConfig = .{
211
+ .options = .{
212
+ .showdown = showdown,
213
+ .log = log,
214
+ .chance = chance,
215
+ .calc = calc,
216
+ },
186
217
  .general = config,
187
218
  .tool = .{
188
- .showdown = showdown,
189
- .trace = trace,
190
219
  .tests = if (tests.build) tests else null,
191
220
  .exes = &exes,
192
221
  },
@@ -200,23 +229,25 @@ pub fn build(b: *std.Build) !void {
200
229
  var fuzz_config = tools;
201
230
  fuzz_config.general.strip = false;
202
231
  fuzz_config.tool.name = "fuzz";
203
- const fuzz = tool(b, "src/test/benchmark.zig", fuzz_config);
232
+ const fuzz = tool(b, "src/test/fuzz.zig", fuzz_config);
204
233
 
205
- const serde = tool(b, "src/tools/serde.zig", tools);
206
- const protocol = tool(b, "src/tools/protocol.zig", tools);
234
+ const analyze = tool(b, "src/tools/analyze.zig", tools);
235
+ const dump = tool(b, "src/tools/dump.zig", tools);
236
+ const transitions = tool(b, "src/tools/transitions.zig", tools);
207
237
 
208
- const lint_exe =
209
- b.addExecutable(.{ .name = "lint", .root_source_file = .{ .path = "src/tools/lint.zig" } });
210
- if (tests.build) tests.step.dependOn(&lint_exe.step);
211
- const lint = lint_exe.run();
238
+ // FIXME: serde randomly fails to build in some release configurations
239
+ var hack = tools;
240
+ if (optimize != .Debug) hack.tool.tests = null;
241
+ const serde = tool(b, "src/tools/serde.zig", hack);
212
242
 
243
+ b.step("analyze", "Run LLVM analysis tool").dependOn(&analyze.step);
213
244
  b.step("benchmark", "Run benchmark code").dependOn(&benchmark.step);
245
+ b.step("dump", "Run protocol dump tool").dependOn(&dump.step);
214
246
  b.step("fuzz", "Run fuzz tester").dependOn(&fuzz.step);
215
- b.step("lint", "Lint source files").dependOn(&lint.step);
216
- b.step("protocol", "Run protocol dump tool").dependOn(&protocol.step);
217
247
  b.step("serde", "Run serialization/deserialization tool").dependOn(&serde.step);
218
248
  b.step("test", "Run all tests").dependOn(&tests.step);
219
249
  b.step("tools", "Install tools").dependOn(&ToolsStep.create(b, &exes).step);
250
+ b.step("transitions", "Visualize transitions algorithm search").dependOn(&transitions.step);
220
251
  }
221
252
 
222
253
  fn maybeStrip(
@@ -233,7 +264,7 @@ fn maybeStrip(
233
264
  if (mac and artifact.isDynamicLibrary()) return;
234
265
  // Assuming GNU strip, which complains "illegal pathname found in archive member"...
235
266
  if (!mac and artifact.isStaticLibrary()) return;
236
- const sh = b.addSystemCommand(&[_][]const u8{ cmd.?, if (mac) "-x" else "-s" });
267
+ const sh = b.addSystemCommand(&.{ cmd.?, if (mac) "-x" else "-s" });
237
268
  sh.addArtifactArg(artifact);
238
269
  step.dependOn(&sh.step);
239
270
  }
@@ -246,12 +277,6 @@ const Config = struct {
246
277
  cmd: ?[]const u8,
247
278
  };
248
279
 
249
- const TESTS = [_][]const u8{
250
- "src/lib/common/test.zig",
251
- "src/lib/gen1/test.zig",
252
- "src/lib/gen2/test.zig",
253
- };
254
-
255
280
  const TestStep = struct {
256
281
  step: std.Build.Step,
257
282
  build: bool,
@@ -259,49 +284,42 @@ const TestStep = struct {
259
284
  pub fn create(b: *std.Build, options: *std.Build.OptionsStep, config: Config) *TestStep {
260
285
  const coverage = b.option([]const u8, "test-coverage", "Generate test coverage");
261
286
  const test_file = b.option([]const u8, "test-file", "Input file for test");
262
- const test_bin = b.option([]const u8, "test-bin", "Emit test binary to");
263
287
  const test_filter =
264
288
  b.option([]const u8, "test-filter", "Skip tests that do not match filter");
265
- const test_no_exec =
266
- b.option(bool, "test-no-exec", "Compiles test binary without running it") orelse false;
267
289
 
268
290
  const self = b.allocator.create(TestStep) catch @panic("OOM");
269
291
  const step = std.Build.Step.init(.{ .id = .custom, .name = "Run all tests", .owner = b });
270
- self.* = TestStep{ .step = step, .build = test_filter == null };
271
-
272
- const paths: []const []const u8 =
273
- if (test_file) |t| &.{t} else if (coverage != null) &.{"src/lib/test.zig"} else &TESTS;
274
- for (paths) |path| {
275
- const tests = b.addTest(.{
276
- .name = std.fs.path.basename(std.fs.path.dirname(path).?),
277
- .root_source_file = .{ .path = path },
278
- .optimize = config.optimize,
279
- .target = config.target,
280
- });
281
- tests.setMainPkgPath("./");
282
- tests.setFilter(test_filter);
283
- tests.addOptions("build_options", options);
284
- tests.single_threaded = true;
285
- maybeStrip(b, tests, &tests.step, config.strip, config.cmd);
286
- if (config.pic) tests.force_pic = config.pic;
287
- if (test_bin) |bin| {
288
- tests.name = std.fs.path.basename(bin);
289
- if (std.fs.path.dirname(bin)) |dir| tests.setOutputDir(dir);
290
- }
291
- if (coverage) |c| {
292
- tests.setExecCmd(&.{ "kcov", "--include-pattern=src/lib", c, null });
293
- }
294
- self.step.dependOn(if (test_no_exec) &tests.step else &tests.run().step);
292
+ self.* = .{ .step = step, .build = test_filter == null };
293
+
294
+ const path = test_file orelse "src/lib/test.zig";
295
+ const tests = b.addTest(.{
296
+ .name = b.fmt("{s}-{s}", .{
297
+ std.fs.path.basename(std.fs.path.dirname(path).?),
298
+ std.fs.path.stem(std.fs.path.basename(path)),
299
+ }),
300
+ .main_pkg_path = .{ .path = "." },
301
+ .root_source_file = .{ .path = path },
302
+ .optimize = config.optimize,
303
+ .target = config.target,
304
+ .filter = test_filter,
305
+ });
306
+ tests.addOptions("build_options", options);
307
+ tests.single_threaded = true;
308
+ maybeStrip(b, tests, &tests.step, config.strip, config.cmd);
309
+ if (config.pic) tests.force_pic = config.pic;
310
+ if (coverage) |c| {
311
+ tests.setExecCmd(&.{ "kcov", "--include-pattern=src/lib", c, null });
295
312
  }
313
+ self.step.dependOn(&b.addRunArtifact(tests).step);
314
+
296
315
  return self;
297
316
  }
298
317
  };
299
318
 
300
319
  const ToolConfig = struct {
320
+ options: Options,
301
321
  general: Config,
302
322
  tool: struct {
303
- showdown: bool,
304
- trace: bool,
305
323
  tests: ?*TestStep,
306
324
  name: ?[]const u8 = null,
307
325
  exes: *std.ArrayList(*std.Build.CompileStep),
@@ -312,7 +330,7 @@ fn tool(b: *std.Build, path: []const u8, config: ToolConfig) *std.Build.RunStep
312
330
  var name = config.tool.name orelse std.fs.path.basename(path);
313
331
  const index = std.mem.lastIndexOfScalar(u8, name, '.');
314
332
  if (index) |i| name = name[0..i];
315
- if (config.tool.showdown) name = b.fmt("{s}-showdown", .{name});
333
+ if (config.options.showdown orelse false) name = b.fmt("{s}-showdown", .{name});
316
334
 
317
335
  const exe = b.addExecutable(.{
318
336
  .name = name,
@@ -320,16 +338,14 @@ fn tool(b: *std.Build, path: []const u8, config: ToolConfig) *std.Build.RunStep
320
338
  .target = config.general.target,
321
339
  .optimize = config.general.optimize,
322
340
  });
323
- exe.addModule("pkmn", module(b, .{
324
- .showdown = config.tool.showdown,
325
- .trace = config.tool.trace,
326
- }));
341
+ exe.addModule("pkmn", module(b, config.options));
342
+
327
343
  exe.single_threaded = true;
328
344
  if (config.general.pic) exe.force_pic = config.general.pic;
329
345
  if (config.tool.tests) |ts| ts.step.dependOn(&exe.step);
330
346
  config.tool.exes.append(exe) catch @panic("OOM");
331
347
 
332
- const run = exe.run();
348
+ const run = b.addRunArtifact(exe);
333
349
  maybeStrip(b, exe, &run.step, config.general.strip, config.general.cmd);
334
350
  if (b.args) |args| run.addArgs(args);
335
351
 
@@ -342,8 +358,8 @@ const ToolsStep = struct {
342
358
  pub fn create(b: *std.Build, exes: *std.ArrayList(*std.Build.CompileStep)) *ToolsStep {
343
359
  const self = b.allocator.create(ToolsStep) catch @panic("OOM");
344
360
  const step = std.Build.Step.init(.{ .id = .custom, .name = "Install tools", .owner = b });
345
- self.* = ToolsStep{ .step = step };
346
- for (exes.items) |t| self.step.dependOn(&b.addInstallArtifact(t).step);
361
+ self.* = .{ .step = step };
362
+ for (exes.items) |t| self.step.dependOn(&b.addInstallArtifact(t, .{}).step);
347
363
  return self;
348
364
  }
349
365
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pkmn/engine",
3
- "version": "0.1.0-dev.84cc1a02",
3
+ "version": "0.1.0-dev.89cc1c98",
4
4
  "description": "A minimal, complete, Pokémon battle simulation engine optimized for performance",
5
5
  "repository": "github:pkmn/engine",
6
6
  "license": "MIT",
@@ -9,86 +9,106 @@
9
9
  "types": "build/pkg/index.d.ts",
10
10
  "files": [
11
11
  "build.zig",
12
+ "build/pkg/data.d.ts",
13
+ "build/pkg/data.js.map",
14
+ "build/pkg/addon.d.ts",
15
+ "build/pkg/addon.js.map",
16
+ "build/pkg/addon.js",
17
+ "build/pkg/data.js",
18
+ "build/pkg/data/ids.json",
19
+ "build/pkg/data/layout.json",
20
+ "build/pkg/data/protocol.json",
21
+ "build/pkg/gen1.d.ts",
22
+ "build/pkg/gen1.js.map",
23
+ "build/pkg/gen1.js",
24
+ "build/pkg/index.d.ts",
25
+ "build/pkg/index.js.map",
26
+ "build/pkg/index.js",
27
+ "build/pkg/protocol.d.ts",
28
+ "build/pkg/protocol.js.map",
29
+ "build/pkg/protocol.js",
30
+ "build/test/display.js.map",
31
+ "build/test/display.js",
32
+ "build/tools/debug.js.map",
33
+ "build/tools/debug.js",
12
34
  "src/bin/install-pkmn-engine",
13
35
  "src/lib/binding/node.zig",
14
36
  "src/lib/binding/wasm.zig",
37
+ "src/lib/common/battle.zig",
15
38
  "src/lib/common/data.zig",
16
39
  "src/lib/common/debug.zig",
40
+ "src/lib/common/js.zig",
41
+ "src/lib/common/optional.zig",
17
42
  "src/lib/common/options.zig",
18
43
  "src/lib/common/protocol.zig",
44
+ "src/lib/common/rational.zig",
19
45
  "src/lib/common/rng.zig",
46
+ "src/lib/common/util.zig",
47
+ "src/lib/gen1/calc.zig",
48
+ "src/lib/gen1/chance.zig",
49
+ "src/lib/gen1/data.zig",
20
50
  "src/lib/gen1/data/moves.zig",
21
51
  "src/lib/gen1/data/species.zig",
22
52
  "src/lib/gen1/data/types.zig",
23
- "src/lib/gen1/data.zig",
24
53
  "src/lib/gen1/helpers.zig",
25
54
  "src/lib/gen1/mechanics.zig",
55
+ "src/lib/gen2/calc.zig",
56
+ "src/lib/gen2/chance.zig",
57
+ "src/lib/gen2/data.zig",
26
58
  "src/lib/gen2/data/items.zig",
27
59
  "src/lib/gen2/data/moves.zig",
28
60
  "src/lib/gen2/data/species.zig",
29
61
  "src/lib/gen2/data/types.zig",
30
- "src/lib/gen2/data.zig",
62
+ "src/lib/gen2/generated.zig",
31
63
  "src/lib/gen2/helpers.zig",
32
64
  "src/lib/gen2/mechanics.zig",
33
65
  "src/lib/pkmn.zig",
34
- "build/pkg/data/ids.json",
35
- "build/pkg/data/layout.json",
36
- "build/pkg/data/protocol.json",
37
- "build/pkg/data.d.ts",
38
- "build/pkg/data.js",
39
- "build/pkg/data.js.map",
40
- "build/pkg/gen1.d.ts",
41
- "build/pkg/gen1.js",
42
- "build/pkg/gen1.js.map",
43
- "build/pkg/index.d.ts",
44
- "build/pkg/index.js",
45
- "build/pkg/index.js.map",
46
- "build/pkg/protocol.d.ts",
47
- "build/pkg/protocol.js",
48
- "build/pkg/protocol.js.map"
66
+ "src/test/display/pkmn.html.tmpl"
49
67
  ],
50
68
  "engines": {
51
69
  "node": ">=16.0.0"
52
70
  },
53
71
  "bin": {
54
- "install-pkmn-engine": "src/bin/install-pkmn-engine"
72
+ "install-pkmn-engine": "src/bin/install-pkmn-engine",
73
+ "pkmn-debug": "src/bin/pkmn-debug"
55
74
  },
56
75
  "publishConfig": {
57
76
  "access": "public"
58
77
  },
59
78
  "dependencies": {
60
- "@pkmn/data": "^0.7.35",
61
- "@pkmn/protocol": "^0.6.11"
79
+ "@pkmn/data": "^0.7.53",
80
+ "@pkmn/protocol": "^0.6.16"
62
81
  },
63
82
  "devDependencies": {
64
- "@pkmn/eslint-config": "^3.0.0",
65
- "@pkmn/img": "^0.2.8",
66
- "@pkmn/sets": "^5.0.4",
67
- "@pkmn/sim": "0.7.35",
68
- "@types/html-minifier": "^4.0.2",
69
- "@types/jest": "^29.5.0",
70
- "@types/minimist": "^1.2.2",
71
- "@types/mustache": "^4.2.2",
72
- "@types/node": "^18.15.11",
73
- "@vitest/coverage-c8": "^0.29.8",
74
- "binaryen": "^112.0.0",
75
- "eslint": "^8.37.0",
83
+ "@pkmn/eslint-config": "^5.3.0",
84
+ "@pkmn/img": "^0.2.18",
85
+ "@pkmn/sets": "^5.1.0",
86
+ "@pkmn/sim": "0.7.53",
87
+ "@types/html-minifier": "^4.0.3",
88
+ "@types/jest": "^29.5.5",
89
+ "@types/minimist": "^1.2.3",
90
+ "@types/mustache": "^4.2.3",
91
+ "@types/node": "^20.8.2",
92
+ "@vitest/coverage-c8": "^0.33.0",
93
+ "binaryen": "^114.0.0",
94
+ "eslint": "^8.51.0",
76
95
  "html-minifier": "^4.0.0",
77
96
  "json-stringify-pretty-compact": "3.0.0",
78
97
  "minimist": "^1.2.8",
79
98
  "mustache": "^4.2.0",
80
99
  "source-map-support": "^0.5.21",
81
100
  "trakr": "^0.2.0",
82
- "typescript": "^5.0.3",
83
- "vitest": "^0.29.8"
101
+ "typescript": "^5.2.2",
102
+ "vitest": "^0.34.6"
84
103
  },
85
104
  "scripts": {
86
- "lint": "eslint --cache src --ext ts,js && eslint src/bin/install-pkmn-engine",
87
- "fix": "eslint --fix src --ext ts,js && eslint --fix src/bin/install-pkmn-engine",
105
+ "lint": "eslint --cache src --ext ts,js && eslint src/bin/*",
106
+ "fix": "eslint --fix src --ext ts,js && eslint --fix src/bin/*",
88
107
  "compile": "tsc -p .",
89
108
  "build": "npm run compile",
90
109
  "test": "vitest src/pkg",
91
110
  "test:integration": "vitest src/test",
111
+ "debug": "npm run compile && node build/tools/debug",
92
112
  "fuzz": "npm run compile && node build/test/fuzz",
93
113
  "generate": "npm run compile && node build/tools/generate",
94
114
  "release": "npm run compile && node build/tools/release",
@@ -130,7 +150,8 @@
130
150
  "rules": {
131
151
  "no-control-regex": "off",
132
152
  "@typescript-eslint/no-empty-interface": "off",
133
- "@typescript-eslint/no-shadow": "off"
153
+ "@typescript-eslint/no-shadow": "off",
154
+ "@typescript-eslint/no-unsafe-declaration-merging": "off"
134
155
  }
135
156
  },
136
157
  {
@@ -146,12 +167,23 @@
146
167
  "src/test/benchmark*.ts"
147
168
  ],
148
169
  "rules": {
149
- "@typescript-eslint/no-unused-vars": "off"
170
+ "@typescript-eslint/no-unused-vars": "off",
171
+ "@typescript-eslint/no-redundant-type-constituents": "off"
172
+ }
173
+ },
174
+ {
175
+ "files": [
176
+ "src/pkg/protocol.test.ts"
177
+ ],
178
+ "rules": {
179
+ "jest/no-standalone-expect": "off",
180
+ "jest/no-conditional-expect": "off"
150
181
  }
151
182
  },
152
183
  {
153
184
  "files": [
154
- "src/test/*.test.ts"
185
+ "src/test/*.test.ts",
186
+ "src/test/regression/*.test.ts"
155
187
  ],
156
188
  "rules": {
157
189
  "jest/no-standalone-expect": "off"