@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.
- package/README.md +22 -22
- package/build/pkg/addon.d.ts +2 -2
- package/build/pkg/addon.js +5 -5
- package/build/pkg/addon.js.map +1 -1
- package/build/pkg/gen1.d.ts +3 -3
- package/build/pkg/gen1.js +13 -11
- package/build/pkg/gen1.js.map +1 -1
- package/build/pkg/index.d.ts +10 -11
- package/build/pkg/index.js.map +1 -1
- package/build/test/display.js +1 -2
- package/build/test/display.js.map +1 -1
- package/build.zig +22 -15
- package/package.json +9 -10
- package/src/bin/install-pkmn-engine +3 -3
- package/src/lib/binding/node.zig +5 -5
- package/src/lib/binding/wasm.zig +3 -3
- package/src/lib/common/debug.zig +0 -1
- package/src/lib/common/options.zig +3 -3
- package/src/lib/common/protocol.zig +38 -38
- package/src/lib/gen1/README.md +11 -13
- package/src/lib/gen1/data.zig +8 -7
- package/src/lib/gen1/helpers.zig +7 -10
- package/src/lib/gen1/mechanics.zig +2341 -2312
- package/src/lib/gen2/data.zig +4 -4
- package/src/lib/pkmn.zig +7 -7
package/src/lib/gen1/data.zig
CHANGED
|
@@ -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
|
|
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
|
|
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
|
|
27
|
-
|
|
26
|
+
pub const OPTIONS_SIZE = if (builtin.mode == .ReleaseSmall)
|
|
27
|
+
MAX_OPTIONS
|
|
28
28
|
else
|
|
29
|
-
std.math.ceilPowerOfTwo(usize,
|
|
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
|
|
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
|
-
|
|
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`
|
package/src/lib/gen1/helpers.zig
CHANGED
|
@@ -211,19 +211,16 @@ pub const Pokemon = struct {
|
|
|
211
211
|
}
|
|
212
212
|
};
|
|
213
213
|
|
|
214
|
-
//
|
|
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,
|
|
218
|
+
.Counter,
|
|
219
|
+
.Mimic,
|
|
220
|
+
.Metronome,
|
|
221
|
+
.MirrorMove,
|
|
222
|
+
.Transform,
|
|
223
|
+
=> true,
|
|
227
224
|
else => false,
|
|
228
225
|
};
|
|
229
226
|
}
|