@pkmn/engine 0.1.0-dev.7f37a47c → 0.1.0-dev.80019d10

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 (61) hide show
  1. package/README.md +105 -66
  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 +16 -13
  15. package/build/pkg/index.js +1 -1
  16. package/build/pkg/index.js.map +1 -1
  17. package/build/pkg/protocol.d.ts +4 -2
  18. package/build/pkg/protocol.js +60 -39
  19. package/build/pkg/protocol.js.map +1 -1
  20. package/build/test/display.js +400 -0
  21. package/build/test/display.js.map +1 -0
  22. package/build/tools/debug.js +135 -0
  23. package/build/tools/debug.js.map +1 -0
  24. package/build.zig +118 -98
  25. package/package.json +74 -42
  26. package/src/bin/install-pkmn-engine +68 -36
  27. package/src/bin/pkmn-debug +62 -0
  28. package/src/lib/binding/node.zig +47 -142
  29. package/src/lib/binding/wasm.zig +6 -4
  30. package/src/lib/common/battle.zig +17 -0
  31. package/src/lib/common/data.zig +19 -31
  32. package/src/lib/common/debug.zig +21 -11
  33. package/src/lib/common/js.zig +118 -0
  34. package/src/lib/common/optional.zig +67 -0
  35. package/src/lib/common/options.zig +12 -3
  36. package/src/lib/common/protocol.zig +904 -361
  37. package/src/lib/common/rational.zig +353 -0
  38. package/src/lib/common/rng.zig +24 -15
  39. package/src/lib/common/util.zig +12 -0
  40. package/src/lib/gen1/README.md +309 -192
  41. package/src/lib/gen1/calc.zig +426 -0
  42. package/src/lib/gen1/chance.zig +1060 -0
  43. package/src/lib/gen1/data/moves.zig +202 -190
  44. package/src/lib/gen1/data/species.zig +4 -4
  45. package/src/lib/gen1/data/types.zig +10 -10
  46. package/src/lib/gen1/data.zig +91 -77
  47. package/src/lib/gen1/helpers.zig +577 -36
  48. package/src/lib/gen1/mechanics.zig +1219 -821
  49. package/src/lib/gen2/README.md +105 -85
  50. package/src/lib/gen2/calc.zig +143 -0
  51. package/src/lib/gen2/chance.zig +1314 -0
  52. package/src/lib/gen2/data/items.zig +14 -20
  53. package/src/lib/gen2/data/moves.zig +664 -570
  54. package/src/lib/gen2/data/species.zig +2 -2
  55. package/src/lib/gen2/data/types.zig +137 -34
  56. package/src/lib/gen2/data.zig +128 -90
  57. package/src/lib/gen2/generated.zig +808 -0
  58. package/src/lib/gen2/helpers.zig +16 -22
  59. package/src/lib/gen2/mechanics.zig +3510 -12
  60. package/src/lib/pkmn.zig +68 -9
  61. package/src/test/display/pkmn.html.tmpl +368 -0
package/build.zig CHANGED
@@ -1,15 +1,20 @@
1
1
  const std = @import("std");
2
2
  const builtin = @import("builtin");
3
3
 
4
- const NativeTargetInfo = std.zig.system.NativeTargetInfo;
5
-
6
- 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
+ };
7
10
 
