@pkmn/engine 0.1.0-dev.cbdbb719 → 0.1.0-dev.cdc837af

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 (67) hide show
  1. package/build/pkg/addon/browser.d.ts +3 -0
  2. package/build/pkg/addon/browser.js +44 -0
  3. package/build/pkg/addon/browser.js.map +1 -0
  4. package/build/pkg/addon/node.d.ts +3 -0
  5. package/build/pkg/addon/node.js +97 -0
  6. package/build/pkg/addon/node.js.map +1 -0
  7. package/build/pkg/addon/wasm.d.ts +2 -0
  8. package/build/pkg/addon/wasm.js +21 -0
  9. package/build/pkg/addon/wasm.js.map +1 -0
  10. package/build/pkg/addon.d.ts +22 -0
  11. package/build/pkg/addon.js +29 -51
  12. package/build/pkg/addon.js.map +1 -1
  13. package/build/pkg/data.d.ts +23 -1
  14. package/build/pkg/data.js.map +1 -1
  15. package/build/pkg/gen1.js +1 -1
  16. package/build/pkg/gen1.js.map +1 -1
  17. package/build/pkg/index.d.ts +21 -8
  18. package/build/pkg/index.js +15 -10
  19. package/build/pkg/index.js.map +1 -1
  20. package/build/pkg/protocol.d.ts +20 -1
  21. package/build/pkg/protocol.js +105 -103
  22. package/build/pkg/protocol.js.map +1 -1
  23. package/build/tools/debug.js +35 -68
  24. package/build/tools/debug.js.map +1 -1
  25. package/build/tools/display/debug.jsx +141 -0
  26. package/build/tools/display/debug.jsx.map +1 -0
  27. package/build/tools/display/index.js +141 -0
  28. package/build/tools/display/index.js.map +1 -0
  29. package/build/tools/display/ui.jsx +349 -0
  30. package/build/tools/display/ui.jsx.map +1 -0
  31. package/build/tools/display/util.js +18 -0
  32. package/build/tools/display/util.js.map +1 -0
  33. package/build.zig +89 -70
  34. package/package.json +49 -32
  35. package/src/bin/install-pkmn-engine +4 -2
  36. package/src/bin/pkmn-debug +1 -1
  37. package/src/lib/common/debug.zig +39 -8
  38. package/src/lib/common/options.zig +2 -0
  39. package/src/lib/common/protocol.zig +4 -8
  40. package/src/lib/common/rational.zig +7 -5
  41. package/src/lib/common/rng.zig +1 -3
  42. package/src/lib/gen1/calc.zig +200 -53
  43. package/src/lib/gen1/chance.zig +40 -22
  44. package/src/lib/gen1/data/moves.zig +2 -4
  45. package/src/lib/gen1/data/species.zig +1 -3
  46. package/src/lib/gen1/data/types.zig +1 -2
  47. package/src/lib/gen1/data.zig +9 -13
  48. package/src/lib/gen1/helpers.zig +5 -21
  49. package/src/lib/gen1/mechanics.zig +55 -61
  50. package/src/lib/gen2/calc.zig +10 -18
  51. package/src/lib/gen2/chance.zig +8 -13
  52. package/src/lib/gen2/data/items.zig +1 -3
  53. package/src/lib/gen2/data/moves.zig +2 -4
  54. package/src/lib/gen2/data/species.zig +1 -3
  55. package/src/lib/gen2/data/types.zig +1 -2
  56. package/src/lib/gen2/data.zig +11 -15
  57. package/src/lib/gen2/generated.zig +18 -23
  58. package/src/lib/gen2/helpers.zig +5 -16
  59. package/src/lib/gen2/mechanics.zig +22 -36
  60. package/src/lib/node.zig +2 -4
  61. package/src/lib/pkmn.zig +4 -0
  62. package/src/lib/wasm.zig +1 -2
  63. package/src/tools/display/dom.ts +96 -0
  64. package/src/tools/display/ui.css +354 -0
  65. package/build/test/display.js +0 -405
  66. package/build/test/display.js.map +0 -1
  67. package/src/test/display/pkmn.html.tmpl +0 -368
@@ -242,6 +242,8 @@ export type CreateOptions = {
242
242
  * that the engine be built in a specific compatibility mode).
243
243
  */
244
244
  showdown?: boolean;
