@pkmn/engine 0.1.0-dev.78dc891c → 0.1.0-dev.79957401

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.
@@ -18,7 +18,7 @@ async function load(showdown, addon) {
18
18
  catch (err) {
19
19
  if (!(err instanceof Error))
20
20
  throw err;
21
- throw new Error(`Could not instantiate WASM module!\n${err.message}`);
21
+ throw new Error(`Could not instantiate WASM module!\n${err.message}`, { cause: err });
22
22
  }
23
23
  }
24
24
  else {
@@ -36,7 +36,7 @@ async function load(showdown, addon) {
36
36
  : addon instanceof URL
37
37
  ? `Could not fetch WASM module from '${addon.href}'!`
38
38
  : 'Could not instantiate WASM module!';
39
- throw new Error(`${message}\n${err.message}`);
39
+ throw new Error(`${message}\n${err.message}`, { cause: err });
40
40
  }
41
41
  }
42
42
  return (0, wasm_1.toBindings)(wasm.exports);
@@ -1 +1 @@
1
- {"version":3,"file":"browser.js","sourceRoot":"","sources":["../../../src/pkg/addon/browser.ts"],"names":[],"mappings":";;AAKA,oBAiCC;AAED,4BAEC;AAvCD,iCAAkC;AAE3B,KAAK,UAAU,IAAI,CAAC,QAAiB,EAAE,KAAgB;IAC5D,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,MAAM,EAAE,CAAC;QAClD,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC,CAAC;IAClE,CAAC;IAED,IAAI,IAA0B,CAAC;IAC/B,IAAI,KAAK,YAAY,WAAW,CAAC,QAAQ,EAAE,CAAC;QAC1C,IAAI,GAAG,KAAK,CAAC;IACf,CAAC;SAAM,IAAI,KAAK,YAAY,WAAW,CAAC,MAAM,EAAE,CAAC;QAC/C,IAAI,CAAC;YACH,IAAI,GAAG,CAAC,MAAM,WAAW,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC;QAChD,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,IAAI,CAAC,CAAC,GAAG,YAAY,KAAK,C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AAE,CAAC;YACb,IAAI,CAAC,CAAC,GAAG,YAAY,KAAK,CAAC;gBAAE,MAAM,GAAG,CAAC;YACvC,MAAM,OAAO,GAAG,CAAC,KAAK,IAAI,KAAK,KAAK,MAAM;gBACxC,CAAC,CAAC,kBAAkB,IAAI,6CAA6C;gBACrE,CAAC,CAAE,KAAiC,YAAY,GAAG;oBACjD,CAAC,CAAC,qCAAsC,KAAa,CAAC,IAAI,IAAI;oBAC9D,CAAC,CAAC,oCAAoC,CAAC;YAC3C,MAAM,IAAI,KAAK,CAAC,GAAG,OAAO,KAAK,GAAG,CAAC,OAAO,EAAE,EAAE,EAAC,KAAK,EAAE,GAAG,EAAC,CAAC,CAAC;QAC9D,CAAC;IACH,CAAC;IAED,OAAO,IAAA,iBAAU,EAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AAClC,CAAC;AAED,SAAgB,QAAQ;IACtB,MAAM,IAAI,KAAK,CAAC,+DAA+D,CAAC,CAAC;AACnF,CAAC"}
@@ -51,7 +51,7 @@ async function load(showdown, addon) {
51
51
  if (!(err instanceof Error))
52
52
  return err;
53
53
  if (addon && addon !== 'node') {
54
- throw new Error(`Unable to load native addon: '${addon}'\n${err.message}`);
54
+ throw new Error(`Unable to load native addon: '${addon}'\n${err.message}`, { cause: err });
55
55
  }
56
56
  else {
57
57
  throw error(NODE[+showdown], err);
@@ -77,7 +77,7 @@ async function load(showdown, addon) {
77
77
  catch (err) {
78
78
  if (!(err instanceof Error))
79
79
  throw err;
80
- throw new Error(`Could not instantiate WASM module!\n${err.message}`);
80
+ throw new Error(`Could not instantiate WASM module!\n${err.message}`, { cause: err });
81
81
  }
82
82
  }
83
83
  else {
@@ -88,7 +88,7 @@ async function load(showdown, addon) {
88
88
  catch (err) {
89
89
  if (!(err instanceof Error))
90
90
  throw err;
91
- throw new Error(`Could not instantiate WASM module!\n${err.message}`);
91
+ throw new Error(`Could not instantiate WASM module!\n${err.message}`, { cause: err });
92
92
  }
93
93
  }
94
94
  return (0, w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AAgB,QAAQ,CAAC,QAAiB;IACxC,IAAI,CAAC;QACH,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC;IACzC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC;AAED,SAAS,KAAK,CAAC,IAAY,EAAE,GAAY;IACvC,IAAI,CAAC,CAAC,GAAG,YAAY,KAAK,CAAC;QAAE,OAAO,GAAG,CAAC;IACxC,MAAM,OAAO,GAAG,kBAAkB,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC;IAC9D,OAAO,IAAI,KAAK,CAAC,GAAG,OAAO,gDAAgD,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC;AAC5F,CAAC"}
package/build.zig CHANGED
@@ -505,9 +505,6 @@ fn tool(b: *std.Build, path: []const u8, config: ToolConfig) !?*std.Build.Step.R
505
505
 
506
506
  const import = module(b, config.options, config.general.target, config.general.optimize);
507
507
  exe.root_module.addImport("pkmn", import);
508
- if (config.general.target.result.os.tag == .windows) {
509
- exe.root_module.linkSystemLibrary("advapi32", .{});
510
- }
511
508
 
512
509
  if (config.tool.tests) |ts| ts.step.dependOn(&exe.step);
513
510
  config.tool.exes.append(b.allocator, exe) catch @panic("OOM");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pkmn/engine",
3
- "version": "0.1.0-dev.78dc891c",
3
+ "version": "0.1.0-dev.79957401",
4
4
  "description": "A minimal, complete, Pokémon battle simulation engine optimized for performance",
5
5
  "repository": "github:pkmn/engine",
6
6
  "license": "MIT",
@@ -104,7 +104,7 @@
104
104
  },
105
105
  "devDependencies": {
106
106
  "@pkmn/dex-types": "0.9.35",
107
- "@pkmn/eslint-config": "^9.28.0",
107
+ "@pkmn/eslint-config": "^10.0.0",
108
108
  "@pkmn/img": "^0.3.4",
109
109
  "@pkmn/sets": "^5.2.0",
110
110
  "@pkmn/sim": "0.9.31",
@@ -113,25 +113,23 @@
113
113
  "@types/jest": "^30.0.0",
114
114
  "@types/minimist": "^1.2.5",
115
115
  "@types/mustache": "^4.2.6",
116
- "@types/node": "^26.0.0",
117
- "@types/react": "^19.2.17",
118
- "@types/semver": "^7.7.1",
119
- "@types/vscode": "^1.125.0",
120
- "@vitest/coverage-v8": "^4.1.9",
121
- "@vscode/vsce": "^3.9.2",
122
- "binaryen": "^130.0.0",
123
- "esbuild": "^0.28.1",
124
- "eslint": "<10",
116
+ "@types/node": "^26.6.3",
117
+ "@types/react": "^19.3.0",
118
+ "@types/vscode": "^1.140.0",
119
+ "@vitest/coverage-v8": "^5.0.3",
120
+ "@vscode/vsce": "^4.0.0",
121
+ "binaryen": "^132.0.0",
122
+ "esbuild": "^0.28.2",
123
+ "eslint": "^10.11.0",
125
124
  "html-minifier": "^4.0.0",
126
125
  "json-stringify-pretty-compact": "3.0.0",
127
126
  "minimist": "^1.2.8",
128
127
  "mustache": "^4.2.0",
129
- "semver": "^7.8.5",
130
128
  "source-map-support": "^0.5.21",
131
129
  "table": "^6.9.0",
132
130
  "trakr": "^0.2.0",
133
131
  "typescript": "^6.0.3",
134
- "vitest": "^4.1.9"
132
+ "vitest": "^5.0.3"
135
133
  },
136
134
  "scripts": {
137
135
  "lint": "eslint --cache src",
@@ -130,12 +130,12 @@ const parse = s => {
130
130
  const find = zig => {
131
131
  try {
132
132
  const {zig_exe, version} = parse(sh(zig, ['env']));
133
- const [major, minor, patch, dev] = version.split('.').map(n => parseInt(n));
133
+ const [major, minor, patch, dev] = version.split('.').map(n => parseInt(n, 10));
134
134
 
135
135
  const compatible = major > ZIG_VERSION.major ||
136
136
  (major >= ZIG_VERSION.major && minor > ZIG_VERSION.minor) ||
137
137
  (major >= ZIG_VERSION.major && minor >= ZIG_VERSION.minor && patch >= ZIG_VERSION.patch &&
138
- (!ZIG_VERSION.dev || (dev && dev >= parseInt(ZIG_VERSION.dev))));
138
+ (!ZIG_VERSION.dev || (dev && dev >= parseInt(ZIG_VERSION.dev, 10))));
139
139
 
140
140
  if (compatible) {
141
141
  log('Found existing compatible Zig executable:', zig_exe);
@@ -406,14 +406,9 @@ const downloadImportLib = async () => {
406
406
  const prefix = process.platform === 'win32' ? '' : 'lib';
407
407
  const ext = process.platform === 'darwin'
408
408
  ? 'dylib' : process.platform === 'win32' ? 'dll' : 'so';
409
- try {
410
- const actual = path.join(ROOT, 'build', 'lib', `${prefix}pkmn${suffix}.node.${ext}`);
411
- fs.renameSync(actual, artifact);
412
- } catch {
413
- // ziglang/zig#19743 changed this path
414
- const actual = path.join(ROOT, 'build', 'bin', `${prefix}pkmn${suffix}.node.${ext}`);
415
- fs.renameSync(actual, artifact);
416
- }
409
+ const dir = process.platform === 'win32' ? 'bin' : 'lib';
410
+ const actual = path.join(ROOT, 'build', dir, `${prefix}pkmn${suffix}.node.${ext}`);
411
+ fs.renameSync(actual, artifact);
417
412
  }
418
413
  }
419
414
  })().catch(e => {
@@ -45,9 +45,9 @@ test Array {
45
45
  try expectEqual(u40, @TypeOf(a));
46
46
 
47
47
  a = A.set(a, 4, 241);
48
- try expectEqual(@as(u8, 241), A.get(a, 4));
48
+ try expectEqual(241, A.get(a, 4));
49
49
  a = A.set(a, 4, 1);
50
- try expectEqual(@as(u8, 1), A.get(a, 4));
50
+ try expectEqual(1, A.get(a, 4));
51
51
 
52
52
  for (0..5) |i| a = A.set(a, i, @intCast(i));
53
53
  for (0..5) |i| try expectEqual(@as(u8, @intCast(i)), A.get(a, i));
@@ -61,10 +61,10 @@ test Array {
61
61
  b = B.set(b, 2, .true);
62
62
  try expectEqual(Optional(bool).None, B.get(b, 1));
63
63
  try expectEqual(Optional(bool).true, B.get(b, 2));
64
- try expectEqual(@as(u8, 0b00100000), b);
64
+ try expectEqual(0b00100000, b);
65
65
  b = B.set(b, 2, .None);
66
66
  b = B.set(b, 0, .false);
67
67
  try expectEqual(Optional(bool).None, B.get(b, 2));
68
68
  try expectEqual(Optional(bool).false, B.get(b, 0));
69
- try expectEqual(@as(u8, 0b0000001), b);
69
+ try expectEqual(0b0000001, b);
70
70
  }
@@ -22,8 +22,8 @@ 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), @as(u8, @bitCast(Player.P1.ident(1))));
26
- try expectEqual(@as(u8, 0b1101), @as(u8, @bitCast(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.
@@ -46,8 +46,8 @@ pub const ID = packed struct(u8) {
46
46
  };
47
47
 
48
48
  test ID {
49
- try expectEqual(@as(u8, 0b0001), @as(u8, @bitCast(ID{ .player = .P1, .id = 1 })));
50
- try expectEqual(@as(u8, 0b1101), @as(u8, @bitCast(ID{ .player = .P2, .id = 5 })));
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
51
  const id: ID = .{ .player = .P2, .id = 4 };
52
52
  try expectEqual(id, ID.from(id.int()));
53
53
  }
@@ -76,8 +76,8 @@ test Choice {
76
76
  const p2: Choice = .{ .type = .Switch, .data = 5 };
77
77
  try expectEqual(5, p2.data);
78
78
  try expectEqual(Choice.Type.Move, p1.type);
79
- try expectEqual(@as(u8, 0b0001_0001), @as(u8, @bitCast(p1)));
80
- try expectEqual(@as(u8, 0b0001_0110), @as(u8, @bitCast(p2)));
79
+ try expectEqual(0b0001_0001, @as(u8, @bitCast(p1)));
80
+ try expectEqual(0b0001_0110, @as(u8, @bitCast(p2)));
81
81
  }
82
82
 
83
83
  /// The result of the battle - all results other than 'None' should be considered terminal.
@@ -112,6 +112,6 @@ pub const Result = packed struct(u8) {
112
112
  };
113
113
 
114
114
  test Result {
115
- try expectEqual(@as(u8, 0b0101_0000), @as(u8, @bitCast(Result.Default)));
116
- try expectEqual(@as(u8, 0b1000_0000), @as(u8, @bitCast(Result{ .p2 = .Switch })));
115
+ try expectEqual(0b0101_0000, @as(u8, @bitCast(Result.Default)));
116
+ try expectEqual(0b1000_0000, @as(u8, @bitCast(Result{ .p2 = .Switch })));
117
117
  }
@@ -66,11 +66,11 @@ fn inspect(w: anytype, value: anytype) void {
66
66
  }
67
67
  @compileError(err);
68
68
  },
69
- .@"enum", .@"union", .@"struct" => return inspect(value.*),
69
+ .@"enum", .@"union", .@"struct" => return inspect(w, value.*),
70
70
  else => @compileError(err),
71
71
  },
72
72
  .many, .c => {
73
- if (ptr_info.sentinel) |_| return inspect(std.mem.span(value));
73
+ if (ptr_info.sentinel_ptr) |_| return inspect(w, std.mem.span(value));
74
74
  if (ptr_info.child == u8) {
75
75
  return w.interface.print("{s}", .{std.mem.span(value)}) catch return;
76
76
  }
@@ -6,20 +6,15 @@ const assert = std.debug.assert;
6
6
  /// Optimized optional representation which stores the empty None value as a sentinel.
7
7
  /// NOTE: ziglang/zig#104
8
8
  pub fn Optional(comptime T: type) type {
9
- const names = if (@hasDecl(std.meta, "fieldNames"))
10
- std.meta.fieldNames(switch (@typeInfo(T)) {
11
- .bool => enum { false, true },
12
- else => T,
13
- })
14
- else blk: {
15
- const fields = std.meta.fields(switch (@typeInfo(T)) {
16
- .bool => enum { false, true },
17
- else => T,
18
- });
19
- var ns: [fields.len][:0]const u8 = undefined;
20
- inline for (fields, 0..) |f, i| ns[i] = f.name;
9
+ const info = @typeInfo(switch (@typeInfo(T)) {
10
+ .bool => enum { false, true },
11
+ else => T,
12
+ }).@"enum";
13
+ const names = if (@hasField(@TypeOf(info), "fields")) blk: {
14
+ var ns: [info.fields.len][:0]const u8 = undefined;
15
+ inline for (info.fields, 0..) |f, i| ns[i] = f.name;
21
16
  break :blk &ns;
22
- };
17
+ } else info.field_names;
23
18
 
24
19
  const TagType = std.math.IntFittingRange(0, names.len);
25
20
  var fieldNames: [names.len + 1][]const u8 = undefined;
@@ -72,7 +72,7 @@ pub const PSRNG = extern struct {
72
72
 
73
73
  test PSRNG {
74
74
  var psrng: PSRNG = .{ .src = .{ .seed = 0x0001000200030004 } };
75
- try expectEqual(@as(u8, 121), psrng.range(u8, 0, 256));
75
+ try expectEqual(121, psrng.range(u8, 0, 256));
76
76
  try expectEqual(false, psrng.chance(u8, 128, 256)); // 226 < 128
77
77
  }
78
78
 
@@ -109,9 +109,9 @@ test Gen12 {
109
109
  try expectEqual(e, rng.next());
110
110
  }
111
111
 
112
- try expectEqual(@as(u8, 16), Gen12.percent(6) + 1);
113
- try expectEqual(@as(u8, 16), Gen12.percent(7) - 1);
114
- try expectEqual(@as(u8, 128), Gen12.percent(50) + 1);
112
+ try expectEqual(16, Gen12.percent(6) + 1);
113
+ try expectEqual(16, Gen12.percent(7) - 1);
114
+ try expectEqual(128, Gen12.percent(50) + 1);
115
115
  }
116
116
 
117
117
  // https://pkmn.cc/pokeemerald/src/random.c
@@ -178,7 +178,7 @@ pub const Options = struct {
178
178
  metronome: bool = false,
179
179
  };
180
180
 
181
- pub const MAX_FRONTIER = 86;
181
+ pub const MAX_FRONTIER = 90;
182
182
 
183
183
  pub fn transitions(
184
184
  battle: anytype,
@@ -876,12 +876,12 @@ test "Rolls.damage" {
876
876
 
877
877
  test "Rolls.coalesce" {
878
878
  var summaries = Summaries{ .p1 = .{ .damage = .{ .base = 74, .final = 69, .capped = true } } };
879
- try expectEqual(@as(u8, 0), Rolls.coalesce(.P2, 0, &summaries, false));
880
- try expectEqual(@as(u8, 241), Rolls.coalesce(.P2, 238, &summaries, false));
881
- try expectEqual(@as(u8, 255), Rolls.coalesce(.P2, 238, &summaries, true));
879
+ try expectEqual(0, Rolls.coalesce(.P2, 0, &summaries, false));
880
+ try expectEqual(241, Rolls.coalesce(.P2, 238, &summaries, false));
881
+ try expectEqual(255, Rolls.coalesce(.P2, 238, &summaries, true));
882
882
  summaries.p1.damage.final = 74;
883
- try expectEqual(@as(u8, 217), Rolls.coalesce(.P2, 217, &summaries, false));
884
- try expectEqual(@as(u8, 255), Rolls.coalesce(.P2, 217, &summaries, true));
883
+ try expectEqual(217, Rolls.coalesce(.P2, 217, &summaries, false));
884
+ try expectEqual(255, Rolls.coalesce(.P2, 217, &summaries, true));
885
885
  }
886
886
 
887
887
  test "Rolls.hit" {
@@ -967,9 +967,9 @@ test "Rolls.psywave" {
967
967
 
968
968
  try expectEqualSlices(u8, &.{0}, Rolls.psywave(actions.p1, &side, .None));
969
969
  var rolls = Rolls.psywave(actions.p2, &side, .None);
970
- try expectEqual(@as(u8, 150), rolls[rolls.len - 1]);
970
+ try expectEqual(150, rolls[rolls.len - 1]);
971
971
  side.stored().level = 81;
972
972
  rolls = Rolls.psywave(actions.p2, &side, .None);
973
- try expectEqual(@as(u8, 121), rolls[rolls.len - 1]);
973
+ try expectEqual(121, rolls[rolls.len - 1]);
974
974
  try expectEqualSlices(u8, &.{0}, Rolls.psywave(actions.p2, &side, .false));
975
975
  }
@@ -878,16 +878,16 @@ test "Chance.damage" {
878
878
 
879
879
  try chance.damage(.P1, 217);
880
880
  if (showdown) {
881
- try expectValue(@as(u8, 217), chance.actions.p1.damage);
881
+ try expectValue(217, chance.actions.p1.damage);
882
882
  try expectProbability(&chance.probability, 1, 39);
883
883
  } else {
884
884
  try expectProbability(&chance.probability, 1, 1);
885
- try expectValue(@as(u8, 0), chance.actions.p1.damage);
885
+ try expectValue(0, chance.actions.p1.damage);
886
886
 
887
887
  try chance.commit(.P1, .hit);
888
888
 
889
889
  try expectProbability(&chance.probability, 1, 39);
890
- try expectValue(@as(u8, 217), chance.actions.p1.damage);
890
+ try expectValue(217, chance.actions.p1.damage);
891
891
  }
892
892
  }
893
893
 
@@ -939,13 +939,13 @@ test "Chance.moveSlot" {
939
939
 
940
940
  try chance.moveSlot(.P2, 2, &ms, 2);
941
941
  try expectProbability(&chance.probability, 1, 2);
942
- try expectValue(@as(u3, 2), chance.actions.p2.move_slot);
942
+ try expectValue(2, chance.actions.p2.move_slot);
943
943
 
944
944
  chance.reset();
945
945
 
946
946
  try chance.moveSlot(.P1, 1, &ms, 0);
947
947
  try expectProbability(&chance.probability, 1, 3);
948
- try expectValue(@as(u3, 1), chance.actions.p1.move_slot);
948
+ try expectValue(1, chance.actions.p1.move_slot);
949
949
  }
950
950
 
951
951
  test "Chance.multiHit" {
@@ -953,25 +953,25 @@ test "Chance.multiHit" {
953
953
 
954
954
  try chance.multiHit(.P1, 3);
955
955
  try expectProbability(&chance.probability, 3, 8);
956
- try expectValue(@as(u4, 3), chance.actions.p1.multi_hit);
956
+ try expectValue(3, chance.actions.p1.multi_hit);
957
957
 
958
958
  chance.reset();
959
959
 
960
960
  try chance.multiHit(.P2, 5);
961
961
  try expectProbability(&chance.probability, 1, 8);
962
- try expectValue(@as(u4, 5), chance.actions.p2.multi_hit);
962
+ try expectValue(5, chance.actions.p2.multi_hit);
963
963
  }
964
964
 
965
965
  test "Chance.duration" {
966
966
  var chance: Chance(rational.Rational(u64)) = .{ .probability = .{} };
967
967
 
968
968
  chance.duration(.P1, 2);
969
- try expectValue(@as(u4, 2), chance.actions.p1.duration);
969
+ try expectValue(2, chance.actions.p1.duration);
970
970
 
971
971
  chance.reset();
972
972
 
973
973
  chance.duration(.P2, 4);
974
- try expectValue(@as(u4, 4), chance.actions.p2.duration);
974
+ try expectValue(4, chance.actions.p2.duration);
975
975
  }
976
976
 
977
977
  test "Chance.sleep" {
@@ -981,7 +981,7 @@ test "Chance.sleep" {
981
981
  chance.durations.p1.sleeps = Sleeps.set(chance.durations.p1.sleeps, 0, @intCast(i));
982
982
  try chance.sleep(.P1, .ended);
983
983
  try expectProbability(&chance.probability, 1, d);
984
- try expectValue(@as(u3, 0), Sleeps.get(chance.durations.p1.sleeps, 0));
984
+ try expectValue(0, Sleeps.get(chance.durations.p1.sleeps, 0));
985
985
 
986
986
  chance.reset();
987
987
 
@@ -1004,7 +1004,7 @@ test "Chance.confusion" {
1004
1004
  chance.durations.p2.confusion = @intCast(i);
1005
1005
  try chance.confusion(.P2, .ended);
1006
1006
  try expectProbability(&chance.probability, 1, d);
1007
- try expectValue(@as(u3, 0), chance.durations.p2.confusion);
1007
+ try expectValue(0, chance.durations.p2.confusion);
1008
1008
 
1009
1009
  chance.reset();
1010
1010
  }
@@ -1027,7 +1027,7 @@ test "Chance.disable" {
1027
1027
  chance.durations.p1.disable = @intCast(i);
1028
1028
  try chance.disable(.P1, .ended);
1029
1029
  try expectProbability(&chance.probability, 1, d);
1030
- try expectValue(@as(u4, 0), chance.durations.p1.disable);
1030
+ try expectValue(0, chance.durations.p1.disable);
1031
1031
 
1032
1032
  chance.reset();
1033
1033
 
@@ -1050,7 +1050,7 @@ test "Chance.attacking" {
1050
1050
  chance.durations.p2.attacking = @intCast(i);
1051
1051
  try chance.attacking(.P2, .ended);
1052
1052
  try expectProbability(&chance.probability, 1, d);
1053
- try expectValue(@as(u3, 0), chance.durations.p2.attacking);
1053
+ try expectValue(0, chance.durations.p2.attacking);
1054
1054
 
1055
1055
  chance.reset();
1056
1056
  }
@@ -1076,7 +1076,7 @@ test "Chance.binding" {
1076
1076
  chance.durations.p1.binding = @intCast(i);
1077
1077
  try chance.binding(.P1, .ended);
1078
1078
  try expectProbability(&chance.probability, p, q);
1079
- try expectValue(@as(u3, 0), chance.durations.p1.binding);
1079
+ try expectValue(0, chance.durations.p1.binding);
1080
1080
 
1081
1081
  chance.reset();
1082
1082
 
@@ -1096,7 +1096,7 @@ test "Chance.psywave" {
1096
1096
 
1097
1097
  try chance.psywave(.P2, 100, 150);
1098
1098
  try expectProbability(&chance.probability, 1, 150);
1099
- try expectValue(@as(u8, 101), chance.actions.p2.psywave);
1099
+ try expectValue(101, chance.actions.p2.psywave);
1100
1100
  }
1101
1101
 
1102
1102
  test "Chance.metronome" {
@@ -316,12 +316,12 @@ test Status {
316
316
  try expect(Status.is(Status.slp(5), .SLP));
317
317
  try expect(!Status.is(Status.slp(5), .EXT));
318
318
  try expect(!Status.is(Status.slp(7), .PSN));
319
- try expectEqual(@as(u3, 5), Status.duration(Status.slp(5)));
319
+ try expectEqual(5, Status.duration(Status.slp(5)));
320
320
  try expect(Status.is(Status.slf(2), .SLP));
321
321
  try expect(Status.is(Status.slf(2), .EXT));
322
322
  try expect(Status.is(Status.TOX, .PSN));
323
323
  try expect(Status.is(Status.TOX, .EXT));
324
- try expectEqual(@as(u3, 1), Status.duration(Status.slp(1)));
324
+ try expectEqual(1, Status.duration(Status.slp(1)));
325
325
  }
326
326
 
327
327
  /// Bitfield representation of volatile statuses and associated data in Generation I.
@@ -405,13 +405,13 @@ test Volatiles {
405
405
  try expect(!volatiles.Transform);
406
406
  try expect(!volatiles.MultiHit);
407
407
 
408
- try expectEqual(@as(u16, 235), volatiles.state);
409
- try expectEqual(@as(u8, 42), volatiles.substitute);
410
- try expectEqual(@as(u4, 2), volatiles.disable_move);
411
- try expectEqual(@as(u4, 4), volatiles.disable_duration);
412
- try expectEqual(@as(u3, 2), volatiles.confusion);
413
- try expectEqual(@as(u5, 4), volatiles.toxic);
414
- try expectEqual(@as(u3, 3), volatiles.attacks);
408
+ try expectEqual(235, volatiles.state);
409
+ try expectEqual(42, volatiles.substitute);
410
+ try expectEqual(2, volatiles.disable_move);
411
+ try expectEqual(4, volatiles.disable_duration);
412
+ try expectEqual(2, volatiles.confusion);
413
+ try expectEqual(4, volatiles.toxic);
414
+ try expectEqual(3, volatiles.attacks);
415
415
  }
416
416
 
417
417
  /// Representation of a Pokémon's stats in Generation I.
@@ -442,9 +442,9 @@ test Stats {
442
442
  try expectEqual(0, stats.def);
443
443
 
444
444
  var base = Species.get(.Gyarados).stats;
445
- try expectEqual(@as(u16, 127), Stats(u16).calc("hp", base.hp, 0, 5120, 38));
445
+ try expectEqual(127, Stats(u16).calc("hp", base.hp, 0, 5120, 38));
446
446
  base = Species.get(.Pidgeot).stats;
447
- try expectEqual(@as(u16, 279), Stats(u16).calc("spe", base.spe, 15, 63001, 100));
447
+ try expectEqual(279, Stats(u16).calc("spe", base.spe, 15, 63001, 100));
448
448
  }
449
449
 
450
450
  /// Representation of a Pokémon's boosts in Generation I.
@@ -537,7 +537,7 @@ pub const Species = species.Species;
537
537
 
538
538
  test Species {
539
539
  try expectEqual(2, @intFromEnum(Species.Ivysaur));
540
- try expectEqual(@as(u8, 100), Species.get(.Mew).stats.def);
540
+ try expectEqual(100, Species.get(.Mew).stats.def);
541
541
  }
542
542
 
543
543
  /// Representation of a Generation I type in Pokémon.
@@ -576,8 +576,8 @@ test Types {
576
576
  try expectEqual(Effectiveness.Resisted, Type.effectiveness(.Fire, .Water));
577
577
  try expectEqual(Effectiveness.Neutral, Type.effectiveness(.Normal, .Grass));
578
578
 
579
- try expectEqual(@as(u8, 3), Type.precedence(.Water, .Water));
580
- try expectEqual(@as(u8, 26), Type.precedence(.Bug, .Ghost));
579
+ try expectEqual(3, Type.precedence(.Water, .Water));
580
+ try expectEqual(26, Type.precedence(.Bug, .Ghost));
581
581
  try expect(Type.precedence(.Poison, .Bug) > Type.precedence(.Poison, .Poison));
582
582
 
583
583
  const t: Types = .{ .type1 = .Rock, .type2 = .Ground };
@@ -617,18 +617,18 @@ pub const DVs = struct {
617
617
 
618
618
  test DVs {
619
619
  var dvs: DVs = .{ .spc = 15, .spe = 15 };
620
- try expectEqual(@as(u4, 15), dvs.hp());
620
+ try expectEqual(15, dvs.hp());
621
621
  dvs = .{
622
622
  .atk = 5,
623
623
  .def = 15,
624
624
  .spe = 13,
625
625
  .spc = 13,
626
626
  };
627
- try expectEqual(@as(u4, 15), dvs.hp());
627
+ try expectEqual(15, dvs.hp());
628
628
  dvs = .{
629
629
  .def = 3,
630
630
  .spe = 10,
631
631
  .spc = 11,
632
632
  };
633
- try expectEqual(@as(u4, 13), dvs.hp());
633
+ try expectEqual(13, dvs.hp());
634
634
  }
@@ -327,8 +327,7 @@ pub fn patch(battle: *data.Battle(data.PRNG), buf: []u8) void {
327
327
  var i: usize = 0;
328
328
  while (i < buf.len) : (i += 3) {
329
329
  const off = @as(u16, @intCast(buf[i])) * 2;
330
- const val = std.mem.readInt(u16, @as(*const [2]u8, @ptrCast(buf[i + 1 .. i + 3])), endian);
331
- const bytes: *[2]u8 = @ptrCast(std.mem.asBytes(battle)[off .. off + 2]);
332
- std.mem.writeInt(u16, bytes, val, endian);
330
+ const val = std.mem.readInt(u16, @ptrCast(buf[i + 1 .. i + 3]), endian);
331
+ std.mem.writeInt(u16, @ptrCast(std.mem.asBytes(battle)[off .. off + 2]), val, endian);
333
332
  }
334
333
  }
@@ -1,6 +1,5 @@
1
1
  const DEBUG = @import("../common/debug.zig").print;
2
2
 
3
- const builtin = @import("builtin");
4
3
  const chance = @import("chance.zig");
5
4
  const common = @import("../common/data.zig");
6
5
  const data = @import("data.zig");
@@ -1296,11 +1295,7 @@ fn counterDamage(battle: anytype, player: Player, move: Move.Data, options: anyt
1296
1295
  return null;
1297
1296
  }
1298
1297
 
1299
- // NOTE: llvm/llvm-project#58557
1300
- battle.last_damage = if (comptime builtin.target.cpu.arch.isWasm())
1301
- @max(battle.last_damage *% 2, std.math.maxInt(u16))
1302
- else
1303
- battle.last_damage *| 2;
1298
+ battle.last_damage *|= 2;
1304
1299
 
1305
1300
  // Pokémon Showdown calls moveHit before Counter
1306
1301
  if (!showdown and !try checkHit(battle, player, move, options)) return null;
@@ -521,7 +521,7 @@ test "Chance.damage" {
521
521
  var chance: Chance(rational.Rational(u64)) = .{ .probability = .{} };
522
522
 
523
523
  try chance.damage(.P1, 0, 219);
524
- try expectValue(@as(u8, 219), Damages.get(chance.actions.p1.damages, 0));
524
+ try expectValue(219, Damages.get(chance.actions.p1.damages, 0));
525
525
  try expectProbability(&chance.probability, 1, 39);
526
526
  }
527
527
 
@@ -646,7 +646,7 @@ test "Chance.present" {
646
646
  } else {
647
647
  try expectProbability(&chance.probability, 25, 256);
648
648
  }
649
- try expectValue(@as(u3, 4), chance.actions.p2.present);
649
+ try expectValue(4, chance.actions.p2.present);
650
650
 
651
651
  chance.reset();
652
652
 
@@ -656,7 +656,7 @@ test "Chance.present" {
656
656
  } else {
657
657
  try expectProbability(&chance.probability, 51, 256);
658
658
  }
659
- try expectValue(@as(u3, 1), chance.actions.p1.present);
659
+ try expectValue(1, chance.actions.p1.present);
660
660
  }
661
661
 
662
662
  test "Chance.magnitude" {
@@ -668,7 +668,7 @@ test "Chance.magnitude" {
668
668
  } else {
669
669
  try expectProbability(&chance.probability, 13, 256);
670
670
  }
671
- try expectValue(@as(u3, 7), chance.actions.p2.magnitude);
671
+ try expectValue(7, chance.actions.p2.magnitude);
672
672
 
673
673
  chance.reset();
674
674
 
@@ -678,7 +678,7 @@ test "Chance.magnitude" {
678
678
  } else {
679
679
  try expectProbability(&chance.probability, 51, 256);
680
680
  }
681
- try expectValue(@as(u3, 5), chance.actions.p1.magnitude);
681
+ try expectValue(5, chance.actions.p1.magnitude);
682
682
  }
683
683
 
684
684
  test "Chance.tripleKick" {
@@ -686,7 +686,7 @@ test "Chance.tripleKick" {
686
686
 
687
687
  try chance.tripleKick(.P1, 2);
688
688
  try expectProbability(&chance.probability, 1, 3);
689
- try expectValue(@as(u2, 2), chance.actions.p1.triple_kick);
689
+ try expectValue(2, chance.actions.p1.triple_kick);
690
690
  }
691
691
 
692
692
  test "Chance.spite" {
@@ -694,7 +694,7 @@ test "Chance.spite" {
694
694
 
695
695
  try chance.spite(.P1, 3);
696
696
  try expectProbability(&chance.probability, 1, 4);
697
- try expectValue(@as(u3, 3), chance.actions.p1.spite);
697
+ try expectValue(3, chance.actions.p1.spite);
698
698
  }
699
699
 
700
700
  test "Chance.conversion2" {
@@ -721,7 +721,7 @@ test "Chance.psywave" {
721
721
 
722
722
  try chance.psywave(.P2, 100, 150);
723
723
  try expectProbability(&chance.probability, 1, 150);
724
- try expectValue(@as(u8, 100), chance.actions.p2.psywave);
724
+ try expectValue(100, chance.actions.p2.psywave);
725
725
  }
726
726
 
727
727
  test "Chance.metronome" {
@@ -737,19 +737,19 @@ test "Chance.moveSlot" {
737
737
 
738
738
  try chance.moveSlot(.P2, 2, 2);
739
739
  try expectProbability(&chance.probability, 1, 2);
740
- try expectValue(@as(u3, 2), chance.actions.p2.move_slot);
740
+ try expectValue(2, chance.actions.p2.move_slot);
741
741
 
742
742
  chance.reset();
743
743
 
744
744
  try chance.moveSlot(.P1, 1, 3);
745
745
  try expectProbability(&chance.probability, 1, 3);
746
- try expectValue(@as(u3, 1), chance.actions.p1.move_slot);
746
+ try expectValue(1, chance.actions.p1.move_slot);
747
747
 
748
748
  chance.reset();
749
749
 
750
750
  try chance.moveSlot(.P1, 4, 1);
751
751
  try expectProbability(&chance.probability, 1, 1);
752
- try expectValue(@as(u3, 4), chance.actions.p1.move_slot);
752
+ try expectValue(4, chance.actions.p1.move_slot);
753
753
  }
754
754
 
755
755
  test "Chance.forceSwitch" {
@@ -757,19 +757,19 @@ test "Chance.forceSwitch" {
757
757
 
758
758
  try chance.forceSwitch(.P2, 2, 2);
759
759
  try expectProbability(&chance.probability, 1, 2);
760
- try expectValue(@as(u3, 2), chance.actions.p2.force_switch);
760
+ try expectValue(2, chance.actions.p2.force_switch);
761
761
 
762
762
  chance.reset();
763
763
 
764
764
  try chance.forceSwitch(.P1, 1, 3);
765
765
  try expectProbability(&chance.probability, 1, 3);
766
- try expectValue(@as(u3, 1), chance.actions.p1.force_switch);
766
+ try expectValue(1, chance.actions.p1.force_switch);
767
767
 
768
768
  chance.reset();
769
769
 
770
770
  try chance.forceSwitch(.P1, 4, 1);
771
771
  try expectProbability(&chance.probability, 1, 1);
772
- try expectValue(@as(u3, 4), chance.actions.p1.force_switch);
772
+ try expectValue(4, chance.actions.p1.force_switch);
773
773
  }
774
774
 
775
775
  test "Chance.multiHit" {
@@ -777,20 +777,20 @@ test "Chance.multiHit" {
777
777
 
778
778
  try chance.multiHit(.P1, 3);
779
779
  try expectProbability(&chance.probability, 3, 8);
780
- try expectValue(@as(u3, 3), chance.actions.p1.multi_hit);
780
+ try expectValue(3, chance.actions.p1.multi_hit);
781
781
 
782
782
  chance.reset();
783
783
 
784
784
  try chance.multiHit(.P2, 5);
785
785
  try expectProbability(&chance.probability, 1, 8);
786
- try expectValue(@as(u3, 5), chance.actions.p2.multi_hit);
786
+ try expectValue(5, chance.actions.p2.multi_hit);
787
787
  }
788
788
 
789
789
  test "Chance.duration" {
790
790
  var chance: Chance(rational.Rational(u64)) = .{ .probability = .{} };
791
791
 
792
792
  chance.duration(.P1, 2);
793
- try expectValue(@as(u3, 2), chance.actions.p1.duration);
793
+ try expectValue(2, chance.actions.p1.duration);
794
794
  }
795
795
 
796
796
  pub fn expectProbability(r: anytype, p: u64, q: u64) !void {
@@ -248,12 +248,12 @@ test DVs {
248
248
  var dvs = DVs.from(.Mewtwo, .{ .def = 13 });
249
249
  try expectEqual(Gender.Unknown, dvs.gender);
250
250
  try expectEqual(Type.Ice, dvs.type);
251
- try expectEqual(@as(u8, 70), dvs.power());
251
+ try expectEqual(70, dvs.power());
252
252
 
253
253
  dvs = DVs.from(.Pikachu, .{ .spc = 14 });
254
254
  try expectEqual(Gender.Male, dvs.gender);
255
255
  try expectEqual(Type.Dark, dvs.type);
256
- try expectEqual(@as(u8, 69), dvs.power());
256
+ try expectEqual(69, dvs.power());
257
257
 
258
258
  dvs = DVs.from(.Cyndaquil, .{ .atk = 1, .def = 3, .spe = 10, .spc = 9 });
259
259
  try expectEqual(Gender.Female, dvs.gender);
@@ -380,9 +380,9 @@ test Stats {
380
380
  try expectEqual(0, stats.def);
381
381
 
382
382
  var base = Species.get(.Gyarados).stats;
383
- try expectEqual(@as(u16, 127), Stats(u16).calc("hp", base.hp, 0, 5120, 38));
383
+ try expectEqual(127, Stats(u16).calc("hp", base.hp, 0, 5120, 38));
384
384
  base = Species.get(.Pidgeot).stats;
385
- try expectEqual(@as(u16, 279), Stats(u16).calc("spe", base.spe, 15, 63001, 100));
385
+ try expectEqual(279, Stats(u16).calc("spe", base.spe, 15, 63001, 100));
386
386
  }
387
387
 
388
388
  pub const Boosts = packed struct(u32) {
@@ -428,8 +428,8 @@ test Move {
428
428
  try expectEqual(Move.Effect.ConfusionChance, move.effect);
429
429
  try expectEqual(rng.Gen12.percent(50), move.accuracy);
430
430
  try expectEqual(rng.Gen12.percent(100), move.chance);
431
- try expectEqual(@as(u8, 5), Move.pp(.DynamicPunch));
432
- try expectEqual(@as(i8, -1), Move.get(.Counter).priority);
431
+ try expectEqual(5, Move.pp(.DynamicPunch));
432
+ try expectEqual(-1, Move.get(.Counter).priority);
433
433
  try expect(!move.effect.isHighCritical());
434
434
  try expect(Move.get(.KarateChop).effect.isHighCritical());
435
435
  try expect(Move.get(.RazorWind).effect.isHighCritical());
@@ -439,7 +439,7 @@ pub const Species = species.Species;
439
439
 
440
440
  test Species {
441
441
  try expectEqual(152, @intFromEnum(Species.Chikorita));
442
- try expectEqual(@as(u8, 100), Species.get(.Celebi).stats.spd);
442
+ try expectEqual(100, Species.get(.Celebi).stats.spd);
443
443
  }
444
444
 
445
445
  pub const Type = types.Type;
@@ -452,7 +452,7 @@ test Types {
452
452
  try expect(!Type.Steel.special());
453
453
  try expect(Type.Dark.special());
454
454
 
455
- try expectEqual(@as(u8, 3), Type.precedence(.Water, .Water));
455
+ try expectEqual(3, Type.precedence(.Water, .Water));
456
456
  try expect(Type.precedence(.Poison, .Bug) > Type.precedence(.Poison, .Poison));
457
457
  try expect(Type.precedence(.Ice, .Fire) > Type.precedence(.Ice, .Water));
458
458
 
@@ -1,6 +1,5 @@
1
1
  const DEBUG = @import("../common/debug.zig").print;
2
2
 
3
- const builtin = @import("builtin");
4
3
  const common = @import("../common/data.zig");
5
4
  const data = @import("data.zig");
6
5
  const generated = @import("generated.zig");
@@ -1427,8 +1426,7 @@ pub const Effects = struct {
1427
1426
  if (move.type.special() != (last == .MirrorCoat)) return;
1428
1427
  if (state.damage == 0) return;
1429
1428
 
1430
- // NOTE: llvm/llvm-project#58557
1431
- state.damage = smul(state.damage, 2);
1429
+ state.damage *|= 2;
1432
1430
  state.miss = false;
1433
1431
  }
1434
1432
 
@@ -1523,18 +1521,15 @@ pub const Effects = struct {
1523
1521
 
1524
1522
  pub const double = struct {
1525
1523
  pub fn flying(battle: anytype, player: Player, state: *State, _: anytype) !void {
1526
- if (!battle.foe(player).active.volatiles.Flying) return;
1527
- state.damage = smul(state.damage, 2);
1524
+ if (battle.foe(player).active.volatiles.Flying) state.damage *|= 2;
1528
1525
  }
1529
1526
 
1530
1527
  pub fn underground(battle: anytype, player: Player, state: *State, _: anytype) !void {
1531
- if (!battle.foe(player).active.volatiles.Underground) return;
1532
- state.damage = smul(state.damage, 2);
1528
+ if (battle.foe(player).active.volatiles.Underground) state.damage *|= 2;
1533
1529
  }
1534
1530
 
1535
1531
  pub fn minimize(battle: anytype, player: Player, state: *State, _: anytype) !void {
1536
- if (!battle.foe(player).active.volatiles.minimized) return;
1537
- state.damage = smul(state.damage, 2);
1532
+ if (battle.foe(player).active.volatiles.minimized) state.damage *|= 2;
1538
1533
  }
1539
1534
  };
1540
1535
 
@@ -1732,7 +1727,7 @@ pub const Effects = struct {
1732
1727
  state.bp *= 2;
1733
1728
  assert(state.bp <= 160);
1734
1729
  } else {
1735
- state.damage = smul(state.damage, 2);
1730
+ state.damage *|= 2;
1736
1731
  }
1737
1732
  }
1738
1733
 
@@ -2203,7 +2198,7 @@ pub const Effects = struct {
2203
2198
 
2204
2199
  pub fn pursuit(battle: anytype, player: Player, state: *State, _: anytype) !void {
2205
2200
  // TODO: remove switching variable and just look at Choice saved in Battle struct?
2206
- if (battle.foe(player).active.volatiles.switching) state.damage = smul(state.damage, 2);
2201
+ if (battle.foe(player).active.volatiles.switching) state.damage *|= 2;
2207
2202
  }
2208
2203
 
2209
2204
  pub const rage = struct {
@@ -2216,7 +2211,7 @@ pub const Effects = struct {
2216
2211
  const side = battle.side(player);
2217
2212
 
2218
2213
  assert(side.active.volatiles.Rage);
2219
- state.damage = smul(state.damage, (side.active.volatiles.rage +| 1)); // TODO: |+
2214
+ state.damage *|= (side.active.volatiles.rage +| 1);
2220
2215
  }
2221
2216
  };
2222
2217
 
@@ -2311,7 +2306,7 @@ pub const Effects = struct {
2311
2306
  side.active.volatiles.attacks += 1;
2312
2307
  side.active.volatiles.Rollout = side.active.volatiles.attacks != 5;
2313
2308
 
2314
- if (side.active.volatiles.DefenseCurl) state.damage = smul(state.damage, 2);
2309
+ if (side.active.volatiles.DefenseCurl) state.damage *|= 2;
2315
2310
  }
2316
2311
  };
2317
2312
 
@@ -2839,12 +2834,6 @@ fn convertible(active: ActivePokemon, m: Move) bool {
2839
2834
  return t != .@"???" and !active.types.includes(t);
2840
2835
  }
2841
2836
 
2842
- // NOTE: llvm/llvm-project#58557
2843
- fn smul(a: anytype, b: @TypeOf(a)) @TypeOf(a) {
2844
- if (!comptime builtin.target.cpu.arch.isWasm()) return a *| b;
2845
- return @max(a *% b, std.math.maxInt(@TypeOf(a)));
2846
- }
2847
-
2848
2837
  pub const Rolls = struct {
2849
2838
  fn speedTie(battle: anytype, options: anytype) !bool {
2850
2839
  const p1 = if (options.calc.overridden(.P1, 0, .speed_tie)) |player|