@pkmn/engine 0.1.0-dev.f3aab252 → 0.1.0-dev.f3b63b86

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 (80) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +35 -8
  3. package/build/pkg/addon/browser.d.ts +3 -0
  4. package/build/pkg/addon/browser.js +47 -0
  5. package/build/pkg/addon/browser.js.map +1 -0
  6. package/build/pkg/addon/node.d.ts +3 -0
  7. package/build/pkg/addon/node.js +110 -0
  8. package/build/pkg/addon/node.js.map +1 -0
  9. package/build/pkg/addon/wasm.d.ts +2 -0
  10. package/build/pkg/addon/wasm.js +53 -0
  11. package/build/pkg/addon/wasm.js.map +1 -0
  12. package/build/pkg/addon.d.ts +26 -4
  13. package/build/pkg/addon.js +34 -65
  14. package/build/pkg/addon.js.map +1 -1
  15. package/build/pkg/data/layout.json +15 -2
  16. package/build/pkg/data/protocol.json +23 -9
  17. package/build/pkg/data.d.ts +23 -1
  18. package/build/pkg/data.js.map +1 -1
  19. package/build/pkg/gen1.d.ts +15 -18
  20. package/build/pkg/gen1.js +28 -19
  21. package/build/pkg/gen1.js.map +1 -1
  22. package/build/pkg/index.d.ts +39 -89
  23. package/build/pkg/index.js +23 -70
  24. package/build/pkg/index.js.map +1 -1
  25. package/build/pkg/protocol.d.ts +20 -1
  26. package/build/pkg/protocol.js +105 -103
  27. package/build/pkg/protocol.js.map +1 -1
  28. package/build/tools/debug.js +68 -74
  29. package/build/tools/debug.js.map +1 -1
  30. package/build/tools/display/debug.jsx +152 -0
  31. package/build/tools/display/debug.jsx.map +1 -0
  32. package/build/tools/display/index.js +152 -0
  33. package/build/tools/display/index.js.map +1 -0
  34. package/build/tools/display/ui.jsx +359 -0
  35. package/build/tools/display/ui.jsx.map +1 -0
  36. package/build/tools/display/util.js +33 -0
  37. package/build/tools/display/util.js.map +1 -0
  38. package/build.zig +235 -213
  39. package/package.json +59 -141
  40. package/src/bin/install-pkmn-engine +25 -9
  41. package/src/bin/pkmn-debug +1 -1
  42. package/src/lib/bindings/c.zig +200 -0
  43. package/src/lib/bindings/node.zig +117 -0
  44. package/src/lib/bindings/wasm.zig +50 -0
  45. package/src/lib/common/array.zig +5 -12
  46. package/src/lib/common/debug.zig +30 -9
  47. package/src/lib/common/js.zig +3 -9
  48. package/src/lib/common/optional.zig +11 -21
  49. package/src/lib/common/options.zig +4 -0
  50. package/src/lib/common/protocol.zig +180 -171
  51. package/src/lib/common/rational.zig +278 -285
  52. package/src/lib/common/rng.zig +1 -3
  53. package/src/lib/common/util.zig +14 -31
  54. package/src/lib/gen1/calc.zig +258 -106
  55. package/src/lib/gen1/chance.zig +57 -54
  56. package/src/lib/gen1/data/moves.zig +2 -4
  57. package/src/lib/gen1/data/species.zig +1 -3
  58. package/src/lib/gen1/data/types.zig +3 -4
  59. package/src/lib/gen1/data.zig +12 -16
  60. package/src/lib/gen1/helpers.zig +13 -28
  61. package/src/lib/gen1/mechanics.zig +131 -101
  62. package/src/lib/gen2/calc.zig +12 -23
  63. package/src/lib/gen2/chance.zig +12 -18
  64. package/src/lib/gen2/data/items.zig +1 -3
  65. package/src/lib/gen2/data/moves.zig +2 -4
  66. package/src/lib/gen2/data/species.zig +1 -3
  67. package/src/lib/gen2/data/types.zig +7 -5
  68. package/src/lib/gen2/data.zig +19 -22
  69. package/src/lib/gen2/generated.zig +18 -23
  70. package/src/lib/gen2/helpers.zig +9 -18
  71. package/src/lib/gen2/mechanics.zig +50 -47
  72. package/src/lib/napi.h +2 -0
  73. package/src/lib/node.zig +4 -121
  74. package/src/lib/pkmn.zig +98 -19
  75. package/src/lib/wasm.zig +9 -9
  76. package/src/tools/display/dom.ts +93 -0
  77. package/src/tools/display/ui.css +354 -0
  78. package/build/test/display.js +0 -405
  79. package/build/test/display.js.map +0 -1
  80. package/src/test/display/pkmn.html.tmpl +0 -368
@@ -1,25 +1,17 @@
1
- const std = @import("std");
2
1
  const builtin = @import("builtin");
3
-
4
- const pkmn = @import("../pkmn.zig");
5
-
6
2
  const data = @import("data.zig");
7
3
  const options = @import("options.zig");
4
+ const pkmn = @import("../pkmn.zig");
5
+ const std = @import("std");
8
6
 
9
7
  const assert = std.debug.assert;
10
- const print = std.debug.print;
11
-
12
8
  const enabled = options.log;
13
-
14
- const Player = data.Player;
15
9
  const ID = data.ID;
10
+ const Player = data.Player;
11
+ const print = std.debug.print;
16
12
 
17
13
  const endian = builtin.cpu.arch.endian();
18
14
  const Endian = std.builtin.Endian;
19
- const big = if (@hasField(Endian, "big")) Endian.big else Endian.Big;
20
- const little = if (@hasField(Endian, "little")) Endian.little else Endian.Little;
21
-
22
- const Int = if (@hasField(std.builtin.Type, "int")) .int else .Int;
23
15
 