245
+ /** Whether the battle should be initialized without functionality afforded by native code. */
246
+ inert?: true;
245
247
  } & ({
246
248
  /** Player 1's options. */
247
249
  p1: PlayerOptions;
@@ -348,12 +350,14 @@ export declare const Battle: {
348
350
  };
349
351
  /** Utilities for working with `Choice` objects. */
350
352
  export declare class Choice {
351
- /** All valid choices types. */
352
- static Types: readonly ["pass", "move", "switch"];
353
- protected static PASS: {
354
- readonly type: "pass";
355
- readonly data: 0;
353
+ /** Encoded values of the various choice types. */
354
+ static Encoding: {
355
+ readonly pass: 0;
356
+ readonly move: 1;
357
+ readonly switch: 2;
356
358
  };
359
+ /** All valid choices types. */
360
+ static Types: readonly Choice["type"][];
357
361
  protected static MATCH: RegExp;
358
362
  private constructor();
359
363
  /** Decode a choice from its binary representation. */
@@ -367,20 +371,29 @@ export declare class Choice {
367
371
  static parse(choice: string): Choice;
368
372
  /** Formats a `Choice` into a Pokémon Showdown compatible choice string. */
369
373
  static format(choice: Choice): string;
370
- /** Returns the "pass" `Choice`. */
371
- static pass(): Choice;
374
+ /** The canonical "pass" `Choice`. */
375
+ static pass: Choice;
372
376
  /** Returns a "move" `Choice` with the provided data. */
373
377
  static move(data: 0 | 1 | 2 | 3 | 4): Choice;
374
378
  /** Returns a "switch" `Choice` with the provided data. */
375
379
  static switch(data: 2 | 3 | 4 | 5 | 6): Choice;
376
380
  }
377
- /** Utilities for working with `Result` objects */
381
+ /** Utilities for working with `Result` objects. */
378
382
  export declare class Result {
383
+ /** Encoded values of non-empty various result types. */
384
+ static Encoding: {
385
+ readonly win: 1;
386
+ readonly lose: 2;
387
+ readonly tie: 3;
388
+ readonly error: 4;
389
+ };
379
390
  /** All valid result types. */
380
391
  static Types: readonly [undefined, "win", "lose", "tie", "error"];
381
392
  private constructor();
382
393
  /** Decode a `Result` from its binary representation. */
383
394
  static decode(byte: number): Result;
395
+ /** Encode a `Result`` to its binary representation. */
396
+ static encode(result: Result): number;
384
397
  }
385
398
  export type { ParsedLine, PokemonInfo } from './protocol';
386
399
  export { Info, SideInfo, Log } from './protocol';
@@ -53,9 +53,10 @@ exports.Battle = new class {
53
53
  };
54
54
  /** Utilities for working with `Choice` objects. */
55
55
  class Choice {
56
+ /** Encoded values of the various choice types. */
57
+ static Encoding = { pass: 0, move: 1, switch: 2 };
56
58
  /** All valid choices types. */
57
- static Types = ['pass', 'move', 'switch'];
58
- static PASS = { type: 'pass', data: 0 };
59
+ static Types = Object.keys(Choice.Encoding);
59
60
  static MATCH = /^(?:(pass)|((move) ([0-4]))|((switch) ([2-6])))$/;
60
61
  constructor() { }
61
62
  /** Decode a choice from its binary representation. */
@@ -64,9 +65,7 @@ class Choice {
64
65
  }
65
66
  /** Encode a choice to its binary representation. */
66
67
  static encode(choice) {
67
- return (choice
68
- ? (choice.data << 2 | (choice.type === 'pass' ? 0 : choice.type === 'move' ? 1 : 2))
69
- : 0);
68
+ return (choice ? (choice.data << 2 | Choice.Encoding[choice.type]) : 0);
70
69
  }
71
70
  /**
72
71
  * Parse a Pokémon Showdown choice string into a `Choice`.
@@ -84,10 +83,8 @@ class Choice {
84
83
  static format(choice) {
85
84
  return choice.type === 'pass' ? choice.type : `${choice.type} ${choice.data}`;
86
85
  }
87
- /** Returns the "pass" `Choice`. */
88
- static pass() {
89
- return Choice.PASS;
90
- }
86
+ /** The canonical "pass" `Choice`. */
87
+ static pass = { type: 'pass', data: 0 };
91
88
  /** Returns a "move" `Choice` with the provided data. */
92
89
  static move(data) {
93
90
  return { type: 'move', data };
@@ -98,8 +95,10 @@ class Choice {
98
95
  }
99
96
  }
100
97
  exports.Choice = Choice;
101
- /** Utilities for working with `Result` objects */
98
+ /** Utilities for working with `Result` objects. */
102
99
  class Result {
100
+ /** Encoded values of non-empty various result types. */
101
+ static Encoding = { win: 1, lose: 2, tie: 3, error: 4 };
103
102
  /** All valid result types. */
104
103
  static Types = [undefined, 'win', 'lose', 'tie', 'error'];
105
104
  constructor() { }
@@ -111,6 +110,12 @@ class Result {
111
110
  p2: Choice.Types[byte >> 6],
112
111
  };
113
112
  }
113
+ /** Encode a `Result`` to its binary representation. */
114
+ static encode(result) {
115
+ return ((result.type ? Result.Encoding[result.type] : 0) |
116
+ Choice.Encoding[result.p1] << 4 |
117
+ Choice.Encoding[result.p2] << 6);
118
+ }
114
119
  }
115
120
  exports.Result = Result;
116
121
  var protocol_1 = require("./protocol");
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/pkg/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;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AAQ,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YACpD,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC;YAC/B,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;IACvC,CAAC;;AAtBH,wBAuBC;AAGD,uCAA+C;AAAvC,gGAAA,IAAI,OAAA;AAAE,oGAAA,QAAQ,OAAA;AAAE,+FAAA,GAAG,OAAA;AAC3B,+BAA8B;AAAtB,8FAAA,MAAM,OAAA"}
@@ -1,7 +1,25 @@
1
- import { Generation, StatusName, TypeName } from '@pkmn/data';
1
+ import { GenderName, GenerationNum, ID, MoveName, SpeciesName, StatusName, TypeName } from '@pkmn/data';
2
2
  import { Protocol } from '@pkmn/protocol';
3
3
  import { Lookup } from './data';
4
4
  import { PlayerOptions } from '.';
5
+ interface Generation {
6
+ num: GenerationNum;
7
+ species: {
8
+ get(id: ID): {
9
+ name: SpeciesName;
10
+ genderRatio: {
11
+ M: number;
12
+ F: number;
13
+ };
14
+ gender?: GenderName;
15
+ } | undefined;
16
+ };
17
+ moves: {
18
+ get(id: ID): {
19
+ name: MoveName;
20
+ } | undefined;
21
+ };
22
+ }
5
23
  /** A message logged by the engine parsed into Pokémon Showdown's protocol. */
6
24
  export interface ParsedLine {
7
25
  /** Positional protocol arguments. */
@@ -71,3 +89,4 @@ export declare function decodeIdentRaw(byte: number): {
71
89
  };
72
90
  export declare function decodeStatus(val: number): StatusName | undefined;
73
91
  export declare function decodeTypes(lookup: Lookup, val: number): readonly [TypeName, TypeName];
92
+ export {};
@@ -4,8 +4,9 @@ exports.Log = exports.SideInfo = exports.Info = void 0;
4
4
  exports.decodeIdentRaw = decodeIdentRaw;
5
5
  exports.decodeStatus = decodeStatus;
6
6
  exports.decodeTypes = decodeTypes;
7
- const data_1 = require("./data");
8
- const ArgType = data_1.PROTOCOL.ArgType;
7
+ const data_1 = require("@pkmn/data");
8
+ const data_2 = require("./data");
9
+ const ArgType = data_2.PROTOCOL.ArgType;
9
10
  /**
10
11
  * Information related to battle required to parse the engine's binary protocol
11
12
  * into Pokémon Showdown's text protocol (e.g. Pokémon nicknames).
@@ -33,10 +34,11 @@ class SideInfo {
33
34
  constructor(gen, player) {
34
35
  this.name = player.name;
35
36
  this.team = player.team.map(p => {
36
- const species = gen.species.get(p.species);
37
+ const species = gen.species.get((0, data_1.toID)(p.species));
37
38
  const name = p.name ?? species.name;
39
+ const dv = Math.floor((p.ivs?.atk ?? 31) / 2);
38
40
  const fallback = gen.num === 1 ? undefined
39
- : gen.num === 2 ? gen.stats.toDV(p.ivs?.atk ?? 31) >= species.genderRatio.F * 16 ? 'M' : 'F'
41
+ : gen.num === 2 ? dv >= species.genderRatio.F * 16 ? 'M' : 'F'
40
42
  : 'M';
41
43
  const gender = (p.gender ?? species.gender ?? fallback);
42
44
  return { species: species.name, name, gender, shiny: p.shiny };
@@ -103,81 +105,81 @@ class Log {
103
105
  }
104
106
  exports.Log = Log;
105
107
  const GENDERS = ['M', 'F', 'N'];
106
- const CANT = new Array(data_1.PROTOCOL.Cant.length);
107
- CANT[data_1.PROTOCOL.Cant.Sleep] = 'slp';
108
- CANT[data_1.PROTOCOL.Cant.Freeze] = 'frz';
109
- CANT[data_1.PROTOCOL.Cant.Paralysis] = 'par';
110
- CANT[data_1.PROTOCOL.Cant.Bound] = 'partiallytrapped';
111
- CANT[data_1.PROTOCOL.Cant.Flinch] = 'flinch';
112
- CANT[data_1.PROTOCOL.Cant.Recharge] = 'recharge';
113
- CANT[data_1.PROTOCOL.Cant.PP] = 'nopp';
114
- const DAMAGE = new Array(data_1.PROTOCOL.Damage.length);
115
- DAMAGE[data_1.PROTOCOL.Damage.Poison] = 'psn';
116
- DAMAGE[data_1.PROTOCOL.Damage.Burn] = 'brn';
117
- DAMAGE[data_1.PROTOCOL.Damage.Confusion] = 'confusion';
118
- DAMAGE[data_1.PROTOCOL.Damage.LeechSeed] = 'Leech Seed';
119
- DAMAGE[data_1.PROTOCOL.Damage.RecoilOf] = 'Recoil';
120
- const BOOSTS = new Array(data_1.PROTOCOL.Boost.length);
121
- BOOSTS[data_1.PROTOCOL.Boost.Rage] = 'atk';
122
- BOOSTS[data_1.PROTOCOL.Boost.Attack] = 'atk';
123
- BOOSTS[data_1.PROTOCOL.Boost.Defense] = 'def';
124
- BOOSTS[data_1.PROTOCOL.Boost.Speed] = 'spe';
125
- BOOSTS[data_1.PROTOCOL.Boost.SpecialAttack] = 'spa';
126
- BOOSTS[data_1.PROTOCOL.Boost.SpecialDefense] = 'spd';
127
- BOOSTS[data_1.PROTOCOL.Boost.Accuracy] = 'accuracy';
128
- BOOSTS[data_1.PROTOCOL.Boost.Evasion] = 'evasion';
129
- const FAIL = new Array(data_1.PROTOCOL.Fail.length);
130
- FAIL[data_1.PROTOCOL.Fail.Sleep] = 'slp';
131
- FAIL[data_1.PROTOCOL.Fail.Poison] = 'psn';
132
- FAIL[data_1.PROTOCOL.Fail.Burn] = 'brn';
133
- FAIL[data_1.PROTOCOL.Fail.Freeze] = 'frz';
134
- FAIL[data_1.PROTOCOL.Fail.Paralysis] = 'par';
135
- FAIL[data_1.PROTOCOL.Fail.Toxic] = 'tox';
136
- const ACTIVATE = [new Array(data_1.PROTOCOL.Activate.length)];
137
- ACTIVATE[0][data_1.PROTOCOL.Activate.Bide] = 'Bide';
138
- ACTIVATE[0][data_1.PROTOCOL.Activate.Confusion] = 'confusion';
139
- ACTIVATE[0][data_1.PROTOCOL.Activate.Haze] = 'move: Haze';
140
- ACTIVATE[0][data_1.PROTOCOL.Activate.Mist] = 'move: Mist';
141
- ACTIVATE[0][data_1.PROTOCOL.Activate.Struggle] = 'move: Struggle';
142
- ACTIVATE[0][data_1.PROTOCOL.Activate.Substitute] = 'Substitute';
143
- ACTIVATE[0][data_1.PROTOCOL.Activate.Splash] = 'move: Splash';
108
+ const CANT = new Array(data_2.PROTOCOL.Cant.length);
109
+ CANT[data_2.PROTOCOL.Cant.Sleep] = 'slp';
110
+ CANT[data_2.PROTOCOL.Cant.Freeze] = 'frz';
111
+ CANT[data_2.PROTOCOL.Cant.Paralysis] = 'par';
112
+ CANT[data_2.PROTOCOL.Cant.Bound] = 'partiallytrapped';
113
+ CANT[data_2.PROTOCOL.Cant.Flinch] = 'flinch';
114
+ CANT[data_2.PROTOCOL.Cant.Recharge] = 'recharge';
115
+ CANT[data_2.PROTOCOL.Cant.PP] = 'nopp';
116
+ const DAMAGE = new Array(data_2.PROTOCOL.Damage.length);
117
+ DAMAGE[data_2.PROTOCOL.Damage.Poison] = 'psn';
118
+ DAMAGE[data_2.PROTOCOL.Damage.Burn] = 'brn';
119
+ DAMAGE[data_2.PROTOCOL.Damage.Confusion] = 'confusion';
120
+ DAMAGE[data_2.PROTOCOL.Damage.LeechSeed] = 'Leech Seed';
121
+ DAMAGE[data_2.PROTOCOL.Damage.RecoilOf] = 'Recoil';
122
+ const BOOSTS = new Array(data_2.PROTOCOL.Boost.length);
123
+ BOOSTS[data_2.PROTOCOL.Boost.Rage] = 'atk';
124
+ BOOSTS[data_2.PROTOCOL.Boost.Attack] = 'atk';
125
+ BOOSTS[data_2.PROTOCOL.Boost.Defense] = 'def';
126
+ BOOSTS[data_2.PROTOCOL.Boost.Speed] = 'spe';
127
+ BOOSTS[data_2.PROTOCOL.Boost.SpecialAttack] = 'spa';
128
+ BOOSTS[data_2.PROTOCOL.Boost.SpecialDefense] = 'spd';
129
+ BOOSTS[data_2.PROTOCOL.Boost.Accuracy] = 'accuracy';
130
+ BOOSTS[data_2.PROTOCOL.Boost.Evasion] = 'evasion';
131
+ const FAIL = new Array(data_2.PROTOCOL.Fail.length);
132
+ FAIL[data_2.PROTOCOL.Fail.Sleep] = 'slp';
133
+ FAIL[data_2.PROTOCOL.Fail.Poison] = 'psn';
134
+ FAIL[data_2.PROTOCOL.Fail.Burn] = 'brn';
135
+ FAIL[data_2.PROTOCOL.Fail.Freeze] = 'frz';
136
+ FAIL[data_2.PROTOCOL.Fail.Paralysis] = 'par';
137
+ FAIL[data_2.PROTOCOL.Fail.Toxic] = 'tox';
138
+ const ACTIVATE = [new Array(data_2.PROTOCOL.Activate.length)];
139
+ ACTIVATE[0][data_2.PROTOCOL.Activate.Bide] = 'Bide';
140
+ ACTIVATE[0][data_2.PROTOCOL.Activate.Confusion] = 'confusion';
141
+ ACTIVATE[0][data_2.PROTOCOL.Activate.Haze] = 'move: Haze';
142
+ ACTIVATE[0][data_2.PROTOCOL.Activate.Mist] = 'move: Mist';
143
+ ACTIVATE[0][data_2.PROTOCOL.Activate.Struggle] = 'move: Struggle';
144
+ ACTIVATE[0][data_2.PROTOCOL.Activate.Substitute] = 'Substitute';
145
+ ACTIVATE[0][data_2.PROTOCOL.Activate.Splash] = 'move: Splash';
144
146
  ACTIVATE[1] = ACTIVATE[0].slice(0);
145
- ACTIVATE[1][data_1.PROTOCOL.Activate.Bide] = 'move: Bide';
146
- const START = [new Array(data_1.PROTOCOL.Start.length)];
147
- START[0][data_1.PROTOCOL.Start.Bide] = 'Bide';
148
- START[0][data_1.PROTOCOL.Start.Confusion] = 'confusion';
149
- START[0][data_1.PROTOCOL.Start.ConfusionSilent] = 'confusion';
150
- START[0][data_1.PROTOCOL.Start.FocusEnergy] = 'move: Focus Energy';
151
- START[0][data_1.PROTOCOL.Start.LeechSeed] = 'move: Leech Seed';
152
- START[0][data_1.PROTOCOL.Start.LightScreen] = 'Light Screen';
153
- START[0][data_1.PROTOCOL.Start.Mist] = 'Mist';
154
- START[0][data_1.PROTOCOL.Start.Reflect] = 'Reflect';
155
- START[0][data_1.PROTOCOL.Start.Substitute] = 'Substitute';
147
+ ACTIVATE[1][data_2.PROTOCOL.Activate.Bide] = 'move: Bide';
148
+ const START = [new Array(data_2.PROTOCOL.Start.length)];
149
+ START[0][data_2.PROTOCOL.Start.Bide] = 'Bide';
150
+ START[0][data_2.PROTOCOL.Start.Confusion] = 'confusion';
151
+ START[0][data_2.PROTOCOL.Start.ConfusionSilent] = 'confusion';
152
+ START[0][data_2.PROTOCOL.Start.FocusEnergy] = 'move: Focus Energy';
153
+ START[0][data_2.PROTOCOL.Start.LeechSeed] = 'move: Leech Seed';
154
+ START[0][data_2.PROTOCOL.Start.LightScreen] = 'Light Screen';
155
+ START[0][data_2.PROTOCOL.Start.Mist] = 'Mist';
156
+ START[0][data_2.PROTOCOL.Start.Reflect] = 'Reflect';
157
+ START[0][data_2.PROTOCOL.Start.Substitute] = 'Substitute';
156
158
  START[1] = START[0].slice(0);
157
- START[1][data_1.PROTOCOL.Start.Bide] = 'move: Bide';
158
- const END = [new Array(data_1.PROTOCOL.End.length)];
159
- END[0][data_1.PROTOCOL.End.Disable] = 'Disable';
160
- END[0][data_1.PROTOCOL.End.Confusion] = 'confusion';
161
- END[0][data_1.PROTOCOL.End.Bide] = 'Bide';
162
- END[0][data_1.PROTOCOL.End.Substitute] = 'Substitute';
163
- END[0][data_1.PROTOCOL.End.DisableSilent] = 'Disable';
164
- END[0][data_1.PROTOCOL.End.ConfusionSilent] = 'confusion';
165
- END[0][data_1.PROTOCOL.End.MistSilent] = 'Mist';
166
- END[0][data_1.PROTOCOL.End.FocusEnergySilent] = 'move: Focus Energy';
167
- END[0][data_1.PROTOCOL.End.LeechSeedSilent] = 'move: Leech Seed';
168
- END[0][data_1.PROTOCOL.End.ToxicSilent] = 'Toxic counter';
169
- END[0][data_1.PROTOCOL.End.LightScreenSilent] = 'Light Screen';
170
- END[0][data_1.PROTOCOL.End.ReflectSilent] = 'Reflect';
171
- END[0][data_1.PROTOCOL.End.BideSilent] = 'move: Bide';
159
+ START[1][data_2.PROTOCOL.Start.Bide] = 'move: Bide';
160
+ const END = [new Array(data_2.PROTOCOL.End.length)];
161
+ END[0][data_2.PROTOCOL.End.Disable] = 'Disable';
162
+ END[0][data_2.PROTOCOL.End.Confusion] = 'confusion';
163
+ END[0][data_2.PROTOCOL.End.Bide] = 'Bide';
164
+ END[0][data_2.PROTOCOL.End.Substitute] = 'Substitute';
165
+ END[0][data_2.PROTOCOL.End.DisableSilent] = 'Disable';
166
+ END[0][data_2.PROTOCOL.End.ConfusionSilent] = 'confusion';
167
+ END[0][data_2.PROTOCOL.End.MistSilent] = 'Mist';
168
+ END[0][data_2.PROTOCOL.End.FocusEnergySilent] = 'move: Focus Energy';
169
+ END[0][data_2.PROTOCOL.End.LeechSeedSilent] = 'move: Leech Seed';
170
+ END[0][data_2.PROTOCOL.End.ToxicSilent] = 'Toxic counter';
171
+ END[0][data_2.PROTOCOL.End.LightScreenSilent] = 'Light Screen';
172
+ END[0][data_2.PROTOCOL.End.ReflectSilent] = 'Reflect';
173
+ END[0][data_2.PROTOCOL.End.BideSilent] = 'move: Bide';
172
174
  END[1] = END[0].slice(0);
173
- END[1][data_1.PROTOCOL.End.Disable] = 'move: Disable';
174
- END[1][data_1.PROTOCOL.End.Bide] = 'move: Bide';
175
- END[1][data_1.PROTOCOL.End.LeechSeed] = 'Leech Seed';
176
- const SIDE = new Array(data_1.PROTOCOL.Side.length);
177
- SIDE[data_1.PROTOCOL.Side.Safeguard] = 'Safeguard';
178
- SIDE[data_1.PROTOCOL.Side.Reflect] = 'Reflect';
179
- SIDE[data_1.PROTOCOL.Side.LightScreen] = 'move: Light Screen';
180
- SIDE[data_1.PROTOCOL.Side.Spikes] = 'Spikes';
175
+ END[1][data_2.PROTOCOL.End.Disable] = 'move: Disable';
176
+ END[1][data_2.PROTOCOL.End.Bide] = 'move: Bide';
177
+ END[1][data_2.PROTOCOL.End.LeechSeed] = 'Leech Seed';
178
+ const SIDE = new Array(data_2.PROTOCOL.Side.length);
179
+ SIDE[data_2.PROTOCOL.Side.Safeguard] = 'Safeguard';
180
+ SIDE[data_2.PROTOCOL.Side.Reflect] = 'Reflect';
181
+ SIDE[data_2.PROTOCOL.Side.LightScreen] = 'move: Light Screen';
182
+ SIDE[data_2.PROTOCOL.Side.Spikes] = 'Spikes';
181
183
  const DECODERS = new Array(ArgType.length);
182
184
  DECODERS[ArgType.Move] = function (offset, data) {
183
185
  const source = decodeIdent(this.info, data.getUint8(offset++));
@@ -187,10 +189,10 @@ DECODERS[ArgType.Move] = function (offset, data) {
187
189
  const target = id === 0
188
190
  ? '' : `${player}a: ${(set.name || set.species)}`;
189
191
  const reason = data.getUint8(offset++);
190
- const move = reason === data_1.PROTOCOL.Move.Recharge
192
+ const move = reason === data_2.PROTOCOL.Move.Recharge
191
193
  ? 'recharge' : this.gen.moves.get(this.lookup.moveByNum(m)).name;
192
194
  const args = ['move', source, move, target];
193
- const kwArgs = reason === data_1.PROTOCOL.Move.From
195
+ const kwArgs = reason === data_2.PROTOCOL.Move.From
194
196
  ? { from: this.gen.moves.get(this.lookup.moveByNum(data.getUint8(offset++))).name } : {};
195
197
  return { offset, line: { args, kwArgs } };
196
198
  };
@@ -207,7 +209,7 @@ DECODERS[ArgType.Cant] = function (offset, data) {
207
209
  const ident = decodeIdent(this.info, data.getUint8(offset++));
208
210
  const reason = data.getUint8(offset++);
209
211
  let args;
210
- if (reason === data_1.PROTOCOL.Cant.Disable) {
212
+ if (reason === data_2.PROTOCOL.Cant.Disable) {
211
213
  const move = this.gen.moves.get(this.lookup.moveByNum(data.getUint8(offset++))).name;
212
214
  args = ['cant', ident, 'Disable', move];
213
215
  }
@@ -220,7 +222,7 @@ DECODERS[ArgType.Faint] = function (offset, data) {
220
222
  return decodeProtocol('faint', offset, data, this.info);
221
223
  };
222
224
  DECODERS[ArgType.Turn] = function (offset, data) {
223
- const turn = data.getUint16(offset, data_1.LE).toString();
225
+ const turn = data.getUint16(offset, data_2.LE).toString();
224
226
  offset += 2;
225
227
  return { offset, line: { args: ['turn', turn], kwArgs: {} } };
226
228
  };
@@ -239,9 +241,9 @@ DECODERS[ArgType.Damage] = function (offset, data) {
239
241
  offset += 5;
240
242
  const reason = data.getUint8(offset++);
241
243
  const kwArgs = {};
242
- if (reason > data_1.PROTOCOL.Damage.None)
244
+ if (reason > data_2.PROTOCOL.Damage.None)
243
245
  kwArgs.from = DAMAGE[reason];
244
- if (reason === data_1.PROTOCOL.Damage.RecoilOf) {
246
+ if (reason === data_2.PROTOCOL.Damage.RecoilOf) {
245
247
  kwArgs.of = decodeIdent(this.info, data.getUint8(offset++));
246
248
  }
247
249
  const args = ['-damage', ident, hpStatus];
@@ -253,11 +255,11 @@ DECODERS[ArgType.Heal] = function (offset, data) {
253
255
  offset += 5;
254
256
  const reason = data.getUint8(offset++);
255
257
  const kwArgs = {};
256
- if (reason === data_1.PROTOCOL.Heal.Drain) {
258
+ if (reason === data_2.PROTOCOL.Heal.Drain) {
257
259
  kwArgs.from = 'drain';
258
260
  kwArgs.of = decodeIdent(this.info, data.getUint8(offset++));
259
261
  }
260
- else if (reason === data_1.PROTOCOL.Heal.Silent) {
262
+ else if (reason === data_2.PROTOCOL.Heal.Silent) {
261
263
  kwArgs.silent = true;
262
264
  }
263
265
  const args = ['-heal', ident, hpStatus];
@@ -268,10 +270,10 @@ DECODERS[ArgType.Status] = function (offset, data) {
268
270
  const status = decodeStatus(data.getUint8(offset++));
269
271
  const reason = data.getUint8(offset++);
270
272
  const kwArgs = {};
271
- if (reason === data_1.PROTOCOL.Status.Silent) {
273
+ if (reason === data_2.PROTOCOL.Status.Silent) {
272
274
  kwArgs.silent = true;
273
275
  }
274
- else if (reason === data_1.PROTOCOL.Status.From) {
276
+ else if (reason === data_2.PROTOCOL.Status.From) {
275
277
  const move = this.gen.moves.get(this.lookup.moveByNum(data.getUint8(offset++))).name;
276
278
  kwArgs.from = `move: ${move}`;
277
279
  }
@@ -283,10 +285,10 @@ DECODERS[ArgType.CureStatus] = function (offset, data) {
283
285
  const status = decodeStatus(data.getUint8(offset++));
284
286
  const reason = data.getUint8(offset++);
285
287
  const kwArgs = {};
286
- if (reason === data_1.PROTOCOL.CureStatus.Message) {
288
+ if (reason === data_2.PROTOCOL.CureStatus.Message) {
287
289
  kwArgs.msg = true;
288
290
  }
289
- else if (reason === data_1.PROTOCOL.CureStatus.Silent) {
291
+ else if (reason === data_2.PROTOCOL.CureStatus.Silent) {
290
292
  kwArgs.silent = true;
291
293
  }
292
294
  const args = ['-curestatus', ident, status];
@@ -297,7 +299,7 @@ DECODERS[ArgType.Boost] = function (offset, data) {
297
299
  const reason = data.getUint8(offset++);
298
300
  const boost = BOOSTS[reason];
299
301
  const kwArgs = {};
300
- if (reason === data_1.PROTOCOL.Boost.Rage) {
302
+ if (reason === data_2.PROTOCOL.Boost.Rage) {
301
303
  kwArgs.from = 'Rage';
302
304
  }
303
305
  const n = data.getUint8(offset++) - 6;
@@ -316,13 +318,13 @@ DECODERS[ArgType.Fail] = function (offset, data) {
316
318
  const reason = data.getUint8(offset++);
317
319
  let args;
318
320
  const kwArgs = {};
319
- const weak = reason === data_1.PROTOCOL.Fail.Weak;
320
- if (weak || reason === data_1.PROTOCOL.Fail.Substitute) {
321
+ const weak = reason === data_2.PROTOCOL.Fail.Weak;
322
+ if (weak || reason === data_2.PROTOCOL.Fail.Substitute) {
321
323
  args = ['-fail', ident, 'move: Substitute'];
322
324
  if (weak)
323
325
  kwArgs.weak = true;
324
326
  }
325
- else if (reason !== data_1.PROTOCOL.Fail.None) {
327
+ else if (reason !== data_2.PROTOCOL.Fail.None) {
326
328
  args = ['-fail', ident, FAIL[reason]];
327
329
  }
328
330
  else {
@@ -351,12 +353,12 @@ DECODERS[ArgType.MustRecharge] = function (offset, data) {
351
353
  DECODERS[ArgType.Activate] = function (offset, data) {
352
354
  const ident = decodeIdent(this.info, data.getUint8(offset++));
353
355
  const reason = data.getUint8(offset++);
354
- const type = reason === data_1.PROTOCOL.Activate.Mist ? '-block' : '-activate';
356
+ const type = reason === data_2.PROTOCOL.Activate.Mist ? '-block' : '-activate';
355
357
  const activate = ACTIVATE[this.gen.num - 1];
356
- const args = reason === data_1.PROTOCOL.Activate.Splash
358
+ const args = reason === data_2.PROTOCOL.Activate.Splash
357
359
  ? [type, '', activate[reason]]
358
360
  : [type, ident, activate[reason], ''];
359
- const kwArgs = reason === data_1.PROTOCOL.Activate.Substitute ? { damage: true } : {};
361
+ const kwArgs = reason === data_2.PROTOCOL.Activate.Substitute ? { damage: true } : {};
360
362
  return { offset, line: { args, kwArgs } };
361
363
  };
362
364
  DECODERS[ArgType.FieldActivate] = function (offset) {
@@ -369,12 +371,12 @@ DECODERS[ArgType.Start] = function (offset, data) {
369
371
  const reason = data.getUint8(offset++);
370
372
  let args;
371
373
  const kwArgs = {};
372
- if (reason < data_1.PROTOCOL.Start.TypeChange) {
374
+ if (reason < data_2.PROTOCOL.Start.TypeChange) {
373
375
  args = ['-start', ident, START[this.gen.num - 1][reason]];
374
- if (reason === data_1.PROTOCOL.Start.ConfusionSilent)
376
+ if (reason === data_2.PROTOCOL.Start.ConfusionSilent)
375
377
  kwArgs.silent = true;
376
378
  }
377
- else if (reason === data_1.PROTOCOL.Start.TypeChange) {
379
+ else if (reason === data_2.PROTOCOL.Start.TypeChange) {
378
380
  const types = decodeTypes(this.lookup, data.getUint8(offset++));
379
381
  const t = types[0] === types[1] ? types[0] : types.join('/');
380
382
  args = ['-start', ident, 'typechange', t];
@@ -383,7 +385,7 @@ DECODERS[ArgType.Start] = function (offset, data) {
383
385
  }
384
386
  else {
385
387
  const move = this.gen.moves.get(this.lookup.moveByNum(data.getUint8(offset++))).name;
386
- const effect = reason === data_1.PROTOCOL.Start.Disable ? 'Disable' : 'Mimic';
388
+ const effect = reason === data_2.PROTOCOL.Start.Disable ? 'Disable' : 'Mimic';
387
389
  args = ['-start', ident, effect, move];
388
390
  }
389
391
  return { offset, line: { args, kwArgs } };
@@ -392,7 +394,7 @@ DECODERS[ArgType.End] = function (offset, data) {
392
394
  const ident = decodeIdent(this.info, data.getUint8(offset++));
393
395
  const reason = data.getUint8(offset++);
394
396
  const args = ['-end', ident, END[this.gen.num - 1][reason]];
395
- const kwArgs = reason >= data_1.PROTOCOL.End.DisableSilent ? { silent: true } : {};
397
+ const kwArgs = reason >= data_2.PROTOCOL.End.DisableSilent ? { silent: true } : {};
396
398
  return { offset, line: { args, kwArgs } };
397
399
  };
398
400
  DECODERS[ArgType.OHKO] = function (offset) {
@@ -410,7 +412,7 @@ DECODERS[ArgType.Resisted] = function (offset, data) {
410
412
  DECODERS[ArgType.Immune] = function (offset, data) {
411
413
  const ident = decodeIdent(this.info, data.getUint8(offset++));
412
414
  const reason = data.getUint8(offset++);
413
- const kwArgs = reason === data_1.PROTOCOL.Immune.OHKO ? { ohko: true } : {};
415
+ const kwArgs = reason === data_2.PROTOCOL.Immune.OHKO ? { ohko: true } : {};
414
416
  return { offset, line: { args: ['-immune', ident], kwArgs } };
415
417
  };
416
418
  DECODERS[ArgType.Transform] = function (offset, data) {
@@ -437,9 +439,9 @@ function decodeDetails(offset, data, gen, lookup) {
437
439
  return `${species}${mf}${lvl}`;
438
440
  }
439
441
  function decodeHPStatus(offset, data) {
440
- const hp = data.getUint16(offset, data_1.LE);
442
+ const hp = data.getUint16(offset, data_2.LE);
441
443
  offset += 2;
442
- const maxhp = data.getUint16(offset, data_1.LE);
444
+ const maxhp = data.getUint16(offset, data_2.LE);
443
445
  offset += 2;
444
446
  if (hp === 0)
445
447
  return '0 fnt';