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

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.
@@ -17,16 +17,16 @@ const expectEqual = std.testing.expectEqual;
17
17
  const expect = std.testing.expect;
18
18
 
19
19
  /// The minimum size in bytes required to hold all Generation I choice options.
20
- pub const MAX_CHOICES: usize = 9; // move 1..4, switch 2..6
20
+ pub const MAX_OPTIONS: usize = 9; // move 1..4, switch 2..6
21
21
  /// The optimal size in bytes required to hold all Generation I choice options.
22
- /// At least as large as MAX_CHOICES.
22
+ /// At least as large as MAX_OPTIONS.
23
23
  pub const MAX_LOGS: usize = 180;
24
24
 
25
25
  /// The maximum number of bytes possibly logged by a single Generation I update.
26
- pub const CHOICES_SIZE = if (builtin.mode == .ReleaseSmall)
27
- MAX_CHOICES
26
+ pub const OPTIONS_SIZE = if (builtin.mode == .ReleaseSmall)
27
+ MAX_OPTIONS
28
28
  else
29
- std.math.ceilPowerOfTwo(usize, MAX_CHOICES) catch unreachable;
29
+ std.math.ceilPowerOfTwo(usize, MAX_OPTIONS) catch unreachable;
30
30
  /// The optimal size in bytes required to hold the largest amount of log data possible from a
31
31
  /// single Generation I update. At least as large as MAX_LOGS.
32
32
  pub const LOGS_SIZE = if (builtin.mode == .ReleaseSmall)
@@ -76,9 +76,10 @@ pub fn Battle(comptime RNG: anytype) type {
76
76
  }
77
77
 
78
78
  /// Returns the result of applying Player 1's choice `c1` and Player 2's choice `c2` to the
79
- /// battle, optionally writing protocol message logs to `log` if `options.log` is enabled.
79
+ /// battle, optionally writing protocol logs to `log` if `options.trace` is enabled.
80
80
  pub fn update(self: *Self, c1: Choice, c2: Choice, log: anytype) !Result {
81
- return mechanics.update(self, c1, c2, log);
81
+ const m = mechanics.Mechanics(*Self, @TypeOf(log)){ .battle = self, .log = log };
82
+ return m.update(c1, c2);
82
83
  }
83
84
 
84
85
  /// Fills in at most `out.len` possible choices for the `player` given the previous `result`
@@ -211,19 +211,16 @@ pub const Pokemon = struct {
211
211
  }
212
212
  };
213
213
 
214
- // TODO: uncomment once integration tests pass
215
- // fn blocked(m: Move) bool {
216
- // // Binding moves are borked but only via Mirror Move / Metronome which are already blocked
217
- // return switch (m) {
218
- // .Mimic, .Metronome, .MirrorMove => true,
219
- // else => false,
220
- // };
221
- // }
222
-
214
+ // cat src/test/showdown/blocklist.json | jq '."1".moves'
223
215
  fn blocked(m: Move) bool {
224
216
  if (Move.get(m).effect == .Binding) return true;
225
217
  return switch (m) {
226
- .Counter, .Mimic, .Metronome, .MirrorMove, .Transform => true,
218
+ .Counter,
219
+ .Mimic,
220
+ .Metronome,
221
+ .MirrorMove,
222
+ .Transform,
223
+ => true,
227
224
  else => false,
228
225
  };
229
226
  }