@pkmn/engine 0.1.0-dev.ad6136e4 → 0.1.0-dev.b3f3e3a6
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/README.md +59 -48
- package/build/pkg/addon.js +3 -2
- package/build/pkg/addon.js.map +1 -1
- package/build/pkg/data/ids.json +12 -12
- package/build/pkg/data/layout.json +26 -4
- package/build/pkg/data/protocol.json +69 -12
- package/build/pkg/data.d.ts +2 -2
- package/build/pkg/gen1.js +15 -18
- package/build/pkg/gen1.js.map +1 -1
- package/build/pkg/index.js.map +1 -1
- package/build/pkg/protocol.js +56 -37
- package/build/pkg/protocol.js.map +1 -1
- package/build/tools/debug.js +3 -1
- package/build/tools/debug.js.map +1 -1
- package/build.zig +103 -73
- package/package.json +43 -22
- package/src/bin/install-pkmn-engine +10 -5
- package/src/lib/binding/node.zig +46 -141
- package/src/lib/binding/wasm.zig +4 -2
- package/src/lib/common/battle.zig +17 -0
- package/src/lib/common/data.zig +19 -31
- package/src/lib/common/debug.zig +20 -11
- package/src/lib/common/js.zig +118 -0
- package/src/lib/common/optional.zig +67 -0
- package/src/lib/common/options.zig +9 -0
- package/src/lib/common/protocol.zig +868 -325
- package/src/lib/common/rational.zig +353 -0
- package/src/lib/common/rng.zig +24 -15
- package/src/lib/common/util.zig +12 -0
- package/src/lib/gen1/README.md +286 -204
- package/src/lib/gen1/calc.zig +426 -0
- package/src/lib/gen1/chance.zig +1060 -0
- package/src/lib/gen1/data/moves.zig +202 -190
- package/src/lib/gen1/data/species.zig +4 -4
- package/src/lib/gen1/data/types.zig +10 -10
- package/src/lib/gen1/data.zig +83 -71
- package/src/lib/gen1/helpers.zig +573 -17
- package/src/lib/gen1/mechanics.zig +931 -692
- package/src/lib/gen2/README.md +105 -85
- package/src/lib/gen2/calc.zig +143 -0
- package/src/lib/gen2/chance.zig +1314 -0
- package/src/lib/gen2/data/items.zig +14 -20
- package/src/lib/gen2/data/moves.zig +664 -570
- package/src/lib/gen2/data/species.zig +2 -2
- package/src/lib/gen2/data/types.zig +137 -34
- package/src/lib/gen2/data.zig +124 -86
- package/src/lib/gen2/generated.zig +808 -0
- package/src/lib/gen2/helpers.zig +16 -22
- package/src/lib/gen2/mechanics.zig +3510 -12
- package/src/lib/pkmn.zig +61 -2
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 {
|
|
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
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() }},
|
|
@@ -28,25 +35,29 @@ pub fn build(b: *std.Build) !void {
|
|
|
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;
|
|
30
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;
|
|
31
39
|
|
|
32
40
|
const cmd = b.findProgram(&.{"strip"}, &.{}) catch null;
|
|
33
41
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
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, ":");
|
|
41
48
|
std.debug.assert(std.mem.eql(u8, repository.first(), "github"));
|
|
42
49
|
|
|
43
50
|
const showdown =
|
|
44
51
|
b.option(bool, "showdown", "Enable Pokémon Showdown compatibility mode") orelse false;
|
|
45
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;
|
|
46
55
|
|
|
47
56
|
const options = b.addOptions();
|
|
48
57
|
options.addOption(?bool, "showdown", showdown);
|
|
49
58
|
options.addOption(?bool, "log", log);
|
|
59
|
+
options.addOption(?bool, "chance", chance);
|
|
60
|
+
options.addOption(?bool, "calc", calc);
|
|
50
61
|
|
|
51
62
|
const name = if (showdown) "pkmn-showdown" else "pkmn";
|
|
52
63
|
|
|
@@ -55,16 +66,16 @@ pub fn build(b: *std.Build) !void {
|
|
|
55
66
|
const addon = b.fmt("{s}.node", .{name});
|
|
56
67
|
const lib = b.addSharedLibrary(.{
|
|
57
68
|
.name = addon,
|
|
69
|
+
.main_pkg_path = .{ .path = "." },
|
|
58
70
|
.root_source_file = .{ .path = "src/lib/binding/node.zig" },
|
|
59
71
|
.optimize = optimize,
|
|
60
72
|
.target = target,
|
|
61
73
|
});
|
|
62
74
|
lib.addOptions("build_options", options);
|
|
63
|
-
lib.
|
|
64
|
-
lib.addSystemIncludePath(headers);
|
|
75
|
+
lib.addSystemIncludePath(.{ .path = headers });
|
|
65
76
|
lib.linkLibC();
|
|
66
77
|
if (node_import_lib) |il| {
|
|
67
|
-
lib.addObjectFile(il);
|
|
78
|
+
lib.addObjectFile(.{ .path = il });
|
|
68
79
|
} else if ((try std.zig.system.NativeTargetInfo.detect(target)).target.os.tag == .windows) {
|
|
69
80
|
try std.io.getStdErr().writeAll("Must provide --node-import-library path on Windows\n");
|
|
70
81
|
std.process.exit(1);
|
|
@@ -84,6 +95,7 @@ pub fn build(b: *std.Build) !void {
|
|
|
84
95
|
} else if (wasm) {
|
|
85
96
|
const lib = b.addSharedLibrary(.{
|
|
86
97
|
.name = name,
|
|
98
|
+
.main_pkg_path = .{ .path = "." },
|
|
87
99
|
.root_source_file = .{ .path = "src/lib/binding/wasm.zig" },
|
|
88
100
|
.optimize = switch (optimize) {
|
|
89
101
|
.ReleaseFast, .ReleaseSafe => .ReleaseSmall,
|
|
@@ -92,7 +104,6 @@ pub fn build(b: *std.Build) !void {
|
|
|
92
104
|
.target = .{ .cpu_arch = .wasm32, .os_tag = .freestanding },
|
|
93
105
|
});
|
|
94
106
|
lib.addOptions("build_options", options);
|
|
95
|
-
lib.setMainPkgPath("./");
|
|
96
107
|
lib.stack_size = wasm_stack_size;
|
|
97
108
|
lib.rdynamic = true;
|
|
98
109
|
lib.strip = strip;
|
|
@@ -110,14 +121,14 @@ pub fn build(b: *std.Build) !void {
|
|
|
110
121
|
} else if (dynamic) {
|
|
111
122
|
const lib = b.addSharedLibrary(.{
|
|
112
123
|
.name = name,
|
|
124
|
+
.main_pkg_path = .{ .path = "." },
|
|
113
125
|
.root_source_file = .{ .path = "src/lib/binding/c.zig" },
|
|
114
|
-
.version = try std.
|
|
126
|
+
.version = try std.SemanticVersion.parse(version),
|
|
115
127
|
.optimize = optimize,
|
|
116
128
|
.target = target,
|
|
117
129
|
});
|
|
118
130
|
lib.addOptions("build_options", options);
|
|
119
|
-
lib.
|
|
120
|
-
lib.addIncludePath("src/include");
|
|
131
|
+
lib.addIncludePath(.{ .path = "src/include" });
|
|
121
132
|
maybeStrip(b, lib, b.getInstallStep(), strip, cmd);
|
|
122
133
|
if (pic) lib.force_pic = pic;
|
|
123
134
|
b.installArtifact(lib);
|
|
@@ -125,17 +136,30 @@ pub fn build(b: *std.Build) !void {
|
|
|
125
136
|
} else {
|
|
126
137
|
const lib = b.addStaticLibrary(.{
|
|
127
138
|
.name = name,
|
|
139
|
+
.main_pkg_path = .{ .path = "." },
|
|
128
140
|
.root_source_file = .{ .path = "src/lib/binding/c.zig" },
|
|
129
141
|
.optimize = optimize,
|
|
130
142
|
.target = target,
|
|
131
143
|
});
|
|
132
144
|
lib.addOptions("build_options", options);
|
|
133
|
-
lib.
|
|
134
|
-
lib.addIncludePath("src/include");
|
|
145
|
+
lib.addIncludePath(.{ .path = "src/include" });
|
|
135
146
|
lib.bundle_compiler_rt = true;
|
|
136
147
|
maybeStrip(b, lib, b.getInstallStep(), strip, cmd);
|
|
137
148
|
if (pic) lib.force_pic = pic;
|
|
138
|
-
if (emit_asm)
|
|
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
|
+
}
|
|
139
163
|
b.installArtifact(lib);
|
|
140
164
|
c = true;
|
|
141
165
|
}
|
|
@@ -178,14 +202,20 @@ pub fn build(b: *std.Build) !void {
|
|
|
178
202
|
.strip = strip,
|
|
179
203
|
.cmd = cmd,
|
|
180
204
|
};
|
|
205
|
+
|
|
206
|
+
// TODO: tests can be run multiple times due to @imports
|
|
181
207
|
const tests = TestStep.create(b, options, config);
|
|
182
208
|
|
|
183
209
|
var exes = std.ArrayList(*std.Build.CompileStep).init(b.allocator);
|
|
184
210
|
const tools: ToolConfig = .{
|
|
185
|
-
.
|
|
186
|
-
.tool = .{
|
|
211
|
+
.options = .{
|
|
187
212
|
.showdown = showdown,
|
|
188
213
|
.log = log,
|
|
214
|
+
.chance = chance,
|
|
215
|
+
.calc = calc,
|
|
216
|
+
},
|
|
217
|
+
.general = config,
|
|
218
|
+
.tool = .{
|
|
189
219
|
.tests = if (tests.build) tests else null,
|
|
190
220
|
.exes = &exes,
|
|
191
221
|
},
|
|
@@ -194,28 +224,32 @@ pub fn build(b: *std.Build) !void {
|
|
|
194
224
|
var benchmark_config = tools;
|
|
195
225
|
benchmark_config.general.optimize = .ReleaseFast;
|
|
196
226
|
benchmark_config.general.strip = true;
|
|
197
|
-
const benchmark = tool(b, "src/test/benchmark.zig", benchmark_config);
|
|
227
|
+
const benchmark = try tool(b, "src/test/benchmark.zig", benchmark_config);
|
|
198
228
|
|
|
199
229
|
var fuzz_config = tools;
|
|
200
230
|
fuzz_config.general.strip = false;
|
|
201
231
|
fuzz_config.tool.name = "fuzz";
|
|
202
|
-
const fuzz = tool(b, "src/test/
|
|
203
|
-
|
|
204
|
-
const
|
|
205
|
-
const
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
b.step("
|
|
214
|
-
b.step("
|
|
215
|
-
b.step("
|
|
216
|
-
b.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);
|
|
217
248
|
b.step("test", "Run all tests").dependOn(&tests.step);
|
|
218
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
|
+
}
|
|
219
253
|
}
|
|
220
254
|
|
|
221
255
|
fn maybeStrip(
|
|
@@ -245,12 +279,6 @@ const Config = struct {
|
|
|
245
279
|
cmd: ?[]const u8,
|
|
246
280
|
};
|
|
247
281
|
|
|
248
|
-
const TESTS = .{
|
|
249
|
-
"src/lib/common/test.zig",
|
|
250
|
-
"src/lib/gen1/test.zig",
|
|
251
|
-
"src/lib/gen2/test.zig",
|
|
252
|
-
};
|
|
253
|
-
|
|
254
282
|
const TestStep = struct {
|
|
255
283
|
step: std.Build.Step,
|
|
256
284
|
build: bool,
|
|
@@ -263,48 +291,52 @@ const TestStep = struct {
|
|
|
263
291
|
|
|
264
292
|
const self = b.allocator.create(TestStep) catch @panic("OOM");
|
|
265
293
|
const step = std.Build.Step.init(.{ .id = .custom, .name = "Run all tests", .owner = b });
|
|
266
|
-
self.* =
|
|
267
|
-
|
|
268
|
-
const
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
}
|
|
286
|
-
self.step.dependOn(&b.addRunArtifact(tests).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 });
|
|
287
314
|
}
|
|
315
|
+
self.step.dependOn(&b.addRunArtifact(tests).step);
|
|
316
|
+
|
|
288
317
|
return self;
|
|
289
318
|
}
|
|
290
319
|
};
|
|
291
320
|
|
|
292
321
|
const ToolConfig = struct {
|
|
322
|
+
options: Options,
|
|
293
323
|
general: Config,
|
|
294
324
|
tool: struct {
|
|
295
|
-
showdown: bool,
|
|
296
|
-
log: bool,
|
|
297
325
|
tests: ?*TestStep,
|
|
298
326
|
name: ?[]const u8 = null,
|
|
299
327
|
exes: *std.ArrayList(*std.Build.CompileStep),
|
|
300
328
|
},
|
|
301
329
|
};
|
|
302
330
|
|
|
303
|
-
fn tool(b: *std.Build, path: []const u8, config: ToolConfig)
|
|
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
|
+
};
|
|
304
336
|
var name = config.tool.name orelse std.fs.path.basename(path);
|
|
305
337
|
const index = std.mem.lastIndexOfScalar(u8, name, '.');
|
|
306
338
|
if (index) |i| name = name[0..i];
|
|
307
|
-
if (config.
|
|
339
|
+
if (config.options.showdown orelse false) name = b.fmt("{s}-showdown", .{name});
|
|
308
340
|
|
|
309
341
|
const exe = b.addExecutable(.{
|
|
310
342
|
.name = name,
|
|
@@ -312,10 +344,8 @@ fn tool(b: *std.Build, path: []const u8, config: ToolConfig) *std.Build.RunStep
|
|
|
312
344
|
.target = config.general.target,
|
|
313
345
|
.optimize = config.general.optimize,
|
|
314
346
|
});
|
|
315
|
-
exe.addModule("pkmn", module(b, .
|
|
316
|
-
|
|
317
|
-
.log = config.tool.log,
|
|
318
|
-
}));
|
|
347
|
+
exe.addModule("pkmn", module(b, config.options));
|
|
348
|
+
|
|
319
349
|
exe.single_threaded = true;
|
|
320
350
|
if (config.general.pic) exe.force_pic = config.general.pic;
|
|
321
351
|
if (config.tool.tests) |ts| ts.step.dependOn(&exe.step);
|
|
@@ -334,8 +364,8 @@ const ToolsStep = struct {
|
|
|
334
364
|
pub fn create(b: *std.Build, exes: *std.ArrayList(*std.Build.CompileStep)) *ToolsStep {
|
|
335
365
|
const self = b.allocator.create(ToolsStep) catch @panic("OOM");
|
|
336
366
|
const step = std.Build.Step.init(.{ .id = .custom, .name = "Install tools", .owner = b });
|
|
337
|
-
self.* =
|
|
338
|
-
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);
|
|
339
369
|
return self;
|
|
340
370
|
}
|
|
341
371
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pkmn/engine",
|
|
3
|
-
"version": "0.1.0-dev.
|
|
3
|
+
"version": "0.1.0-dev.b3f3e3a6",
|
|
4
4
|
"description": "A minimal, complete, Pokémon battle simulation engine optimized for performance",
|
|
5
5
|
"repository": "github:pkmn/engine",
|
|
6
6
|
"license": "MIT",
|
|
@@ -34,22 +34,32 @@
|
|
|
34
34
|
"src/bin/install-pkmn-engine",
|
|
35
35
|
"src/lib/binding/node.zig",
|
|
36
36
|
"src/lib/binding/wasm.zig",
|
|
37
|
+
"src/lib/common/battle.zig",
|
|
37
38
|
"src/lib/common/data.zig",
|
|
38
39
|
"src/lib/common/debug.zig",
|
|
40
|
+
"src/lib/common/js.zig",
|
|
41
|
+
"src/lib/common/optional.zig",
|
|
39
42
|
"src/lib/common/options.zig",
|
|
40
43
|
"src/lib/common/protocol.zig",
|
|
44
|
+
"src/lib/common/rational.zig",
|
|
41
45
|
"src/lib/common/rng.zig",
|
|
46
|
+
"src/lib/common/util.zig",
|
|
47
|
+
"src/lib/gen1/calc.zig",
|
|
48
|
+
"src/lib/gen1/chance.zig",
|
|
42
49
|
"src/lib/gen1/data.zig",
|
|
43
50
|
"src/lib/gen1/data/moves.zig",
|
|
44
51
|
"src/lib/gen1/data/species.zig",
|
|
45
52
|
"src/lib/gen1/data/types.zig",
|
|
46
53
|
"src/lib/gen1/helpers.zig",
|
|
47
54
|
"src/lib/gen1/mechanics.zig",
|
|
55
|
+
"src/lib/gen2/calc.zig",
|
|
56
|
+
"src/lib/gen2/chance.zig",
|
|
48
57
|
"src/lib/gen2/data.zig",
|
|
49
58
|
"src/lib/gen2/data/items.zig",
|
|
50
59
|
"src/lib/gen2/data/moves.zig",
|
|
51
60
|
"src/lib/gen2/data/species.zig",
|
|
52
61
|
"src/lib/gen2/data/types.zig",
|
|
62
|
+
"src/lib/gen2/generated.zig",
|
|
53
63
|
"src/lib/gen2/helpers.zig",
|
|
54
64
|
"src/lib/gen2/mechanics.zig",
|
|
55
65
|
"src/lib/pkmn.zig",
|
|
@@ -66,30 +76,30 @@
|
|
|
66
76
|
"access": "public"
|
|
67
77
|
},
|
|
68
78
|
"dependencies": {
|
|
69
|
-
"@pkmn/data": "^0.7.
|
|
70
|
-
"@pkmn/protocol": "^0.6.
|
|
79
|
+
"@pkmn/data": "^0.7.53",
|
|
80
|
+
"@pkmn/protocol": "^0.6.16"
|
|
71
81
|
},
|
|
72
82
|
"devDependencies": {
|
|
73
|
-
"@pkmn/eslint-config": "^3.
|
|
74
|
-
"@pkmn/img": "^0.2.
|
|
75
|
-
"@pkmn/sets": "^5.0
|
|
76
|
-
"@pkmn/sim": "0.7.
|
|
77
|
-
"@types/html-minifier": "^4.0.
|
|
78
|
-
"@types/jest": "^29.5.
|
|
79
|
-
"@types/minimist": "^1.2.
|
|
80
|
-
"@types/mustache": "^4.2.
|
|
81
|
-
"@types/node": "^20.2
|
|
82
|
-
"@vitest/coverage-c8": "^0.
|
|
83
|
-
"binaryen": "^
|
|
84
|
-
"eslint": "^8.
|
|
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",
|
|
85
95
|
"html-minifier": "^4.0.0",
|
|
86
|
-
"json-stringify-pretty-compact": "
|
|
96
|
+
"json-stringify-pretty-compact": "3.0.0",
|
|
87
97
|
"minimist": "^1.2.8",
|
|
88
98
|
"mustache": "^4.2.0",
|
|
89
99
|
"source-map-support": "^0.5.21",
|
|
90
100
|
"trakr": "^0.2.0",
|
|
91
|
-
"typescript": "^5.
|
|
92
|
-
"vitest": "^0.
|
|
101
|
+
"typescript": "^5.2.2",
|
|
102
|
+
"vitest": "^0.34.6"
|
|
93
103
|
},
|
|
94
104
|
"scripts": {
|
|
95
105
|
"lint": "eslint --cache src --ext ts,js && eslint src/bin/*",
|
|
@@ -111,7 +121,7 @@
|
|
|
111
121
|
"ignorePatterns": [
|
|
112
122
|
"dist/",
|
|
113
123
|
"node_modules/",
|
|
114
|
-
"
|
|
124
|
+
"examples/zig",
|
|
115
125
|
"build/"
|
|
116
126
|
],
|
|
117
127
|
"env": {
|
|
@@ -127,7 +137,7 @@
|
|
|
127
137
|
"parserOptions": {
|
|
128
138
|
"project": [
|
|
129
139
|
"./tsconfig.json",
|
|
130
|
-
"./
|
|
140
|
+
"./examples/js/tsconfig.json"
|
|
131
141
|
]
|
|
132
142
|
}
|
|
133
143
|
},
|
|
@@ -140,7 +150,8 @@
|
|
|
140
150
|
"rules": {
|
|
141
151
|
"no-control-regex": "off",
|
|
142
152
|
"@typescript-eslint/no-empty-interface": "off",
|
|
143
|
-
"@typescript-eslint/no-shadow": "off"
|
|
153
|
+
"@typescript-eslint/no-shadow": "off",
|
|
154
|
+
"@typescript-eslint/no-unsafe-declaration-merging": "off"
|
|
144
155
|
}
|
|
145
156
|
},
|
|
146
157
|
{
|
|
@@ -156,7 +167,17 @@
|
|
|
156
167
|
"src/test/benchmark*.ts"
|
|
157
168
|
],
|
|
158
169
|
"rules": {
|
|
159
|
-
"@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"
|
|
160
181
|
}
|
|
161
182
|
},
|
|
162
183
|
{
|
|
@@ -10,7 +10,7 @@ const path = require('path');
|
|
|
10
10
|
const {pipeline} = require('stream/promises');
|
|
11
11
|
const tty = require('tty');
|
|
12
12
|
|
|
13
|
-
const ZIG_VERSION = {major: 0, minor: 11, patch: 0
|
|
13
|
+
const ZIG_VERSION = {major: 0, minor: 11, patch: 0};
|
|
14
14
|
const DEV = ZIG_VERSION.dev ? `-dev.${ZIG_VERSION.dev}` : '';
|
|
15
15
|
const VERSION = `${ZIG_VERSION.major}.${ZIG_VERSION.minor}.${ZIG_VERSION.patch}${DEV}`;
|
|
16
16
|
const INDEX = 'https://ziglang.org/download/index.json';
|
|
@@ -336,14 +336,18 @@ const downloadImportLib = async () => {
|
|
|
336
336
|
node = true;
|
|
337
337
|
if (!options) {
|
|
338
338
|
const addon = require(copy);
|
|
339
|
-
if (addon.options.showdown) opts.push('-Dshowdown');
|
|
340
|
-
if (addon.options.log) opts.push('-Dlog');
|
|
339
|
+
if (addon.engine.options.showdown) opts.push('-Dshowdown');
|
|
340
|
+
if (addon.engine.options.log) opts.push('-Dlog');
|
|
341
|
+
if (addon.engine.options.chance) opts.push('-Dchance');
|
|
342
|
+
if (addon.engine.options.calc) opts.push('-Dcalc');
|
|
341
343
|
}
|
|
342
344
|
} else if (!options) {
|
|
343
345
|
const addon = await WebAssembly.instantiate(fs.readFileSync(copy));
|
|
344
346
|
const values = new Uint8Array(addon.instance.exports.memory.buffer);
|
|
345
347
|
if (values[addon.instance.exports.SHOWDOWN.value]) opts.push('-Dshowdown');
|
|
346
348
|
if (values[addon.instance.exports.LOG.value]) opts.push('-Dlog');
|
|
349
|
+
if (values[addon.instance.exports.CHANCE.value]) opts.push('-Dchance');
|
|
350
|
+
if (values[addon.instance.exports.CALC.value]) opts.push('-Dcalc');
|
|
347
351
|
}
|
|
348
352
|
const key = `${type} ${opts.sort().join(' ')}`;
|
|
349
353
|
if (!configs.has(key)) configs.set(key, {type, options: opts});
|
|
@@ -354,8 +358,9 @@ const downloadImportLib = async () => {
|
|
|
354
358
|
// either the default options or whatever was passed in
|
|
355
359
|
if (!configs.size) {
|
|
356
360
|
node = true;
|
|
357
|
-
|
|
358
|
-
configs.set('
|
|
361
|
+
const DEFAULT = ['-Dshowdown'];
|
|
362
|
+
configs.set('node', {type: 'node', options: options || DEFAULT});
|
|
363
|
+
configs.set('wasm', {type: 'wasm', options: options || DEFAULT});
|
|
359
364
|
}
|
|
360
365
|
|
|
361
366
|
const headers = node ? await downloadHeaders() : undefined;
|