@pkmn/engine 0.1.0-dev.305a932f → 0.1.0-dev.30c63015

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.
@@ -150,6 +150,10 @@ pub const Damage = enum(u8) {
150
150
  Clamp,
151
151
  Whirlpool,
152
152
  Spikes,
153
+
154
+ Nightmare,
155
+ Curse,
156
+ Sandstorm,
153
157
  };
154
158
 
155
159
  pub const Status = enum(u8) {
@@ -192,9 +196,11 @@ pub const Activate = enum(u8) {
192
196
  Haze,
193
197
  Mist,
194
198
  Struggle,
195
- Substitute,
199
+ Substitute, // FIXME SubstituteDamage
196
200
  Splash,
197
201
 
202
+ Rage, // TODO
203
+
198
204
  Attract,
199
205
  LockOn,
200
206
  Bind,
@@ -202,8 +208,13 @@ pub const Activate = enum(u8) {
202
208
  FireSpin,
203
209
  Clamp,
204
210
  Whirlpool,
211
+ SubstituteBlock,
212
+
213
+ DestinyBond,
205
214
 
206
215
  BeatUp, // FIXME of
216
+
217
+ Magnitude,
207
218
  };
208
219
 
209
220
  pub const Start = enum(u8) {
@@ -222,6 +233,7 @@ pub const Start = enum(u8) {
222
233
  Disable,
223
234
  Mimic,
224
235
 
236
+ Attract,
225
237
  Nightmare,
226
238
  Curse,
227
239
  Foresight,
@@ -247,6 +259,7 @@ pub const End = enum(u8) {
247
259
  Encore,
248
260
  FutureSight,
249
261
  LeechSeed,
262
+
250
263
  Bind,
251
264
  Wrap,
252
265
  FireSpin,
@@ -262,6 +275,8 @@ pub const End = enum(u8) {
262
275
  LightScreenSilent,
263
276
  ReflectSilent,
264
277
  BideSilent,
278
+
279
+ LeechSeedFrom,
265
280
  };
266
281
 
267
282
  pub const Immune = enum(u8) {
@@ -305,267 +320,254 @@ pub fn Log(comptime Writer: type) type {
305
320
 
306
321
  pub const Error = Writer.Error;
307
322
 
308
- pub fn move(self: Self, source: ID, m: anytype, target: ID, from: anytype) Error!void {
323
+ // source: ID, m: anytype, target: ID, from?: anytype
324
+ pub fn move(self: Self, args: anytype) Error!void {
309
325
  if (!enabled) return;
310
326
 
311
- assert(m != .None);
327
+ assert(args[1] != .None);
312
328
  try self.writer.writeAll(&.{
313
329
  @intFromEnum(ArgType.Move),
314
- @as(u8, @bitCast(source)),
315
- @intFromEnum(m),
316
- @as(u8, @bitCast(target)),
317
- });
318
- const none = &[_]u8{@intFromEnum(Move.None)};
319
- try self.writer.writeAll(switch (@typeInfo(@TypeOf(from))) {
320
- .Null => none,
321
- .Optional => if (from) |f| blk: {
322
- assert(@intFromEnum(f) != 0);
323
- break :blk &[_]u8{ @intFromEnum(Move.From), @intFromEnum(f) };
324
- } else none,
325
- else => blk: {
326
- assert(@intFromEnum(from) != 0);
327
- break :blk &[_]u8{ @intFromEnum(Move.From), @intFromEnum(from) };
328
- },
330
+ @as(u8, @bitCast(args[0])),
331
+ @intFromEnum(args[1]),
332
+ @as(u8, @bitCast(args[2])),
329
333
  });
334
+ try self.writer.writeAll(if (args.len < 4 or @intFromEnum(args[3]) == 0)
335
+ &.{@intFromEnum(Move.None)}
336
+ else
337
+ &.{ @intFromEnum(Move.From), @intFromEnum(args[3]) });
330
338
  }
331
339
 
332
- pub fn switched(self: Self, ident: ID, pokemon: anytype) Error!void {
333
- return switchDrag(self, .Switch, ident, pokemon);
340
+ // ident: ID, pokemon: anytype
341
+ pub fn switched(self: Self, args: anytype) Error!void {
342
+ return switchDrag(self, .Switch, args);
334
343
  }
335
344
 
336
- fn switchDrag(self: Self, arg: ArgType, ident: ID, pokemon: anytype) Error!void {
345
+ // ident: ID, pokemon: anytype
346
+ fn switchDrag(self: Self, arg: ArgType, args: anytype) Error!void {
337
347
  if (!enabled) return;
338
348
 
339
- try self.writer.writeAll(&.{ @intFromEnum(arg), @as(u8, @bitCast(ident)) });
340
- if (@hasField(@TypeOf(pokemon.*), "dvs")) {
349
+ try self.writer.writeAll(&.{ @intFromEnum(arg), @as(u8, @bitCast(args[0])) });
350
+ if (@hasField(@TypeOf(args[1].*), "dvs")) {
341
351
  try self.writer.writeAll(&.{
342
- @intFromEnum(pokemon.species),
343
- @intFromEnum(pokemon.dvs.gender),
344
- pokemon.level,
352
+ @intFromEnum(args[1].species),
353
+ @intFromEnum(args[1].dvs.gender),
354
+ args[1].level,
345
355
  });
346
356
  } else {
347
- try self.writer.writeAll(&.{ @intFromEnum(pokemon.species), pokemon.level });
357
+ try self.writer.writeAll(&.{ @intFromEnum(args[1].species), args[1].level });
348
358
  }
349
- try self.writer.writeIntNative(u16, pokemon.hp);
350
- try self.writer.writeIntNative(u16, pokemon.stats.hp);
351
- try self.writer.writeAll(&.{pokemon.status});
359
+ try self.writer.writeIntNative(u16, args[1].hp);
360
+ try self.writer.writeIntNative(u16, args[1].stats.hp);
361
+ try self.writer.writeAll(&.{args[1].status});
352
362
  }
353
363
 
354
- pub fn cant(self: Self, ident: ID, reason: Cant) Error!void {
364
+ // ident: ID, reason: Cant, m?: anytype
365
+ pub fn cant(self: Self, args: anytype) Error!void {
355
366
  if (!enabled) return;
356
367
 
357
- assert(reason != .Disable);
368
+ assert(args[1] != .Disable or args.len == 3);
358
369
  try self.writer.writeAll(&.{
359
370
  @intFromEnum(ArgType.Cant),
360
- @as(u8, @bitCast(ident)),
361
- @intFromEnum(reason),
362
- });
363
- }
364
-
365
- pub fn disabled(self: Self, ident: ID, m: anytype) Error!void {
366
- if (!enabled) return;
367
-
368
- try self.writer.writeAll(&.{
369
- @intFromEnum(ArgType.Cant),
370
- @as(u8, @bitCast(ident)),
371
- @intFromEnum(Cant.Disable),
372
- @intFromEnum(m),
371
+ @as(u8, @bitCast(args[0])),
372
+ @intFromEnum(args[1]),
373
373
  });
374
+ if (args.len == 3) try self.writer.writeByte(@intFromEnum(args[2]));
374
375
  }
375
376
 
376
- pub fn faint(self: Self, ident: ID, done: bool) Error!void {
377
+ // ident: ID, done: bool
378
+ pub fn faint(self: Self, args: anytype) Error!void {
377
379
  if (!enabled) return;
378
380
 
379
- try self.writer.writeAll(&.{ @intFromEnum(ArgType.Faint), @as(u8, @bitCast(ident)) });
380
- if (done) try self.writer.writeByte(@intFromEnum(ArgType.None));
381
+ try self.writer.writeAll(&.{ @intFromEnum(ArgType.Faint), @as(u8, @bitCast(args[0])) });
382
+ if (args[1]) try self.writer.writeByte(@intFromEnum(ArgType.None));
381
383
  }
382
384
 
383
- pub fn turn(self: Self, num: u16) Error!void {
385
+ // num: u16
386
+ pub fn turn(self: Self, args: anytype) Error!void {
384
387
  if (!enabled) return;
385
388
 
386
389
  try self.writer.writeByte(@intFromEnum(ArgType.Turn));
387
- try self.writer.writeIntNative(u16, num);
390
+ try self.writer.writeIntNative(u16, args[0]);
388
391
  try self.writer.writeByte(@intFromEnum(ArgType.None));
389
392
  }
390
393
 
391
- pub fn win(self: Self, player: Player) Error!void {
394
+ // player: Player
395
+ pub fn win(self: Self, args: anytype) Error!void {
392
396
  if (!enabled) return;
393
397
 
394
398
  try self.writer.writeAll(&.{
395
399
  @intFromEnum(ArgType.Win),
396
- @intFromEnum(player),
400
+ @intFromEnum(args[0]),
397
401
  @intFromEnum(ArgType.None),
398
402
  });
399
403
  }
400
404
 
401
- pub fn tie(self: Self) Error!void {
405
+ // -
406
+ pub fn tie(self: Self, _: anytype) Error!void {
402
407
  if (!enabled) return;
403
408
 
404
409
  try self.writer.writeAll(&.{ @intFromEnum(ArgType.Tie), @intFromEnum(ArgType.None) });
405
410
  }
406
411
 
407
- pub fn damage(self: Self, ident: ID, pokemon: anytype, reason: Damage) Error!void {
408
- if (!enabled) return;
409
-
410
- assert(@intFromEnum(reason) <= @intFromEnum(Damage.LeechSeed));
411
- try self.writer.writeAll(&.{ @intFromEnum(ArgType.Damage), @as(u8, @bitCast(ident)) });
412
- try self.writer.writeIntNative(u16, pokemon.hp);
413
- try self.writer.writeIntNative(u16, pokemon.stats.hp);
414
- try self.writer.writeAll(&.{ pokemon.status, @intFromEnum(reason) });
415
- }
416
-
417
- pub fn damageOf(
418
- self: Self,
419
- ident: ID,
420
- pokemon: anytype,
421
- reason: Damage,
422
- source: ID,
423
- ) Error!void {
412
+ // ident: ID, pokemon: anytype, reason: Damage, source?: ID
413
+ pub fn damage(self: Self, args: anytype) Error!void {
424
414
  if (!enabled) return;
425
415
 
426
- assert(@intFromEnum(reason) == @intFromEnum(Damage.RecoilOf));
427
- try self.writer.writeAll(&.{ @intFromEnum(ArgType.Damage), @as(u8, @bitCast(ident)) });
428
- try self.writer.writeIntNative(u16, pokemon.hp);
429
- try self.writer.writeIntNative(u16, pokemon.stats.hp);
416
+ assert(@intFromEnum(args[2]) <= @intFromEnum(Damage.LeechSeed) or args.len == 4);
430
417
  try self.writer.writeAll(&.{
431
- pokemon.status,
432
- @intFromEnum(reason),
433
- @as(u8, @bitCast(source)),
418
+ @intFromEnum(ArgType.Damage),
419
+ @as(u8, @bitCast(args[0])),
434
420
  });
421
+ try self.writer.writeIntNative(u16, args[1].hp);
422
+ try self.writer.writeIntNative(u16, args[1].stats.hp);
423
+ try self.writer.writeAll(&.{ args[1].status, @intFromEnum(args[2]) });
424
+ if (args.len == 4) try self.writer.writeByte(@as(u8, @bitCast(args[3])));
435
425
  }
436
426
 
437
- pub fn heal(self: Self, ident: ID, pokemon: anytype, reason: Heal) Error!void {
427
+ // ident: ID, pokemon: anytype, reason: Heal, target?: ID)
428
+ pub fn heal(self: Self, args: anytype) Error!void {
438
429
  if (!enabled) return;
439
430
 
440
- assert(reason != .Drain);
441
- try self.writer.writeAll(&.{ @intFromEnum(ArgType.Heal), @as(u8, @bitCast(ident)) });
442
- try self.writer.writeIntNative(u16, pokemon.hp);
443
- try self.writer.writeIntNative(u16, pokemon.stats.hp);
444
- try self.writer.writeAll(&.{ pokemon.status, @intFromEnum(reason) });
431
+ assert(args[2] != .Drain or args.len == 4);
432
+ try self.writer.writeAll(&.{ @intFromEnum(ArgType.Heal), @as(u8, @bitCast(args[0])) });
433
+ try self.writer.writeIntNative(u16, args[1].hp);
434
+ try self.writer.writeIntNative(u16, args[1].stats.hp);
435
+ try self.writer.writeAll(&.{ args[1].status, @intFromEnum(args[2]) });
436
+ if (args.len == 4) try self.writer.writeByte(@as(u8, @bitCast(args[3])));
445
437
  }
446
438
 
447
- pub fn drain(self: Self, source: ID, pokemon: anytype, target: ID) Error!void {
439
+ // ident: ID, value: u8, reason: Status, m?: anytype)
440
+ pub fn status(self: Self, args: anytype) Error!void {
448
441
  if (!enabled) return;
449
442
 
450
- try self.writer.writeAll(&.{ @intFromEnum(ArgType.Heal), @as(u8, @bitCast(source)) });
451
- try self.writer.writeIntNative(u16, pokemon.hp);
452
- try self.writer.writeIntNative(u16, pokemon.stats.hp);
443
+ assert(args[2] != .From or args.len == 4);
453
444
  try self.writer.writeAll(&.{
454
- pokemon.status,
455
- @intFromEnum(Heal.Drain),
456
- @as(u8, @bitCast(target)),
445
+ @intFromEnum(ArgType.Status),
446
+ @as(u8, @bitCast(args[0])),
447
+ args[1],
448
+ @intFromEnum(args[2]),
457
449
  });
450
+ if (args.len == 4) try self.writer.writeByte(@intFromEnum(args[3]));
458
451
  }
459
452
 
460
- pub fn status(self: Self, ident: ID, value: u8, reason: Status) Error!void {
453
+ // ident: ID, value: u8, reason: CureStatus
454
+ pub fn curestatus(self: Self, args: anytype) Error!void {
461
455
  if (!enabled) return;
462
456
 
463
- assert(reason != .From);
464
457
  try self.writer.writeAll(&.{
465
- @intFromEnum(ArgType.Status),
466
- @as(u8, @bitCast(ident)),
467
- value,
468
- @intFromEnum(reason),
458
+ @intFromEnum(ArgType.CureStatus),
459
+ @as(u8, @bitCast(args[0])),
460
+ args[1],
461
+ @intFromEnum(args[2]),
469
462
  });
470
463
  }
471
464
 
472
- pub fn statusFrom(self: Self, ident: ID, value: u8, m: anytype) Error!void {
465
+ // ident: ID, reason: Boost, num: i8
466
+ pub fn boost(self: Self, args: anytype) Error!void {
473
467
  if (!enabled) return;
474
468
 
469
+ assert(args[2] != 0 and (args[1] != .Rage or args[2] > 0));
475
470
  try self.writer.writeAll(&.{
476
- @intFromEnum(ArgType.Status),
477
- @as(u8, @bitCast(ident)),
478
- value,
479
- @intFromEnum(Status.From),
480
- @intFromEnum(m),
471
+ @intFromEnum(ArgType.Boost),
472
+ @as(u8, @bitCast(args[0])),
473
+ @intFromEnum(args[1]),
474
+ @as(u8, @intCast(@as(i8, args[2]) + 6)),
481
475
  });
482
476
  }
483
477
 
484
- pub fn curestatus(self: Self, ident: ID, value: u8, reason: CureStatus) Error!void {
478
+ // -
479
+ pub fn clearallboost(self: Self, _: anytype) Error!void {
485
480
  if (!enabled) return;
486
481
 
487
- try self.writer.writeAll(&.{
488
- @intFromEnum(ArgType.CureStatus),
489
- @as(u8, @bitCast(ident)),
490
- value,
491
- @intFromEnum(reason),
492
- });
482
+ try self.writer.writeAll(&.{@intFromEnum(ArgType.ClearAllBoost)});
493
483
  }
494
484
 
495
- pub fn boost(self: Self, ident: ID, reason: Boost, num: i8) Error!void {
485
+ // ident: ID, reason: Fail
486
+ pub fn fail(self: Self, args: anytype) Error!void {
496
487
  if (!enabled) return;
497
488
 
498
- assert(num != 0 and (reason != .Rage or num > 0));
499
489
  try self.writer.writeAll(&.{
500
- @intFromEnum(ArgType.Boost),
501
- @as(u8, @bitCast(ident)),
502
- @intFromEnum(reason),
503
- @as(u8, @intCast(num + 6)),
490
+ @intFromEnum(ArgType.Fail),
491
+ @as(u8, @bitCast(args[0])),
492
+ @intFromEnum(args[1]),
504
493
  });
505
494
  }
506
495
 
507
- pub fn clearallboost(self: Self) Error!void {
496
+ // source: ID
497
+ pub fn miss(self: Self, args: anytype) Error!void {
508
498
  if (!enabled) return;
509
499
 
510
- try self.writer.writeAll(&.{@intFromEnum(ArgType.ClearAllBoost)});
500
+ try self.writer.writeAll(&.{ @intFromEnum(ArgType.Miss), @as(u8, @bitCast(args[0])) });
511
501
  }
512
502
 
513
- pub fn fail(self: Self, ident: ID, reason: Fail) Error!void {
503
+ // ident: ID, num: u8
504
+ pub fn hitcount(self: Self, args: anytype) Error!void {
514
505
  if (!enabled) return;
515
506
 
516
507
  try self.writer.writeAll(&.{
517
- @intFromEnum(ArgType.Fail),
518
- @as(u8, @bitCast(ident)),
519
- @intFromEnum(reason),
508
+ @intFromEnum(ArgType.HitCount),
509
+ @as(u8, @bitCast(args[0])),
510
+ args[1],
520
511
  });
521
512
  }
522
513
 
523
- pub fn miss(self: Self, source: ID) Error!void {
514
+ // source: ID, m: anytype
515
+ pub fn prepare(self: Self, args: anytype) Error!void {
524
516
  if (!enabled) return;
525
517
 
526
- try self.writer.writeAll(&.{ @intFromEnum(ArgType.Miss), @as(u8, @bitCast(source)) });
518
+ try self.writer.writeAll(&.{
519
+ @intFromEnum(ArgType.Prepare),
520
+ @as(u8, @bitCast(args[0])),
521
+ @intFromEnum(args[1]),
522
+ });
527
523
  }
528
524
 
529
- pub fn hitcount(self: Self, ident: ID, num: u8) Error!void {
525
+ // ident: ID
526
+ pub fn mustrecharge(self: Self, args: anytype) Error!void {
530
527
  if (!enabled) return;
531
528
 
532
529
  try self.writer.writeAll(&.{
533
- @intFromEnum(ArgType.HitCount),
534
- @as(u8, @bitCast(ident)),
535
- num,
530
+ @intFromEnum(ArgType.MustRecharge),
531
+ @as(u8, @bitCast(args[0])),
536
532
  });
537
533
  }
538
534
 
539
- pub fn prepare(self: Self, source: ID, m: anytype) Error!void {
535
+ pub fn activate(self: Self, ident: ID, reason: Activate) Error!void {
540
536
  if (!enabled) return;
541
537
 
538
+ assert(reason != .SubstituteBlock); // TODO
542
539
  try self.writer.writeAll(&.{
543
- @intFromEnum(ArgType.Prepare),
544
- @as(u8, @bitCast(source)),
545
- @intFromEnum(m),
540
+ @intFromEnum(ArgType.Activate),
541
+ @as(u8, @bitCast(ident)),
542
+ @intFromEnum(reason),
546
543
  });
547
544
  }
548
545
 
549
- pub fn mustrecharge(self: Self, ident: ID) Error!void {
546
+ pub fn activateMove(self: Self, ident: ID, reason: Activate, m: anytype) Error!void {
550
547
  if (!enabled) return;
551
548
 
549
+ assert(reason == .SubstituteBlock); // TODO
552
550
  try self.writer.writeAll(&.{
553
- @intFromEnum(ArgType.MustRecharge),
551
+ @intFromEnum(ArgType.Activate),
554
552
  @as(u8, @bitCast(ident)),
553
+ @intFromEnum(reason),
554
+ @intFromEnum(m),
555
555
  });
556
556
  }
557
557
 
558
- pub fn activate(self: Self, ident: ID, reason: Activate) Error!void {
558
+ pub fn magnitude(self: Self, ident: ID, num: u8) Error!void {
559
559
  if (!enabled) return;
560
560
 
561
561
  try self.writer.writeAll(&.{
562
562
  @intFromEnum(ArgType.Activate),
563
563
  @as(u8, @bitCast(ident)),
564
- @intFromEnum(reason),
564
+ @intFromEnum(Activate.Magnitude),
565
+ num,
565
566
  });
566
567
  }
567
568
 
568
- pub fn fieldactivate(self: Self) Error!void {
569
+ // -
570
+ pub fn fieldactivate(self: Self, _: anytype) Error!void {
569
571
  if (!enabled) return;
570
572
 
571
573
  try self.writer.writeAll(&.{@intFromEnum(ArgType.FieldActivate)});
@@ -606,200 +608,211 @@ pub fn Log(comptime Writer: type) type {
606
608
  });
607
609
  }
608
610
 
609
- pub fn end(self: Self, ident: ID, reason: End) Error!void {
611
+ // ident: ID, reason: End)
612
+ pub fn end(self: Self, args: anytype) Error!void {
610
613
  if (!enabled) return;
611
614
 
612
615
  try self.writer.writeAll(&.{
613
616
  @intFromEnum(ArgType.End),
614
- @as(u8, @bitCast(ident)),
615
- @intFromEnum(reason),
617
+ @as(u8, @bitCast(args[0])),
618
+ @intFromEnum(args[1]),
616
619
  });
617
620
  }
618
621
 
619
- pub fn ohko(self: Self) Error!void {
622
+ // -
623
+ pub fn ohko(self: Self, _: anytype) Error!void {
620
624
  if (!enabled) return;
621
625
 
622
626
  try self.writer.writeAll(&.{@intFromEnum(ArgType.OHKO)});
623
627
  }
624
628
 
625
- pub fn crit(self: Self, ident: ID) Error!void {
629
+ // ident: ID
630
+ pub fn crit(self: Self, args: anytype) Error!void {
626
631
  if (!enabled) return;
627
632
 
628
- try self.writer.writeAll(&.{ @intFromEnum(ArgType.Crit), @as(u8, @bitCast(ident)) });
633
+ try self.writer.writeAll(&.{ @intFromEnum(ArgType.Crit), @as(u8, @bitCast(args[0])) });
629
634
  }
630
635
 
631
- pub fn supereffective(self: Self, ident: ID) Error!void {
636
+ // ident: ID
637
+ pub fn supereffective(self: Self, args: anytype) Error!void {
632
638
  if (!enabled) return;
633
639
 
634
640
  try self.writer.writeAll(&.{
635
641
  @intFromEnum(ArgType.SuperEffective),
636
- @as(u8, @bitCast(ident)),
642
+ @as(u8, @bitCast(args[0])),
637
643
  });
638
644
  }
639
645
 
640
- pub fn resisted(self: Self, ident: ID) Error!void {
646
+ // ident: ID
647
+ pub fn resisted(self: Self, args: anytype) Error!void {
641
648
  if (!enabled) return;
642
649
 
643
650
  try self.writer.writeAll(&.{
644
651
  @intFromEnum(ArgType.Resisted),
645
- @as(u8, @bitCast(ident)),
652
+ @as(u8, @bitCast(args[0])),
646
653
  });
647
654
  }
648
655
 
649
- pub fn immune(self: Self, ident: ID, reason: Immune) Error!void {
656
+ // ident: ID, reason: Immune
657
+ pub fn immune(self: Self, args: anytype) Error!void {
650
658
  if (!enabled) return;
651
659
 
652
660
  try self.writer.writeAll(&.{
653
661
  @intFromEnum(ArgType.Immune),
654
- @as(u8, @bitCast(ident)),
655
- @intFromEnum(reason),
662
+ @as(u8, @bitCast(args[0])),
663
+ @intFromEnum(args[1]),
656
664
  });
657
665
  }
658
666
 
659
- pub fn transform(self: Self, source: ID, target: ID) Error!void {
667
+ // source: ID, target: ID
668
+ pub fn transform(self: Self, args: anytype) Error!void {
660
669
  if (!enabled) return;
661
670
 
662
671
  try self.writer.writeAll(&.{
663
672
  @intFromEnum(ArgType.Transform),
664
- @as(u8, @bitCast(source)),
665
- @as(u8, @bitCast(target)),
673
+ @as(u8, @bitCast(args[0])),
674
+ @as(u8, @bitCast(args[1])),
666
675
  });
667
676
  }
668
677
 
669
- pub fn drag(self: Self, ident: ID, pokemon: anytype) Error!void {
670
- return switchDrag(self, .Drag, ident, pokemon);
678
+ // ident: ID, pokemon: anytype
679
+ pub fn drag(self: Self, args: anytype) Error!void {
680
+ return switchDrag(self, .Drag, args);
671
681
  }
672
682
 
673
- pub fn item(self: Self, target: ID, i: anytype, source: ID) Error!void {
683
+ // target: ID, i: anytype, source: ID
684
+ pub fn item(self: Self, args: anytype) Error!void {
674
685
  if (!enabled) return;
675
686
 
676
687
  try self.writer.writeAll(&.{
677
688
  @intFromEnum(ArgType.Item),
678
- @as(u8, @bitCast(target)),
679
- @intFromEnum(i),
680
- @as(u8, @bitCast(source)),
689
+ @as(u8, @bitCast(args[0])),
690
+ @intFromEnum(args[1]),
691
+ @as(u8, @bitCast(args[2])),
681
692
  });
682
693
  }
683
694
 
684
- pub fn enditem(self: Self, ident: ID, i: anytype, reason: EndItem) Error!void {
695
+ // ident: ID, i: anytype, reason: EndItem
696
+ pub fn enditem(self: Self, args: anytype) Error!void {
685
697
  if (!enabled) return;
686
698
 
687
699
  try self.writer.writeAll(&.{
688
700
  @intFromEnum(ArgType.EndItem),
689
- @as(u8, @bitCast(ident)),
690
- @intFromEnum(i),
691
- @intFromEnum(reason),
701
+ @as(u8, @bitCast(args[0])),
702
+ @intFromEnum(args[1]),
703
+ @intFromEnum(args[2]),
692
704
  });
693
705
  }
694
706
 
695
- pub fn cureteam(self: Self, source: ID) Error!void {
707
+ // source: ID
708
+ pub fn cureteam(self: Self, args: anytype) Error!void {
696
709
  if (!enabled) return;
697
710
 
698
711
  try self.writer.writeAll(&.{
699
712
  @intFromEnum(ArgType.CureTeam),
700
- @as(u8, @bitCast(source)),
713
+ @as(u8, @bitCast(args[0])),
701
714
  });
702
715
  }
703
716
 
704
- pub fn sethp(self: Self, ident: ID, pokemon: anytype, reason: SetHP) Error!void {
717
+ // ident: ID, pokemon: anytype, reason: SetHP
718
+ pub fn sethp(self: Self, args: anytype) Error!void {
705
719
  if (!enabled) return;
706
720
 
707
- try self.writer.writeAll(&.{ @intFromEnum(ArgType.SetHP), @as(u8, @bitCast(ident)) });
708
- try self.writer.writeIntNative(u16, pokemon.hp);
709
- try self.writer.writeIntNative(u16, pokemon.stats.hp);
710
- try self.writer.writeAll(&.{pokemon.status});
711
- try self.writer.writeByte(@intFromEnum(reason));
721
+ try self.writer.writeAll(&.{ @intFromEnum(ArgType.SetHP), @as(u8, @bitCast(args[0])) });
722
+ try self.writer.writeIntNative(u16, args[1].hp);
723
+ try self.writer.writeIntNative(u16, args[1].stats.hp);
724
+ try self.writer.writeAll(&.{args[1].status});
725
+ try self.writer.writeByte(@intFromEnum(args[2]));
712
726
  }
713
727
 
714
- pub fn setboost(self: Self, ident: ID, num: i8) Error!void {
728
+ // ident: ID, num: i8
729
+ pub fn setboost(self: Self, args: anytype) Error!void {
715
730
  if (!enabled) return;
716
731
 
717
732
  try self.writer.writeAll(&.{
718
733
  @intFromEnum(ArgType.SetBoost),
719
- @as(u8, @bitCast(ident)),
720
- @as(u8, @intCast(num + 6)),
734
+ @as(u8, @bitCast(args[0])),
735
+ @as(u8, @intCast(args[1] + 6)),
721
736
  });
722
737
  }
723
738
 
724
- pub fn copyboost(self: Self, source: ID, target: ID) Error!void {
739
+ // source: ID, target: ID
740
+ pub fn copyboost(self: Self, args: anytype) Error!void {
725
741
  if (!enabled) return;
726
742
 
727
743
  try self.writer.writeAll(&.{
728
744
  @intFromEnum(ArgType.CopyBoost),
729
- @as(u8, @bitCast(source)),
730
- @as(u8, @bitCast(target)),
745
+ @as(u8, @bitCast(args[0])),
746
+ @as(u8, @bitCast(args[1])),
731
747
  });
732
748
  }
733
749
 
734
- pub fn sidestart(self: Self, player: Player, reason: Side) Error!void {
750
+ // player: Player, reason: Side
751
+ pub fn sidestart(self: Self, args: anytype) Error!void {
735
752
  if (!enabled) return;
736
753
 
737
754
  try self.writer.writeAll(&.{
738
755
  @intFromEnum(ArgType.SideStart),
739
- @intFromEnum(player),
740
- @intFromEnum(reason),
756
+ @intFromEnum(args[0]),
757
+ @intFromEnum(args[1]),
741
758
  });
742
759
  }
743
760
 
744
- pub fn sideend(self: Self, player: Player, reason: Side) Error!void {
761
+ // player: Player, reason: Side, source?: ID
762
+ pub fn sideend(self: Self, args: anytype) Error!void {
745
763
  if (!enabled) return;
746
764
 
747
- assert(@intFromEnum(reason) != @intFromEnum(Side.Spikes));
765
+ assert(@intFromEnum(args[1]) != @intFromEnum(Side.Spikes) or args.len == 3);
748
766
  try self.writer.writeAll(&.{
749
767
  @intFromEnum(ArgType.SideEnd),
750
- @intFromEnum(player),
751
- @intFromEnum(reason),
768
+ @intFromEnum(args[0]),
769
+ @intFromEnum(args[1]),
752
770
  });
771
+ if (args.len == 3) try self.writer.writeByte(@as(u8, @bitCast(args[2])));
753
772
  }
754
773
 
755
- pub fn spikesend(self: Self, player: Player, m: anytype, source: ID) Error!void {
756
- if (!enabled) return;
757
-
758
- try self.writer.writeAll(&.{
759
- @intFromEnum(ArgType.SideEnd),
760
- @intFromEnum(player),
761
- @intFromEnum(Side.Spikes),
762
- @intFromEnum(m),
763
- @as(u8, @bitCast(source)),
764
- });
774
+ // ident: ID, move: anytype
775
+ pub fn singlemove(self: Self, args: anytype) Error!void {
776
+ return single(self, .SingleMove, args);
765
777
  }
766
778
 
767
- pub fn singlemove(self: Self, ident: ID, m: anytype) Error!void {
768
- return single(self, .SingleMove, ident, m);
779
+ // ident: ID, m: anytype
780
+ pub fn singleturn(self: Self, args: anytype) Error!void {
781
+ return single(self, .SingleTurn, args);
769
782
  }
770
783
 
771
- pub fn singleturn(self: Self, ident: ID, m: anytype) Error!void {
772
- return single(self, .SingleTurn, ident, m);
773
- }
774
-
775
- fn single(self: Self, arg: ArgType, ident: ID, m: anytype) Error!void {
784
+ // ident: ID, move: anytype
785
+ fn single(self: Self, arg: ArgType, args: anytype) Error!void {
776
786
  if (!enabled) return;
777
787
 
778
788
  try self.writer.writeAll(&.{
779
789
  @intFromEnum(arg),
780
- @as(u8, @bitCast(ident)),
781
- @intFromEnum(m),
790
+ @as(u8, @bitCast(args[0])),
791
+ @intFromEnum(args[1]),
782
792
  });
783
793
  }
784
794
 
785
- pub fn weather(self: Self, w: anytype, reason: Weather) Error!void {
795
+ // w: anytype, reason: Weather
796
+ pub fn weather(self: Self, args: anytype) Error!void {
786
797
  if (!enabled) return;
787
798
 
788
- assert(!(w == .None and reason == .Upkeep));
799
+ assert(!(args[0] == .None and args[1] == .Upkeep));
789
800
  try self.writer.writeAll(&.{
790
801
  @intFromEnum(ArgType.Weather),
791
- @intFromEnum(w),
792
- @intFromEnum(reason),
802
+ @intFromEnum(args[0]),
803
+ @intFromEnum(args[1]),
793
804
  });
794
805
  }
795
806
 
796
- pub fn laststill(self: Self) Error!void {
807
+ // -
808
+ pub fn laststill(self: Self, _: anytype) Error!void {
797
809
  if (!enabled) return;
798
810
 
799
811
  try self.writer.writeAll(&.{@intFromEnum(ArgType.LastStill)});
800
812
  }
801
813
 
802
- pub fn lastmiss(self: Self) Error!void {
814
+ // -
815
+ pub fn lastmiss(self: Self, _: anytype) Error!void {
803
816
  if (!enabled) return;
804
817
 
805
818
  try self.writer.writeAll(&.{@intFromEnum(ArgType.LastMiss)});
@@ -1288,23 +1301,22 @@ fn formatter(comptime gen: anytype, kind: Kind, byte: u8) []const u8 {
1288
1301
  }
1289
1302
 
1290
1303
  test "|move|" {
1291
- try log.move(p2.ident(4), M1.Thunderbolt, p1.ident(5), null);
1304
+ try log.move(.{ p2.ident(4), M1.Thunderbolt, p1.ident(5) });
1292
1305
  try expectLog1(
1293
1306
  &.{ N(ArgType.Move), 0b1100, N(M1.Thunderbolt), 0b0101, N(Move.None) },
1294
1307
  buf[0..5],
1295
1308
  );
1296
1309
  stream.reset();
1297
1310
 
1298
- try log.move(p2.ident(4), M1.Wrap, p1.ident(5), M1.Wrap);
1299
- const wrap = N(M1.Wrap);
1311
+ try log.move(.{ p2.ident(4), M1.Pound, p1.ident(5), M1.Metronome });
1300
1312
  try expectLog1(
1301
- &.{ N(ArgType.Move), 0b1100, wrap, 0b0101, N(Move.From), wrap },
1313
+ &.{ N(ArgType.Move), 0b1100, N(M1.Pound), 0b0101, N(Move.From), N(M1.Metronome) },
1302
1314
  buf[0..6],
1303
1315
  );
1304
1316
  stream.reset();
1305
1317
 
1306
- try log.move(p2.ident(4), M1.SkullBash, .{}, null);
1307
- try log.laststill();
1318
+ try log.move(.{ p2.ident(4), M1.SkullBash, ID{} });
1319
+ try log.laststill(.{});
1308
1320
  try expectLog1(
1309
1321
  &.{
1310
1322
  N(ArgType.Move),
@@ -1318,8 +1330,8 @@ test "|move|" {
1318
1330
  );
1319
1331
  stream.reset();
1320
1332
 
1321
- try log.move(p2.ident(4), M1.Tackle, p1.ident(5), null);
1322
- try log.lastmiss();
1333
+ try log.move(.{ p2.ident(4), M1.Tackle, p1.ident(5) });
1334
+ try log.lastmiss(.{});
1323
1335
  try expectLog1(
1324
1336
  &.{
1325
1337
  N(ArgType.Move),
@@ -1340,7 +1352,7 @@ test "|switch|" {
1340
1352
  snorlax.hp = 200;
1341
1353
  snorlax.stats.hp = 400;
1342
1354
  snorlax.status = gen1.Status.init(.PAR);
1343
- try log.switched(p2.ident(3), &snorlax);
1355
+ try log.switched(.{ p2.ident(3), &snorlax });
1344
1356
  const par = 0b1000000;
1345
1357
  var expected: []const u8 = switch (endian) {
1346
1358
  .Big => &.{ N(ArgType.Switch), 0b1011, N(S1.Snorlax), 91, 0, 200, 1, 144, par },
@@ -1352,7 +1364,7 @@ test "|switch|" {
1352
1364
  snorlax.level = 100;
1353
1365
  snorlax.hp = 0;
1354
1366
  snorlax.status = 0;
1355
- try log.switched(p2.ident(3), &snorlax);
1367
+ try log.switched(.{ p2.ident(3), &snorlax });
1356
1368
  expected = switch (endian) {
1357
1369
  .Big => &.{ N(ArgType.Switch), 0b1011, N(S1.Snorlax), 100, 0, 0, 1, 144, 0 },
1358
1370
  .Little => &.{ N(ArgType.Switch), 0b1011, N(S1.Snorlax), 100, 0, 0, 144, 1, 0 },
@@ -1361,7 +1373,7 @@ test "|switch|" {
1361
1373
  stream.reset();
1362
1374
 
1363
1375
  snorlax.hp = 400;
1364
- try log.switched(p2.ident(3), &snorlax);
1376
+ try log.switched(.{ p2.ident(3), &snorlax });
1365
1377
  expected = switch (endian) {
1366
1378
  .Big => &.{ N(ArgType.Switch), 0b1011, N(S1.Snorlax), 100, 1, 144, 1, 144, 0 },
1367
1379
  .Little => &.{ N(ArgType.Switch), 0b1011, N(S1.Snorlax), 100, 144, 1, 144, 1, 0 },
@@ -1374,7 +1386,7 @@ test "|switch|" {
1374
1386
  blissey.hp = 200;
1375
1387
  blissey.stats.hp = 400;
1376
1388
  blissey.status = gen2.Status.init(.PAR);
1377
- try log.switched(p2.ident(3), &blissey);
1389
+ try log.switched(.{ p2.ident(3), &blissey });
1378
1390
  expected = &(.{
1379
1391
  N(ArgType.Switch),
1380
1392
  0b1011,
@@ -1390,27 +1402,27 @@ test "|switch|" {
1390
1402
  }
1391
1403
 
1392
1404
  test "|cant|" {
1393
- try log.cant(p2.ident(6), .Bound);
1405
+ try log.cant(.{ p2.ident(6), Cant.Bound });
1394
1406
  try expectLog1(&.{ N(ArgType.Cant), 0b1110, N(Cant.Bound) }, buf[0..3]);
1395
1407
  stream.reset();
1396
1408
 
1397
- try log.disabled(p1.ident(2), M1.Earthquake);
1409
+ try log.cant(.{ p1.ident(2), Cant.Disable, M1.Earthquake });
1398
1410
  try expectLog1(&.{ N(ArgType.Cant), 2, N(Cant.Disable), N(M1.Earthquake) }, buf[0..4]);
1399
1411
  stream.reset();
1400
1412
  }
1401
1413
 
1402
1414
  test "|faint|" {
1403
- try log.faint(p2.ident(2), false);
1415
+ try log.faint(.{ p2.ident(2), false });
1404
1416
  try expectLog1(&.{ N(ArgType.Faint), 0b1010 }, buf[0..2]);
1405
1417
  stream.reset();
1406
1418
 
1407
- try log.faint(p2.ident(2), true);
1419
+ try log.faint(.{ p2.ident(2), true });
1408
1420
  try expectLog1(&.{ N(ArgType.Faint), 0b1010, N(ArgType.None) }, buf[0..3]);
1409
1421
  stream.reset();
1410
1422
  }
1411
1423
 
1412
1424
  test "|turn|" {
1413
- try log.turn(42);
1425
+ try log.turn(.{42});
1414
1426
  var expected = switch (endian) {
1415
1427
  .Big => &.{ N(ArgType.Turn), 0, 42, N(ArgType.None) },
1416
1428
  .Little => &.{ N(ArgType.Turn), 42, 0, N(ArgType.None) },
@@ -1420,13 +1432,13 @@ test "|turn|" {
1420
1432
  }
1421
1433
 
1422
1434
  test "|win|" {
1423
- try log.win(.P2);
1435
+ try log.win(.{Player.P2});
1424
1436
  try expectLog1(&.{ N(ArgType.Win), 1, N(ArgType.None) }, buf[0..3]);
1425
1437
  stream.reset();
1426
1438
  }
1427
1439
 
1428
1440
  test "|tie|" {
1429
- try log.tie();
1441
+ try log.tie(.{});
1430
1442
  try expectLog1(&.{ N(ArgType.Tie), N(ArgType.None) }, buf[0..2]);
1431
1443
  stream.reset();
1432
1444
  }
@@ -1435,7 +1447,7 @@ test "|-damage|" {
1435
1447
  var chansey = gen1.helpers.Pokemon.init(.{ .species = .Chansey, .moves = &.{.Splash} });
1436
1448
  chansey.hp = 612;
1437
1449
  chansey.status = gen1.Status.slp(1);
1438
- try log.damage(p2.ident(2), &chansey, .None);
1450
+ try log.damage(.{ p2.ident(2), &chansey, Damage.None });
1439
1451
  var expected: []const u8 = switch (endian) {
1440
1452
  .Big => &.{ N(ArgType.Damage), 0b1010, 2, 100, 2, 191, 1, N(Damage.None) },
1441
1453
  .Little => &.{ N(ArgType.Damage), 0b1010, 100, 2, 191, 2, 1, N(Damage.None) },
@@ -1446,7 +1458,7 @@ test "|-damage|" {
1446
1458
  chansey.hp = 100;
1447
1459
  chansey.stats.hp = 256;
1448
1460
  chansey.status = 0;
1449
- try log.damage(p2.ident(2), &chansey, .Confusion);
1461
+ try log.damage(.{ p2.ident(2), &chansey, Damage.Confusion });
1450
1462
  expected = switch (endian) {
1451
1463
  .Big => &.{ N(ArgType.Damage), 0b1010, 0, 100, 1, 0, 0, N(Damage.Confusion) },
1452
1464
  .Little => &.{ N(ArgType.Damage), 0b1010, 100, 0, 0, 1, 0, N(Damage.Confusion) },
@@ -1455,7 +1467,7 @@ test "|-damage|" {
1455
1467
  stream.reset();
1456
1468
 
1457
1469
  chansey.status = gen1.Status.init(.PSN);
1458
- try log.damageOf(p2.ident(2), &chansey, .RecoilOf, p1.ident(1));
1470
+ try log.damage(.{ p2.ident(2), &chansey, Damage.RecoilOf, p1.ident(1) });
1459
1471
  expected = switch (endian) {
1460
1472
  .Big => &.{ N(ArgType.Damage), 0b1010, 0, 100, 1, 0, 0b1000, N(Damage.RecoilOf), 1 },
1461
1473
  .Little => &.{ N(ArgType.Damage), 0b1010, 100, 0, 0, 1, 0b1000, N(Damage.RecoilOf), 1 },
@@ -1468,7 +1480,7 @@ test "|-heal|" {
1468
1480
  var chansey = gen1.helpers.Pokemon.init(.{ .species = .Chansey, .moves = &.{.Splash} });
1469
1481
  chansey.hp = 612;
1470
1482
  chansey.status = gen1.Status.slp(1);
1471
- try log.heal(p2.ident(2), &chansey, .None);
1483
+ try log.heal(.{ p2.ident(2), &chansey, Heal.None });
1472
1484
  var expected: []const u8 = switch (endian) {
1473
1485
  .Big => &.{ N(ArgType.Heal), 0b1010, 2, 100, 2, 191, 1, N(Heal.None) },
1474
1486
  .Little => &.{ N(ArgType.Heal), 0b1010, 100, 2, 191, 2, 1, N(Heal.None) },
@@ -1479,7 +1491,7 @@ test "|-heal|" {
1479
1491
  chansey.hp = 100;
1480
1492
  chansey.stats.hp = 256;
1481
1493
  chansey.status = 0;
1482
- try log.heal(p2.ident(2), &chansey, .Silent);
1494
+ try log.heal(.{ p2.ident(2), &chansey, Heal.Silent });
1483
1495
  expected = switch (endian) {
1484
1496
  .Big => &.{ N(ArgType.Heal), 0b1010, 0, 100, 1, 0, 0, N(Heal.Silent) },
1485
1497
  .Little => &.{ N(ArgType.Heal), 0b1010, 100, 0, 0, 1, 0, N(Heal.Silent) },
@@ -1487,7 +1499,7 @@ test "|-heal|" {
1487
1499
  try expectLog1(expected, buf[0..8]);
1488
1500
  stream.reset();
1489
1501
 
1490
- try log.drain(p2.ident(2), &chansey, p1.ident(1));
1502
+ try log.heal(.{ p2.ident(2), &chansey, Heal.Drain, p1.ident(1) });
1491
1503
  expected = switch (endian) {
1492
1504
  .Big => &.{ N(ArgType.Heal), 0b1010, 0, 100, 1, 0, 0, N(Heal.Drain), 1 },
1493
1505
  .Little => &.{ N(ArgType.Heal), 0b1010, 100, 0, 0, 1, 0, N(Heal.Drain), 1 },
@@ -1497,15 +1509,15 @@ test "|-heal|" {
1497
1509
  }
1498
1510
 
1499
1511
  test "|-status|" {
1500
- try log.status(p2.ident(6), gen1.Status.init(.BRN), .None);
1512
+ try log.status(.{ p2.ident(6), gen1.Status.init(.BRN), Status.None });
1501
1513
  try expectLog1(&.{ N(ArgType.Status), 0b1110, 0b10000, N(Status.None) }, buf[0..4]);
1502
1514
  stream.reset();
1503
1515
 
1504
- try log.status(p2.ident(2), gen1.Status.init(.PSN), .Silent);
1516
+ try log.status(.{ p2.ident(2), gen1.Status.init(.PSN), Status.Silent });
1505
1517
  try expectLog1(&.{ N(ArgType.Status), 0b1010, 0b1000, N(Status.Silent) }, buf[0..4]);
1506
1518
  stream.reset();
1507
1519
 
1508
- try log.statusFrom(p1.ident(1), gen1.Status.init(.PAR), M1.BodySlam);
1520
+ try log.status(.{ p1.ident(1), gen1.Status.init(.PAR), Status.From, M1.BodySlam });
1509
1521
  try expectLog1(
1510
1522
  &.{ N(ArgType.Status), 0b0001, 0b1000000, N(Status.From), N(M1.BodySlam) },
1511
1523
  buf[0..5],
@@ -1514,11 +1526,11 @@ test "|-status|" {
1514
1526
  }
1515
1527
 
1516
1528
  test "|-curestatus|" {
1517
- try log.curestatus(p2.ident(6), gen1.Status.slp(7), .Message);
1529
+ try log.curestatus(.{ p2.ident(6), gen1.Status.slp(7), CureStatus.Message });
1518
1530
  try expectLog1(&.{ N(ArgType.CureStatus), 0b1110, 0b111, N(CureStatus.Message) }, buf[0..4]);
1519
1531
  stream.reset();
1520
1532
 
1521
- try log.curestatus(p1.ident(2), gen1.Status.TOX, .Silent);
1533
+ try log.curestatus(.{ p1.ident(2), gen1.Status.TOX, CureStatus.Silent });
1522
1534
  try expectLog1(&.{
1523
1535
  N(ArgType.CureStatus),
1524
1536
  0b0010,
@@ -1529,62 +1541,62 @@ test "|-curestatus|" {
1529
1541
  }
1530
1542
 
1531
1543
  test "|-boost|" {
1532
- try log.boost(p2.ident(6), .Speed, 2);
1544
+ try log.boost(.{ p2.ident(6), Boost.Speed, 2 });
1533
1545
  try expectLog1(&.{ N(ArgType.Boost), 0b1110, N(Boost.Speed), 8 }, buf[0..4]);
1534
1546
  stream.reset();
1535
1547
 
1536
- try log.boost(p1.ident(2), .Rage, 1);
1548
+ try log.boost(.{ p1.ident(2), Boost.Rage, 1 });
1537
1549
  try expectLog1(&.{ N(ArgType.Boost), 0b0010, N(Boost.Rage), 7 }, buf[0..4]);
1538
1550
  stream.reset();
1539
1551
 
1540
- try log.boost(p2.ident(3), .Defense, -2);
1552
+ try log.boost(.{ p2.ident(3), Boost.Defense, -2 });
1541
1553
  try expectLog1(&.{ N(ArgType.Boost), 0b1011, N(Boost.Defense), 4 }, buf[0..4]);
1542
1554
  stream.reset();
1543
1555
  }
1544
1556
 
1545
1557
  test "|-clearallboost|" {
1546
- try log.clearallboost();
1558
+ try log.clearallboost(.{});
1547
1559
  try expectLog1(&.{N(ArgType.ClearAllBoost)}, buf[0..1]);
1548
1560
  stream.reset();
1549
1561
  }
1550
1562
 
1551
1563
  test "|-fail|" {
1552
- try log.fail(p2.ident(6), .None);
1564
+ try log.fail(.{ p2.ident(6), Fail.None });
1553
1565
  try expectLog1(&.{ N(ArgType.Fail), 0b1110, N(Fail.None) }, buf[0..3]);
1554
1566
  stream.reset();
1555
1567
 
1556
- try log.fail(p2.ident(6), .Sleep);
1568
+ try log.fail(.{ p2.ident(6), Fail.Sleep });
1557
1569
  try expectLog1(&.{ N(ArgType.Fail), 0b1110, N(Fail.Sleep) }, buf[0..3]);
1558
1570
  stream.reset();
1559
1571
 
1560
- try log.fail(p2.ident(6), .Substitute);
1572
+ try log.fail(.{ p2.ident(6), Fail.Substitute });
1561
1573
  try expectLog1(&.{ N(ArgType.Fail), 0b1110, N(Fail.Substitute) }, buf[0..3]);
1562
1574
  stream.reset();
1563
1575
 
1564
- try log.fail(p2.ident(6), .Weak);
1576
+ try log.fail(.{ p2.ident(6), Fail.Weak });
1565
1577
  try expectLog1(&.{ N(ArgType.Fail), 0b1110, N(Fail.Weak) }, buf[0..3]);
1566
1578
  stream.reset();
1567
1579
  }
1568
1580
 
1569
1581
  test "|-miss|" {
1570
- try log.miss(p2.ident(4));
1582
+ try log.miss(.{p2.ident(4)});
1571
1583
  try expectLog1(&.{ N(ArgType.Miss), 0b1100 }, buf[0..2]);
1572
1584
  stream.reset();
1573
1585
  }
1574
1586
  test "|-hitcount|" {
1575
- try log.hitcount(p2.ident(1), 5);
1587
+ try log.hitcount(.{ p2.ident(1), 5 });
1576
1588
  try expectLog1(&.{ N(ArgType.HitCount), 0b1001, 5 }, buf[0..3]);
1577
1589
  stream.reset();
1578
1590
  }
1579
1591
 
1580
1592
  test "|-prepare|" {
1581
- try log.prepare(p2.ident(2), M1.Dig);
1593
+ try log.prepare(.{ p2.ident(2), M1.Dig });
1582
1594
  try expectLog1(&.{ N(ArgType.Prepare), 0b1010, N(M1.Dig) }, buf[0..3]);
1583
1595
  stream.reset();
1584
1596
  }
1585
1597
 
1586
1598
  test "|-mustrecharge|" {
1587
- try log.mustrecharge(p1.ident(6));
1599
+ try log.mustrecharge(.{p1.ident(6)});
1588
1600
  try expectLog1(&.{ N(ArgType.MustRecharge), 0b0110 }, buf[0..2]);
1589
1601
  stream.reset();
1590
1602
  }
@@ -1605,10 +1617,16 @@ test "|-activate|" {
1605
1617
  try log.activate(p1.ident(2), .Splash);
1606
1618
  try expectLog1(&.{ N(ArgType.Activate), 0b0010, N(Activate.Splash) }, buf[0..3]);
1607
1619
  stream.reset();
1620
+
1621
+ // TODO activateMove
1622
+
1623
+ try log.magnitude(p1.ident(3), 5);
1624
+ try expectLog1(&.{ N(ArgType.Activate), 0b0011, N(Activate.Magnitude), 5 }, buf[0..4]);
1625
+ stream.reset();
1608
1626
  }
1609
1627
 
1610
1628
  test "|-fieldactivate|" {
1611
- try log.fieldactivate();
1629
+ try log.fieldactivate(.{});
1612
1630
  try expectLog1(&.{N(ArgType.FieldActivate)}, buf[0..1]);
1613
1631
  stream.reset();
1614
1632
  }
@@ -1646,51 +1664,51 @@ test "|-start|" {
1646
1664
  }
1647
1665
 
1648
1666
  test "|-end|" {
1649
- try log.end(p2.ident(6), .Bide);
1667
+ try log.end(.{ p2.ident(6), End.Bide });
1650
1668
  try expectLog1(&.{ N(ArgType.End), 0b1110, N(End.Bide) }, buf[0..3]);
1651
1669
  stream.reset();
1652
1670
 
1653
- try log.end(p1.ident(2), .ConfusionSilent);
1671
+ try log.end(.{ p1.ident(2), End.ConfusionSilent });
1654
1672
  try expectLog1(&.{ N(ArgType.End), 0b0010, N(End.ConfusionSilent) }, buf[0..3]);
1655
1673
  stream.reset();
1656
1674
  }
1657
1675
 
1658
1676
  test "|-ohko|" {
1659
- try log.ohko();
1677
+ try log.ohko(.{});
1660
1678
  try expectLog1(&.{N(ArgType.OHKO)}, buf[0..1]);
1661
1679
  stream.reset();
1662
1680
  }
1663
1681
 
1664
1682
  test "|-crit|" {
1665
- try log.crit(p2.ident(5));
1683
+ try log.crit(.{p2.ident(5)});
1666
1684
  try expectLog1(&.{ N(ArgType.Crit), 0b1101 }, buf[0..2]);
1667
1685
  stream.reset();
1668
1686
  }
1669
1687
 
1670
1688
  test "|-supereffective|" {
1671
- try log.supereffective(p1.ident(1));
1689
+ try log.supereffective(.{p1.ident(1)});
1672
1690
  try expectLog1(&.{ N(ArgType.SuperEffective), 0b0001 }, buf[0..2]);
1673
1691
  stream.reset();
1674
1692
  }
1675
1693
 
1676
1694
  test "|-resisted|" {
1677
- try log.resisted(p2.ident(2));
1695
+ try log.resisted(.{p2.ident(2)});
1678
1696
  try expectLog1(&.{ N(ArgType.Resisted), 0b1010 }, buf[0..2]);
1679
1697
  stream.reset();
1680
1698
  }
1681
1699
 
1682
1700
  test "|-immune|" {
1683
- try log.immune(p1.ident(3), .None);
1701
+ try log.immune(.{ p1.ident(3), Immune.None });
1684
1702
  try expectLog1(&.{ N(ArgType.Immune), 0b0011, N(Immune.None) }, buf[0..3]);
1685
1703
  stream.reset();
1686
1704
 
1687
- try log.immune(p2.ident(2), .OHKO);
1705
+ try log.immune(.{ p2.ident(2), Immune.OHKO });
1688
1706
  try expectLog1(&.{ N(ArgType.Immune), 0b1010, N(Immune.OHKO) }, buf[0..3]);
1689
1707
  stream.reset();
1690
1708
  }
1691
1709
 
1692
1710
  test "|-transform|" {
1693
- try log.transform(p2.ident(4), p1.ident(5));
1711
+ try log.transform(.{ p2.ident(4), p1.ident(5) });
1694
1712
  try expectLog1(&.{ N(ArgType.Transform), 0b1100, 0b0101 }, buf[0..3]);
1695
1713
  stream.reset();
1696
1714
  }
@@ -1701,7 +1719,7 @@ test "|drag|" {
1701
1719
  blissey.hp = 200;
1702
1720
  blissey.stats.hp = 400;
1703
1721
  blissey.status = gen2.Status.init(.PAR);
1704
- try log.drag(p2.ident(3), &blissey);
1722
+ try log.drag(.{ p2.ident(3), &blissey });
1705
1723
  const par = 0b1000000;
1706
1724
  const expected = &(.{
1707
1725
  N(ArgType.Drag),
@@ -1718,23 +1736,23 @@ test "|drag|" {
1718
1736
  }
1719
1737
 
1720
1738
  test "|-item|" {
1721
- try log.item(p2.ident(2), I2.GoldBerry, p1.ident(4));
1739
+ try log.item(.{ p2.ident(2), I2.GoldBerry, p1.ident(4) });
1722
1740
  try expectLog2(&.{ N(ArgType.Item), 0b1010, N(I2.GoldBerry), 0b0100 }, buf[0..4]);
1723
1741
  stream.reset();
1724
1742
  }
1725
1743
 
1726
1744
  test "|-enditem|" {
1727
- try log.enditem(p1.ident(1), I2.BerserkGene, .None);
1745
+ try log.enditem(.{ p1.ident(1), I2.BerserkGene, EndItem.None });
1728
1746
  try expectLog2(&.{ N(ArgType.EndItem), 0b0001, N(I2.BerserkGene), N(EndItem.None) }, buf[0..4]);
1729
1747
  stream.reset();
1730
1748
 
1731
- try log.enditem(p2.ident(4), I2.PRZCureBerry, .Eat);
1749
+ try log.enditem(.{ p2.ident(4), I2.PRZCureBerry, EndItem.Eat });
1732
1750
  try expectLog2(&.{ N(ArgType.EndItem), 0b1100, N(I2.PRZCureBerry), N(EndItem.Eat) }, buf[0..4]);
1733
1751
  stream.reset();
1734
1752
  }
1735
1753
 
1736
1754
  test "|-cureteam|" {
1737
- try log.cureteam(p2.ident(5));
1755
+ try log.cureteam(.{p2.ident(5)});
1738
1756
  try expectLog2(&.{ N(ArgType.CureTeam), 0b1101 }, buf[0..2]);
1739
1757
  stream.reset();
1740
1758
  }
@@ -1742,7 +1760,7 @@ test "|-cureteam|" {
1742
1760
  test "|-sethp|" {
1743
1761
  var blissey = gen2.helpers.Pokemon.init(.{ .species = .Blissey, .moves = &.{.PainSplit} });
1744
1762
  blissey.hp = 612;
1745
- try log.sethp(p2.ident(2), &blissey, .Silent);
1763
+ try log.sethp(.{ p2.ident(2), &blissey, SetHP.Silent });
1746
1764
  var expected: []const u8 = switch (endian) {
1747
1765
  .Big => &.{ N(ArgType.SetHP), 0b1010, 2, 100, 2, 201, 0, N(SetHP.Silent) },
1748
1766
  .Little => &.{ N(ArgType.SetHP), 0b1010, 100, 2, 201, 2, 0, N(SetHP.Silent) },
@@ -1752,61 +1770,60 @@ test "|-sethp|" {
1752
1770
  }
1753
1771
 
1754
1772
  test "|-setboost|" {
1755
- try log.setboost(p2.ident(6), 6);
1773
+ try log.setboost(.{ p2.ident(6), 6 });
1756
1774
  try expectLog2(&.{ N(ArgType.SetBoost), 0b1110, 12 }, buf[0..3]);
1757
1775
  stream.reset();
1758
1776
 
1759
- try log.setboost(p2.ident(3), 2);
1777
+ try log.setboost(.{ p2.ident(3), 2 });
1760
1778
  try expectLog2(&.{ N(ArgType.SetBoost), 0b1011, 8 }, buf[0..3]);
1761
1779
  stream.reset();
1762
1780
  }
1763
1781
 
1764
1782
  test "|-copyboost|" {
1765
- try log.copyboost(p2.ident(3), p1.ident(6));
1783
+ try log.copyboost(.{ p2.ident(3), p1.ident(6) });
1766
1784
  try expectLog2(&.{ N(ArgType.CopyBoost), 0b1011, 0b0110 }, buf[0..3]);
1767
1785
  stream.reset();
1768
1786
  }
1769
1787
 
1770
1788
  test "|-sidestart|" {
1771
- try log.sidestart(.P2, .Reflect);
1789
+ try log.sidestart(.{ Player.P2, Side.Reflect });
1772
1790
  try expectLog2(&.{ N(ArgType.SideStart), 1, N(Side.Reflect) }, buf[0..3]);
1773
1791
  stream.reset();
1774
1792
  }
1775
1793
 
1776
1794
  test "|-sideend|" {
1777
- try log.sideend(.P2, .LightScreen);
1795
+ try log.sideend(.{ Player.P2, Side.LightScreen });
1778
1796
  try expectLog2(&.{ N(ArgType.SideEnd), 1, N(Side.LightScreen) }, buf[0..3]);
1779
1797
  stream.reset();
1780
1798
 
1781
- try log.spikesend(.P1, M2.RapidSpin, p1.ident(3));
1799
+ try log.sideend(.{ Player.P1, Side.Spikes, p1.ident(3) });
1782
1800
  try expectLog2(&.{
1783
1801
  N(ArgType.SideEnd),
1784
1802
  0,
1785
1803
  N(Side.Spikes),
1786
- N(M2.RapidSpin),
1787
1804
  0b0011,
1788
- }, buf[0..5]);
1805
+ }, buf[0..4]);
1789
1806
  stream.reset();
1790
1807
  }
1791
1808
 
1792
1809
  test "|-singlemove|" {
1793
- try log.singlemove(p2.ident(2), M2.DestinyBond);
1810
+ try log.singlemove(.{ p2.ident(2), M2.DestinyBond });
1794
1811
  try expectLog2(&.{ N(ArgType.SingleMove), 0b1010, N(M2.DestinyBond) }, buf[0..3]);
1795
1812
  stream.reset();
1796
1813
  }
1797
1814
 
1798
1815
  test "|-singleturn|" {
1799
- try log.singleturn(p1.ident(3), M2.Protect);
1816
+ try log.singleturn(.{ p1.ident(3), M2.Protect });
1800
1817
  try expectLog2(&.{ N(ArgType.SingleTurn), 0b0011, N(M2.Protect) }, buf[0..3]);
1801
1818
  stream.reset();
1802
1819
  }
1803
1820
 
1804
1821
  test "|-weather|" {
1805
- try log.weather(W2.Rain, .Upkeep);
1822
+ try log.weather(.{ W2.Rain, Weather.Upkeep });
1806
1823
  try expectLog2(&.{ N(ArgType.Weather), N(W2.Rain), N(Weather.Upkeep) }, buf[0..3]);
1807
1824
  stream.reset();
1808
1825
 
1809
- try log.weather(W2.None, .None);
1826
+ try log.weather(.{ W2.None, Weather.None });
1810
1827
  try expectLog2(&.{ N(ArgType.Weather), N(W2.None), N(Weather.None) }, buf[0..3]);
1811
1828
  stream.reset();
1812
1829
  }