@pkmn/engine 0.1.0-dev.a1fcc5d9 → 0.1.0-dev.a23f64f3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -4
- package/build/pkg/addon/browser.d.ts +1 -1
- package/build/pkg/addon/browser.js +2 -1
- package/build/pkg/addon/browser.js.map +1 -1
- package/build/pkg/addon/node.js +2 -1
- package/build/pkg/addon/node.js.map +1 -1
- package/build/pkg/addon/wasm.d.ts +2 -0
- package/build/pkg/addon/wasm.js +44 -0
- package/build/pkg/addon/wasm.js.map +1 -0
- package/build/pkg/addon.d.ts +23 -3
- package/build/pkg/addon.js +8 -17
- package/build/pkg/addon.js.map +1 -1
- package/build/pkg/data/layout.json +15 -2
- package/build/pkg/data/protocol.json +23 -9
- package/build/pkg/gen1.d.ts +13 -17
- package/build/pkg/gen1.js +6 -10
- package/build/pkg/gen1.js.map +1 -1
- package/build/pkg/index.d.ts +35 -100
- package/build/pkg/index.js +6 -68
- package/build/pkg/index.js.map +1 -1
- package/build/tools/debug.js +1 -2
- package/build/tools/debug.js.map +1 -1
- package/build/tools/display/index.js +17 -8
- package/build/tools/display/index.js.map +1 -1
- package/build/tools/display/ui.jsx.map +1 -1
- package/build.zig +112 -68
- package/package.json +20 -120
- package/src/bin/install-pkmn-engine +2 -2
- package/src/lib/common/options.zig +2 -0
- package/src/lib/common/protocol.zig +4 -8
- package/src/lib/common/rng.zig +1 -3
- package/src/lib/gen1/calc.zig +22 -48
- package/src/lib/gen1/chance.zig +34 -18
- package/src/lib/gen1/data/moves.zig +2 -4
- package/src/lib/gen1/data/species.zig +1 -3
- package/src/lib/gen1/data/types.zig +1 -2
- package/src/lib/gen1/data.zig +7 -11
- package/src/lib/gen1/helpers.zig +4 -10
- package/src/lib/gen1/mechanics.zig +65 -42
- package/src/lib/gen2/calc.zig +9 -17
- package/src/lib/gen2/data/items.zig +1 -3
- package/src/lib/gen2/data/moves.zig +2 -4
- package/src/lib/gen2/data/species.zig +1 -3
- package/src/lib/gen2/data/types.zig +1 -2
- package/src/lib/gen2/data.zig +11 -15
- package/src/lib/gen2/generated.zig +18 -23
- package/src/lib/gen2/helpers.zig +5 -12
- package/src/lib/gen2/mechanics.zig +41 -38
- package/src/lib/node.zig +2 -4
- package/src/lib/pkmn.zig +4 -0
- package/src/lib/wasm.zig +36 -1
- package/src/tools/display/ui.css +0 -5
package/README.md
CHANGED
|
@@ -212,18 +212,19 @@ protocol via `Log.parse`.
|
|
|
212
212
|
```ts
|
|
213
213
|
import {Dex} from '@pkmn/dex';
|
|
214
214
|
import {Generations} from '@pkmn/data';
|
|
215
|
-
import {Battle} from '@pkmn/engine';
|
|
215
|
+
import {Battle, Choice} from '@pkmn/engine';
|
|
216
216
|
|
|
217
217
|
const gens = new Generations(Dex);
|
|
218
218
|
const battle = Battle.create(...);
|
|
219
219
|
|
|
220
|
-
const choose = (
|
|
220
|
+
const choose = (choices: Choice[]) =>
|
|
221
|
+
choices[Math.floor(Math.random() * choices.length)];
|
|
221
222
|
|
|
222
223
|
let result: Result;
|
|
223
224
|
let c1: Choice, c2: Choice;
|
|
224
225
|
while (!(result = battle.update(c1, c2)).type) {
|
|
225
|
-
c1 = battle.
|
|
226
|
-
c2 = battle.
|
|
226
|
+
c1 = choose(battle.choices('p1', result));
|
|
227
|
+
c2 = choose(battle.choices('p2', result));
|
|
227
228
|
}
|
|
228
229
|
|
|
229
230
|
console.log(result);
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { Argument } from '../addon';
|
|
2
|
-
export declare function load(showdown: boolean, addon?: Argument): Promise<
|
|
2
|
+
export declare function load(showdown: boolean, addon?: Argument): Promise<import("../addon").Bindings<boolean>>;
|
|
3
3
|
export declare function loadSync(): void;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.load = load;
|
|
4
4
|
exports.loadSync = loadSync;
|
|
5
|
+
const wasm_1 = require("./wasm");
|
|
5
6
|
async function load(showdown, addon) {
|
|
6
7
|
if (typeof addon === 'string' && addon !== 'wasm') {
|
|
7
8
|
throw new Error('Unable to load native addons in the browser!');
|
|
@@ -35,7 +36,7 @@ async function load(showdown, addon) {
|
|
|
35
36
|
throw new Error(`${message}\n${err.message}`);
|
|
36
37
|
}
|
|
37
38
|
}
|
|
38
|
-
return wasm.exports;
|
|
39
|
+
return (0, wasm_1.toBindings)(wasm.exports);
|
|
39
40
|
}
|
|
40
41
|
function loadSync() {
|
|
41
42
|
throw new Error('You must `initialize` the WASM addon before using the engine!');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browser.js","sourceRoot":"","sources":["../../../src/pkg/addon/browser.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"browser.js","sourceRoot":"","sources":["../../../src/pkg/addon/browser.ts"],"names":[],"mappings":";;AAKA,oBA+BC;AAED,4BAEC;AArCD,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,MAAM,EAAE,CAAC;QACxC,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,CAAC;gBAAE,MAAM,GAAG,CAAC;YACvC,MAAM,IAAI,KAAK,CAAC,uCAAuC,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC;QACxE,CAAC;IACH,CAAC;SAAM,CAAC;QACN,MAAM,IAAI,GAAG,OAAO,QAAQ,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC;QACvD,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,CAAC,KAAK,IAAI,KAAK,KAAK,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC;gBACvD,CAAC,CAAE,KAAiC,YAAY,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;YAC7E,IAAI,GAAG,CAAC,MAAM,WAAW,CAAC,oBAAoB,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC;QACrE,CAAC;QAAC,OAAO,GAAG,EAAE,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,CAAC,CAAC;QAChD,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"}
|
package/build/pkg/addon/node.js
CHANGED
|
@@ -27,6 +27,7 @@ exports.load = load;
|
|
|
27
27
|
exports.loadSync = loadSync;
|
|
28
28
|
const fs = __importStar(require("fs"));
|
|
29
29
|
const path = __importStar(require("path"));
|
|
30
|
+
const wasm_1 = require("./wasm");
|
|
30
31
|
const ROOT = path.join(__dirname, '..', '..', '..');
|
|
31
32
|
const LIB = path.join(ROOT, 'build', 'lib');
|
|
32
33
|
const NODE = [path.join(LIB, 'pkmn.node'), path.join(LIB, 'pkmn-showdown.node')];
|
|
@@ -77,7 +78,7 @@ async function load(showdown, addon) {
|
|
|
77
78
|
throw new Error(`Could not instantiate WASM module!\n${err.message}`);
|
|
78
79
|
}
|
|
79
80
|
}
|
|
80
|
-
return wasm.exports;
|
|
81
|
+
return (0, wasm_1.toBindings)(wasm.exports);
|
|
81
82
|
}
|
|
82
83
|
function loadSync(showdown) {
|
|
83
84
|
try {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.js","sourceRoot":"","sources":["../../../src/pkg/addon/node.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"node.js","sourceRoot":"","sources":["../../../src/pkg/addon/node.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAcA,oBAuCC;AAED,4BAMC;AA5DD,uCAAyB;AACzB,2CAA6B;AAI7B,iCAAkC;AAElC,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;AACpD,MAAM,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;AAE5C,MAAM,IAAI,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,WAAW,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,oBAAoB,CAAC,CAAC,CAAC;AACjF,MAAM,IAAI,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,WAAW,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,oBAAoB,CAAC,CAAC,CAAC;AAE1E,KAAK,UAAU,IAAI,CAAC,QAAiB,EAAE,KAAgB;IAC5D,IAAI,KAAK,KAAK,SAAS,IAAI,OAAO,KAAK,KAAK,Q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});
|
|
3
|
+
exports.toBindings = toBindings;
|
|
4
|
+
const data_1 = require("../data");
|
|
5
|
+
function toBindings(w) {
|
|
6
|
+
return {
|
|
7
|
+
options: {
|
|
8
|
+
showdown: w.SHOWDOWN.valueOf(),
|
|
9
|
+
log: w.LOG.valueOf(),
|
|
10
|
+
chance: w.CHANCE.valueOf(),
|
|
11
|
+
calc: w.CALC.valueOf(),
|
|
12
|
+
},
|
|
13
|
+
bindings: [toBinding(1, w)],
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
function toBinding(gen, w) {
|
|
17
|
+
const prefix = `GEN${gen}`;
|
|
18
|
+
const size = data_1.LAYOUT[gen - 1].sizes.Battle;
|
|
19
|
+
const update = w[`${prefix}_update`];
|
|
20
|
+
const choices = w[`${prefix}_choices`];
|
|
21
|
+
const memory = new Uint8Array(w.memory.buffer);
|
|
22
|
+
return {
|
|
23
|
+
CHOICES_SIZE: w[`${prefix}_CHOICES_SIZE`].valueOf(),
|
|
24
|
+
LOGS_SIZE: w[`${prefix}_LOGS_SIZE`].valueOf(),
|
|
25
|
+
update(battle, c1, c2, log) {
|
|
26
|
+
memory.set(battle);
|
|
27
|
+
if (log) {
|
|
28
|
+
memory.set(log, size);
|
|
29
|
+
return update(0, c1, c2, size);
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
return update(0, c1, c2, 0);
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
choices(battle, player, request, options) {
|
|
36
|
+
memory.set(battle);
|
|
37
|
+
const n = choices(0, player, request, size);
|
|
38
|
+
for (let i = 0; i < n; i++)
|
|
39
|
+
options[i] = memory[size + i];
|
|
40
|
+
return n;
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=wasm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wasm.js","sourceRoot":"","sources":["../../../src/pkg/addon/wasm.ts"],"names":[],"mappings":";;AAGA,gCA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,CAAC,CAAC;YACjC,CAAC;iBAAM,CAAC;gBACN,OAAO,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC;YAC9B,CAAC;QACH,CAAC;QACD,OAAO,CAAC,MAAmB,EAAE,MAAc,EAAE,OAAe,EAAE,OAAmB;YAC/E,MAAM,CAAC,GAAG,CAAC,MAAa,CAAC,CAAC;YAC1B,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;YAC5C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE;gBAAE,OAAO,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC;YAC1D,OAAO,CAAC,CAAC;QACX,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/build/pkg/addon.d.ts
CHANGED
|
@@ -1,9 +1,29 @@
|
|
|
1
|
-
import { Choice, Player, Result } from '
|
|
1
|
+
import { Choice, Player, Result } from './common';
|
|
2
2
|
export type Argument = string | URL | WebAssembly.Module | Promise<Response>;
|
|
3
|
+
export interface Bindings<T extends boolean> {
|
|
4
|
+
/**
|
|
5
|
+
* The compile-time options the bindings were built with. showdown is special
|
|
6
|
+
* cased because it changes the name of addon.
|
|
7
|
+
*/
|
|
8
|
+
options: {
|
|
9
|
+
showdown: T;
|
|
10
|
+
log: boolean;
|
|
11
|
+
chance: boolean;
|
|
12
|
+
calc: boolean;
|
|
13
|
+
};
|
|
14
|
+
/** Bindings are per-generation, Generation I is index 0. */
|
|
15
|
+
bindings: Binding[];
|
|
16
|
+
}
|
|
17
|
+
export interface Binding {
|
|
18
|
+
CHOICES_SIZE: number;
|
|
19
|
+
LOGS_SIZE: number;
|
|
20
|
+
update(battle: ArrayBuffer, c1: number, c2: number, log: ArrayBuffer | undefined): number;
|
|
21
|
+
choices(battle: ArrayBuffer, player: number, request: number, out: ArrayBuffer): number;
|
|
22
|
+
}
|
|
23
|
+
/** TODO */
|
|
3
24
|
export declare function initialize(showdown: boolean, addon?: Argument): Promise<void | undefined>;
|
|
4
25
|
export declare function check(showdown: boolean): void;
|
|
5
26
|
export declare function supports(showdown: boolean, log?: boolean): boolean;
|
|
6
27
|
export declare function update(index: number, showdown: boolean, battle: ArrayBuffer, c1?: Choice, c2?: Choice, log?: ArrayBuffer): Result;
|
|
7
|
-
export declare function choices(index: number, showdown: boolean, battle: ArrayBuffer, player: Player, choice: Choice['type'],
|
|
8
|
-
export declare function choose(index: number, showdown: boolean, battle: ArrayBuffer, player: Player, choice: Choice['type'], buf: ArrayBuffer, fn: (n: number) => number): Choice;
|
|
28
|
+
export declare function choices(index: number, showdown: boolean, battle: ArrayBuffer, player: Player, choice: Choice['type'], out: Uint8Array): Choice[];
|
|
9
29
|
export declare function size(index: number, type: 'choices' | 'log'): number;
|
package/build/pkg/addon.js
CHANGED
|
@@ -5,12 +5,12 @@ exports.check = check;
|
|
|
5
5
|
exports.supports = supports;
|
|
6
6
|
exports.update = update;
|
|
7
7
|
exports.choices = choices;
|
|
8
|
-
exports.choose = choose;
|
|
9
8
|
exports.size = size;
|
|
10
9
|
const node_1 = require("./addon/node");
|
|
11
|
-
const
|
|
10
|
+
const common_1 = require("./common");
|
|
12
11
|
const ADDONS = [];
|
|
13
12
|
const loading = [];
|
|
13
|
+
/** TODO */
|
|
14
14
|
async function initialize(showdown, addon) {
|
|
15
15
|
if (loading[+showdown]) {
|
|
16
16
|
throw new Error(`Cannot call initialize more than once with showdown=${showdown}`);
|
|
@@ -47,12 +47,12 @@ function addons(showdown) {
|
|
|
47
47
|
return ADDONS;
|
|
48
48
|
}
|
|
49
49
|
function update(index, showdown, battle, c1, c2, log) {
|
|
50
|
-
return
|
|
51
|
-
.update(battle,
|
|
50
|
+
return common_1.Result.decode(ADDONS[+showdown].bindings[index]
|
|
51
|
+
.update(battle, common_1.Choice.encode(c1), common_1.Choice.encode(c2), log));
|
|
52
52
|
}
|
|
53
|
-
function choices(index, showdown, battle, player, choice,
|
|
53
|
+
function choices(index, showdown, battle, player, choice, out) {
|
|
54
54
|
const request = choice[0] === 'p' ? 0 : choice[0] === 'm' ? 1 : 2;
|
|
55
|
-
const n = ADDONS[+showdown].bindings[index].choices(battle, +(player !== 'p1'), request,
|
|
55
|
+
const n = ADDONS[+showdown].bindings[index].choices(battle, +(player !== 'p1'), request, out.buffer);
|
|
56
56
|
// The top-level API signature means our hands our tied with respect to
|
|
57
57
|
// writing really fast bindings here. The simplest approach would be to return
|
|
58
58
|
// the ArrayBuffer the bindings populate as well as its size and only decode a
|
|
@@ -67,21 +67,12 @@ function choices(index, showdown, battle, player, choice, buf) {
|
|
|
67
67
|
// choices function for each generation within node.zig. We could do something
|
|
68
68
|
// really galaxy-brained and return some sort of frankenstein subclass of
|
|
69
69
|
// Array backed by ArrayBuffer which would lazily decode the Choice on access,
|
|
70
|
-
// but thats ultimately not worth the effort.
|
|
71
|
-
// idiomatic API and performance here, hence why the choose function below
|
|
72
|
-
// exists.
|
|
70
|
+
// but thats ultimately not worth the effort.
|
|
73
71
|
const options = new Array(n);
|
|
74
|
-
const data = new Uint8Array(buf);
|
|
75
72
|
for (let i = 0; i < n; i++)
|
|
76
|
-
options[i] =
|
|
73
|
+
options[i] = common_1.Choice.decode(out[i]);
|
|
77
74
|
return options;
|
|
78
75
|
}
|
|
79
|
-
function choose(index, showdown, battle, player, choice, buf, fn) {
|
|
80
|
-
const request = choice[0] === 'p' ? 0 : choice[0] === 'm' ? 1 : 2;
|
|
81
|
-
const n = ADDONS[+showdown].bindings[index].choices(battle, +(player !== 'p1'), request, buf);
|
|
82
|
-
const data = new Uint8Array(buf);
|
|
83
|
-
return _1.Choice.decode(data[fn(n)]);
|
|
84
|
-
}
|
|
85
76
|
function size(index, type) {
|
|
86
77
|
const bindings = (ADDONS[1] ?? ADDONS[0]).bindings[index];
|
|
87
78
|
return type[0] === 'c' ? bindings.CHOICES_SIZE : bindings.LOGS_SIZE;
|
package/build/pkg/addon.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"addon.js","sourceRoot":"","sources":["../../src/pkg/addon.ts"],"names":[],"mappings":";;AA0BA,gCAWC;AAED,sBASC;AAED,4BAIC;AASD,wBAUC;AAED,
|
|
1
|
+
{"version":3,"file":"addon.js","sourceRoot":"","sources":["../../src/pkg/addon.ts"],"names":[],"mappings":";;AA0BA,gCAWC;AAED,sBASC;AAED,4BAIC;AASD,wBAUC;AAED,0BA6BC;AAED,oBAGC;AA7GD,uCAA4C;AAC5C,qCAAgD;AAqBhD,MAAM,MAAM,GAAwC,EAAE,CAAC;AACvD,MAAM,OAAO,GAA0D,EAAE,CAAC;AAE1E,WAAW;AACJ,KAAK,UAAU,UAAU,CAAC,QAAiB,EAAE,KAAgB;IAClE,IAAI,OAAO,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC;QACvB,MAAM,IAAI,KAAK,CAAC,uDAAuD,QAAQ,EAAE,CAAC,CAAC;IACrF,CAAC;IACD,OAAO,CAAC,CAAC,QAAQ,CAAC,GAAG,IAAA,WAAI,EAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;IAC3C,OAAO,CAAC,CAAC,QAAQ,CAAE,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE;QAC3B,MAAM,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;IACxB,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE;QACZ,OAAO,CAAC,CAAC,QAAQ,CAAC,GAAG,SAAS,CAAC;IACjC,CAAC,CAAC,CAAC;IACH,OAAO,OAAO,CAAC,CAAC,QAAQ,CAAC,EAAE,IAAI,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;AAC5C,CAAC;AAED,SAAgB,KAAK,CAAC,QAAiB;IACrC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC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C,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC;AACtE,CAAC"}
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
"Pokemon": 24,
|
|
7
7
|
"ActivePokemon": 32,
|
|
8
8
|
"Actions": 16,
|
|
9
|
+
"Durations": 8,
|
|
9
10
|
"Summaries": 12
|
|
10
11
|
},
|
|
11
12
|
"offsets": {
|
|
@@ -92,12 +93,24 @@
|
|
|
92
93
|
"confused": 16,
|
|
93
94
|
"paralyzed": 18,
|
|
94
95
|
"duration": 20,
|
|
95
|
-
"
|
|
96
|
-
"
|
|
96
|
+
"sleep": 24,
|
|
97
|
+
"confusion": 26,
|
|
98
|
+
"disable": 29,
|
|
99
|
+
"attacking": 31,
|
|
100
|
+
"binding": 33,
|
|
101
|
+
"move_slot": 36,
|
|
102
|
+
"pp": 40,
|
|
97
103
|
"multi_hit": 44,
|
|
98
104
|
"psywave": 48,
|
|
99
105
|
"metronome": 56
|
|
100
106
|
},
|
|
107
|
+
"Duration": {
|
|
108
|
+
"sleeps": 0,
|
|
109
|
+
"confusion": 18,
|
|
110
|
+
"disable": 21,
|
|
111
|
+
"attacking": 25,
|
|
112
|
+
"binding": 28
|
|
113
|
+
},
|
|
101
114
|
"Damage": {
|
|
102
115
|
"base": 0,
|
|
103
116
|
"final": 2,
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"EndAbility",
|
|
49
49
|
"ClearNegativeBoost",
|
|
50
50
|
"FormeChange",
|
|
51
|
-
"
|
|
51
|
+
"LastNoTarget",
|
|
52
52
|
"SwapBoost",
|
|
53
53
|
"FieldStart",
|
|
54
54
|
"FieldEnd",
|
|
@@ -71,6 +71,7 @@
|
|
|
71
71
|
"ClearPositiveBoost",
|
|
72
72
|
"CanDynamax",
|
|
73
73
|
"SwapSideConditions",
|
|
74
|
+
"UpdatePoke",
|
|
74
75
|
"Terastallize"
|
|
75
76
|
],
|
|
76
77
|
"Move": [
|
|
@@ -92,7 +93,10 @@
|
|
|
92
93
|
"None",
|
|
93
94
|
"Silent",
|
|
94
95
|
"Drain",
|
|
95
|
-
"Leftovers"
|
|
96
|
+
"Leftovers",
|
|
97
|
+
"Berry",
|
|
98
|
+
"BerryJuice",
|
|
99
|
+
"GoldBerry"
|
|
96
100
|
],
|
|
97
101
|
"Damage": [
|
|
98
102
|
"None",
|
|
@@ -106,7 +110,10 @@
|
|
|
106
110
|
"FireSpin",
|
|
107
111
|
"Clamp",
|
|
108
112
|
"Whirlpool",
|
|
109
|
-
"Spikes"
|
|
113
|
+
"Spikes",
|
|
114
|
+
"Nightmare",
|
|
115
|
+
"Curse",
|
|
116
|
+
"Sandstorm"
|
|
110
117
|
],
|
|
111
118
|
"Status": [
|
|
112
119
|
"None",
|
|
@@ -146,6 +153,7 @@
|
|
|
146
153
|
"Struggle",
|
|
147
154
|
"Substitute",
|
|
148
155
|
"Splash",
|
|
156
|
+
"Rage",
|
|
149
157
|
"Attract",
|
|
150
158
|
"LockOn",
|
|
151
159
|
"Bind",
|
|
@@ -153,7 +161,11 @@
|
|
|
153
161
|
"FireSpin",
|
|
154
162
|
"Clamp",
|
|
155
163
|
"Whirlpool",
|
|
156
|
-
"
|
|
164
|
+
"SubstituteBlock",
|
|
165
|
+
"DestinyBond",
|
|
166
|
+
"BeatUp",
|
|
167
|
+
"Magnitude",
|
|
168
|
+
"Spite"
|
|
157
169
|
],
|
|
158
170
|
"Start": [
|
|
159
171
|
"Bide",
|
|
@@ -168,16 +180,17 @@
|
|
|
168
180
|
"TypeChange",
|
|
169
181
|
"Disable",
|
|
170
182
|
"Mimic",
|
|
183
|
+
"Attract",
|
|
171
184
|
"Nightmare",
|
|
172
185
|
"Curse",
|
|
173
186
|
"Foresight",
|
|
174
187
|
"Encore",
|
|
175
188
|
"FutureSight",
|
|
176
|
-
"
|
|
177
|
-
"PerishSong3",
|
|
178
|
-
"PerishSong2",
|
|
189
|
+
"PerishSong0",
|
|
179
190
|
"PerishSong1",
|
|
180
|
-
"
|
|
191
|
+
"PerishSong2",
|
|
192
|
+
"PerishSong3",
|
|
193
|
+
"PerishSong3Silent"
|
|
181
194
|
],
|
|
182
195
|
"End": [
|
|
183
196
|
"Disable",
|
|
@@ -203,7 +216,8 @@
|
|
|
203
216
|
"ToxicSilent",
|
|
204
217
|
"LightScreenSilent",
|
|
205
218
|
"ReflectSilent",
|
|
206
|
-
"BideSilent"
|
|
219
|
+
"BideSilent",
|
|
220
|
+
"LeechSeedFrom"
|
|
207
221
|
],
|
|
208
222
|
"Immune": [
|
|
209
223
|
"None",
|
package/build/pkg/gen1.d.ts
CHANGED
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
import { BoostID, BoostsTable, Generation, ID, PokemonSet, StatID, StatsTable, StatusName, TypeName } from '@pkmn/data';
|
|
2
|
+
import { Choice, Player, Result } from './common';
|
|
2
3
|
import { Lookup } from './data';
|
|
3
|
-
import {
|
|
4
|
+
import { CreateOptions, Data, Gen1, RestoreOptions, Slot } from '.';
|
|
4
5
|
export declare class Battle implements Gen1.Battle {
|
|
5
6
|
readonly config: CreateOptions | RestoreOptions;
|
|
6
7
|
readonly log?: DataView;
|
|
7
8
|
private readonly lookup;
|
|
8
9
|
private readonly data;
|
|
9
|
-
private readonly
|
|
10
|
-
private readonly buf;
|
|
10
|
+
private readonly out;
|
|
11
11
|
private readonly cache;
|
|
12
12
|
constructor(lookup: Lookup, data: DataView, config: CreateOptions | RestoreOptions);
|
|
13
13
|
update(c1?: Choice, c2?: Choice): Result;
|
|
14
14
|
choices(id: Player, result: Result): Choice[];
|
|
15
|
-
choose(id: Player, result: Result, fn: (n: number) => number): Choice;
|
|
16
15
|
get sides(): Generator<Side, void, unknown>;
|
|
17
|
-
_sides
|
|
16
|
+
private _sides;
|
|
18
17
|
side(id: Player): Side;
|
|
19
18
|
foe(side: Player): Side;
|
|
20
19
|
get turn(): number;
|
|
@@ -34,16 +33,16 @@ export declare class Side implements Gen1.Side {
|
|
|
34
33
|
constructor(battle: Battle, lookup: Lookup, data: DataView, id: 'p1' | 'p2');
|
|
35
34
|
get active(): Pokemon | undefined;
|
|
36
35
|
get pokemon(): Generator<Pokemon, void, unknown>;
|
|
37
|
-
_pokemon
|
|
36
|
+
private _pokemon;
|
|
38
37
|
slot(id: number): Slot | undefined;
|
|
39
38
|
get(slot: Slot): Pokemon | undefined;
|
|
40
39
|
get lastUsedMove(): ID | undefined;
|
|
41
40
|
get lastSelectedMove(): ID | undefined;
|
|
42
41
|
get lastMoveIndex(): 1 | 2 | 3 | 4 | undefined;
|
|
43
42
|
get lastMoveCounterable(): boolean;
|
|
44
|
-
toJSON(): Gen1.Side
|
|
43
|
+
toJSON(): Data<Gen1.Side>;
|
|
45
44
|
static init(gen: Generation, lookup: Lookup, team: Partial<PokemonSet>[], data: DataView, offset: number): void;
|
|
46
|
-
static encode(gen: Generation, showdown: boolean, lookup: Lookup, battle: Data<Gen1.Battle>, side: Gen1.Side
|
|
45
|
+
static encode(gen: Generation, showdown: boolean, lookup: Lookup, battle: Data<Gen1.Battle>, side: Data<Gen1.Side>, data: DataView, offset: number): void;
|
|
47
46
|
}
|
|
48
47
|
export declare class Pokemon implements Gen1.Pokemon {
|
|
49
48
|
static Volatiles: {
|
|
@@ -64,7 +63,7 @@ export declare class Pokemon implements Gen1.Pokemon {
|
|
|
64
63
|
get volatiles(): Gen1.Volatiles;
|
|
65
64
|
move(slot: 1 | 2 | 3 | 4): Gen1.MoveSlot | undefined;
|
|
66
65
|
get moves(): Iterable<Gen1.MoveSlot>;
|
|
67
|
-
_moves
|
|
66
|
+
private _moves;
|
|
68
67
|
boost(boost: BoostID): number;
|
|
69
68
|
get boosts(): BoostsTable;
|
|
70
69
|
get species(): ID;
|
|
@@ -80,10 +79,10 @@ export declare class Pokemon implements Gen1.Pokemon {
|
|
|
80
79
|
private get sleep();
|
|
81
80
|
private get ext();
|
|
82
81
|
private get toxic();
|
|
83
|
-
toJSON(): Gen1.Pokemon
|
|
82
|
+
toJSON(): Data<Gen1.Pokemon>;
|
|
84
83
|
static init(gen: Generation, lookup: Lookup, set: Partial<PokemonSet>, data: DataView, offset: number, index: number): void;
|
|
85
|
-
static encodeStored(gen: Generation, showdown: boolean, lookup: Lookup, pokemon: Gen1.Pokemon
|
|
86
|
-
static encodeActive(gen: Generation, lookup: Lookup, battle: Data<Gen1.Battle>, pokemon: Gen1.Pokemon | undefined, data: DataView, offset: number): void;
|
|
84
|
+
static encodeStored(gen: Generation, showdown: boolean, lookup: Lookup, pokemon: Data<Gen1.Pokemon>, data: DataView, offset: number): void;
|
|
85
|
+
static encodeActive(gen: Generation, lookup: Lookup, battle: Data<Gen1.Battle>, pokemon: Data<Gen1.Pokemon> | undefined, data: DataView, offset: number): void;
|
|
87
86
|
}
|
|
88
87
|
export declare class StoredPokemon {
|
|
89
88
|
private readonly lookup;
|
|
@@ -100,11 +99,8 @@ export declare class StoredPokemon {
|
|
|
100
99
|
id: ID;
|
|
101
100
|
pp: number;
|
|
102
101
|
}, void, unknown>;
|
|
103
|
-
_moves
|
|
104
|
-
id: ID;
|
|
105
|
-
pp: number;
|
|
106
|
-
}, void, unknown>;
|
|
102
|
+
private _moves;
|
|
107
103
|
get species(): ID;
|
|
108
104
|
get types(): readonly [TypeName, TypeName];
|
|
109
|
-
toJSON(): Gen1.Pokemon['stored']
|
|
105
|
+
toJSON(): Data<Gen1.Pokemon['stored']>;
|
|
110
106
|
}
|
package/build/pkg/gen1.js
CHANGED
|
@@ -43,26 +43,22 @@ class Battle {
|
|
|
43
43
|
log;
|
|
44
44
|
lookup;
|
|
45
45
|
data;
|
|
46
|
-
|
|
47
|
-
buf;
|
|
46
|
+
out;
|
|
48
47
|
cache;
|
|
49
48
|
constructor(lookup, data, config) {
|
|
50
49
|
this.config = config;
|
|
51
50
|
this.lookup = lookup;
|
|
52
51
|
this.data = data;
|
|
53
|
-
this.
|
|
54
|
-
|
|
55
|
-
this.log = config.log ? new DataView(
|
|
52
|
+
this.out =
|
|
53
|
+
new Uint8Array(new ArrayBuffer('inert' in config ? 0 : addon.size(0, 'choices')));
|
|
54
|
+
this.log = config.log ? new DataView(new ArrayBuffer(addon.size(0, 'log'))) : undefined;
|
|
56
55
|
this.cache = [undefined, undefined];
|
|
57
56
|
}
|
|
58
57
|
update(c1, c2) {
|
|
59
|
-
return addon.update(0, !!this.config.showdown, this.data.buffer, c1, c2, this.
|
|
58
|
+
return addon.update(0, !!this.config.showdown, this.data.buffer, c1, c2, this.log?.buffer);
|
|
60
59
|
}
|
|
61
60
|
choices(id, result) {
|
|
62
|
-
return addon.choices(0, !!this.config.showdown, this.data.buffer, id, result[id], this.
|
|
63
|
-
}
|
|
64
|
-
choose(id, result, fn) {
|
|
65
|
-
return addon.choose(0, !!this.config.showdown, this.data.buffer, id, result[id], this.options, fn);
|
|
61
|
+
return addon.choices(0, !!this.config.showdown, this.data.buffer, id, result[id], this.out);
|
|
66
62
|
}
|
|
67
63
|
get sides() {
|
|
68
64
|
return this._sides();
|