@pkmn/engine 0.1.0-dev.cf6f5d2c → 0.1.0-dev.d4119c62

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.
Files changed (55) hide show
  1. package/README.md +58 -47
  2. package/build/pkg/addon.js +3 -2
  3. package/build/pkg/addon.js.map +1 -1
  4. package/build/pkg/data/ids.json +12 -12
  5. package/build/pkg/data/layout.json +27 -5
  6. package/build/pkg/data/protocol.json +69 -12
  7. package/build/pkg/data.d.ts +2 -2
  8. package/build/pkg/gen1.d.ts +2 -1
  9. package/build/pkg/gen1.js +38 -20
  10. package/build/pkg/gen1.js.map +1 -1
  11. package/build/pkg/index.d.ts +6 -3
  12. package/build/pkg/index.js.map +1 -1
  13. package/build/pkg/protocol.d.ts +4 -2
  14. package/build/pkg/protocol.js +61 -40
  15. package/build/pkg/protocol.js.map +1 -1
  16. package/build/test/display.js +7 -3
  17. package/build/test/display.js.map +1 -1
  18. package/build/tools/debug.js +3 -1
  19. package/build/tools/debug.js.map +1 -1
  20. package/build.zig +122 -81
  21. package/package.json +43 -21
  22. package/src/bin/install-pkmn-engine +10 -5
  23. package/src/lib/binding/node.zig +46 -141
  24. package/src/lib/binding/wasm.zig +4 -2
  25. package/src/lib/common/battle.zig +17 -0
  26. package/src/lib/common/data.zig +19 -31
  27. package/src/lib/common/debug.zig +20 -11
  28. package/src/lib/common/js.zig +118 -0
  29. package/src/lib/common/optional.zig +67 -0
  30. package/src/lib/common/options.zig +9 -0
  31. package/src/lib/common/protocol.zig +894 -350
  32. package/src/lib/common/rational.zig +353 -0
  33. package/src/lib/common/rng.zig +24 -15
  34. package/src/lib/common/util.zig +12 -0
  35. package/src/lib/gen1/README.md +269 -179
  36. package/src/lib/gen1/calc.zig +426 -0
  37. package/src/lib/gen1/chance.zig +1060 -0
  38. package/src/lib/gen1/data/moves.zig +202 -190
  39. package/src/lib/gen1/data/species.zig +4 -4
  40. package/src/lib/gen1/data/types.zig +10 -10
  41. package/src/lib/gen1/data.zig +85 -71
  42. package/src/lib/gen1/helpers.zig +577 -35
  43. package/src/lib/gen1/mechanics.zig +962 -696
  44. package/src/lib/gen2/README.md +105 -85
  45. package/src/lib/gen2/calc.zig +143 -0
  46. package/src/lib/gen2/chance.zig +1314 -0
  47. package/src/lib/gen2/data/items.zig +14 -20
  48. package/src/lib/gen2/data/moves.zig +664 -570
  49. package/src/lib/gen2/data/species.zig +2 -2
  50. package/src/lib/gen2/data/types.zig +137 -34
  51. package/src/lib/gen2/data.zig +124 -86
  52. package/src/lib/gen2/generated.zig +808 -0
  53. package/src/lib/gen2/helpers.zig +16 -22
  54. package/src/lib/gen2/mechanics.zig +3510 -12
  55. package/src/lib/pkmn.zig +61 -2
package/src/lib/pkmn.zig CHANGED
@@ -1,4 +1,4 @@
1
- /// Configurated Options for the pkmn package.
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;
@@ -46,9 +46,68 @@ pub const protocol = if (options.internal) struct {
46
46
  pub const NULL = @import("common/protocol.zig").NULL;
47
47
  };
48
48
 
49
- /// Namespace for Generation I Pokémon
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 {};