24
16
  pub const ArgType = enum(u8) {
25
17
  None,
@@ -317,19 +309,29 @@ pub const Weather = enum(u8) {
317
309
  Upkeep,
318
310
  };
319
311
 
320
- /// Null object pattern implementation of `Log` backed by a `std.io.null_writer`.
321
- /// Ignores anything sent to it, though protocol logging should additionally be turned off
322
- /// entirely with `options.log`.
323
- pub const NULL = Log(@TypeOf(std.io.null_writer)){ .writer = std.io.null_writer };
324
-
325
- /// Logs protocol information to its `Writer` during a battle update when `options.log` is enabled.
326
- pub fn Log(comptime Writer: type) type {
312
+ /// Logs protocol information to its `WriterT` during a battle update when `options.log` is enabled.
313
+ pub fn Log(comptime WriterT: type) type {
327
314
  return struct {
328
315
  const Self = @This();
329
316
 
330
- writer: Writer,
317
+ writer: WriterT,
331
318
 
332
- pub const Error = Writer.Error;
319
+ pub const Error = err(WriterT);
320
+
321
+ fn err(comptime T: type) type {
322
+ const msg = "Invalid Writer type " ++ @typeName(T) ++ "'";
323
+ return switch (@typeInfo(T)) {
324
+ .pointer => |ptr_info| switch (ptr_info.size) {
325
+ .one => switch (@typeInfo(ptr_info.child)) {
326
+ .@"struct" => err(ptr_info.child),
327
+ else => @compileError(msg),
328
+ },
329
+ else => @compileError(msg),
330
+ },
331
+ .@"struct" => if (@hasDecl(T, "Error")) T.Error else @compileError(msg),
332
+ else => @compileError(msg),
333
+ };
334
+ }
333
335
 
334
336
  // source: ID, move: <Move>, target: ID, from?: <Move>
335
337
  pub fn move(self: Self, args: anytype) Error!void {
@@ -820,49 +822,61 @@ pub fn Log(comptime Writer: type) type {
820
822
  };
821
823
  }
822
824
 
823
- /// `Log` type backed by the optimized `ByteStream.Writer`.
824
- pub const FixedLog = Log(ByteStream.Writer);
825
+ /// `Log` type backed by the optimized `Writer`.
826
+ pub const FixedLog = Log(*Writer);
825
827
 
826
- /// Stripped down version of `std.io.FixedBufferStream` optimized for efficiently writing the
827
- /// individual protocol bytes. Note that the `ByteStream.Writer` is **not** a `std.io.Writer` and
828
- /// should not be used for general purpose writing.
829
- pub const ByteStream = struct {
828
+ /// Minimal logging helper optimized for efficiently writing the individual protocol bytes into a
829
+ /// fixed buffer. Note that this is **not** a `std.Io.Writer` and should not be used for general
830
+ /// purpose writing.
831
+ pub const Writer = struct {
830
832
  buffer: []u8,
831
833
  pos: usize = 0,
832
834
 
833
- pub const Writer = struct {
834
- stream: *ByteStream,
835
+ pub const Error = error{NoSpaceLeft};
835
836
 
836
- pub const Error = error{NoSpaceLeft};
837
+ pub fn writeByte(self: *Writer, byte: u8) Error!void {
838
+ if (self.pos >= self.buffer.len) return error.NoSpaceLeft;
839
+ self.buffer[self.pos] = byte;
840
+ self.pos += 1;
841
+ }
837
842
 
838
- pub fn writeAll(self: Writer, bytes: []const u8) Error!void {
839
- for (bytes) |b| try self.writeByte(b);
840
- }
843
+ pub fn writeAll(self: *Writer, bytes: []const u8) Error!void {
844
+ const npos = self.pos + bytes.len;
845
+ if (npos > self.buffer.len) return error.NoSpaceLeft;
846
+ @memcpy(self.buffer[self.pos..npos], bytes);
847
+ self.pos = npos;
848
+ }
841
849
 
842
- pub fn writeByte(self: Writer, byte: u8) Error!void {
843
- try self.stream.writeByte(byte);
844
- }
850
+ pub fn writeInt(self: *Writer, comptime T: type, v: T, end: std.builtin.Endian) Error!void {
851
+ const bytes = @divExact(@typeInfo(T).int.bits, 8);
852
+ const npos = self.pos + bytes;
853
+ if (npos > self.buffer.len) return error.NoSpaceLeft;
854
+ std.mem.writeInt(T, self.buffer[self.pos..][0..bytes], v, end);
855
+ self.pos = npos;
856
+ }
845
857
 
846
- pub fn writeInt(self: Writer, comptime T: type, v: T, end: std.builtin.Endian) Error!void {
847
- // TODO: rework this to write directly to the buffer?
848
- var bytes: [@divExact(@field(@typeInfo(T), @tagName(Int)).bits, 8)]u8 = undefined;
849
- std.mem.writeInt(std.math.ByteAlignedInt(@TypeOf(v)), &bytes, v, end);
850
- return self.writeAll(&bytes);
851
- }
852
- };
858
+ pub fn reset(self: *Writer) void {
859
+ self.pos = 0;
860
+ }
861
+ };
862
+
863
+ /// Null object pattern implementation of `Log` backed by a null writer. Ignores anything sent to
864
+ /// it, though protocol logging should additionally be turned off entirely with `options.log`.
865
+ pub const NULL = Log(NullWriter){ .writer = .{} };
853
866
 
854
- pub fn writer(self: *ByteStream) Writer {
855
- return .{ .stream = self };
867
+ const NullWriter = struct {
868
+ pub const Error = error{};
869
+
870
+ pub fn writeByte(self: NullWriter, byte: u8) Error!void {
871
+ _ = .{ self, byte };
856
872
  }
857
873
 
858
- pub fn writeByte(self: *ByteStream, byte: u8) Writer.Error!void {
859
- if (self.pos >= self.buffer.len) return error.NoSpaceLeft;
860
- self.buffer[self.pos] = byte;
861
- self.pos += 1;
874
+ pub fn writeAll(self: NullWriter, bytes: []const u8) Error!void {
875
+ _ = .{ self, bytes };
862
876
  }
863
877
 
864
- pub fn reset(self: *ByteStream) void {
865
- self.pos = 0;
878
+ pub fn writeInt(self: NullWriter, comptime T: type, v: T, end: std.builtin.Endian) Error!void {
879
+ _ = .{ self, T, v, end };
866
880
  }
867
881
  };
868
882
 
@@ -961,13 +975,13 @@ pub fn format(
961
975
  }
962
976
  printc(" L{d}", .{a[i]}, a, b, &i, 1, color);
963
977
  switch (endian) {
964
- big => {
978
+ .big => {
965
979
  var hp = @as(u16, a[i]) << 8 | @as(u16, a[i + 1]);
966
980
  printc(" {d}", .{hp}, a, b, &i, 2, color);
967
981
  hp = @as(u16, a[i]) << 8 | @as(u16, a[i + 1]);
968
982
  printc("/{d}", .{hp}, a, b, &i, 2, color);
969
983
  },
970
- little => {
984
+ .little => {
971
985
  var hp = @as(u16, a[i + 1]) << 8 | @as(u16, a[i]);
972
986
  printc(" {d}", .{hp}, a, b, &i, 2, color);
973
987
  hp = @as(u16, a[i + 1]) << 8 | @as(u16, a[i]);
@@ -998,8 +1012,8 @@ pub fn format(
998
1012
  },
999
1013
  .Turn => {
1000
1014
  const turn = switch (endian) {
1001
- big => @as(u16, a[i]) << 8 | @as(u16, a[i + 1]),
1002
- little => @as(u16, a[i + 1]) << 8 | @as(u16, a[i]),
1015
+ .big => @as(u16, a[i]) << 8 | @as(u16, a[i + 1]),
1016
+ .little => @as(u16, a[i + 1]) << 8 | @as(u16, a[i]),
1003
1017
  };
1004
1018
  printc(" {d}", .{turn}, a, b, &i, 2, color);
1005
1019
  },
@@ -1010,13 +1024,13 @@ pub fn format(
1010
1024
  var id = ID.from(@intCast(a[i]));
1011
1025
  printc(" {s}({d})", .{ @tagName(id.player), id.id }, a, b, &i, 1, color);
1012
1026
  switch (endian) {
1013
- big => {
1027
+ .big => {
1014
1028
  var hp = @as(u16, a[i]) << 8 | @as(u16, a[i + 1]);
1015
1029
  printc(" {d}", .{hp}, a, b, &i, 2, color);
1016
1030
  hp = @as(u16, a[i]) << 8 | @as(u16, a[i + 1]);
1017
1031
  printc("/{d}", .{hp}, a, b, &i, 2, color);
1018
1032
  },
1019
- little => {
1033
+ .little => {
1020
1034
  var hp = @as(u16, a[i + 1]) << 8 | @as(u16, a[i]);
1021
1035
  printc(" {d}", .{hp}, a, b, &i, 2, color);
1022
1036
  hp = @as(u16, a[i + 1]) << 8 | @as(u16, a[i]);
@@ -1138,13 +1152,13 @@ pub fn format(
1138
1152
  const id = ID.from(@intCast(a[i]));
1139
1153
  printc(" {s}({d})", .{ @tagName(id.player), id.id }, a, b, &i, 1, color);
1140
1154
  switch (endian) {
1141
- big => {
1155
+ .big => {
1142
1156
  var hp = @as(u16, a[i]) << 8 | @as(u16, a[i + 1]);
1143
1157
  printc(" {d}", .{hp}, a, b, &i, 2, color);
1144
1158
  hp = @as(u16, a[i]) << 8 | @as(u16, a[i + 1]);
1145
1159
  printc("/{d}", .{hp}, a, b, &i, 2, color);
1146
1160
  },
1147
- little => {
1161
+ .little => {
1148
1162
  var hp = @as(u16, a[i + 1]) << 8 | @as(u16, a[i]);
1149
1163
  printc(" {d}", .{hp}, a, b, &i, 2, color);
1150
1164
  hp = @as(u16, a[i + 1]) << 8 | @as(u16, a[i]);
@@ -1212,12 +1226,8 @@ pub fn expectLog(
1212
1226
  ) !void {
1213
1227
  if (!enabled) return;
1214
1228
 
1215
- const color = if (std.process.hasEnvVarConstant("ZIG_DEBUG_COLOR"))
1216
- true
1217
- else switch (std.io.tty.detectConfig(std.io.getStdErr())) {
1218
- .escape_codes => true,
1219
- else => false,
1220
- };
1229
+ // TODO: ziglang/zig#30833 - read from environment
1230
+ const color = true;
1221
1231
 
1222
1232
  expectEqualBytes(expected, actual, offset) catch |err| switch (err) {
1223
1233
  error.TestExpectedEqual => {
@@ -1225,7 +1235,6 @@ pub fn expectLog(
1225
1235
  format(gen, actual, expected, color);
1226
1236
  return err;
1227
1237
  },
1228
- else => return err,
1229
1238
  };
1230
1239
  }
1231
1240
 
@@ -1233,7 +1242,7 @@ fn expectEqualBytes(expected: []const u8, actual: []const u8, offset: usize) !vo
1233
1242
  for (offset..@min(expected.len, actual.len)) |i| {
1234
1243
  if (expected[i] != actual[i]) {
1235
1244
  print(
1236
- "index {} incorrect. expected 0x{X:0>2}, found 0x{X:0>2}\n",
1245
+ "index {d} incorrect. expected 0x{X:0>2}, found 0x{X:0>2}\n",
1237
1246
  .{ i, expected[i], actual[i] },
1238
1247
  );
1239
1248
  return error.TestExpectedEqual;
@@ -1256,8 +1265,8 @@ const p1 = Player.P1;
1256
1265
  const p2 = Player.P2;
1257
1266
 
1258
1267
  var buf: [pkmn.LOGS_SIZE]u8 = undefined;
1259
- var stream: ByteStream = .{ .buffer = &buf };
1260
- var log: FixedLog = .{ .writer = stream.writer() };
1268
+ var writer: Writer = .{ .buffer = &buf };
1269
+ var log: FixedLog = .{ .writer = &writer };
1261
1270
 
1262
1271
  const gen1 = pkmn.gen1;
1263
1272
  const gen2 = pkmn.gen2;
@@ -1301,14 +1310,14 @@ test "|move|" {
1301
1310
  &.{ N(ArgType.Move), 0b1100, N(M1.Thunderbolt), 0b0101, N(Move.None) },
1302
1311
  buf[0..5],
1303
1312
  );
1304
- stream.reset();
1313
+ writer.reset();
1305
1314
 
1306
1315
  try log.move(.{ p2.ident(4), M1.Pound, p1.ident(5), M1.Metronome });
1307
1316
  try expectLog1(
1308
1317
  &.{ N(ArgType.Move), 0b1100, N(M1.Pound), 0b0101, N(Move.From), N(M1.Metronome) },
1309
1318
  buf[0..6],
1310
1319
  );
1311
- stream.reset();
1320
+ writer.reset();
1312
1321
 
1313
1322
  try log.move(.{ p2.ident(4), M1.SkullBash, ID{} });
1314
1323
  try log.laststill(.{});
@@ -1323,7 +1332,7 @@ test "|move|" {
1323
1332
  },
1324
1333
  buf[0..6],
1325
1334
  );
1326
- stream.reset();
1335
+ writer.reset();
1327
1336
 
1328
1337
  try log.move(.{ p2.ident(4), M1.Tackle, p1.ident(5) });
1329
1338
  try log.lastmiss(.{});
@@ -1338,7 +1347,7 @@ test "|move|" {
1338
1347
  },
1339
1348
  buf[0..6],
1340
1349
  );
1341
- stream.reset();
1350
+ writer.reset();
1342
1351
  }
1343
1352
 
1344
1353
  test "|switch|" {
@@ -1350,31 +1359,31 @@ test "|switch|" {
1350
1359
  try log.switched(.{ p2.ident(3), &snorlax });
1351
1360
  const par = 0b1000000;
1352
1361
  var expected: []const u8 = switch (endian) {
1353
- big => &.{ N(ArgType.Switch), 0b1011, N(S1.Snorlax), 91, 0, 200, 1, 144, par },
1354
- little => &.{ N(ArgType.Switch), 0b1011, N(S1.Snorlax), 91, 200, 0, 144, 1, par },
1362
+ .big => &.{ N(ArgType.Switch), 0b1011, N(S1.Snorlax), 91, 0, 200, 1, 144, par },
1363
+ .little => &.{ N(ArgType.Switch), 0b1011, N(S1.Snorlax), 91, 200, 0, 144, 1, par },
1355
1364
  };
1356
1365
  try expectLog1(expected, buf[0..9]);
1357
- stream.reset();
1366
+ writer.reset();
1358
1367
 
1359
1368
  snorlax.level = 100;
1360
1369
  snorlax.hp = 0;
1361
1370
  snorlax.status = 0;
1362
1371
  try log.switched(.{ p2.ident(3), &snorlax });
1363
1372
  expected = switch (endian) {
1364
- big => &.{ N(ArgType.Switch), 0b1011, N(S1.Snorlax), 100, 0, 0, 1, 144, 0 },
1365
- little => &.{ N(ArgType.Switch), 0b1011, N(S1.Snorlax), 100, 0, 0, 144, 1, 0 },
1373
+ .big => &.{ N(ArgType.Switch), 0b1011, N(S1.Snorlax), 100, 0, 0, 1, 144, 0 },
1374
+ .little => &.{ N(ArgType.Switch), 0b1011, N(S1.Snorlax), 100, 0, 0, 144, 1, 0 },
1366
1375
  };
1367
1376
  try expectLog1(expected, buf[0..9]);
1368
- stream.reset();
1377
+ writer.reset();
1369
1378
 
1370
1379
  snorlax.hp = 400;
1371
1380
  try log.switched(.{ p2.ident(3), &snorlax });
1372
1381
  expected = switch (endian) {
1373
- big => &.{ N(ArgType.Switch), 0b1011, N(S1.Snorlax), 100, 1, 144, 1, 144, 0 },
1374
- little => &.{ N(ArgType.Switch), 0b1011, N(S1.Snorlax), 100, 144, 1, 144, 1, 0 },
1382
+ .big => &.{ N(ArgType.Switch), 0b1011, N(S1.Snorlax), 100, 1, 144, 1, 144, 0 },
1383
+ .little => &.{ N(ArgType.Switch), 0b1011, N(S1.Snorlax), 100, 144, 1, 144, 1, 0 },
1375
1384
  };
1376
1385
  try expectLog1(expected, buf[0..9]);
1377
- stream.reset();
1386
+ writer.reset();
1378
1387
 
1379
1388
  var blissey = gen2.helpers.Pokemon.init(.{ .species = .Blissey, .moves = &.{.Splash} });
1380
1389
  blissey.level = 91;
@@ -1389,53 +1398,53 @@ test "|switch|" {
1389
1398
  N(gen2.Gender.Female),
1390
1399
  91,
1391
1400
  } ++ switch (endian) {
1392
- big => .{ 0, 200, 1, 144, par },
1393
- little => .{ 200, 0, 144, 1, par },
1401
+ .big => .{ 0, 200, 1, 144, par },
1402
+ .little => .{ 200, 0, 144, 1, par },
1394
1403
  });
1395
1404
  try expectLog2(expected, buf[0..10]);
1396
- stream.reset();
1405
+ writer.reset();
1397
1406
  }
1398
1407
 
1399
1408
  test "|cant|" {
1400
1409
  try log.cant(.{ p2.ident(6), .Bound });
1401
1410
  try expectLog1(&.{ N(ArgType.Cant), 0b1110, N(Cant.Bound) }, buf[0..3]);
1402
- stream.reset();
1411
+ writer.reset();
1403
1412
 
1404
1413
  try log.cant(.{ p1.ident(2), .Disable, M1.Earthquake });
1405
1414
  try expectLog1(&.{ N(ArgType.Cant), 2, N(Cant.Disable), N(M1.Earthquake) }, buf[0..4]);
1406
- stream.reset();
1415
+ writer.reset();
1407
1416
  }
1408
1417
 
1409
1418
  test "|faint|" {
1410
1419
  try log.faint(.{ p2.ident(2), false });
1411
1420
  try expectLog1(&.{ N(ArgType.Faint), 0b1010 }, buf[0..2]);
1412
- stream.reset();
1421
+ writer.reset();
1413
1422
 
1414
1423
  try log.faint(.{ p2.ident(2), true });
1415
1424
  try expectLog1(&.{ N(ArgType.Faint), 0b1010, N(ArgType.None) }, buf[0..3]);
1416
- stream.reset();
1425
+ writer.reset();
1417
1426
  }
1418
1427
 
1419
1428
  test "|turn|" {
1420
1429
  try log.turn(.{42});
1421
1430
  const expected = switch (endian) {
1422
- big => &.{ N(ArgType.Turn), 0, 42, N(ArgType.None) },
1423
- little => &.{ N(ArgType.Turn), 42, 0, N(ArgType.None) },
1431
+ .big => &.{ N(ArgType.Turn), 0, 42, N(ArgType.None) },
1432
+ .little => &.{ N(ArgType.Turn), 42, 0, N(ArgType.None) },
1424
1433
  };
1425
1434
  try expectLog1(expected, buf[0..4]);
1426
- stream.reset();
1435
+ writer.reset();
1427
1436
  }
1428
1437
 
1429
1438
  test "|win|" {
1430
1439
  try log.win(.{.P2});
1431
1440
  try expectLog1(&.{ N(ArgType.Win), 1, N(ArgType.None) }, buf[0..3]);
1432
- stream.reset();
1441
+ writer.reset();
1433
1442
  }
1434
1443
 
1435
1444
  test "|tie|" {
1436
1445
  try log.tie(.{});
1437
1446
  try expectLog1(&.{ N(ArgType.Tie), N(ArgType.None) }, buf[0..2]);
1438
- stream.reset();
1447
+ writer.reset();
1439
1448
  }
1440
1449
 
1441
1450
  test "|-damage|" {
@@ -1444,31 +1453,31 @@ test "|-damage|" {
1444
1453
  chansey.status = gen1.Status.slp(1);
1445
1454
  try log.damage(.{ p2.ident(2), &chansey, .None });
1446
1455
  var expected: []const u8 = switch (endian) {
1447
- big => &.{ N(ArgType.Damage), 0b1010, 2, 100, 2, 191, 1, N(Damage.None) },
1448
- little => &.{ N(ArgType.Damage), 0b1010, 100, 2, 191, 2, 1, N(Damage.None) },
1456
+ .big => &.{ N(ArgType.Damage), 0b1010, 2, 100, 2, 191, 1, N(Damage.None) },
1457
+ .little => &.{ N(ArgType.Damage), 0b1010, 100, 2, 191, 2, 1, N(Damage.None) },
1449
1458
  };
1450
1459
  try expectLog1(expected, buf[0..8]);
1451
- stream.reset();
1460
+ writer.reset();
1452
1461
 
1453
1462
  chansey.hp = 100;
1454
1463
  chansey.stats.hp = 256;
1455
1464
  chansey.status = 0;
1456
1465
  try log.damage(.{ p2.ident(2), &chansey, .Confusion });
1457
1466
  expected = switch (endian) {
1458
- big => &.{ N(ArgType.Damage), 0b1010, 0, 100, 1, 0, 0, N(Damage.Confusion) },
1459
- little => &.{ N(ArgType.Damage), 0b1010, 100, 0, 0, 1, 0, N(Damage.Confusion) },
1467
+ .big => &.{ N(ArgType.Damage), 0b1010, 0, 100, 1, 0, 0, N(Damage.Confusion) },
1468
+ .little => &.{ N(ArgType.Damage), 0b1010, 100, 0, 0, 1, 0, N(Damage.Confusion) },
1460
1469
  };
1461
1470
  try expectLog1(expected, buf[0..8]);
1462
- stream.reset();
1471
+ writer.reset();
1463
1472
 
1464
1473
  chansey.status = gen1.Status.init(.PSN);
1465
1474
  try log.damage(.{ p2.ident(2), &chansey, .RecoilOf, p1.ident(1) });
1466
1475
  expected = switch (endian) {
1467
- big => &.{ N(ArgType.Damage), 0b1010, 0, 100, 1, 0, 0b1000, N(Damage.RecoilOf), 1 },
1468
- little => &.{ N(ArgType.Damage), 0b1010, 100, 0, 0, 1, 0b1000, N(Damage.RecoilOf), 1 },
1476
+ .big => &.{ N(ArgType.Damage), 0b1010, 0, 100, 1, 0, 0b1000, N(Damage.RecoilOf), 1 },
1477
+ .little => &.{ N(ArgType.Damage), 0b1010, 100, 0, 0, 1, 0b1000, N(Damage.RecoilOf), 1 },
1469
1478
  };
1470
1479
  try expectLog1(expected, buf[0..9]);
1471
- stream.reset();
1480
+ writer.reset();
1472
1481
  }
1473
1482
 
1474
1483
  test "|-heal|" {
@@ -1477,53 +1486,53 @@ test "|-heal|" {
1477
1486
  chansey.status = gen1.Status.slp(1);
1478
1487
  try log.heal(.{ p2.ident(2), &chansey, .None });
1479
1488
  var expected: []const u8 = switch (endian) {
1480
- big => &.{ N(ArgType.Heal), 0b1010, 2, 100, 2, 191, 1, N(Heal.None) },
1481
- little => &.{ N(ArgType.Heal), 0b1010, 100, 2, 191, 2, 1, N(Heal.None) },
1489
+ .big => &.{ N(ArgType.Heal), 0b1010, 2, 100, 2, 191, 1, N(Heal.None) },
1490
+ .little => &.{ N(ArgType.Heal), 0b1010, 100, 2, 191, 2, 1, N(Heal.None) },
1482
1491
  };
1483
1492
  try expectLog1(expected, buf[0..8]);
1484
- stream.reset();
1493
+ writer.reset();
1485
1494
 
1486
1495
  chansey.hp = 100;
1487
1496
  chansey.stats.hp = 256;
1488
1497
  chansey.status = 0;
1489
1498
  try log.heal(.{ p2.ident(2), &chansey, .Silent });
1490
1499
  expected = switch (endian) {
1491
- big => &.{ N(ArgType.Heal), 0b1010, 0, 100, 1, 0, 0, N(Heal.Silent) },
1492
- little => &.{ N(ArgType.Heal), 0b1010, 100, 0, 0, 1, 0, N(Heal.Silent) },
1500
+ .big => &.{ N(ArgType.Heal), 0b1010, 0, 100, 1, 0, 0, N(Heal.Silent) },
1501
+ .little => &.{ N(ArgType.Heal), 0b1010, 100, 0, 0, 1, 0, N(Heal.Silent) },
1493
1502
  };
1494
1503
  try expectLog1(expected, buf[0..8]);
1495
- stream.reset();
1504
+ writer.reset();
1496
1505
 
1497
1506
  try log.heal(.{ p2.ident(2), &chansey, .Drain, p1.ident(1) });
1498
1507
  expected = switch (endian) {
1499
- big => &.{ N(ArgType.Heal), 0b1010, 0, 100, 1, 0, 0, N(Heal.Drain), 1 },
1500
- little => &.{ N(ArgType.Heal), 0b1010, 100, 0, 0, 1, 0, N(Heal.Drain), 1 },
1508
+ .big => &.{ N(ArgType.Heal), 0b1010, 0, 100, 1, 0, 0, N(Heal.Drain), 1 },
1509
+ .little => &.{ N(ArgType.Heal), 0b1010, 100, 0, 0, 1, 0, N(Heal.Drain), 1 },
1501
1510
  };
1502
1511
  try expectLog1(expected, buf[0..9]);
1503
- stream.reset();
1512
+ writer.reset();
1504
1513
  }
1505
1514
 
1506
1515
  test "|-status|" {
1507
1516
  try log.status(.{ p2.ident(6), gen1.Status.init(.BRN), .None });
1508
1517
  try expectLog1(&.{ N(ArgType.Status), 0b1110, 0b10000, N(Status.None) }, buf[0..4]);
1509
- stream.reset();
1518
+ writer.reset();
1510
1519
 
1511
1520
  try log.status(.{ p2.ident(2), gen1.Status.init(.PSN), .Silent });
1512
1521
  try expectLog1(&.{ N(ArgType.Status), 0b1010, 0b1000, N(Status.Silent) }, buf[0..4]);
1513
- stream.reset();
1522
+ writer.reset();
1514
1523
 
1515
1524
  try log.status(.{ p1.ident(1), gen1.Status.init(.PAR), .From, M1.BodySlam });
1516
1525
  try expectLog1(
1517
1526
  &.{ N(ArgType.Status), 0b0001, 0b1000000, N(Status.From), N(M1.BodySlam) },
1518
1527
  buf[0..5],
1519
1528
  );
1520
- stream.reset();
1529
+ writer.reset();
1521
1530
  }
1522
1531
 
1523
1532
  test "|-curestatus|" {
1524
1533
  try log.curestatus(.{ p2.ident(6), gen1.Status.slp(7), .Message });
1525
1534
  try expectLog1(&.{ N(ArgType.CureStatus), 0b1110, 0b111, N(CureStatus.Message) }, buf[0..4]);
1526
- stream.reset();
1535
+ writer.reset();
1527
1536
 
1528
1537
  try log.curestatus(.{ p1.ident(2), gen1.Status.TOX, .Silent });
1529
1538
  try expectLog1(&.{
@@ -1532,86 +1541,86 @@ test "|-curestatus|" {
1532
1541
  0b10001000,
1533
1542
  N(CureStatus.Silent),
1534
1543
  }, buf[0..4]);
1535
- stream.reset();
1544
+ writer.reset();
1536
1545
  }
1537
1546
 
1538
1547
  test "|-boost|" {
1539
1548
  try log.boost(.{ p2.ident(6), .Speed, 2 });
1540
1549
  try expectLog1(&.{ N(ArgType.Boost), 0b1110, N(Boost.Speed), 8 }, buf[0..4]);
1541
- stream.reset();
1550
+ writer.reset();
1542
1551
 
1543
1552
  try log.boost(.{ p1.ident(2), .Rage, 1 });
1544
1553
  try expectLog1(&.{ N(ArgType.Boost), 0b0010, N(Boost.Rage), 7 }, buf[0..4]);
1545
- stream.reset();
1554
+ writer.reset();
1546
1555
 
1547
1556
  try log.boost(.{ p2.ident(3), .Defense, -2 });
1548
1557
  try expectLog1(&.{ N(ArgType.Boost), 0b1011, N(Boost.Defense), 4 }, buf[0..4]);
1549
- stream.reset();
1558
+ writer.reset();
1550
1559
  }
1551
1560
 
1552
1561
  test "|-clearallboost|" {
1553
1562
  try log.clearallboost(.{});
1554
1563
  try expectLog1(&.{N(ArgType.ClearAllBoost)}, buf[0..1]);
1555
- stream.reset();
1564
+ writer.reset();
1556
1565
  }
1557
1566
 
1558
1567
  test "|-fail|" {
1559
1568
  try log.fail(.{ p2.ident(6), .None });
1560
1569
  try expectLog1(&.{ N(ArgType.Fail), 0b1110, N(Fail.None) }, buf[0..3]);
1561
- stream.reset();
1570
+ writer.reset();
1562
1571
 
1563
1572
  try log.fail(.{ p2.ident(6), .Sleep });
1564
1573
  try expectLog1(&.{ N(ArgType.Fail), 0b1110, N(Fail.Sleep) }, buf[0..3]);
1565
- stream.reset();
1574
+ writer.reset();
1566
1575
 
1567
1576
  try log.fail(.{ p2.ident(6), .Substitute });
1568
1577
  try expectLog1(&.{ N(ArgType.Fail), 0b1110, N(Fail.Substitute) }, buf[0..3]);
1569
- stream.reset();
1578
+ writer.reset();
1570
1579
 
1571
1580
  try log.fail(.{ p2.ident(6), .Weak });
1572
1581
  try expectLog1(&.{ N(ArgType.Fail), 0b1110, N(Fail.Weak) }, buf[0..3]);
1573
- stream.reset();
1582
+ writer.reset();
1574
1583
  }
1575
1584
 
1576
1585
  test "|-miss|" {
1577
1586
  try log.miss(.{p2.ident(4)});
1578
1587
  try expectLog1(&.{ N(ArgType.Miss), 0b1100 }, buf[0..2]);
1579
- stream.reset();
1588
+ writer.reset();
1580
1589
  }
1581
1590
  test "|-hitcount|" {
1582
1591
  try log.hitcount(.{ p2.ident(1), 5 });
1583
1592
  try expectLog1(&.{ N(ArgType.HitCount), 0b1001, 5 }, buf[0..3]);
1584
- stream.reset();
1593
+ writer.reset();
1585
1594
  }
1586
1595
 
1587
1596
  test "|-prepare|" {
1588
1597
  try log.prepare(.{ p2.ident(2), M1.Dig });
1589
1598
  try expectLog1(&.{ N(ArgType.Prepare), 0b1010, N(M1.Dig) }, buf[0..3]);
1590
- stream.reset();
1599
+ writer.reset();
1591
1600
  }
1592
1601
 
1593
1602
  test "|-mustrecharge|" {
1594
1603
  try log.mustrecharge(.{p1.ident(6)});
1595
1604
  try expectLog1(&.{ N(ArgType.MustRecharge), 0b0110 }, buf[0..2]);
1596
- stream.reset();
1605
+ writer.reset();
1597
1606
  }
1598
1607
 
1599
1608
  test "|-activate|" {
1600
1609
  try log.activate(.{ p1.ident(2), .Struggle });
1601
1610
  try expectLog1(&.{ N(ArgType.Activate), 0b0010, N(Activate.Struggle) }, buf[0..3]);
1602
- stream.reset();
1611
+ writer.reset();
1603
1612
 
1604
1613
  try log.activate(.{ p2.ident(4), .Mist });
1605
1614
  try expectLog1(&.{ N(ArgType.Activate), 0b1100, N(Activate.Mist) }, buf[0..3]);
1606
- stream.reset();
1615
+ writer.reset();
1607
1616
 
1608
1617
  try log.activate(.{ p2.ident(6), .Substitute });
1609
1618
  try expectLog1(&.{ N(ArgType.Activate), 0b1110, N(Activate.Substitute) }, buf[0..3]);
1610
- stream.reset();
1619
+ writer.reset();
1611
1620
 
1612
1621
  try log.activate(.{ p1.ident(2), .Splash });
1613
1622
  try expectLog1(&.{ N(ArgType.Activate), 0b0010, N(Activate.Splash) }, buf[0..3]);
1614
- stream.reset();
1623
+ writer.reset();
1615
1624
 
1616
1625
  try log.activate(.{ p1.ident(4), .SubstituteBlock, M2.Spite });
1617
1626
  try expectLog1(&.{
@@ -1620,27 +1629,27 @@ test "|-activate|" {
1620
1629
  N(Activate.SubstituteBlock),
1621
1630
  N(M2.Spite),
1622
1631
  }, buf[0..4]);
1623
- stream.reset();
1632
+ writer.reset();
1624
1633
 
1625
1634
  try log.activate(.{ p1.ident(3), .Magnitude, 5 });
1626
1635
  try expectLog1(&.{ N(ArgType.Activate), 0b0011, N(Activate.Magnitude), 5 }, buf[0..4]);
1627
- stream.reset();
1636
+ writer.reset();
1628
1637
  }
1629
1638
 
1630
1639
  test "|-fieldactivate|" {
1631
1640
  try log.fieldactivate(.{});
1632
1641
  try expectLog1(&.{N(ArgType.FieldActivate)}, buf[0..1]);
1633
- stream.reset();
1642
+ writer.reset();
1634
1643
  }
1635
1644
 
1636
1645
  test "|-start|" {
1637
1646
  try log.start(.{ p2.ident(6), .Bide });
1638
1647
  try expectLog1(&.{ N(ArgType.Start), 0b1110, N(Start.Bide) }, buf[0..3]);
1639
- stream.reset();
1648
+ writer.reset();
1640
1649
 
1641
1650
  try log.start(.{ p1.ident(2), .ConfusionSilent });
1642
1651
  try expectLog1(&.{ N(ArgType.Start), 0b0010, N(Start.ConfusionSilent) }, buf[0..3]);
1643
- stream.reset();
1652
+ writer.reset();
1644
1653
 
1645
1654
  try log.start(.{
1646
1655
  p2.ident(6),
@@ -1652,7 +1661,7 @@ test "|-start|" {
1652
1661
  &.{ N(ArgType.Start), 0b1110, N(Start.TypeChange), 0b1000_1000, 0b1101 },
1653
1662
  buf[0..5],
1654
1663
  );
1655
- stream.reset();
1664
+ writer.reset();
1656
1665
 
1657
1666
  try log.start(.{
1658
1667
  p1.ident(2),
@@ -1664,65 +1673,65 @@ test "|-start|" {
1664
1673
  &.{ N(ArgType.Start), 0b0010, N(Start.TypeChange), 0b0011_0110, 0b1100 },
1665
1674
  buf[0..5],
1666
1675
  );
1667
- stream.reset();
1676
+ writer.reset();
1668
1677
 
1669
1678
  try log.start(.{ p1.ident(2), .Disable, M1.Surf });
1670
1679
  try expectLog1(&.{ N(ArgType.Start), 0b0010, N(Start.Disable), N(M1.Surf) }, buf[0..4]);
1671
- stream.reset();
1680
+ writer.reset();
1672
1681
 
1673
1682
  try log.start(.{ p1.ident(2), .Mimic, M1.Surf });
1674
1683
  try expectLog1(&.{ N(ArgType.Start), 0b0010, N(Start.Mimic), N(M1.Surf) }, buf[0..4]);
1675
- stream.reset();
1684
+ writer.reset();
1676
1685
  }
1677
1686
 
1678
1687
  test "|-end|" {
1679
1688
  try log.end(.{ p2.ident(6), .Bide });
1680
1689
  try expectLog1(&.{ N(ArgType.End), 0b1110, N(End.Bide) }, buf[0..3]);
1681
- stream.reset();
1690
+ writer.reset();
1682
1691
 
1683
1692
  try log.end(.{ p1.ident(2), .ConfusionSilent });
1684
1693
  try expectLog1(&.{ N(ArgType.End), 0b0010, N(End.ConfusionSilent) }, buf[0..3]);
1685
- stream.reset();
1694
+ writer.reset();
1686
1695
  }
1687
1696
 
1688
1697
  test "|-ohko|" {
1689
1698
  try log.ohko(.{});
1690
1699
  try expectLog1(&.{N(ArgType.OHKO)}, buf[0..1]);
1691
- stream.reset();
1700
+ writer.reset();
1692
1701
  }
1693
1702
 
1694
1703
  test "|-crit|" {
1695
1704
  try log.crit(.{p2.ident(5)});
1696
1705
  try expectLog1(&.{ N(ArgType.Crit), 0b1101 }, buf[0..2]);
1697
- stream.reset();
1706
+ writer.reset();
1698
1707
  }
1699
1708
 
1700
1709
  test "|-supereffective|" {
1701
1710
  try log.supereffective(.{p1.ident(1)});
1702
1711
  try expectLog1(&.{ N(ArgType.SuperEffective), 0b0001 }, buf[0..2]);
1703
- stream.reset();
1712
+ writer.reset();
1704
1713
  }
1705
1714
 
1706
1715
  test "|-resisted|" {
1707
1716
  try log.resisted(.{p2.ident(2)});
1708
1717
  try expectLog1(&.{ N(ArgType.Resisted), 0b1010 }, buf[0..2]);
1709
- stream.reset();
1718
+ writer.reset();
1710
1719
  }
1711
1720
 
1712
1721
  test "|-immune|" {
1713
1722
  try log.immune(.{ p1.ident(3), .None });
1714
1723
  try expectLog1(&.{ N(ArgType.Immune), 0b0011, N(Immune.None) }, buf[0..3]);
1715
- stream.reset();
1724
+ writer.reset();
1716
1725
 
1717
1726
  try log.immune(.{ p2.ident(2), .OHKO });
1718
1727
  try expectLog1(&.{ N(ArgType.Immune), 0b1010, N(Immune.OHKO) }, buf[0..3]);
1719
- stream.reset();
1728
+ writer.reset();
1720
1729
  }
1721
1730
 
1722
1731
  test "|-transform|" {
1723
1732
  try log.transform(.{ p2.ident(4), p1.ident(5) });
1724
1733
  try expectLog1(&.{ N(ArgType.Transform), 0b1100, 0b0101 }, buf[0..3]);
1725
- stream.reset();
1734
+ writer.reset();
1726
1735
  }
1727
1736
 
1728
1737
  test "|drag|" {
@@ -1740,33 +1749,33 @@ test "|drag|" {
1740
1749
  N(gen2.Gender.Female),
1741
1750
  91,
1742
1751
  } ++ switch (endian) {
1743
- big => .{ 0, 200, 1, 144, par },
1744
- little => .{ 200, 0, 144, 1, par },
1752
+ .big => .{ 0, 200, 1, 144, par },
1753
+ .little => .{ 200, 0, 144, 1, par },
1745
1754
  });
1746
1755
  try expectLog2(expected, buf[0..10]);
1747
- stream.reset();
1756
+ writer.reset();
1748
1757
  }
1749
1758
 
1750
1759
  test "|-item|" {
1751
1760
  try log.item(.{ p2.ident(2), I2.GoldBerry, p1.ident(4) });
1752
1761
  try expectLog2(&.{ N(ArgType.Item), 0b1010, N(I2.GoldBerry), 0b0100 }, buf[0..4]);
1753
- stream.reset();
1762
+ writer.reset();
1754
1763
  }
1755
1764
 
1756
1765
  test "|-enditem|" {
1757
1766
  try log.enditem(.{ p1.ident(1), I2.BerserkGene, .None });
1758
1767
  try expectLog2(&.{ N(ArgType.EndItem), 0b0001, N(I2.BerserkGene), N(EndItem.None) }, buf[0..4]);
1759
- stream.reset();
1768
+ writer.reset();
1760
1769
 
1761
1770
  try log.enditem(.{ p2.ident(4), I2.PRZCureBerry, .Eat });
1762
1771
  try expectLog2(&.{ N(ArgType.EndItem), 0b1100, N(I2.PRZCureBerry), N(EndItem.Eat) }, buf[0..4]);
1763
- stream.reset();
1772
+ writer.reset();
1764
1773
  }
1765
1774
 
1766
1775
  test "|-cureteam|" {
1767
1776
  try log.cureteam(.{p2.ident(5)});
1768
1777
  try expectLog2(&.{ N(ArgType.CureTeam), 0b1101 }, buf[0..2]);
1769
- stream.reset();
1778
+ writer.reset();
1770
1779
  }
1771
1780
 
1772
1781
  test "|-sethp|" {
@@ -1774,39 +1783,39 @@ test "|-sethp|" {
1774
1783
  blissey.hp = 612;
1775
1784
  try log.sethp(.{ p2.ident(2), &blissey, .Silent });
1776
1785
  const expected: []const u8 = switch (endian) {
1777
- big => &.{ N(ArgType.SetHP), 0b1010, 2, 100, 2, 201, 0, N(SetHP.Silent) },
1778
- little => &.{ N(ArgType.SetHP), 0b1010, 100, 2, 201, 2, 0, N(SetHP.Silent) },
1786
+ .big => &.{ N(ArgType.SetHP), 0b1010, 2, 100, 2, 201, 0, N(SetHP.Silent) },
1787
+ .little => &.{ N(ArgType.SetHP), 0b1010, 100, 2, 201, 2, 0, N(SetHP.Silent) },
1779
1788
  };
1780
1789
  try expectLog2(expected, buf[0..8]);
1781
- stream.reset();
1790
+ writer.reset();
1782
1791
  }
1783
1792
 
1784
1793
  test "|-setboost|" {
1785
1794
  try log.setboost(.{ p2.ident(6), 6 });
1786
1795
  try expectLog2(&.{ N(ArgType.SetBoost), 0b1110, 12 }, buf[0..3]);
1787
- stream.reset();
1796
+ writer.reset();
1788
1797
 
1789
1798
  try log.setboost(.{ p2.ident(3), 2 });
1790
1799
  try expectLog2(&.{ N(ArgType.SetBoost), 0b1011, 8 }, buf[0..3]);
1791
- stream.reset();
1800
+ writer.reset();
1792
1801
  }
1793
1802
 
1794
1803
  test "|-copyboost|" {
1795
1804
  try log.copyboost(.{ p2.ident(3), p1.ident(6) });
1796
1805
  try expectLog2(&.{ N(ArgType.CopyBoost), 0b1011, 0b0110 }, buf[0..3]);
1797
- stream.reset();
1806
+ writer.reset();
1798
1807
  }
1799
1808
 
1800
1809
  test "|-sidestart|" {
1801
1810
  try log.sidestart(.{ .P2, .Reflect });
1802
1811
  try expectLog2(&.{ N(ArgType.SideStart), 1, N(Side.Reflect) }, buf[0..3]);
1803
- stream.reset();
1812
+ writer.reset();
1804
1813
  }
1805
1814
 
1806
1815
  test "|-sideend|" {
1807
1816
  try log.sideend(.{ .P2, .LightScreen });
1808
1817
  try expectLog2(&.{ N(ArgType.SideEnd), 1, N(Side.LightScreen) }, buf[0..3]);
1809
- stream.reset();
1818
+ writer.reset();
1810
1819
 
1811
1820
  try log.sideend(.{ .P1, .Spikes, p1.ident(3) });
1812
1821
  try expectLog2(&.{
@@ -1815,27 +1824,27 @@ test "|-sideend|" {
1815
1824
  N(Side.Spikes),
1816
1825
  0b0011,
1817
1826
  }, buf[0..4]);
1818
- stream.reset();
1827
+ writer.reset();
1819
1828
  }
1820
1829
 
1821
1830
  test "|-singlemove|" {
1822
1831
  try log.singlemove(.{ p2.ident(2), M2.DestinyBond });
1823
1832
  try expectLog2(&.{ N(ArgType.SingleMove), 0b1010, N(M2.DestinyBond) }, buf[0..3]);
1824
- stream.reset();
1833
+ writer.reset();
1825
1834
  }
1826
1835
 
1827
1836
  test "|-singleturn|" {
1828
1837
  try log.singleturn(.{ p1.ident(3), M2.Protect });
1829
1838
  try expectLog2(&.{ N(ArgType.SingleTurn), 0b0011, N(M2.Protect) }, buf[0..3]);
1830
- stream.reset();
1839
+ writer.reset();
1831
1840
  }
1832
1841
 
1833
1842
  test "|-weather|" {
1834
1843
  try log.weather(.{ W2.Rain, .Upkeep });
1835
1844
  try expectLog2(&.{ N(ArgType.Weather), N(W2.Rain), N(Weather.Upkeep) }, buf[0..3]);
1836
- stream.reset();
1845
+ writer.reset();
1837
1846
 
1838
1847
  try log.weather(.{ W2.None, .None });
1839
1848
  try expectLog2(&.{ N(ArgType.Weather), N(W2.None), N(Weather.None) }, buf[0..3]);
1840
- stream.reset();
1849
+ writer.reset();
1841
1850
  }