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

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 (60) hide show
  1. package/LICENSE +1 -3
  2. package/README.md +95 -59
  3. package/build/pkg/addon.js +9 -9
  4. package/build/pkg/addon.js.map +1 -1
  5. package/build/pkg/data/ids.json +12 -12
  6. package/build/pkg/data/layout.json +27 -5
  7. package/build/pkg/data/protocol.json +69 -12
  8. package/build/pkg/data.d.ts +4 -4
  9. package/build/pkg/data.js.map +1 -1
  10. package/build/pkg/gen1.d.ts +2 -1
  11. package/build/pkg/gen1.js +38 -20
  12. package/build/pkg/gen1.js.map +1 -1
  13. package/build/pkg/index.d.ts +7 -4
  14. package/build/pkg/index.js.map +1 -1
  15. package/build/pkg/protocol.d.ts +4 -2
  16. package/build/pkg/protocol.js +65 -44
  17. package/build/pkg/protocol.js.map +1 -1
  18. package/build/test/display.js +15 -6
  19. package/build/test/display.js.map +1 -1
  20. package/build/tools/debug.js +5 -4
  21. package/build/tools/debug.js.map +1 -1
  22. package/build.zig +148 -126
  23. package/package.json +53 -24
  24. package/src/bin/install-pkmn-engine +35 -22
  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 +22 -13
  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 +11 -0
  31. package/src/lib/common/protocol.zig +906 -367
  32. package/src/lib/common/rational.zig +454 -0
  33. package/src/lib/common/rng.zig +35 -26
  34. package/src/lib/common/util.zig +12 -0
  35. package/src/lib/gen1/calc.zig +802 -0
  36. package/src/lib/gen1/chance.zig +1159 -0
  37. package/src/lib/gen1/data/moves.zig +202 -190
  38. package/src/lib/gen1/data/species.zig +5 -5
  39. package/src/lib/gen1/data/types.zig +10 -10
  40. package/src/lib/gen1/data.zig +104 -90
  41. package/src/lib/gen1/helpers.zig +140 -42
  42. package/src/lib/gen1/mechanics.zig +1135 -773
  43. package/src/lib/gen2/calc.zig +135 -0
  44. package/src/lib/gen2/chance.zig +895 -0
  45. package/src/lib/gen2/data/items.zig +14 -20
  46. package/src/lib/gen2/data/moves.zig +664 -570
  47. package/src/lib/gen2/data/species.zig +2 -2
  48. package/src/lib/gen2/data/types.zig +137 -34
  49. package/src/lib/gen2/data.zig +130 -92
  50. package/src/lib/gen2/generated.zig +806 -0
  51. package/src/lib/gen2/helpers.zig +50 -26
  52. package/src/lib/gen2/mechanics.zig +3568 -12
  53. package/src/lib/node.zig +131 -0
  54. package/src/lib/pkmn.zig +81 -5
  55. package/src/lib/wasm.zig +13 -0
  56. package/src/test/display/pkmn.html.tmpl +5 -5
  57. package/src/lib/binding/node.zig +0 -229
  58. package/src/lib/binding/wasm.zig +0 -10
  59. package/src/lib/gen1/README.md +0 -804
  60. package/src/lib/gen2/README.md +0 -309
@@ -10,7 +10,7 @@ const path = require('path');
10
10
  const {pipeline} = require('stream/promises');
11
11
  const tty = require('tty');
12
12
 
13
- const ZIG_VERSION = {major: 0, minor: 11, patch: 0, dev: 2750};
13
+ const ZIG_VERSION = {major: 0, minor: 13, patch: 0};
14
14
  const DEV = ZIG_VERSION.dev ? `-dev.${ZIG_VERSION.dev}` : '';
15
15
  const VERSION = `${ZIG_VERSION.major}.${ZIG_VERSION.minor}.${ZIG_VERSION.patch}${DEV}`;
16
16
  const INDEX = 'https://ziglang.org/download/index.json';
