@pkmn/engine 0.1.0-dev.d716e940 → 0.1.0-dev.fb5bf955
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/data/layout.json +1 -1
- package/build/pkg/gen1.d.ts +4 -5
- package/build/pkg/gen1.js +24 -43
- package/build/pkg/gen1.js.map +1 -1
- package/build/pkg/index.d.ts +12 -15
- package/build/pkg/index.js.map +1 -1
- package/build/pkg/protocol.d.ts +2 -4
- package/build/pkg/protocol.js +2 -4
- package/build/pkg/protocol.js.map +1 -1
- package/build/test/display.js +13 -31
- package/build/test/display.js.map +1 -1
- package/build.zig +22 -17
- package/package.json +9 -10
- package/src/bin/install-pkmn-engine +3 -3
- package/src/bin/pkmn-debug +6 -29
- 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 +71 -99
- package/src/lib/gen1/data.zig +17 -19
- package/src/lib/gen1/helpers.zig +14 -3
- package/src/lib/gen1/mechanics.zig +304 -378
- 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_OPTIONS: 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 OPTIONS_SIZE = if (builtin.mode == .ReleaseSmall)
|
|
26
|
+
MAX_OPTIONS
|
|
27
27
|
else
|
|
28
|
-
std.math.ceilPowerOfTwo(usize,
|
|
28
|
+
std.math.ceilPowerOfTwo(usize, MAX_OPTIONS) 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_OPTIONS = gen1.MAX_OPTIONS;
|
|
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_OPTIONS`.
|
|
10
|
+
pub const OPTIONS_SIZE = gen1.OPTIONS_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 trace 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.trace` 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
|
-
///
|
|
44
|
+
/// `std.io.null_writer`. Ignores anything sent to it, though trace logging
|
|
45
|
+
/// should addtionally be turned off entirely by using `options.trace`.
|
|
46
46
|
pub const NULL = @import("common/protocol.zig").NULL;
|
|
47
47
|
};
|
|
48
48
|
|