@pkmn/sim 0.7.58 → 0.7.59
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/build/cjs/config/formats.js +83 -61
- package/build/cjs/config/formats.js.map +1 -1
- package/build/cjs/data/aliases.js +4 -2
- package/build/cjs/data/aliases.js.map +1 -1
- package/build/cjs/data/formats-data.js +180 -170
- package/build/cjs/data/formats-data.js.map +1 -1
- package/build/esm/config/formats.mjs +83 -61
- package/build/esm/config/formats.mjs.map +1 -1
- package/build/esm/data/aliases.mjs +4 -2
- package/build/esm/data/aliases.mjs.map +1 -1
- package/build/esm/data/formats-data.mjs +180 -170
- package/build/esm/data/formats-data.mjs.map +1 -1
- package/build/types/config/formats.d.ts +1 -0
- package/build/types/data/abilities.d.ts +3 -0
- package/build/types/data/aliases.d.ts +3 -0
- package/build/types/data/conditions.d.ts +3 -0
- package/build/types/data/formats-data.d.ts +3 -0
- package/build/types/data/index.d.ts +11 -0
- package/build/types/data/items.d.ts +3 -0
- package/build/types/data/learnsets.d.ts +3 -0
- package/build/types/data/legality.d.ts +3 -0
- package/build/types/data/mods/gen1/conditions.d.ts +12 -0
- package/build/types/data/mods/gen1/formats-data.d.ts +3 -0
- package/build/types/data/mods/gen1/index.d.ts +7 -0
- package/build/types/data/mods/gen1/moves.d.ts +7 -0
- package/build/types/data/mods/gen1/pokedex.d.ts +3 -0
- package/build/types/data/mods/gen1/rulesets.d.ts +3 -0
- package/build/types/data/mods/gen1/scripts.d.ts +6 -0
- package/build/types/data/mods/gen1/typechart.d.ts +10 -0
- package/build/types/data/mods/gen2/conditions.d.ts +3 -0
- package/build/types/data/mods/gen2/formats-data.d.ts +3 -0
- package/build/types/data/mods/gen2/index.d.ts +8 -0
- package/build/types/data/mods/gen2/items.d.ts +3 -0
- package/build/types/data/mods/gen2/learnsets.d.ts +3 -0
- package/build/types/data/mods/gen2/legality.d.ts +3 -0
- package/build/types/data/mods/gen2/moves.d.ts +6 -0
- package/build/types/data/mods/gen2/pokedex.d.ts +3 -0
- package/build/types/data/mods/gen2/rulesets.d.ts +3 -0
- package/build/types/data/mods/gen2/scripts.d.ts +4 -0
- package/build/types/data/mods/gen2/typechart.d.ts +3 -0
- package/build/types/data/mods/gen3/abilities.d.ts +3 -0
- package/build/types/data/mods/gen3/conditions.d.ts +3 -0
- package/build/types/data/mods/gen3/formats-data.d.ts +3 -0
- package/build/types/data/mods/gen3/index.d.ts +7 -0
- package/build/types/data/mods/gen3/items.d.ts +3 -0
- package/build/types/data/mods/gen3/moves.d.ts +6 -0
- package/build/types/data/mods/gen3/rulesets.d.ts +3 -0
- package/build/types/data/mods/gen3/scripts.d.ts +1 -0
- package/build/types/data/mods/gen4/abilities.d.ts +3 -0
- package/build/types/data/mods/gen4/conditions.d.ts +3 -0
- package/build/types/data/mods/gen4/formats-data.d.ts +3 -0
- package/build/types/data/mods/gen4/index.d.ts +8 -0
- package/build/types/data/mods/gen4/items.d.ts +3 -0
- package/build/types/data/mods/gen4/moves.d.ts +3 -0
- package/build/types/data/mods/gen4/pokedex.d.ts +3 -0
- package/build/types/data/mods/gen4/rulesets.d.ts +3 -0
- package/build/types/data/mods/gen4/scripts.d.ts +1 -0
- package/build/types/data/mods/gen5/abilities.d.ts +3 -0
- package/build/types/data/mods/gen5/conditions.d.ts +3 -0
- package/build/types/data/mods/gen5/formats-data.d.ts +3 -0
- package/build/types/data/mods/gen5/index.d.ts +9 -0
- package/build/types/data/mods/gen5/items.d.ts +3 -0
- package/build/types/data/mods/gen5/moves.d.ts +3 -0
- package/build/types/data/mods/gen5/pokedex.d.ts +3 -0
- package/build/types/data/mods/gen5/rulesets.d.ts +3 -0
- package/build/types/data/mods/gen5/scripts.d.ts +1 -0
- package/build/types/data/mods/gen5/typechart.d.ts +3 -0
- package/build/types/data/mods/gen6/abilities.d.ts +3 -0
- package/build/types/data/mods/gen6/conditions.d.ts +3 -0
- package/build/types/data/mods/gen6/formats-data.d.ts +3 -0
- package/build/types/data/mods/gen6/index.d.ts +8 -0
- package/build/types/data/mods/gen6/items.d.ts +3 -0
- package/build/types/data/mods/gen6/learnsets.d.ts +3 -0
- package/build/types/data/mods/gen6/legality.d.ts +3 -0
- package/build/types/data/mods/gen6/moves.d.ts +3 -0
- package/build/types/data/mods/gen6/pokedex.d.ts +3 -0
- package/build/types/data/mods/gen6/scripts.d.ts +1 -0
- package/build/types/data/mods/gen6/typechart.d.ts +3 -0
- package/build/types/data/mods/gen7/abilities.d.ts +3 -0
- package/build/types/data/mods/gen7/formats-data.d.ts +3 -0
- package/build/types/data/mods/gen7/index.d.ts +7 -0
- package/build/types/data/mods/gen7/items.d.ts +3 -0
- package/build/types/data/mods/gen7/moves.d.ts +3 -0
- package/build/types/data/mods/gen7/pokedex.d.ts +3 -0
- package/build/types/data/mods/gen7/rulesets.d.ts +3 -0
- package/build/types/data/mods/gen7/scripts.d.ts +1 -0
- package/build/types/data/mods/gen8/abilities.d.ts +3 -0
- package/build/types/data/mods/gen8/formats-data.d.ts +3 -0
- package/build/types/data/mods/gen8/index.d.ts +7 -0
- package/build/types/data/mods/gen8/items.d.ts +3 -0
- package/build/types/data/mods/gen8/learnsets.d.ts +3 -0
- package/build/types/data/mods/gen8/legality.d.ts +3 -0
- package/build/types/data/mods/gen8/moves.d.ts +3 -0
- package/build/types/data/mods/gen8/pokedex.d.ts +3 -0
- package/build/types/data/mods/gen8/rulesets.d.ts +3 -0
- package/build/types/data/mods/gen8/scripts.d.ts +1 -0
- package/build/types/data/moves.d.ts +3 -0
- package/build/types/data/natures.d.ts +3 -0
- package/build/types/data/pokedex.d.ts +3 -0
- package/build/types/data/pokemongo.d.ts +31 -0
- package/build/types/data/rulesets.d.ts +3 -0
- package/build/types/data/scripts.d.ts +1 -0
- package/build/types/data/tags.d.ts +15 -0
- package/build/types/data/text/abilities.d.ts +3 -0
- package/build/types/data/text/default.d.ts +3 -0
- package/build/types/data/text/items.d.ts +3 -0
- package/build/types/data/text/moves.d.ts +3 -0
- package/build/types/data/typechart.d.ts +3 -0
- package/build/types/lib/index.d.ts +2 -0
- package/build/types/lib/streams.d.ts +1 -0
- package/build/types/lib/utils.d.ts +139 -0
- package/build/types/sim/battle-actions.d.ts +90 -0
- package/build/types/sim/battle-queue.d.ts +164 -0
- package/build/types/sim/battle-stream.d.ts +67 -0
- package/build/types/sim/battle.d.ts +396 -0
- package/build/types/sim/dex-abilities.d.ts +35 -0
- package/build/types/sim/dex-conditions.d.ts +518 -0
- package/build/types/sim/dex-data.d.ts +169 -0
- package/build/types/sim/dex-formats.d.ts +170 -0
- package/build/types/sim/dex-items.d.ts +110 -0
- package/build/types/sim/dex-moves.d.ts +441 -0
- package/build/types/sim/dex-species.d.ts +289 -0
- package/build/types/sim/dex.d.ts +162 -0
- package/build/types/sim/exported-global-types.d.ts +510 -0
- package/build/types/sim/field.d.ts +30 -0
- package/build/types/sim/global-types.d.ts +510 -0
- package/build/types/sim/index.d.ts +13 -0
- package/build/types/sim/pokemon.d.ts +427 -0
- package/build/types/sim/prng.d.ts +97 -0
- package/build/types/sim/side.d.ts +127 -0
- package/build/types/sim/state.d.ts +42 -0
- package/build/types/sim/team-validator.d.ts +198 -0
- package/build/types/sim/teams.d.ts +26 -0
- package/build/types/sim/tools/exhaustive-runner.d.ts +52 -0
- package/build/types/sim/tools/index.d.ts +2 -0
- package/build/types/sim/tools/random-player-ai.d.ts +32 -0
- package/build/types/sim/tools/runner.d.ts +41 -0
- package/package.json +1 -1
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { ActiveMove, Battle, Effect, ModdedDex, Move, Pokemon, Side, SpreadMoveDamage, SpreadMoveTargets, ZMoveOptions } from './exported-global-types';
|
|
2
|
+
import { Dex } from './dex';
|
|
3
|
+
export declare class BattleActions {
|
|
4
|
+
battle: Battle;
|
|
5
|
+
dex: ModdedDex;
|
|
6
|
+
readonly MAX_MOVES: {
|
|
7
|
+
readonly [k: string]: string;
|
|
8
|
+
};
|
|
9
|
+
readonly Z_MOVES: {
|
|
10
|
+
readonly [k: string]: string;
|
|
11
|
+
};
|
|
12
|
+
constructor(battle: Battle);
|
|
13
|
+
switchIn(pokemon: Pokemon, pos: number, sourceEffect?: Effect | null, isDrag?: boolean): boolean | "pursuitfaint";
|
|
14
|
+
dragIn(side: Side, pos: number): boolean;
|
|
15
|
+
runSwitch(pokemon: Pokemon): boolean;
|
|
16
|
+
/**
|
|
17
|
+
* runMove is the "outside" move caller. It handles deducting PP,
|
|
18
|
+
* flinching, full paralysis, etc. All the stuff up to and including
|
|
19
|
+
* the "POKEMON used MOVE" message.
|
|
20
|
+
*
|
|
21
|
+
* For details of the difference between runMove and useMove, see
|
|
22
|
+
* useMove's info.
|
|
23
|
+
*
|
|
24
|
+
* externalMove skips LockMove and PP deduction, mostly for use by
|
|
25
|
+
* Dancer.
|
|
26
|
+
*/
|
|
27
|
+
runMove(moveOrMoveName: Move | string, pokemon: Pokemon, targetLoc: number, sourceEffect?: Effect | null, zMove?: string, externalMove?: boolean, maxMove?: string, originalTarget?: Pokemon): void;
|
|
28
|
+
/**
|
|
29
|
+
* useMove is the "inside" move caller. It handles effects of the
|
|
30
|
+
* move itself, but not the idea of using the move.
|
|
31
|
+
*
|
|
32
|
+
* Most caller effects, like Sleep Talk, Nature Power, Magic Bounce,
|
|
33
|
+
* etc use useMove.
|
|
34
|
+
*
|
|
35
|
+
* The only ones that use runMove are Instruct, Pursuit, and
|
|
36
|
+
* Dancer.
|
|
37
|
+
*/
|
|
38
|
+
useMove(move: Move | string, pokemon: Pokemon, target?: Pokemon | null, sourceEffect?: Effect | null, zMove?: string, maxMove?: string): boolean;
|
|
39
|
+
useMoveInner(moveOrMoveName: Move | string, pokemon: Pokemon, target?: Pokemon | null, sourceEffect?: Effect | null, zMove?: string, maxMove?: string): boolean;
|
|
40
|
+
/** NOTE: includes single-target moves */
|
|
41
|
+
trySpreadMoveHit(targets: Pokemon[], pokemon: Pokemon, move: ActiveMove, notActive?: boolean): boolean;
|
|
42
|
+
hitStepInvulnerabilityEvent(targets: Pokemon[], pokemon: Pokemon, move: ActiveMove): any;
|
|
43
|
+
hitStepTryHitEvent(targets: Pokemon[], pokemon: Pokemon, move: ActiveMove): any;
|
|
44
|
+
hitStepTypeImmunity(targets: Pokemon[], pokemon: Pokemon, move: ActiveMove): boolean[];
|
|
45
|
+
hitStepTryImmunity(targets: Pokemon[], pokemon: Pokemon, move: ActiveMove): boolean[];
|
|
46
|
+
hitStepAccuracy(targets: Pokemon[], pokemon: Pokemon, move: ActiveMove): boolean[];
|
|
47
|
+
hitStepBreakProtect(targets: Pokemon[], pokemon: Pokemon, move: ActiveMove): undefined;
|
|
48
|
+
hitStepStealBoosts(targets: Pokemon[], pokemon: Pokemon, move: ActiveMove): undefined;
|
|
49
|
+
afterMoveSecondaryEvent(targets: Pokemon[], pokemon: Pokemon, move: ActiveMove): undefined;
|
|
50
|
+
/** NOTE: used only for moves that target sides/fields rather than pokemon */
|
|
51
|
+
tryMoveHit(targetOrTargets: Pokemon | Pokemon[], pokemon: Pokemon, move: ActiveMove): number | undefined | false | '';
|
|
52
|
+
hitStepMoveHitLoop(targets: Pokemon[], pokemon: Pokemon, move: ActiveMove): (number | boolean | undefined)[];
|
|
53
|
+
spreadMoveHit(targets: SpreadMoveTargets, pokemon: Pokemon, moveOrMoveName: ActiveMove, hitEffect?: Dex.HitEffect, isSecondary?: boolean, isSelf?: boolean): [SpreadMoveDamage, SpreadMoveTargets];
|
|
54
|
+
tryPrimaryHitEvent(damage: SpreadMoveDamage, targets: SpreadMoveTargets, pokemon: Pokemon, move: ActiveMove, moveData: ActiveMove, isSecondary?: boolean): SpreadMoveDamage;
|
|
55
|
+
getSpreadDamage(damage: SpreadMoveDamage, targets: SpreadMoveTargets, source: Pokemon, move: ActiveMove, moveData: ActiveMove, isSecondary?: boolean, isSelf?: boolean): SpreadMoveDamage;
|
|
56
|
+
runMoveEffects(damage: SpreadMoveDamage, targets: SpreadMoveTargets, source: Pokemon, move: ActiveMove, moveData: ActiveMove, isSecondary?: boolean, isSelf?: boolean): SpreadMoveDamage;
|
|
57
|
+
selfDrops(targets: SpreadMoveTargets, source: Pokemon, move: ActiveMove, moveData: ActiveMove, isSecondary?: boolean): void;
|
|
58
|
+
secondaries(targets: SpreadMoveTargets, source: Pokemon, move: ActiveMove, moveData: ActiveMove, isSelf?: boolean): void;
|
|
59
|
+
forceSwitch(damage: SpreadMoveDamage, targets: SpreadMoveTargets, source: Pokemon, move: ActiveMove): SpreadMoveDamage;
|
|
60
|
+
moveHit(targets: Pokemon | null | (Pokemon | null)[], pokemon: Pokemon, moveOrMoveName: ActiveMove, moveData?: Dex.HitEffect, isSecondary?: boolean, isSelf?: boolean): number | undefined | false;
|
|
61
|
+
calcRecoilDamage(damageDealt: number, move: Move, pokemon: Pokemon): number;
|
|
62
|
+
getZMove(move: Move, pokemon: Pokemon, skipChecks?: boolean): string | undefined;
|
|
63
|
+
getActiveZMove(move: Move, pokemon: Pokemon): ActiveMove;
|
|
64
|
+
canZMove(pokemon: Pokemon): ZMoveOptions | undefined;
|
|
65
|
+
getMaxMove(move: Move, pokemon: Pokemon): import("./dex-moves").Move | undefined;
|
|
66
|
+
getActiveMaxMove(move: Move, pokemon: Pokemon): import("./dex-moves").ActiveMove;
|
|
67
|
+
runZPower(move: ActiveMove, pokemon: Pokemon): void;
|
|
68
|
+
targetTypeChoices(targetType: string): boolean;
|
|
69
|
+
combineResults<T extends number | boolean | null | '' | undefined, U extends number | boolean | null | '' | undefined>(left: T, right: U): T | U;
|
|
70
|
+
/**
|
|
71
|
+
* 0 is a success dealing 0 damage, such as from False Swipe at 1 HP.
|
|
72
|
+
*
|
|
73
|
+
* Normal PS return value rules apply:
|
|
74
|
+
* undefined = success, null = silent failure, false = loud failure
|
|
75
|
+
*/
|
|
76
|
+
getDamage(source: Pokemon, target: Pokemon, move: string | number | ActiveMove, suppressMessages?: boolean): number | undefined | null | false;
|
|
77
|
+
modifyDamage(baseDamage: number, pokemon: Pokemon, target: Pokemon, move: ActiveMove, suppressMessages?: boolean): number;
|
|
78
|
+
/**
|
|
79
|
+
* Confusion damage is unique - most typical modifiers that get run when calculating
|
|
80
|
+
* damage (e.g. Huge Power, Life Orb, critical hits) don't apply. It also uses a 16-bit
|
|
81
|
+
* context for its damage, unlike the regular damage formula (though this only comes up
|
|
82
|
+
* for base damage).
|
|
83
|
+
*/
|
|
84
|
+
getConfusionDamage(pokemon: Pokemon, basePower: number): number;
|
|
85
|
+
canMegaEvo(pokemon: Pokemon): string | null | undefined;
|
|
86
|
+
canUltraBurst(pokemon: Pokemon): "Necrozma-Ultra" | null;
|
|
87
|
+
runMegaEvo(pokemon: Pokemon): boolean;
|
|
88
|
+
canTerastallize(pokemon: Pokemon): string | null;
|
|
89
|
+
terastallize(pokemon: Pokemon): void;
|
|
90
|
+
}
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import { Effect, ID, Move, Pokemon } from './exported-global-types';
|
|
2
|
+
/**
|
|
3
|
+
* Simulator Battle Action Queue
|
|
4
|
+
* Pokemon Showdown - http://pokemonshowdown.com/
|
|
5
|
+
*
|
|
6
|
+
* The action queue is the core of the battle simulation. A rough overview of
|
|
7
|
+
* the core battle loop:
|
|
8
|
+
*
|
|
9
|
+
* - chosen moves/switches are added to the action queue
|
|
10
|
+
* - the action queue is sorted in speed/priority order
|
|
11
|
+
* - we go through the action queue
|
|
12
|
+
* - repeat
|
|
13
|
+
*
|
|
14
|
+
* @license MIT
|
|
15
|
+
*/
|
|
16
|
+
import type { Battle } from './battle';
|
|
17
|
+
/** A move action */
|
|
18
|
+
export interface MoveAction {
|
|
19
|
+
/** action type */
|
|
20
|
+
choice: 'move' | 'beforeTurnMove' | 'priorityChargeMove';
|
|
21
|
+
order: 3 | 5 | 200 | 201 | 199 | 106;
|
|
22
|
+
/** priority of the action (lower first) */
|
|
23
|
+
priority: number;
|
|
24
|
+
/** fractional priority of the action (lower first) */
|
|
25
|
+
fractionalPriority: number;
|
|
26
|
+
/** speed of pokemon using move (higher first if priority tie) */
|
|
27
|
+
speed: number;
|
|
28
|
+
/** the pokemon doing the move */
|
|
29
|
+
pokemon: Pokemon;
|
|
30
|
+
/** location of the target, relative to pokemon's side */
|
|
31
|
+
targetLoc: number;
|
|
32
|
+
/** original target pokemon, for target-tracking moves */
|
|
33
|
+
originalTarget: Pokemon;
|
|
34
|
+
/** a move to use (move action only) */
|
|
35
|
+
moveid: ID;
|
|
36
|
+
/** a move to use (move action only) */
|
|
37
|
+
move: Move;
|
|
38
|
+
/** true if megaing or ultra bursting */
|
|
39
|
+
mega: boolean | 'done';
|
|
40
|
+
/** if zmoving, the name of the zmove */
|
|
41
|
+
zmove?: string;
|
|
42
|
+
/** if dynamaxed, the name of the max move */
|
|
43
|
+
maxMove?: string;
|
|
44
|
+
/** effect that called the move (eg Instruct) if any */
|
|
45
|
+
sourceEffect?: Effect | null;
|
|
46
|
+
}
|
|
47
|
+
/** A switch action */
|
|
48
|
+
export interface SwitchAction {
|
|
49
|
+
/** action type */
|
|
50
|
+
choice: 'switch' | 'instaswitch' | 'revivalblessing';
|
|
51
|
+
order: 3 | 6 | 103;
|
|
52
|
+
/** priority of the action (lower first) */
|
|
53
|
+
priority: number;
|
|
54
|
+
/** speed of pokemon switching (higher first if priority tie) */
|
|
55
|
+
speed: number;
|
|
56
|
+
/** the pokemon doing the switch */
|
|
57
|
+
pokemon: Pokemon;
|
|
58
|
+
/** pokemon to switch to */
|
|
59
|
+
target: Pokemon;
|
|
60
|
+
/** effect that called the switch (eg U */
|
|
61
|
+
sourceEffect: Effect | null;
|
|
62
|
+
}
|
|
63
|
+
/** A Team Preview choice action */
|
|
64
|
+
export interface TeamAction {
|
|
65
|
+
/** action type */
|
|
66
|
+
choice: 'team';
|
|
67
|
+
/** priority of the action (lower first) */
|
|
68
|
+
priority: number;
|
|
69
|
+
/** unused for this action type */
|
|
70
|
+
speed: 1;
|
|
71
|
+
/** the pokemon switching */
|
|
72
|
+
pokemon: Pokemon;
|
|
73
|
+
/** new index */
|
|
74
|
+
index: number;
|
|
75
|
+
}
|
|
76
|
+
/** A generic action not done by a pokemon */
|
|
77
|
+
export interface FieldAction {
|
|
78
|
+
/** action type */
|
|
79
|
+
choice: 'start' | 'residual' | 'pass' | 'beforeTurn';
|
|
80
|
+
/** priority of the action (lower first) */
|
|
81
|
+
priority: number;
|
|
82
|
+
/** unused for this action type */
|
|
83
|
+
speed: 1;
|
|
84
|
+
/** unused for this action type */
|
|
85
|
+
pokemon: null;
|
|
86
|
+
}
|
|
87
|
+
/** A generic action done by a single pokemon */
|
|
88
|
+
export interface PokemonAction {
|
|
89
|
+
/** action type */
|
|
90
|
+
choice: 'megaEvo' | 'shift' | 'runPrimal' | 'runSwitch' | 'event' | 'runUnnerve' | 'runDynamax' | 'terastallize';
|
|
91
|
+
/** priority of the action (lower first) */
|
|
92
|
+
priority: number;
|
|
93
|
+
/** speed of pokemon doing action (higher first if priority tie) */
|
|
94
|
+
speed: number;
|
|
95
|
+
/** the pokemon doing action */
|
|
96
|
+
pokemon: Pokemon;
|
|
97
|
+
/** `runSwitch` only: the pokemon forcing this pokemon to switch in */
|
|
98
|
+
dragger?: Pokemon;
|
|
99
|
+
/** `event` only: the event to run */
|
|
100
|
+
event?: string;
|
|
101
|
+
}
|
|
102
|
+
export type Action = MoveAction | SwitchAction | TeamAction | FieldAction | PokemonAction;
|
|
103
|
+
/**
|
|
104
|
+
* An ActionChoice is like an Action and has the same structure, but it doesn't need to be fully filled out.
|
|
105
|
+
*
|
|
106
|
+
* Any Action or ChosenAction qualifies as an ActionChoice.
|
|
107
|
+
*
|
|
108
|
+
* The `[k: string]: any` part is required so TypeScript won't warn about unnecessary properties.
|
|
109
|
+
*/
|
|
110
|
+
export interface ActionChoice {
|
|
111
|
+
choice: string;
|
|
112
|
+
[k: string]: any;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Kind of like a priority queue, although not sorted mid-turn in Gen 1-7.
|
|
116
|
+
*
|
|
117
|
+
* Sort order is documented in `BattleQueue.comparePriority`.
|
|
118
|
+
*/
|
|
119
|
+
export declare class BattleQueue {
|
|
120
|
+
battle: Battle;
|
|
121
|
+
list: Action[];
|
|
122
|
+
constructor(battle: Battle);
|
|
123
|
+
shift(): Action | undefined;
|
|
124
|
+
peek(end?: boolean): Action | undefined;
|
|
125
|
+
push(action: Action): number;
|
|
126
|
+
unshift(action: Action): number;
|
|
127
|
+
[Symbol.iterator](): IterableIterator<Action>;
|
|
128
|
+
entries(): IterableIterator<[number, Action]>;
|
|
129
|
+
/**
|
|
130
|
+
* Takes an ActionChoice, and fills it out into a full Action object.
|
|
131
|
+
*
|
|
132
|
+
* Returns an array of Actions because some ActionChoices (like mega moves)
|
|
133
|
+
* resolve to two Actions (mega evolution + use move)
|
|
134
|
+
*/
|
|
135
|
+
resolveAction(action: ActionChoice, midTurn?: boolean): Action[];
|
|
136
|
+
/**
|
|
137
|
+
* Makes the passed action happen next (skipping speed order).
|
|
138
|
+
*/
|
|
139
|
+
prioritizeAction(action: MoveAction | SwitchAction, sourceEffect?: Effect): void;
|
|
140
|
+
/**
|
|
141
|
+
* Changes a pokemon's action, and inserts its new action
|
|
142
|
+
* in priority order.
|
|
143
|
+
*
|
|
144
|
+
* You'd normally want the OverrideAction event (which doesn't
|
|
145
|
+
* change priority order).
|
|
146
|
+
*/
|
|
147
|
+
changeAction(pokemon: Pokemon, action: ActionChoice): void;
|
|
148
|
+
addChoice(choices: ActionChoice | ActionChoice[]): void;
|
|
149
|
+
willAct(): Action | null;
|
|
150
|
+
willMove(pokemon: Pokemon): MoveAction | null;
|
|
151
|
+
cancelAction(pokemon: Pokemon): boolean;
|
|
152
|
+
cancelMove(pokemon: Pokemon): boolean;
|
|
153
|
+
willSwitch(pokemon: Pokemon): MoveAction | SwitchAction | TeamAction | PokemonAction | null;
|
|
154
|
+
/**
|
|
155
|
+
* Inserts the passed action into the action queue when it normally
|
|
156
|
+
* would have happened (sorting by priority/speed), without
|
|
157
|
+
* re-sorting the existing actions.
|
|
158
|
+
*/
|
|
159
|
+
insertChoice(choices: ActionChoice | ActionChoice[], midTurn?: boolean): void;
|
|
160
|
+
clear(): void;
|
|
161
|
+
debug(action?: any): string;
|
|
162
|
+
sort(): this;
|
|
163
|
+
}
|
|
164
|
+
export default BattleQueue;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { AnyObject } from './exported-global-types';
|
|
3
|
+
/**
|
|
4
|
+
* Battle Stream
|
|
5
|
+
* Pokemon Showdown - http://pokemonshowdown.com/
|
|
6
|
+
*
|
|
7
|
+
* Supports interacting with a PS battle in Stream format.
|
|
8
|
+
*
|
|
9
|
+
* This format is VERY NOT FINALIZED, please do not use it directly yet.
|
|
10
|
+
*
|
|
11
|
+
* @license MIT
|
|
12
|
+
*/
|
|
13
|
+
import { Streams } from '../lib';
|
|
14
|
+
import { Battle } from './battle';
|
|
15
|
+
export declare class BattleStream extends Streams.ObjectReadWriteStream<string> {
|
|
16
|
+
debug: boolean;
|
|
17
|
+
noCatch: boolean;
|
|
18
|
+
replay: boolean | 'spectator';
|
|
19
|
+
keepAlive: boolean;
|
|
20
|
+
battle: Battle | null;
|
|
21
|
+
constructor(options?: {
|
|
22
|
+
debug?: boolean;
|
|
23
|
+
noCatch?: boolean;
|
|
24
|
+
keepAlive?: boolean;
|
|
25
|
+
replay?: boolean | 'spectator';
|
|
26
|
+
});
|
|
27
|
+
_write(chunk: string): void;
|
|
28
|
+
_writeLines(chunk: string): void;
|
|
29
|
+
pushMessage(type: string, data: string): void;
|
|
30
|
+
_writeLine(type: string, message: string): void;
|
|
31
|
+
_writeEnd(): void;
|
|
32
|
+
_destroy(): void;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Splits a BattleStream into omniscient, spectator, p1, p2, p3 and p4
|
|
36
|
+
* streams, for ease of consumption.
|
|
37
|
+
*/
|
|
38
|
+
export declare function getPlayerStreams(stream: BattleStream): {
|
|
39
|
+
omniscient: Streams.ObjectReadWriteStream<string>;
|
|
40
|
+
spectator: Streams.ObjectReadStream<string>;
|
|
41
|
+
p1: Streams.ObjectReadWriteStream<string>;
|
|
42
|
+
p2: Streams.ObjectReadWriteStream<string>;
|
|
43
|
+
p3: Streams.ObjectReadWriteStream<string>;
|
|
44
|
+
p4: Streams.ObjectReadWriteStream<string>;
|
|
45
|
+
};
|
|
46
|
+
export declare abstract class BattlePlayer {
|
|
47
|
+
readonly stream: Streams.ObjectReadWriteStream<string>;
|
|
48
|
+
readonly log: string[];
|
|
49
|
+
readonly debug: boolean;
|
|
50
|
+
constructor(playerStream: Streams.ObjectReadWriteStream<string>, debug?: boolean);
|
|
51
|
+
start(): Promise<void>;
|
|
52
|
+
receive(chunk: string): void;
|
|
53
|
+
receiveLine(line: string): void;
|
|
54
|
+
abstract receiveRequest(request: AnyObject): void;
|
|
55
|
+
receiveError(error: Error): void;
|
|
56
|
+
choose(choice: string): void;
|
|
57
|
+
}
|
|
58
|
+
export declare class BattleTextStream extends Streams.ReadWriteStream {
|
|
59
|
+
readonly battleStream: BattleStream;
|
|
60
|
+
currentMessage: string;
|
|
61
|
+
constructor(options: {
|
|
62
|
+
debug?: boolean;
|
|
63
|
+
});
|
|
64
|
+
start(): Promise<void>;
|
|
65
|
+
_write(message: string | Buffer): void;
|
|
66
|
+
_writeEnd(): Promise<void>;
|
|
67
|
+
}
|