@pkmn/engine 0.1.0-dev.9a0c07c3 → 0.1.0-dev.af1565df
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 +7 -0
- package/build/pkg/addon.js +111 -0
- package/build/pkg/addon.js.map +1 -0
- package/build/pkg/data/layout.json +1 -1
- package/build/pkg/gen1.d.ts +5 -4
- package/build/pkg/gen1.js +43 -24
- package/build/pkg/gen1.js.map +1 -1
- package/build/pkg/index.d.ts +15 -12
- package/build/pkg/index.js.map +1 -1
- package/build/pkg/protocol.d.ts +4 -2
- package/build/pkg/protocol.js +4 -2
- package/build/pkg/protocol.js.map +1 -1
- package/build/test/display.js +31 -13
- package/build/test/display.js.map +1 -1
- package/build.zig +17 -22
- package/package.json +13 -9
- package/src/bin/install-pkmn-engine +3 -3
- package/src/bin/pkmn-debug +34 -7
- package/src/lib/binding/node.zig +5 -5
- package/src/lib/binding/wasm.zig +3 -3
- package/src/lib/common/debug.zig +1 -0
- package/src/lib/common/options.zig +3 -3
- package/src/lib/common/protocol.zig +38 -38
- package/src/lib/gen1/README.md +99 -71
- package/src/lib/gen1/data.zig +19 -17
- package/src/lib/gen1/helpers.zig +4 -15
- package/src/lib/gen1/mechanics.zig +378 -304
- package/src/lib/gen2/data.zig +4 -4
- package/src/lib/pkmn.zig +7 -7
package/src/lib/gen2/data.zig
CHANGED
|
@@ -19,13 +19,13 @@ const assert = std.debug.assert;
|
|
|
19
19
|
const expectEqual = std.testing.expectEqual;
|
|
20
20
|
const expect = std.testing.expect;
|
|
21
21
|
|
|
22
|
-
pub const
|
|
22
|
+
pub const MAX_CHOICES: usize = 9; // move 1..4, switch 2..6
|
|
23
23
|
pub const MAX_LOGS: usize = 180; // TODO
|
|
24
24
|
|
|
25
|
-
pub const
|
|
26
|
-
|
|
25
|
+
pub const CHOICES_SIZE = if (builtin.mode == .ReleaseSmall)
|
|
26
|
+
MAX_CHOICES
|
|
27
27
|
else
|
|
28
|
-
std.math.ceilPowerOfTwo(usize,
|
|
28
|
+
std.math.ceilPowerOfTwo(usize, MAX_CHOICES) catch unreachable;
|
|
29
29
|
pub const LOGS_SIZE = if (builtin.mode == .ReleaseSmall)
|
|
30
30
|
MAX_LOGS
|
|
31
31
|
else
|
package/src/lib/pkmn.zig
CHANGED
|
@@ -4,10 +4,10 @@ pub const options = @import("common/options.zig");
|
|
|
4
4
|
pub const Options = options.Options;
|
|
5
5
|
|
|
6
6
|
/// The minimum size in bytes required to hold all choice options.
|
|
7
|
-
pub const
|
|
7
|
+
pub const MAX_CHOICES = gen1.MAX_CHOICES;
|
|
8
8
|
/// The optimal size in bytes required to hold all choice options.
|
|
9
|
-
/// At least as large as `
|
|
10
|
-
pub const
|
|
9
|
+
/// At least as large as `MAX_CHOICES`.
|
|
10
|
+
pub const CHOICES_SIZE = gen1.CHOICES_SIZE;
|
|
11
11
|
/// The maximum number of bytes possibly logged by a single update.
|
|
12
12
|
pub const MAX_LOGS = gen1.MAX_LOGS;
|
|
13
13
|
/// The optimal size in bytes required to hold the largest amount of log data
|
|
@@ -25,12 +25,12 @@ pub const Result = @import("common/data.zig").Result;
|
|
|
25
25
|
/// Pokémon Showdown's RNG (backed by a Generation V & VI RNG).
|
|
26
26
|
pub const PSRNG = @import("common/rng.zig").PSRNG;
|
|
27
27
|
|
|
28
|
-
/// Namespace for helpers related to protocol
|
|
28
|
+
/// Namespace for helpers related to protocol message logging.
|
|
29
29
|
pub const protocol = if (options.internal) struct {
|
|
30
30
|
pub usingnamespace @import("common/protocol.zig");
|
|
31
31
|
} else struct {
|
|
32
32
|
/// Logs protocol information to its `Writer` during a battle update when
|
|
33
|
-
/// `options.
|
|
33
|
+
/// `options.log` is enabled.
|
|
34
34
|
pub const Log = @import("common/protocol.zig").Log;
|
|
35
35
|
/// Stripped down version of `std.io.FixedBufferStream` optimized for
|
|
36
36
|
/// efficiently writing the individual protocol bytes. Note that the
|
|
@@ -41,8 +41,8 @@ pub const protocol = if (options.internal) struct {
|
|
|
41
41
|
/// intialized with a `LOGS_SIZE`-sized buffer.
|
|
42
42
|
pub const FixedLog = @import("common/protocol.zig").FixedLog;
|
|
43
43
|
/// Null object pattern implementation of `Log` backed by a
|
|
44
|
-
/// `std.io.null_writer`. Ignores anything sent to it, though
|
|
45
|
-
/// should
|
|
44
|
+
/// `std.io.null_writer`. Ignores anything sent to it, though protocol
|
|
45
|
+
/// logging should additionally be turned off entirely with `options.log`.
|
|
46
46
|
pub const NULL = @import("common/protocol.zig").NULL;
|
|
47
47
|
};
|
|
48
48
|
|