@pkmn/engine 0.1.0-dev.6195e056 → 0.1.0-dev.631762fb
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/LICENSE +1 -3
- package/README.md +190 -78
- package/build/pkg/addon/browser.d.ts +3 -0
- package/build/pkg/addon/browser.js +47 -0
- package/build/pkg/addon/browser.js.map +1 -0
- package/build/pkg/addon/node.d.ts +3 -0
- package/build/pkg/addon/node.js +110 -0
- package/build/pkg/addon/node.js.map +1 -0
- package/build/pkg/addon/wasm.d.ts +2 -0
- package/build/pkg/addon/wasm.js +53 -0
- package/build/pkg/addon/wasm.js.map +1 -0
- package/build/pkg/addon.d.ts +29 -0
- package/build/pkg/addon.js +80 -0
- package/build/pkg/addon.js.map +1 -0
- package/build/pkg/data/ids.json +12 -12
- package/build/pkg/data/layout.json +40 -5
- package/build/pkg/data/protocol.json +84 -13
- package/build/pkg/data.d.ts +28 -7
- package/build/pkg/data.js +3 -5
- package/build/pkg/data.js.map +1 -1
- package/build/pkg/gen1.d.ts +18 -20
- package/build/pkg/gen1.js +76 -51
- package/build/pkg/gen1.js.map +1 -1
- package/build/pkg/index.d.ts +57 -103
- package/build/pkg/index.js +23 -70
- package/build/pkg/index.js.map +1 -1
- package/build/pkg/protocol.d.ts +24 -3
- package/build/pkg/protocol.js +127 -104
- package/build/pkg/protocol.js.map +1 -1
- package/build/tools/debug.js +110 -0
- package/build/tools/debug.js.map +1 -0
- package/build/tools/display/debug.jsx +152 -0
- package/build/tools/display/debug.jsx.map +1 -0
- package/build/tools/display/index.js +152 -0
- package/build/tools/display/index.js.map +1 -0
- package/build/tools/display/ui.jsx +359 -0
- package/build/tools/display/ui.jsx.map +1 -0
- package/build/tools/display/util.js +33 -0
- package/build/tools/display/util.js.map +1 -0
- package/build.zig +417 -160
- package/package.json +93 -133
- package/src/bin/install-pkmn-engine +85 -42
- package/src/bin/pkmn-debug +62 -0
- package/src/lib/bindings/c.zig +255 -0
- package/src/lib/bindings/node.zig +117 -0
- package/src/lib/bindings/wasm.zig +59 -0
- package/src/lib/common/array.zig +77 -0
- package/src/lib/common/battle.zig +17 -0
- package/src/lib/common/data.zig +19 -31
- package/src/lib/common/debug.zig +105 -0
- package/src/lib/common/js.zig +116 -0
- package/src/lib/common/optional.zig +71 -0
- package/src/lib/common/options.zig +18 -3
- package/src/lib/common/protocol.zig +947 -407
- package/src/lib/common/rational.zig +597 -0
- package/src/lib/common/rng.zig +31 -24
- package/src/lib/common/util.zig +76 -0
- package/src/lib/gen1/calc.zig +962 -0
- package/src/lib/gen1/chance.zig +1185 -0
- package/src/lib/gen1/data/moves.zig +203 -193
- package/src/lib/gen1/data/species.zig +6 -8
- package/src/lib/gen1/data/types.zig +11 -12
- package/src/lib/gen1/data.zig +101 -90
- package/src/lib/gen1/helpers.zig +139 -54
- package/src/lib/gen1/mechanics.zig +1445 -924
- package/src/lib/gen2/calc.zig +153 -0
- package/src/lib/gen2/chance.zig +902 -0
- package/src/lib/gen2/data/items.zig +15 -23
- package/src/lib/gen2/data/moves.zig +665 -573
- package/src/lib/gen2/data/species.zig +3 -5
- package/src/lib/gen2/data/types.zig +141 -36
- package/src/lib/gen2/data.zig +137 -101
- package/src/lib/gen2/generated.zig +801 -0
- package/src/lib/gen2/helpers.zig +59 -44
- package/src/lib/gen2/mechanics.zig +3582 -30
- package/src/lib/node.zig +14 -0
- package/src/lib/pkmn.zig +93 -12
- package/src/lib/wasm.zig +17 -0
- package/src/tools/display/dom.ts +93 -0
- package/src/tools/display/ui.css +354 -0
- package/src/lib/binding/node.zig +0 -229
- package/src/lib/binding/wasm.zig +0 -10
- package/src/lib/gen1/README.md +0 -777
- package/src/lib/gen2/README.md +0 -309
package/build/pkg/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { BoostsTable, Generation, ID, PokemonSet, StatsTable, StatusName, TypeName } from '@pkmn/data';
|
|
2
|
-
|
|
3
|
-
export type Player = 'p1' | 'p2';
|
|
1
|
+
import { BoostID, BoostsTable, Generation, ID, PokemonSet, StatID, StatsTable, StatusName, TypeName } from '@pkmn/data';
|
|
2
|
+
import { Choice, Player, Result } from './common';
|
|
4
3
|
/** The one-indexed location of a player's Pokémon in battle. */
|
|
5
4
|
export type Slot = 1 | 2 | 3 | 4 | 5 | 6;
|
|
6
5
|
/** Representation of the entire state of a Pokémon battle. */
|
|
@@ -14,10 +13,13 @@ export type MoveSlot = Gen1.MoveSlot;
|
|
|
14
13
|
/** Generic API supported by all Generations of Battle. */
|
|
15
14
|
export interface API {
|
|
16
15
|
/**
|
|
17
|
-
* The most recent buffer of binary protocol
|
|
18
|
-
* if
|
|
16
|
+
* The most recent buffer of binary protocol message log data filled by
|
|
17
|
+
* `update` if logging is enabled, otherwise undefined. Meant to be parsed by
|
|
18
|
+
* `Log`.
|
|
19
19
|
*/
|
|
20
20
|
log?: DataView;
|
|
21
|
+
/** FIXME */
|
|
22
|
+
bytes(): DataView;
|
|
21
23
|
/**
|
|
22
24
|
* Returns the result of applying Player 1's choice `c1` and Player 2's choice
|
|
23
25
|
* `c2` to the battle.
|
|
@@ -33,31 +35,25 @@ export interface API {
|
|
|
33
35
|
* soft-lock occurs).
|
|
34
36
|
*/
|
|
35
37
|
choices(player: Player, result: Result): Choice[];
|
|
36
|
-
/**
|
|
37
|
-
* Determines all possible choices for the `player` given the previous
|
|
38
|
-
* `result` of an {@link update} and calls a selection function `fn` with the
|
|
39
|
-
* number of possible choices `n`, returning the choice corresponding with the
|
|
40
|
-
* index it returns. `fn` must return an index in the range `[0, n)`.
|
|
41
|
-
*
|
|
42
|
-
* This function helps speed up MCTS-based agents which wish to avoid
|
|
43
|
-
* decoding/allocating `Choice` objects which they ignore. Most other use
|
|
44
|
-
* cases will likely be better served by the choices method.
|
|
45
|
-
*
|
|
46
|
-
* Note that the number of possible choices n passed to `fn` may be 0 as
|
|
47
|
-
* outlined above in {@link choices}.
|
|
48
|
-
*/
|
|
49
|
-
choose(player: Player, result: Result, fn: (n: number) => number): Choice;
|
|
50
38
|
/** Returns a copy of the Battle data. */
|
|
51
39
|
toJSON(): Data<Battle>;
|
|
52
40
|
}
|
|
53
|
-
/** Helper type removing
|
|
54
|
-
export type Data<T
|
|
41
|
+
/** Helper type removing function types from a data type `T`. */
|
|
42
|
+
export type Data<T> = T extends readonly any[] ? {
|
|
43
|
+
[K in keyof T]: Data<T[K]>;
|
|
44
|
+
} : T extends Iterable<infer U> ? (U extends object ? Iterable<Data<U>> : T) : T extends object ? {
|
|
45
|
+
[K in keyof T as T[K] extends Function ? never : K]: Data<T[K]>;
|
|
46
|
+
} : T;
|
|
55
47
|
/** Type definitions for Generation I Pokémon data relevant in a battle. */
|
|
56
48
|
export declare namespace Gen1 {
|
|
57
49
|
/** Representation of the entire state of a Generation I Pokémon battle. */
|
|
58
50
|
interface Battle extends API {
|
|
59
51
|
/** The sides involved in the battle. */
|
|
60
52
|
sides: Iterable<Side>;
|
|
53
|
+
/** Returns the side of the `player`. */
|
|
54
|
+
side(player: Player): Side;
|
|
55
|
+
/** Returns the opposing side to `player`. */
|
|
56
|
+
foe(player: Player): Side;
|
|
61
57
|
/** The battle's current turn number. */
|
|
62
58
|
turn: number;
|
|
63
59
|
/** The last damage dealt by either side. */
|
|
@@ -83,12 +79,24 @@ export declare namespace Gen1 {
|
|
|
83
79
|
* the effect switching would have on its original order).
|
|
84
80
|
*/
|
|
85
81
|
pokemon: Iterable<Pokemon>;
|
|
82
|
+
/**
|
|
83
|
+
* Returns the current slot of the Pokémon that started the battle at index
|
|
84
|
+
* `id`, or undefined if the index is invalid.
|
|
85
|
+
*/
|
|
86
|
+
slot(id: number): Slot | undefined;
|
|
87
|
+
/**
|
|
88
|
+
* Returns the Pokémon currently at the provided `slot`, or undefined if
|
|
89
|
+
* nothing occupies the slot.
|
|
90
|
+
*/
|
|
91
|
+
get(slot: Slot): Pokemon | undefined;
|
|
86
92
|
/** The last move the player used. */
|
|
87
93
|
lastUsedMove: ID | undefined;
|
|
88
94
|
/** The last move the player selected. */
|
|
89
95
|
lastSelectedMove: ID | undefined;
|
|
90
|
-
/** The move slot index of the last selected
|
|
91
|
-
|
|
96
|
+
/** The move slot index of the last move selected in the battle menu. */
|
|
97
|
+
lastMoveIndex: 1 | 2 | 3 | 4 | undefined;
|
|
98
|
+
/** Whether the last move executed by the player was counterable. */
|
|
99
|
+
lastMoveCounterable: boolean;
|
|
92
100
|
}
|
|
93
101
|
/**
|
|
94
102
|
* Representation of the state for single Generation I Pokémon in a battle.
|
|
@@ -124,13 +132,19 @@ export declare namespace Gen1 {
|
|
|
124
132
|
* boosts/status/etc (and which may differ from its original stored stats).
|
|
125
133
|
*/
|
|
126
134
|
stats: StatsTable;
|
|
135
|
+
/** Returns the value Pokémon's current `stat`. */
|
|
136
|
+
stat(stat: StatID | 'spc'): number;
|
|
127
137
|
/** The Pokémon's current boosts. */
|
|
128
138
|
boosts: BoostsTable;
|
|
139
|
+
/** Returns the value Pokémon's current `boost`. */
|
|
140
|
+
boost(boost: BoostID): number;
|
|
129
141
|
/**
|
|
130
142
|
* The Pokémon's move slots (which may differ from its original stored
|
|
131
143
|
* moves).
|
|
132
144
|
*/
|
|
133
145
|
moves: Iterable<MoveSlot>;
|
|
146
|
+
/** The Pokémon's current move at `slot`, or undefined if absent. */
|
|
147
|
+
move(slot: 1 | 2 | 3 | 4): MoveSlot | undefined;
|
|
134
148
|
/** The Pokémon's volatiles statuses. */
|
|
135
149
|
volatiles: Volatiles;
|
|
136
150
|
stored: {
|
|
@@ -140,8 +154,12 @@ export declare namespace Gen1 {
|
|
|
140
154
|
types: readonly [TypeName, TypeName];
|
|
141
155
|
/** The Pokémon original unmodified stats. */
|
|
142
156
|
stats: StatsTable;
|
|
157
|
+
/** Returns the value Pokémon's original `stat`. */
|
|
158
|
+
stat(stat: StatID | 'spc'): number;
|
|
143
159
|
/** The Pokémon's original move slots. */
|
|
144
160
|
moves: Iterable<Omit<MoveSlot, 'disabled'>>;
|
|
161
|
+
/** The Pokémon's original move at `slot`, or undefined if absent. */
|
|
162
|
+
move(slot: 1 | 2 | 3 | 4): Omit<MoveSlot, 'disabled'> | undefined;
|
|
145
163
|
};
|
|
146
164
|
/** The current one-indexed position of this Pokémon in the party. */
|
|
147
165
|
position: Slot;
|
|
@@ -239,14 +257,16 @@ export type CreateOptions = {
|
|
|
239
257
|
* that the engine be built in a specific compatibility mode).
|
|
240
258
|
*/
|
|
241
259
|
showdown?: boolean;
|
|
260
|
+
/** Whether the battle should be initialized without functionality afforded by native code. */
|
|
261
|
+
inert?: true;
|
|
242
262
|
} & ({
|
|
243
263
|
/** Player 1's options. */
|
|
244
264
|
p1: PlayerOptions;
|
|
245
265
|
/** Player 2's options. */
|
|
246
266
|
p2: PlayerOptions;
|
|
247
267
|
/**
|
|
248
|
-
* Whether to capture protocol
|
|
249
|
-
* not build with
|
|
268
|
+
* Whether to capture protocol message logs. Note that if the engine itself
|
|
269
|
+
* was not build with protocol logging enabled then enabling this will have no
|
|
250
270
|
* effect.
|
|
251
271
|
*/
|
|
252
272
|
log: true;
|
|
@@ -256,8 +276,8 @@ export type CreateOptions = {
|
|
|
256
276
|
/** Player 2's options. */
|
|
257
277
|
p2: Omit<PlayerOptions, 'name'>;
|
|
258
278
|
/**
|
|
259
|
-
* Whether to capture protocol
|
|
260
|
-
* not build with
|
|
279
|
+
* Whether to capture protocol message logs. Note that if the engine itself
|
|
280
|
+
* was not build with protocol logging enabled then enabling this will have no
|
|
261
281
|
* effect.
|
|
262
282
|
*/
|
|
263
283
|
log?: false;
|
|
@@ -274,8 +294,8 @@ export type RestoreOptions = {
|
|
|
274
294
|
*/
|
|
275
295
|
showdown?: boolean;
|
|
276
296
|
/**
|
|
277
|
-
* Whether to capture protocol
|
|
278
|
-
* not build with
|
|
297
|
+
* Whether to capture protocol message logs. Note that if the engine itself
|
|
298
|
+
* was not build with protocol logging enabled then enabling this will have no
|
|
279
299
|
* effect.
|
|
280
300
|
*/
|
|
281
301
|
log: true;
|
|
@@ -286,8 +306,8 @@ export type RestoreOptions = {
|
|
|
286
306
|
*/
|
|
287
307
|
showdown?: boolean;
|
|
288
308
|
/**
|
|
289
|
-
* Whether to capture protocol
|
|
290
|
-
* not build with
|
|
309
|
+
* Whether to capture protocol message logs. Note that if the engine itself
|
|
310
|
+
* was not build with protocol logging enabled then enabling this will have no
|
|
291
311
|
* effect.
|
|
292
312
|
*/
|
|
293
313
|
log?: false;
|
|
@@ -299,40 +319,6 @@ export interface PlayerOptions {
|
|
|
299
319
|
/** The player's team. */
|
|
300
320
|
team: Partial<PokemonSet>[];
|
|
301
321
|
}
|
|
302
|
-
/** A choice made by a player during battle. */
|
|
303
|
-
export interface Choice {
|
|
304
|
-
/** The choice type. */
|
|
305
|
-
type: 'pass' | 'move' | 'switch';
|
|
306
|
-
/**
|
|
307
|
-
* The choice data:
|
|
308
|
-
*
|
|
309
|
-
* - 0 for 'pass'
|
|
310
|
-
* - 0-4 for 'move'
|
|
311
|
-
* - 2-6 for 'switch'
|
|
312
|
-
*/
|
|
313
|
-
data: number;
|
|
314
|
-
}
|
|
315
|
-
/**
|
|
316
|
-
* The result of the battle - all defined results should be considered terminal.
|
|
317
|
-
*/
|
|
318
|
-
export interface Result {
|
|
319
|
-
/**
|
|
320
|
-
* The type of result from the perspective of Player 1:
|
|
321
|
-
*
|
|
322
|
-
* - undefined: no result, battle is non-terminal
|
|
323
|
-
* - win: Player 1 wins
|
|
324
|
-
* - lose: Player 2 wins
|
|
325
|
-
* - tie: Player 1 & 2 tie
|
|
326
|
-
* - error: the battle has terminated in error (e.g. due to a desync)
|
|
327
|
-
*
|
|
328
|
-
* 'error' is not possible when in Pokémon Showdown compatibility mode.
|
|
329
|
-
*/
|
|
330
|
-
type: undefined | 'win' | 'lose' | 'tie' | 'error';
|
|
331
|
-
/** The choice type of the result for Player 1. */
|
|
332
|
-
p1: Choice['type'];
|
|
333
|
-
/** The choice type of the result for Player 2. */
|
|
334
|
-
p2: Choice['type'];
|
|
335
|
-
}
|
|
336
322
|
/** Factory for creating Battle objects. */
|
|
337
323
|
export declare const Battle: {
|
|
338
324
|
/** Create a `Battle` in the given generation with the provided options. */
|
|
@@ -341,43 +327,11 @@ export declare const Battle: {
|
|
|
341
327
|
* Restore a (possibly in-progress) `Battle` in the given generation with the
|
|
342
328
|
* provided options.
|
|
343
329
|
*/
|
|
344
|
-
restore(gen: Generation, battle: Battle
|
|
330
|
+
restore(gen: Generation, battle: Data<Battle>, options: RestoreOptions): Battle;
|
|
345
331
|
};
|
|
346
|
-
|
|
347
|
-
export
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
readonly type: "pass";
|
|
352
|
-
readonly data: 0;
|
|
353
|
-
};
|
|
354
|
-
protected static MATCH: RegExp;
|
|
355
|
-
private constructor();
|
|
356
|
-
/** Decode a choice from its binary representation. */
|
|
357
|
-
static decode(byte: number): Choice;
|
|
358
|
-
/** Encode a choice to its binary representation. */
|
|
359
|
-
static encode(choice?: Choice): number;
|
|
360
|
-
/**
|
|
361
|
-
* Parse a Pokémon Showdown choice string into a `Choice`.
|
|
362
|
-
* Only numeric choice data is supported.
|
|
363
|
-
*/
|
|
364
|
-
static parse(choice: string): Choice;
|
|
365
|
-
/** Formats a `Choice` ino a Pokémon Showdown compatible choice string. */
|
|
366
|
-
static format(choice: Choice): string;
|
|
367
|
-
/** Returns the "pass" `Choice`. */
|
|
368
|
-
static pass(): Choice;
|
|
369
|
-
/** Returns a "move" `Choice` with the provided data. */
|
|
370
|
-
static move(data: 0 | 1 | 2 | 3 | 4): Choice;
|
|
371
|
-
/** Returns a "switch" `Choice` with the provided data. */
|
|
372
|
-
static switch(data: 2 | 3 | 4 | 5 | 6): Choice;
|
|
373
|
-
}
|
|
374
|
-
/** Utilities for working with `Result` objects */
|
|
375
|
-
export declare class Result {
|
|
376
|
-
/** All valid result types. */
|
|
377
|
-
static Types: readonly [undefined, "win", "lose", "tie", "error"];
|
|
378
|
-
private constructor();
|
|
379
|
-
/** Decode a `Result` from its binary representation. */
|
|
380
|
-
static decode(byte: number): Result;
|
|
381
|
-
}
|
|
382
|
-
export { ParsedLine, Info, SideInfo, PokemonInfo, Log } from './protocol';
|
|
332
|
+
export { initialize } from './addon';
|
|
333
|
+
export { Choice, Result } from './common';
|
|
334
|
+
export type { Player } from './common';
|
|
335
|
+
export type { ParsedLine, PokemonInfo } from './protocol';
|
|
336
|
+
export { Info, SideInfo, Log } from './protocol';
|
|
383
337
|
export { Lookup } from './data';
|
package/build/pkg/index.js
CHANGED
|
@@ -15,15 +15,25 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.Lookup = exports.Log = exports.SideInfo = exports.Info = exports.Result = exports.Choice = exports.Battle = void 0;
|
|
36
|
+
exports.Lookup = exports.Log = exports.SideInfo = exports.Info = exports.Result = exports.Choice = exports.initialize = exports.Battle = void 0;
|
|
27
37
|
const addon = __importStar(require("./addon"));
|
|
28
38
|
const data_1 = require("./data");
|
|
29
39
|
const gen1 = __importStar(require("./gen1"));
|
|
@@ -51,68 +61,11 @@ exports.Battle = new class {
|
|
|
51
61
|
}
|
|
52
62
|
}
|
|
53
63
|
};
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
static MATCH = /^(?:(pass)|((move) ([0-4]))|((switch) ([2-6])))$/;
|
|
60
|
-
constructor() { }
|
|
61
|
-
/** Decode a choice from its binary representation. */
|
|
62
|
-
static decode(byte) {
|
|
63
|
-
return { type: Choice.Types[byte & 0b11], data: byte >> 2 };
|
|
64
|
-
}
|
|
65
|
-
/** Encode a choice to its binary representation. */
|
|
66
|
-
static encode(choice) {
|
|
67
|
-
return (choice
|
|
68
|
-
? (choice.data << 2 | (choice.type === 'pass' ? 0 : choice.type === 'move' ? 1 : 2))
|
|
69
|
-
: 0);
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Parse a Pokémon Showdown choice string into a `Choice`.
|
|
73
|
-
* Only numeric choice data is supported.
|
|
74
|
-
*/
|
|
75
|
-
static parse(choice) {
|
|
76
|
-
const m = Choice.MATCH.exec(choice);
|
|
77
|
-
if (!m)
|
|
78
|
-
throw new Error(`Invalid choice: '${choice}'`);
|
|
79
|
-
const type = (m[1] ?? m[3] ?? m[6]);
|
|
80
|
-
const data = +(m[4] ?? m[7] ?? 0);
|
|
81
|
-
return { type, data };
|
|
82
|
-
}
|
|
83
|
-
/** Formats a `Choice` ino a Pokémon Showdown compatible choice string. */
|
|
84
|
-
static format(choice) {
|
|
85
|
-
return choice.type === 'pass' ? choice.type : `${choice.type} ${choice.data}`;
|
|
86
|
-
}
|
|
87
|
-
/** Returns the "pass" `Choice`. */
|
|
88
|
-
static pass() {
|
|
89
|
-
return Choice.PASS;
|
|
90
|
-
}
|
|
91
|
-
/** Returns a "move" `Choice` with the provided data. */
|
|
92
|
-
static move(data) {
|
|
93
|
-
return { type: 'move', data };
|
|
94
|
-
}
|
|
95
|
-
/** Returns a "switch" `Choice` with the provided data. */
|
|
96
|
-
static switch(data) {
|
|
97
|
-
return { type: 'switch', data };
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
exports.Choice = Choice;
|
|
101
|
-
/** Utilities for working with `Result` objects */
|
|
102
|
-
class Result {
|
|
103
|
-
/** All valid result types. */
|
|
104
|
-
static Types = [undefined, 'win', 'lose', 'tie', 'error'];
|
|
105
|
-
constructor() { }
|
|
106
|
-
/** Decode a `Result` from its binary representation. */
|
|
107
|
-
static decode(byte) {
|
|
108
|
-
return {
|
|
109
|
-
type: Result.Types[byte & 0b1111],
|
|
110
|
-
p1: Choice.Types[(byte >> 4) & 0b11],
|
|
111
|
-
p2: Choice.Types[byte >> 6],
|
|
112
|
-
};
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
exports.Result = Result;
|
|
64
|
+
var addon_1 = require("./addon");
|
|
65
|
+
Object.defineProperty(exports, "initialize", { enumerable: true, get: function () { return addon_1.initialize; } });
|
|
66
|
+
var common_1 = require("./common");
|
|
67
|
+
Object.defineProperty(exports, "Choice", { enumerable: true, get: function () { return common_1.Choice; } });
|
|
68
|
+
Object.defineProperty(exports, "Result", { enumerable: true, get: function () { return common_1.Result; } });
|
|
116
69
|
var protocol_1 = require("./protocol");
|
|
117
70
|
Object.defineProperty(exports, "Info", { enumerable: true, get: function () { return protocol_1.Info; } });
|
|
118
71
|
Object.defineProperty(exports, "SideInfo", { enumerable: true, get: function () { return protocol_1.SideInfo; } });
|
package/build/pkg/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/pkg/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/pkg/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,+CAAiC;AAEjC,iCAA8B;AAC9B,6CAA+B;AA6U/B,2CAA2C;AAC9B,QAAA,MAAM,GAAG,IAAI;IACxB,2EAA2E;IAC3E,MAAM,CAAC,GAAe,EAAE,OAAsB;QAC5C,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QAChC,MAAM,MAAM,GAAG,aAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAC/B,QAAQ,GAAG,CAAC,GAAG,EAAE,CAAC;YAChB,KAAK,CAAC,CAAC,CAAC,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;YACxD,OAAO,CAAC,CAAC,MAAM,IAAI,KAAK,CAAC,mBAAmB,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC;QACzD,CAAC;IACH,CAAC;IAED;;;OAGG;IACH,OAAO,CAAC,GAAe,EAAE,MAAoB,EAAE,OAAuB;QACpE,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QAChC,MAAM,MAAM,GAAG,aAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAC/B,QAAQ,GAAG,CAAC,GAAG,EAAE,CAAC;YAChB,KAAK,CAAC,CAAC,CAAC,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;YACjE,OAAO,CAAC,CAAC,MAAM,IAAI,KAAK,CAAC,mBAAmB,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC;QACzD,CAAC;IACH,CAAC;CACF,CAAC;AAEF,iCAAmC;AAA3B,mGAAA,UAAU,OAAA;AAClB,mCAAwC;AAAhC,gGAAA,MAAM,OAAA;AAAE,gGAAA,MAAM,OAAA;AAGtB,uCAA+C;AAAvC,gGAAA,IAAI,OAAA;AAAE,oGAAA,QAAQ,OAAA;AAAE,+FAAA,GAAG,OAAA;AAC3B,+BAA8B;AAAtB,8FAAA,MAAM,OAAA"}
|
package/build/pkg/protocol.d.ts
CHANGED
|
@@ -1,7 +1,25 @@
|
|
|
1
|
-
import {
|
|
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. */
|
|
@@ -39,8 +57,10 @@ export declare class SideInfo {
|
|
|
39
57
|
* protocol from the engine's binary protocol.
|
|
40
58
|
*/
|
|
41
59
|
export interface PokemonInfo {
|
|
42
|
-
/** The Pokémon's nickname. */
|
|
43
|
-
name
|
|
60
|
+
/** The Pokémon's nickname. Either this or species must be set. */
|
|
61
|
+
name?: string;
|
|
62
|
+
/** The Pokémon's species. Either this or name must be set. */
|
|
63
|
+
species?: string;
|
|
44
64
|
/** The gender of the Pokémon. */
|
|
45
65
|
gender?: string;
|
|
46
66
|
/** Whether or not the Pokémon is shiny. */
|
|
@@ -69,3 +89,4 @@ export declare function decodeIdentRaw(byte: number): {
|
|
|
69
89
|
};
|
|
70
90
|
export declare function decodeStatus(val: number): StatusName | undefined;
|
|
71
91
|
export declare function decodeTypes(lookup: Lookup, val: number): readonly [TypeName, TypeName];
|
|
92
|
+
export {};
|