8
11
  pub fn module(b: *std.Build, options: Options) *std.Build.Module {
9
12
  const dirname = comptime std.fs.path.dirname(@src().file) orelse ".";
10
13
  const build_options = b.addOptions();
11
14
  build_options.addOption(?bool, "showdown", options.showdown);
12
- 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);
13
18
  return b.createModule(.{
14
19
  .source_file = .{ .path = dirname ++ "/src/lib/pkmn.zig" },
15
20
  .dependencies = &.{.{ .name = "build_options", .module = build_options.createModule() }},
@@ -29,25 +34,30 @@ pub fn build(b: *std.Build) !void {
29
34
  const dynamic = b.option(bool, "dynamic", "Build a dynamic library") orelse false;
30
35
  const strip = b.option(bool, "strip", "Strip debugging symbols from binary") orelse false;
31
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;
32
39
 
33
- const cmd = b.findProgram(&[_][]const u8{"strip"}, &[_][]const u8{}) catch null;
40
+ const cmd = b.findProgram(&.{"strip"}, &.{}) catch null;
34
41
 
35
- var parser = std.json.Parser.init(b.allocator, false);
36
- defer parser.deinit();
37
- var tree = try parser.parse(@embedFile("package.json"));
38
- defer tree.deinit();
39
- const version = tree.root.Object.get("version").?.String;
40
- const description = tree.root.Object.get("description").?.String;
41
- 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, ":");
42
48
  std.debug.assert(std.mem.eql(u8, repository.first(), "github"));
43
49
 
44
50
  const showdown =
45
51
  b.option(bool, "showdown", "Enable Pokémon Showdown compatibility mode") orelse false;
46
- 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;
47
55
 
48
56
  const options = b.addOptions();
49
57
  options.addOption(?bool, "showdown", showdown);
50
- options.addOption(?bool, "trace", trace);
58
+ options.addOption(?bool, "log", log);
59
+ options.addOption(?bool, "chance", chance);
60
+ options.addOption(?bool, "calc", calc);
51
61
 
52
62
  const name = if (showdown) "pkmn-showdown" else "pkmn";
53
63
 
@@ -56,17 +66,17 @@ pub fn build(b: *std.Build) !void {
56
66
  const addon = b.fmt("{s}.node", .{name});
57
67
  const lib = b.addSharedLibrary(.{
58
68
  .name = addon,
69
+ .main_pkg_path = .{ .path = "." },
59
70
  .root_source_file = .{ .path = "src/lib/binding/node.zig" },
60
71
  .optimize = optimize,
61
72
  .target = target,
62
73
  });
63
74
  lib.addOptions("build_options", options);
64
- lib.setMainPkgPath("./");
65
- lib.addSystemIncludePath(headers);
75
+ lib.addSystemIncludePath(.{ .path = headers });
66
76
  lib.linkLibC();
67
77
  if (node_import_lib) |il| {
68
- lib.addObjectFile(il);
69
- } else if ((try NativeTargetInfo.detect(target)).target.os.tag == .windows) {
78
+ lib.addObjectFile(.{ .path = il });
79
+ } else if ((try std.zig.system.NativeTargetInfo.detect(target)).target.os.tag == .windows) {
70
80
  try std.io.getStdErr().writeAll("Must provide --node-import-library path on Windows\n");
71
81
  std.process.exit(1);
72
82
  }
@@ -74,17 +84,18 @@ pub fn build(b: *std.Build) !void {
74
84
  maybeStrip(b, lib, b.getInstallStep(), strip, cmd);
75
85
  if (pic) lib.force_pic = pic;
76
86
  // Always emit to build/lib because this is where the driver code expects to find it
77
- // 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):
78
88
  //
79
89
  // lib.emit_bin = .{ .emit_to = b.fmt("build/lib/{s}", .{addon}) };
80
90
  // b.getInstallStep().dependOn(&lib.step);
81
91
  //
82
92
  // But ziglang/zig#14647 broke this so we now need to do an install() and then manually
83
93
  // rename the file ourself in install-pkmn-engine
84
- lib.install();
94
+ b.installArtifact(lib);
85
95
  } else if (wasm) {
86
96
  const lib = b.addSharedLibrary(.{
87
97
  .name = name,
98
+ .main_pkg_path = .{ .path = "." },
88
99
  .root_source_file = .{ .path = "src/lib/binding/wasm.zig" },
89
100
  .optimize = switch (optimize) {
90
101
  .ReleaseFast, .ReleaseSafe => .ReleaseSmall,
@@ -93,53 +104,63 @@ pub fn build(b: *std.Build) !void {
93
104
  .target = .{ .cpu_arch = .wasm32, .os_tag = .freestanding },
94
105
  });
95
106
  lib.addOptions("build_options", options);
96
- lib.setMainPkgPath("./");
97
107
  lib.stack_size = wasm_stack_size;
98
108
  lib.rdynamic = true;
99
109
  lib.strip = strip;
100
110
  if (pic) lib.force_pic = pic;
101
- const opt = b.findProgram(
102
- &[_][]const u8{"wasm-opt"},
103
- &[_][]const u8{"./node_modules/.bin"},
104
- ) catch null;
111
+ const opt = b.findProgram(&.{"wasm-opt"}, &.{"./node_modules/.bin"}) catch null;
105
112
  if (optimize != .Debug and opt != null) {
106
113
  const out = b.fmt("build/lib/{s}.wasm", .{name});
107
- const sh = b.addSystemCommand(&[_][]const u8{ opt.?, "-O4" });
114
+ const sh = b.addSystemCommand(&.{ opt.?, "-O4" });
108
115
  sh.addArtifactArg(lib);
109
116
  sh.addArg("-o");
110
117
  sh.addFileSourceArg(.{ .path = out });
111
118
  b.getInstallStep().dependOn(&sh.step);
112
119
  }
113
- lib.install();
120
+ b.installArtifact(lib);
114
121
  } else if (dynamic) {
115
122
  const lib = b.addSharedLibrary(.{
116
123
  .name = name,
124
+ .main_pkg_path = .{ .path = "." },
117
125
  .root_source_file = .{ .path = "src/lib/binding/c.zig" },
118
- .version = try std.builtin.Version.parse(version),
126
+ .version = try std.SemanticVersion.parse(version),
119
127
  .optimize = optimize,
120
128
  .target = target,
121
129
  });
122
130
  lib.addOptions("build_options", options);
123
- lib.setMainPkgPath("./");
124
- lib.addIncludePath("src/include");
131
+ lib.addIncludePath(.{ .path = "src/include" });
125
132
  maybeStrip(b, lib, b.getInstallStep(), strip, cmd);
126
133
  if (pic) lib.force_pic = pic;
127
- lib.install();
134
+ b.installArtifact(lib);
128
135
  c = true;
129
136
  } else {
130
137
  const lib = b.addStaticLibrary(.{
131
138
  .name = name,
139
+ .main_pkg_path = .{ .path = "." },
132
140
  .root_source_file = .{ .path = "src/lib/binding/c.zig" },
133
141
  .optimize = optimize,
134
142
  .target = target,
135
143
  });
136
144
  lib.addOptions("build_options", options);
137
- lib.setMainPkgPath("./");
138
- lib.addIncludePath("src/include");
145
+ lib.addIncludePath(.{ .path = "src/include" });
139
146
  lib.bundle_compiler_rt = true;
140
147
  maybeStrip(b, lib, b.getInstallStep(), strip, cmd);
141
148
  if (pic) lib.force_pic = pic;
142
- 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);
143
164
  c = true;
144
165
  }
145
166
 
@@ -181,14 +202,20 @@ pub fn build(b: *std.Build) !void {
181
202
  .strip = strip,
182
203
  .cmd = cmd,
183
204
  };
205
+
206
+ // TODO: tests can be run multiple times due to @imports
184
207
  const tests = TestStep.create(b, options, config);
185
208
 
186
209
  var exes = std.ArrayList(*std.Build.CompileStep).init(b.allocator);
187
210
  const tools: ToolConfig = .{
211
+ .options = .{
212
+ .showdown = showdown,
213
+ .log = log,
214
+ .chance = chance,
215
+ .calc = calc,
216
+ },
188
217
  .general = config,
189
218
  .tool = .{
190
- .showdown = showdown,
191
- .trace = trace,
192
219
  .tests = if (tests.build) tests else null,
193
220
  .exes = &exes,
194
221
  },
@@ -197,28 +224,32 @@ pub fn build(b: *std.Build) !void {
197
224
  var benchmark_config = tools;
198
225
  benchmark_config.general.optimize = .ReleaseFast;
199
226
  benchmark_config.general.strip = true;
200
- const benchmark = tool(b, "src/test/benchmark.zig", benchmark_config);
227
+ const benchmark = try tool(b, "src/test/benchmark.zig", benchmark_config);
201
228
 
202
229
  var fuzz_config = tools;
203
230
  fuzz_config.general.strip = false;
204
231
  fuzz_config.tool.name = "fuzz";
205
- const fuzz = tool(b, "src/test/benchmark.zig", fuzz_config);
206
-
207
- const serde = tool(b, "src/tools/serde.zig", tools);
208
- const protocol = tool(b, "src/tools/protocol.zig", tools);
209
-
210
- const lint_exe =
211
- b.addExecutable(.{ .name = "lint", .root_source_file = .{ .path = "src/tools/lint.zig" } });
212
- if (tests.build) tests.step.dependOn(&lint_exe.step);
213
- const lint = lint_exe.run();
214
-
215
- b.step("benchmark", "Run benchmark code").dependOn(&benchmark.step);
216
- b.step("fuzz", "Run fuzz tester").dependOn(&fuzz.step);
217
- b.step("lint", "Lint source files").dependOn(&lint.step);
218
- b.step("protocol", "Run protocol dump tool").dependOn(&protocol.step);
219
- b.step("serde", "Run serialization/deserialization tool").dependOn(&serde.step);
232
+ const fuzz = try tool(b, "src/test/fuzz.zig", fuzz_config);
233
+
234
+ const analyze = try tool(b, "src/tools/analyze.zig", tools);
235
+ const dump = try tool(b, "src/tools/dump.zig", tools);
236
+ const transitions = try tool(b, "src/tools/transitions.zig", tools);
237
+
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 = try tool(b, "src/tools/serde.zig", hack);
242
+
243
+ if (analyze) |t| b.step("analyze", "Run LLVM analysis tool").dependOn(&t.step);
244
+ if (benchmark) |t| b.step("benchmark", "Run benchmark code").dependOn(&t.step);
245
+ if (dump) |t| b.step("dump", "Run protocol dump tool").dependOn(&t.step);
246
+ if (fuzz) |t| b.step("fuzz", "Run fuzz tester").dependOn(&t.step);
247
+ if (serde) |t| b.step("serde", "Run serialization/deserialization tool").dependOn(&t.step);
220
248
  b.step("test", "Run all tests").dependOn(&tests.step);
221
249
  b.step("tools", "Install tools").dependOn(&ToolsStep.create(b, &exes).step);
250
+ if (transitions) |t| {
251
+ b.step("transitions", "Visualize transitions algorithm search").dependOn(&t.step);
252
+ }
222
253
  }
223
254
 
224
255
  fn maybeStrip(
@@ -235,7 +266,7 @@ fn maybeStrip(
235
266
  if (mac and artifact.isDynamicLibrary()) return;
236
267
  // Assuming GNU strip, which complains "illegal pathname found in archive member"...
237
268
  if (!mac and artifact.isStaticLibrary()) return;
238
- const sh = b.addSystemCommand(&[_][]const u8{ cmd.?, if (mac) "-x" else "-s" });
269
+ const sh = b.addSystemCommand(&.{ cmd.?, if (mac) "-x" else "-s" });
239
270
  sh.addArtifactArg(artifact);
240
271
  step.dependOn(&sh.step);
241
272
  }
@@ -248,12 +279,6 @@ const Config = struct {
248
279
  cmd: ?[]const u8,
249
280
  };
250
281
 
251
- const TESTS = [_][]const u8{
252
- "src/lib/common/test.zig",
253
- "src/lib/gen1/test.zig",
254
- "src/lib/gen2/test.zig",
255
- };
256
-
257
282
  const TestStep = struct {
258
283
  step: std.Build.Step,
259
284
  build: bool,
@@ -261,60 +286,57 @@ const TestStep = struct {
261
286
  pub fn create(b: *std.Build, options: *std.Build.OptionsStep, config: Config) *TestStep {
262
287
  const coverage = b.option([]const u8, "test-coverage", "Generate test coverage");
263
288
  const test_file = b.option([]const u8, "test-file", "Input file for test");
264
- const test_bin = b.option([]const u8, "test-bin", "Emit test binary to");
265
289
  const test_filter =
266
290
  b.option([]const u8, "test-filter", "Skip tests that do not match filter");
267
- const test_no_exec =
268
- b.option(bool, "test-no-exec", "Compiles test binary without running it") orelse false;
269
291
 
270
292
  const self = b.allocator.create(TestStep) catch @panic("OOM");
271
293
  const step = std.Build.Step.init(.{ .id = .custom, .name = "Run all tests", .owner = b });
272
- self.* = TestStep{ .step = step, .build = test_filter == null };
273
-
274
- const paths: []const []const u8 =
275
- if (test_file) |t| &.{t} else if (coverage != null) &.{"src/lib/test.zig"} else &TESTS;
276
- for (paths) |path| {
277
- const tests = b.addTest(.{
278
- .name = std.fs.path.basename(std.fs.path.dirname(path).?),
279
- .root_source_file = .{ .path = path },
280
- .optimize = config.optimize,
281
- .target = config.target,
282
- });
283
- tests.setMainPkgPath("./");
284
- tests.setFilter(test_filter);
285
- tests.addOptions("build_options", options);
286
- tests.single_threaded = true;
287
- maybeStrip(b, tests, &tests.step, config.strip, config.cmd);
288
- if (config.pic) tests.force_pic = config.pic;
289
- if (test_bin) |bin| {
290
- tests.name = std.fs.path.basename(bin);
291
- if (std.fs.path.dirname(bin)) |dir| tests.setOutputDir(dir);
292
- }
293
- if (coverage) |c| {
294
- tests.setExecCmd(&.{ "kcov", "--include-pattern=src/lib", c, null });
295
- }
296
- self.step.dependOn(if (test_no_exec) &tests.step else &tests.run().step);
294
+ self.* = .{ .step = step, .build = test_filter == null };
295
+
296
+ const path = test_file orelse "src/lib/test.zig";
297
+ const tests = b.addTest(.{
298
+ .name = b.fmt("{s}-{s}", .{
299
+ std.fs.path.basename(std.fs.path.dirname(path).?),
300
+ std.fs.path.stem(std.fs.path.basename(path)),
301
+ }),
302
+ .main_pkg_path = .{ .path = "." },
303
+ .root_source_file = .{ .path = path },
304
+ .optimize = config.optimize,
305
+ .target = config.target,
306
+ .filter = test_filter,
307
+ });
308
+ tests.addOptions("build_options", options);
309
+ tests.single_threaded = true;
310
+ maybeStrip(b, tests, &tests.step, config.strip, config.cmd);
311
+ if (config.pic) tests.force_pic = config.pic;
312
+ if (coverage) |c| {
313
+ tests.setExecCmd(&.{ "kcov", "--include-pattern=src/lib", c, null });
297
314
  }
315
+ self.step.dependOn(&b.addRunArtifact(tests).step);
316
+
298
317
  return self;
299
318
  }
300
319
  };
301
320
 
302
321
  const ToolConfig = struct {
322
+ options: Options,
303
323
  general: Config,
304
324
  tool: struct {
305
- showdown: bool,
306
- trace: bool,
307
325
  tests: ?*TestStep,
308
326
  name: ?[]const u8 = null,
309
327
  exes: *std.ArrayList(*std.Build.CompileStep),
310
328
  },
311
329
  };
312
330
 
313
- fn tool(b: *std.Build, path: []const u8, config: ToolConfig) *std.Build.RunStep {
331
+ fn tool(b: *std.Build, path: []const u8, config: ToolConfig) !?*std.Build.RunStep {
332
+ std.fs.cwd().access(path, .{}) catch |err| switch (err) {
333
+ error.FileNotFound => return null,
334
+ else => |e| return e,
335
+ };
314
336
  var name = config.tool.name orelse std.fs.path.basename(path);
315
337
  const index = std.mem.lastIndexOfScalar(u8, name, '.');
316
338
  if (index) |i| name = name[0..i];
317
- if (config.tool.showdown) name = b.fmt("{s}-showdown", .{name});
339
+ if (config.options.showdown orelse false) name = b.fmt("{s}-showdown", .{name});
318
340
 
319
341
  const exe = b.addExecutable(.{
320
342
  .name = name,
@@ -322,16 +344,14 @@ fn tool(b: *std.Build, path: []const u8, config: ToolConfig) *std.Build.RunStep
322
344
  .target = config.general.target,
323
345
  .optimize = config.general.optimize,
324
346
  });
325
- exe.addModule("pkmn", module(b, .{
326
- .showdown = config.tool.showdown,
327
- .trace = config.tool.trace,
328
- }));
347
+ exe.addModule("pkmn", module(b, config.options));
348
+
329
349
  exe.single_threaded = true;
330
350
  if (config.general.pic) exe.force_pic = config.general.pic;
331
351
  if (config.tool.tests) |ts| ts.step.dependOn(&exe.step);
332
352
  config.tool.exes.append(exe) catch @panic("OOM");
333
353
 
334
- const run = exe.run();
354
+ const run = b.addRunArtifact(exe);
335
355
  maybeStrip(b, exe, &run.step, config.general.strip, config.general.cmd);
336
356
  if (b.args) |args| run.addArgs(args);
337
357
 
@@ -344,8 +364,8 @@ const ToolsStep = struct {
344
364
  pub fn create(b: *std.Build, exes: *std.ArrayList(*std.Build.CompileStep)) *ToolsStep {
345
365
  const self = b.allocator.create(ToolsStep) catch @panic("OOM");
346
366
  const step = std.Build.Step.init(.{ .id = .custom, .name = "Install tools", .owner = b });
347
- self.* = ToolsStep{ .step = step };
348
- for (exes.items) |t| self.step.dependOn(&b.addInstallArtifact(t).step);
367
+ self.* = .{ .step = step };
368
+ for (exes.items) |t| self.step.dependOn(&b.addInstallArtifact(t, .{}).step);
349
369
  return self;
350
370
  }
351
371
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pkmn/engine",
3
- "version": "0.1.0-dev.7f37a47c",
3
+ "version": "0.1.0-dev.80019d10",
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.33",
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-alpha.0",
65
- "@pkmn/img": "^0.2.8",
66
- "@pkmn/sets": "^5.0.4",
67
- "@pkmn/sim": "0.7.33",
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.2",
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",
@@ -101,7 +121,7 @@
101
121
  "ignorePatterns": [
102
122
  "dist/",
103
123
  "node_modules/",
104
- "src/examples/zig",
124
+ "examples/zig",
105
125
  "build/"
106
126
  ],
107
127
  "env": {
@@ -117,7 +137,7 @@
117
137
  "parserOptions": {
118
138
  "project": [
119
139
  "./tsconfig.json",
120
- "./src/examples/js/tsconfig.json"
140
+ "./examples/js/tsconfig.json"
121
141
  ]
122
142
  }
123
143
  },
@@ -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"