@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,396 @@
|
|
|
1
|
+
import { ActiveMove, AnyObject, Effect, Format, GameType, ID, ModdedDex, Move, PlayerOptions, PokemonSet, PokemonSlot, SideID, SparseBoostsTable, SpreadMoveDamage, StatsTable } from './exported-global-types';
|
|
2
|
+
/**
|
|
3
|
+
* Simulator Battle
|
|
4
|
+
* Pokemon Showdown - http://pokemonshowdown.com/
|
|
5
|
+
*
|
|
6
|
+
* This file is where the battle simulation itself happens.
|
|
7
|
+
*
|
|
8
|
+
* The most important part of the simulation is the event system:
|
|
9
|
+
* see the `runEvent` function definition for details.
|
|
10
|
+
*
|
|
11
|
+
* General battle mechanics are in `battle-actions`; move-specific,
|
|
12
|
+
* item-specific, etc mechanics are in the corresponding file in
|
|
13
|
+
* `data`.
|
|
14
|
+
*
|
|
15
|
+
* @license MIT
|
|
16
|
+
*/
|
|
17
|
+
import { Dex } from './dex';
|
|
18
|
+
import { Teams } from './teams';
|
|
19
|
+
import { Field } from './field';
|
|
20
|
+
import { Pokemon, EffectState } from './pokemon';
|
|
21
|
+
import { PRNG, PRNGSeed } from './prng';
|
|
22
|
+
import { Side } from './side';
|
|
23
|
+
import { BattleQueue, Action } from './battle-queue';
|
|
24
|
+
import { BattleActions } from './battle-actions';
|
|
25
|
+
export type ChannelID = 0 | 1 | 2 | 3 | 4;
|
|
26
|
+
export type ChannelMessages<T extends ChannelID | -1> = Record<T, string[]>;
|
|
27
|
+
export declare function extractChannelMessages<T extends ChannelID | -1>(message: string, channelIds: T[]): ChannelMessages<T>;
|
|
28
|
+
interface BattleOptions {
|
|
29
|
+
format?: Format;
|
|
30
|
+
formatid: ID;
|
|
31
|
+
/** Output callback */
|
|
32
|
+
send?: (type: string, data: string | string[]) => void;
|
|
33
|
+
prng?: PRNG;
|
|
34
|
+
seed?: PRNGSeed;
|
|
35
|
+
rated?: boolean | string;
|
|
36
|
+
p1?: PlayerOptions;
|
|
37
|
+
p2?: PlayerOptions;
|
|
38
|
+
p3?: PlayerOptions;
|
|
39
|
+
p4?: PlayerOptions;
|
|
40
|
+
debug?: boolean;
|
|
41
|
+
forceRandomChance?: boolean;
|
|
42
|
+
deserialized?: boolean;
|
|
43
|
+
strictChoices?: boolean;
|
|
44
|
+
}
|
|
45
|
+
interface EventListenerWithoutPriority {
|
|
46
|
+
effect: Effect;
|
|
47
|
+
target?: Pokemon;
|
|
48
|
+
index?: number;
|
|
49
|
+
callback?: Function;
|
|
50
|
+
state: EffectState | null;
|
|
51
|
+
end: Function | null;
|
|
52
|
+
endCallArgs?: any[];
|
|
53
|
+
effectHolder: Pokemon | Side | Field | Battle;
|
|
54
|
+
}
|
|
55
|
+
interface EventListener extends EventListenerWithoutPriority {
|
|
56
|
+
order: number | false;
|
|
57
|
+
priority: number;
|
|
58
|
+
subOrder: number;
|
|
59
|
+
speed?: number;
|
|
60
|
+
}
|
|
61
|
+
type Part = string | number | boolean | Pokemon | Side | Effect | Move | null | undefined;
|
|
62
|
+
export type RequestState = 'teampreview' | 'move' | 'switch' | '';
|
|
63
|
+
export declare class Battle {
|
|
64
|
+
readonly id: ID;
|
|
65
|
+
readonly debugMode: boolean;
|
|
66
|
+
readonly forceRandomChance: boolean | null;
|
|
67
|
+
readonly deserialized: boolean;
|
|
68
|
+
readonly strictChoices: boolean;
|
|
69
|
+
readonly format: Format;
|
|
70
|
+
readonly formatData: EffectState;
|
|
71
|
+
readonly gameType: GameType;
|
|
72
|
+
/**
|
|
73
|
+
* The number of active pokemon per half-field.
|
|
74
|
+
* See header comment in side.ts for details.
|
|
75
|
+
*/
|
|
76
|
+
readonly activePerHalf: 1 | 2 | 3;
|
|
77
|
+
readonly field: Field;
|
|
78
|
+
readonly sides: [Side, Side] | [Side, Side, Side, Side];
|
|
79
|
+
readonly prngSeed: PRNGSeed;
|
|
80
|
+
dex: ModdedDex;
|
|
81
|
+
gen: number;
|
|
82
|
+
ruleTable: Dex.RuleTable;
|
|
83
|
+
prng: PRNG;
|
|
84
|
+
rated: boolean | string;
|
|
85
|
+
reportExactHP: boolean;
|
|
86
|
+
reportPercentages: boolean;
|
|
87
|
+
supportCancel: boolean;
|
|
88
|
+
actions: BattleActions;
|
|
89
|
+
queue: BattleQueue;
|
|
90
|
+
readonly faintQueue: {
|
|
91
|
+
target: Pokemon;
|
|
92
|
+
source: Pokemon | null;
|
|
93
|
+
effect: Effect | null;
|
|
94
|
+
}[];
|
|
95
|
+
readonly log: string[];
|
|
96
|
+
readonly inputLog: string[];
|
|
97
|
+
readonly messageLog: string[];
|
|
98
|
+
sentLogPos: number;
|
|
99
|
+
sentEnd: boolean;
|
|
100
|
+
requestState: RequestState;
|
|
101
|
+
turn: number;
|
|
102
|
+
midTurn: boolean;
|
|
103
|
+
started: boolean;
|
|
104
|
+
ended: boolean;
|
|
105
|
+
winner?: string;
|
|
106
|
+
effect: Effect;
|
|
107
|
+
effectState: EffectState;
|
|
108
|
+
event: AnyObject;
|
|
109
|
+
events: AnyObject | null;
|
|
110
|
+
eventDepth: number;
|
|
111
|
+
activeMove: ActiveMove | null;
|
|
112
|
+
activePokemon: Pokemon | null;
|
|
113
|
+
activeTarget: Pokemon | null;
|
|
114
|
+
lastMove: ActiveMove | null;
|
|
115
|
+
lastSuccessfulMoveThisTurn: ID | null;
|
|
116
|
+
lastMoveLine: number;
|
|
117
|
+
/** The last damage dealt by a move in the battle - only used by Gen 1 Counter. */
|
|
118
|
+
lastDamage: number;
|
|
119
|
+
abilityOrder: number;
|
|
120
|
+
quickClawRoll: boolean;
|
|
121
|
+
teamGenerator: ReturnType<typeof Teams.getGenerator> | null;
|
|
122
|
+
readonly hints: Set<string>;
|
|
123
|
+
readonly NOT_FAIL: '';
|
|
124
|
+
readonly HIT_SUBSTITUTE: 0;
|
|
125
|
+
readonly FAIL: false;
|
|
126
|
+
readonly SILENT_FAIL: null;
|
|
127
|
+
readonly send: (type: string, data: string | string[]) => void;
|
|
128
|
+
trunc: (num: number, bits?: number) => number;
|
|
129
|
+
clampIntRange: (num: any, min?: number, max?: number) => number;
|
|
130
|
+
toID: typeof import("./dex-data").toID;
|
|
131
|
+
constructor(options: BattleOptions);
|
|
132
|
+
toJSON(): AnyObject;
|
|
133
|
+
static fromJSON(serialized: string | AnyObject): Battle;
|
|
134
|
+
get p1(): Side;
|
|
135
|
+
get p2(): Side;
|
|
136
|
+
get p3(): Side | undefined;
|
|
137
|
+
get p4(): Side | undefined;
|
|
138
|
+
toString(): string;
|
|
139
|
+
random(m?: number, n?: number): number;
|
|
140
|
+
randomChance(numerator: number, denominator: number): boolean;
|
|
141
|
+
sample<T>(items: readonly T[]): T;
|
|
142
|
+
/** Note that passing `undefined` resets to the starting seed, but `null` will roll a new seed */
|
|
143
|
+
resetRNG(seed?: PRNGSeed | null): void;
|
|
144
|
+
suppressingAbility(target?: Pokemon): boolean | null | undefined;
|
|
145
|
+
setActiveMove(move?: ActiveMove | null, pokemon?: Pokemon | null, target?: Pokemon | null): void;
|
|
146
|
+
clearActiveMove(failed?: boolean): void;
|
|
147
|
+
updateSpeed(): void;
|
|
148
|
+
/**
|
|
149
|
+
* The default sort order for actions, but also event listeners.
|
|
150
|
+
*
|
|
151
|
+
* 1. Order, low to high (default last)
|
|
152
|
+
* 2. Priority, high to low (default 0)
|
|
153
|
+
* 3. Speed, high to low (default 0)
|
|
154
|
+
* 4. SubOrder, low to high (default 0)
|
|
155
|
+
*
|
|
156
|
+
* Doesn't reference `this` so doesn't need to be bound.
|
|
157
|
+
*/
|
|
158
|
+
comparePriority(a: AnyObject, b: AnyObject): number;
|
|
159
|
+
static compareRedirectOrder(a: AnyObject, b: AnyObject): number;
|
|
160
|
+
static compareLeftToRightOrder(a: AnyObject, b: AnyObject): number;
|
|
161
|
+
/** Sort a list, resolving speed ties the way the games do. */
|
|
162
|
+
speedSort<T extends AnyObject>(list: T[], comparator?: (a: T, b: T) => number): void;
|
|
163
|
+
/**
|
|
164
|
+
* Runs an event with no source on each Pokémon on the field, in Speed order.
|
|
165
|
+
*/
|
|
166
|
+
eachEvent(eventid: string, effect?: Effect | null, relayVar?: boolean): void;
|
|
167
|
+
/**
|
|
168
|
+
* Runs an event with no source on each effect on the field, in Speed order.
|
|
169
|
+
*
|
|
170
|
+
* Unlike `eachEvent`, this contains a lot of other handling and is intended only for the residual step.
|
|
171
|
+
*/
|
|
172
|
+
residualEvent(eventid: string, relayVar?: any): void;
|
|
173
|
+
/** The entire event system revolves around this function and runEvent. */
|
|
174
|
+
singleEvent(eventid: string, effect: Effect, state: AnyObject | null, target: string | Pokemon | Side | Field | Battle | null, source?: string | Pokemon | Effect | false | null, sourceEffect?: Effect | string | null, relayVar?: any, customCallback?: unknown): any;
|
|
175
|
+
/**
|
|
176
|
+
* runEvent is the core of Pokemon Showdown's event system.
|
|
177
|
+
*
|
|
178
|
+
* Basic usage
|
|
179
|
+
* ===========
|
|
180
|
+
*
|
|
181
|
+
* this.runEvent('Blah')
|
|
182
|
+
* will trigger any onBlah global event handlers.
|
|
183
|
+
*
|
|
184
|
+
* this.runEvent('Blah', target)
|
|
185
|
+
* will additionally trigger any onBlah handlers on the target, onAllyBlah
|
|
186
|
+
* handlers on any active pokemon on the target's team, and onFoeBlah
|
|
187
|
+
* handlers on any active pokemon on the target's foe's team
|
|
188
|
+
*
|
|
189
|
+
* this.runEvent('Blah', target, source)
|
|
190
|
+
* will additionally trigger any onSourceBlah handlers on the source
|
|
191
|
+
*
|
|
192
|
+
* this.runEvent('Blah', target, source, effect)
|
|
193
|
+
* will additionally pass the effect onto all event handlers triggered
|
|
194
|
+
*
|
|
195
|
+
* this.runEvent('Blah', target, source, effect, relayVar)
|
|
196
|
+
* will additionally pass the relayVar as the first argument along all event
|
|
197
|
+
* handlers
|
|
198
|
+
*
|
|
199
|
+
* You may leave any of these null. For instance, if you have a relayVar but
|
|
200
|
+
* no source or effect:
|
|
201
|
+
* this.runEvent('Damage', target, null, null, 50)
|
|
202
|
+
*
|
|
203
|
+
* Event handlers
|
|
204
|
+
* ==============
|
|
205
|
+
*
|
|
206
|
+
* Items, abilities, statuses, and other effects like SR, confusion, weather,
|
|
207
|
+
* or Trick Room can have event handlers. Event handlers are functions that
|
|
208
|
+
* can modify what happens during an event.
|
|
209
|
+
*
|
|
210
|
+
* event handlers are passed:
|
|
211
|
+
* function (target, source, effect)
|
|
212
|
+
* although some of these can be blank.
|
|
213
|
+
*
|
|
214
|
+
* certain events have a relay variable, in which case they're passed:
|
|
215
|
+
* function (relayVar, target, source, effect)
|
|
216
|
+
*
|
|
217
|
+
* Relay variables are variables that give additional information about the
|
|
218
|
+
* event. For instance, the damage event has a relayVar which is the amount
|
|
219
|
+
* of damage dealt.
|
|
220
|
+
*
|
|
221
|
+
* If a relay variable isn't passed to runEvent, there will still be a secret
|
|
222
|
+
* relayVar defaulting to `true`, but it won't get passed to any event
|
|
223
|
+
* handlers.
|
|
224
|
+
*
|
|
225
|
+
* After an event handler is run, its return value helps determine what
|
|
226
|
+
* happens next:
|
|
227
|
+
* 1. If the return value isn't `undefined`, relayVar is set to the return
|
|
228
|
+
* value
|
|
229
|
+
* 2. If relayVar is falsy, no more event handlers are run
|
|
230
|
+
* 3. Otherwise, if there are more event handlers, the next one is run and
|
|
231
|
+
* we go back to step 1.
|
|
232
|
+
* 4. Once all event handlers are run (or one of them results in a falsy
|
|
233
|
+
* relayVar), relayVar is returned by runEvent
|
|
234
|
+
*
|
|
235
|
+
* As a shortcut, an event handler that isn't a function will be interpreted
|
|
236
|
+
* as a function that returns that value.
|
|
237
|
+
*
|
|
238
|
+
* You can have return values mean whatever you like, but in general, we
|
|
239
|
+
* follow the convention that returning `false` or `null` means
|
|
240
|
+
* stopping or interrupting the event.
|
|
241
|
+
*
|
|
242
|
+
* For instance, returning `false` from a TrySetStatus handler means that
|
|
243
|
+
* the pokemon doesn't get statused.
|
|
244
|
+
*
|
|
245
|
+
* If a failed event usually results in a message like "But it failed!"
|
|
246
|
+
* or "It had no effect!", returning `null` will suppress that message and
|
|
247
|
+
* returning `false` will display it. Returning `null` is useful if your
|
|
248
|
+
* event handler already gave its own custom failure message.
|
|
249
|
+
*
|
|
250
|
+
* Returning `undefined` means "don't change anything" or "keep going".
|
|
251
|
+
* A function that does nothing but return `undefined` is the equivalent
|
|
252
|
+
* of not having an event handler at all.
|
|
253
|
+
*
|
|
254
|
+
* Returning a value means that that value is the new `relayVar`. For
|
|
255
|
+
* instance, if a Damage event handler returns 50, the damage event
|
|
256
|
+
* will deal 50 damage instead of whatever it was going to deal before.
|
|
257
|
+
*
|
|
258
|
+
* Useful values
|
|
259
|
+
* =============
|
|
260
|
+
*
|
|
261
|
+
* In addition to all the methods and attributes of Dex, Battle, and
|
|
262
|
+
* Scripts, event handlers have some additional values they can access:
|
|
263
|
+
*
|
|
264
|
+
* this.effect:
|
|
265
|
+
* the Effect having the event handler
|
|
266
|
+
* this.effectState:
|
|
267
|
+
* the data store associated with the above Effect. This is a plain Object
|
|
268
|
+
* and you can use it to store data for later event handlers.
|
|
269
|
+
* this.effectState.target:
|
|
270
|
+
* the Pokemon, Side, or Battle that the event handler's effect was
|
|
271
|
+
* attached to.
|
|
272
|
+
* this.event.id:
|
|
273
|
+
* the event ID
|
|
274
|
+
* this.event.target, this.event.source, this.event.effect:
|
|
275
|
+
* the target, source, and effect of the event. These are the same
|
|
276
|
+
* variables that are passed as arguments to the event handler, but
|
|
277
|
+
* they're useful for functions called by the event handler.
|
|
278
|
+
*/
|
|
279
|
+
runEvent(eventid: string, target?: Pokemon | Pokemon[] | Side | Battle | null, source?: string | Pokemon | false | null, sourceEffect?: Effect | null, relayVar?: any, onEffect?: boolean, fastExit?: boolean): any;
|
|
280
|
+
/**
|
|
281
|
+
* priorityEvent works just like runEvent, except it exits and returns
|
|
282
|
+
* on the first non-undefined value instead of only on null/false.
|
|
283
|
+
*/
|
|
284
|
+
priorityEvent(eventid: string, target: Pokemon | Side | Battle, source?: Pokemon | null, effect?: Effect, relayVar?: any, onEffect?: boolean): any;
|
|
285
|
+
resolvePriority(handler: EventListenerWithoutPriority, callbackName: string): EventListener;
|
|
286
|
+
findEventHandlers(target: Pokemon | Pokemon[] | Side | Battle, eventName: string, source?: Pokemon | null): EventListener[];
|
|
287
|
+
findPokemonEventHandlers(pokemon: Pokemon, callbackName: string, getKey?: 'duration'): EventListener[];
|
|
288
|
+
findBattleEventHandlers(callbackName: string, getKey?: 'duration'): EventListener[];
|
|
289
|
+
findFieldEventHandlers(field: Field, callbackName: string, getKey?: 'duration', customHolder?: Pokemon): EventListener[];
|
|
290
|
+
findSideEventHandlers(side: Side, callbackName: string, getKey?: 'duration', customHolder?: Pokemon): EventListener[];
|
|
291
|
+
/**
|
|
292
|
+
* Use this function to attach custom event handlers to a battle. See Battle#runEvent for
|
|
293
|
+
* more information on how to write callbacks for event handlers.
|
|
294
|
+
*
|
|
295
|
+
* Try to use this sparingly. Most event handlers can be simply placed in a format instead.
|
|
296
|
+
*
|
|
297
|
+
* this.onEvent(eventid, target, callback)
|
|
298
|
+
* will set the callback as an event handler for the target when eventid is called with the
|
|
299
|
+
* default priority. Currently only valid formats are supported as targets but this will
|
|
300
|
+
* eventually be expanded to support other target types.
|
|
301
|
+
*
|
|
302
|
+
* this.onEvent(eventid, target, priority, callback)
|
|
303
|
+
* will set the callback as an event handler for the target when eventid is called with the
|
|
304
|
+
* provided priority. Priority can either be a number or an object that contains the priority,
|
|
305
|
+
* order, and subOrder for the event handler as needed (undefined keys will use default values)
|
|
306
|
+
*/
|
|
307
|
+
onEvent(eventid: string, target: Format, ...rest: AnyObject[]): void;
|
|
308
|
+
checkMoveMakesContact(move: ActiveMove, attacker: Pokemon, defender: Pokemon, announcePads?: boolean): false | 1 | undefined;
|
|
309
|
+
getPokemon(fullname: string | Pokemon): Pokemon | null;
|
|
310
|
+
getAllPokemon(): Pokemon[];
|
|
311
|
+
getAllActive(): Pokemon[];
|
|
312
|
+
makeRequest(type?: RequestState): void;
|
|
313
|
+
clearRequest(): void;
|
|
314
|
+
getRequests(type: RequestState): AnyObject[];
|
|
315
|
+
tiebreak(): boolean;
|
|
316
|
+
forceWin(side?: SideID | null): boolean;
|
|
317
|
+
tie(): boolean;
|
|
318
|
+
win(side?: SideID | '' | Side | null): boolean;
|
|
319
|
+
lose(side: SideID | Side): boolean | undefined;
|
|
320
|
+
canSwitch(side: Side): number;
|
|
321
|
+
getRandomSwitchable(side: Side): Pokemon | null;
|
|
322
|
+
private possibleSwitches;
|
|
323
|
+
swapPosition(pokemon: Pokemon, newPosition: number, attributes?: string): boolean;
|
|
324
|
+
getAtSlot(slot: PokemonSlot): Pokemon;
|
|
325
|
+
getAtSlot(slot: PokemonSlot | null): Pokemon | null;
|
|
326
|
+
faint(pokemon: Pokemon, source?: Pokemon, effect?: Effect): void;
|
|
327
|
+
nextTurn(): void;
|
|
328
|
+
maybeTriggerEndlessBattleClause(trappedBySide: boolean[], stalenessBySide: ('internal' | 'external' | undefined)[]): boolean | undefined;
|
|
329
|
+
start(): void;
|
|
330
|
+
restart(send?: (type: string, data: string | string[]) => void): void;
|
|
331
|
+
checkEVBalance(): void;
|
|
332
|
+
boost(boost: SparseBoostsTable, target?: Pokemon | null, source?: Pokemon | null, effect?: Effect | null, isSecondary?: boolean, isSelf?: boolean): boolean | 0 | null;
|
|
333
|
+
spreadDamage(damage: SpreadMoveDamage, targetArray?: (false | Pokemon | null)[] | null, source?: Pokemon | null, effect?: 'drain' | 'recoil' | Effect | null, instafaint?: boolean): (number | false | undefined)[];
|
|
334
|
+
damage(damage: number, target?: Pokemon | null, source?: Pokemon | null, effect?: 'drain' | 'recoil' | Effect | null, instafaint?: boolean): number | false | undefined;
|
|
335
|
+
directDamage(damage: number, target?: Pokemon, source?: Pokemon | null, effect?: Effect | null): number;
|
|
336
|
+
heal(damage: number, target?: Pokemon, source?: Pokemon | null, effect?: 'drain' | Effect | null): number | false;
|
|
337
|
+
chain(previousMod: number | number[], nextMod: number | number[]): number;
|
|
338
|
+
chainModify(numerator: number | number[], denominator?: number): void;
|
|
339
|
+
modify(value: number, numerator: number | number[], denominator?: number): number;
|
|
340
|
+
/** Given a table of base stats and a pokemon set, return the actual stats. */
|
|
341
|
+
spreadModify(baseStats: StatsTable, set: PokemonSet): StatsTable;
|
|
342
|
+
natureModify(stats: StatsTable, set: PokemonSet): StatsTable;
|
|
343
|
+
finalModify(relayVar: number): number;
|
|
344
|
+
getCategory(move: string | Move): Move['category'];
|
|
345
|
+
randomizer(baseDamage: number): number;
|
|
346
|
+
/**
|
|
347
|
+
* Returns whether a proposed target for a move is valid.
|
|
348
|
+
*/
|
|
349
|
+
validTargetLoc(targetLoc: number, source: Pokemon, targetType: string): boolean;
|
|
350
|
+
validTarget(target: Pokemon, source: Pokemon, targetType: string): boolean;
|
|
351
|
+
getTarget(pokemon: Pokemon, move: string | Move, targetLoc: number, originalTarget?: Pokemon): Pokemon | null;
|
|
352
|
+
getRandomTarget(pokemon: Pokemon, move: string | Move): Pokemon | null;
|
|
353
|
+
checkFainted(): void;
|
|
354
|
+
faintMessages(lastFirst?: boolean, forceCheck?: boolean, checkWin?: boolean): boolean | undefined;
|
|
355
|
+
checkWin(faintData?: Battle['faintQueue'][0]): true | undefined;
|
|
356
|
+
getActionSpeed(action: AnyObject): void;
|
|
357
|
+
runAction(action: Action): boolean | undefined;
|
|
358
|
+
go(): void;
|
|
359
|
+
/**
|
|
360
|
+
* Takes a choice string passed from the client. Starts the next
|
|
361
|
+
* turn if all required choices have been made.
|
|
362
|
+
*/
|
|
363
|
+
choose(sideid: SideID, input: string): boolean;
|
|
364
|
+
/**
|
|
365
|
+
* Convenience method for easily making choices.
|
|
366
|
+
*/
|
|
367
|
+
makeChoices(...inputs: string[]): void;
|
|
368
|
+
commitDecisions(): void;
|
|
369
|
+
undoChoice(sideid: SideID): void;
|
|
370
|
+
/**
|
|
371
|
+
* returns true if both decisions are complete
|
|
372
|
+
*/
|
|
373
|
+
allChoicesDone(): boolean;
|
|
374
|
+
hint(hint: string, once?: boolean, side?: Side): void;
|
|
375
|
+
addSplit(side: SideID, secret: Part[], shared?: Part[]): void;
|
|
376
|
+
add(...parts: (Part | (() => {
|
|
377
|
+
side: SideID;
|
|
378
|
+
secret: string;
|
|
379
|
+
shared: string;
|
|
380
|
+
}))[]): void;
|
|
381
|
+
addMove(...args: (string | number | Function | AnyObject)[]): void;
|
|
382
|
+
attrLastMove(...args: (string | number | Function | AnyObject)[]): void;
|
|
383
|
+
retargetLastMove(newTarget: Pokemon): void;
|
|
384
|
+
debug(activity: string): void;
|
|
385
|
+
getDebugLog(): string;
|
|
386
|
+
debugError(activity: string): void;
|
|
387
|
+
getTeam(options: PlayerOptions): PokemonSet[];
|
|
388
|
+
showOpenTeamSheets(hideFromSpectators?: boolean): void;
|
|
389
|
+
setPlayer(slot: SideID, options: PlayerOptions): void;
|
|
390
|
+
/** @deprecated */
|
|
391
|
+
join(slot: SideID, name: string, avatar: string, team: PokemonSet[] | string | null): Side;
|
|
392
|
+
sendUpdates(): void;
|
|
393
|
+
getSide(sideid: SideID): Side;
|
|
394
|
+
destroy(): void;
|
|
395
|
+
}
|
|
396
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { AnyObject, Battle, ConditionData, Field, ID, ModdedDex, Pokemon, Side } from './exported-global-types';
|
|
2
|
+
import { PokemonEventMethods } from './dex-conditions';
|
|
3
|
+
import { BasicEffect } from './dex-data';
|
|
4
|
+
interface AbilityEventMethods {
|
|
5
|
+
onCheckShow?: (this: Battle, pokemon: Pokemon) => void;
|
|
6
|
+
onEnd?: (this: Battle, target: Pokemon & Side & Field) => void;
|
|
7
|
+
onPreStart?: (this: Battle, pokemon: Pokemon) => void;
|
|
8
|
+
onStart?: (this: Battle, target: Pokemon) => void;
|
|
9
|
+
}
|
|
10
|
+
export interface AbilityData extends Partial<Ability>, AbilityEventMethods, PokemonEventMethods {
|
|
11
|
+
name: string;
|
|
12
|
+
}
|
|
13
|
+
export type ModdedAbilityData = AbilityData | Partial<AbilityData> & {
|
|
14
|
+
inherit: true;
|
|
15
|
+
};
|
|
16
|
+
export declare class Ability extends BasicEffect implements Readonly<BasicEffect> {
|
|
17
|
+
readonly effectType: 'Ability';
|
|
18
|
+
/** Rating from -1 Detrimental to +5 Essential; see `data/abilities.ts` for details. */
|
|
19
|
+
readonly rating: number;
|
|
20
|
+
readonly suppressWeather: boolean;
|
|
21
|
+
readonly condition?: ConditionData;
|
|
22
|
+
readonly isPermanent?: boolean;
|
|
23
|
+
readonly isBreakable?: boolean;
|
|
24
|
+
constructor(data: AnyObject);
|
|
25
|
+
}
|
|
26
|
+
export declare class DexAbilities {
|
|
27
|
+
readonly dex: ModdedDex;
|
|
28
|
+
readonly abilityCache: Map<ID, Ability>;
|
|
29
|
+
allCache: readonly Ability[] | null;
|
|
30
|
+
constructor(dex: ModdedDex);
|
|
31
|
+
get(name?: string | Ability): Ability;
|
|
32
|
+
getByID(id: ID): Ability;
|
|
33
|
+
all(): readonly Ability[];
|
|
34
|
+
}
|
|
35
|
+
export {};
|