@pkmn/engine 0.1.0-dev.550c3889 → 0.1.0-dev.5ec64ea5

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/build.zig CHANGED
@@ -1,13 +1,13 @@
1
1
  const std = @import("std");
2
2
  const builtin = @import("builtin");
3
3
 
4
- pub const Options = struct { showdown: ?bool = null, log: ?bool = null };
4
+ pub const Options = struct { showdown: ?bool = null, trace: ?bool = null };
5
5
 
6
6
  pub fn module(b: *std.Build, options: Options) *std.Build.Module {
7
7
  const dirname = comptime std.fs.path.dirname(@src().file) orelse ".";
8
8
  const build_options = b.addOptions();
9
9
  build_options.addOption(?bool, "showdown", options.showdown);
10
- build_options.addOption(?bool, "log", options.log);
10
+ build_options.addOption(?bool, "trace", options.trace);
11
11
  return b.createModule(.{
12
12
  .source_file = .{ .path = dirname ++ "/src/lib/pkmn.zig" },
13
13
  .dependencies = &.{.{ .name = "build_options", .module = build_options.createModule() }},
@@ -27,7 +27,6 @@ pub fn build(b: *std.Build) !void {
27
27
  const dynamic = b.option(bool, "dynamic", "Build a dynamic library") orelse false;
28
28
  const strip = b.option(bool, "strip", "Strip debugging symbols from binary") orelse false;
29
29
  const pic = b.option(bool, "pic", "Force position independent code") orelse false;
30
- const emit_asm = b.option(bool, "emit-asm", "Output .s (assembly code)") orelse false;
31
30
 
32
31
  const cmd = b.findProgram(&.{"strip"}, &.{}) catch null;
33
32
 
@@ -42,11 +41,11 @@ pub fn build(b: *std.Build) !void {
42
41
 
43
42
  const showdown =
44
43
  b.option(bool, "showdown", "Enable Pokémon Showdown compatibility mode") orelse false;
45
- const log = b.option(bool, "log", "Enable protocol message logging") orelse false;
44
+ const trace = b.option(bool, "trace", "Enable trace logs") orelse false;
46
45
 
47
46
  const options = b.addOptions();
48
47
  options.addOption(?bool, "showdown", showdown);
49
- options.addOption(?bool, "log", log);
48
+ options.addOption(?bool, "trace", trace);
50
49
 
51
50
  const name = if (showdown) "pkmn-showdown" else "pkmn";
52
51
 
@@ -80,7 +79,7 @@ pub fn build(b: *std.Build) !void {
80
79
  //
81
80
  // But ziglang/zig#14647 broke this so we now need to do an install() and then manually
82
81
  // rename the file ourself in install-pkmn-engine
83
- b.installArtifact(lib);
82
+ lib.install();
84
83
  } else if (wasm) {
85
84
  const lib = b.addSharedLibrary(.{
86
85
  .name = name,
@@ -106,7 +105,7 @@ pub fn build(b: *std.Build) !void {
106
105
  sh.addFileSourceArg(.{ .path = out });
107
106
  b.getInstallStep().dependOn(&sh.step);
108
107
  }
109
- b.installArtifact(lib);
108
+ lib.install();
110
109
  } else if (dynamic) {
111
110
  const lib = b.addSharedLibrary(.{
112
111
  .name = name,
@@ -120,7 +119,7 @@ pub fn build(b: *std.Build) !void {
120
119
  lib.addIncludePath("src/include");
121
120
  maybeStrip(b, lib, b.getInstallStep(), strip, cmd);
122
121
  if (pic) lib.force_pic = pic;
123
- b.installArtifact(lib);
122
+ lib.install();
124
123
  c = true;
125
124
  } else {
126
125
  const lib = b.addStaticLibrary(.{
@@ -135,8 +134,7 @@ pub fn build(b: *std.Build) !void {
135
134
  lib.bundle_compiler_rt = true;
136
135
  maybeStrip(b, lib, b.getInstallStep(), strip, cmd);
137
136
  if (pic) lib.force_pic = pic;
138
- if (emit_asm) lib.emit_asm = .emit;
139
- b.installArtifact(lib);
137
+ lib.install();
140
138
  c = true;
141
139
  }
142
140
 
@@ -185,7 +183,7 @@ pub fn build(b: *std.Build) !void {
185
183
  .general = config,
186
184
  .tool = .{
187
185
  .showdown = showdown,
188
- .log = log,
186
+ .trace = trace,
189
187
  .tests = if (tests.build) tests else null,
190
188
  .exes = &exes,
191
189
  },
@@ -207,7 +205,7 @@ pub fn build(b: *std.Build) !void {
207
205
  const lint_exe =
208
206
  b.addExecutable(.{ .name = "lint", .root_source_file = .{ .path = "src/tools/lint.zig" } });
209
207
  if (tests.build) tests.step.dependOn(&lint_exe.step);
210
- const lint = b.addRunArtifact(lint_exe);
208
+ const lint = lint_exe.run();
211
209
 
212
210
  b.step("benchmark", "Run benchmark code").dependOn(&benchmark.step);
213
211
  b.step("fuzz", "Run fuzz tester").dependOn(&fuzz.step);
@@ -258,8 +256,11 @@ const TestStep = struct {
258
256
  pub fn create(b: *std.Build, options: *std.Build.OptionsStep, config: Config) *TestStep {
259
257
  const coverage = b.option([]const u8, "test-coverage", "Generate test coverage");
260
258
  const test_file = b.option([]const u8, "test-file", "Input file for test");
259
+ const test_bin = b.option([]const u8, "test-bin", "Emit test binary to");
261
260
  const test_filter =
262
261
  b.option([]const u8, "test-filter", "Skip tests that do not match filter");
262
+ const test_no_exec =
263
+ b.option(bool, "test-no-exec", "Compiles test binary without running it") orelse false;
263
264
 
264
265
  const self = b.allocator.create(TestStep) catch @panic("OOM");
265
266
  const step = std.Build.Step.init(.{ .id = .custom, .name = "Run all tests", .owner = b });
@@ -273,17 +274,21 @@ const TestStep = struct {
273
274
  .root_source_file = .{ .path = path },
274
275
  .optimize = config.optimize,
275
276
  .target = config.target,
276
- .filter = test_filter,
277
277
  });
278
278
  tests.setMainPkgPath("./");
279
+ tests.setFilter(test_filter);
279
280
  tests.addOptions("build_options", options);
280
281
  tests.single_threaded = true;
281
282
  maybeStrip(b, tests, &tests.step, config.strip, config.cmd);
282
283
  if (config.pic) tests.force_pic = config.pic;
284
+ if (test_bin) |bin| {
285
+ tests.name = std.fs.path.basename(bin);
286
+ if (std.fs.path.dirname(bin)) |dir| tests.setOutputDir(dir);
287
+ }
283
288
  if (coverage) |c| {
284
289
  tests.setExecCmd(&.{ "kcov", "--include-pattern=src/lib", c, null });
285
290
  }
286
- self.step.dependOn(&b.addRunArtifact(tests).step);
291
+ self.step.dependOn(if (test_no_exec) &tests.step else &tests.run().step);
287
292
  }
288
293
  return self;
289
294
  }
@@ -293,7 +298,7 @@ const ToolConfig = struct {
293
298
  general: Config,
294
299
  tool: struct {
295
300
  showdown: bool,
296
- log: bool,
301
+ trace: bool,
297
302
  tests: ?*TestStep,
298
303
  name: ?[]const u8 = null,
299
304
  exes: *std.ArrayList(*std.Build.CompileStep),
@@ -314,14 +319,14 @@ fn tool(b: *std.Build, path: []const u8, config: ToolConfig) *std.Build.RunStep
314
319
  });
315
320
  exe.addModule("pkmn", module(b, .{
316
321
  .showdown = config.tool.showdown,
317
- .log = config.tool.log,
322
+ .trace = config.tool.trace,
318
323
  }));
319
324
  exe.single_threaded = true;
320
325
  if (config.general.pic) exe.force_pic = config.general.pic;
321
326
  if (config.tool.tests) |ts| ts.step.dependOn(&exe.step);
322
327
  config.tool.exes.append(exe) catch @panic("OOM");
323
328
 
324
- const run = b.addRunArtifact(exe);
329
+ const run = exe.run();
325
330
  maybeStrip(b, exe, &run.step, config.general.strip, config.general.cmd);
326
331
  if (b.args) |args| run.addArgs(args);
327
332
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pkmn/engine",
3
- "version": "0.1.0-dev.550c3889",
3
+ "version": "0.1.0-dev.5ec64ea5",
4
4
  "description": "A minimal, complete, Pokémon battle simulation engine optimized for performance",
5
5
  "repository": "github:pkmn/engine",
6
6
  "license": "MIT",
@@ -66,30 +66,30 @@
66
66
  "access": "public"
67
67
  },
68
68
  "dependencies": {
69
- "@pkmn/data": "^0.7.38",
69
+ "@pkmn/data": "^0.7.36",
70
70
  "@pkmn/protocol": "^0.6.11"
71
71
  },
72
72
  "devDependencies": {
73
73
  "@pkmn/eslint-config": "^3.0.0",
74
74
  "@pkmn/img": "^0.2.8",
75
75
  "@pkmn/sets": "^5.0.4",
76
- "@pkmn/sim": "0.7.38",
76
+ "@pkmn/sim": "0.7.36",
77
77
  "@types/html-minifier": "^4.0.2",
78
78
  "@types/jest": "^29.5.0",
79
79
  "@types/minimist": "^1.2.2",
80
80
  "@types/mustache": "^4.2.2",
81
81
  "@types/node": "^18.15.11",
82
- "@vitest/coverage-c8": "^0.30.1",
82
+ "@vitest/coverage-c8": "^0.29.8",
83
83
  "binaryen": "^112.0.0",
84
- "eslint": "^8.38.0",
84
+ "eslint": "^8.37.0",
85
85
  "html-minifier": "^4.0.0",
86
- "json-stringify-pretty-compact": "4.0.0",
86
+ "json-stringify-pretty-compact": "3.0.0",
87
87
  "minimist": "^1.2.8",
88
88
  "mustache": "^4.2.0",
89
89
  "source-map-support": "^0.5.21",
90
90
  "trakr": "^0.2.0",
91
- "typescript": "^5.0.4",
92
- "vitest": "^0.30.1"
91
+ "typescript": "^5.0.3",
92
+ "vitest": "^0.29.8"
93
93
  },
94
94
  "scripts": {
95
95
  "lint": "eslint --cache src --ext ts,js && eslint src/bin/*",
@@ -161,8 +161,7 @@
161
161
  },
162
162
  {
163
163
  "files": [
164
- "src/test/*.test.ts",
165
- "src/test/regression/*.test.ts"
164
+ "src/test/*.test.ts"
166
165
  ],
167
166
  "rules": {
168
167
  "jest/no-standalone-expect": "off"
@@ -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, dev: 2560};
13
+ const ZIG_VERSION = {major: 0, minor: 11, patch: 0, dev: 2168};
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';
@@ -337,13 +337,13 @@ const downloadImportLib = async () => {
337
337
  if (!options) {
338
338
  const addon = require(copy);
339
339
  if (addon.options.showdown) opts.push('-Dshowdown');
340
- if (addon.options.log) opts.push('-Dlog');
340
+ if (addon.options.trace) opts.push('-Dtrace');
341
341
  }
342
342
  } else if (!options) {
343
343
  const addon = await WebAssembly.instantiate(fs.readFileSync(copy));
344
344
  const values = new Uint8Array(addon.instance.exports.memory.buffer);
345
345
  if (values[addon.instance.exports.SHOWDOWN.value]) opts.push('-Dshowdown');
346
- if (values[addon.instance.exports.LOG.value]) opts.push('-Dlog');
346
+ if (values[addon.instance.exports.TRACE.value]) opts.push('-Dtrace');
347
347
  }
348
348
  const key = `${type} ${opts.sort().join(' ')}`;
349
349
  if (!configs.has(key)) configs.set(key, {type, options: opts});
@@ -7,9 +7,9 @@ try {
7
7
  if (err.code !== 'MODULE_NOT_FOUND') throw err;
8
8
  }
9
9
 
10
+ const {join, resolve} = require('path');
10
11
  const {execFileSync} = require('child_process');
11
12
  const {readFileSync} = require('fs');
12
- const {join, resolve} = require('path');
13
13
 
14
14
  const ROOT = resolve(__dirname, '..', '..');
15
15
  const packageJSON = JSON.parse(readFileSync(join(ROOT, 'package.json'), 'utf8'));
@@ -46,7 +46,8 @@ if (missing.length) {
46
46
  execFileSync('npm', ['install', ...missing, '--global'], {encoding: 'utf8'});
47
47
 
48
48
  const node_modules = execFileSync('npm', ['root', '--global'], {encoding: 'utf8'}).trim();
49
- if (!process.env.NODE_PATH || !process.env.NODE_PATH.includes(node_modules)) {
49
+ let NODE_PATH = process.env.NODE_PATH;
50
+ if (!NODE_PATH || !NODE_PATH.includes(node_modules)) {
50
51
  console.error(`NODE_PATH must include npm's global node_modules directory: '${node_modules}'`);
51
52
  process.exit(1);
52
53
  }
@@ -21,7 +21,7 @@ fn options(env: c.napi_env) c.napi_value {
21
21
  var object = Object.init(env);
22
22
  const properties = [_]c.napi_property_descriptor{
23
23
  Property.init("showdown", .{ .value = Boolean.init(env, pkmn.options.showdown) }),
24
- Property.init("log", .{ .value = Boolean.init(env, pkmn.options.log) }),
24
+ Property.init("trace", .{ .value = Boolean.init(env, pkmn.options.trace) }),
25
25
  };
26
26
  assert(c.napi_define_properties(env, object, properties.len, &properties) == c.napi_ok);
27
27
  return object;
@@ -34,11 +34,11 @@ fn bindings(env: c.napi_env) c.napi_value {
34
34
  }
35
35
 
36
36
  fn bind(env: c.napi_env, gen: anytype) c.napi_value {
37
- const choices_size = @intCast(u32, gen.CHOICES_SIZE);
37
+ const options_size = @intCast(u32, gen.OPTIONS_SIZE);
38
38
  const logs_size = @intCast(u32, gen.LOGS_SIZE);
39
39
  var object = Object.init(env);
40
40
  const properties = [_]c.napi_property_descriptor{
41
- Property.init("CHOICES_SIZE", .{ .value = Number.init(env, choices_size) }),
41
+ Property.init("OPTIONS_SIZE", .{ .value = Number.init(env, options_size) }),
42
42
  Property.init("LOGS_SIZE", .{ .value = Number.init(env, logs_size) }),
43
43
  Property.init("update", .{ .method = update(gen) }),
44
44
  Property.init("choices", .{ .method = choices(gen) }),
@@ -108,10 +108,10 @@ fn choices(gen: anytype) c.napi_callback {
108
108
  const request = @intToEnum(pkmn.Choice.Type, Number.get(env, argv[2], u8));
109
109
 
110
110
  assert(c.napi_get_arraybuffer_info(env, argv[3], &data, &len) == c.napi_ok);
111
- assert(len == gen.CHOICES_SIZE);
111
+ assert(len == gen.OPTIONS_SIZE);
112
112
  assert(data != null);
113
113
 
114
- var out = @ptrCast([*]pkmn.Choice, data.?)[0..gen.CHOICES_SIZE];
114
+ var out = @ptrCast([*]pkmn.Choice, data.?)[0..gen.OPTIONS_SIZE];
115
115
  const n = battle.choices(player, request, out);
116
116
  return Number.init(env, @bitCast(u8, n));
117
117
  }
@@ -2,9 +2,9 @@ const std = @import("std");
2
2
  const pkmn = @import("../pkmn.zig");
3
3
 
4
4
  export const SHOWDOWN = pkmn.options.showdown;
5
- export const LOG = pkmn.options.log;
5
+ export const TRACE = pkmn.options.trace;
6
6
 
7
- export const GEN1_CHOICES_SIZE =
8
- std.math.ceilPowerOfTwo(u32, @intCast(u32, pkmn.gen1.CHOICES_SIZE)) catch unreachable;
7
+ export const GEN1_OPTIONS_SIZE =
8
+ std.math.ceilPowerOfTwo(u32, @intCast(u32, pkmn.gen1.OPTIONS_SIZE)) catch unreachable;
9
9
  export const GEN1_LOGS_SIZE =
10
10
  std.math.ceilPowerOfTwo(u32, @intCast(u32, pkmn.gen1.LOGS_SIZE)) catch unreachable;
@@ -58,7 +58,6 @@ fn inspect(value: anytype) void {
58
58
  @compileError(err);
59
59
  },
60
60
  },
61
- .Optional => stderr.print("{?}", .{value}) catch return,
62
61
  else => stderr.print("{}", .{value}) catch return,
63
62
  }
64
63
  }
@@ -3,7 +3,7 @@ const root = @import("root");
3
3
 
4
4
  pub const Options = struct {
5
5
  showdown: ?bool = null,
6
- log: ?bool = null,
6
+ trace: ?bool = null,
7
7
  advance: ?bool = null,
8
8
  ebc: ?bool = null,
9
9
  internal: ?bool = null,
@@ -11,8 +11,8 @@ pub const Options = struct {
11
11
 
12
12
  /// Whether or not Pokémon Showdown compatibility mode is enabled.
13
13
  pub const showdown = get("showdown", false);
14
- /// Whether or not protocol message logging is enabled.
15
- pub const log = get("log", false);
14
+ /// Whether or not protocol trace logging is enabled.
15
+ pub const trace = get("trace", false);
16
16
 
17
17
  pub const advance = get("advance", true);
18
18
  pub const ebc = get("ebc", true);
@@ -7,7 +7,7 @@ const options = @import("./options.zig");
7
7
  const assert = std.debug.assert;
8
8
  const print = std.debug.print;
9
9
 
10
- const enabled = options.log;
10
+ const trace = options.trace;
11
11
 
12
12
  const Player = data.Player;
13
13
  const ID = data.ID;
@@ -230,7 +230,7 @@ pub fn Log(comptime Writer: type) type {
230
230
  pub const Error = Writer.Error;
231
231
 
232
232
  pub fn move(self: Self, source: ID, m: anytype, target: ID, from: anytype) Error!void {
233
- if (!enabled) return;
233
+ if (!trace) return;
234
234
  assert(m != .None);
235
235
  try self.writer.writeAll(&.{
236
236
  @enumToInt(ArgType.Move),
@@ -253,7 +253,7 @@ pub fn Log(comptime Writer: type) type {
253
253
  }
254
254
 
255
255
  pub fn switched(self: Self, ident: ID, pokemon: anytype) Error!void {
256
- if (!enabled) return;
256
+ if (!trace) return;
257
257
  try self.writer.writeAll(&.{ @enumToInt(ArgType.Switch), @bitCast(u8, ident) });
258
258
  try self.writer.writeAll(&.{ @enumToInt(pokemon.species), pokemon.level });
259
259
  try self.writer.writeIntNative(u16, pokemon.hp);
@@ -262,7 +262,7 @@ pub fn Log(comptime Writer: type) type {
262
262
  }
263
263
 
264
264
  pub fn cant(self: Self, ident: ID, reason: Cant) Error!void {
265
- if (!enabled) return;
265
+ if (!trace) return;
266
266
  assert(reason != .Disable);
267
267
  try self.writer.writeAll(&.{
268
268
  @enumToInt(ArgType.Cant),
@@ -272,7 +272,7 @@ pub fn Log(comptime Writer: type) type {
272
272
  }
273
273
 
274
274
  pub fn disabled(self: Self, ident: ID, m: anytype) Error!void {
275
- if (!enabled) return;
275
+ if (!trace) return;
276
276
  try self.writer.writeAll(&.{
277
277
  @enumToInt(ArgType.Cant),
278
278
  @bitCast(u8, ident),
@@ -282,20 +282,20 @@ pub fn Log(comptime Writer: type) type {
282
282
  }
283
283
 
284
284
  pub fn faint(self: Self, ident: ID, done: bool) Error!void {
285
- if (!enabled) return;
285
+ if (!trace) return;
286
286
  try self.writer.writeAll(&.{ @enumToInt(ArgType.Faint), @bitCast(u8, ident) });
287
287
  if (done) try self.writer.writeByte(@enumToInt(ArgType.None));
288
288
  }
289
289
 
290
290
  pub fn turn(self: Self, num: u16) Error!void {
291
- if (!enabled) return;
291
+ if (!trace) return;
292
292
  try self.writer.writeByte(@enumToInt(ArgType.Turn));
293
293
  try self.writer.writeIntNative(u16, num);
294
294
  try self.writer.writeByte(@enumToInt(ArgType.None));
295
295
  }
296
296
 
297
297
  pub fn win(self: Self, player: Player) Error!void {
298
- if (!enabled) return;
298
+ if (!trace) return;
299
299
  try self.writer.writeAll(&.{
300
300
  @enumToInt(ArgType.Win),
301
301
  @enumToInt(player),
@@ -304,12 +304,12 @@ pub fn Log(comptime Writer: type) type {
304
304
  }
305
305
 
306
306
  pub fn tie(self: Self) Error!void {
307
- if (!enabled) return;
307
+ if (!trace) return;
308
308
  try self.writer.writeAll(&.{ @enumToInt(ArgType.Tie), @enumToInt(ArgType.None) });
309
309
  }
310
310
 
311
311
  pub fn damage(self: Self, ident: ID, pokemon: anytype, reason: Damage) Error!void {
312
- if (!enabled) return;
312
+ if (!trace) return;
313
313
  assert(@enumToInt(reason) <= @enumToInt(Damage.LeechSeed));
314
314
  try self.writer.writeAll(&.{ @enumToInt(ArgType.Damage), @bitCast(u8, ident) });
315
315
  try self.writer.writeIntNative(u16, pokemon.hp);
@@ -324,7 +324,7 @@ pub fn Log(comptime Writer: type) type {
324
324
  reason: Damage,
325
325
  source: ID,
326
326
  ) Error!void {
327
- if (!enabled) return;
327
+ if (!trace) return;
328
328
  assert(@enumToInt(reason) == @enumToInt(Damage.RecoilOf));
329
329
  try self.writer.writeAll(&.{ @enumToInt(ArgType.Damage), @bitCast(u8, ident) });
330
330
  try self.writer.writeIntNative(u16, pokemon.hp);
@@ -337,7 +337,7 @@ pub fn Log(comptime Writer: type) type {
337
337
  }
338
338
 
339
339
  pub fn heal(self: Self, ident: ID, pokemon: anytype, reason: Heal) Error!void {
340
- if (!enabled) return;
340
+ if (!trace) return;
341
341
  assert(reason != .Drain);
342
342
  try self.writer.writeAll(&.{ @enumToInt(ArgType.Heal), @bitCast(u8, ident) });
343
343
  try self.writer.writeIntNative(u16, pokemon.hp);
@@ -346,7 +346,7 @@ pub fn Log(comptime Writer: type) type {
346
346
  }
347
347
 
348
348
  pub fn drain(self: Self, source: ID, pokemon: anytype, target: ID) Error!void {
349
- if (!enabled) return;
349
+ if (!trace) return;
350
350
  try self.writer.writeAll(&.{ @enumToInt(ArgType.Heal), @bitCast(u8, source) });
351
351
  try self.writer.writeIntNative(u16, pokemon.hp);
352
352
  try self.writer.writeIntNative(u16, pokemon.stats.hp);
@@ -358,7 +358,7 @@ pub fn Log(comptime Writer: type) type {
358
358
  }
359
359
 
360
360
  pub fn status(self: Self, ident: ID, value: u8, reason: Status) Error!void {
361
- if (!enabled) return;
361
+ if (!trace) return;
362
362
  assert(reason != .From);
363
363
  try self.writer.writeAll(&.{
364
364
  @enumToInt(ArgType.Status),
@@ -369,7 +369,7 @@ pub fn Log(comptime Writer: type) type {
369
369
  }
370
370
 
371
371
  pub fn statusFrom(self: Self, ident: ID, value: u8, m: anytype) Error!void {
372
- if (!enabled) return;
372
+ if (!trace) return;
373
373
  try self.writer.writeAll(&.{
374
374
  @enumToInt(ArgType.Status),
375
375
  @bitCast(u8, ident),
@@ -380,7 +380,7 @@ pub fn Log(comptime Writer: type) type {
380
380
  }
381
381
 
382
382
  pub fn curestatus(self: Self, ident: ID, value: u8, reason: CureStatus) Error!void {
383
- if (!enabled) return;
383
+ if (!trace) return;
384
384
  try self.writer.writeAll(&.{
385
385
  @enumToInt(ArgType.CureStatus),
386
386
  @bitCast(u8, ident),
@@ -390,7 +390,7 @@ pub fn Log(comptime Writer: type) type {
390
390
  }
391
391
 
392
392
  pub fn boost(self: Self, ident: ID, reason: Boost, num: i8) Error!void {
393
- if (!enabled) return;
393
+ if (!trace) return;
394
394
  assert(num != 0 and (reason != .Rage or num > 0));
395
395
  try self.writer.writeAll(&.{
396
396
  @enumToInt(ArgType.Boost),
@@ -401,12 +401,12 @@ pub fn Log(comptime Writer: type) type {
401
401
  }
402
402
 
403
403
  pub fn clearallboost(self: Self) Error!void {
404
- if (!enabled) return;
404
+ if (!trace) return;
405
405
  try self.writer.writeAll(&.{@enumToInt(ArgType.ClearAllBoost)});
406
406
  }
407
407
 
408
408
  pub fn fail(self: Self, ident: ID, reason: Fail) Error!void {
409
- if (!enabled) return;
409
+ if (!trace) return;
410
410
  try self.writer.writeAll(&.{
411
411
  @enumToInt(ArgType.Fail),
412
412
  @bitCast(u8, ident),
@@ -415,17 +415,17 @@ pub fn Log(comptime Writer: type) type {
415
415
  }
416
416
 
417
417
  pub fn miss(self: Self, source: ID) Error!void {
418
- if (!enabled) return;
418
+ if (!trace) return;
419
419
  try self.writer.writeAll(&.{ @enumToInt(ArgType.Miss), @bitCast(u8, source) });
420
420
  }
421
421
 
422
422
  pub fn hitcount(self: Self, ident: ID, num: u8) Error!void {
423
- if (!enabled) return;
423
+ if (!trace) return;
424
424
  try self.writer.writeAll(&.{ @enumToInt(ArgType.HitCount), @bitCast(u8, ident), num });
425
425
  }
426
426
 
427
427
  pub fn prepare(self: Self, source: ID, m: anytype) Error!void {
428
- if (!enabled) return;
428
+ if (!trace) return;
429
429
  try self.writer.writeAll(&.{
430
430
  @enumToInt(ArgType.Prepare),
431
431
  @bitCast(u8, source),
@@ -434,12 +434,12 @@ pub fn Log(comptime Writer: type) type {
434
434
  }
435
435
 
436
436
  pub fn mustrecharge(self: Self, ident: ID) Error!void {
437
- if (!enabled) return;
437
+ if (!trace) return;
438
438
  try self.writer.writeAll(&.{ @enumToInt(ArgType.MustRecharge), @bitCast(u8, ident) });
439
439
  }
440
440
 
441
441
  pub fn activate(self: Self, ident: ID, reason: Activate) Error!void {
442
- if (!enabled) return;
442
+ if (!trace) return;
443
443
  try self.writer.writeAll(&.{
444
444
  @enumToInt(ArgType.Activate),
445
445
  @bitCast(u8, ident),
@@ -448,12 +448,12 @@ pub fn Log(comptime Writer: type) type {
448
448
  }
449
449
 
450
450
  pub fn fieldactivate(self: Self) Error!void {
451
- if (!enabled) return;
451
+ if (!trace) return;
452
452
  try self.writer.writeAll(&.{@enumToInt(ArgType.FieldActivate)});
453
453
  }
454
454
 
455
455
  pub fn start(self: Self, ident: ID, reason: Start) Error!void {
456
- if (!enabled) return;
456
+ if (!trace) return;
457
457
  assert(@enumToInt(reason) < @enumToInt(Start.TypeChange));
458
458
  try self.writer.writeAll(&.{
459
459
  @enumToInt(ArgType.Start),
@@ -463,7 +463,7 @@ pub fn Log(comptime Writer: type) type {
463
463
  }
464
464
 
465
465
  pub fn typechange(self: Self, source: ID, types: anytype, target: ID) Error!void {
466
- if (!enabled) return;
466
+ if (!trace) return;
467
467
  try self.writer.writeAll(&.{
468
468
  @enumToInt(ArgType.Start),
469
469
  @bitCast(u8, source),
@@ -474,7 +474,7 @@ pub fn Log(comptime Writer: type) type {
474
474
  }
475
475
 
476
476
  pub fn startEffect(self: Self, ident: ID, reason: Start, m: anytype) Error!void {
477
- if (!enabled) return;
477
+ if (!trace) return;
478
478
  assert(@enumToInt(reason) > @enumToInt(Start.TypeChange));
479
479
  try self.writer.writeAll(&.{
480
480
  @enumToInt(ArgType.Start),
@@ -485,7 +485,7 @@ pub fn Log(comptime Writer: type) type {
485
485
  }
486
486
 
487
487
  pub fn end(self: Self, ident: ID, reason: End) Error!void {
488
- if (!enabled) return;
488
+ if (!trace) return;
489
489
  try self.writer.writeAll(&.{
490
490
  @enumToInt(ArgType.End),
491
491
  @bitCast(u8, ident),
@@ -494,27 +494,27 @@ pub fn Log(comptime Writer: type) type {
494
494
  }
495
495
 
496
496
  pub fn ohko(self: Self) Error!void {
497
- if (!enabled) return;
497
+ if (!trace) return;
498
498
  try self.writer.writeAll(&.{@enumToInt(ArgType.OHKO)});
499
499
  }
500
500
 
501
501
  pub fn crit(self: Self, ident: ID) Error!void {
502
- if (!enabled) return;
502
+ if (!trace) return;
503
503
  try self.writer.writeAll(&.{ @enumToInt(ArgType.Crit), @bitCast(u8, ident) });
504
504
  }
505
505
 
506
506
  pub fn supereffective(self: Self, ident: ID) Error!void {
507
- if (!enabled) return;
507
+ if (!trace) return;
508
508
  try self.writer.writeAll(&.{ @enumToInt(ArgType.SuperEffective), @bitCast(u8, ident) });
509
509
  }
510
510
 
511
511
  pub fn resisted(self: Self, ident: ID) Error!void {
512
- if (!enabled) return;
512
+ if (!trace) return;
513
513
  try self.writer.writeAll(&.{ @enumToInt(ArgType.Resisted), @bitCast(u8, ident) });
514
514
  }
515
515
 
516
516
  pub fn immune(self: Self, ident: ID, reason: Immune) Error!void {
517
- if (!enabled) return;
517
+ if (!trace) return;
518
518
  try self.writer.writeAll(&.{
519
519
  @enumToInt(ArgType.Immune),
520
520
  @bitCast(u8, ident),
@@ -523,7 +523,7 @@ pub fn Log(comptime Writer: type) type {
523
523
  }
524
524
 
525
525
  pub fn transform(self: Self, source: ID, target: ID) Error!void {
526
- if (!enabled) return;
526
+ if (!trace) return;
527
527
  try self.writer.writeAll(&.{
528
528
  @enumToInt(ArgType.Transform),
529
529
  @bitCast(u8, source),
@@ -532,12 +532,12 @@ pub fn Log(comptime Writer: type) type {
532
532
  }
533
533
 
534
534
  pub fn laststill(self: Self) Error!void {
535
- if (!enabled) return;
535
+ if (!trace) return;
536
536
  try self.writer.writeAll(&.{@enumToInt(ArgType.LastStill)});
537
537
  }
538
538
 
539
539
  pub fn lastmiss(self: Self) Error!void {
540
- if (!enabled) return;
540
+ if (!trace) return;
541
541
  try self.writer.writeAll(&.{@enumToInt(ArgType.LastMiss)});
542
542
  }
543
543
  };
@@ -838,7 +838,7 @@ pub fn expectLog(
838
838
  actual: []const u8,
839
839
  offset: usize,
840
840
  ) !void {
841
- if (!enabled) return;
841
+ if (!trace) return;
842
842
  const color = color: {
843
843
  if (std.process.hasEnvVarConstant("ZIG_DEBUG_COLOR")) {
844
844
  break :color true;