@@ -283,19 +283,19 @@ const downloadImportLib = async () => {
283
283
  let error = false;
284
284
  for (let i = 2; i < process.argv.length; i++) {
285
285
  switch (process.argv[i]) {
286
- case "--silent": {
287
- SILENT = true;
288
- break;
289
- }
290
- case "--zig": {
291
- if (options || only) error = true;
292
- only = true;
293
- break;
294
- }
295
- default: {
296
- if (options || only || !process.argv[i].startsWith('--options=')) error = true;
297
- options = process.argv[i].slice(10).split(' ');
298
- }
286
+ case "--silent": {
287
+ SILENT = true;
288
+ break;
289
+ }
290
+ case "--zig": {
291
+ if (options || only) error = true;
292
+ only = true;
293
+ break;
294
+ }
295
+ default: {
296
+ if (options || only || !process.argv[i].startsWith('--options=')) error = true;
297
+ options = process.argv[i].slice(10).split(' ');
298
+ }
299
299
  }
300
300
  }
301
301
  if (error) {
@@ -336,14 +336,18 @@ const downloadImportLib = async () => {
336
336
  node = true;
337
337
  if (!options) {
338
338
  const addon = require(copy);
339
- if (addon.options.showdown) opts.push('-Dshowdown');
340
- if (addon.options.log) opts.push('-Dlog');
339
+ if (addon.engine.options.showdown) opts.push('-Dshowdown');
340
+ if (addon.engine.options.log) opts.push('-Dlog');
341
+ if (addon.engine.options.chance) opts.push('-Dchance');
342
+ if (addon.engine.options.calc) opts.push('-Dcalc');
341
343
  }
342
344
  } else if (!options) {
343
345
  const addon = await WebAssembly.instantiate(fs.readFileSync(copy));
344
346
  const values = new Uint8Array(addon.instance.exports.memory.buffer);
345
347
  if (values[addon.instance.exports.SHOWDOWN.value]) opts.push('-Dshowdown');
346
348
  if (values[addon.instance.exports.LOG.value]) opts.push('-Dlog');
349
+ if (values[addon.instance.exports.CHANCE.value]) opts.push('-Dchance');
350
+ if (values[addon.instance.exports.CALC.value]) opts.push('-Dcalc');
347
351
  }
348
352
  const key = `${type} ${opts.sort().join(' ')}`;
349
353
  if (!configs.has(key)) configs.set(key, {type, options: opts});
@@ -354,8 +358,9 @@ const downloadImportLib = async () => {
354
358
  // either the default options or whatever was passed in
355
359
  if (!configs.size) {
356
360
  node = true;
357
- configs.set('node', {type: 'node', options: options || ['-Dshowdown']});
358
- configs.set('wasm', {type: 'wasm', options: options || ['-Dshowdown']});
361
+ const DEFAULT = ['-Dshowdown'];
362
+ configs.set('node', {type: 'node', options: options || DEFAULT});
363
+ configs.set('wasm', {type: 'wasm', options: options || DEFAULT});
359
364
  }
360
365
 
361
366
  const headers = node ? await downloadHeaders() : undefined;
@@ -365,8 +370,10 @@ const downloadImportLib = async () => {
365
370
  const args = ['build', '-p', 'build', ...opts];
366
371
  if (!process.env.DEBUG_PKMN_ENGINE) args.push('-Doptimize=ReleaseFast', '-Dstrip');
367
372
  if (config.type === 'node') {
368
- args.push(`-Dnode-headers=${headers}`);
369
- if (process.platform === 'win32') args.push(`-Dnode-import-library=${lib}`);
373
+ args.push(`-Dnode-headers=${path.relative(ROOT, headers)}`);
374
+ if (process.platform === 'win32') {
375
+ args.push(`-Dnode-import-library=${path.relative(ROOT, lib)}`);
376
+ }
370
377
  } else {
371
378
  args.push('-Dwasm');
372
379
  }
@@ -381,8 +388,14 @@ const downloadImportLib = async () => {
381
388
  const prefix = process.platform === 'win32' ? '' : 'lib';
382
389
  const ext = process.platform === 'darwin'
383
390
  ? 'dylib' : process.platform === 'win32' ? 'dll' : 'so';
384
- const actual = path.join('build', 'lib', `${prefix}pkmn${suffix}.node.${ext}`);
385
- fs.renameSync(path.join(ROOT, actual), path.join(ROOT, artifact));
391
+ try {
392
+ const actual = path.join(ROOT, 'build', 'lib', `${prefix}pkmn${suffix}.node.${ext}`);
393
+ fs.renameSync(actual, artifact);
394
+ } catch (err) {
395
+ // ziglang/zig#19743 changed this path
396
+ const actual = path.join(ROOT, 'build', 'bin', `${prefix}pkmn${suffix}.node.${ext}`);
397
+ fs.renameSync(actual, artifact);
398
+ }
386
399
  }
387
400
  }
388
401
  })().catch(e => {
@@ -0,0 +1,17 @@
1
+ /// Stores state required by optional features to the engine that can be passed to a generation's
2
+ /// `Battle.update` function. All generations generically support protocol logging (enabled via
3
+ /// `-Dlog`), chance actions and probability tracking (enabled via `-Dchance`), and damage
4
+ /// computation and chance overrides (`-Dcalc`), though the concrete types for these features are
5
+ /// generation dependent.
6
+ pub fn Options(comptime Log: type, comptime Chance: type, comptime Calc: type) type {
7
+ return struct { log: Log, chance: Chance, calc: Calc };
8
+ }
9
+
10
+ /// Helper to create a battle `Options` object with the provided `log`, `chance`, and `calc`.
11
+ pub fn options(
12
+ log: anytype,
13
+ chance: anytype,
14
+ calc: anytype,
15
+ ) Options(@TypeOf(log), @TypeOf(chance), @TypeOf(calc)) {
16
+ return .{ .log = log, .chance = chance, .calc = calc };
17
+ }
@@ -9,12 +9,12 @@ pub const Player = enum(u1) {
9
9
  P2,
10
10
 
11
11
  /// Returns a player's opponent.
12
- pub inline fn foe(self: Player) Player {
13
- return @intToEnum(Player, ~@enumToInt(self));
12
+ pub fn foe(self: Player) Player {
13
+ return @enumFromInt(~@intFromEnum(self));
14
14
  }
15
15
 
16
16
  /// Return's an identifier for the player's Pokémon at the one-indexed `id`.
17
- pub inline fn ident(self: Player, id: u3) ID {
17
+ pub fn ident(self: Player, id: u3) ID {
18
18
  assert(id > 0 and id <= 6);
19
19
  return .{ .id = id, .player = self };
20
20
  }
@@ -22,42 +22,38 @@ pub const Player = enum(u1) {
22
22
 
23
23
  test Player {
24
24
  try expectEqual(Player.P2, Player.P1.foe());
25
- try expectEqual(@as(u8, 0b0001), @bitCast(u8, Player.P1.ident(1)));
26
- try expectEqual(@as(u8, 0b1101), @bitCast(u8, Player.P2.ident(5)));
25
+ try expectEqual(0b0001, @as(u8, @bitCast(Player.P1.ident(1))));
26
+ try expectEqual(0b1101, @as(u8, @bitCast(Player.P2.ident(5))));
27
27
  }
28
28
 
29
29
  /// An identifier for a specific Pokémon in battle.
30
- pub const ID = packed struct {
30
+ pub const ID = packed struct(u8) {
31
31
  /// The one-indexed team slot of the Pokémon
32
32
  id: u3 = 0,
33
33
  /// The Pokémon's trainer.
34
34
  player: Player = .P1,
35
35
  _: u4 = 0,
36
36
 
37
- comptime {
38
- assert(@sizeOf(ID) == 1);
39
- }
40
-
41
37
  /// Converts the identifier into a number.
42
- pub inline fn int(self: ID) u4 {
43
- return @intCast(u4, @bitCast(u8, self));
38
+ pub fn int(self: ID) u4 {
39
+ return @intCast(@as(u8, @bitCast(self)));
44
40
  }
45
41
 
46
42
  /// Decodes the identifier from a number.
47
- pub inline fn from(id: u4) ID {
48
- return @bitCast(ID, @as(u8, id));
43
+ pub fn from(id: u4) ID {
44
+ return @bitCast(@as(u8, id));
49
45
  }
50
46
  };
51
47
 
52
48
  test ID {
53
- try expectEqual(@as(u8, 0b0001), @bitCast(u8, ID{ .player = .P1, .id = 1 }));
54
- try expectEqual(@as(u8, 0b1101), @bitCast(u8, ID{ .player = .P2, .id = 5 }));
55
- const id = ID{ .player = .P2, .id = 4 };
49
+ try expectEqual(0b0001, @as(u8, @bitCast(ID{ .player = .P1, .id = 1 })));
50
+ try expectEqual(0b1101, @as(u8, @bitCast(ID{ .player = .P2, .id = 5 })));
51
+ const id: ID = .{ .player = .P2, .id = 4 };
56
52
  try expectEqual(id, ID.from(id.int()));
57
53
  }
58
54
 
59
55
  /// A choice made by a player during battle.
60
- pub const Choice = packed struct {
56
+ pub const Choice = packed struct(u8) {
61
57
  /// The choice type.
62
58
  type: Choice.Type = .Pass,
63
59
  /// The choice data:
@@ -73,10 +69,6 @@ pub const Choice = packed struct {
73
69
  Move,
74
70
  Switch,
75
71
  };
76
-
77
- comptime {
78
- assert(@sizeOf(Choice) == 1);
79
- }
80
72
  };
81
73
 
82
74
  test Choice {
@@ -84,12 +76,12 @@ test Choice {
84
76
  const p2: Choice = .{ .type = .Switch, .data = 5 };
85
77
  try expectEqual(5, p2.data);
86
78
  try expectEqual(Choice.Type.Move, p1.type);
87
- try expectEqual(0b0001_0001, @bitCast(u8, p1));
88
- try expectEqual(0b0001_0110, @bitCast(u8, p2));
79
+ try expectEqual(0b0001_0001, @as(u8, @bitCast(p1)));
80
+ try expectEqual(0b0001_0110, @as(u8, @bitCast(p2)));
89
81
  }
90
82
 
91
83
  /// The result of the battle - all results other than 'None' should be considered terminal.
92
- pub const Result = packed struct {
84
+ pub const Result = packed struct(u8) {
93
85
  /// The type of result from the perspective of Player 1.
94
86
  /// `Error` is not possible when in Pokémon Showdown compatibility mode.
95
87
  type: Result.Type = .None,
@@ -117,13 +109,9 @@ pub const Result = packed struct {
117
109
  pub const Error: Result = .{ .type = .Error };
118
110
  /// The default result.
119
111
  pub const Default: Result = .{ .p1 = .Move, .p2 = .Move };
120
-
121
- comptime {
122
- assert(@sizeOf(Result) == 1);
123
- }
124
112
  };
125
113
 
126
114
  test Result {
127
- try expectEqual(0b0101_0000, @bitCast(u8, Result.Default));
128
- try expectEqual(0b1000_0000, @bitCast(u8, Result{ .p2 = .Switch }));
115
+ try expectEqual(0b0101_0000, @as(u8, @bitCast(Result.Default)));
116
+ try expectEqual(0b1000_0000, @as(u8, @bitCast(Result{ .p2 = .Switch })));
129
117
  }
@@ -4,24 +4,33 @@ const debug = std.debug;
4
4
  const io = std.io;
5
5
 
6
6
  pub fn print(value: anytype) void {
7
- debug.getStderrMutex().lock();
8
- defer debug.getStderrMutex().unlock();
7
+ debug.lockStdErr();
8
+ defer debug.unlockStdErr();
9
9
  const stderr = io.getStdErr().writer();
10
10
 
11
11
  nosuspend {
12
12
  stderr.writeAll("\x1b[41m") catch return;
13
- switch (@typeInfo(@TypeOf(value))) {
14
- .Struct => |info| {
15
- if (info.is_tuple) {
16
- inline for (info.fields, 0..) |f, i| {
17
- inspect(@field(value, f.name));
18
- if (i < info.fields.len - 1) stderr.writeAll(" ") catch return;
13
+ if (@TypeOf(@src()) == @TypeOf(value)) {
14
+ stderr.print("{s} ({s}:{d}:{d})", .{
15
+ value.fn_name,
16
+ value.file,
17
+ value.line,
18
+ value.column,
19
+ }) catch return;
20
+ } else {
21
+ switch (@typeInfo(@TypeOf(value))) {
22
+ .Struct => |info| {
23
+ if (info.is_tuple) {
24
+ inline for (info.fields, 0..) |f, i| {
25
+ inspect(@field(value, f.name));
26
+ if (i < info.fields.len - 1) stderr.writeAll(" ") catch return;
27
+ }
28
+ } else {
29
+ inspect(value);
19
30
  }
20
- } else {
21
- inspect(value);
22
- }
23
- },
24
- else => inspect(value),
31
+ },
32
+ else => inspect(value),
33
+ }
25
34
  }
26
35
  stderr.writeAll("\x1b[K\x1b[0m\n") catch return;
27
36
  }
@@ -0,0 +1,118 @@
1
+ const std = @import("std");
2
+
3
+ const assert = std.debug.assert;
4
+
5
+ const c = @cImport({
6
+ @cDefine("NAPI_VERSION", "8");
7
+ @cInclude("node_api.h");
8
+ });
9
+
10
+ pub const Array = struct {
11
+ pub fn init(env: c.napi_env, o: struct { length: ?usize }) c.napi_value {
12
+ var result: c.napi_value = undefined;
13
+ assert(c.napi_ok == if (o.length) |n|
14
+ c.napi_create_array_with_length(env, n, &result)
15
+ else
16
+ c.napi_create_array(env, &result));
17
+ return result;
18
+ }
19
+
20
+ pub fn set(env: c.napi_env, array: c.napi_value, index: u32, value: c.napi_value) void {
21
+ assert(c.napi_set_element(env, array, index, value) == c.napi_ok);
22
+ }
23
+ };
24
+
25
+ pub const Boolean = struct {
26
+ pub fn init(env: c.napi_env, value: bool) c.napi_value {
27
+ var result: c.napi_value = undefined;
28
+ assert(c.napi_get_boolean(env, value, &result) == c.napi_ok);
29
+ return result;
30
+ }
31
+ };
32
+
33
+ pub const Number = struct {
34
+ pub fn init(env: c.napi_env, value: anytype) c.napi_value {
35
+ const T = @TypeOf(value);
36
+ var result: c.napi_value = undefined;
37
+ assert(c.napi_ok == switch (@typeInfo(T)) {
38
+ .Int => |info| switch (info.bits) {
39
+ 0...32 => switch (info.signedness) {
40
+ .signed => c.napi_create_int32(env, @as(i32, value), &result),
41
+ .unsigned => c.napi_create_uint32(env, @as(u32, value), &result),
42
+ },
43
+ 33...52 => c.napi_create_int64(env, @as(i64, value), &result),
44
+ else => @compileError("int can't be represented as JS number"),
45
+ },
46
+ else => @compileError("expected number, got: " ++ @typeName(T)),
47
+ });
48
+ return result;
49
+ }
50
+
51
+ pub fn get(env: c.napi_env, value: c.napi_value, comptime T: type) T {
52
+ switch (@typeInfo(T)) {
53
+ .Int => |info| switch (info.bits) {
54
+ 0...32 => switch (info.signedness) {
55
+ .signed => {
56
+ var result: i32 = undefined;
57
+ assert(c.napi_get_value_int32(env, value, &result) == c.napi_ok);
58
+ return if (info.bits == 32) result else @intCast(result);
59
+ },
60
+ .unsigned => {
61
+ var result: u32 = undefined;
62
+ assert(c.napi_get_value_uint32(env, value, &result) == c.napi_ok);
63
+ return if (info.bits == 32) result else @intCast(result);
64
+ },
65
+ },
66
+ 33...63 => {
67
+ var result: i64 = undefined;
68
+ assert(c.napi_get_value_int64(env, value, &result) == c.napi_ok);
69
+ return @intCast(result);
70
+ },
71
+ else => {
72
+ var result: i64 = undefined;
73
+ assert(c.napi_get_value_int64(env, value, &result) == c.napi_ok);
74
+ return switch (info.signedness) {
75
+ .signed => value,
76
+ .unsigned => if (0 <= value) @intCast(value) else unreachable,
77
+ };
78
+ },
79
+ },
80
+ else => @compileError("expected number, got: " ++ @typeName(T)),
81
+ }
82
+ }
83
+ };
84
+
85
+ pub const Object = struct {
86
+ pub fn init(env: c.napi_env) c.napi_value {
87
+ var result: c.napi_value = undefined;
88
+ assert(c.napi_create_object(env, &result) == c.napi_ok);
89
+ return result;
90
+ }
91
+ };
92
+
93
+ pub const Property = union(enum) {
94
+ method: c.napi_callback,
95
+ value: c.napi_value,
96
+
97
+ pub fn init(comptime name: [:0]const u8, property: Property) c.napi_property_descriptor {
98
+ return .{
99
+ .utf8name = name,
100
+ .name = null,
101
+ .method = switch (property) {
102
+ .method => |m| m,
103
+ .value => null,
104
+ },
105
+ .getter = null,
106
+ .setter = null,
107
+ .value = switch (property) {
108
+ .method => null,
109
+ .value => |v| v,
110
+ },
111
+ .attributes = switch (property) {
112
+ .method => c.napi_default,
113
+ .value => c.napi_enumerable,
114
+ },
115
+ .data = null,
116
+ };
117
+ }
118
+ };
@@ -0,0 +1,67 @@
1
+ const std = @import("std");
2
+
3
+ const expect = std.testing.expect;
4
+ const assert = std.debug.assert;
5
+
6
+ // TODO: ziglang/zig#104
7
+ pub fn Optional(comptime T: type) type {
8
+ const fields = std.meta.fields(switch (@typeInfo(T)) {
9
+ .Bool => enum { false, true },
10
+ else => T,
11
+ });
12
+
13
+ var enumFields: [fields.len + 1]std.builtin.Type.EnumField = undefined;
14
+ var decls = [_]std.builtin.Type.Declaration{};
15
+
16
+ enumFields[0] = .{ .name = "None", .value = 0 };
17
+
18
+ inline for (fields, 1..) |field, i| {
19
+ assert(!std.mem.eql(u8, field.name, "None"));
20
+ enumFields[i] = .{
21
+ .name = field.name,
22
+ .value = i,
23
+ };
24
+ }
25
+
26
+ return @Type(.{
27
+ .Enum = .{
28
+ .tag_type = std.math.IntFittingRange(0, fields.len),
29
+ .fields = &enumFields,
30
+ .decls = &decls,
31
+ .is_exhaustive = true,
32
+ },
33
+ });
34
+ }
35
+
36
+ test Optional {
37
+ try expect(@bitSizeOf(Optional(bool)) == 2);
38
+
39
+ const a: Optional(bool) = .true;
40
+ try expect(a != .None);
41
+ try expect(a == .true);
42
+ try expect(a != .false);
43
+
44
+ const b: Optional(bool) = .None;
45
+ try expect(b == .None);
46
+ try expect(b != .true);
47
+ try expect(b != .false);
48
+
49
+ const Player = @import("data.zig").Player;
50
+ try expect(@bitSizeOf(Optional(Player)) == 2);
51
+
52
+ const p: Optional(Player) = .P2;
53
+ try expect(p != .None);
54
+ try expect(p != .P1);
55
+ try expect(p == .P2);
56
+
57
+ const q: Optional(Player) = .None;
58
+ try expect(q == .None);
59
+ try expect(q != .P1);
60
+ try expect(q != .P2);
61
+
62
+ const Three = enum(u2) { A, B, C };
63
+ try expect(@bitSizeOf(Optional(Three)) == 2);
64
+
65
+ const Four = enum(u2) { A, B, C, D };
66
+ try expect(@bitSizeOf(Optional(Four)) == 3);
67
+ }
@@ -1,11 +1,16 @@
1
1
  const build_options = @import("build_options");
2
2
  const root = @import("root");
3
3
 
4
+ /// Configures the behavior of the pkmn package.
4
5
  pub const Options = struct {
5
6
  showdown: ?bool = null,
6
7
  log: ?bool = null,
8
+ chance: ?bool = null,
9
+ calc: ?bool = null,
7
10
  advance: ?bool = null,
8
11
  ebc: ?bool = null,
12
+ key: ?bool = null,
13
+ miss: ?bool = null,
9
14
  internal: ?bool = null,
10
15
  };
11
16
 
@@ -13,9 +18,15 @@ pub const Options = struct {
13
18
  pub const showdown = get("showdown", false);
14
19
  /// Whether or not protocol message logging is enabled.
15
20
  pub const log = get("log", false);
21
+ /// Whether or not update probability tracking is enabled.
22
+ pub const chance = get("chance", false);
23
+ /// Whether or not damage calculator support is enabled.
24
+ pub const calc = get("calc", false);
16
25
 
17
26
  pub const advance = get("advance", true);
18
27
  pub const ebc = get("ebc", true);
28
+ pub const key = get("key", false);
29
+ pub const miss = get("miss", true);
19
30
  pub const internal = get("internal", false);
20
31
 
21
32
  fn get(comptime name: []const u8, default: bool) bool {