@pkmn/engine 0.1.0-dev.fb5bf955 → 0.1.0-dev.fc150752
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 +71 -60
- package/build/pkg/addon.d.ts +2 -2
- package/build/pkg/addon.js +8 -7
- package/build/pkg/addon.js.map +1 -1
- package/build/pkg/data/layout.json +25 -3
- package/build/pkg/gen1.d.ts +5 -4
- package/build/pkg/gen1.js +47 -31
- 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 +95 -76
- package/package.json +26 -16
- package/src/bin/install-pkmn-engine +11 -6
- package/src/bin/pkmn-debug +29 -6
- package/src/lib/binding/node.zig +46 -141
- package/src/lib/binding/wasm.zig +6 -4
- package/src/lib/common/battle.zig +17 -0
- package/src/lib/common/data.zig +14 -26
- package/src/lib/common/debug.zig +21 -11
- package/src/lib/common/js.zig +118 -0
- package/src/lib/common/optional.zig +60 -0
- package/src/lib/common/options.zig +12 -3
- package/src/lib/common/protocol.zig +315 -197
- package/src/lib/common/rational.zig +353 -0
- package/src/lib/common/rng.zig +11 -11
- package/src/lib/common/util.zig +12 -0
- package/src/lib/gen1/README.md +265 -155
- package/src/lib/gen1/calc.zig +426 -0
- package/src/lib/gen1/chance.zig +1036 -0
- package/src/lib/gen1/data/moves.zig +178 -180
- package/src/lib/gen1/data/species.zig +2 -2
- package/src/lib/gen1/data/types.zig +3 -3
- package/src/lib/gen1/data.zig +73 -59
- package/src/lib/gen1/helpers.zig +592 -32
- package/src/lib/gen1/mechanics.zig +994 -641
- package/src/lib/gen2/README.md +87 -13
- package/src/lib/gen2/data/items.zig +3 -3
- package/src/lib/gen2/data/moves.zig +635 -563
- package/src/lib/gen2/data/species.zig +1 -1
- package/src/lib/gen2/data/types.zig +3 -3
- package/src/lib/gen2/data.zig +104 -74
- package/src/lib/gen2/helpers.zig +16 -22
- package/src/lib/gen2/mechanics.zig +916 -11
- package/src/lib/pkmn.zig +68 -9
package/src/lib/pkmn.zig
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
///
|
|
1
|
+
/// Configured Options for the pkmn package.
|
|
2
2
|
pub const options = @import("common/options.zig");
|
|
3
3
|
/// Configures the behavior of the pkmn package.
|
|
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,14 +41,73 @@ 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
|
|
|
49
|
-
|
|
49
|
+
pub usingnamespace @import("common/rational.zig");
|
|
50
|
+
|
|
51
|
+
/// Namespace for cross-generation battle-related types.
|
|
52
|
+
pub const battle = @import("common/battle.zig");
|
|
53
|
+
|
|
54
|
+
/// Namespace for Generation I Pokémon.
|
|
50
55
|
pub const gen1 = struct {
|
|
51
56
|
pub usingnamespace @import("gen1/data.zig");
|
|
57
|
+
/// Tracks chance actions and their associated probability during a
|
|
58
|
+
/// Generation I battle update when `options.chance` is enabled.
|
|
59
|
+
pub const Chance = @import("gen1/chance.zig").Chance;
|
|
60
|
+
/// Namespace for types associated with tracking Generation I Pokémon chance outcomes.
|
|
61
|
+
pub const chance = struct {
|
|
62
|
+
/// Actions taken by a hypothetical "chance player" that convey
|
|
63
|
+
/// information about which RNG events were observed during a Generation
|
|
64
|
+
/// I battle `update`. This can additionally be provided as input to the
|
|
65
|
+
/// `update` call via the `Calc` when `options.calc` is enabled to
|
|
66
|
+
/// override the normal behavior of the RNG in order to force specific
|
|
67
|
+
/// outcomes.
|
|
68
|
+
pub const Actions = @import("gen1/chance.zig").Actions;
|
|
69
|
+
/// Information about the RNG that was observed during a Generation I
|
|
70
|
+
/// battle `update` for a single player.
|
|
71
|
+
pub const Action = @import("gen1/chance.zig").Action;
|
|
72
|
+
/// TODO
|
|
73
|
+
pub const Durations = @import("gen1/chance.zig").Durations;
|
|
74
|
+
/// TODO
|
|
75
|
+
pub const Duration = @import("gen1/chance.zig").Duration;
|
|
76
|
+
/// Null object pattern implementation of Generation I `Chance` which
|
|
77
|
+
/// does nothing, though chance tracking should additionally be turned
|
|
78
|
+
/// off entirely via `options.chance`.
|
|
79
|
+
pub const NULL = @import("gen1/chance.zig").NULL;
|
|
80
|
+
};
|
|
81
|
+
/// Allows for forcing the value of specific RNG events during a Generation I battle `update`
|
|
82
|
+
/// via `overrides` and tracks `summaries` of information relevant to damage calculation.
|
|
83
|
+
pub const Calc = @import("gen1/calc.zig").Calc;
|
|
84
|
+
/// Namespace for types associated with supported Generation I Pokémon damage calc features.
|
|
85
|
+
pub const calc = if (options.internal) struct {
|
|
86
|
+
pub usingnamespace @import("gen1/calc.zig");
|
|
87
|
+
} else struct {
|
|
88
|
+
/// TODO
|
|
89
|
+
pub const Overrides = @import("gen1/calc.zig").Overrides;
|
|
90
|
+
/// Information relevant to damage calculation that occured during a Generation I
|
|
91
|
+
/// battle `update`.
|
|
92
|
+
pub const Summaries = @import("gen1/calc.zig").Summaries;
|
|
93
|
+
/// Information relevant to damage calculation that occured during a Generation I
|
|
94
|
+
/// battle `update` for a single player.
|
|
95
|
+
pub const Summary = @import("gen1/calc.zig").Summary;
|
|
96
|
+
/// Null object pattern implementation of Generation I `Calc` which does nothing,
|
|
97
|
+
/// though damage calculator support should additionally be turned off
|
|
98
|
+
/// entirely via `options.calc`.
|
|
99
|
+
pub const NULL = @import("gen1/calc.zig").NULL;
|
|
100
|
+
};
|
|
52
101
|
/// Provides helpers for initializing Generation I Pokémon battles.
|
|
53
102
|
pub const helpers = @import("gen1/helpers.zig");
|
|
54
103
|
};
|
|
104
|
+
|
|
105
|
+
// Internal APIs used by other pkmn libraries, not actually part of the public API.
|
|
106
|
+
// NOTE: `pub usingnamespace struct { ... }` here results in a (false?) dependency loop
|
|
107
|
+
pub const js = if (options.internal) struct {
|
|
108
|
+
pub usingnamespace @import("common/js.zig");
|
|
109
|
+
} else struct {};
|
|
110
|
+
pub const bindings = if (options.internal) struct {
|
|
111
|
+
pub const node = @import("binding/node.zig");
|
|
112
|
+
pub const wasm = @import("binding/wasm.zig");
|
|
113
|
+
} else struct {};
|